blob: ac16d799c1bd185f8213e44630d40d51af37e209 [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 Moolenaar40e6a712010-05-16 22:32:54 +020080#define PV_CM 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)
143#ifdef FEAT_OSFILETYPE
144# define PV_OFT OPT_BUF(BV_OFT)
145#endif
146#ifdef FEAT_COMPL_FUNC
147# define PV_OFU OPT_BUF(BV_OFU)
148#endif
149#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
150#define PV_PI OPT_BUF(BV_PI)
151#ifdef FEAT_TEXTOBJ
152# define PV_QE OPT_BUF(BV_QE)
153#endif
154#define PV_RO OPT_BUF(BV_RO)
155#ifdef FEAT_SMARTINDENT
156# define PV_SI OPT_BUF(BV_SI)
157#endif
158#ifndef SHORT_FNAME
159# define PV_SN OPT_BUF(BV_SN)
160#endif
161#ifdef FEAT_SYN_HL
162# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000163# define PV_SYN OPT_BUF(BV_SYN)
164#endif
165#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166# define PV_SPC OPT_BUF(BV_SPC)
167# define PV_SPF OPT_BUF(BV_SPF)
168# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000169#endif
170#define PV_STS OPT_BUF(BV_STS)
171#ifdef FEAT_SEARCHPATH
172# define PV_SUA OPT_BUF(BV_SUA)
173#endif
174#define PV_SW OPT_BUF(BV_SW)
175#define PV_SWF OPT_BUF(BV_SWF)
176#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
177#define PV_TS OPT_BUF(BV_TS)
178#define PV_TW OPT_BUF(BV_TW)
179#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200180#ifdef FEAT_PERSISTENT_UNDO
181# define PV_UDF OPT_BUF(BV_UDF)
182#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000183#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000184
185/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186 * Definition of the PV_ values for window-local options.
187 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189#define PV_LIST OPT_WIN(WV_LIST)
190#ifdef FEAT_ARABIC
191# define PV_ARAB OPT_WIN(WV_ARAB)
192#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000193#ifdef FEAT_DIFF
194# define PV_DIFF OPT_WIN(WV_DIFF)
195#endif
196#ifdef FEAT_FOLDING
197# define PV_FDC OPT_WIN(WV_FDC)
198# define PV_FEN OPT_WIN(WV_FEN)
199# define PV_FDI OPT_WIN(WV_FDI)
200# define PV_FDL OPT_WIN(WV_FDL)
201# define PV_FDM OPT_WIN(WV_FDM)
202# define PV_FML OPT_WIN(WV_FML)
203# define PV_FDN OPT_WIN(WV_FDN)
204# ifdef FEAT_EVAL
205# define PV_FDE OPT_WIN(WV_FDE)
206# define PV_FDT OPT_WIN(WV_FDT)
207# endif
208# define PV_FMR OPT_WIN(WV_FMR)
209#endif
210#ifdef FEAT_LINEBREAK
211# define PV_LBR OPT_WIN(WV_LBR)
212#endif
213#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200214#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000215#ifdef FEAT_LINEBREAK
216# define PV_NUW OPT_WIN(WV_NUW)
217#endif
218#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
219# define PV_PVW OPT_WIN(WV_PVW)
220#endif
221#ifdef FEAT_RIGHTLEFT
222# define PV_RL OPT_WIN(WV_RL)
223# define PV_RLC OPT_WIN(WV_RLC)
224#endif
225#ifdef FEAT_SCROLLBIND
226# define PV_SCBIND OPT_WIN(WV_SCBIND)
227#endif
228#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000229#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000230# define PV_SPELL OPT_WIN(WV_SPELL)
231#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000232#ifdef FEAT_SYN_HL
233# define PV_CUC OPT_WIN(WV_CUC)
234# define PV_CUL OPT_WIN(WV_CUL)
235#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000236#ifdef FEAT_STL_OPT
237# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
238#endif
239#ifdef FEAT_WINDOWS
240# define PV_WFH OPT_WIN(WV_WFH)
241#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000242#ifdef FEAT_VERTSPLIT
243# define PV_WFW OPT_WIN(WV_WFW)
244#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000245#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200246#ifdef FEAT_CURSORBIND
247# define PV_CRBIND OPT_WIN(WV_CRBIND)
248#endif
249#ifdef FEAT_CONCEAL
250# define PV_CONCEAL OPT_WIN(WV_CONCEAL)
251#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000252
253/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000254typedef enum
255{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000256 PV_NONE = 0,
257 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258} idopt_T;
259
260/*
261 * Options local to a window have a value local to a buffer and global to all
262 * buffers. Indicate this by setting "var" to VAR_WIN.
263 */
264#define VAR_WIN ((char_u *)-1)
265
266/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000267 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268 * Only to be used in option.c!
269 */
270static int p_ai;
271static int p_bin;
272#ifdef FEAT_MBYTE
273static int p_bomb;
274#endif
275#if defined(FEAT_QUICKFIX)
276static char_u *p_bh;
277static char_u *p_bt;
278#endif
279static int p_bl;
280static int p_ci;
281#ifdef FEAT_CINDENT
282static int p_cin;
283static char_u *p_cink;
284static char_u *p_cino;
285#endif
286#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
287static char_u *p_cinw;
288#endif
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200289#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200290static long p_cm;
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200291#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292#ifdef FEAT_COMMENTS
293static char_u *p_com;
294#endif
295#ifdef FEAT_FOLDING
296static char_u *p_cms;
297#endif
298#ifdef FEAT_INS_EXPAND
299static char_u *p_cpt;
300#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000301#ifdef FEAT_COMPL_FUNC
302static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000303static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000304#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000305static int p_eol;
306static int p_et;
307#ifdef FEAT_MBYTE
308static char_u *p_fenc;
309#endif
310static char_u *p_ff;
311static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000312static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313#ifdef FEAT_AUTOCMD
314static char_u *p_ft;
315#endif
316static long p_iminsert;
317static long p_imsearch;
318#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
319static char_u *p_inex;
320#endif
321#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
322static char_u *p_inde;
323static char_u *p_indk;
324#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000325#if defined(FEAT_EVAL)
326static char_u *p_fex;
327#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000328static int p_inf;
329static char_u *p_isk;
330#ifdef FEAT_CRYPT
331static char_u *p_key;
332#endif
333#ifdef FEAT_LISP
334static int p_lisp;
335#endif
336static int p_ml;
337static int p_ma;
338static int p_mod;
339static char_u *p_mps;
340static char_u *p_nf;
341#ifdef FEAT_OSFILETYPE
342static char_u *p_oft;
343#endif
344static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000345#ifdef FEAT_TEXTOBJ
346static char_u *p_qe;
347#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000348static int p_ro;
349#ifdef FEAT_SMARTINDENT
350static int p_si;
351#endif
352#ifndef SHORT_FNAME
353static int p_sn;
354#endif
355static long p_sts;
356#if defined(FEAT_SEARCHPATH)
357static char_u *p_sua;
358#endif
359static long p_sw;
360static int p_swf;
361#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000362static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000364#endif
365#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000366static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000367static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000368static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369#endif
370static long p_ts;
371static long p_tw;
372static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200373#ifdef FEAT_PERSISTENT_UNDO
374static int p_udf;
375#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376static long p_wm;
377#ifdef FEAT_KEYMAP
378static char_u *p_keymap;
379#endif
380
381/* Saved values for when 'bin' is set. */
382static int p_et_nobin;
383static int p_ml_nobin;
384static long p_tw_nobin;
385static long p_wm_nobin;
386
387/* Saved values for when 'paste' is set */
388static long p_tw_nopaste;
389static long p_wm_nopaste;
390static long p_sts_nopaste;
391static int p_ai_nopaste;
392
393struct vimoption
394{
395 char *fullname; /* full option name */
396 char *shortname; /* permissible abbreviation */
397 long_u flags; /* see below */
398 char_u *var; /* global option: pointer to variable;
399 * window-local option: VAR_WIN;
400 * buffer-local option: global value */
401 idopt_T indir; /* global option: PV_NONE;
402 * local option: indirect option index */
403 char_u *def_val[2]; /* default values for variable (vi and vim) */
404#ifdef FEAT_EVAL
405 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000406# define SCRIPTID_INIT , 0
407#else
408# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000409#endif
410};
411
412#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
413#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
414
415/*
416 * Flags
417 */
418#define P_BOOL 0x01 /* the option is boolean */
419#define P_NUM 0x02 /* the option is numeric */
420#define P_STRING 0x04 /* the option is a string */
421#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000422 must use free_string_option() when
423 assigning new value. Not set if default is
424 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
426 never be used for local or hidden options! */
427#define P_NODEFAULT 0x40 /* don't set to default value */
428#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
429 use vim_free() when assigning new value */
430#define P_WAS_SET 0x100 /* option has been set/reset */
431#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
432#define P_VI_DEF 0x400 /* Use Vi default for Vim */
433#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
434
435 /* when option changed, what to display: */
436#define P_RSTAT 0x1000 /* redraw status lines */
437#define P_RWIN 0x2000 /* redraw current window */
438#define P_RBUF 0x4000 /* redraw current buffer */
439#define P_RALL 0x6000 /* redraw all windows */
440#define P_RCLR 0x7000 /* clear and redraw all */
441
442#define P_COMMA 0x8000 /* comma separated list */
443#define P_NODUP 0x10000L/* don't allow duplicate strings */
444#define P_FLAGLIST 0x20000L/* list of single-char flags */
445
446#define P_SECURE 0x40000L/* cannot change in modeline or secure mode */
447#define P_GETTEXT 0x80000L/* expand default value with _() */
448#define P_NOGLOB 0x100000L/* do not use local value for global vimrc */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000449#define P_NFNAME 0x200000L/* only normal file name chars allowed */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +0000450#define P_INSECURE 0x400000L/* option was set from a modeline */
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000451#define P_PRI_MKRC 0x800000L/* priority for :mkvimrc (setting option has
452 side effects) */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000453
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000454#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
455
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000456/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
457 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000458#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000459# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000460#else
461# define ISP_LATIN1 (char_u *)"@,161-255"
462#endif
463
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000464/* The 16 bit MS-DOS version is low on space, make the string as short as
465 * possible when compiling with few features. */
466#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
467 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200468 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
469# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,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"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000470#else
471# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
472#endif
473
Bram Moolenaar071d4272004-06-13 20:20:40 +0000474/*
475 * options[] is initialized here.
476 * The order of the options MUST be alphabetic for ":set all" and findoption().
477 * All option names MUST start with a lowercase letter (for findoption()).
478 * Exception: "t_" options are at the end.
479 * The options with a NULL variable are 'hidden': a set command for them is
480 * ignored and they are not printed.
481 */
482static struct vimoption
483#ifdef FEAT_GUI_W16
484 _far
485#endif
486 options[] =
487{
488 {"aleph", "al", P_NUM|P_VI_DEF,
489#ifdef FEAT_RIGHTLEFT
490 (char_u *)&p_aleph, PV_NONE,
491#else
492 (char_u *)NULL, PV_NONE,
493#endif
494 {
495#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
496 (char_u *)128L,
497#else
498 (char_u *)224L,
499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000500 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000501 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
502#if defined(FEAT_GUI) && defined(MACOS_X)
503 (char_u *)&p_antialias, PV_NONE,
504 {(char_u *)FALSE, (char_u *)FALSE}
505#else
506 (char_u *)NULL, PV_NONE,
507 {(char_u *)FALSE, (char_u *)FALSE}
508#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000509 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000510 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
511#ifdef FEAT_ARABIC
512 (char_u *)VAR_WIN, PV_ARAB,
513#else
514 (char_u *)NULL, PV_NONE,
515#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000516 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000517 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
518#ifdef FEAT_ARABIC
519 (char_u *)&p_arshape, PV_NONE,
520#else
521 (char_u *)NULL, PV_NONE,
522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000523 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
525#ifdef FEAT_RIGHTLEFT
526 (char_u *)&p_ari, PV_NONE,
527#else
528 (char_u *)NULL, PV_NONE,
529#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000530 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
532#ifdef FEAT_FKMAP
533 (char_u *)&p_altkeymap, PV_NONE,
534#else
535 (char_u *)NULL, PV_NONE,
536#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000537 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
539#if defined(FEAT_MBYTE)
540 (char_u *)&p_ambw, PV_NONE,
541 {(char_u *)"single", (char_u *)0L}
542#else
543 (char_u *)NULL, PV_NONE,
544 {(char_u *)0L, (char_u *)0L}
545#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000546 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000547#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000548 {"autochdir", "acd", P_BOOL|P_VI_DEF,
549 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000551#endif
552 {"autoindent", "ai", P_BOOL|P_VI_DEF,
553 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000554 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 {"autoprint", "ap", P_BOOL|P_VI_DEF,
556 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000559 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000560 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561 {"autowrite", "aw", P_BOOL|P_VI_DEF,
562 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000563 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000564 {"autowriteall","awa", P_BOOL|P_VI_DEF,
565 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000566 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
568 (char_u *)&p_bg, PV_NONE,
569 {
570#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
571 (char_u *)"dark",
572#else
573 (char_u *)"light",
574#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000575 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
577 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000578 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
580 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000581 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000582 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
583 (char_u *)&p_bkc, PV_NONE,
584#ifdef UNIX
585 {(char_u *)"yes", (char_u *)"auto"}
586#else
587 {(char_u *)"auto", (char_u *)"auto"}
588#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000589 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
591 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000592 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000593 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 (char_u *)&p_bex, PV_NONE,
595 {
596#ifdef VMS
597 (char_u *)"_",
598#else
599 (char_u *)"~",
600#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000601 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
603#ifdef FEAT_WILDIGN
604 (char_u *)&p_bsk, PV_NONE,
605 {(char_u *)"", (char_u *)0L}
606#else
607 (char_u *)NULL, PV_NONE,
608 {(char_u *)0L, (char_u *)0L}
609#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000610 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611#ifdef FEAT_BEVAL
612 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
613 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000614 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
616 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000617 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000618# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000619 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000620 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000621 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000622# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623#endif
624 {"beautify", "bf", P_BOOL|P_VI_DEF,
625 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000626 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
628 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
631#ifdef MSDOS
632 (char_u *)&p_biosk, PV_NONE,
633#else
634 (char_u *)NULL, PV_NONE,
635#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000636 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
638#ifdef FEAT_MBYTE
639 (char_u *)&p_bomb, PV_BOMB,
640#else
641 (char_u *)NULL, PV_NONE,
642#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000643 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000644 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
645#ifdef FEAT_LINEBREAK
646 (char_u *)&p_breakat, PV_NONE,
647 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
648#else
649 (char_u *)NULL, PV_NONE,
650 {(char_u *)0L, (char_u *)0L}
651#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000652 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000653 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
654#ifdef FEAT_BROWSE
655 (char_u *)&p_bsdir, PV_NONE,
656 {(char_u *)"last", (char_u *)0L}
657#else
658 (char_u *)NULL, PV_NONE,
659 {(char_u *)0L, (char_u *)0L}
660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000661 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
663#if defined(FEAT_QUICKFIX)
664 (char_u *)&p_bh, PV_BH,
665 {(char_u *)"", (char_u *)0L}
666#else
667 (char_u *)NULL, PV_NONE,
668 {(char_u *)0L, (char_u *)0L}
669#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000670 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
672 (char_u *)&p_bl, PV_BL,
673 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000674 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
676#if defined(FEAT_QUICKFIX)
677 (char_u *)&p_bt, PV_BT,
678 {(char_u *)"", (char_u *)0L}
679#else
680 (char_u *)NULL, PV_NONE,
681 {(char_u *)0L, (char_u *)0L}
682#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000683 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000684 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000685#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000686 (char_u *)&p_cmp, PV_NONE,
687 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000688#else
689 (char_u *)NULL, PV_NONE,
690 {(char_u *)0L, (char_u *)0L}
691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000692 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000693 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
694#ifdef FEAT_SEARCHPATH
695 (char_u *)&p_cdpath, PV_NONE,
696 {(char_u *)",,", (char_u *)0L}
697#else
698 (char_u *)NULL, PV_NONE,
699 {(char_u *)0L, (char_u *)0L}
700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000701 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000702 {"cedit", NULL, P_STRING,
703#ifdef FEAT_CMDWIN
704 (char_u *)&p_cedit, PV_NONE,
705 {(char_u *)"", (char_u *)CTRL_F_STR}
706#else
707 (char_u *)NULL, PV_NONE,
708 {(char_u *)0L, (char_u *)0L}
709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000710 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000711 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
712#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
713 (char_u *)&p_ccv, PV_NONE,
714 {(char_u *)"", (char_u *)0L}
715#else
716 (char_u *)NULL, PV_NONE,
717 {(char_u *)0L, (char_u *)0L}
718#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000719 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000720 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
721#ifdef FEAT_CINDENT
722 (char_u *)&p_cin, PV_CIN,
723#else
724 (char_u *)NULL, PV_NONE,
725#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000726 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000727 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
728#ifdef FEAT_CINDENT
729 (char_u *)&p_cink, PV_CINK,
730 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
731#else
732 (char_u *)NULL, PV_NONE,
733 {(char_u *)0L, (char_u *)0L}
734#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000735 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000736 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
737#ifdef FEAT_CINDENT
738 (char_u *)&p_cino, PV_CINO,
739#else
740 (char_u *)NULL, PV_NONE,
741#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000742 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000743 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
744#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
745 (char_u *)&p_cinw, PV_CINW,
746 {(char_u *)"if,else,while,do,for,switch",
747 (char_u *)0L}
748#else
749 (char_u *)NULL, PV_NONE,
750 {(char_u *)0L, (char_u *)0L}
751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000753 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
754#ifdef FEAT_CLIPBOARD
755 (char_u *)&p_cb, PV_NONE,
756# ifdef FEAT_XCLIPBOARD
757 {(char_u *)"autoselect,exclude:cons\\|linux",
758 (char_u *)0L}
759# else
760 {(char_u *)"", (char_u *)0L}
761# endif
762#else
763 (char_u *)NULL, PV_NONE,
764 {(char_u *)"", (char_u *)0L}
765#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000766 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
768 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000769 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000770 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
771#ifdef FEAT_CMDWIN
772 (char_u *)&p_cwh, PV_NONE,
773#else
774 (char_u *)NULL, PV_NONE,
775#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000776 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000777 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
778 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000779 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000780 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
781#ifdef FEAT_COMMENTS
782 (char_u *)&p_com, PV_COM,
783 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
784 (char_u *)0L}
785#else
786 (char_u *)NULL, PV_NONE,
787 {(char_u *)0L, (char_u *)0L}
788#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000789 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000790 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
791#ifdef FEAT_FOLDING
792 (char_u *)&p_cms, PV_CMS,
793 {(char_u *)"/*%s*/", (char_u *)0L}
794#else
795 (char_u *)NULL, PV_NONE,
796 {(char_u *)0L, (char_u *)0L}
797#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000798 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000799 /* P_PRI_MKRC isn't needed here, optval_default()
800 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000801 {"compatible", "cp", P_BOOL|P_RALL,
802 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000803 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000804 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
805#ifdef FEAT_INS_EXPAND
806 (char_u *)&p_cpt, PV_CPT,
807 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
808#else
809 (char_u *)NULL, PV_NONE,
810 {(char_u *)0L, (char_u *)0L}
811#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000812 SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200813 {"conceallevel","conc", P_NUM|P_RWIN|P_VI_DEF,
814#ifdef FEAT_CONCEAL
815 (char_u *)VAR_WIN, PV_CONCEAL,
816#else
817 (char_u *)NULL, PV_NONE,
818#endif
819 {(char_u *)0L, (char_u *)0L}
820 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000821 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
822#ifdef FEAT_COMPL_FUNC
823 (char_u *)&p_cfu, PV_CFU,
824 {(char_u *)"", (char_u *)0L}
825#else
826 (char_u *)NULL, PV_NONE,
827 {(char_u *)0L, (char_u *)0L}
828#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000829 SCRIPTID_INIT},
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000830 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
831#ifdef FEAT_INS_EXPAND
832 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000833 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000834#else
835 (char_u *)NULL, PV_NONE,
836 {(char_u *)0L, (char_u *)0L}
837#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000838 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000839 {"confirm", "cf", P_BOOL|P_VI_DEF,
840#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
841 (char_u *)&p_confirm, PV_NONE,
842#else
843 (char_u *)NULL, PV_NONE,
844#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000845 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000846 {"conskey", "consk",P_BOOL|P_VI_DEF,
847#ifdef MSDOS
848 (char_u *)&p_consk, PV_NONE,
849#else
850 (char_u *)NULL, PV_NONE,
851#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000852 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000853 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
854 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000855 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000856 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
857 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000858 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
859 SCRIPTID_INIT},
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200860 {"cryptmethod", "cm", P_NUM|P_VI_DEF|P_VIM,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200861#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200862 (char_u *)&p_cm, PV_CM,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200863#else
864 (char_u *)NULL, PV_NONE,
865#endif
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200866 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000867 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
868#ifdef FEAT_CSCOPE
869 (char_u *)&p_cspc, PV_NONE,
870#else
871 (char_u *)NULL, PV_NONE,
872#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000873 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000874 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
875#ifdef FEAT_CSCOPE
876 (char_u *)&p_csprg, PV_NONE,
877 {(char_u *)"cscope", (char_u *)0L}
878#else
879 (char_u *)NULL, PV_NONE,
880 {(char_u *)0L, (char_u *)0L}
881#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000882 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000883 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
884#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
885 (char_u *)&p_csqf, PV_NONE,
886 {(char_u *)"", (char_u *)0L}
887#else
888 (char_u *)NULL, PV_NONE,
889 {(char_u *)0L, (char_u *)0L}
890#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000891 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000892 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
893#ifdef FEAT_CSCOPE
894 (char_u *)&p_cst, PV_NONE,
895#else
896 (char_u *)NULL, PV_NONE,
897#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000898 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000899 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
900#ifdef FEAT_CSCOPE
901 (char_u *)&p_csto, PV_NONE,
902#else
903 (char_u *)NULL, PV_NONE,
904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000905 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000906 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
907#ifdef FEAT_CSCOPE
908 (char_u *)&p_csverbose, PV_NONE,
909#else
910 (char_u *)NULL, PV_NONE,
911#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000912 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200913 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
914#ifdef FEAT_CURSORBIND
915 (char_u *)VAR_WIN, PV_CRBIND,
916#else
917 (char_u *)NULL, PV_NONE,
918#endif
919 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000920 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
921#ifdef FEAT_SYN_HL
922 (char_u *)VAR_WIN, PV_CUC,
923#else
924 (char_u *)NULL, PV_NONE,
925#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000926 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000927 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
928#ifdef FEAT_SYN_HL
929 (char_u *)VAR_WIN, PV_CUL,
930#else
931 (char_u *)NULL, PV_NONE,
932#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000933 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000934 {"debug", NULL, P_STRING|P_VI_DEF,
935 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000936 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000937 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF,
938#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000939 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000940 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000941#else
942 (char_u *)NULL, PV_NONE,
943 {(char_u *)NULL, (char_u *)0L}
944#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000945 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000946 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
947#ifdef FEAT_MBYTE
948 (char_u *)&p_deco, PV_NONE,
949#else
950 (char_u *)NULL, PV_NONE,
951#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000952 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000953 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
954#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000955 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000956#else
957 (char_u *)NULL, PV_NONE,
958#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000959 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000960 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
961#ifdef FEAT_DIFF
962 (char_u *)VAR_WIN, PV_DIFF,
963#else
964 (char_u *)NULL, PV_NONE,
965#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000966 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000967 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE,
968#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
969 (char_u *)&p_dex, PV_NONE,
970 {(char_u *)"", (char_u *)0L}
971#else
972 (char_u *)NULL, PV_NONE,
973 {(char_u *)0L, (char_u *)0L}
974#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000975 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000976 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
977#ifdef FEAT_DIFF
978 (char_u *)&p_dip, PV_NONE,
979 {(char_u *)"filler", (char_u *)NULL}
980#else
981 (char_u *)NULL, PV_NONE,
982 {(char_u *)"", (char_u *)NULL}
983#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000984 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000985 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
986#ifdef FEAT_DIGRAPHS
987 (char_u *)&p_dg, PV_NONE,
988#else
989 (char_u *)NULL, PV_NONE,
990#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000991 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000992 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
993 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000994 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000995 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
996 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000997 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000998 {"eadirection", "ead", P_STRING|P_VI_DEF,
999#ifdef FEAT_VERTSPLIT
1000 (char_u *)&p_ead, PV_NONE,
1001 {(char_u *)"both", (char_u *)0L}
1002#else
1003 (char_u *)NULL, PV_NONE,
1004 {(char_u *)NULL, (char_u *)0L}
1005#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001006 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1008 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001009 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR,
1011#ifdef FEAT_MBYTE
1012 (char_u *)&p_enc, PV_NONE,
1013 {(char_u *)ENC_DFLT, (char_u *)0L}
1014#else
1015 (char_u *)NULL, PV_NONE,
1016 {(char_u *)0L, (char_u *)0L}
1017#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001018 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1020 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001021 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001022 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1023 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001024 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001025 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001026 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001027 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1029 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001030 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1032#ifdef FEAT_QUICKFIX
1033 (char_u *)&p_ef, PV_NONE,
1034 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1035#else
1036 (char_u *)NULL, PV_NONE,
1037 {(char_u *)NULL, (char_u *)0L}
1038#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001039 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1041#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001042 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001043 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044#else
1045 (char_u *)NULL, PV_NONE,
1046 {(char_u *)NULL, (char_u *)0L}
1047#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001048 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 {"esckeys", "ek", P_BOOL|P_VIM,
1050 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001051 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1053#ifdef FEAT_AUTOCMD
1054 (char_u *)&p_ei, PV_NONE,
1055#else
1056 (char_u *)NULL, PV_NONE,
1057#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001058 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001059 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1060 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001061 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1063 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
1066#ifdef FEAT_MBYTE
1067 (char_u *)&p_fenc, PV_FENC,
1068 {(char_u *)"", (char_u *)0L}
1069#else
1070 (char_u *)NULL, PV_NONE,
1071 {(char_u *)0L, (char_u *)0L}
1072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
1075#ifdef FEAT_MBYTE
1076 (char_u *)&p_fencs, PV_NONE,
1077 {(char_u *)"ucs-bom", (char_u *)0L}
1078#else
1079 (char_u *)NULL, PV_NONE,
1080 {(char_u *)0L, (char_u *)0L}
1081#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC,
1084 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
1087 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001088 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1089 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001090 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001091#ifdef FEAT_AUTOCMD
1092 (char_u *)&p_ft, PV_FT,
1093 {(char_u *)"", (char_u *)0L}
1094#else
1095 (char_u *)NULL, PV_NONE,
1096 {(char_u *)0L, (char_u *)0L}
1097#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001098 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1100#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1101 (char_u *)&p_fcs, PV_NONE,
1102 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1103#else
1104 (char_u *)NULL, PV_NONE,
1105 {(char_u *)"", (char_u *)0L}
1106#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001107 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1109#ifdef FEAT_FKMAP
1110 (char_u *)&p_fkmap, PV_NONE,
1111#else
1112 (char_u *)NULL, PV_NONE,
1113#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001114 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001115 {"flash", "fl", P_BOOL|P_VI_DEF,
1116 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001117 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001118#ifdef FEAT_FOLDING
1119 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
1120 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001121 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1123 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001124 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1126 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001127 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001128 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1129# ifdef FEAT_EVAL
1130 (char_u *)VAR_WIN, PV_FDE,
1131 {(char_u *)"0", (char_u *)NULL}
1132# else
1133 (char_u *)NULL, PV_NONE,
1134 {(char_u *)NULL, (char_u *)0L}
1135# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001136 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1138 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001139 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001140 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1141 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001142 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143 {"foldlevelstart","fdls", P_NUM|P_VI_DEF,
1144 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
1147 P_RWIN|P_COMMA|P_NODUP,
1148 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001149 {(char_u *)"{{{,}}}", (char_u *)NULL}
1150 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001151 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1152 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001153 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1155 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001156 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001157 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1158 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001159 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1161 (char_u *)&p_fdo, PV_NONE,
1162 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001163 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1165# ifdef FEAT_EVAL
1166 (char_u *)VAR_WIN, PV_FDT,
1167 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001168# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001169 (char_u *)NULL, PV_NONE,
1170 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001171# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001173#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001174 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001175#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001176 (char_u *)&p_fex, PV_FEX,
1177 {(char_u *)"", (char_u *)0L}
1178#else
1179 (char_u *)NULL, PV_NONE,
1180 {(char_u *)0L, (char_u *)0L}
1181#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001182 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001183 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1184 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001185 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1186 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001187 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1188 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001189 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1190 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1192 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001194 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1195#ifdef HAVE_FSYNC
1196 (char_u *)&p_fs, PV_NONE,
1197 {(char_u *)TRUE, (char_u *)0L}
1198#else
1199 (char_u *)NULL, PV_NONE,
1200 {(char_u *)FALSE, (char_u *)0L}
1201#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001202 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1204 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001205 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206 {"graphic", "gr", P_BOOL|P_VI_DEF,
1207 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001208 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1210#ifdef FEAT_QUICKFIX
1211 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001212 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213#else
1214 (char_u *)NULL, PV_NONE,
1215 {(char_u *)NULL, (char_u *)0L}
1216#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001217 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1219#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001220 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001221 {
1222# ifdef WIN3264
1223 /* may be changed to "grep -n" in os_win32.c */
1224 (char_u *)"findstr /n",
1225# else
1226# ifdef UNIX
1227 /* Add an extra file name so that grep will always
1228 * insert a file name in the match line. */
1229 (char_u *)"grep -n $* /dev/null",
1230# else
1231# ifdef VMS
1232 (char_u *)"SEARCH/NUMBERS ",
1233# else
1234 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001235# endif
1236# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001238 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239#else
1240 (char_u *)NULL, PV_NONE,
1241 {(char_u *)NULL, (char_u *)0L}
1242#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001243 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001244 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1245#ifdef CURSOR_SHAPE
1246 (char_u *)&p_guicursor, PV_NONE,
1247 {
1248# ifdef FEAT_GUI
1249 (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",
1250# else /* MSDOS or Win32 console */
1251 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1252# endif
1253 (char_u *)0L}
1254#else
1255 (char_u *)NULL, PV_NONE,
1256 {(char_u *)NULL, (char_u *)0L}
1257#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001258 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1260#ifdef FEAT_GUI
1261 (char_u *)&p_guifont, PV_NONE,
1262 {(char_u *)"", (char_u *)0L}
1263#else
1264 (char_u *)NULL, PV_NONE,
1265 {(char_u *)NULL, (char_u *)0L}
1266#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001267 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001268 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
1269#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1270 (char_u *)&p_guifontset, PV_NONE,
1271 {(char_u *)"", (char_u *)0L}
1272#else
1273 (char_u *)NULL, PV_NONE,
1274 {(char_u *)NULL, (char_u *)0L}
1275#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001276 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1278#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1279 (char_u *)&p_guifontwide, PV_NONE,
1280 {(char_u *)"", (char_u *)0L}
1281#else
1282 (char_u *)NULL, PV_NONE,
1283 {(char_u *)NULL, (char_u *)0L}
1284#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001285 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001286 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001287#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001288 (char_u *)&p_ghr, PV_NONE,
1289#else
1290 (char_u *)NULL, PV_NONE,
1291#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001292 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001294#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001295 (char_u *)&p_go, PV_NONE,
1296# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001297 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001298# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001299 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001300# endif
1301#else
1302 (char_u *)NULL, PV_NONE,
1303 {(char_u *)NULL, (char_u *)0L}
1304#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001305 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306 {"guipty", NULL, P_BOOL|P_VI_DEF,
1307#if defined(FEAT_GUI)
1308 (char_u *)&p_guipty, PV_NONE,
1309#else
1310 (char_u *)NULL, PV_NONE,
1311#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001312 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001313 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001314#if defined(FEAT_GUI_TABLINE)
1315 (char_u *)&p_gtl, PV_NONE,
1316 {(char_u *)"", (char_u *)0L}
1317#else
1318 (char_u *)NULL, PV_NONE,
1319 {(char_u *)NULL, (char_u *)0L}
1320#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001321 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001322 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001323#if defined(FEAT_GUI_TABLINE)
1324 (char_u *)&p_gtt, PV_NONE,
1325 {(char_u *)"", (char_u *)0L}
1326#else
1327 (char_u *)NULL, PV_NONE,
1328 {(char_u *)NULL, (char_u *)0L}
1329#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001330 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1332 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001333 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001334 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1335 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001336 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1337 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338 {"helpheight", "hh", P_NUM|P_VI_DEF,
1339#ifdef FEAT_WINDOWS
1340 (char_u *)&p_hh, PV_NONE,
1341#else
1342 (char_u *)NULL, PV_NONE,
1343#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001344 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001345 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
1346#ifdef FEAT_MULTI_LANG
1347 (char_u *)&p_hlg, PV_NONE,
1348 {(char_u *)"", (char_u *)0L}
1349#else
1350 (char_u *)NULL, PV_NONE,
1351 {(char_u *)0L, (char_u *)0L}
1352#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001353 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354 {"hidden", "hid", P_BOOL|P_VI_DEF,
1355 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001356 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1358 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001359 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1360 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361 {"history", "hi", P_NUM|P_VIM,
1362 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001363 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1365#ifdef FEAT_RIGHTLEFT
1366 (char_u *)&p_hkmap, PV_NONE,
1367#else
1368 (char_u *)NULL, PV_NONE,
1369#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001370 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001371 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1372#ifdef FEAT_RIGHTLEFT
1373 (char_u *)&p_hkmapp, PV_NONE,
1374#else
1375 (char_u *)NULL, PV_NONE,
1376#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001377 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1379 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001380 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001381 {"icon", NULL, P_BOOL|P_VI_DEF,
1382#ifdef FEAT_TITLE
1383 (char_u *)&p_icon, PV_NONE,
1384#else
1385 (char_u *)NULL, PV_NONE,
1386#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001387 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001388 {"iconstring", NULL, P_STRING|P_VI_DEF,
1389#ifdef FEAT_TITLE
1390 (char_u *)&p_iconstring, PV_NONE,
1391#else
1392 (char_u *)NULL, PV_NONE,
1393#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001394 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001395 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1396 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001397 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001398 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001399#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001400 (char_u *)&p_imak, PV_NONE,
1401#else
1402 (char_u *)NULL, PV_NONE,
1403#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001404 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1406#ifdef USE_IM_CONTROL
1407 (char_u *)&p_imcmdline, PV_NONE,
1408#else
1409 (char_u *)NULL, PV_NONE,
1410#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001411 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001412 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1413#ifdef USE_IM_CONTROL
1414 (char_u *)&p_imdisable, PV_NONE,
1415#else
1416 (char_u *)NULL, PV_NONE,
1417#endif
1418#ifdef __sgi
1419 {(char_u *)TRUE, (char_u *)0L}
1420#else
1421 {(char_u *)FALSE, (char_u *)0L}
1422#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001423 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001424 {"iminsert", "imi", P_NUM|P_VI_DEF,
1425 (char_u *)&p_iminsert, PV_IMI,
1426#ifdef B_IMODE_IM
1427 {(char_u *)B_IMODE_IM, (char_u *)0L}
1428#else
1429 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1430#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001431 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001432 {"imsearch", "ims", P_NUM|P_VI_DEF,
1433 (char_u *)&p_imsearch, PV_IMS,
1434#ifdef B_IMODE_IM
1435 {(char_u *)B_IMODE_IM, (char_u *)0L}
1436#else
1437 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1438#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001439 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001440 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1441#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001442 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001443 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1444#else
1445 (char_u *)NULL, PV_NONE,
1446 {(char_u *)0L, (char_u *)0L}
1447#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001448 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001449 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1450#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1451 (char_u *)&p_inex, PV_INEX,
1452 {(char_u *)"", (char_u *)0L}
1453#else
1454 (char_u *)NULL, PV_NONE,
1455 {(char_u *)0L, (char_u *)0L}
1456#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001457 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001458 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1459 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001460 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001461 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1462#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1463 (char_u *)&p_inde, PV_INDE,
1464 {(char_u *)"", (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 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1471#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1472 (char_u *)&p_indk, PV_INDK,
1473 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (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 {"infercase", "inf", P_BOOL|P_VI_DEF,
1480 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001481 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001482 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1483 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001484 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001485 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1486 (char_u *)&p_isf, PV_NONE,
1487 {
1488#ifdef BACKSLASH_IN_FILENAME
1489 /* Excluded are: & and ^ are special in cmd.exe
1490 * ( and ) are used in text separating fnames */
1491 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1492#else
1493# ifdef AMIGA
1494 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1495# else
1496# ifdef VMS
1497 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1498# else /* UNIX et al. */
1499# ifdef EBCDIC
1500 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1501# else
1502 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1503# endif
1504# endif
1505# endif
1506#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001507 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001508 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1509 (char_u *)&p_isi, PV_NONE,
1510 {
1511#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1512 (char_u *)"@,48-57,_,128-167,224-235",
1513#else
1514# ifdef EBCDIC
1515 /* TODO: EBCDIC Check this! @ == isalpha()*/
1516 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1517 "112-120,128,140-142,156,158,172,"
1518 "174,186,191,203-207,219-225,235-239,"
1519 "251-254",
1520# else
1521 (char_u *)"@,48-57,_,192-255",
1522# endif
1523#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001524 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001525 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1526 (char_u *)&p_isk, PV_ISK,
1527 {
1528#ifdef EBCDIC
1529 (char_u *)"@,240-249,_",
1530 /* TODO: EBCDIC Check this! @ == isalpha()*/
1531 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1532 "112-120,128,140-142,156,158,172,"
1533 "174,186,191,203-207,219-225,235-239,"
1534 "251-254",
1535#else
1536 (char_u *)"@,48-57,_",
1537# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1538 (char_u *)"@,48-57,_,128-167,224-235"
1539# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001540 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001541# endif
1542#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001543 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001544 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1545 (char_u *)&p_isp, PV_NONE,
1546 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001547#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1548 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001549 || defined(VMS)
1550 (char_u *)"@,~-255",
1551#else
1552# ifdef EBCDIC
1553 /* all chars above 63 are printable */
1554 (char_u *)"63-255",
1555# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001556 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001557# endif
1558#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001559 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001560 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1561 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001562 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001563 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1564#ifdef FEAT_CRYPT
1565 (char_u *)&p_key, PV_KEY,
1566 {(char_u *)"", (char_u *)0L}
1567#else
1568 (char_u *)NULL, PV_NONE,
1569 {(char_u *)0L, (char_u *)0L}
1570#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001571 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001572 {"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 +00001573#ifdef FEAT_KEYMAP
1574 (char_u *)&p_keymap, PV_KMAP,
1575 {(char_u *)"", (char_u *)0L}
1576#else
1577 (char_u *)NULL, PV_NONE,
1578 {(char_u *)"", (char_u *)0L}
1579#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001580 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001581 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1582#ifdef FEAT_VISUAL
1583 (char_u *)&p_km, PV_NONE,
1584#else
1585 (char_u *)NULL, PV_NONE,
1586#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001587 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001588 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001589 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001590 {
1591#if defined(MSDOS) || defined(MSWIN)
1592 (char_u *)":help",
1593#else
1594#ifdef VMS
1595 (char_u *)"help",
1596#else
1597# if defined(OS2)
1598 (char_u *)"view /",
1599# else
1600# ifdef USEMAN_S
1601 (char_u *)"man -s",
1602# else
1603 (char_u *)"man",
1604# endif
1605# endif
1606#endif
1607#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001608 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001609 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1610#ifdef FEAT_LANGMAP
1611 (char_u *)&p_langmap, PV_NONE,
1612 {(char_u *)"", /* unmatched } */
1613#else
1614 (char_u *)NULL, PV_NONE,
1615 {(char_u *)NULL,
1616#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001617 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001618 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001619#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1620 (char_u *)&p_lm, PV_NONE,
1621#else
1622 (char_u *)NULL, PV_NONE,
1623#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001624 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001625 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1626#ifdef FEAT_WINDOWS
1627 (char_u *)&p_ls, PV_NONE,
1628#else
1629 (char_u *)NULL, PV_NONE,
1630#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001631 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001632 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1633 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001634 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001635 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1636#ifdef FEAT_LINEBREAK
1637 (char_u *)VAR_WIN, PV_LBR,
1638#else
1639 (char_u *)NULL, PV_NONE,
1640#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001641 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001642 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1643 (char_u *)&Rows, PV_NONE,
1644 {
1645#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1646 (char_u *)25L,
1647#else
1648 (char_u *)24L,
1649#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001650 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001651 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1652#ifdef FEAT_GUI
1653 (char_u *)&p_linespace, PV_NONE,
1654#else
1655 (char_u *)NULL, PV_NONE,
1656#endif
1657#ifdef FEAT_GUI_W32
1658 {(char_u *)1L, (char_u *)0L}
1659#else
1660 {(char_u *)0L, (char_u *)0L}
1661#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001662 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001663 {"lisp", NULL, P_BOOL|P_VI_DEF,
1664#ifdef FEAT_LISP
1665 (char_u *)&p_lisp, PV_LISP,
1666#else
1667 (char_u *)NULL, PV_NONE,
1668#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001669 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001670 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1671#ifdef FEAT_LISP
1672 (char_u *)&p_lispwords, PV_NONE,
1673 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1674#else
1675 (char_u *)NULL, PV_NONE,
1676 {(char_u *)"", (char_u *)0L}
1677#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001678 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001679 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1680 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001681 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001682 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1683 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001684 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001685 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1686 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001687 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001688#ifdef FEAT_GUI_MAC
1689 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1690 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001691 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001692#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001693 {"magic", NULL, P_BOOL|P_VI_DEF,
1694 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001695 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001696 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001697#ifdef FEAT_QUICKFIX
1698 (char_u *)&p_mef, PV_NONE,
1699 {(char_u *)"", (char_u *)0L}
1700#else
1701 (char_u *)NULL, PV_NONE,
1702 {(char_u *)NULL, (char_u *)0L}
1703#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001704 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001705 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1706#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001707 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001708# ifdef VMS
1709 {(char_u *)"MMS", (char_u *)0L}
1710# else
1711 {(char_u *)"make", (char_u *)0L}
1712# endif
1713#else
1714 (char_u *)NULL, PV_NONE,
1715 {(char_u *)NULL, (char_u *)0L}
1716#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001717 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1719 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001720 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1721 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001722 {"matchtime", "mat", P_NUM|P_VI_DEF,
1723 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001724 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001725 {"maxcombine", "mco", P_NUM|P_VI_DEF,
1726#ifdef FEAT_MBYTE
1727 (char_u *)&p_mco, PV_NONE,
1728#else
1729 (char_u *)NULL, PV_NONE,
1730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001731 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1733#ifdef FEAT_EVAL
1734 (char_u *)&p_mfd, PV_NONE,
1735#else
1736 (char_u *)NULL, PV_NONE,
1737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001738 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1740 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001741 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 {"maxmem", "mm", P_NUM|P_VI_DEF,
1743 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001744 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1745 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001746 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1747 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001748 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001749 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1750 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001751 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001753 {"menuitems", "mis", P_NUM|P_VI_DEF,
1754#ifdef FEAT_MENU
1755 (char_u *)&p_mis, PV_NONE,
1756#else
1757 (char_u *)NULL, PV_NONE,
1758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001760 {"mesg", NULL, P_BOOL|P_VI_DEF,
1761 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001762 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001763 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001764#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001765 (char_u *)&p_msm, PV_NONE,
1766 {(char_u *)"460000,2000,500", (char_u *)0L}
1767#else
1768 (char_u *)NULL, PV_NONE,
1769 {(char_u *)0L, (char_u *)0L}
1770#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001771 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 {"modeline", "ml", P_BOOL|P_VIM,
1773 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001774 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 {"modelines", "mls", P_NUM|P_VI_DEF,
1776 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001777 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1779 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001780 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001781 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1782 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001783 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001784 {"more", NULL, P_BOOL|P_VIM,
1785 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001786 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1788 (char_u *)&p_mouse, PV_NONE,
1789 {
1790#if defined(MSDOS) || defined(WIN3264)
1791 (char_u *)"a",
1792#else
1793 (char_u *)"",
1794#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001795 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001796 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1797#ifdef FEAT_GUI
1798 (char_u *)&p_mousef, PV_NONE,
1799#else
1800 (char_u *)NULL, PV_NONE,
1801#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001802 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001803 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1804#ifdef FEAT_GUI
1805 (char_u *)&p_mh, PV_NONE,
1806#else
1807 (char_u *)NULL, PV_NONE,
1808#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001809 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001810 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1811 (char_u *)&p_mousem, PV_NONE,
1812 {
1813#if defined(MSDOS) || defined(MSWIN)
1814 (char_u *)"popup",
1815#else
1816# if defined(MACOS)
1817 (char_u *)"popup_setpos",
1818# else
1819 (char_u *)"extend",
1820# endif
1821#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001822 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1824#ifdef FEAT_MOUSESHAPE
1825 (char_u *)&p_mouseshape, PV_NONE,
1826 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1827#else
1828 (char_u *)NULL, PV_NONE,
1829 {(char_u *)NULL, (char_u *)0L}
1830#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001831 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1833 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001835 {"mzquantum", "mzq", P_NUM,
1836#ifdef FEAT_MZSCHEME
1837 (char_u *)&p_mzq, PV_NONE,
1838#else
1839 (char_u *)NULL, PV_NONE,
1840#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 {"novice", NULL, P_BOOL|P_VI_DEF,
1843 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1846 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001847 {(char_u *)"octal,hex", (char_u *)0L}
1848 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001849 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1850 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001851 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001852 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1853#ifdef FEAT_LINEBREAK
1854 (char_u *)VAR_WIN, PV_NUW,
1855#else
1856 (char_u *)NULL, PV_NONE,
1857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001858 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001859 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001860#ifdef FEAT_COMPL_FUNC
1861 (char_u *)&p_ofu, PV_OFU,
1862 {(char_u *)"", (char_u *)0L}
1863#else
1864 (char_u *)NULL, PV_NONE,
1865 {(char_u *)0L, (char_u *)0L}
1866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"open", NULL, P_BOOL|P_VI_DEF,
1869 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001871 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1872#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1873 (char_u *)&p_odev, PV_NONE,
1874#else
1875 (char_u *)NULL, PV_NONE,
1876#endif
1877 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001878 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001879 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1880 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001881 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001882 {"optimize", "opt", P_BOOL|P_VI_DEF,
1883 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001884 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001885 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
1886#ifdef FEAT_OSFILETYPE
1887 (char_u *)&p_oft, PV_OFT,
1888 {(char_u *)DFLT_OFT, (char_u *)0L}
1889#else
1890 (char_u *)NULL, PV_NONE,
1891 {(char_u *)0L, (char_u *)0L}
1892#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001893 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894 {"paragraphs", "para", P_STRING|P_VI_DEF,
1895 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001896 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001897 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001898 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001900 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001901 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1902 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001903 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001904 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1905#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1906 (char_u *)&p_pex, PV_NONE,
1907 {(char_u *)"", (char_u *)0L}
1908#else
1909 (char_u *)NULL, PV_NONE,
1910 {(char_u *)0L, (char_u *)0L}
1911#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001912 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001913 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001915 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001917 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001918 {
1919#if defined AMIGA || defined MSDOS || defined MSWIN
1920 (char_u *)".,,",
1921#else
1922# if defined(__EMX__)
1923 (char_u *)".,/emx/include,,",
1924# else /* Unix, probably */
1925 (char_u *)".,/usr/include,,",
1926# endif
1927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001928 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
1930 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001932 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1934 (char_u *)&p_pvh, PV_NONE,
1935#else
1936 (char_u *)NULL, PV_NONE,
1937#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001938 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
1940#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1941 (char_u *)VAR_WIN, PV_PVW,
1942#else
1943 (char_u *)NULL, PV_NONE,
1944#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001946 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947#ifdef FEAT_PRINTER
1948 (char_u *)&p_pdev, PV_NONE,
1949 {(char_u *)"", (char_u *)0L}
1950#else
1951 (char_u *)NULL, PV_NONE,
1952 {(char_u *)NULL, (char_u *)0L}
1953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001954 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001955 {"printencoding", "penc", P_STRING|P_VI_DEF,
1956#ifdef FEAT_POSTSCRIPT
1957 (char_u *)&p_penc, PV_NONE,
1958 {(char_u *)"", (char_u *)0L}
1959#else
1960 (char_u *)NULL, PV_NONE,
1961 {(char_u *)NULL, (char_u *)0L}
1962#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
1965#ifdef FEAT_POSTSCRIPT
1966 (char_u *)&p_pexpr, PV_NONE,
1967 {(char_u *)"", (char_u *)0L}
1968#else
1969 (char_u *)NULL, PV_NONE,
1970 {(char_u *)NULL, (char_u *)0L}
1971#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001972 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001973 {"printfont", "pfn", P_STRING|P_VI_DEF,
1974#ifdef FEAT_PRINTER
1975 (char_u *)&p_pfn, PV_NONE,
1976 {
1977# ifdef MSWIN
1978 (char_u *)"Courier_New:h10",
1979# else
1980 (char_u *)"courier",
1981# endif
1982 (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 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
1989#ifdef FEAT_PRINTER
1990 (char_u *)&p_header, PV_NONE,
1991 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
1992#else
1993 (char_u *)NULL, PV_NONE,
1994 {(char_u *)NULL, (char_u *)0L}
1995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00001997 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
1998#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
1999 (char_u *)&p_pmcs, PV_NONE,
2000 {(char_u *)"", (char_u *)0L}
2001#else
2002 (char_u *)NULL, PV_NONE,
2003 {(char_u *)NULL, (char_u *)0L}
2004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002005 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002006 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2007#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2008 (char_u *)&p_pmfn, PV_NONE,
2009 {(char_u *)"", (char_u *)0L}
2010#else
2011 (char_u *)NULL, PV_NONE,
2012 {(char_u *)NULL, (char_u *)0L}
2013#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002014 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2016#ifdef FEAT_PRINTER
2017 (char_u *)&p_popt, PV_NONE,
2018 {(char_u *)"", (char_u *)0L}
2019#else
2020 (char_u *)NULL, PV_NONE,
2021 {(char_u *)NULL, (char_u *)0L}
2022#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002023 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002024 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002025 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002026 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002027 {"pumheight", "ph", P_NUM|P_VI_DEF,
2028#ifdef FEAT_INS_EXPAND
2029 (char_u *)&p_ph, PV_NONE,
2030#else
2031 (char_u *)NULL, PV_NONE,
2032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002033 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002034 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2035#ifdef FEAT_TEXTOBJ
2036 (char_u *)&p_qe, PV_QE,
2037 {(char_u *)"\\", (char_u *)0L}
2038#else
2039 (char_u *)NULL, PV_NONE,
2040 {(char_u *)NULL, (char_u *)0L}
2041#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002042 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002043 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2044 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002045 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046 {"redraw", NULL, P_BOOL|P_VI_DEF,
2047 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002048 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002049 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2050#ifdef FEAT_RELTIME
2051 (char_u *)&p_rdt, PV_NONE,
2052#else
2053 (char_u *)NULL, PV_NONE,
2054#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002055 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002056 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2057 (char_u *)VAR_WIN, PV_RNU,
2058 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059 {"remap", NULL, P_BOOL|P_VI_DEF,
2060 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002061 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002062 {"report", NULL, P_NUM|P_VI_DEF,
2063 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002064 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002065 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2066#ifdef WIN3264
2067 (char_u *)&p_rs, PV_NONE,
2068#else
2069 (char_u *)NULL, PV_NONE,
2070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002071 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2073#ifdef FEAT_RIGHTLEFT
2074 (char_u *)&p_ri, PV_NONE,
2075#else
2076 (char_u *)NULL, PV_NONE,
2077#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002078 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002079 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2080#ifdef FEAT_RIGHTLEFT
2081 (char_u *)VAR_WIN, PV_RL,
2082#else
2083 (char_u *)NULL, PV_NONE,
2084#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2087#ifdef FEAT_RIGHTLEFT
2088 (char_u *)VAR_WIN, PV_RLC,
2089 {(char_u *)"search", (char_u *)NULL}
2090#else
2091 (char_u *)NULL, PV_NONE,
2092 {(char_u *)NULL, (char_u *)0L}
2093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002094 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002095 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2096#ifdef FEAT_CMDL_INFO
2097 (char_u *)&p_ru, PV_NONE,
2098#else
2099 (char_u *)NULL, PV_NONE,
2100#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002101 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002102 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2103#ifdef FEAT_STL_OPT
2104 (char_u *)&p_ruf, PV_NONE,
2105#else
2106 (char_u *)NULL, PV_NONE,
2107#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002108 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002109 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
2110 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002111 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2112 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2114 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002115 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002116 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2117#ifdef FEAT_SCROLLBIND
2118 (char_u *)VAR_WIN, PV_SCBIND,
2119#else
2120 (char_u *)NULL, PV_NONE,
2121#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002122 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2124 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002125 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2127 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002128 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002129 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2130#ifdef FEAT_SCROLLBIND
2131 (char_u *)&p_sbo, PV_NONE,
2132 {(char_u *)"ver,jump", (char_u *)0L}
2133#else
2134 (char_u *)NULL, PV_NONE,
2135 {(char_u *)0L, (char_u *)0L}
2136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002137 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002138 {"sections", "sect", P_STRING|P_VI_DEF,
2139 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002140 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2141 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002142 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2143 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002144 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002145 {"selection", "sel", P_STRING|P_VI_DEF,
2146#ifdef FEAT_VISUAL
2147 (char_u *)&p_sel, PV_NONE,
2148#else
2149 (char_u *)NULL, PV_NONE,
2150#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002151 {(char_u *)"inclusive", (char_u *)0L}
2152 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002153 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2154#ifdef FEAT_VISUAL
2155 (char_u *)&p_slm, PV_NONE,
2156#else
2157 (char_u *)NULL, PV_NONE,
2158#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002159 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002160 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2161#ifdef FEAT_SESSION
2162 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002163 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002164 (char_u *)0L}
2165#else
2166 (char_u *)NULL, PV_NONE,
2167 {(char_u *)0L, (char_u *)0L}
2168#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002169 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002170 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2171 (char_u *)&p_sh, PV_NONE,
2172 {
2173#ifdef VMS
2174 (char_u *)"-",
2175#else
2176# if defined(MSDOS)
2177 (char_u *)"command",
2178# else
2179# if defined(WIN16)
2180 (char_u *)"command.com",
2181# else
2182# if defined(WIN3264)
2183 (char_u *)"", /* set in set_init_1() */
2184# else
2185# if defined(OS2)
2186 (char_u *)"cmd.exe",
2187# else
2188# if defined(ARCHIE)
2189 (char_u *)"gos",
2190# else
2191 (char_u *)"sh",
2192# endif
2193# endif
2194# endif
2195# endif
2196# endif
2197#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002198 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002199 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2200 (char_u *)&p_shcf, PV_NONE,
2201 {
2202#if defined(MSDOS) || defined(MSWIN)
2203 (char_u *)"/c",
2204#else
2205# if defined(OS2)
2206 (char_u *)"/c",
2207# else
2208 (char_u *)"-c",
2209# endif
2210#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002211 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002212 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2213#ifdef FEAT_QUICKFIX
2214 (char_u *)&p_sp, PV_NONE,
2215 {
2216#if defined(UNIX) || defined(OS2)
2217# ifdef ARCHIE
2218 (char_u *)"2>",
2219# else
2220 (char_u *)"| tee",
2221# endif
2222#else
2223 (char_u *)">",
2224#endif
2225 (char_u *)0L}
2226#else
2227 (char_u *)NULL, PV_NONE,
2228 {(char_u *)0L, (char_u *)0L}
2229#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002230 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002231 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2232 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002233 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2235 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002236 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002237 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2238#ifdef BACKSLASH_IN_FILENAME
2239 (char_u *)&p_ssl, PV_NONE,
2240#else
2241 (char_u *)NULL, PV_NONE,
2242#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002243 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002244 {"shelltemp", "stmp", P_BOOL,
2245 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002246 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002247 {"shelltype", "st", P_NUM|P_VI_DEF,
2248#ifdef AMIGA
2249 (char_u *)&p_st, PV_NONE,
2250#else
2251 (char_u *)NULL, PV_NONE,
2252#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002253 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002254 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2255 (char_u *)&p_sxq, PV_NONE,
2256 {
2257#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2258 (char_u *)"\"",
2259#else
2260 (char_u *)"",
2261#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002262 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002263 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2264 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002265 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002266 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2267 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002268 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002269 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2270 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002271 {(char_u *)"", (char_u *)"filnxtToO"}
2272 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002273 {"shortname", "sn", P_BOOL|P_VI_DEF,
2274#ifdef SHORT_FNAME
2275 (char_u *)NULL, PV_NONE,
2276#else
2277 (char_u *)&p_sn, PV_SN,
2278#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002279 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002280 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2281#ifdef FEAT_LINEBREAK
2282 (char_u *)&p_sbr, PV_NONE,
2283#else
2284 (char_u *)NULL, PV_NONE,
2285#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002286 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287 {"showcmd", "sc", P_BOOL|P_VIM,
2288#ifdef FEAT_CMDL_INFO
2289 (char_u *)&p_sc, PV_NONE,
2290#else
2291 (char_u *)NULL, PV_NONE,
2292#endif
2293 {(char_u *)FALSE,
2294#ifdef UNIX
2295 (char_u *)FALSE
2296#else
2297 (char_u *)TRUE
2298#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002299 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2301 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002302 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2304 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002305 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306 {"showmode", "smd", P_BOOL|P_VIM,
2307 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002308 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002309 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2310#ifdef FEAT_WINDOWS
2311 (char_u *)&p_stal, PV_NONE,
2312#else
2313 (char_u *)NULL, PV_NONE,
2314#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002315 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002316 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2317 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002318 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002319 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2320 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002321 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002322 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2323 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002324 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2326 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002327 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2329#ifdef FEAT_SMARTINDENT
2330 (char_u *)&p_si, PV_SI,
2331#else
2332 (char_u *)NULL, PV_NONE,
2333#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002334 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2336 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002337 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2339 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002340 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002341 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2342 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002343 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002344 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002345#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002346 (char_u *)VAR_WIN, PV_SPELL,
2347#else
2348 (char_u *)NULL, PV_NONE,
2349#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002350 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002351 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002352#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002353 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002354 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002355#else
2356 (char_u *)NULL, PV_NONE,
2357 {(char_u *)0L, (char_u *)0L}
2358#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002359 SCRIPTID_INIT},
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002360 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002361#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002362 (char_u *)&p_spf, PV_SPF,
2363 {(char_u *)"", (char_u *)0L}
2364#else
2365 (char_u *)NULL, PV_NONE,
2366 {(char_u *)0L, (char_u *)0L}
2367#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002368 SCRIPTID_INIT},
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00002369 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002370#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002371 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002372 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002373#else
2374 (char_u *)NULL, PV_NONE,
2375 {(char_u *)0L, (char_u *)0L}
2376#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 SCRIPTID_INIT},
Bram Moolenaar28e4c8d2006-05-09 16:15:42 +00002378 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002379#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002380 (char_u *)&p_sps, PV_NONE,
2381 {(char_u *)"best", (char_u *)0L}
2382#else
2383 (char_u *)NULL, PV_NONE,
2384 {(char_u *)0L, (char_u *)0L}
2385#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002386 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002387 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2388#ifdef FEAT_WINDOWS
2389 (char_u *)&p_sb, PV_NONE,
2390#else
2391 (char_u *)NULL, PV_NONE,
2392#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002393 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394 {"splitright", "spr", P_BOOL|P_VI_DEF,
2395#ifdef FEAT_VERTSPLIT
2396 (char_u *)&p_spr, PV_NONE,
2397#else
2398 (char_u *)NULL, PV_NONE,
2399#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2402 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2405#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002406 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407#else
2408 (char_u *)NULL, PV_NONE,
2409#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002410 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002411 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2412 (char_u *)&p_su, PV_NONE,
2413 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002414 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002415 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002416#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 (char_u *)&p_sua, PV_SUA,
2418 {(char_u *)"", (char_u *)0L}
2419#else
2420 (char_u *)NULL, PV_NONE,
2421 {(char_u *)0L, (char_u *)0L}
2422#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002423 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002424 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2425 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002426 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002427 {"swapsync", "sws", P_STRING|P_VI_DEF,
2428 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002429 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002430 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2431 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002432 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002433 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2434#ifdef FEAT_SYN_HL
2435 (char_u *)&p_smc, PV_SMC,
2436 {(char_u *)3000L, (char_u *)0L}
2437#else
2438 (char_u *)NULL, PV_NONE,
2439 {(char_u *)0L, (char_u *)0L}
2440#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002442 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443#ifdef FEAT_SYN_HL
2444 (char_u *)&p_syn, PV_SYN,
2445 {(char_u *)"", (char_u *)0L}
2446#else
2447 (char_u *)NULL, PV_NONE,
2448 {(char_u *)0L, (char_u *)0L}
2449#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002450 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002451 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2452#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002453 (char_u *)&p_tal, PV_NONE,
2454#else
2455 (char_u *)NULL, PV_NONE,
2456#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002457 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002458 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2459#ifdef FEAT_WINDOWS
2460 (char_u *)&p_tpm, PV_NONE,
2461#else
2462 (char_u *)NULL, PV_NONE,
2463#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002464 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2466 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2469 (char_u *)&p_tbs, PV_NONE,
2470#ifdef VMS /* binary searching doesn't appear to work on VMS */
2471 {(char_u *)0L, (char_u *)0L}
2472#else
2473 {(char_u *)TRUE, (char_u *)0L}
2474#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002475 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002476 {"taglength", "tl", P_NUM|P_VI_DEF,
2477 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002478 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002479 {"tagrelative", "tr", P_BOOL|P_VIM,
2480 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002481 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002483 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 {
2485#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2486 (char_u *)"./tags,./TAGS,tags,TAGS",
2487#else
2488 (char_u *)"./tags,tags",
2489#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002490 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002491 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2492 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002493 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002494 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2495 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002496 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002497 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2498#ifdef FEAT_ARABIC
2499 (char_u *)&p_tbidi, PV_NONE,
2500#else
2501 (char_u *)NULL, PV_NONE,
2502#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002503 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2505#ifdef FEAT_MBYTE
2506 (char_u *)&p_tenc, PV_NONE,
2507 {(char_u *)"", (char_u *)0L}
2508#else
2509 (char_u *)NULL, PV_NONE,
2510 {(char_u *)0L, (char_u *)0L}
2511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002512 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 {"terse", NULL, P_BOOL|P_VI_DEF,
2514 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002515 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"textauto", "ta", P_BOOL|P_VIM,
2517 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002518 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2519 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2521 (char_u *)&p_tx, PV_TX,
2522 {
2523#ifdef USE_CRNL
2524 (char_u *)TRUE,
2525#else
2526 (char_u *)FALSE,
2527#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002528 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002529 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM,
2530 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002531 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2533#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002534 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002535#else
2536 (char_u *)NULL, PV_NONE,
2537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002538 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2540 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002541 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542 {"timeout", "to", P_BOOL|P_VI_DEF,
2543 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2546 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002547 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002548 {"title", NULL, P_BOOL|P_VI_DEF,
2549#ifdef FEAT_TITLE
2550 (char_u *)&p_title, PV_NONE,
2551#else
2552 (char_u *)NULL, PV_NONE,
2553#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002554 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002555 {"titlelen", NULL, P_NUM|P_VI_DEF,
2556#ifdef FEAT_TITLE
2557 (char_u *)&p_titlelen, PV_NONE,
2558#else
2559 (char_u *)NULL, PV_NONE,
2560#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002561 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002562 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563#ifdef FEAT_TITLE
2564 (char_u *)&p_titleold, PV_NONE,
2565 {(char_u *)N_("Thanks for flying Vim"),
2566 (char_u *)0L}
2567#else
2568 (char_u *)NULL, PV_NONE,
2569 {(char_u *)0L, (char_u *)0L}
2570#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002571 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002572 {"titlestring", NULL, P_STRING|P_VI_DEF,
2573#ifdef FEAT_TITLE
2574 (char_u *)&p_titlestring, PV_NONE,
2575#else
2576 (char_u *)NULL, PV_NONE,
2577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
2580 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
2581 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002582 {(char_u *)"icons,tooltips", (char_u *)0L}
2583 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002584#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002585#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002586 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2587 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589#endif
2590 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2591 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002592 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002593 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2594 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002595 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002596 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2597 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002598 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002599 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2600 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002601 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002602 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2603#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2604 (char_u *)&p_ttym, PV_NONE,
2605#else
2606 (char_u *)NULL, PV_NONE,
2607#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002608 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2610 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002611 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002612 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2613 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002614 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002615 {"undodir", "udir", P_STRING|P_EXPAND|P_COMMA|P_NODUP|P_SECURE|P_VI_DEF,
2616#ifdef FEAT_PERSISTENT_UNDO
2617 (char_u *)&p_udir, PV_NONE,
2618 {(char_u *)".", (char_u *)0L}
2619#else
2620 (char_u *)NULL, PV_NONE,
2621 {(char_u *)0L, (char_u *)0L}
2622#endif
2623 SCRIPTID_INIT},
2624 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2625#ifdef FEAT_PERSISTENT_UNDO
2626 (char_u *)&p_udf, PV_UDF,
2627#else
2628 (char_u *)NULL, PV_NONE,
2629#endif
2630 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002631 {"undolevels", "ul", P_NUM|P_VI_DEF,
2632 (char_u *)&p_ul, PV_NONE,
2633 {
2634#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2635 (char_u *)1000L,
2636#else
2637 (char_u *)100L,
2638#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002639 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002640 {"updatecount", "uc", P_NUM|P_VI_DEF,
2641 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002642 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643 {"updatetime", "ut", P_NUM|P_VI_DEF,
2644 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002645 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002646 {"verbose", "vbs", P_NUM|P_VI_DEF,
2647 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002648 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002649 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2650 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002651 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002652 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2653#ifdef FEAT_SESSION
2654 (char_u *)&p_vdir, PV_NONE,
2655 {(char_u *)DFLT_VDIR, (char_u *)0L}
2656#else
2657 (char_u *)NULL, PV_NONE,
2658 {(char_u *)0L, (char_u *)0L}
2659#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002660 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2662#ifdef FEAT_SESSION
2663 (char_u *)&p_vop, PV_NONE,
2664 {(char_u *)"folds,options,cursor", (char_u *)0L}
2665#else
2666 (char_u *)NULL, PV_NONE,
2667 {(char_u *)0L, (char_u *)0L}
2668#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
2671#ifdef FEAT_VIMINFO
2672 (char_u *)&p_viminfo, PV_NONE,
2673#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002674 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675#else
2676# ifdef AMIGA
2677 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002678 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002680 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681# endif
2682#endif
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 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM,
2689#ifdef FEAT_VIRTUALEDIT
2690 (char_u *)&p_ve, PV_NONE,
2691 {(char_u *)"", (char_u *)""}
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 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2698 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002699 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002700 {"w300", NULL, P_NUM|P_VI_DEF,
2701 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002702 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002703 {"w1200", NULL, P_NUM|P_VI_DEF,
2704 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002705 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002706 {"w9600", NULL, P_NUM|P_VI_DEF,
2707 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002708 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709 {"warn", NULL, P_BOOL|P_VI_DEF,
2710 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002711 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2713 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
2716 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002717 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002718 {"wildchar", "wc", P_NUM|P_VIM,
2719 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002720 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2721 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002722 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
2723 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002724 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002725 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2726#ifdef FEAT_WILDIGN
2727 (char_u *)&p_wig, PV_NONE,
2728#else
2729 (char_u *)NULL, PV_NONE,
2730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002731 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2733#ifdef FEAT_WILDMENU
2734 (char_u *)&p_wmnu, PV_NONE,
2735#else
2736 (char_u *)NULL, PV_NONE,
2737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002738 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002739 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2740 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002741 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002742 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2743#ifdef FEAT_CMDL_COMPL
2744 (char_u *)&p_wop, PV_NONE,
2745 {(char_u *)"", (char_u *)0L}
2746#else
2747 (char_u *)NULL, PV_NONE,
2748 {(char_u *)NULL, (char_u *)0L}
2749#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002750 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002751 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2752#ifdef FEAT_WAK
2753 (char_u *)&p_wak, PV_NONE,
2754 {(char_u *)"menu", (char_u *)0L}
2755#else
2756 (char_u *)NULL, PV_NONE,
2757 {(char_u *)NULL, (char_u *)0L}
2758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002759 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002760 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002761 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002762 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 {"winheight", "wh", P_NUM|P_VI_DEF,
2764#ifdef FEAT_WINDOWS
2765 (char_u *)&p_wh, PV_NONE,
2766#else
2767 (char_u *)NULL, PV_NONE,
2768#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002769 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002770 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002771#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002772 (char_u *)VAR_WIN, PV_WFH,
2773#else
2774 (char_u *)NULL, PV_NONE,
2775#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002776 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002777 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2778#ifdef FEAT_VERTSPLIT
2779 (char_u *)VAR_WIN, PV_WFW,
2780#else
2781 (char_u *)NULL, PV_NONE,
2782#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002783 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002784 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2785#ifdef FEAT_WINDOWS
2786 (char_u *)&p_wmh, PV_NONE,
2787#else
2788 (char_u *)NULL, PV_NONE,
2789#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002790 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002791 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2792#ifdef FEAT_VERTSPLIT
2793 (char_u *)&p_wmw, PV_NONE,
2794#else
2795 (char_u *)NULL, PV_NONE,
2796#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002797 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2799#ifdef FEAT_VERTSPLIT
2800 (char_u *)&p_wiw, PV_NONE,
2801#else
2802 (char_u *)NULL, PV_NONE,
2803#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2806 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002808 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2809 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2812 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002813 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814 {"write", NULL, P_BOOL|P_VI_DEF,
2815 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002816 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817 {"writeany", "wa", P_BOOL|P_VI_DEF,
2818 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2821 (char_u *)&p_wb, PV_NONE,
2822 {
2823#ifdef FEAT_WRITEBACKUP
2824 (char_u *)TRUE,
2825#else
2826 (char_u *)FALSE,
2827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002828 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002829 {"writedelay", "wd", P_NUM|P_VI_DEF,
2830 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002831 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002832
2833/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002834#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002835 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002836 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002837
2838 p_term("t_AB", T_CAB)
2839 p_term("t_AF", T_CAF)
2840 p_term("t_AL", T_CAL)
2841 p_term("t_al", T_AL)
2842 p_term("t_bc", T_BC)
2843 p_term("t_cd", T_CD)
2844 p_term("t_ce", T_CE)
2845 p_term("t_cl", T_CL)
2846 p_term("t_cm", T_CM)
2847 p_term("t_Co", T_CCO)
2848 p_term("t_CS", T_CCS)
2849 p_term("t_cs", T_CS)
2850#ifdef FEAT_VERTSPLIT
2851 p_term("t_CV", T_CSV)
2852#endif
2853 p_term("t_ut", T_UT)
2854 p_term("t_da", T_DA)
2855 p_term("t_db", T_DB)
2856 p_term("t_DL", T_CDL)
2857 p_term("t_dl", T_DL)
2858 p_term("t_fs", T_FS)
2859 p_term("t_IE", T_CIE)
2860 p_term("t_IS", T_CIS)
2861 p_term("t_ke", T_KE)
2862 p_term("t_ks", T_KS)
2863 p_term("t_le", T_LE)
2864 p_term("t_mb", T_MB)
2865 p_term("t_md", T_MD)
2866 p_term("t_me", T_ME)
2867 p_term("t_mr", T_MR)
2868 p_term("t_ms", T_MS)
2869 p_term("t_nd", T_ND)
2870 p_term("t_op", T_OP)
2871 p_term("t_RI", T_CRI)
2872 p_term("t_RV", T_CRV)
2873 p_term("t_Sb", T_CSB)
2874 p_term("t_Sf", T_CSF)
2875 p_term("t_se", T_SE)
2876 p_term("t_so", T_SO)
2877 p_term("t_sr", T_SR)
2878 p_term("t_ts", T_TS)
2879 p_term("t_te", T_TE)
2880 p_term("t_ti", T_TI)
2881 p_term("t_ue", T_UE)
2882 p_term("t_us", T_US)
2883 p_term("t_vb", T_VB)
2884 p_term("t_ve", T_VE)
2885 p_term("t_vi", T_VI)
2886 p_term("t_vs", T_VS)
2887 p_term("t_WP", T_CWP)
2888 p_term("t_WS", T_CWS)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002889 p_term("t_SI", T_CSI)
2890 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002891 p_term("t_xs", T_XS)
2892 p_term("t_ZH", T_CZH)
2893 p_term("t_ZR", T_CZR)
2894
2895/* terminal key codes are not in here */
2896
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002897 /* end marker */
2898 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899};
2900
2901#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
2902
2903#ifdef FEAT_MBYTE
2904static char *(p_ambw_values[]) = {"single", "double", NULL};
2905#endif
2906static char *(p_bg_values[]) = {"light", "dark", NULL};
2907static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
2908static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002909#ifdef FEAT_CMDL_COMPL
2910static char *(p_wop_values[]) = {"tagfile", NULL};
2911#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002912#ifdef FEAT_WAK
2913static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
2914#endif
2915static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
2916#ifdef FEAT_VISUAL
2917static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
2918static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
2919#endif
2920#ifdef FEAT_VISUAL
2921static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
2922#endif
2923#ifdef FEAT_BROWSE
2924static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
2925#endif
2926#ifdef FEAT_SCROLLBIND
2927static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
2928#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00002929static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930#ifdef FEAT_VERTSPLIT
2931static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
2932#endif
2933#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002934# ifdef FEAT_AUTOCMD
2935static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
2936# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002938# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
2940#endif
2941static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
2942#ifdef FEAT_FOLDING
2943static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002944# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00002945 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002946# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002947 NULL};
2948static char *(p_fcl_values[]) = {"all", NULL};
2949#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002950#ifdef FEAT_INS_EXPAND
Bram Moolenaarc270d802006-03-11 21:29:41 +00002951static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002952#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953
2954static void set_option_default __ARGS((int, int opt_flags, int compatible));
2955static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00002956static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00002957static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00002958static char_u *illegal_char __ARGS((char_u *, int));
2959static int string_to_key __ARGS((char_u *arg));
2960#ifdef FEAT_CMDWIN
2961static char_u *check_cedit __ARGS((void));
2962#endif
2963#ifdef FEAT_TITLE
2964static void did_set_title __ARGS((int icon));
2965#endif
2966static char_u *option_expand __ARGS((int opt_idx, char_u *val));
2967static void didset_options __ARGS((void));
2968static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00002969#if defined(FEAT_EVAL) || defined(PROTO)
2970static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
2971#else
2972# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
2973#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002974static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
2975static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
2976static 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));
2977static char_u *set_chars_option __ARGS((char_u **varp));
2978#ifdef FEAT_CLIPBOARD
2979static char_u *check_clipboard_option __ARGS((void));
2980#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002981#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02002982static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002983#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002984#ifdef FEAT_EVAL
2985static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
2986#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00002988static 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 +00002989static void check_redraw __ARGS((long_u flags));
2990static int findoption __ARGS((char_u *));
2991static int find_key_option __ARGS((char_u *));
2992static void showoptions __ARGS((int all, int opt_flags));
2993static int optval_default __ARGS((struct vimoption *, char_u *varp));
2994static void showoneopt __ARGS((struct vimoption *, int opt_flags));
2995static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
2996static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
2997static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
2998static int istermoption __ARGS((struct vimoption *));
2999static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3000static char_u *get_varp __ARGS((struct vimoption *));
3001static void option_value2string __ARGS((struct vimoption *, int opt_flags));
3002static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3003#ifdef FEAT_LANGMAP
3004static void langmap_init __ARGS((void));
3005static void langmap_set __ARGS((void));
3006#endif
3007static void paste_option_changed __ARGS((void));
3008static void compatible_set __ARGS((void));
3009#ifdef FEAT_LINEBREAK
3010static void fill_breakat_flags __ARGS((void));
3011#endif
3012static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3013static int check_opt_strings __ARGS((char_u *val, char **values, int));
3014static int check_opt_wim __ARGS((void));
3015
3016/*
3017 * Initialize the options, first part.
3018 *
3019 * Called only once from main(), just after creating the first buffer.
3020 */
3021 void
3022set_init_1()
3023{
3024 char_u *p;
3025 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003026 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003027
3028#ifdef FEAT_LANGMAP
3029 langmap_init();
3030#endif
3031
3032 /* Be Vi compatible by default */
3033 p_cp = TRUE;
3034
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003035 /* Use POSIX compatibility when $VIM_POSIX is set. */
3036 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003037 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003038 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003039 set_string_default("shm", (char_u *)"A");
3040 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003041
Bram Moolenaar071d4272004-06-13 20:20:40 +00003042 /*
3043 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003044 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003046 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003047#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3048# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003049 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003050# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003051 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003052# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003053 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054# endif
3055#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003056 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003057 set_string_default("sh", p);
3058
3059#ifdef FEAT_WILDIGN
3060 /*
3061 * Set the default for 'backupskip' to include environment variables for
3062 * temp files.
3063 */
3064 {
3065# ifdef UNIX
3066 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3067# else
3068 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3069# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003070 int len;
3071 garray_T ga;
3072 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073
3074 ga_init2(&ga, 1, 100);
3075 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3076 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003077 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003078# ifdef UNIX
3079 if (*names[n] == NUL)
3080 p = (char_u *)"/tmp";
3081 else
3082# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003083 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003084 if (p != NULL && *p != NUL)
3085 {
3086 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003087 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003088 if (ga_grow(&ga, len) == OK)
3089 {
3090 if (ga.ga_len > 0)
3091 STRCAT(ga.ga_data, ",");
3092 STRCAT(ga.ga_data, p);
3093 add_pathsep(ga.ga_data);
3094 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095 ga.ga_len += len;
3096 }
3097 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003098 if (mustfree)
3099 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003100 }
3101 if (ga.ga_data != NULL)
3102 {
3103 set_string_default("bsk", ga.ga_data);
3104 vim_free(ga.ga_data);
3105 }
3106 }
3107#endif
3108
3109 /*
3110 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3111 */
3112 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003113 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003115#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3116 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3117#endif
3118 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003119#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003120 /* Use amount of memory available at this moment. */
3121 n = (mch_avail_mem(FALSE) >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003122#else
3123# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003124 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003125 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003126# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003127 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003128# endif
3129#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003131 opt_idx = findoption((char_u *)"maxmem");
3132 if (opt_idx >= 0)
3133 {
3134#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3135 if ((long)options[opt_idx].def_val[VI_DEFAULT] > n
3136 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3137#endif
3138 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3139 }
3140 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003141 }
3142
3143#ifdef FEAT_GUI_W32
3144 /* force 'shortname' for Win32s */
3145 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003146 {
3147 opt_idx = findoption((char_u *)"shortname");
3148 if (opt_idx >= 0)
3149 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3150 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151#endif
3152
3153#ifdef FEAT_SEARCHPATH
3154 {
3155 char_u *cdpath;
3156 char_u *buf;
3157 int i;
3158 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003159 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160
3161 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003162 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 if (cdpath != NULL)
3164 {
3165 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3166 if (buf != NULL)
3167 {
3168 buf[0] = ','; /* start with ",", current dir first */
3169 j = 1;
3170 for (i = 0; cdpath[i] != NUL; ++i)
3171 {
3172 if (vim_ispathlistsep(cdpath[i]))
3173 buf[j++] = ',';
3174 else
3175 {
3176 if (cdpath[i] == ' ' || cdpath[i] == ',')
3177 buf[j++] = '\\';
3178 buf[j++] = cdpath[i];
3179 }
3180 }
3181 buf[j] = NUL;
3182 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003183 if (opt_idx >= 0)
3184 {
3185 options[opt_idx].def_val[VI_DEFAULT] = buf;
3186 options[opt_idx].flags |= P_DEF_ALLOCED;
3187 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003188 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003189 if (mustfree)
3190 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003191 }
3192 }
3193#endif
3194
3195#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3196 /* Set print encoding on platforms that don't default to latin1 */
3197 set_string_default("penc",
3198# if defined(MSWIN) || defined(OS2)
3199 (char_u *)"cp1252"
3200# else
3201# ifdef VMS
3202 (char_u *)"dec-mcs"
3203# else
3204# ifdef EBCDIC
3205 (char_u *)"ebcdic-uk"
3206# else
3207# ifdef MAC
3208 (char_u *)"mac-roman"
3209# else /* HPUX */
3210 (char_u *)"hp-roman8"
3211# endif
3212# endif
3213# endif
3214# endif
3215 );
3216#endif
3217
3218#ifdef FEAT_POSTSCRIPT
3219 /* 'printexpr' must be allocated to be able to evaluate it. */
3220 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003221# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3222 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003223# else
3224# ifdef VMS
3225 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3226
3227# else
3228 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3229# endif
3230# endif
3231 );
3232#endif
3233
3234 /*
3235 * Set all the options (except the terminal options) to their default
3236 * value. Also set the global value for local options.
3237 */
3238 set_options_default(0);
3239
3240#ifdef FEAT_GUI
3241 if (found_reverse_arg)
3242 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3243#endif
3244
3245 curbuf->b_p_initialized = TRUE;
3246 curbuf->b_p_ar = -1; /* no local 'autoread' value */
3247 check_buf_options(curbuf);
3248 check_win_options(curwin);
3249 check_options();
3250
3251 /* Must be before option_expand(), because that one needs vim_isIDc() */
3252 didset_options();
3253
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003254#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003255 /* Use the current chartab for the generic chartab. */
3256 init_spell_chartab();
3257#endif
3258
Bram Moolenaar071d4272004-06-13 20:20:40 +00003259#ifdef FEAT_LINEBREAK
3260 /*
3261 * initialize the table for 'breakat'.
3262 */
3263 fill_breakat_flags();
3264#endif
3265
3266 /*
3267 * Expand environment variables and things like "~" for the defaults.
3268 * If option_expand() returns non-NULL the variable is expanded. This can
3269 * only happen for non-indirect options.
3270 * Also set the default to the expanded value, so ":set" does not list
3271 * them.
3272 * Don't set the P_ALLOCED flag, because we don't want to free the
3273 * default.
3274 */
3275 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3276 {
3277 if ((options[opt_idx].flags & P_GETTEXT)
3278 && options[opt_idx].var != NULL)
3279 p = (char_u *)_(*(char **)options[opt_idx].var);
3280 else
3281 p = option_expand(opt_idx, NULL);
3282 if (p != NULL && (p = vim_strsave(p)) != NULL)
3283 {
3284 *(char_u **)options[opt_idx].var = p;
3285 /* VIMEXP
3286 * Defaults for all expanded options are currently the same for Vi
3287 * and Vim. When this changes, add some code here! Also need to
3288 * split P_DEF_ALLOCED in two.
3289 */
3290 if (options[opt_idx].flags & P_DEF_ALLOCED)
3291 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3292 options[opt_idx].def_val[VI_DEFAULT] = p;
3293 options[opt_idx].flags |= P_DEF_ALLOCED;
3294 }
3295 }
3296
3297 /* Initialize the highlight_attr[] table. */
3298 highlight_changed();
3299
3300 save_file_ff(curbuf); /* Buffer is unchanged */
3301
3302 /* Parse default for 'wildmode' */
3303 check_opt_wim();
3304
3305#if defined(FEAT_ARABIC)
3306 /* Detect use of mlterm.
3307 * Mlterm is a terminal emulator akin to xterm that has some special
3308 * abilities (bidi namely).
3309 * NOTE: mlterm's author is being asked to 'set' a variable
3310 * instead of an environment variable due to inheritance.
3311 */
3312 if (mch_getenv((char_u *)"MLTERM") != NULL)
3313 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3314#endif
3315
3316#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3317 /* Parse default for 'fillchars'. */
3318 (void)set_chars_option(&p_fcs);
3319#endif
3320
3321#ifdef FEAT_CLIPBOARD
3322 /* Parse default for 'clipboard' */
3323 (void)check_clipboard_option();
3324#endif
3325
3326#ifdef FEAT_MBYTE
3327# if defined(WIN3264) && defined(FEAT_GETTEXT)
3328 /*
3329 * If $LANG isn't set, try to get a good value for it. This makes the
3330 * right language be used automatically. Don't do this for English.
3331 */
3332 if (mch_getenv((char_u *)"LANG") == NULL)
3333 {
3334 char buf[20];
3335
3336 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3337 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3338 * only the first two. */
3339 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3340 (LPTSTR)buf, 20);
3341 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3342 {
3343 /* There are a few exceptions (probably more) */
3344 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3345 STRCPY(buf, "zh_TW");
3346 else if (STRNICMP(buf, "chs", 3) == 0
3347 || STRNICMP(buf, "zhc", 3) == 0)
3348 STRCPY(buf, "zh_CN");
3349 else if (STRNICMP(buf, "jp", 2) == 0)
3350 STRCPY(buf, "ja");
3351 else
3352 buf[2] = NUL; /* truncate to two-letter code */
3353 vim_setenv("LANG", buf);
3354 }
3355 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003356# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003357# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003358 /* Moved to os_mac_conv.c to avoid dependency problems. */
3359 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003360# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003361# endif
3362
3363 /* enc_locale() will try to find the encoding of the current locale. */
3364 p = enc_locale();
3365 if (p != NULL)
3366 {
3367 char_u *save_enc;
3368
3369 /* Try setting 'encoding' and check if the value is valid.
3370 * If not, go back to the default "latin1". */
3371 save_enc = p_enc;
3372 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003373 if (STRCMP(p_enc, "gb18030") == 0)
3374 {
3375 /* We don't support "gb18030", but "cp936" is a good substitute
3376 * for practical purposes, thus use that. It's not an alias to
3377 * still support conversion between gb18030 and utf-8. */
3378 p_enc = vim_strsave((char_u *)"cp936");
3379 vim_free(p);
3380 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003381 if (mb_init() == NULL)
3382 {
3383 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003384 if (opt_idx >= 0)
3385 {
3386 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3387 options[opt_idx].flags |= P_DEF_ALLOCED;
3388 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003389
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003390#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3391 || defined(VMS)
3392 if (STRCMP(p_enc, "latin1") == 0
3393# ifdef FEAT_MBYTE
3394 || enc_utf8
3395# endif
3396 )
3397 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003398 /* Adjust the default for 'isprint' and 'iskeyword' to match
3399 * latin1. Also set the defaults for when 'nocompatible' is
3400 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003401 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003402 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003403 set_string_option_direct((char_u *)"isk", -1,
3404 ISK_LATIN1, OPT_FREE, SID_NONE);
3405 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003406 if (opt_idx >= 0)
3407 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003408 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003409 if (opt_idx >= 0)
3410 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003411 (void)init_chartab();
3412 }
3413#endif
3414
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415# if defined(WIN3264) && !defined(FEAT_GUI)
3416 /* Win32 console: When GetACP() returns a different value from
3417 * GetConsoleCP() set 'termencoding'. */
3418 if (GetACP() != GetConsoleCP())
3419 {
3420 char buf[50];
3421
3422 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3423 p_tenc = vim_strsave((char_u *)buf);
3424 if (p_tenc != NULL)
3425 {
3426 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003427 if (opt_idx >= 0)
3428 {
3429 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3430 options[opt_idx].flags |= P_DEF_ALLOCED;
3431 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003432 convert_setup(&input_conv, p_tenc, p_enc);
3433 convert_setup(&output_conv, p_enc, p_tenc);
3434 }
3435 else
3436 p_tenc = empty_option;
3437 }
3438# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003439# if defined(WIN3264) && defined(FEAT_MBYTE)
3440 /* $HOME may have characters in active code page. */
3441 init_homedir();
3442# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003443 }
3444 else
3445 {
3446 vim_free(p_enc);
3447 p_enc = save_enc;
3448 }
3449 }
3450#endif
3451
3452#ifdef FEAT_MULTI_LANG
3453 /* Set the default for 'helplang'. */
3454 set_helplang_default(get_mess_lang());
3455#endif
3456}
3457
3458/*
3459 * Set an option to its default value.
3460 * This does not take care of side effects!
3461 */
3462 static void
3463set_option_default(opt_idx, opt_flags, compatible)
3464 int opt_idx;
3465 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3466 int compatible; /* use Vi default value */
3467{
3468 char_u *varp; /* pointer to variable for current option */
3469 int dvi; /* index in def_val[] */
3470 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003471 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3473
3474 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3475 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003476 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003477 {
3478 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3479 if (flags & P_STRING)
3480 {
3481 /* Use set_string_option_direct() for local options to handle
3482 * freeing and allocating the value. */
3483 if (options[opt_idx].indir != PV_NONE)
3484 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003485 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003486 else
3487 {
3488 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3489 free_string_option(*(char_u **)(varp));
3490 *(char_u **)varp = options[opt_idx].def_val[dvi];
3491 options[opt_idx].flags &= ~P_ALLOCED;
3492 }
3493 }
3494 else if (flags & P_NUM)
3495 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003496 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003497 win_comp_scroll(curwin);
3498 else
3499 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003500 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003501 /* May also set global value for local option. */
3502 if (both)
3503 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3504 *(long *)varp;
3505 }
3506 }
3507 else /* P_BOOL */
3508 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003509 /* the cast to long is required for Manx C, long_i is needed for
3510 * MSVC */
3511 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003512#ifdef UNIX
3513 /* 'modeline' defaults to off for root */
3514 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3515 *(int *)varp = FALSE;
3516#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003517 /* May also set global value for local option. */
3518 if (both)
3519 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3520 *(int *)varp;
3521 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003522
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003523 /* The default value is not insecure. */
3524 flagsp = insecure_flag(opt_idx, opt_flags);
3525 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003526 }
3527
3528#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003529 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003530#endif
3531}
3532
3533/*
3534 * Set all options (except terminal options) to their default value.
3535 */
3536 static void
3537set_options_default(opt_flags)
3538 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3539{
3540 int i;
3541#ifdef FEAT_WINDOWS
3542 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003543 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003544#endif
3545
3546 for (i = 0; !istermoption(&options[i]); i++)
3547 if (!(options[i].flags & P_NODEFAULT))
3548 set_option_default(i, opt_flags, p_cp);
3549
3550#ifdef FEAT_WINDOWS
3551 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003552 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003553 win_comp_scroll(wp);
3554#else
3555 win_comp_scroll(curwin);
3556#endif
3557}
3558
3559/*
3560 * Set the Vi-default value of a string option.
3561 * Used for 'sh', 'backupskip' and 'term'.
3562 */
3563 void
3564set_string_default(name, val)
3565 char *name;
3566 char_u *val;
3567{
3568 char_u *p;
3569 int opt_idx;
3570
3571 p = vim_strsave(val);
3572 if (p != NULL) /* we don't want a NULL */
3573 {
3574 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003575 if (opt_idx >= 0)
3576 {
3577 if (options[opt_idx].flags & P_DEF_ALLOCED)
3578 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3579 options[opt_idx].def_val[VI_DEFAULT] = p;
3580 options[opt_idx].flags |= P_DEF_ALLOCED;
3581 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003582 }
3583}
3584
3585/*
3586 * Set the Vi-default value of a number option.
3587 * Used for 'lines' and 'columns'.
3588 */
3589 void
3590set_number_default(name, val)
3591 char *name;
3592 long val;
3593{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003594 int opt_idx;
3595
3596 opt_idx = findoption((char_u *)name);
3597 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003598 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003599}
3600
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003601#if defined(EXITFREE) || defined(PROTO)
3602/*
3603 * Free all options.
3604 */
3605 void
3606free_all_options()
3607{
3608 int i;
3609
3610 for (i = 0; !istermoption(&options[i]); i++)
3611 {
3612 if (options[i].indir == PV_NONE)
3613 {
3614 /* global option: free value and default value. */
3615 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3616 free_string_option(*(char_u **)options[i].var);
3617 if (options[i].flags & P_DEF_ALLOCED)
3618 free_string_option(options[i].def_val[VI_DEFAULT]);
3619 }
3620 else if (options[i].var != VAR_WIN
3621 && (options[i].flags & P_STRING))
3622 /* buffer-local option: free global value */
3623 free_string_option(*(char_u **)options[i].var);
3624 }
3625}
3626#endif
3627
3628
Bram Moolenaar071d4272004-06-13 20:20:40 +00003629/*
3630 * Initialize the options, part two: After getting Rows and Columns and
3631 * setting 'term'.
3632 */
3633 void
3634set_init_2()
3635{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003636 int idx;
3637
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638 /*
3639 * 'scroll' defaults to half the window height. Note that this default is
3640 * wrong when the window height changes.
3641 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003642 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003643 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003644 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003645 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003646 comp_col();
3647
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003648 /*
3649 * 'window' is only for backwards compatibility with Vi.
3650 * Default is Rows - 1.
3651 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003652 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003653 p_window = Rows - 1;
3654 set_number_default("window", Rows - 1);
3655
Bram Moolenaarf740b292006-02-16 22:11:02 +00003656 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003658 /*
3659 * If 'background' wasn't set by the user, try guessing the value,
3660 * depending on the terminal name. Only need to check for terminals
3661 * with a dark background, that can handle color.
3662 */
3663 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003664 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3665 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003666 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003667 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003668 /* don't mark it as set, when starting the GUI it may be
3669 * changed again */
3670 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003671 }
3672#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003673
3674#ifdef CURSOR_SHAPE
3675 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3676#endif
3677#ifdef FEAT_MOUSESHAPE
3678 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3679#endif
3680#ifdef FEAT_PRINTER
3681 (void)parse_printoptions(); /* parse 'printoptions' default value */
3682#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003683}
3684
3685/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003686 * Return "dark" or "light" depending on the kind of terminal.
3687 * This is just guessing! Recognized are:
3688 * "linux" Linux console
3689 * "screen.linux" Linux console with screen
3690 * "cygwin" Cygwin shell
3691 * "putty" Putty program
3692 * We also check the COLORFGBG environment variable, which is set by
3693 * rxvt and derivatives. This variable contains either two or three
3694 * values separated by semicolons; we want the last value in either
3695 * case. If this value is 0-6 or 8, our background is dark.
3696 */
3697 static char_u *
3698term_bg_default()
3699{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003700#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3701 /* DOS console nearly always black */
3702 return (char_u *)"dark";
3703#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003704 char_u *p;
3705
Bram Moolenaarf740b292006-02-16 22:11:02 +00003706 if (STRCMP(T_NAME, "linux") == 0
3707 || STRCMP(T_NAME, "screen.linux") == 0
3708 || STRCMP(T_NAME, "cygwin") == 0
3709 || STRCMP(T_NAME, "putty") == 0
3710 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3711 && (p = vim_strrchr(p, ';')) != NULL
3712 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3713 && p[2] == NUL))
3714 return (char_u *)"dark";
3715 return (char_u *)"light";
3716#endif
3717}
3718
3719/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003720 * Initialize the options, part three: After reading the .vimrc
3721 */
3722 void
3723set_init_3()
3724{
3725#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3726/*
3727 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3728 * This is done after other initializations, where 'shell' might have been
3729 * set, but only if they have not been set before.
3730 */
3731 char_u *p;
3732 int idx_srr;
3733 int do_srr;
3734#ifdef FEAT_QUICKFIX
3735 int idx_sp;
3736 int do_sp;
3737#endif
3738
3739 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003740 if (idx_srr < 0)
3741 do_srr = FALSE;
3742 else
3743 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003744#ifdef FEAT_QUICKFIX
3745 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003746 if (idx_sp < 0)
3747 do_sp = FALSE;
3748 else
3749 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003750#endif
3751
3752 /*
3753 * Isolate the name of the shell:
3754 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
3755 * - Remove any argument. E.g., "csh -f" -> "csh".
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003756 * But don't allow a space in the path, so that this works:
3757 * "/usr/bin/csh --rcfile ~/.cshrc"
3758 * But don't do that for Windows, it's common to have a space in the path.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003759 */
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003760#ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003761 p = gettail(p_sh);
3762 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003763#else
3764 p = skiptowhite(p_sh);
3765 if (*p == NUL)
3766 {
3767 /* No white space, use the tail. */
3768 p = vim_strsave(gettail(p_sh));
3769 }
3770 else
3771 {
3772 char_u *p1, *p2;
3773
3774 /* Find the last path separator before the space. */
3775 p1 = p_sh;
3776 for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
3777 if (vim_ispathsep(*p2))
3778 p1 = p2 + 1;
3779 p = vim_strnsave(p1, (int)(p - p1));
3780 }
3781#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003782 if (p != NULL)
3783 {
3784 /*
3785 * Default for p_sp is "| tee", for p_srr is ">".
3786 * For known shells it is changed here to include stderr.
3787 */
3788 if ( fnamecmp(p, "csh") == 0
3789 || fnamecmp(p, "tcsh") == 0
3790# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3791 || fnamecmp(p, "csh.exe") == 0
3792 || fnamecmp(p, "tcsh.exe") == 0
3793# endif
3794 )
3795 {
3796#if defined(FEAT_QUICKFIX)
3797 if (do_sp)
3798 {
3799# ifdef WIN3264
3800 p_sp = (char_u *)">&";
3801# else
3802 p_sp = (char_u *)"|& tee";
3803# endif
3804 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3805 }
3806#endif
3807 if (do_srr)
3808 {
3809 p_srr = (char_u *)">&";
3810 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3811 }
3812 }
3813 else
3814# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3815 if ( fnamecmp(p, "sh") == 0
3816 || fnamecmp(p, "ksh") == 0
3817 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003818 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003819 || fnamecmp(p, "bash") == 0
3820# ifdef WIN3264
3821 || fnamecmp(p, "cmd") == 0
3822 || fnamecmp(p, "sh.exe") == 0
3823 || fnamecmp(p, "ksh.exe") == 0
3824 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003825 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003826 || fnamecmp(p, "bash.exe") == 0
3827 || fnamecmp(p, "cmd.exe") == 0
3828# endif
3829 )
3830# endif
3831 {
3832#if defined(FEAT_QUICKFIX)
3833 if (do_sp)
3834 {
3835# ifdef WIN3264
3836 p_sp = (char_u *)">%s 2>&1";
3837# else
3838 p_sp = (char_u *)"2>&1| tee";
3839# endif
3840 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3841 }
3842#endif
3843 if (do_srr)
3844 {
3845 p_srr = (char_u *)">%s 2>&1";
3846 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3847 }
3848 }
3849 vim_free(p);
3850 }
3851#endif
3852
3853#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3854 /*
3855 * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
3856 * This is done after other initializations, where 'shell' might have been
3857 * set, but only if they have not been set before. Default for p_shcf is
3858 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3859 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3860 * command.com. And for Win32 we need to set p_sxq instead.
3861 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003862 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003863 {
3864 int idx3;
3865
3866 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003867 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003868 {
3869 p_shcf = (char_u *)"-c";
3870 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3871 }
3872
3873# ifndef DJGPP
3874# ifdef WIN3264
3875 /* Somehow Win32 requires the quotes around the redirection too */
3876 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003877 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878 {
3879 p_sxq = (char_u *)"\"";
3880 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3881 }
3882# else
3883 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003884 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003885 {
3886 p_shq = (char_u *)"\"";
3887 options[idx3].def_val[VI_DEFAULT] = p_shq;
3888 }
3889# endif
3890# endif
3891 }
3892#endif
3893
3894#ifdef FEAT_TITLE
3895 set_title_defaults();
3896#endif
3897}
3898
3899#if defined(FEAT_MULTI_LANG) || defined(PROTO)
3900/*
3901 * When 'helplang' is still at its default value, set it to "lang".
3902 * Only the first two characters of "lang" are used.
3903 */
3904 void
3905set_helplang_default(lang)
3906 char_u *lang;
3907{
3908 int idx;
3909
3910 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
3911 return;
3912 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003913 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914 {
3915 if (options[idx].flags & P_ALLOCED)
3916 free_string_option(p_hlg);
3917 p_hlg = vim_strsave(lang);
3918 if (p_hlg == NULL)
3919 p_hlg = empty_option;
3920 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00003921 {
3922 /* zh_CN becomes "cn", zh_TW becomes "tw". */
3923 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
3924 {
3925 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
3926 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
3927 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003928 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00003929 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003930 options[idx].flags |= P_ALLOCED;
3931 }
3932}
3933#endif
3934
3935#ifdef FEAT_GUI
3936static char_u *gui_bg_default __ARGS((void));
3937
3938 static char_u *
3939gui_bg_default()
3940{
3941 if (gui_get_lightness(gui.back_pixel) < 127)
3942 return (char_u *)"dark";
3943 return (char_u *)"light";
3944}
3945
3946/*
3947 * Option initializations that can only be done after opening the GUI window.
3948 */
3949 void
3950init_gui_options()
3951{
3952 /* Set the 'background' option according to the lightness of the
3953 * background color, unless the user has set it already. */
3954 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
3955 {
3956 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
3957 highlight_changed();
3958 }
3959}
3960#endif
3961
3962#ifdef FEAT_TITLE
3963/*
3964 * 'title' and 'icon' only default to true if they have not been set or reset
3965 * in .vimrc and we can read the old value.
3966 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
3967 * they can be reset. This reduces startup time when using X on a remote
3968 * machine.
3969 */
3970 void
3971set_title_defaults()
3972{
3973 int idx1;
3974 long val;
3975
3976 /*
3977 * If GUI is (going to be) used, we can always set the window title and
3978 * icon name. Saves a bit of time, because the X11 display server does
3979 * not need to be contacted.
3980 */
3981 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003982 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003983 {
3984#ifdef FEAT_GUI
3985 if (gui.starting || gui.in_use)
3986 val = TRUE;
3987 else
3988#endif
3989 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003990 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003991 p_title = val;
3992 }
3993 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003994 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003995 {
3996#ifdef FEAT_GUI
3997 if (gui.starting || gui.in_use)
3998 val = TRUE;
3999 else
4000#endif
4001 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004002 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004003 p_icon = val;
4004 }
4005}
4006#endif
4007
4008/*
4009 * Parse 'arg' for option settings.
4010 *
4011 * 'arg' may be IObuff, but only when no errors can be present and option
4012 * does not need to be expanded with option_expand().
4013 * "opt_flags":
4014 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004015 * OPT_GLOBAL for ":setglobal"
4016 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004017 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004018 * OPT_WINONLY to only set window-local options
4019 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004020 *
4021 * returns FAIL if an error is detected, OK otherwise
4022 */
4023 int
4024do_set(arg, opt_flags)
4025 char_u *arg; /* option string (may be written to!) */
4026 int opt_flags;
4027{
4028 int opt_idx;
4029 char_u *errmsg;
4030 char_u errbuf[80];
4031 char_u *startarg;
4032 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4033 int nextchar; /* next non-white char after option name */
4034 int afterchar; /* character just after option name */
4035 int len;
4036 int i;
4037 long value;
4038 int key;
4039 long_u flags; /* flags for current option */
4040 char_u *varp = NULL; /* pointer to variable for current option */
4041 int did_show = FALSE; /* already showed one value */
4042 int adding; /* "opt+=arg" */
4043 int prepending; /* "opt^=arg" */
4044 int removing; /* "opt-=arg" */
4045 int cp_val = 0;
4046 char_u key_name[2];
4047
4048 if (*arg == NUL)
4049 {
4050 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004051 did_show = TRUE;
4052 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004053 }
4054
4055 while (*arg != NUL) /* loop to process all options */
4056 {
4057 errmsg = NULL;
4058 startarg = arg; /* remember for error message */
4059
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004060 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4061 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062 {
4063 /*
4064 * ":set all" show all options.
4065 * ":set all&" set all options to their default value.
4066 */
4067 arg += 3;
4068 if (*arg == '&')
4069 {
4070 ++arg;
4071 /* Only for :set command set global value of local options. */
4072 set_options_default(OPT_FREE | opt_flags);
4073 }
4074 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004075 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004076 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004077 did_show = TRUE;
4078 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004079 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004080 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081 {
4082 showoptions(2, opt_flags);
4083 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004084 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004085 arg += 7;
4086 }
4087 else
4088 {
4089 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004090 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004091 {
4092 prefix = 0;
4093 arg += 2;
4094 }
4095 else if (STRNCMP(arg, "inv", 3) == 0)
4096 {
4097 prefix = 2;
4098 arg += 3;
4099 }
4100
4101 /* find end of name */
4102 key = 0;
4103 if (*arg == '<')
4104 {
4105 nextchar = 0;
4106 opt_idx = -1;
4107 /* look out for <t_>;> */
4108 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4109 len = 5;
4110 else
4111 {
4112 len = 1;
4113 while (arg[len] != NUL && arg[len] != '>')
4114 ++len;
4115 }
4116 if (arg[len] != '>')
4117 {
4118 errmsg = e_invarg;
4119 goto skip;
4120 }
4121 arg[len] = NUL; /* put NUL after name */
4122 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4123 opt_idx = findoption(arg + 1);
4124 arg[len++] = '>'; /* restore '>' */
4125 if (opt_idx == -1)
4126 key = find_key_option(arg + 1);
4127 }
4128 else
4129 {
4130 len = 0;
4131 /*
4132 * The two characters after "t_" may not be alphanumeric.
4133 */
4134 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4135 len = 4;
4136 else
4137 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4138 ++len;
4139 nextchar = arg[len];
4140 arg[len] = NUL; /* put NUL after name */
4141 opt_idx = findoption(arg);
4142 arg[len] = nextchar; /* restore nextchar */
4143 if (opt_idx == -1)
4144 key = find_key_option(arg);
4145 }
4146
4147 /* remember character after option name */
4148 afterchar = arg[len];
4149
4150 /* skip white space, allow ":set ai ?" */
4151 while (vim_iswhite(arg[len]))
4152 ++len;
4153
4154 adding = FALSE;
4155 prepending = FALSE;
4156 removing = FALSE;
4157 if (arg[len] != NUL && arg[len + 1] == '=')
4158 {
4159 if (arg[len] == '+')
4160 {
4161 adding = TRUE; /* "+=" */
4162 ++len;
4163 }
4164 else if (arg[len] == '^')
4165 {
4166 prepending = TRUE; /* "^=" */
4167 ++len;
4168 }
4169 else if (arg[len] == '-')
4170 {
4171 removing = TRUE; /* "-=" */
4172 ++len;
4173 }
4174 }
4175 nextchar = arg[len];
4176
4177 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4178 {
4179 errmsg = (char_u *)N_("E518: Unknown option");
4180 goto skip;
4181 }
4182
4183 if (opt_idx >= 0)
4184 {
4185 if (options[opt_idx].var == NULL) /* hidden option: skip */
4186 {
4187 /* Only give an error message when requesting the value of
4188 * a hidden option, ignore setting it. */
4189 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4190 && (!(options[opt_idx].flags & P_BOOL)
4191 || nextchar == '?'))
4192 errmsg = (char_u *)N_("E519: Option not supported");
4193 goto skip;
4194 }
4195
4196 flags = options[opt_idx].flags;
4197 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4198 }
4199 else
4200 {
4201 flags = P_STRING;
4202 if (key < 0)
4203 {
4204 key_name[0] = KEY2TERMCAP0(key);
4205 key_name[1] = KEY2TERMCAP1(key);
4206 }
4207 else
4208 {
4209 key_name[0] = KS_KEY;
4210 key_name[1] = (key & 0xff);
4211 }
4212 }
4213
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004214 /* Skip all options that are not window-local (used when showing
4215 * an already loaded buffer in a window). */
4216 if ((opt_flags & OPT_WINONLY)
4217 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4218 goto skip;
4219
Bram Moolenaara3227e22006-03-08 21:32:40 +00004220 /* Skip all options that are window-local (used for :vimgrep). */
4221 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4222 && options[opt_idx].var == VAR_WIN)
4223 goto skip;
4224
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004225 /* Disallow changing some options from modelines. */
4226 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004227 {
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004228 if (flags & P_SECURE)
4229 {
4230 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4231 goto skip;
4232 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004233#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004234 /* In diff mode some options are overruled. This avoids that
4235 * 'foldmethod' becomes "marker" instead of "diff" and that
4236 * "wrap" gets set. */
4237 if (curwin->w_p_diff
4238 && (options[opt_idx].indir == PV_FDM
4239 || options[opt_idx].indir == PV_WRAP))
4240 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004241#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004242 }
4243
4244#ifdef HAVE_SANDBOX
4245 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004246 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004247 {
4248 errmsg = (char_u *)_(e_sandbox);
4249 goto skip;
4250 }
4251#endif
4252
4253 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4254 {
4255 arg += len;
4256 cp_val = p_cp;
4257 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4258 {
4259 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4260 {
4261 cp_val = FALSE;
4262 arg += 3;
4263 }
4264 else /* "opt&vi": set to Vi default */
4265 {
4266 cp_val = TRUE;
4267 arg += 2;
4268 }
4269 }
4270 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4271 && arg[1] != NUL && !vim_iswhite(arg[1]))
4272 {
4273 errmsg = e_trailing;
4274 goto skip;
4275 }
4276 }
4277
4278 /*
4279 * allow '=' and ':' as MSDOS command.com allows only one
4280 * '=' character per "set" command line. grrr. (jw)
4281 */
4282 if (nextchar == '?'
4283 || (prefix == 1
4284 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4285 && !(flags & P_BOOL)))
4286 {
4287 /*
4288 * print value
4289 */
4290 if (did_show)
4291 msg_putchar('\n'); /* cursor below last one */
4292 else
4293 {
4294 gotocmdline(TRUE); /* cursor at status line */
4295 did_show = TRUE; /* remember that we did a line */
4296 }
4297 if (opt_idx >= 0)
4298 {
4299 showoneopt(&options[opt_idx], opt_flags);
4300#ifdef FEAT_EVAL
4301 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004302 {
4303 /* Mention where the option was last set. */
4304 if (varp == options[opt_idx].var)
4305 last_set_msg(options[opt_idx].scriptID);
4306 else if ((int)options[opt_idx].indir & PV_WIN)
4307 last_set_msg(curwin->w_p_scriptID[
4308 (int)options[opt_idx].indir & PV_MASK]);
4309 else if ((int)options[opt_idx].indir & PV_BUF)
4310 last_set_msg(curbuf->b_p_scriptID[
4311 (int)options[opt_idx].indir & PV_MASK]);
4312 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004313#endif
4314 }
4315 else
4316 {
4317 char_u *p;
4318
4319 p = find_termcode(key_name);
4320 if (p == NULL)
4321 {
4322 errmsg = (char_u *)N_("E518: Unknown option");
4323 goto skip;
4324 }
4325 else
4326 (void)show_one_termcode(key_name, p, TRUE);
4327 }
4328 if (nextchar != '?'
4329 && nextchar != NUL && !vim_iswhite(afterchar))
4330 errmsg = e_trailing;
4331 }
4332 else
4333 {
4334 if (flags & P_BOOL) /* boolean */
4335 {
4336 if (nextchar == '=' || nextchar == ':')
4337 {
4338 errmsg = e_invarg;
4339 goto skip;
4340 }
4341
4342 /*
4343 * ":set opt!": invert
4344 * ":set opt&": reset to default value
4345 * ":set opt<": reset to global value
4346 */
4347 if (nextchar == '!')
4348 value = *(int *)(varp) ^ 1;
4349 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004350 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004351 ((flags & P_VI_DEF) || cp_val)
4352 ? VI_DEFAULT : VIM_DEFAULT];
4353 else if (nextchar == '<')
4354 {
4355 /* For 'autoread' -1 means to use global value. */
4356 if ((int *)varp == &curbuf->b_p_ar
4357 && opt_flags == OPT_LOCAL)
4358 value = -1;
4359 else
4360 value = *(int *)get_varp_scope(&(options[opt_idx]),
4361 OPT_GLOBAL);
4362 }
4363 else
4364 {
4365 /*
4366 * ":set invopt": invert
4367 * ":set opt" or ":set noopt": set or reset
4368 */
4369 if (nextchar != NUL && !vim_iswhite(afterchar))
4370 {
4371 errmsg = e_trailing;
4372 goto skip;
4373 }
4374 if (prefix == 2) /* inv */
4375 value = *(int *)(varp) ^ 1;
4376 else
4377 value = prefix;
4378 }
4379
4380 errmsg = set_bool_option(opt_idx, varp, (int)value,
4381 opt_flags);
4382 }
4383 else /* numeric or string */
4384 {
4385 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4386 || prefix != 1)
4387 {
4388 errmsg = e_invarg;
4389 goto skip;
4390 }
4391
4392 if (flags & P_NUM) /* numeric */
4393 {
4394 /*
4395 * Different ways to set a number option:
4396 * & set to default value
4397 * < set to global value
4398 * <xx> accept special key codes for 'wildchar'
4399 * c accept any non-digit for 'wildchar'
4400 * [-]0-9 set number
4401 * other error
4402 */
4403 ++arg;
4404 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004405 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004406 ((flags & P_VI_DEF) || cp_val)
4407 ? VI_DEFAULT : VIM_DEFAULT];
4408 else if (nextchar == '<')
4409 value = *(long *)get_varp_scope(&(options[opt_idx]),
4410 OPT_GLOBAL);
4411 else if (((long *)varp == &p_wc
4412 || (long *)varp == &p_wcm)
4413 && (*arg == '<'
4414 || *arg == '^'
4415 || ((!arg[1] || vim_iswhite(arg[1]))
4416 && !VIM_ISDIGIT(*arg))))
4417 {
4418 value = string_to_key(arg);
4419 if (value == 0 && (long *)varp != &p_wcm)
4420 {
4421 errmsg = e_invarg;
4422 goto skip;
4423 }
4424 }
4425 /* allow negative numbers (for 'undolevels') */
4426 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4427 {
4428 i = 0;
4429 if (*arg == '-')
4430 i = 1;
4431#ifdef HAVE_STRTOL
4432 value = strtol((char *)arg, NULL, 0);
4433 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
4434 i += 2;
4435#else
4436 value = atol((char *)arg);
4437#endif
4438 while (VIM_ISDIGIT(arg[i]))
4439 ++i;
4440 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4441 {
4442 errmsg = e_invarg;
4443 goto skip;
4444 }
4445 }
4446 else
4447 {
4448 errmsg = (char_u *)N_("E521: Number required after =");
4449 goto skip;
4450 }
4451
4452 if (adding)
4453 value = *(long *)varp + value;
4454 if (prepending)
4455 value = *(long *)varp * value;
4456 if (removing)
4457 value = *(long *)varp - value;
4458 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004459 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004460 }
4461 else if (opt_idx >= 0) /* string */
4462 {
4463 char_u *save_arg = NULL;
4464 char_u *s = NULL;
4465 char_u *oldval; /* previous value if *varp */
4466 char_u *newval;
4467 char_u *origval;
4468 unsigned newlen;
4469 int comma;
4470 int bs;
4471 int new_value_alloced; /* new string option
4472 was allocated */
4473
4474 /* When using ":set opt=val" for a global option
4475 * with a local value the local value will be
4476 * reset, use the global value here. */
4477 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004478 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004479 varp = options[opt_idx].var;
4480
4481 /* The old value is kept until we are sure that the
4482 * new value is valid. */
4483 oldval = *(char_u **)varp;
4484 if (nextchar == '&') /* set to default val */
4485 {
4486 newval = options[opt_idx].def_val[
4487 ((flags & P_VI_DEF) || cp_val)
4488 ? VI_DEFAULT : VIM_DEFAULT];
4489 if ((char_u **)varp == &p_bg)
4490 {
4491 /* guess the value of 'background' */
4492#ifdef FEAT_GUI
4493 if (gui.in_use)
4494 newval = gui_bg_default();
4495 else
4496#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004497 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004498 }
4499
4500 /* expand environment variables and ~ (since the
4501 * default value was already expanded, only
4502 * required when an environment variable was set
4503 * later */
4504 if (newval == NULL)
4505 newval = empty_option;
4506 else
4507 {
4508 s = option_expand(opt_idx, newval);
4509 if (s == NULL)
4510 s = newval;
4511 newval = vim_strsave(s);
4512 }
4513 new_value_alloced = TRUE;
4514 }
4515 else if (nextchar == '<') /* set to global val */
4516 {
4517 newval = vim_strsave(*(char_u **)get_varp_scope(
4518 &(options[opt_idx]), OPT_GLOBAL));
4519 new_value_alloced = TRUE;
4520 }
4521 else
4522 {
4523 ++arg; /* jump to after the '=' or ':' */
4524
4525 /*
4526 * Set 'keywordprg' to ":help" if an empty
4527 * value was passed to :set by the user.
4528 * Misuse errbuf[] for the resulting string.
4529 */
4530 if (varp == (char_u *)&p_kp
4531 && (*arg == NUL || *arg == ' '))
4532 {
4533 STRCPY(errbuf, ":help");
4534 save_arg = arg;
4535 arg = errbuf;
4536 }
4537 /*
4538 * Convert 'whichwrap' number to string, for
4539 * backwards compatibility with Vim 3.0.
4540 * Misuse errbuf[] for the resulting string.
4541 */
4542 else if (varp == (char_u *)&p_ww
4543 && VIM_ISDIGIT(*arg))
4544 {
4545 *errbuf = NUL;
4546 i = getdigits(&arg);
4547 if (i & 1)
4548 STRCAT(errbuf, "b,");
4549 if (i & 2)
4550 STRCAT(errbuf, "s,");
4551 if (i & 4)
4552 STRCAT(errbuf, "h,l,");
4553 if (i & 8)
4554 STRCAT(errbuf, "<,>,");
4555 if (i & 16)
4556 STRCAT(errbuf, "[,],");
4557 if (*errbuf != NUL) /* remove trailing , */
4558 errbuf[STRLEN(errbuf) - 1] = NUL;
4559 save_arg = arg;
4560 arg = errbuf;
4561 }
4562 /*
4563 * Remove '>' before 'dir' and 'bdir', for
4564 * backwards compatibility with version 3.0
4565 */
4566 else if ( *arg == '>'
4567 && (varp == (char_u *)&p_dir
4568 || varp == (char_u *)&p_bdir))
4569 {
4570 ++arg;
4571 }
4572
4573 /* When setting the local value of a global
4574 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004575 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004576 && (opt_flags & OPT_LOCAL))
4577 origval = *(char_u **)get_varp(
4578 &options[opt_idx]);
4579 else
4580 origval = oldval;
4581
4582 /*
4583 * Copy the new string into allocated memory.
4584 * Can't use set_string_option_direct(), because
4585 * we need to remove the backslashes.
4586 */
4587 /* get a bit too much */
4588 newlen = (unsigned)STRLEN(arg) + 1;
4589 if (adding || prepending || removing)
4590 newlen += (unsigned)STRLEN(origval) + 1;
4591 newval = alloc(newlen);
4592 if (newval == NULL) /* out of mem, don't change */
4593 break;
4594 s = newval;
4595
4596 /*
4597 * Copy the string, skip over escaped chars.
4598 * For MS-DOS and WIN32 backslashes before normal
4599 * file name characters are not removed, and keep
4600 * backslash at start, for "\\machine\path", but
4601 * do remove it for "\\\\machine\\path".
4602 * The reverse is found in ExpandOldSetting().
4603 */
4604 while (*arg && !vim_iswhite(*arg))
4605 {
4606 if (*arg == '\\' && arg[1] != NUL
4607#ifdef BACKSLASH_IN_FILENAME
4608 && !((flags & P_EXPAND)
4609 && vim_isfilec(arg[1])
4610 && (arg[1] != '\\'
4611 || (s == newval
4612 && arg[2] != '\\')))
4613#endif
4614 )
4615 ++arg; /* remove backslash */
4616#ifdef FEAT_MBYTE
4617 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004618 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004619 {
4620 /* copy multibyte char */
4621 mch_memmove(s, arg, (size_t)i);
4622 arg += i;
4623 s += i;
4624 }
4625 else
4626#endif
4627 *s++ = *arg++;
4628 }
4629 *s = NUL;
4630
4631 /*
4632 * Expand environment variables and ~.
4633 * Don't do it when adding without inserting a
4634 * comma.
4635 */
4636 if (!(adding || prepending || removing)
4637 || (flags & P_COMMA))
4638 {
4639 s = option_expand(opt_idx, newval);
4640 if (s != NULL)
4641 {
4642 vim_free(newval);
4643 newlen = (unsigned)STRLEN(s) + 1;
4644 if (adding || prepending || removing)
4645 newlen += (unsigned)STRLEN(origval) + 1;
4646 newval = alloc(newlen);
4647 if (newval == NULL)
4648 break;
4649 STRCPY(newval, s);
4650 }
4651 }
4652
4653 /* locate newval[] in origval[] when removing it
4654 * and when adding to avoid duplicates */
4655 i = 0; /* init for GCC */
4656 if (removing || (flags & P_NODUP))
4657 {
4658 i = (int)STRLEN(newval);
4659 bs = 0;
4660 for (s = origval; *s; ++s)
4661 {
4662 if ((!(flags & P_COMMA)
4663 || s == origval
4664 || (s[-1] == ',' && !(bs & 1)))
4665 && STRNCMP(s, newval, i) == 0
4666 && (!(flags & P_COMMA)
4667 || s[i] == ','
4668 || s[i] == NUL))
4669 break;
4670 /* Count backspaces. Only a comma with an
4671 * even number of backspaces before it is
4672 * recognized as a separator */
4673 if (s > origval && s[-1] == '\\')
4674 ++bs;
4675 else
4676 bs = 0;
4677 }
4678
4679 /* do not add if already there */
4680 if ((adding || prepending) && *s)
4681 {
4682 prepending = FALSE;
4683 adding = FALSE;
4684 STRCPY(newval, origval);
4685 }
4686 }
4687
4688 /* concatenate the two strings; add a ',' if
4689 * needed */
4690 if (adding || prepending)
4691 {
4692 comma = ((flags & P_COMMA) && *origval != NUL
4693 && *newval != NUL);
4694 if (adding)
4695 {
4696 i = (int)STRLEN(origval);
4697 mch_memmove(newval + i + comma, newval,
4698 STRLEN(newval) + 1);
4699 mch_memmove(newval, origval, (size_t)i);
4700 }
4701 else
4702 {
4703 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004704 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004705 }
4706 if (comma)
4707 newval[i] = ',';
4708 }
4709
4710 /* Remove newval[] from origval[]. (Note: "i" has
4711 * been set above and is used here). */
4712 if (removing)
4713 {
4714 STRCPY(newval, origval);
4715 if (*s)
4716 {
4717 /* may need to remove a comma */
4718 if (flags & P_COMMA)
4719 {
4720 if (s == origval)
4721 {
4722 /* include comma after string */
4723 if (s[i] == ',')
4724 ++i;
4725 }
4726 else
4727 {
4728 /* include comma before string */
4729 --s;
4730 ++i;
4731 }
4732 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004733 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004734 }
4735 }
4736
4737 if (flags & P_FLAGLIST)
4738 {
4739 /* Remove flags that appear twice. */
4740 for (s = newval; *s; ++s)
4741 if ((!(flags & P_COMMA) || *s != ',')
4742 && vim_strchr(s + 1, *s) != NULL)
4743 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004744 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004745 --s;
4746 }
4747 }
4748
4749 if (save_arg != NULL) /* number for 'whichwrap' */
4750 arg = save_arg;
4751 new_value_alloced = TRUE;
4752 }
4753
4754 /* Set the new value. */
4755 *(char_u **)(varp) = newval;
4756
4757 /* Handle side effects, and set the global value for
4758 * ":set" on local options. */
4759 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4760 new_value_alloced, oldval, errbuf, opt_flags);
4761
4762 /* If error detected, print the error message. */
4763 if (errmsg != NULL)
4764 goto skip;
4765 }
4766 else /* key code option */
4767 {
4768 char_u *p;
4769
4770 if (nextchar == '&')
4771 {
4772 if (add_termcap_entry(key_name, TRUE) == FAIL)
4773 errmsg = (char_u *)N_("E522: Not found in termcap");
4774 }
4775 else
4776 {
4777 ++arg; /* jump to after the '=' or ':' */
4778 for (p = arg; *p && !vim_iswhite(*p); ++p)
4779 if (*p == '\\' && p[1] != NUL)
4780 ++p;
4781 nextchar = *p;
4782 *p = NUL;
4783 add_termcode(key_name, arg, FALSE);
4784 *p = nextchar;
4785 }
4786 if (full_screen)
4787 ttest(FALSE);
4788 redraw_all_later(CLEAR);
4789 }
4790 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004791
Bram Moolenaar071d4272004-06-13 20:20:40 +00004792 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004793 did_set_option(opt_idx, opt_flags,
4794 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004795 }
4796
4797skip:
4798 /*
4799 * Advance to next argument.
4800 * - skip until a blank found, taking care of backslashes
4801 * - skip blanks
4802 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4803 */
4804 for (i = 0; i < 2 ; ++i)
4805 {
4806 while (*arg != NUL && !vim_iswhite(*arg))
4807 if (*arg++ == '\\' && *arg != NUL)
4808 ++arg;
4809 arg = skipwhite(arg);
4810 if (*arg != '=')
4811 break;
4812 }
4813 }
4814
4815 if (errmsg != NULL)
4816 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00004817 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00004818 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004819 if (i + (arg - startarg) < IOSIZE)
4820 {
4821 /* append the argument with the error */
4822 STRCAT(IObuff, ": ");
4823 mch_memmove(IObuff + i, startarg, (arg - startarg));
4824 IObuff[i + (arg - startarg)] = NUL;
4825 }
4826 /* make sure all characters are printable */
4827 trans_characters(IObuff, IOSIZE);
4828
4829 ++no_wait_return; /* wait_return done later */
4830 emsg(IObuff); /* show error highlighted */
4831 --no_wait_return;
4832
4833 return FAIL;
4834 }
4835
4836 arg = skipwhite(arg);
4837 }
4838
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004839theend:
4840 if (silent_mode && did_show)
4841 {
4842 /* After displaying option values in silent mode. */
4843 silent_mode = FALSE;
4844 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
4845 msg_putchar('\n');
4846 cursor_on(); /* msg_start() switches it off */
4847 out_flush();
4848 silent_mode = TRUE;
4849 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
4850 }
4851
Bram Moolenaar071d4272004-06-13 20:20:40 +00004852 return OK;
4853}
4854
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004855/*
4856 * Call this when an option has been given a new value through a user command.
4857 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4858 */
4859 static void
4860did_set_option(opt_idx, opt_flags, new_value)
4861 int opt_idx;
4862 int opt_flags; /* possibly with OPT_MODELINE */
4863 int new_value; /* value was replaced completely */
4864{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004865 long_u *p;
4866
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004867 options[opt_idx].flags |= P_WAS_SET;
4868
4869 /* When an option is set in the sandbox, from a modeline or in secure mode
4870 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004871 * flag. */
4872 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004873 if (secure
4874#ifdef HAVE_SANDBOX
4875 || sandbox != 0
4876#endif
4877 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004878 *p = *p | P_INSECURE;
4879 else if (new_value)
4880 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004881}
4882
Bram Moolenaar071d4272004-06-13 20:20:40 +00004883 static char_u *
4884illegal_char(errbuf, c)
4885 char_u *errbuf;
4886 int c;
4887{
4888 if (errbuf == NULL)
4889 return (char_u *)"";
4890 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00004891 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00004892 return errbuf;
4893}
4894
4895/*
4896 * Convert a key name or string into a key value.
4897 * Used for 'wildchar' and 'cedit' options.
4898 */
4899 static int
4900string_to_key(arg)
4901 char_u *arg;
4902{
4903 if (*arg == '<')
4904 return find_key_option(arg + 1);
4905 if (*arg == '^')
4906 return Ctrl_chr(arg[1]);
4907 return *arg;
4908}
4909
4910#ifdef FEAT_CMDWIN
4911/*
4912 * Check value of 'cedit' and set cedit_key.
4913 * Returns NULL if value is OK, error message otherwise.
4914 */
4915 static char_u *
4916check_cedit()
4917{
4918 int n;
4919
4920 if (*p_cedit == NUL)
4921 cedit_key = -1;
4922 else
4923 {
4924 n = string_to_key(p_cedit);
4925 if (vim_isprintc(n))
4926 return e_invarg;
4927 cedit_key = n;
4928 }
4929 return NULL;
4930}
4931#endif
4932
4933#ifdef FEAT_TITLE
4934/*
4935 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
4936 * maketitle() to create and display it.
4937 * When switching the title or icon off, call mch_restore_title() to get
4938 * the old value back.
4939 */
4940 static void
4941did_set_title(icon)
4942 int icon; /* Did set icon instead of title */
4943{
4944 if (starting != NO_SCREEN
4945#ifdef FEAT_GUI
4946 && !gui.starting
4947#endif
4948 )
4949 {
4950 maketitle();
4951 if (icon)
4952 {
4953 if (!p_icon)
4954 mch_restore_title(2);
4955 }
4956 else
4957 {
4958 if (!p_title)
4959 mch_restore_title(1);
4960 }
4961 }
4962}
4963#endif
4964
4965/*
4966 * set_options_bin - called when 'bin' changes value.
4967 */
4968 void
4969set_options_bin(oldval, newval, opt_flags)
4970 int oldval;
4971 int newval;
4972 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
4973{
4974 /*
4975 * The option values that are changed when 'bin' changes are
4976 * copied when 'bin is set and restored when 'bin' is reset.
4977 */
4978 if (newval)
4979 {
4980 if (!oldval) /* switched on */
4981 {
4982 if (!(opt_flags & OPT_GLOBAL))
4983 {
4984 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
4985 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
4986 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
4987 curbuf->b_p_et_nobin = curbuf->b_p_et;
4988 }
4989 if (!(opt_flags & OPT_LOCAL))
4990 {
4991 p_tw_nobin = p_tw;
4992 p_wm_nobin = p_wm;
4993 p_ml_nobin = p_ml;
4994 p_et_nobin = p_et;
4995 }
4996 }
4997
4998 if (!(opt_flags & OPT_GLOBAL))
4999 {
5000 curbuf->b_p_tw = 0; /* no automatic line wrap */
5001 curbuf->b_p_wm = 0; /* no automatic line wrap */
5002 curbuf->b_p_ml = 0; /* no modelines */
5003 curbuf->b_p_et = 0; /* no expandtab */
5004 }
5005 if (!(opt_flags & OPT_LOCAL))
5006 {
5007 p_tw = 0;
5008 p_wm = 0;
5009 p_ml = FALSE;
5010 p_et = FALSE;
5011 p_bin = TRUE; /* needed when called for the "-b" argument */
5012 }
5013 }
5014 else if (oldval) /* switched off */
5015 {
5016 if (!(opt_flags & OPT_GLOBAL))
5017 {
5018 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5019 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5020 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5021 curbuf->b_p_et = curbuf->b_p_et_nobin;
5022 }
5023 if (!(opt_flags & OPT_LOCAL))
5024 {
5025 p_tw = p_tw_nobin;
5026 p_wm = p_wm_nobin;
5027 p_ml = p_ml_nobin;
5028 p_et = p_et_nobin;
5029 }
5030 }
5031}
5032
5033#ifdef FEAT_VIMINFO
5034/*
5035 * Find the parameter represented by the given character (eg ', :, ", or /),
5036 * and return its associated value in the 'viminfo' string.
5037 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005038 * If the parameter is not specified in the string or there is no following
5039 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005040 */
5041 int
5042get_viminfo_parameter(type)
5043 int type;
5044{
5045 char_u *p;
5046
5047 p = find_viminfo_parameter(type);
5048 if (p != NULL && VIM_ISDIGIT(*p))
5049 return atoi((char *)p);
5050 return -1;
5051}
5052
5053/*
5054 * Find the parameter represented by the given character (eg ''', ':', '"', or
5055 * '/') in the 'viminfo' option and return a pointer to the string after it.
5056 * Return NULL if the parameter is not specified in the string.
5057 */
5058 char_u *
5059find_viminfo_parameter(type)
5060 int type;
5061{
5062 char_u *p;
5063
5064 for (p = p_viminfo; *p; ++p)
5065 {
5066 if (*p == type)
5067 return p + 1;
5068 if (*p == 'n') /* 'n' is always the last one */
5069 break;
5070 p = vim_strchr(p, ','); /* skip until next ',' */
5071 if (p == NULL) /* hit the end without finding parameter */
5072 break;
5073 }
5074 return NULL;
5075}
5076#endif
5077
5078/*
5079 * Expand environment variables for some string options.
5080 * These string options cannot be indirect!
5081 * If "val" is NULL expand the current value of the option.
5082 * Return pointer to NameBuff, or NULL when not expanded.
5083 */
5084 static char_u *
5085option_expand(opt_idx, val)
5086 int opt_idx;
5087 char_u *val;
5088{
5089 /* if option doesn't need expansion nothing to do */
5090 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5091 return NULL;
5092
5093 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5094 * expand_env() would truncate the string. */
5095 if (val != NULL && STRLEN(val) > MAXPATHL)
5096 return NULL;
5097
5098 if (val == NULL)
5099 val = *(char_u **)options[opt_idx].var;
5100
5101 /*
5102 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5103 * Escape spaces when expanding 'tags', they are used to separate file
5104 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005105 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005106 */
5107 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005108 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005109#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005110 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5111#endif
5112 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005113 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5114 return NULL;
5115
5116 return NameBuff;
5117}
5118
5119/*
5120 * After setting various option values: recompute variables that depend on
5121 * option values.
5122 */
5123 static void
5124didset_options()
5125{
5126 /* initialize the table for 'iskeyword' et.al. */
5127 (void)init_chartab();
5128
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005129#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005130 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005131#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005132 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5133#ifdef FEAT_SESSION
5134 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5135 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5136#endif
5137#ifdef FEAT_FOLDING
5138 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5139#endif
5140 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5141#ifdef FEAT_VIRTUALEDIT
5142 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5143#endif
5144#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5145 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5146#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005147#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005148 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005149 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005150 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005151#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005152#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5153 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5154#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005155#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005156 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5157#endif
5158#ifdef FEAT_CMDWIN
5159 /* set cedit_key */
5160 (void)check_cedit();
5161#endif
5162}
5163
5164/*
5165 * Check for string options that are NULL (normally only termcap options).
5166 */
5167 void
5168check_options()
5169{
5170 int opt_idx;
5171
5172 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5173 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5174 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5175}
5176
5177/*
5178 * Check string options in a buffer for NULL value.
5179 */
5180 void
5181check_buf_options(buf)
5182 buf_T *buf;
5183{
5184#if defined(FEAT_QUICKFIX)
5185 check_string_option(&buf->b_p_bh);
5186 check_string_option(&buf->b_p_bt);
5187#endif
5188#ifdef FEAT_MBYTE
5189 check_string_option(&buf->b_p_fenc);
5190#endif
5191 check_string_option(&buf->b_p_ff);
5192#ifdef FEAT_FIND_ID
5193 check_string_option(&buf->b_p_def);
5194 check_string_option(&buf->b_p_inc);
5195# ifdef FEAT_EVAL
5196 check_string_option(&buf->b_p_inex);
5197# endif
5198#endif
5199#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5200 check_string_option(&buf->b_p_inde);
5201 check_string_option(&buf->b_p_indk);
5202#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005203#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5204 check_string_option(&buf->b_p_bexpr);
5205#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005206#if defined(FEAT_EVAL)
5207 check_string_option(&buf->b_p_fex);
5208#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005209#ifdef FEAT_CRYPT
5210 check_string_option(&buf->b_p_key);
5211#endif
5212 check_string_option(&buf->b_p_kp);
5213 check_string_option(&buf->b_p_mps);
5214 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005215 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005216 check_string_option(&buf->b_p_isk);
5217#ifdef FEAT_COMMENTS
5218 check_string_option(&buf->b_p_com);
5219#endif
5220#ifdef FEAT_FOLDING
5221 check_string_option(&buf->b_p_cms);
5222#endif
5223 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005224#ifdef FEAT_TEXTOBJ
5225 check_string_option(&buf->b_p_qe);
5226#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005227#ifdef FEAT_SYN_HL
5228 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005229#endif
5230#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005231 check_string_option(&buf->b_s.b_p_spc);
5232 check_string_option(&buf->b_s.b_p_spf);
5233 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005234#endif
5235#ifdef FEAT_SEARCHPATH
5236 check_string_option(&buf->b_p_sua);
5237#endif
5238#ifdef FEAT_CINDENT
5239 check_string_option(&buf->b_p_cink);
5240 check_string_option(&buf->b_p_cino);
5241#endif
5242#ifdef FEAT_AUTOCMD
5243 check_string_option(&buf->b_p_ft);
5244#endif
5245#ifdef FEAT_OSFILETYPE
5246 check_string_option(&buf->b_p_oft);
5247#endif
5248#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5249 check_string_option(&buf->b_p_cinw);
5250#endif
5251#ifdef FEAT_INS_EXPAND
5252 check_string_option(&buf->b_p_cpt);
5253#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005254#ifdef FEAT_COMPL_FUNC
5255 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005256 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005257#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005258#ifdef FEAT_KEYMAP
5259 check_string_option(&buf->b_p_keymap);
5260#endif
5261#ifdef FEAT_QUICKFIX
5262 check_string_option(&buf->b_p_gp);
5263 check_string_option(&buf->b_p_mp);
5264 check_string_option(&buf->b_p_efm);
5265#endif
5266 check_string_option(&buf->b_p_ep);
5267 check_string_option(&buf->b_p_path);
5268 check_string_option(&buf->b_p_tags);
5269#ifdef FEAT_INS_EXPAND
5270 check_string_option(&buf->b_p_dict);
5271 check_string_option(&buf->b_p_tsr);
5272#endif
5273}
5274
5275/*
5276 * Free the string allocated for an option.
5277 * Checks for the string being empty_option. This may happen if we're out of
5278 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5279 * check_options().
5280 * Does NOT check for P_ALLOCED flag!
5281 */
5282 void
5283free_string_option(p)
5284 char_u *p;
5285{
5286 if (p != empty_option)
5287 vim_free(p);
5288}
5289
5290 void
5291clear_string_option(pp)
5292 char_u **pp;
5293{
5294 if (*pp != empty_option)
5295 vim_free(*pp);
5296 *pp = empty_option;
5297}
5298
5299 static void
5300check_string_option(pp)
5301 char_u **pp;
5302{
5303 if (*pp == NULL)
5304 *pp = empty_option;
5305}
5306
5307/*
5308 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5309 */
5310 void
5311set_term_option_alloced(p)
5312 char_u **p;
5313{
5314 int opt_idx;
5315
5316 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5317 if (options[opt_idx].var == (char_u *)p)
5318 {
5319 options[opt_idx].flags |= P_ALLOCED;
5320 return;
5321 }
5322 return; /* cannot happen: didn't find it! */
5323}
5324
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005325#if defined(FEAT_EVAL) || defined(PROTO)
5326/*
5327 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5328 * Return FALSE when it wasn't.
5329 * Return -1 for an unknown option.
5330 */
5331 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005332was_set_insecurely(opt, opt_flags)
5333 char_u *opt;
5334 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005335{
5336 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005337 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005338
5339 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005340 {
5341 flagp = insecure_flag(idx, opt_flags);
5342 return (*flagp & P_INSECURE) != 0;
5343 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005344 EMSG2(_(e_intern2), "was_set_insecurely()");
5345 return -1;
5346}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005347
5348/*
5349 * Get a pointer to the flags used for the P_INSECURE flag of option
5350 * "opt_idx". For some local options a local flags field is used.
5351 */
5352 static long_u *
5353insecure_flag(opt_idx, opt_flags)
5354 int opt_idx;
5355 int opt_flags;
5356{
5357 if (opt_flags & OPT_LOCAL)
5358 switch ((int)options[opt_idx].indir)
5359 {
5360#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005361 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005362#endif
5363#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005364# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005365 case PV_FDE: return &curwin->w_p_fde_flags;
5366 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005367# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005368# ifdef FEAT_BEVAL
5369 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5370# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005371# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005372 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005373# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005374 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005375# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005376 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005377# endif
5378#endif
5379 }
5380
5381 /* Nothing special, return global flags field. */
5382 return &options[opt_idx].flags;
5383}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005384#endif
5385
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005386#ifdef FEAT_TITLE
5387static void redraw_titles __ARGS((void));
5388
5389/*
5390 * Redraw the window title and/or tab page text later.
5391 */
5392static void redraw_titles()
5393{
5394 need_maketitle = TRUE;
5395# ifdef FEAT_WINDOWS
5396 redraw_tabline = TRUE;
5397# endif
5398}
5399#endif
5400
Bram Moolenaar071d4272004-06-13 20:20:40 +00005401/*
5402 * Set a string option to a new value (without checking the effect).
5403 * The string is copied into allocated memory.
5404 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005405 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005406 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005407 */
5408 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005409set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005410 char_u *name;
5411 int opt_idx;
5412 char_u *val;
5413 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005414 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005415{
5416 char_u *s;
5417 char_u **varp;
5418 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005419 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005420
Bram Moolenaar89d40322006-08-29 15:30:07 +00005421 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005422 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005423 idx = findoption(name);
5424 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005425 {
5426 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar071d4272004-06-13 20:20:40 +00005427 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005428 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005429 }
5430
Bram Moolenaar89d40322006-08-29 15:30:07 +00005431 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005432 return;
5433
5434 s = vim_strsave(val);
5435 if (s != NULL)
5436 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005437 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005438 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005439 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005440 free_string_option(*varp);
5441 *varp = s;
5442
5443 /* For buffer/window local option may also set the global value. */
5444 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005445 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005446
Bram Moolenaar89d40322006-08-29 15:30:07 +00005447 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005448
5449 /* When setting both values of a global option with a local value,
5450 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005451 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005452 {
5453 free_string_option(*varp);
5454 *varp = empty_option;
5455 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005456# ifdef FEAT_EVAL
5457 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005458 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005459 set_sid == 0 ? current_SID : set_sid);
5460# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005461 }
5462}
5463
5464/*
5465 * Set global value for string option when it's a local option.
5466 */
5467 static void
5468set_string_option_global(opt_idx, varp)
5469 int opt_idx; /* option index */
5470 char_u **varp; /* pointer to option variable */
5471{
5472 char_u **p, *s;
5473
5474 /* the global value is always allocated */
5475 if (options[opt_idx].var == VAR_WIN)
5476 p = (char_u **)GLOBAL_WO(varp);
5477 else
5478 p = (char_u **)options[opt_idx].var;
5479 if (options[opt_idx].indir != PV_NONE
5480 && p != varp
5481 && (s = vim_strsave(*varp)) != NULL)
5482 {
5483 free_string_option(*p);
5484 *p = s;
5485 }
5486}
5487
5488/*
5489 * Set a string option to a new value, and handle the effects.
5490 */
5491 static void
5492set_string_option(opt_idx, value, opt_flags)
5493 int opt_idx;
5494 char_u *value;
5495 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5496{
5497 char_u *s;
5498 char_u **varp;
5499 char_u *oldval;
5500
5501 if (options[opt_idx].var == NULL) /* don't set hidden option */
5502 return;
5503
5504 s = vim_strsave(value);
5505 if (s != NULL)
5506 {
5507 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5508 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005509 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005510 ? OPT_GLOBAL : OPT_LOCAL)
5511 : opt_flags);
5512 oldval = *varp;
5513 *varp = s;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005514 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5515 opt_flags) == NULL)
5516 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005517 }
5518}
5519
5520/*
5521 * Handle string options that need some action to perform when changed.
5522 * Returns NULL for success, or an error message for an error.
5523 */
5524 static char_u *
5525did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5526 opt_flags)
5527 int opt_idx; /* index in options[] table */
5528 char_u **varp; /* pointer to the option variable */
5529 int new_value_alloced; /* new value was allocated */
5530 char_u *oldval; /* previous value of the option */
5531 char_u *errbuf; /* buffer for errors, or NULL */
5532 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5533{
5534 char_u *errmsg = NULL;
5535 char_u *s, *p;
5536 int did_chartab = FALSE;
5537 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005538 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005539#ifdef FEAT_GUI
5540 /* set when changing an option that only requires a redraw in the GUI */
5541 int redraw_gui_only = FALSE;
5542#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005543
5544 /* Get the global option to compare with, otherwise we would have to check
5545 * two values for all local options. */
5546 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5547
5548 /* Disallow changing some options from secure mode */
5549 if ((secure
5550#ifdef HAVE_SANDBOX
5551 || sandbox != 0
5552#endif
5553 ) && (options[opt_idx].flags & P_SECURE))
5554 {
5555 errmsg = e_secure;
5556 }
5557
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005558 /* Check for a "normal" file name in some options. Disallow a path
5559 * separator (slash and/or backslash), wildcards and characters that are
5560 * often illegal in a file name. */
5561 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005562 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005563 {
5564 errmsg = e_invarg;
5565 }
5566
Bram Moolenaar071d4272004-06-13 20:20:40 +00005567 /* 'term' */
5568 else if (varp == &T_NAME)
5569 {
5570 if (T_NAME[0] == NUL)
5571 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5572#ifdef FEAT_GUI
5573 if (gui.in_use)
5574 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5575 else if (term_is_gui(T_NAME))
5576 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5577#endif
5578 else if (set_termname(T_NAME) == FAIL)
5579 errmsg = (char_u *)N_("E522: Not found in termcap");
5580 else
5581 /* Screen colors may have changed. */
5582 redraw_later_clear();
5583 }
5584
5585 /* 'backupcopy' */
5586 else if (varp == &p_bkc)
5587 {
5588 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
5589 errmsg = e_invarg;
5590 if (((bkc_flags & BKC_AUTO) != 0)
5591 + ((bkc_flags & BKC_YES) != 0)
5592 + ((bkc_flags & BKC_NO) != 0) != 1)
5593 {
5594 /* Must have exactly one of "auto", "yes" and "no". */
5595 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
5596 errmsg = e_invarg;
5597 }
5598 }
5599
5600 /* 'backupext' and 'patchmode' */
5601 else if (varp == &p_bex || varp == &p_pm)
5602 {
5603 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5604 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5605 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5606 }
5607
5608 /*
5609 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5610 * If the new option is invalid, use old value. 'lisp' option: refill
5611 * chartab[] for '-' char
5612 */
5613 else if ( varp == &p_isi
5614 || varp == &(curbuf->b_p_isk)
5615 || varp == &p_isp
5616 || varp == &p_isf)
5617 {
5618 if (init_chartab() == FAIL)
5619 {
5620 did_chartab = TRUE; /* need to restore it below */
5621 errmsg = e_invarg; /* error in value */
5622 }
5623 }
5624
5625 /* 'helpfile' */
5626 else if (varp == &p_hf)
5627 {
5628 /* May compute new values for $VIM and $VIMRUNTIME */
5629 if (didset_vim)
5630 {
5631 vim_setenv((char_u *)"VIM", (char_u *)"");
5632 didset_vim = FALSE;
5633 }
5634 if (didset_vimruntime)
5635 {
5636 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5637 didset_vimruntime = FALSE;
5638 }
5639 }
5640
5641#ifdef FEAT_MULTI_LANG
5642 /* 'helplang' */
5643 else if (varp == &p_hlg)
5644 {
5645 /* Check for "", "ab", "ab,cd", etc. */
5646 for (s = p_hlg; *s != NUL; s += 3)
5647 {
5648 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5649 {
5650 errmsg = e_invarg;
5651 break;
5652 }
5653 if (s[2] == NUL)
5654 break;
5655 }
5656 }
5657#endif
5658
5659 /* 'highlight' */
5660 else if (varp == &p_hl)
5661 {
5662 if (highlight_changed() == FAIL)
5663 errmsg = e_invarg; /* invalid flags */
5664 }
5665
5666 /* 'nrformats' */
5667 else if (gvarp == &p_nf)
5668 {
5669 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5670 errmsg = e_invarg;
5671 }
5672
5673#ifdef FEAT_SESSION
5674 /* 'sessionoptions' */
5675 else if (varp == &p_ssop)
5676 {
5677 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5678 errmsg = e_invarg;
5679 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5680 {
5681 /* Don't allow both "sesdir" and "curdir". */
5682 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5683 errmsg = e_invarg;
5684 }
5685 }
5686 /* 'viewoptions' */
5687 else if (varp == &p_vop)
5688 {
5689 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5690 errmsg = e_invarg;
5691 }
5692#endif
5693
5694 /* 'scrollopt' */
5695#ifdef FEAT_SCROLLBIND
5696 else if (varp == &p_sbo)
5697 {
5698 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5699 errmsg = e_invarg;
5700 }
5701#endif
5702
5703 /* 'ambiwidth' */
5704#ifdef FEAT_MBYTE
5705 else if (varp == &p_ambw)
5706 {
5707 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5708 errmsg = e_invarg;
5709 }
5710#endif
5711
5712 /* 'background' */
5713 else if (varp == &p_bg)
5714 {
5715 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5716 {
5717#ifdef FEAT_EVAL
5718 int dark = (*p_bg == 'd');
5719#endif
5720
5721 init_highlight(FALSE, FALSE);
5722
5723#ifdef FEAT_EVAL
5724 if (dark != (*p_bg == 'd')
5725 && get_var_value((char_u *)"g:colors_name") != NULL)
5726 {
5727 /* The color scheme must have set 'background' back to another
5728 * value, that's not what we want here. Disable the color
5729 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005730 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005731 free_string_option(p_bg);
5732 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5733 check_string_option(&p_bg);
5734 init_highlight(FALSE, FALSE);
5735 }
5736#endif
5737 }
5738 else
5739 errmsg = e_invarg;
5740 }
5741
5742 /* 'wildmode' */
5743 else if (varp == &p_wim)
5744 {
5745 if (check_opt_wim() == FAIL)
5746 errmsg = e_invarg;
5747 }
5748
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00005749#ifdef FEAT_CMDL_COMPL
5750 /* 'wildoptions' */
5751 else if (varp == &p_wop)
5752 {
5753 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
5754 errmsg = e_invarg;
5755 }
5756#endif
5757
Bram Moolenaar071d4272004-06-13 20:20:40 +00005758#ifdef FEAT_WAK
5759 /* 'winaltkeys' */
5760 else if (varp == &p_wak)
5761 {
5762 if (*p_wak == NUL
5763 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
5764 errmsg = e_invarg;
5765# ifdef FEAT_MENU
5766# ifdef FEAT_GUI_MOTIF
5767 else if (gui.in_use)
5768 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5769# else
5770# ifdef FEAT_GUI_GTK
5771 else if (gui.in_use)
5772 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5773# endif
5774# endif
5775# endif
5776 }
5777#endif
5778
5779#ifdef FEAT_AUTOCMD
5780 /* 'eventignore' */
5781 else if (varp == &p_ei)
5782 {
5783 if (check_ei() == FAIL)
5784 errmsg = e_invarg;
5785 }
5786#endif
5787
5788#ifdef FEAT_MBYTE
5789 /* 'encoding' and 'fileencoding' */
5790 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
5791 {
5792 if (gvarp == &p_fenc)
5793 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00005794 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005795 errmsg = e_modifiable;
5796 else if (vim_strchr(*varp, ',') != NULL)
5797 /* No comma allowed in 'fileencoding'; catches confusing it
5798 * with 'fileencodings'. */
5799 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005800 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005801 {
5802# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005803 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005804 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005805# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005806 /* Add 'fileencoding' to the swap file. */
5807 ml_setflags(curbuf);
5808 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005809 }
5810 if (errmsg == NULL)
5811 {
5812 /* canonize the value, so that STRCMP() can be used on it */
5813 p = enc_canonize(*varp);
5814 if (p != NULL)
5815 {
5816 vim_free(*varp);
5817 *varp = p;
5818 }
5819 if (varp == &p_enc)
5820 {
5821 errmsg = mb_init();
5822# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005823 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005824# endif
5825 }
5826 }
5827
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005828# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005829 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
5830 {
5831 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
5832 if (STRCMP(p_tenc, "utf-8") != 0)
5833 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
5834 }
5835# endif
5836
5837 if (errmsg == NULL)
5838 {
5839# ifdef FEAT_KEYMAP
5840 /* When 'keymap' is used and 'encoding' changes, reload the keymap
5841 * (with another encoding). */
5842 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
5843 (void)keymap_init();
5844# endif
5845
5846 /* When 'termencoding' is not empty and 'encoding' changes or when
5847 * 'termencoding' changes, need to setup for keyboard input and
5848 * display output conversion. */
5849 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
5850 {
5851 convert_setup(&input_conv, p_tenc, p_enc);
5852 convert_setup(&output_conv, p_enc, p_tenc);
5853 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00005854
5855# if defined(WIN3264) && defined(FEAT_MBYTE)
5856 /* $HOME may have characters in active code page. */
5857 if (varp == &p_enc)
5858 init_homedir();
5859# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005860 }
5861 }
5862#endif
5863
5864#if defined(FEAT_POSTSCRIPT)
5865 else if (varp == &p_penc)
5866 {
5867 /* Canonize printencoding if VIM standard one */
5868 p = enc_canonize(p_penc);
5869 if (p != NULL)
5870 {
5871 vim_free(p_penc);
5872 p_penc = p;
5873 }
5874 else
5875 {
5876 /* Ensure lower case and '-' for '_' */
5877 for (s = p_penc; *s != NUL; s++)
5878 {
5879 if (*s == '_')
5880 *s = '-';
5881 else
5882 *s = TOLOWER_ASC(*s);
5883 }
5884 }
5885 }
5886#endif
5887
Bram Moolenaar9372a112005-12-06 19:59:18 +00005888#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005889 else if (varp == &p_imak)
5890 {
5891 if (gui.in_use && !im_xim_isvalid_imactivate())
5892 errmsg = e_invarg;
5893 }
5894#endif
5895
5896#ifdef FEAT_KEYMAP
5897 else if (varp == &curbuf->b_p_keymap)
5898 {
5899 /* load or unload key mapping tables */
5900 errmsg = keymap_init();
5901
Bram Moolenaarfab06232009-03-04 03:13:35 +00005902 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005903 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00005904 if (*curbuf->b_p_keymap != NUL)
5905 {
5906 /* Installed a new keymap, switch on using it. */
5907 curbuf->b_p_iminsert = B_IMODE_LMAP;
5908 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
5909 curbuf->b_p_imsearch = B_IMODE_LMAP;
5910 }
5911 else
5912 {
5913 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
5914 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
5915 curbuf->b_p_iminsert = B_IMODE_NONE;
5916 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
5917 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
5918 }
5919 if ((opt_flags & OPT_LOCAL) == 0)
5920 {
5921 set_iminsert_global();
5922 set_imsearch_global();
5923 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005924# ifdef FEAT_WINDOWS
5925 status_redraw_curbuf();
5926# endif
5927 }
5928 }
5929#endif
5930
5931 /* 'fileformat' */
5932 else if (gvarp == &p_ff)
5933 {
5934 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
5935 errmsg = e_modifiable;
5936 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
5937 errmsg = e_invarg;
5938 else
5939 {
5940 /* may also change 'textmode' */
5941 if (get_fileformat(curbuf) == EOL_DOS)
5942 curbuf->b_p_tx = TRUE;
5943 else
5944 curbuf->b_p_tx = FALSE;
5945#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005946 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005947#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005948 /* update flag in swap file */
5949 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01005950 /* Redraw needed when switching to/from "mac": a CR in the text
5951 * will be displayed differently. */
5952 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
5953 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005954 }
5955 }
5956
5957 /* 'fileformats' */
5958 else if (varp == &p_ffs)
5959 {
5960 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
5961 errmsg = e_invarg;
5962 else
5963 {
5964 /* also change 'textauto' */
5965 if (*p_ffs == NUL)
5966 p_ta = FALSE;
5967 else
5968 p_ta = TRUE;
5969 }
5970 }
5971
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02005972#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005973 /* 'cryptkey' */
5974 else if (gvarp == &p_key)
5975 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02005976# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005977 /* Make sure the ":set" command doesn't show the new value in the
5978 * history. */
5979 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02005980# endif
5981 if (STRCMP(curbuf->b_p_key, oldval) != 0)
5982 /* Need to update the swapfile. */
5983 ml_set_crypt_key(curbuf, oldval, curbuf->b_p_cm);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005984 }
5985#endif
5986
5987 /* 'matchpairs' */
5988 else if (gvarp == &p_mps)
5989 {
5990 /* Check for "x:y,x:y" */
5991 for (p = *varp; *p != NUL; p += 4)
5992 {
5993 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
5994 {
5995 errmsg = e_invarg;
5996 break;
5997 }
5998 if (p[3] == NUL)
5999 break;
6000 }
6001 }
6002
6003#ifdef FEAT_COMMENTS
6004 /* 'comments' */
6005 else if (gvarp == &p_com)
6006 {
6007 for (s = *varp; *s; )
6008 {
6009 while (*s && *s != ':')
6010 {
6011 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6012 && !VIM_ISDIGIT(*s) && *s != '-')
6013 {
6014 errmsg = illegal_char(errbuf, *s);
6015 break;
6016 }
6017 ++s;
6018 }
6019 if (*s++ == NUL)
6020 errmsg = (char_u *)N_("E524: Missing colon");
6021 else if (*s == ',' || *s == NUL)
6022 errmsg = (char_u *)N_("E525: Zero length string");
6023 if (errmsg != NULL)
6024 break;
6025 while (*s && *s != ',')
6026 {
6027 if (*s == '\\' && s[1] != NUL)
6028 ++s;
6029 ++s;
6030 }
6031 s = skip_to_option_part(s);
6032 }
6033 }
6034#endif
6035
6036 /* 'listchars' */
6037 else if (varp == &p_lcs)
6038 {
6039 errmsg = set_chars_option(varp);
6040 }
6041
6042#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6043 /* 'fillchars' */
6044 else if (varp == &p_fcs)
6045 {
6046 errmsg = set_chars_option(varp);
6047 }
6048#endif
6049
6050#ifdef FEAT_CMDWIN
6051 /* 'cedit' */
6052 else if (varp == &p_cedit)
6053 {
6054 errmsg = check_cedit();
6055 }
6056#endif
6057
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006058 /* 'verbosefile' */
6059 else if (varp == &p_vfile)
6060 {
6061 verbose_stop();
6062 if (*p_vfile != NUL && verbose_open() == FAIL)
6063 errmsg = e_invarg;
6064 }
6065
Bram Moolenaar071d4272004-06-13 20:20:40 +00006066#ifdef FEAT_VIMINFO
6067 /* 'viminfo' */
6068 else if (varp == &p_viminfo)
6069 {
6070 for (s = p_viminfo; *s;)
6071 {
6072 /* Check it's a valid character */
6073 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6074 {
6075 errmsg = illegal_char(errbuf, *s);
6076 break;
6077 }
6078 if (*s == 'n') /* name is always last one */
6079 {
6080 break;
6081 }
6082 else if (*s == 'r') /* skip until next ',' */
6083 {
6084 while (*++s && *s != ',')
6085 ;
6086 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006087 else if (*s == '%')
6088 {
6089 /* optional number */
6090 while (vim_isdigit(*++s))
6091 ;
6092 }
6093 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006094 ++s; /* no extra chars */
6095 else /* must have a number */
6096 {
6097 while (vim_isdigit(*++s))
6098 ;
6099
6100 if (!VIM_ISDIGIT(*(s - 1)))
6101 {
6102 if (errbuf != NULL)
6103 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006104 sprintf((char *)errbuf,
6105 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006106 transchar_byte(*(s - 1)));
6107 errmsg = errbuf;
6108 }
6109 else
6110 errmsg = (char_u *)"";
6111 break;
6112 }
6113 }
6114 if (*s == ',')
6115 ++s;
6116 else if (*s)
6117 {
6118 if (errbuf != NULL)
6119 errmsg = (char_u *)N_("E527: Missing comma");
6120 else
6121 errmsg = (char_u *)"";
6122 break;
6123 }
6124 }
6125 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6126 errmsg = (char_u *)N_("E528: Must specify a ' value");
6127 }
6128#endif /* FEAT_VIMINFO */
6129
6130 /* terminal options */
6131 else if (istermoption(&options[opt_idx]) && full_screen)
6132 {
6133 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6134 if (varp == &T_CCO)
6135 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006136 int colors = atoi((char *)T_CCO);
6137
6138 /* Only reinitialize colors if t_Co value has really changed to
6139 * avoid expensive reload of colorscheme if t_Co is set to the
6140 * same value multiple times. */
6141 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006142 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006143 t_colors = colors;
6144 if (t_colors <= 1)
6145 {
6146 if (new_value_alloced)
6147 vim_free(T_CCO);
6148 T_CCO = empty_option;
6149 }
6150 /* We now have a different color setup, initialize it again. */
6151 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006152 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006153 }
6154 ttest(FALSE);
6155 if (varp == &T_ME)
6156 {
6157 out_str(T_ME);
6158 redraw_later(CLEAR);
6159#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6160 /* Since t_me has been set, this probably means that the user
6161 * wants to use this as default colors. Need to reset default
6162 * background/foreground colors. */
6163 mch_set_normal_colors();
6164#endif
6165 }
6166 }
6167
6168#ifdef FEAT_LINEBREAK
6169 /* 'showbreak' */
6170 else if (varp == &p_sbr)
6171 {
6172 for (s = p_sbr; *s; )
6173 {
6174 if (ptr2cells(s) != 1)
6175 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006176 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006177 }
6178 }
6179#endif
6180
6181#ifdef FEAT_GUI
6182 /* 'guifont' */
6183 else if (varp == &p_guifont)
6184 {
6185 if (gui.in_use)
6186 {
6187 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006188# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006189 /*
6190 * Put up a font dialog and let the user select a new value.
6191 * If this is cancelled go back to the old value but don't
6192 * give an error message.
6193 */
6194 if (STRCMP(p, "*") == 0)
6195 {
6196 p = gui_mch_font_dialog(oldval);
6197
6198 if (new_value_alloced)
6199 free_string_option(p_guifont);
6200
6201 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6202 new_value_alloced = TRUE;
6203 }
6204# endif
6205 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6206 {
6207# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6208 if (STRCMP(p_guifont, "*") == 0)
6209 {
6210 /* Dialog was cancelled: Keep the old value without giving
6211 * an error message. */
6212 if (new_value_alloced)
6213 free_string_option(p_guifont);
6214 p_guifont = vim_strsave(oldval);
6215 new_value_alloced = TRUE;
6216 }
6217 else
6218# endif
6219 errmsg = (char_u *)N_("E596: Invalid font(s)");
6220 }
6221 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006222 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006223 }
6224# ifdef FEAT_XFONTSET
6225 else if (varp == &p_guifontset)
6226 {
6227 if (STRCMP(p_guifontset, "*") == 0)
6228 errmsg = (char_u *)N_("E597: can't select fontset");
6229 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6230 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006231 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006232 }
6233# endif
6234# ifdef FEAT_MBYTE
6235 else if (varp == &p_guifontwide)
6236 {
6237 if (STRCMP(p_guifontwide, "*") == 0)
6238 errmsg = (char_u *)N_("E533: can't select wide font");
6239 else if (gui_get_wide_font() == FAIL)
6240 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006241 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006242 }
6243# endif
6244#endif
6245
6246#ifdef CURSOR_SHAPE
6247 /* 'guicursor' */
6248 else if (varp == &p_guicursor)
6249 errmsg = parse_shape_opt(SHAPE_CURSOR);
6250#endif
6251
6252#ifdef FEAT_MOUSESHAPE
6253 /* 'mouseshape' */
6254 else if (varp == &p_mouseshape)
6255 {
6256 errmsg = parse_shape_opt(SHAPE_MOUSE);
6257 update_mouseshape(-1);
6258 }
6259#endif
6260
6261#ifdef FEAT_PRINTER
6262 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006263 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006264# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006265 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006266 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006267# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006268#endif
6269
6270#ifdef FEAT_LANGMAP
6271 /* 'langmap' */
6272 else if (varp == &p_langmap)
6273 langmap_set();
6274#endif
6275
6276#ifdef FEAT_LINEBREAK
6277 /* 'breakat' */
6278 else if (varp == &p_breakat)
6279 fill_breakat_flags();
6280#endif
6281
6282#ifdef FEAT_TITLE
6283 /* 'titlestring' and 'iconstring' */
6284 else if (varp == &p_titlestring || varp == &p_iconstring)
6285 {
6286# ifdef FEAT_STL_OPT
6287 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6288
6289 /* NULL => statusline syntax */
6290 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6291 stl_syntax |= flagval;
6292 else
6293 stl_syntax &= ~flagval;
6294# endif
6295 did_set_title(varp == &p_iconstring);
6296
6297 }
6298#endif
6299
6300#ifdef FEAT_GUI
6301 /* 'guioptions' */
6302 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006303 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006304 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006305 redraw_gui_only = TRUE;
6306 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006307#endif
6308
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006309#if defined(FEAT_GUI_TABLINE)
6310 /* 'guitablabel' */
6311 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006312 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006313 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006314 redraw_gui_only = TRUE;
6315 }
6316 /* 'guitabtooltip' */
6317 else if (varp == &p_gtt)
6318 {
6319 redraw_gui_only = TRUE;
6320 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006321#endif
6322
Bram Moolenaar071d4272004-06-13 20:20:40 +00006323#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6324 /* 'ttymouse' */
6325 else if (varp == &p_ttym)
6326 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006327 /* Switch the mouse off before changing the escape sequences used for
6328 * that. */
6329 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006330 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6331 errmsg = e_invarg;
6332 else
6333 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006334 if (termcap_active)
6335 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006336 }
6337#endif
6338
6339#ifdef FEAT_VISUAL
6340 /* 'selection' */
6341 else if (varp == &p_sel)
6342 {
6343 if (*p_sel == NUL
6344 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6345 errmsg = e_invarg;
6346 }
6347
6348 /* 'selectmode' */
6349 else if (varp == &p_slm)
6350 {
6351 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6352 errmsg = e_invarg;
6353 }
6354#endif
6355
6356#ifdef FEAT_BROWSE
6357 /* 'browsedir' */
6358 else if (varp == &p_bsdir)
6359 {
6360 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6361 && !mch_isdir(p_bsdir))
6362 errmsg = e_invarg;
6363 }
6364#endif
6365
6366#ifdef FEAT_VISUAL
6367 /* 'keymodel' */
6368 else if (varp == &p_km)
6369 {
6370 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6371 errmsg = e_invarg;
6372 else
6373 {
6374 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6375 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6376 }
6377 }
6378#endif
6379
6380 /* 'mousemodel' */
6381 else if (varp == &p_mousem)
6382 {
6383 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6384 errmsg = e_invarg;
6385#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6386 else if (*p_mousem != *oldval)
6387 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6388 * to create or delete the popup menus. */
6389 gui_motif_update_mousemodel(root_menu);
6390#endif
6391 }
6392
6393 /* 'switchbuf' */
6394 else if (varp == &p_swb)
6395 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006396 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006397 errmsg = e_invarg;
6398 }
6399
6400 /* 'debug' */
6401 else if (varp == &p_debug)
6402 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006403 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006404 errmsg = e_invarg;
6405 }
6406
6407 /* 'display' */
6408 else if (varp == &p_dy)
6409 {
6410 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6411 errmsg = e_invarg;
6412 else
6413 (void)init_chartab();
6414
6415 }
6416
6417#ifdef FEAT_VERTSPLIT
6418 /* 'eadirection' */
6419 else if (varp == &p_ead)
6420 {
6421 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6422 errmsg = e_invarg;
6423 }
6424#endif
6425
6426#ifdef FEAT_CLIPBOARD
6427 /* 'clipboard' */
6428 else if (varp == &p_cb)
6429 errmsg = check_clipboard_option();
6430#endif
6431
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006432#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006433 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6434 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006435 else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006436 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006437 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006438 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006439
Bram Moolenaar860cae12010-06-05 23:22:07 +02006440 if (varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006441 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006442 l = (int)STRLEN(curbuf->b_s.b_p_spf);
6443 if (l > 0 && (l < 4 || STRCMP(curbuf->b_s.b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006444 ".add") != 0))
6445 errmsg = e_invarg;
6446 }
6447
6448 if (errmsg == NULL)
6449 {
6450 FOR_ALL_WINDOWS(wp)
6451 if (wp->w_buffer == curbuf && wp->w_p_spell)
6452 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006453 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006454# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006455 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006456# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006457 }
6458 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006459 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006460 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006461 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006462 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006463 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006464 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006465 /* 'spellsuggest' */
6466 else if (varp == &p_sps)
6467 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006468 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006469 errmsg = e_invarg;
6470 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006471 /* 'mkspellmem' */
6472 else if (varp == &p_msm)
6473 {
6474 if (spell_check_msm() != OK)
6475 errmsg = e_invarg;
6476 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006477#endif
6478
Bram Moolenaar071d4272004-06-13 20:20:40 +00006479#ifdef FEAT_QUICKFIX
6480 /* When 'bufhidden' is set, check for valid value. */
6481 else if (gvarp == &p_bh)
6482 {
6483 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6484 errmsg = e_invarg;
6485 }
6486
6487 /* When 'buftype' is set, check for valid value. */
6488 else if (gvarp == &p_bt)
6489 {
6490 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6491 errmsg = e_invarg;
6492 else
6493 {
6494# ifdef FEAT_WINDOWS
6495 if (curwin->w_status_height)
6496 {
6497 curwin->w_redr_status = TRUE;
6498 redraw_later(VALID);
6499 }
6500# endif
6501 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006502# ifdef FEAT_TITLE
6503 redraw_titles();
6504# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006505 }
6506 }
6507#endif
6508
6509#ifdef FEAT_STL_OPT
6510 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006511 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006512 {
6513 int wid;
6514
6515 if (varp == &p_ruf) /* reset ru_wid first */
6516 ru_wid = 0;
6517 s = *varp;
6518 if (varp == &p_ruf && *s == '%')
6519 {
6520 /* set ru_wid if 'ruf' starts with "%99(" */
6521 if (*++s == '-') /* ignore a '-' */
6522 s++;
6523 wid = getdigits(&s);
6524 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6525 ru_wid = wid;
6526 else
6527 errmsg = check_stl_option(p_ruf);
6528 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006529 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006530 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006531 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006532 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006533 comp_col();
6534 }
6535#endif
6536
6537#ifdef FEAT_INS_EXPAND
6538 /* check if it is a valid value for 'complete' -- Acevedo */
6539 else if (gvarp == &p_cpt)
6540 {
6541 for (s = *varp; *s;)
6542 {
6543 while(*s == ',' || *s == ' ')
6544 s++;
6545 if (!*s)
6546 break;
6547 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6548 {
6549 errmsg = illegal_char(errbuf, *s);
6550 break;
6551 }
6552 if (*++s != NUL && *s != ',' && *s != ' ')
6553 {
6554 if (s[-1] == 'k' || s[-1] == 's')
6555 {
6556 /* skip optional filename after 'k' and 's' */
6557 while (*s && *s != ',' && *s != ' ')
6558 {
6559 if (*s == '\\')
6560 ++s;
6561 ++s;
6562 }
6563 }
6564 else
6565 {
6566 if (errbuf != NULL)
6567 {
6568 sprintf((char *)errbuf,
6569 _("E535: Illegal character after <%c>"),
6570 *--s);
6571 errmsg = errbuf;
6572 }
6573 else
6574 errmsg = (char_u *)"";
6575 break;
6576 }
6577 }
6578 }
6579 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006580
6581 /* 'completeopt' */
6582 else if (varp == &p_cot)
6583 {
6584 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6585 errmsg = e_invarg;
6586 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006587#endif /* FEAT_INS_EXPAND */
6588
6589
6590#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6591 else if (varp == &p_toolbar)
6592 {
6593 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6594 &toolbar_flags, TRUE) != OK)
6595 errmsg = e_invarg;
6596 else
6597 {
6598 out_flush();
6599 gui_mch_show_toolbar((toolbar_flags &
6600 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6601 }
6602 }
6603#endif
6604
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006605#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006606 /* 'toolbariconsize': GTK+ 2 only */
6607 else if (varp == &p_tbis)
6608 {
6609 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6610 errmsg = e_invarg;
6611 else
6612 {
6613 out_flush();
6614 gui_mch_show_toolbar((toolbar_flags &
6615 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6616 }
6617 }
6618#endif
6619
6620 /* 'pastetoggle': translate key codes like in a mapping */
6621 else if (varp == &p_pt)
6622 {
6623 if (*p_pt)
6624 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006625 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006626 if (p != NULL)
6627 {
6628 if (new_value_alloced)
6629 free_string_option(p_pt);
6630 p_pt = p;
6631 new_value_alloced = TRUE;
6632 }
6633 }
6634 }
6635
6636 /* 'backspace' */
6637 else if (varp == &p_bs)
6638 {
6639 if (VIM_ISDIGIT(*p_bs))
6640 {
6641 if (*p_bs >'2' || p_bs[1] != NUL)
6642 errmsg = e_invarg;
6643 }
6644 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6645 errmsg = e_invarg;
6646 }
6647
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006648#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006649 /* 'casemap' */
6650 else if (varp == &p_cmp)
6651 {
6652 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6653 errmsg = e_invarg;
6654 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006655#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006656
6657#ifdef FEAT_DIFF
6658 /* 'diffopt' */
6659 else if (varp == &p_dip)
6660 {
6661 if (diffopt_changed() == FAIL)
6662 errmsg = e_invarg;
6663 }
6664#endif
6665
6666#ifdef FEAT_FOLDING
6667 /* 'foldmethod' */
6668 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
6669 {
6670 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
6671 || *curwin->w_p_fdm == NUL)
6672 errmsg = e_invarg;
6673 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006674 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006675 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006676 if (foldmethodIsDiff(curwin))
6677 newFoldLevel();
6678 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006679 }
6680# ifdef FEAT_EVAL
6681 /* 'foldexpr' */
6682 else if (varp == &curwin->w_p_fde)
6683 {
6684 if (foldmethodIsExpr(curwin))
6685 foldUpdateAll(curwin);
6686 }
6687# endif
6688 /* 'foldmarker' */
6689 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
6690 {
6691 p = vim_strchr(*varp, ',');
6692 if (p == NULL)
6693 errmsg = (char_u *)N_("E536: comma required");
6694 else if (p == *varp || p[1] == NUL)
6695 errmsg = e_invarg;
6696 else if (foldmethodIsMarker(curwin))
6697 foldUpdateAll(curwin);
6698 }
6699 /* 'commentstring' */
6700 else if (gvarp == &p_cms)
6701 {
6702 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
6703 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
6704 }
6705 /* 'foldopen' */
6706 else if (varp == &p_fdo)
6707 {
6708 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
6709 errmsg = e_invarg;
6710 }
6711 /* 'foldclose' */
6712 else if (varp == &p_fcl)
6713 {
6714 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
6715 errmsg = e_invarg;
6716 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00006717 /* 'foldignore' */
6718 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
6719 {
6720 if (foldmethodIsIndent(curwin))
6721 foldUpdateAll(curwin);
6722 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006723#endif
6724
6725#ifdef FEAT_VIRTUALEDIT
6726 /* 'virtualedit' */
6727 else if (varp == &p_ve)
6728 {
6729 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
6730 errmsg = e_invarg;
6731 else if (STRCMP(p_ve, oldval) != 0)
6732 {
6733 /* Recompute cursor position in case the new 've' setting
6734 * changes something. */
6735 validate_virtcol();
6736 coladvance(curwin->w_virtcol);
6737 }
6738 }
6739#endif
6740
6741#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
6742 else if (varp == &p_csqf)
6743 {
6744 if (p_csqf != NULL)
6745 {
6746 p = p_csqf;
6747 while (*p != NUL)
6748 {
6749 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
6750 || p[1] == NUL
6751 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
6752 || (p[2] != NUL && p[2] != ','))
6753 {
6754 errmsg = e_invarg;
6755 break;
6756 }
6757 else if (p[2] == NUL)
6758 break;
6759 else
6760 p += 3;
6761 }
6762 }
6763 }
6764#endif
6765
6766 /* Options that are a list of flags. */
6767 else
6768 {
6769 p = NULL;
6770 if (varp == &p_ww)
6771 p = (char_u *)WW_ALL;
6772 if (varp == &p_shm)
6773 p = (char_u *)SHM_ALL;
6774 else if (varp == &(p_cpo))
6775 p = (char_u *)CPO_ALL;
6776 else if (varp == &(curbuf->b_p_fo))
6777 p = (char_u *)FO_ALL;
6778 else if (varp == &p_mouse)
6779 {
6780#ifdef FEAT_MOUSE
6781 p = (char_u *)MOUSE_ALL;
6782#else
6783 if (*p_mouse != NUL)
6784 errmsg = (char_u *)N_("E538: No mouse support");
6785#endif
6786 }
6787#if defined(FEAT_GUI)
6788 else if (varp == &p_go)
6789 p = (char_u *)GO_ALL;
6790#endif
6791 if (p != NULL)
6792 {
6793 for (s = *varp; *s; ++s)
6794 if (vim_strchr(p, *s) == NULL)
6795 {
6796 errmsg = illegal_char(errbuf, *s);
6797 break;
6798 }
6799 }
6800 }
6801
6802 /*
6803 * If error detected, restore the previous value.
6804 */
6805 if (errmsg != NULL)
6806 {
6807 if (new_value_alloced)
6808 free_string_option(*varp);
6809 *varp = oldval;
6810 /*
6811 * When resetting some values, need to act on it.
6812 */
6813 if (did_chartab)
6814 (void)init_chartab();
6815 if (varp == &p_hl)
6816 (void)highlight_changed();
6817 }
6818 else
6819 {
6820#ifdef FEAT_EVAL
6821 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00006822 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006823#endif
6824 /*
6825 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00006826 * Use "free_oldval", because recursiveness may change the flags under
6827 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00006828 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00006829 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006830 free_string_option(oldval);
6831 if (new_value_alloced)
6832 options[opt_idx].flags |= P_ALLOCED;
6833 else
6834 options[opt_idx].flags &= ~P_ALLOCED;
6835
6836 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00006837 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00006838 {
6839 /* global option with local value set to use global value; free
6840 * the local value and make it empty */
6841 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
6842 free_string_option(*(char_u **)p);
6843 *(char_u **)p = empty_option;
6844 }
6845
6846 /* May set global value for local option. */
6847 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
6848 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00006849
6850#ifdef FEAT_AUTOCMD
6851 /*
6852 * Trigger the autocommand only after setting the flags.
6853 */
6854# ifdef FEAT_SYN_HL
6855 /* When 'syntax' is set, load the syntax of that name */
6856 if (varp == &(curbuf->b_p_syn))
6857 {
6858 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
6859 curbuf->b_fname, TRUE, curbuf);
6860 }
6861# endif
6862 else if (varp == &(curbuf->b_p_ft))
6863 {
6864 /* 'filetype' is set, trigger the FileType autocommand */
6865 did_filetype = TRUE;
6866 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
6867 curbuf->b_fname, TRUE, curbuf);
6868 }
6869#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006870#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02006871 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00006872 {
6873 char_u fname[200];
6874
6875 /*
6876 * Source the spell/LANG.vim in 'runtimepath'.
6877 * They could set 'spellcapcheck' depending on the language.
6878 * Use the first name in 'spelllang' up to '_region' or
6879 * '.encoding'.
6880 */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006881 for (p = curwin->w_s->b_p_spl; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00006882 if (vim_strchr((char_u *)"_.,", *p) != NULL)
6883 break;
6884 vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
Bram Moolenaar860cae12010-06-05 23:22:07 +02006885 (int)(p - curwin->w_s->b_p_spl), curwin->w_s->b_p_spl);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00006886 source_runtime(fname, TRUE);
6887 }
6888#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006889 }
6890
6891#ifdef FEAT_MOUSE
6892 if (varp == &p_mouse)
6893 {
6894# ifdef FEAT_MOUSE_TTY
6895 if (*p_mouse == NUL)
6896 mch_setmouse(FALSE); /* switch mouse off */
6897 else
6898# endif
6899 setmouse(); /* in case 'mouse' changed */
6900 }
6901#endif
6902
6903 if (curwin->w_curswant != MAXCOL)
6904 curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006905#ifdef FEAT_GUI
6906 /* check redraw when it's not a GUI option or the GUI is active. */
6907 if (!redraw_gui_only || gui.in_use)
6908#endif
6909 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006910
6911 return errmsg;
6912}
6913
6914/*
6915 * Handle setting 'listchars' or 'fillchars'.
6916 * Returns error message, NULL if it's OK.
6917 */
6918 static char_u *
6919set_chars_option(varp)
6920 char_u **varp;
6921{
6922 int round, i, len, entries;
6923 char_u *p, *s;
6924 int c1, c2 = 0;
6925 struct charstab
6926 {
6927 int *cp;
6928 char *name;
6929 };
6930#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6931 static struct charstab filltab[] =
6932 {
6933 {&fill_stl, "stl"},
6934 {&fill_stlnc, "stlnc"},
6935 {&fill_vert, "vert"},
6936 {&fill_fold, "fold"},
6937 {&fill_diff, "diff"},
6938 };
6939#endif
6940 static struct charstab lcstab[] =
6941 {
6942 {&lcs_eol, "eol"},
6943 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00006944 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00006945 {&lcs_prec, "precedes"},
6946 {&lcs_tab2, "tab"},
6947 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02006948#ifdef FEAT_CONCEAL
6949 {&lcs_conceal, "conceal"},
6950#else
6951 {NULL, "conceal"},
6952#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006953 };
6954 struct charstab *tab;
6955
6956#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6957 if (varp == &p_lcs)
6958#endif
6959 {
6960 tab = lcstab;
6961 entries = sizeof(lcstab) / sizeof(struct charstab);
6962 }
6963#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6964 else
6965 {
6966 tab = filltab;
6967 entries = sizeof(filltab) / sizeof(struct charstab);
6968 }
6969#endif
6970
6971 /* first round: check for valid value, second round: assign values */
6972 for (round = 0; round <= 1; ++round)
6973 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006974 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006975 {
6976 /* After checking that the value is valid: set defaults: space for
6977 * 'fillchars', NUL for 'listchars' */
6978 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02006979 if (tab[i].cp != NULL)
6980 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00006981 if (varp == &p_lcs)
6982 lcs_tab1 = NUL;
6983#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6984 else
6985 fill_diff = '-';
6986#endif
6987 }
6988 p = *varp;
6989 while (*p)
6990 {
6991 for (i = 0; i < entries; ++i)
6992 {
6993 len = (int)STRLEN(tab[i].name);
6994 if (STRNCMP(p, tab[i].name, len) == 0
6995 && p[len] == ':'
6996 && p[len + 1] != NUL)
6997 {
6998 s = p + len + 1;
6999#ifdef FEAT_MBYTE
7000 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007001 if (mb_char2cells(c1) > 1)
7002 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007003#else
7004 c1 = *s++;
7005#endif
7006 if (tab[i].cp == &lcs_tab2)
7007 {
7008 if (*s == NUL)
7009 continue;
7010#ifdef FEAT_MBYTE
7011 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007012 if (mb_char2cells(c2) > 1)
7013 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007014#else
7015 c2 = *s++;
7016#endif
7017 }
7018 if (*s == ',' || *s == NUL)
7019 {
7020 if (round)
7021 {
7022 if (tab[i].cp == &lcs_tab2)
7023 {
7024 lcs_tab1 = c1;
7025 lcs_tab2 = c2;
7026 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007027 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028 *(tab[i].cp) = c1;
7029
7030 }
7031 p = s;
7032 break;
7033 }
7034 }
7035 }
7036
7037 if (i == entries)
7038 return e_invarg;
7039 if (*p == ',')
7040 ++p;
7041 }
7042 }
7043
7044 return NULL; /* no error */
7045}
7046
7047#ifdef FEAT_STL_OPT
7048/*
7049 * Check validity of options with the 'statusline' format.
7050 * Return error message or NULL.
7051 */
7052 char_u *
7053check_stl_option(s)
7054 char_u *s;
7055{
7056 int itemcnt = 0;
7057 int groupdepth = 0;
7058 static char_u errbuf[80];
7059
7060 while (*s && itemcnt < STL_MAX_ITEM)
7061 {
7062 /* Check for valid keys after % sequences */
7063 while (*s && *s != '%')
7064 s++;
7065 if (!*s)
7066 break;
7067 s++;
7068 if (*s != '%' && *s != ')')
7069 ++itemcnt;
7070 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7071 {
7072 s++;
7073 continue;
7074 }
7075 if (*s == ')')
7076 {
7077 s++;
7078 if (--groupdepth < 0)
7079 break;
7080 continue;
7081 }
7082 if (*s == '-')
7083 s++;
7084 while (VIM_ISDIGIT(*s))
7085 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007086 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007087 continue;
7088 if (*s == '.')
7089 {
7090 s++;
7091 while (*s && VIM_ISDIGIT(*s))
7092 s++;
7093 }
7094 if (*s == '(')
7095 {
7096 groupdepth++;
7097 continue;
7098 }
7099 if (vim_strchr(STL_ALL, *s) == NULL)
7100 {
7101 return illegal_char(errbuf, *s);
7102 }
7103 if (*s == '{')
7104 {
7105 s++;
7106 while (*s != '}' && *s)
7107 s++;
7108 if (*s != '}')
7109 return (char_u *)N_("E540: Unclosed expression sequence");
7110 }
7111 }
7112 if (itemcnt >= STL_MAX_ITEM)
7113 return (char_u *)N_("E541: too many items");
7114 if (groupdepth != 0)
7115 return (char_u *)N_("E542: unbalanced groups");
7116 return NULL;
7117}
7118#endif
7119
7120#ifdef FEAT_CLIPBOARD
7121/*
7122 * Extract the items in the 'clipboard' option and set global values.
7123 */
7124 static char_u *
7125check_clipboard_option()
7126{
7127 int new_unnamed = FALSE;
7128 int new_autoselect = FALSE;
7129 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007130 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007131 regprog_T *new_exclude_prog = NULL;
7132 char_u *errmsg = NULL;
7133 char_u *p;
7134
7135 for (p = p_cb; *p != NUL; )
7136 {
7137 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7138 {
7139 new_unnamed = TRUE;
7140 p += 7;
7141 }
7142 else if (STRNCMP(p, "autoselect", 10) == 0
7143 && (p[10] == ',' || p[10] == NUL))
7144 {
7145 new_autoselect = TRUE;
7146 p += 10;
7147 }
7148 else if (STRNCMP(p, "autoselectml", 12) == 0
7149 && (p[12] == ',' || p[12] == NUL))
7150 {
7151 new_autoselectml = TRUE;
7152 p += 12;
7153 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007154 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7155 {
7156 new_html = TRUE;
7157 p += 4;
7158 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007159 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7160 {
7161 p += 8;
7162 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7163 if (new_exclude_prog == NULL)
7164 errmsg = e_invarg;
7165 break;
7166 }
7167 else
7168 {
7169 errmsg = e_invarg;
7170 break;
7171 }
7172 if (*p == ',')
7173 ++p;
7174 }
7175 if (errmsg == NULL)
7176 {
7177 clip_unnamed = new_unnamed;
7178 clip_autoselect = new_autoselect;
7179 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007180 clip_html = new_html;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007181 vim_free(clip_exclude_prog);
7182 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007183#ifdef FEAT_GUI_GTK
7184 if (gui.in_use)
7185 {
7186 gui_gtk_set_selection_targets();
7187 gui_gtk_set_dnd_targets();
7188 }
7189#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007190 }
7191 else
7192 vim_free(new_exclude_prog);
7193
7194 return errmsg;
7195}
7196#endif
7197
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007198#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007199/*
7200 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7201 * Return error message when failed, NULL when OK.
7202 */
7203 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007204compile_cap_prog(synblock)
7205 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007206{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007207 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007208 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007209
Bram Moolenaar860cae12010-06-05 23:22:07 +02007210 if (*synblock->b_p_spc == NUL)
7211 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007212 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007213 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007214 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007215 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007216 if (re != NULL)
7217 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007218 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
7219 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007220 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007221 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007222 return e_invarg;
7223 }
7224 vim_free(re);
7225 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007226 }
7227
7228 vim_free(rp);
7229 return NULL;
7230}
7231#endif
7232
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007233#if defined(FEAT_EVAL) || defined(PROTO)
7234/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007235 * Set the scriptID for an option, taking care of setting the buffer- or
7236 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007237 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007238 static void
7239set_option_scriptID_idx(opt_idx, opt_flags, id)
7240 int opt_idx;
7241 int opt_flags;
7242 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007243{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007244 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7245 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007246
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007247 /* Remember where the option was set. For local options need to do that
7248 * in the buffer or window structure. */
7249 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007250 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007251 if (both || (opt_flags & OPT_LOCAL))
7252 {
7253 if (indir & PV_BUF)
7254 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7255 else if (indir & PV_WIN)
7256 curwin->w_p_scriptID[indir & PV_MASK] = id;
7257 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007258}
7259#endif
7260
Bram Moolenaar071d4272004-06-13 20:20:40 +00007261/*
7262 * Set the value of a boolean option, and take care of side effects.
7263 * Returns NULL for success, or an error message for an error.
7264 */
7265 static char_u *
7266set_bool_option(opt_idx, varp, value, opt_flags)
7267 int opt_idx; /* index in options[] table */
7268 char_u *varp; /* pointer to the option variable */
7269 int value; /* new value */
7270 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7271{
7272 int old_value = *(int *)varp;
7273
Bram Moolenaar071d4272004-06-13 20:20:40 +00007274 /* Disallow changing some options from secure mode */
7275 if ((secure
7276#ifdef HAVE_SANDBOX
7277 || sandbox != 0
7278#endif
7279 ) && (options[opt_idx].flags & P_SECURE))
7280 return e_secure;
7281
7282 *(int *)varp = value; /* set the new value */
7283#ifdef FEAT_EVAL
7284 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007285 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007286#endif
7287
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007288#ifdef FEAT_GUI
7289 need_mouse_correct = TRUE;
7290#endif
7291
Bram Moolenaar071d4272004-06-13 20:20:40 +00007292 /* May set global value for local option. */
7293 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7294 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7295
7296 /*
7297 * Handle side effects of changing a bool option.
7298 */
7299
7300 /* 'compatible' */
7301 if ((int *)varp == &p_cp)
7302 {
7303 compatible_set();
7304 }
7305
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007306 /* 'list', 'number' */
7307 else if ((int *)varp == &curwin->w_p_list
Bram Moolenaar64486672010-05-16 15:46:46 +02007308 || (int *)varp == &curwin->w_p_nu
7309 || (int *)varp == &curwin->w_p_rnu)
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007310 {
7311 if (curwin->w_curswant != MAXCOL)
7312 curwin->w_set_curswant = TRUE;
Bram Moolenaar64486672010-05-16 15:46:46 +02007313
7314 /* If 'number' is set, reset 'relativenumber'. */
7315 /* If 'relativenumber' is set, reset 'number'. */
7316 if ((int *)varp == &curwin->w_p_nu && curwin->w_p_nu)
7317 curwin->w_p_rnu = FALSE;
7318 if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu)
7319 curwin->w_p_nu = FALSE;
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007320 }
7321
Bram Moolenaar071d4272004-06-13 20:20:40 +00007322 else if ((int *)varp == &curbuf->b_p_ro)
7323 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007324 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007325 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7326 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007327
7328 /* when 'readonly' is set may give W10 again */
7329 if (curbuf->b_p_ro)
7330 curbuf->b_did_warn = FALSE;
7331
Bram Moolenaar071d4272004-06-13 20:20:40 +00007332#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007333 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007334#endif
7335 }
7336
Bram Moolenaar370df582010-06-22 05:16:38 +02007337#if defined(FEAT_TITLE) || defined(FEAT_CONCEAL)
7338 /* when 'modifiable' is changed, redraw the window title and
7339 * update current line for concealable items */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007340 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007341 {
Bram Moolenaar370df582010-06-22 05:16:38 +02007342# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007343 redraw_titles();
Bram Moolenaar370df582010-06-22 05:16:38 +02007344# endif
7345# ifdef FEAT_CONCEAL
7346 if (curwin->w_p_conceal)
7347 update_single_line(curwin, curwin->w_cursor.lnum);
7348# endif
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007349 }
Bram Moolenaar370df582010-06-22 05:16:38 +02007350#endif
7351#ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007352 /* when 'endofline' is changed, redraw the window title */
7353 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007354 {
7355 redraw_titles();
7356 }
7357# ifdef FEAT_MBYTE
7358 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007359 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007360 {
7361 redraw_titles();
7362 }
7363# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007364#endif
7365
7366 /* when 'bin' is set also set some other options */
7367 else if ((int *)varp == &curbuf->b_p_bin)
7368 {
7369 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7370#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007371 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007372#endif
7373 }
7374
7375#ifdef FEAT_AUTOCMD
7376 /* when 'buflisted' changes, trigger autocommands */
7377 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7378 {
7379 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7380 NULL, NULL, TRUE, curbuf);
7381 }
7382#endif
7383
7384 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7385 else if ((int *)varp == &curbuf->b_p_swf)
7386 {
7387 if (curbuf->b_p_swf && p_uc)
7388 ml_open_file(curbuf); /* create the swap file */
7389 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007390 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7391 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007392 mf_close_file(curbuf, TRUE); /* remove the swap file */
7393 }
7394
7395 /* when 'terse' is set change 'shortmess' */
7396 else if ((int *)varp == &p_terse)
7397 {
7398 char_u *p;
7399
7400 p = vim_strchr(p_shm, SHM_SEARCH);
7401
7402 /* insert 's' in p_shm */
7403 if (p_terse && p == NULL)
7404 {
7405 STRCPY(IObuff, p_shm);
7406 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007407 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007408 }
7409 /* remove 's' from p_shm */
7410 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007411 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007412 }
7413
7414 /* when 'paste' is set or reset also change other options */
7415 else if ((int *)varp == &p_paste)
7416 {
7417 paste_option_changed();
7418 }
7419
7420 /* when 'insertmode' is set from an autocommand need to do work here */
7421 else if ((int *)varp == &p_im)
7422 {
7423 if (p_im)
7424 {
7425 if ((State & INSERT) == 0)
7426 need_start_insertmode = TRUE;
7427 stop_insert_mode = FALSE;
7428 }
7429 else
7430 {
7431 need_start_insertmode = FALSE;
7432 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007433 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007434 clear_cmdline = TRUE; /* remove "(insert)" */
7435 restart_edit = 0;
7436 }
7437 }
7438
7439 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7440 else if ((int *)varp == &p_ic && p_hls)
7441 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007442 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007443 }
7444
7445#ifdef FEAT_SEARCH_EXTRA
7446 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7447 else if ((int *)varp == &p_hls)
7448 {
7449 no_hlsearch = FALSE;
7450 }
7451#endif
7452
7453#ifdef FEAT_SCROLLBIND
7454 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7455 * at the end of normal_cmd() */
7456 else if ((int *)varp == &curwin->w_p_scb)
7457 {
7458 if (curwin->w_p_scb)
7459 do_check_scrollbind(FALSE);
7460 }
7461#endif
7462
7463#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7464 /* There can be only one window with 'previewwindow' set. */
7465 else if ((int *)varp == &curwin->w_p_pvw)
7466 {
7467 if (curwin->w_p_pvw)
7468 {
7469 win_T *win;
7470
7471 for (win = firstwin; win != NULL; win = win->w_next)
7472 if (win->w_p_pvw && win != curwin)
7473 {
7474 curwin->w_p_pvw = FALSE;
7475 return (char_u *)N_("E590: A preview window already exists");
7476 }
7477 }
7478 }
7479#endif
7480
7481 /* when 'textmode' is set or reset also change 'fileformat' */
7482 else if ((int *)varp == &curbuf->b_p_tx)
7483 {
7484 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7485 }
7486
7487 /* when 'textauto' is set or reset also change 'fileformats' */
7488 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007489 set_string_option_direct((char_u *)"ffs", -1,
7490 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007491 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007492
7493 /*
7494 * When 'lisp' option changes include/exclude '-' in
7495 * keyword characters.
7496 */
7497#ifdef FEAT_LISP
7498 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7499 {
7500 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7501 }
7502#endif
7503
7504#ifdef FEAT_TITLE
7505 /* when 'title' changed, may need to change the title; same for 'icon' */
7506 else if ((int *)varp == &p_title)
7507 {
7508 did_set_title(FALSE);
7509 }
7510
7511 else if ((int *)varp == &p_icon)
7512 {
7513 did_set_title(TRUE);
7514 }
7515#endif
7516
7517 else if ((int *)varp == &curbuf->b_changed)
7518 {
7519 if (!value)
7520 save_file_ff(curbuf); /* Buffer is unchanged */
7521#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007522 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007523#endif
7524#ifdef FEAT_AUTOCMD
7525 modified_was_set = value;
7526#endif
7527 }
7528
7529#ifdef BACKSLASH_IN_FILENAME
7530 else if ((int *)varp == &p_ssl)
7531 {
7532 if (p_ssl)
7533 {
7534 psepc = '/';
7535 psepcN = '\\';
7536 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007537 }
7538 else
7539 {
7540 psepc = '\\';
7541 psepcN = '/';
7542 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007543 }
7544
7545 /* need to adjust the file name arguments and buffer names. */
7546 buflist_slash_adjust();
7547 alist_slash_adjust();
7548# ifdef FEAT_EVAL
7549 scriptnames_slash_adjust();
7550# endif
7551 }
7552#endif
7553
7554 /* If 'wrap' is set, set w_leftcol to zero. */
7555 else if ((int *)varp == &curwin->w_p_wrap)
7556 {
7557 if (curwin->w_p_wrap)
7558 curwin->w_leftcol = 0;
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00007559 if (curwin->w_curswant != MAXCOL)
7560 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007561 }
7562
7563#ifdef FEAT_WINDOWS
7564 else if ((int *)varp == &p_ea)
7565 {
7566 if (p_ea && !old_value)
7567 win_equal(curwin, FALSE, 0);
7568 }
7569#endif
7570
7571 else if ((int *)varp == &p_wiv)
7572 {
7573 /*
7574 * When 'weirdinvert' changed, set/reset 't_xs'.
7575 * Then set 'weirdinvert' according to value of 't_xs'.
7576 */
7577 if (p_wiv && !old_value)
7578 T_XS = (char_u *)"y";
7579 else if (!p_wiv && old_value)
7580 T_XS = empty_option;
7581 p_wiv = (*T_XS != NUL);
7582 }
7583
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007584#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00007585 else if ((int *)varp == &p_beval)
7586 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007587 if (p_beval == TRUE)
7588 gui_mch_enable_beval_area(balloonEval);
7589 else
7590 gui_mch_disable_beval_area(balloonEval);
7591 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007592#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007593
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007594#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007595 else if ((int *)varp == &p_acd)
7596 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00007597 /* Change directories when the 'acd' option is set now. */
7598 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007599 }
7600#endif
7601
7602#ifdef FEAT_DIFF
7603 /* 'diff' */
7604 else if ((int *)varp == &curwin->w_p_diff)
7605 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007606 /* May add or remove the buffer from the list of diff buffers. */
7607 diff_buf_adjust(curwin);
7608# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00007609 if (foldmethodIsDiff(curwin))
7610 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007611# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007612 }
7613#endif
7614
7615#ifdef USE_IM_CONTROL
7616 /* 'imdisable' */
7617 else if ((int *)varp == &p_imdisable)
7618 {
7619 /* Only de-activate it here, it will be enabled when changing mode. */
7620 if (p_imdisable)
7621 im_set_active(FALSE);
7622 }
7623#endif
7624
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007625#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007626 /* 'spell' */
7627 else if ((int *)varp == &curwin->w_p_spell)
7628 {
7629 if (curwin->w_p_spell)
7630 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007631 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007632 if (errmsg != NULL)
7633 EMSG(_(errmsg));
7634 }
7635 }
7636#endif
7637
Bram Moolenaar071d4272004-06-13 20:20:40 +00007638#ifdef FEAT_FKMAP
7639 else if ((int *)varp == &p_altkeymap)
7640 {
7641 if (old_value != p_altkeymap)
7642 {
7643 if (!p_altkeymap)
7644 {
7645 p_hkmap = p_fkmap;
7646 p_fkmap = 0;
7647 }
7648 else
7649 {
7650 p_fkmap = p_hkmap;
7651 p_hkmap = 0;
7652 }
7653 (void)init_chartab();
7654 }
7655 }
7656
7657 /*
7658 * In case some second language keymapping options have changed, check
7659 * and correct the setting in a consistent way.
7660 */
7661
7662 /*
7663 * If hkmap or fkmap are set, reset Arabic keymapping.
7664 */
7665 if ((p_hkmap || p_fkmap) && p_altkeymap)
7666 {
7667 p_altkeymap = p_fkmap;
7668# ifdef FEAT_ARABIC
7669 curwin->w_p_arab = FALSE;
7670# endif
7671 (void)init_chartab();
7672 }
7673
7674 /*
7675 * If hkmap set, reset Farsi keymapping.
7676 */
7677 if (p_hkmap && p_altkeymap)
7678 {
7679 p_altkeymap = 0;
7680 p_fkmap = 0;
7681# ifdef FEAT_ARABIC
7682 curwin->w_p_arab = FALSE;
7683# endif
7684 (void)init_chartab();
7685 }
7686
7687 /*
7688 * If fkmap set, reset Hebrew keymapping.
7689 */
7690 if (p_fkmap && !p_altkeymap)
7691 {
7692 p_altkeymap = 1;
7693 p_hkmap = 0;
7694# ifdef FEAT_ARABIC
7695 curwin->w_p_arab = FALSE;
7696# endif
7697 (void)init_chartab();
7698 }
7699#endif
7700
7701#ifdef FEAT_ARABIC
7702 if ((int *)varp == &curwin->w_p_arab)
7703 {
7704 if (curwin->w_p_arab)
7705 {
7706 /*
7707 * 'arabic' is set, handle various sub-settings.
7708 */
7709 if (!p_tbidi)
7710 {
7711 /* set rightleft mode */
7712 if (!curwin->w_p_rl)
7713 {
7714 curwin->w_p_rl = TRUE;
7715 changed_window_setting();
7716 }
7717
7718 /* Enable Arabic shaping (major part of what Arabic requires) */
7719 if (!p_arshape)
7720 {
7721 p_arshape = TRUE;
7722 redraw_later_clear();
7723 }
7724 }
7725
7726 /* Arabic requires a utf-8 encoding, inform the user if its not
7727 * set. */
7728 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007729 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00007730 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
7731
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007732 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00007733 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
7734#ifdef FEAT_EVAL
7735 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
7736#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007737 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007738
7739# ifdef FEAT_MBYTE
7740 /* set 'delcombine' */
7741 p_deco = TRUE;
7742# endif
7743
7744# ifdef FEAT_KEYMAP
7745 /* Force-set the necessary keymap for arabic */
7746 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
7747 OPT_LOCAL);
7748# endif
7749# ifdef FEAT_FKMAP
7750 p_altkeymap = 0;
7751 p_hkmap = 0;
7752 p_fkmap = 0;
7753 (void)init_chartab();
7754# endif
7755 }
7756 else
7757 {
7758 /*
7759 * 'arabic' is reset, handle various sub-settings.
7760 */
7761 if (!p_tbidi)
7762 {
7763 /* reset rightleft mode */
7764 if (curwin->w_p_rl)
7765 {
7766 curwin->w_p_rl = FALSE;
7767 changed_window_setting();
7768 }
7769
7770 /* 'arabicshape' isn't reset, it is a global option and
7771 * another window may still need it "on". */
7772 }
7773
7774 /* 'delcombine' isn't reset, it is a global option and another
7775 * window may still want it "on". */
7776
7777# ifdef FEAT_KEYMAP
7778 /* Revert to the default keymap */
7779 curbuf->b_p_iminsert = B_IMODE_NONE;
7780 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
7781# endif
7782 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007783 if (curwin->w_curswant != MAXCOL)
7784 curwin->w_set_curswant = TRUE;
7785 }
7786
7787 else if ((int *)varp == &p_arshape)
7788 {
7789 if (curwin->w_curswant != MAXCOL)
7790 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007791 }
7792#endif
7793
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00007794#ifdef FEAT_LINEBREAK
7795 if ((int *)varp == &curwin->w_p_lbr)
7796 {
7797 if (curwin->w_curswant != MAXCOL)
7798 curwin->w_set_curswant = TRUE;
7799 }
7800#endif
7801
7802#ifdef FEAT_RIGHTLEFT
7803 if ((int *)varp == &curwin->w_p_rl)
7804 {
7805 if (curwin->w_curswant != MAXCOL)
7806 curwin->w_set_curswant = TRUE;
7807 }
7808#endif
7809
Bram Moolenaar071d4272004-06-13 20:20:40 +00007810 /*
7811 * End of handling side effects for bool options.
7812 */
7813
7814 options[opt_idx].flags |= P_WAS_SET;
7815
7816 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007817
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818 check_redraw(options[opt_idx].flags);
7819
7820 return NULL;
7821}
7822
7823/*
7824 * Set the value of a number option, and take care of side effects.
7825 * Returns NULL for success, or an error message for an error.
7826 */
7827 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00007828set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007829 int opt_idx; /* index in options[] table */
7830 char_u *varp; /* pointer to the option variable */
7831 long value; /* new value */
7832 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00007833 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007834 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
7835 OPT_MODELINE */
7836{
7837 char_u *errmsg = NULL;
7838 long old_value = *(long *)varp;
7839 long old_Rows = Rows; /* remember old Rows */
7840 long old_Columns = Columns; /* remember old Columns */
7841 long *pp = (long *)varp;
7842
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007843 /* Disallow changing some options from secure mode. */
7844 if ((secure
7845#ifdef HAVE_SANDBOX
7846 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00007847#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007848 ) && (options[opt_idx].flags & P_SECURE))
7849 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007850
7851 *pp = value;
7852#ifdef FEAT_EVAL
7853 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007854 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007855#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007856#ifdef FEAT_GUI
7857 need_mouse_correct = TRUE;
7858#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007859
7860 if (curbuf->b_p_sw <= 0)
7861 {
7862 errmsg = e_positive;
7863 curbuf->b_p_sw = curbuf->b_p_ts;
7864 }
7865
7866 /*
7867 * Number options that need some action when changed
7868 */
7869#ifdef FEAT_WINDOWS
7870 if (pp == &p_wh || pp == &p_hh)
7871 {
7872 if (p_wh < 1)
7873 {
7874 errmsg = e_positive;
7875 p_wh = 1;
7876 }
7877 if (p_wmh > p_wh)
7878 {
7879 errmsg = e_winheight;
7880 p_wh = p_wmh;
7881 }
7882 if (p_hh < 0)
7883 {
7884 errmsg = e_positive;
7885 p_hh = 0;
7886 }
7887
7888 /* Change window height NOW */
7889 if (lastwin != firstwin)
7890 {
7891 if (pp == &p_wh && curwin->w_height < p_wh)
7892 win_setheight((int)p_wh);
7893 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
7894 win_setheight((int)p_hh);
7895 }
7896 }
7897
7898 /* 'winminheight' */
7899 else if (pp == &p_wmh)
7900 {
7901 if (p_wmh < 0)
7902 {
7903 errmsg = e_positive;
7904 p_wmh = 0;
7905 }
7906 if (p_wmh > p_wh)
7907 {
7908 errmsg = e_winheight;
7909 p_wmh = p_wh;
7910 }
7911 win_setminheight();
7912 }
7913
7914# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00007915 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007916 {
7917 if (p_wiw < 1)
7918 {
7919 errmsg = e_positive;
7920 p_wiw = 1;
7921 }
7922 if (p_wmw > p_wiw)
7923 {
7924 errmsg = e_winwidth;
7925 p_wiw = p_wmw;
7926 }
7927
7928 /* Change window width NOW */
7929 if (lastwin != firstwin && curwin->w_width < p_wiw)
7930 win_setwidth((int)p_wiw);
7931 }
7932
7933 /* 'winminwidth' */
7934 else if (pp == &p_wmw)
7935 {
7936 if (p_wmw < 0)
7937 {
7938 errmsg = e_positive;
7939 p_wmw = 0;
7940 }
7941 if (p_wmw > p_wiw)
7942 {
7943 errmsg = e_winwidth;
7944 p_wmw = p_wiw;
7945 }
7946 win_setminheight();
7947 }
7948# endif
7949
7950#endif
7951
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02007952#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +02007953 else if (pp == &curbuf->b_p_cm)
7954 {
7955 if (curbuf->b_p_cm < 0)
7956 {
7957 errmsg = e_positive;
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02007958 curbuf->b_p_cm = old_value;
Bram Moolenaar40e6a712010-05-16 22:32:54 +02007959 }
7960 if (curbuf->b_p_cm > 1)
7961 {
7962 errmsg = e_invarg;
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02007963 curbuf->b_p_cm = old_value;
Bram Moolenaar40e6a712010-05-16 22:32:54 +02007964 }
7965 if (curbuf->b_p_cm > 0 && blowfish_self_test() == FAIL)
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02007966 curbuf->b_p_cm = old_value;
7967
7968 if (curbuf->b_p_cm != old_value && *curbuf->b_p_key != NUL)
7969 /* Need to update the swapfile. */
7970 ml_set_crypt_key(curbuf, curbuf->b_p_key, old_value);
Bram Moolenaar40e6a712010-05-16 22:32:54 +02007971 }
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02007972#endif
Bram Moolenaar40e6a712010-05-16 22:32:54 +02007973
Bram Moolenaar071d4272004-06-13 20:20:40 +00007974#ifdef FEAT_WINDOWS
7975 /* (re)set last window status line */
7976 else if (pp == &p_ls)
7977 {
7978 last_status(FALSE);
7979 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00007980
7981 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00007982 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00007983 {
7984 shell_new_rows(); /* recompute window positions and heights */
7985 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007986#endif
7987
7988#ifdef FEAT_GUI
7989 else if (pp == &p_linespace)
7990 {
Bram Moolenaar02743632005-07-25 20:42:36 +00007991 /* Recompute gui.char_height and resize the Vim window to keep the
7992 * same number of lines. */
7993 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00007994 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007995 }
7996#endif
7997
7998#ifdef FEAT_FOLDING
7999 /* 'foldlevel' */
8000 else if (pp == &curwin->w_p_fdl)
8001 {
8002 if (curwin->w_p_fdl < 0)
8003 curwin->w_p_fdl = 0;
8004 newFoldLevel();
8005 }
8006
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008007 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008008 else if (pp == &curwin->w_p_fml)
8009 {
8010 foldUpdateAll(curwin);
8011 }
8012
8013 /* 'foldnestmax' */
8014 else if (pp == &curwin->w_p_fdn)
8015 {
8016 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8017 foldUpdateAll(curwin);
8018 }
8019
8020 /* 'foldcolumn' */
8021 else if (pp == &curwin->w_p_fdc)
8022 {
8023 if (curwin->w_p_fdc < 0)
8024 {
8025 errmsg = e_positive;
8026 curwin->w_p_fdc = 0;
8027 }
8028 else if (curwin->w_p_fdc > 12)
8029 {
8030 errmsg = e_invarg;
8031 curwin->w_p_fdc = 12;
8032 }
8033 }
8034
8035 /* 'shiftwidth' or 'tabstop' */
8036 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8037 {
8038 if (foldmethodIsIndent(curwin))
8039 foldUpdateAll(curwin);
8040 }
8041#endif /* FEAT_FOLDING */
8042
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008043#ifdef FEAT_MBYTE
8044 /* 'maxcombine' */
8045 else if (pp == &p_mco)
8046 {
8047 if (p_mco > MAX_MCO)
8048 p_mco = MAX_MCO;
8049 else if (p_mco < 0)
8050 p_mco = 0;
8051 screenclear(); /* will re-allocate the screen */
8052 }
8053#endif
8054
Bram Moolenaar071d4272004-06-13 20:20:40 +00008055 else if (pp == &curbuf->b_p_iminsert)
8056 {
8057 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8058 {
8059 errmsg = e_invarg;
8060 curbuf->b_p_iminsert = B_IMODE_NONE;
8061 }
8062 p_iminsert = curbuf->b_p_iminsert;
8063 if (termcap_active) /* don't do this in the alternate screen */
8064 showmode();
8065#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8066 /* Show/unshow value of 'keymap' in status lines. */
8067 status_redraw_curbuf();
8068#endif
8069 }
8070
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008071 else if (pp == &p_window)
8072 {
8073 if (p_window < 1)
8074 p_window = 1;
8075 else if (p_window >= Rows)
8076 p_window = Rows - 1;
8077 }
8078
Bram Moolenaar071d4272004-06-13 20:20:40 +00008079 else if (pp == &curbuf->b_p_imsearch)
8080 {
8081 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8082 {
8083 errmsg = e_invarg;
8084 curbuf->b_p_imsearch = B_IMODE_NONE;
8085 }
8086 p_imsearch = curbuf->b_p_imsearch;
8087 }
8088
8089#ifdef FEAT_TITLE
8090 /* if 'titlelen' has changed, redraw the title */
8091 else if (pp == &p_titlelen)
8092 {
8093 if (p_titlelen < 0)
8094 {
8095 errmsg = e_positive;
8096 p_titlelen = 85;
8097 }
8098 if (starting != NO_SCREEN && old_value != p_titlelen)
8099 need_maketitle = TRUE;
8100 }
8101#endif
8102
8103 /* if p_ch changed value, change the command line height */
8104 else if (pp == &p_ch)
8105 {
8106 if (p_ch < 1)
8107 {
8108 errmsg = e_positive;
8109 p_ch = 1;
8110 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008111 if (p_ch > Rows - min_rows() + 1)
8112 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008113
8114 /* Only compute the new window layout when startup has been
8115 * completed. Otherwise the frame sizes may be wrong. */
8116 if (p_ch != old_value && full_screen
8117#ifdef FEAT_GUI
8118 && !gui.starting
8119#endif
8120 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008121 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008122 }
8123
8124 /* when 'updatecount' changes from zero to non-zero, open swap files */
8125 else if (pp == &p_uc)
8126 {
8127 if (p_uc < 0)
8128 {
8129 errmsg = e_positive;
8130 p_uc = 100;
8131 }
8132 if (p_uc && !old_value)
8133 ml_open_files();
8134 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008135#ifdef FEAT_CONCEAL
Bram Moolenaarf506c5b2010-06-22 06:28:58 +02008136 else if (pp == &curwin->w_p_conceal)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008137 {
8138 if (curwin->w_p_conceal < 0)
8139 {
8140 errmsg = e_positive;
8141 curwin->w_p_conceal = 0;
8142 }
8143 else if (curwin->w_p_conceal > 3)
8144 {
8145 errmsg = e_invarg;
8146 curwin->w_p_conceal = 3;
8147 }
8148 }
8149#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008150#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008151 else if (pp == &p_mzq)
8152 mzvim_reset_timer();
8153#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008154
8155 /* sync undo before 'undolevels' changes */
8156 else if (pp == &p_ul)
8157 {
8158 /* use the old value, otherwise u_sync() may not work properly */
8159 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008160 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008161 p_ul = value;
8162 }
8163
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008164#ifdef FEAT_LINEBREAK
8165 /* 'numberwidth' must be positive */
8166 else if (pp == &curwin->w_p_nuw)
8167 {
8168 if (curwin->w_p_nuw < 1)
8169 {
8170 errmsg = e_positive;
8171 curwin->w_p_nuw = 1;
8172 }
8173 if (curwin->w_p_nuw > 10)
8174 {
8175 errmsg = e_invarg;
8176 curwin->w_p_nuw = 10;
8177 }
8178 curwin->w_nrwidth_line_count = 0;
8179 }
8180#endif
8181
Bram Moolenaar071d4272004-06-13 20:20:40 +00008182 /*
8183 * Check the bounds for numeric options here
8184 */
8185 if (Rows < min_rows() && full_screen)
8186 {
8187 if (errbuf != NULL)
8188 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008189 vim_snprintf((char *)errbuf, errbuflen,
8190 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008191 errmsg = errbuf;
8192 }
8193 Rows = min_rows();
8194 }
8195 if (Columns < MIN_COLUMNS && full_screen)
8196 {
8197 if (errbuf != NULL)
8198 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008199 vim_snprintf((char *)errbuf, errbuflen,
8200 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008201 errmsg = errbuf;
8202 }
8203 Columns = MIN_COLUMNS;
8204 }
Bram Moolenaar482aaeb2005-09-29 18:26:07 +00008205 /* Limit the values to avoid an overflow in Rows * Columns. */
8206 if (Columns > 10000)
8207 Columns = 10000;
8208 if (Rows > 1000)
8209 Rows = 1000;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008210
8211#ifdef DJGPP
8212 /* avoid a crash by checking for a too large value of 'columns' */
8213 if (old_Columns != Columns && full_screen && term_console)
8214 mch_check_columns();
8215#endif
8216
8217 /*
8218 * If the screen (shell) height has been changed, assume it is the
8219 * physical screenheight.
8220 */
8221 if (old_Rows != Rows || old_Columns != Columns)
8222 {
8223 /* Changing the screen size is not allowed while updating the screen. */
8224 if (updating_screen)
8225 *pp = old_value;
8226 else if (full_screen
8227#ifdef FEAT_GUI
8228 && !gui.starting
8229#endif
8230 )
8231 set_shellsize((int)Columns, (int)Rows, TRUE);
8232 else
8233 {
8234 /* Postpone the resizing; check the size and cmdline position for
8235 * messages. */
8236 check_shellsize();
8237 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8238 cmdline_row = Rows - p_ch;
8239 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008240 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008241 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008242 }
8243
8244 if (curbuf->b_p_sts < 0)
8245 {
8246 errmsg = e_positive;
8247 curbuf->b_p_sts = 0;
8248 }
8249 if (curbuf->b_p_ts <= 0)
8250 {
8251 errmsg = e_positive;
8252 curbuf->b_p_ts = 8;
8253 }
8254 if (curbuf->b_p_tw < 0)
8255 {
8256 errmsg = e_positive;
8257 curbuf->b_p_tw = 0;
8258 }
8259 if (p_tm < 0)
8260 {
8261 errmsg = e_positive;
8262 p_tm = 0;
8263 }
8264 if ((curwin->w_p_scr <= 0
8265 || (curwin->w_p_scr > curwin->w_height
8266 && curwin->w_height > 0))
8267 && full_screen)
8268 {
8269 if (pp == &(curwin->w_p_scr))
8270 {
8271 if (curwin->w_p_scr != 0)
8272 errmsg = e_scroll;
8273 win_comp_scroll(curwin);
8274 }
8275 /* If 'scroll' became invalid because of a side effect silently adjust
8276 * it. */
8277 else if (curwin->w_p_scr <= 0)
8278 curwin->w_p_scr = 1;
8279 else /* curwin->w_p_scr > curwin->w_height */
8280 curwin->w_p_scr = curwin->w_height;
8281 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008282 if (p_hi < 0)
8283 {
8284 errmsg = e_positive;
8285 p_hi = 0;
8286 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008287 if (p_report < 0)
8288 {
8289 errmsg = e_positive;
8290 p_report = 1;
8291 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008292 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008293 {
8294 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8295 p_sj = Rows / 2;
8296 else
8297 {
8298 errmsg = e_scroll;
8299 p_sj = 1;
8300 }
8301 }
8302 if (p_so < 0 && full_screen)
8303 {
8304 errmsg = e_scroll;
8305 p_so = 0;
8306 }
8307 if (p_siso < 0 && full_screen)
8308 {
8309 errmsg = e_positive;
8310 p_siso = 0;
8311 }
8312#ifdef FEAT_CMDWIN
8313 if (p_cwh < 1)
8314 {
8315 errmsg = e_positive;
8316 p_cwh = 1;
8317 }
8318#endif
8319 if (p_ut < 0)
8320 {
8321 errmsg = e_positive;
8322 p_ut = 2000;
8323 }
8324 if (p_ss < 0)
8325 {
8326 errmsg = e_positive;
8327 p_ss = 0;
8328 }
8329
8330 /* May set global value for local option. */
8331 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8332 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8333
8334 options[opt_idx].flags |= P_WAS_SET;
8335
8336 comp_col(); /* in case 'columns' or 'ls' changed */
8337 if (curwin->w_curswant != MAXCOL)
8338 curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */
8339 check_redraw(options[opt_idx].flags);
8340
8341 return errmsg;
8342}
8343
8344/*
8345 * Called after an option changed: check if something needs to be redrawn.
8346 */
8347 static void
8348check_redraw(flags)
8349 long_u flags;
8350{
8351 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
8352 int clear = (flags & P_RCLR) == P_RCLR;
8353 int all = ((flags & P_RALL) == P_RALL || clear);
8354
8355#ifdef FEAT_WINDOWS
8356 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8357 status_redraw_all();
8358#endif
8359
8360 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8361 changed_window_setting();
8362 if (flags & P_RBUF)
8363 redraw_curbuf_later(NOT_VALID);
8364 if (clear)
8365 redraw_all_later(CLEAR);
8366 else if (all)
8367 redraw_all_later(NOT_VALID);
8368}
8369
8370/*
8371 * Find index for option 'arg'.
8372 * Return -1 if not found.
8373 */
8374 static int
8375findoption(arg)
8376 char_u *arg;
8377{
8378 int opt_idx;
8379 char *s, *p;
8380 static short quick_tab[27] = {0, 0}; /* quick access table */
8381 int is_term_opt;
8382
8383 /*
8384 * For first call: Initialize the quick-access table.
8385 * It contains the index for the first option that starts with a certain
8386 * letter. There are 26 letters, plus the first "t_" option.
8387 */
8388 if (quick_tab[1] == 0)
8389 {
8390 p = options[0].fullname;
8391 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8392 {
8393 if (s[0] != p[0])
8394 {
8395 if (s[0] == 't' && s[1] == '_')
8396 quick_tab[26] = opt_idx;
8397 else
8398 quick_tab[CharOrdLow(s[0])] = opt_idx;
8399 }
8400 p = s;
8401 }
8402 }
8403
8404 /*
8405 * Check for name starting with an illegal character.
8406 */
8407#ifdef EBCDIC
8408 if (!islower(arg[0]))
8409#else
8410 if (arg[0] < 'a' || arg[0] > 'z')
8411#endif
8412 return -1;
8413
8414 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8415 if (is_term_opt)
8416 opt_idx = quick_tab[26];
8417 else
8418 opt_idx = quick_tab[CharOrdLow(arg[0])];
8419 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8420 {
8421 if (STRCMP(arg, s) == 0) /* match full name */
8422 break;
8423 }
8424 if (s == NULL && !is_term_opt)
8425 {
8426 opt_idx = quick_tab[CharOrdLow(arg[0])];
8427 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8428 {
8429 s = options[opt_idx].shortname;
8430 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8431 break;
8432 s = NULL;
8433 }
8434 }
8435 if (s == NULL)
8436 opt_idx = -1;
8437 return opt_idx;
8438}
8439
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008440#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008441/*
8442 * Get the value for an option.
8443 *
8444 * Returns:
8445 * Number or Toggle option: 1, *numval gets value.
8446 * String option: 0, *stringval gets allocated string.
8447 * Hidden Number or Toggle option: -1.
8448 * hidden String option: -2.
8449 * unknown option: -3.
8450 */
8451 int
8452get_option_value(name, numval, stringval, opt_flags)
8453 char_u *name;
8454 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008455 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008456 int opt_flags;
8457{
8458 int opt_idx;
8459 char_u *varp;
8460
8461 opt_idx = findoption(name);
8462 if (opt_idx < 0) /* unknown option */
8463 return -3;
8464
8465 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8466
8467 if (options[opt_idx].flags & P_STRING)
8468 {
8469 if (varp == NULL) /* hidden option */
8470 return -2;
8471 if (stringval != NULL)
8472 {
8473#ifdef FEAT_CRYPT
8474 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008475 if ((char_u **)varp == &curbuf->b_p_key
8476 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008477 *stringval = vim_strsave((char_u *)"*****");
8478 else
8479#endif
8480 *stringval = vim_strsave(*(char_u **)(varp));
8481 }
8482 return 0;
8483 }
8484
8485 if (varp == NULL) /* hidden option */
8486 return -1;
8487 if (options[opt_idx].flags & P_NUM)
8488 *numval = *(long *)varp;
8489 else
8490 {
8491 /* Special case: 'modified' is b_changed, but we also want to consider
8492 * it set when 'ff' or 'fenc' changed. */
8493 if ((int *)varp == &curbuf->b_changed)
8494 *numval = curbufIsChanged();
8495 else
8496 *numval = *(int *)varp;
8497 }
8498 return 1;
8499}
8500#endif
8501
8502/*
8503 * Set the value of option "name".
8504 * Use "string" for string options, use "number" for other options.
8505 */
8506 void
8507set_option_value(name, number, string, opt_flags)
8508 char_u *name;
8509 long number;
8510 char_u *string;
8511 int opt_flags; /* OPT_LOCAL or 0 (both) */
8512{
8513 int opt_idx;
8514 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00008515 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008516
8517 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00008518 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008519 EMSG2(_("E355: Unknown option: %s"), name);
8520 else
8521 {
8522 flags = options[opt_idx].flags;
8523#ifdef HAVE_SANDBOX
8524 /* Disallow changing some options in the sandbox */
8525 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008526 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008527 EMSG(_(e_sandbox));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008528 return;
8529 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008530#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008531 if (flags & P_STRING)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008532 set_string_option(opt_idx, string, opt_flags);
8533 else
8534 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00008535 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008536 if (varp != NULL) /* hidden option is not changed */
8537 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008538 if (number == 0 && string != NULL)
8539 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00008540 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008541
8542 /* Either we are given a string or we are setting option
8543 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00008544 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008545 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00008546 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008547 {
8548 /* There's another character after zeros or the string
8549 * is empty. In both cases, we are trying to set a
8550 * num option using a string. */
8551 EMSG3(_("E521: Number required: &%s = '%s'"),
8552 name, string);
8553 return; /* do nothing as we hit an error */
8554
8555 }
8556 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008557 if (flags & P_NUM)
Bram Moolenaar555b2802005-05-19 21:08:39 +00008558 (void)set_num_option(opt_idx, varp, number,
8559 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008560 else
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008561 (void)set_bool_option(opt_idx, varp, (int)number,
8562 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008563 }
8564 }
8565 }
8566}
8567
8568/*
8569 * Get the terminal code for a terminal option.
8570 * Returns NULL when not found.
8571 */
8572 char_u *
8573get_term_code(tname)
8574 char_u *tname;
8575{
8576 int opt_idx;
8577 char_u *varp;
8578
8579 if (tname[0] != 't' || tname[1] != '_' ||
8580 tname[2] == NUL || tname[3] == NUL)
8581 return NULL;
8582 if ((opt_idx = findoption(tname)) >= 0)
8583 {
8584 varp = get_varp(&(options[opt_idx]));
8585 if (varp != NULL)
8586 varp = *(char_u **)(varp);
8587 return varp;
8588 }
8589 return find_termcode(tname + 2);
8590}
8591
8592 char_u *
8593get_highlight_default()
8594{
8595 int i;
8596
8597 i = findoption((char_u *)"hl");
8598 if (i >= 0)
8599 return options[i].def_val[VI_DEFAULT];
8600 return (char_u *)NULL;
8601}
8602
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00008603#if defined(FEAT_MBYTE) || defined(PROTO)
8604 char_u *
8605get_encoding_default()
8606{
8607 int i;
8608
8609 i = findoption((char_u *)"enc");
8610 if (i >= 0)
8611 return options[i].def_val[VI_DEFAULT];
8612 return (char_u *)NULL;
8613}
8614#endif
8615
Bram Moolenaar071d4272004-06-13 20:20:40 +00008616/*
8617 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
8618 */
8619 static int
8620find_key_option(arg)
8621 char_u *arg;
8622{
8623 int key;
8624 int modifiers;
8625
8626 /*
8627 * Don't use get_special_key_code() for t_xx, we don't want it to call
8628 * add_termcap_entry().
8629 */
8630 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
8631 key = TERMCAP2KEY(arg[2], arg[3]);
8632 else
8633 {
8634 --arg; /* put arg at the '<' */
8635 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00008636 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008637 if (modifiers) /* can't handle modifiers here */
8638 key = 0;
8639 }
8640 return key;
8641}
8642
8643/*
8644 * if 'all' == 0: show changed options
8645 * if 'all' == 1: show all normal options
8646 * if 'all' == 2: show all terminal options
8647 */
8648 static void
8649showoptions(all, opt_flags)
8650 int all;
8651 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
8652{
8653 struct vimoption *p;
8654 int col;
8655 int isterm;
8656 char_u *varp;
8657 struct vimoption **items;
8658 int item_count;
8659 int run;
8660 int row, rows;
8661 int cols;
8662 int i;
8663 int len;
8664
8665#define INC 20
8666#define GAP 3
8667
8668 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
8669 PARAM_COUNT));
8670 if (items == NULL)
8671 return;
8672
8673 /* Highlight title */
8674 if (all == 2)
8675 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
8676 else if (opt_flags & OPT_GLOBAL)
8677 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
8678 else if (opt_flags & OPT_LOCAL)
8679 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
8680 else
8681 MSG_PUTS_TITLE(_("\n--- Options ---"));
8682
8683 /*
8684 * do the loop two times:
8685 * 1. display the short items
8686 * 2. display the long items (only strings and numbers)
8687 */
8688 for (run = 1; run <= 2 && !got_int; ++run)
8689 {
8690 /*
8691 * collect the items in items[]
8692 */
8693 item_count = 0;
8694 for (p = &options[0]; p->fullname != NULL; p++)
8695 {
8696 varp = NULL;
8697 isterm = istermoption(p);
8698 if (opt_flags != 0)
8699 {
8700 if (p->indir != PV_NONE && !isterm)
8701 varp = get_varp_scope(p, opt_flags);
8702 }
8703 else
8704 varp = get_varp(p);
8705 if (varp != NULL
8706 && ((all == 2 && isterm)
8707 || (all == 1 && !isterm)
8708 || (all == 0 && !optval_default(p, varp))))
8709 {
8710 if (p->flags & P_BOOL)
8711 len = 1; /* a toggle option fits always */
8712 else
8713 {
8714 option_value2string(p, opt_flags);
8715 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
8716 }
8717 if ((len <= INC - GAP && run == 1) ||
8718 (len > INC - GAP && run == 2))
8719 items[item_count++] = p;
8720 }
8721 }
8722
8723 /*
8724 * display the items
8725 */
8726 if (run == 1)
8727 {
8728 cols = (Columns + GAP - 3) / INC;
8729 if (cols == 0)
8730 cols = 1;
8731 rows = (item_count + cols - 1) / cols;
8732 }
8733 else /* run == 2 */
8734 rows = item_count;
8735 for (row = 0; row < rows && !got_int; ++row)
8736 {
8737 msg_putchar('\n'); /* go to next line */
8738 if (got_int) /* 'q' typed in more */
8739 break;
8740 col = 0;
8741 for (i = row; i < item_count; i += rows)
8742 {
8743 msg_col = col; /* make columns */
8744 showoneopt(items[i], opt_flags);
8745 col += INC;
8746 }
8747 out_flush();
8748 ui_breakcheck();
8749 }
8750 }
8751 vim_free(items);
8752}
8753
8754/*
8755 * Return TRUE if option "p" has its default value.
8756 */
8757 static int
8758optval_default(p, varp)
8759 struct vimoption *p;
8760 char_u *varp;
8761{
8762 int dvi;
8763
8764 if (varp == NULL)
8765 return TRUE; /* hidden option is always at default */
8766 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
8767 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00008768 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008769 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00008770 /* the cast to long is required for Manx C, long_i is
8771 * needed for MSVC */
8772 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008773 /* P_STRING */
8774 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
8775}
8776
8777/*
8778 * showoneopt: show the value of one option
8779 * must not be called with a hidden option!
8780 */
8781 static void
8782showoneopt(p, opt_flags)
8783 struct vimoption *p;
8784 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
8785{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00008786 char_u *varp;
8787 int save_silent = silent_mode;
8788
8789 silent_mode = FALSE;
8790 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008791
8792 varp = get_varp_scope(p, opt_flags);
8793
8794 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
8795 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
8796 ? !curbufIsChanged() : !*(int *)varp))
8797 MSG_PUTS("no");
8798 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
8799 MSG_PUTS("--");
8800 else
8801 MSG_PUTS(" ");
8802 MSG_PUTS(p->fullname);
8803 if (!(p->flags & P_BOOL))
8804 {
8805 msg_putchar('=');
8806 /* put value string in NameBuff */
8807 option_value2string(p, opt_flags);
8808 msg_outtrans(NameBuff);
8809 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00008810
8811 silent_mode = save_silent;
8812 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008813}
8814
8815/*
8816 * Write modified options as ":set" commands to a file.
8817 *
8818 * There are three values for "opt_flags":
8819 * OPT_GLOBAL: Write global option values and fresh values of
8820 * buffer-local options (used for start of a session
8821 * file).
8822 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
8823 * curwin (used for a vimrc file).
8824 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
8825 * and local values for window-local options of
8826 * curwin. Local values are also written when at the
8827 * default value, because a modeline or autocommand
8828 * may have set them when doing ":edit file" and the
8829 * user has set them back at the default or fresh
8830 * value.
8831 * When "local_only" is TRUE, don't write fresh
8832 * values, only local values (for ":mkview").
8833 * (fresh value = value used for a new buffer or window for a local option).
8834 *
8835 * Return FAIL on error, OK otherwise.
8836 */
8837 int
8838makeset(fd, opt_flags, local_only)
8839 FILE *fd;
8840 int opt_flags;
8841 int local_only;
8842{
8843 struct vimoption *p;
8844 char_u *varp; /* currently used value */
8845 char_u *varp_fresh; /* local value */
8846 char_u *varp_local = NULL; /* fresh value */
8847 char *cmd;
8848 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00008849 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008850
8851 /*
8852 * The options that don't have a default (terminal name, columns, lines)
8853 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00008854 * Do the loop over "options[]" twice: once for options with the
8855 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00008856 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00008857 for (pri = 1; pri >= 0; --pri)
8858 {
8859 for (p = &options[0]; !istermoption(p); p++)
8860 if (!(p->flags & P_NO_MKRC)
8861 && !istermoption(p)
8862 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00008863 {
8864 /* skip global option when only doing locals */
8865 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
8866 continue;
8867
8868 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
8869 * file, they are always buffer-specific. */
8870 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
8871 continue;
8872
8873 /* Global values are only written when not at the default value. */
8874 varp = get_varp_scope(p, opt_flags);
8875 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
8876 continue;
8877
8878 round = 2;
8879 if (p->indir != PV_NONE)
8880 {
8881 if (p->var == VAR_WIN)
8882 {
8883 /* skip window-local option when only doing globals */
8884 if (!(opt_flags & OPT_LOCAL))
8885 continue;
8886 /* When fresh value of window-local option is not at the
8887 * default, need to write it too. */
8888 if (!(opt_flags & OPT_GLOBAL) && !local_only)
8889 {
8890 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
8891 if (!optval_default(p, varp_fresh))
8892 {
8893 round = 1;
8894 varp_local = varp;
8895 varp = varp_fresh;
8896 }
8897 }
8898 }
8899 }
8900
8901 /* Round 1: fresh value for window-local options.
8902 * Round 2: other values */
8903 for ( ; round <= 2; varp = varp_local, ++round)
8904 {
8905 if (round == 1 || (opt_flags & OPT_GLOBAL))
8906 cmd = "set";
8907 else
8908 cmd = "setlocal";
8909
8910 if (p->flags & P_BOOL)
8911 {
8912 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
8913 return FAIL;
8914 }
8915 else if (p->flags & P_NUM)
8916 {
8917 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
8918 return FAIL;
8919 }
8920 else /* P_STRING */
8921 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008922#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
8923 int do_endif = FALSE;
8924
Bram Moolenaar071d4272004-06-13 20:20:40 +00008925 /* Don't set 'syntax' and 'filetype' again if the value is
8926 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008927 if (
8928# if defined(FEAT_SYN_HL)
8929 p->indir == PV_SYN
8930# if defined(FEAT_AUTOCMD)
8931 ||
8932# endif
8933# endif
8934# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00008935 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008936# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00008937 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00008938 {
8939 if (fprintf(fd, "if &%s != '%s'", p->fullname,
8940 *(char_u **)(varp)) < 0
8941 || put_eol(fd) < 0)
8942 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008943 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008944 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008945#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008946 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
8947 (p->flags & P_EXPAND) != 0) == FAIL)
8948 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008949#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
8950 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008951 {
8952 if (put_line(fd, "endif") == FAIL)
8953 return FAIL;
8954 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008955#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008956 }
8957 }
8958 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00008959 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008960 return OK;
8961}
8962
8963#if defined(FEAT_FOLDING) || defined(PROTO)
8964/*
8965 * Generate set commands for the local fold options only. Used when
8966 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
8967 */
8968 int
8969makefoldset(fd)
8970 FILE *fd;
8971{
8972 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
8973# ifdef FEAT_EVAL
8974 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
8975 == FAIL
8976# endif
8977 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
8978 == FAIL
8979 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
8980 == FAIL
8981 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
8982 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
8983 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
8984 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
8985 )
8986 return FAIL;
8987
8988 return OK;
8989}
8990#endif
8991
8992 static int
8993put_setstring(fd, cmd, name, valuep, expand)
8994 FILE *fd;
8995 char *cmd;
8996 char *name;
8997 char_u **valuep;
8998 int expand;
8999{
9000 char_u *s;
9001 char_u buf[MAXPATHL];
9002
9003 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9004 return FAIL;
9005 if (*valuep != NULL)
9006 {
9007 /* Output 'pastetoggle' as key names. For other
9008 * options some characters have to be escaped with
9009 * CTRL-V or backslash */
9010 if (valuep == &p_pt)
9011 {
9012 s = *valuep;
9013 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009014 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009015 return FAIL;
9016 }
9017 else if (expand)
9018 {
9019 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9020 if (put_escstr(fd, buf, 2) == FAIL)
9021 return FAIL;
9022 }
9023 else if (put_escstr(fd, *valuep, 2) == FAIL)
9024 return FAIL;
9025 }
9026 if (put_eol(fd) < 0)
9027 return FAIL;
9028 return OK;
9029}
9030
9031 static int
9032put_setnum(fd, cmd, name, valuep)
9033 FILE *fd;
9034 char *cmd;
9035 char *name;
9036 long *valuep;
9037{
9038 long wc;
9039
9040 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9041 return FAIL;
9042 if (wc_use_keyname((char_u *)valuep, &wc))
9043 {
9044 /* print 'wildchar' and 'wildcharm' as a key name */
9045 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9046 return FAIL;
9047 }
9048 else if (fprintf(fd, "%ld", *valuep) < 0)
9049 return FAIL;
9050 if (put_eol(fd) < 0)
9051 return FAIL;
9052 return OK;
9053}
9054
9055 static int
9056put_setbool(fd, cmd, name, value)
9057 FILE *fd;
9058 char *cmd;
9059 char *name;
9060 int value;
9061{
Bram Moolenaar893de922007-10-02 18:40:57 +00009062 if (value < 0) /* global/local option using global value */
9063 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009064 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9065 || put_eol(fd) < 0)
9066 return FAIL;
9067 return OK;
9068}
9069
9070/*
9071 * Clear all the terminal options.
9072 * If the option has been allocated, free the memory.
9073 * Terminal options are never hidden or indirect.
9074 */
9075 void
9076clear_termoptions()
9077{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009078 /*
9079 * Reset a few things before clearing the old options. This may cause
9080 * outputting a few things that the terminal doesn't understand, but the
9081 * screen will be cleared later, so this is OK.
9082 */
9083#ifdef FEAT_MOUSE_TTY
9084 mch_setmouse(FALSE); /* switch mouse off */
9085#endif
9086#ifdef FEAT_TITLE
9087 mch_restore_title(3); /* restore window titles */
9088#endif
9089#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9090 /* When starting the GUI close the display opened for the clipboard.
9091 * After restoring the title, because that will need the display. */
9092 if (gui.starting)
9093 clear_xterm_clip();
9094#endif
9095#ifdef WIN3264
9096 /*
9097 * Check if this is allowed now.
9098 */
9099 if (can_end_termcap_mode(FALSE) == TRUE)
9100#endif
9101 stoptermcap(); /* stop termcap mode */
9102
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009103 free_termoptions();
9104}
9105
9106 void
9107free_termoptions()
9108{
9109 struct vimoption *p;
9110
Bram Moolenaar071d4272004-06-13 20:20:40 +00009111 for (p = &options[0]; p->fullname != NULL; p++)
9112 if (istermoption(p))
9113 {
9114 if (p->flags & P_ALLOCED)
9115 free_string_option(*(char_u **)(p->var));
9116 if (p->flags & P_DEF_ALLOCED)
9117 free_string_option(p->def_val[VI_DEFAULT]);
9118 *(char_u **)(p->var) = empty_option;
9119 p->def_val[VI_DEFAULT] = empty_option;
9120 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9121 }
9122 clear_termcodes();
9123}
9124
9125/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009126 * Free the string for one term option, if it was allocated.
9127 * Set the string to empty_option and clear allocated flag.
9128 * "var" points to the option value.
9129 */
9130 void
9131free_one_termoption(var)
9132 char_u *var;
9133{
9134 struct vimoption *p;
9135
9136 for (p = &options[0]; p->fullname != NULL; p++)
9137 if (p->var == var)
9138 {
9139 if (p->flags & P_ALLOCED)
9140 free_string_option(*(char_u **)(p->var));
9141 *(char_u **)(p->var) = empty_option;
9142 p->flags &= ~P_ALLOCED;
9143 break;
9144 }
9145}
9146
9147/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009148 * Set the terminal option defaults to the current value.
9149 * Used after setting the terminal name.
9150 */
9151 void
9152set_term_defaults()
9153{
9154 struct vimoption *p;
9155
9156 for (p = &options[0]; p->fullname != NULL; p++)
9157 {
9158 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9159 {
9160 if (p->flags & P_DEF_ALLOCED)
9161 {
9162 free_string_option(p->def_val[VI_DEFAULT]);
9163 p->flags &= ~P_DEF_ALLOCED;
9164 }
9165 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9166 if (p->flags & P_ALLOCED)
9167 {
9168 p->flags |= P_DEF_ALLOCED;
9169 p->flags &= ~P_ALLOCED; /* don't free the value now */
9170 }
9171 }
9172 }
9173}
9174
9175/*
9176 * return TRUE if 'p' starts with 't_'
9177 */
9178 static int
9179istermoption(p)
9180 struct vimoption *p;
9181{
9182 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9183}
9184
9185/*
9186 * Compute columns for ruler and shown command. 'sc_col' is also used to
9187 * decide what the maximum length of a message on the status line can be.
9188 * If there is a status line for the last window, 'sc_col' is independent
9189 * of 'ru_col'.
9190 */
9191
9192#define COL_RULER 17 /* columns needed by standard ruler */
9193
9194 void
9195comp_col()
9196{
9197#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9198 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9199
9200 sc_col = 0;
9201 ru_col = 0;
9202 if (p_ru)
9203 {
9204#ifdef FEAT_STL_OPT
9205 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9206#else
9207 ru_col = COL_RULER + 1;
9208#endif
9209 /* no last status line, adjust sc_col */
9210 if (!last_has_status)
9211 sc_col = ru_col;
9212 }
9213 if (p_sc)
9214 {
9215 sc_col += SHOWCMD_COLS;
9216 if (!p_ru || last_has_status) /* no need for separating space */
9217 ++sc_col;
9218 }
9219 sc_col = Columns - sc_col;
9220 ru_col = Columns - ru_col;
9221 if (sc_col <= 0) /* screen too narrow, will become a mess */
9222 sc_col = 1;
9223 if (ru_col <= 0)
9224 ru_col = 1;
9225#else
9226 sc_col = Columns;
9227 ru_col = Columns;
9228#endif
9229}
9230
9231/*
9232 * Get pointer to option variable, depending on local or global scope.
9233 */
9234 static char_u *
9235get_varp_scope(p, opt_flags)
9236 struct vimoption *p;
9237 int opt_flags;
9238{
9239 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9240 {
9241 if (p->var == VAR_WIN)
9242 return (char_u *)GLOBAL_WO(get_varp(p));
9243 return p->var;
9244 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009245 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009246 {
9247 switch ((int)p->indir)
9248 {
9249#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009250 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9251 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9252 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009253#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009254 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9255 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9256 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009257 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009258 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009259#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009260 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9261 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009262#endif
9263#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009264 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9265 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009266#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009267#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9268 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9269#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009270#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009271 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009272#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009273 }
9274 return NULL; /* "cannot happen" */
9275 }
9276 return get_varp(p);
9277}
9278
9279/*
9280 * Get pointer to option variable.
9281 */
9282 static char_u *
9283get_varp(p)
9284 struct vimoption *p;
9285{
9286 /* hidden option, always return NULL */
9287 if (p->var == NULL)
9288 return NULL;
9289
9290 switch ((int)p->indir)
9291 {
9292 case PV_NONE: return p->var;
9293
9294 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009295 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009296 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009297 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009298 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009299 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009300 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009301 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00009302 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009303 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009304 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9305#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009306 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009307 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009308 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009309 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9310#endif
9311#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009312 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009313 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009314 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009315 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9316#endif
9317#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009318 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009319 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009320 case PV_GP: return *curbuf->b_p_gp != NUL
9321 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9322 case PV_MP: return *curbuf->b_p_mp != NUL
9323 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009324#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009325#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9326 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9327 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9328#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009329#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009330 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009331 ? (char_u *)&(curwin->w_p_stl) : p->var;
9332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009333
9334#ifdef FEAT_ARABIC
9335 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9336#endif
9337 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009338#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00009339 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
9340#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009341#ifdef FEAT_SYN_HL
9342 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
9343 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
9344#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009345#ifdef FEAT_DIFF
9346 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
9347#endif
9348#ifdef FEAT_FOLDING
9349 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
9350 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
9351 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
9352 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
9353 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
9354 case PV_FML: return (char_u *)&(curwin->w_p_fml);
9355 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
9356# ifdef FEAT_EVAL
9357 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
9358 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
9359# endif
9360 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
9361#endif
9362 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +02009363 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009364#ifdef FEAT_LINEBREAK
9365 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
9366#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009367#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00009368 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
9369#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00009370#ifdef FEAT_VERTSPLIT
9371 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
9372#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009373#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
9374 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
9375#endif
9376#ifdef FEAT_RIGHTLEFT
9377 case PV_RL: return (char_u *)&(curwin->w_p_rl);
9378 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
9379#endif
9380 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
9381 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
9382#ifdef FEAT_LINEBREAK
9383 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
9384#endif
9385#ifdef FEAT_SCROLLBIND
9386 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
9387#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +02009388#ifdef FEAT_CURSORBIND
9389 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
9390#endif
9391#ifdef FEAT_CONCEAL
9392 case PV_CONCEAL: return (char_u *)&(curwin->w_p_conceal);
9393#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009394
9395 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
9396 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
9397#ifdef FEAT_MBYTE
9398 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
9399#endif
9400#if defined(FEAT_QUICKFIX)
9401 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
9402 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
9403#endif
9404 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
9405 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
9406#ifdef FEAT_CINDENT
9407 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
9408 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
9409 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
9410#endif
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02009411#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +02009412 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
Bram Moolenaar0bbabe82010-05-17 20:32:55 +02009413#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009414#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9415 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
9416#endif
9417#ifdef FEAT_COMMENTS
9418 case PV_COM: return (char_u *)&(curbuf->b_p_com);
9419#endif
9420#ifdef FEAT_FOLDING
9421 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
9422#endif
9423#ifdef FEAT_INS_EXPAND
9424 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
9425#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009426#ifdef FEAT_COMPL_FUNC
9427 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00009428 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009429#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009430 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
9431 case PV_ET: return (char_u *)&(curbuf->b_p_et);
9432#ifdef FEAT_MBYTE
9433 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
9434#endif
9435 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
9436#ifdef FEAT_AUTOCMD
9437 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
9438#endif
9439 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00009440 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009441 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
9442 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
9443 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
9444 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
9445#ifdef FEAT_FIND_ID
9446# ifdef FEAT_EVAL
9447 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
9448# endif
9449#endif
9450#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9451 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
9452 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
9453#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009454#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00009455 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
9456#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009457#ifdef FEAT_CRYPT
9458 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
9459#endif
9460#ifdef FEAT_LISP
9461 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
9462#endif
9463 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
9464 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
9465 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
9466 case PV_MOD: return (char_u *)&(curbuf->b_changed);
9467 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
9468#ifdef FEAT_OSFILETYPE
9469 case PV_OFT: return (char_u *)&(curbuf->b_p_oft);
9470#endif
9471 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009472#ifdef FEAT_TEXTOBJ
9473 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
9474#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009475 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
9476#ifdef FEAT_SMARTINDENT
9477 case PV_SI: return (char_u *)&(curbuf->b_p_si);
9478#endif
9479#ifndef SHORT_FNAME
9480 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
9481#endif
9482 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
9483#ifdef FEAT_SEARCHPATH
9484 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
9485#endif
9486 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
9487#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00009488 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009489 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
9490#endif
9491#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02009492 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
9493 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
9494 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009495#endif
9496 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
9497 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
9498 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
9499 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +02009500#ifdef FEAT_PERSISTENT_UNDO
9501 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
9502#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009503 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
9504#ifdef FEAT_KEYMAP
9505 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
9506#endif
9507 default: EMSG(_("E356: get_varp ERROR"));
9508 }
9509 /* always return a valid pointer to avoid a crash! */
9510 return (char_u *)&(curbuf->b_p_wm);
9511}
9512
9513/*
9514 * Get the value of 'equalprg', either the buffer-local one or the global one.
9515 */
9516 char_u *
9517get_equalprg()
9518{
9519 if (*curbuf->b_p_ep == NUL)
9520 return p_ep;
9521 return curbuf->b_p_ep;
9522}
9523
9524#if defined(FEAT_WINDOWS) || defined(PROTO)
9525/*
9526 * Copy options from one window to another.
9527 * Used when splitting a window.
9528 */
9529 void
9530win_copy_options(wp_from, wp_to)
9531 win_T *wp_from;
9532 win_T *wp_to;
9533{
9534 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
9535 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
9536# ifdef FEAT_RIGHTLEFT
9537# ifdef FEAT_FKMAP
9538 /* Is this right? */
9539 wp_to->w_farsi = wp_from->w_farsi;
9540# endif
9541# endif
9542}
9543#endif
9544
9545/*
9546 * Copy the options from one winopt_T to another.
9547 * Doesn't free the old option values in "to", use clear_winopt() for that.
9548 * The 'scroll' option is not copied, because it depends on the window height.
9549 * The 'previewwindow' option is reset, there can be only one preview window.
9550 */
9551 void
9552copy_winopt(from, to)
9553 winopt_T *from;
9554 winopt_T *to;
9555{
9556#ifdef FEAT_ARABIC
9557 to->wo_arab = from->wo_arab;
9558#endif
9559 to->wo_list = from->wo_list;
9560 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +02009561 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009562#ifdef FEAT_LINEBREAK
9563 to->wo_nuw = from->wo_nuw;
9564#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009565#ifdef FEAT_RIGHTLEFT
9566 to->wo_rl = from->wo_rl;
9567 to->wo_rlc = vim_strsave(from->wo_rlc);
9568#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009569#ifdef FEAT_STL_OPT
9570 to->wo_stl = vim_strsave(from->wo_stl);
9571#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009572 to->wo_wrap = from->wo_wrap;
9573#ifdef FEAT_LINEBREAK
9574 to->wo_lbr = from->wo_lbr;
9575#endif
9576#ifdef FEAT_SCROLLBIND
9577 to->wo_scb = from->wo_scb;
9578#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009579#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00009580 to->wo_spell = from->wo_spell;
9581#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009582#ifdef FEAT_SYN_HL
9583 to->wo_cuc = from->wo_cuc;
9584 to->wo_cul = from->wo_cul;
9585#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009586#ifdef FEAT_DIFF
9587 to->wo_diff = from->wo_diff;
9588#endif
9589#ifdef FEAT_FOLDING
9590 to->wo_fdc = from->wo_fdc;
9591 to->wo_fen = from->wo_fen;
9592 to->wo_fdi = vim_strsave(from->wo_fdi);
9593 to->wo_fml = from->wo_fml;
9594 to->wo_fdl = from->wo_fdl;
9595 to->wo_fdm = vim_strsave(from->wo_fdm);
9596 to->wo_fdn = from->wo_fdn;
9597# ifdef FEAT_EVAL
9598 to->wo_fde = vim_strsave(from->wo_fde);
9599 to->wo_fdt = vim_strsave(from->wo_fdt);
9600# endif
9601 to->wo_fmr = vim_strsave(from->wo_fmr);
9602#endif
9603 check_winopt(to); /* don't want NULL pointers */
9604}
9605
9606/*
9607 * Check string options in a window for a NULL value.
9608 */
9609 void
9610check_win_options(win)
9611 win_T *win;
9612{
9613 check_winopt(&win->w_onebuf_opt);
9614 check_winopt(&win->w_allbuf_opt);
9615}
9616
9617/*
9618 * Check for NULL pointers in a winopt_T and replace them with empty_option.
9619 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009620 void
9621check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +00009622 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009623{
9624#ifdef FEAT_FOLDING
9625 check_string_option(&wop->wo_fdi);
9626 check_string_option(&wop->wo_fdm);
9627# ifdef FEAT_EVAL
9628 check_string_option(&wop->wo_fde);
9629 check_string_option(&wop->wo_fdt);
9630# endif
9631 check_string_option(&wop->wo_fmr);
9632#endif
9633#ifdef FEAT_RIGHTLEFT
9634 check_string_option(&wop->wo_rlc);
9635#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009636#ifdef FEAT_STL_OPT
9637 check_string_option(&wop->wo_stl);
9638#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009639}
9640
9641/*
9642 * Free the allocated memory inside a winopt_T.
9643 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009644 void
9645clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +00009646 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009647{
9648#ifdef FEAT_FOLDING
9649 clear_string_option(&wop->wo_fdi);
9650 clear_string_option(&wop->wo_fdm);
9651# ifdef FEAT_EVAL
9652 clear_string_option(&wop->wo_fde);
9653 clear_string_option(&wop->wo_fdt);
9654# endif
9655 clear_string_option(&wop->wo_fmr);
9656#endif
9657#ifdef FEAT_RIGHTLEFT
9658 clear_string_option(&wop->wo_rlc);
9659#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009660#ifdef FEAT_STL_OPT
9661 clear_string_option(&wop->wo_stl);
9662#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009663}
9664
9665/*
9666 * Copy global option values to local options for one buffer.
9667 * Used when creating a new buffer and sometimes when entering a buffer.
9668 * flags:
9669 * BCO_ENTER We will enter the buf buffer.
9670 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
9671 * appropriate.
9672 * BCO_NOHELP Don't copy the values to a help buffer.
9673 */
9674 void
9675buf_copy_options(buf, flags)
9676 buf_T *buf;
9677 int flags;
9678{
9679 int should_copy = TRUE;
9680 char_u *save_p_isk = NULL; /* init for GCC */
9681 int dont_do_help;
9682 int did_isk = FALSE;
9683
9684 /*
9685 * Don't do anything of the buffer is invalid.
9686 */
9687 if (buf == NULL || !buf_valid(buf))
9688 return;
9689
9690 /*
9691 * Skip this when the option defaults have not been set yet. Happens when
9692 * main() allocates the first buffer.
9693 */
9694 if (p_cpo != NULL)
9695 {
9696 /*
9697 * Always copy when entering and 'cpo' contains 'S'.
9698 * Don't copy when already initialized.
9699 * Don't copy when 'cpo' contains 's' and not entering.
9700 * 'S' BCO_ENTER initialized 's' should_copy
9701 * yes yes X X TRUE
9702 * yes no yes X FALSE
9703 * no X yes X FALSE
9704 * X no no yes FALSE
9705 * X no no no TRUE
9706 * no yes no X TRUE
9707 */
9708 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
9709 && (buf->b_p_initialized
9710 || (!(flags & BCO_ENTER)
9711 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
9712 should_copy = FALSE;
9713
9714 if (should_copy || (flags & BCO_ALWAYS))
9715 {
9716 /* Don't copy the options specific to a help buffer when
9717 * BCO_NOHELP is given or the options were initialized already
9718 * (jumping back to a help file with CTRL-T or CTRL-O) */
9719 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
9720 || buf->b_p_initialized;
9721 if (dont_do_help) /* don't free b_p_isk */
9722 {
9723 save_p_isk = buf->b_p_isk;
9724 buf->b_p_isk = NULL;
9725 }
9726 /*
9727 * Always free the allocated strings.
9728 * If not already initialized, set 'readonly' and copy 'fileformat'.
9729 */
9730 if (!buf->b_p_initialized)
9731 {
9732 free_buf_options(buf, TRUE);
9733 buf->b_p_ro = FALSE; /* don't copy readonly */
9734 buf->b_p_tx = p_tx;
9735#ifdef FEAT_MBYTE
9736 buf->b_p_fenc = vim_strsave(p_fenc);
9737#endif
9738 buf->b_p_ff = vim_strsave(p_ff);
9739#if defined(FEAT_QUICKFIX)
9740 buf->b_p_bh = empty_option;
9741 buf->b_p_bt = empty_option;
9742#endif
9743 }
9744 else
9745 free_buf_options(buf, FALSE);
9746
9747 buf->b_p_ai = p_ai;
9748 buf->b_p_ai_nopaste = p_ai_nopaste;
9749 buf->b_p_sw = p_sw;
9750 buf->b_p_tw = p_tw;
9751 buf->b_p_tw_nopaste = p_tw_nopaste;
9752 buf->b_p_tw_nobin = p_tw_nobin;
9753 buf->b_p_wm = p_wm;
9754 buf->b_p_wm_nopaste = p_wm_nopaste;
9755 buf->b_p_wm_nobin = p_wm_nobin;
9756 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +00009757#ifdef FEAT_MBYTE
9758 buf->b_p_bomb = p_bomb;
9759#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009760 buf->b_p_et = p_et;
9761 buf->b_p_et_nobin = p_et_nobin;
9762 buf->b_p_ml = p_ml;
9763 buf->b_p_ml_nobin = p_ml_nobin;
9764 buf->b_p_inf = p_inf;
9765 buf->b_p_swf = p_swf;
9766#ifdef FEAT_INS_EXPAND
9767 buf->b_p_cpt = vim_strsave(p_cpt);
9768#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009769#ifdef FEAT_COMPL_FUNC
9770 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00009771 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009772#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009773 buf->b_p_sts = p_sts;
9774 buf->b_p_sts_nopaste = p_sts_nopaste;
9775#ifndef SHORT_FNAME
9776 buf->b_p_sn = p_sn;
9777#endif
9778#ifdef FEAT_COMMENTS
9779 buf->b_p_com = vim_strsave(p_com);
9780#endif
9781#ifdef FEAT_FOLDING
9782 buf->b_p_cms = vim_strsave(p_cms);
9783#endif
9784 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00009785 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009786 buf->b_p_nf = vim_strsave(p_nf);
9787 buf->b_p_mps = vim_strsave(p_mps);
9788#ifdef FEAT_SMARTINDENT
9789 buf->b_p_si = p_si;
9790#endif
9791 buf->b_p_ci = p_ci;
9792#ifdef FEAT_CINDENT
9793 buf->b_p_cin = p_cin;
9794 buf->b_p_cink = vim_strsave(p_cink);
9795 buf->b_p_cino = vim_strsave(p_cino);
9796#endif
9797#ifdef FEAT_AUTOCMD
9798 /* Don't copy 'filetype', it must be detected */
9799 buf->b_p_ft = empty_option;
9800#endif
9801#ifdef FEAT_OSFILETYPE
9802 buf->b_p_oft = vim_strsave(p_oft);
9803#endif
9804 buf->b_p_pi = p_pi;
9805#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9806 buf->b_p_cinw = vim_strsave(p_cinw);
9807#endif
9808#ifdef FEAT_LISP
9809 buf->b_p_lisp = p_lisp;
9810#endif
9811#ifdef FEAT_SYN_HL
9812 /* Don't copy 'syntax', it must be set */
9813 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00009814 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009815#endif
9816#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02009817 buf->b_s.b_p_spc = vim_strsave(p_spf);
9818 (void)compile_cap_prog(&buf->b_s);
9819 buf->b_s.b_p_spf = vim_strsave(p_spf);
9820 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009821#endif
9822#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9823 buf->b_p_inde = vim_strsave(p_inde);
9824 buf->b_p_indk = vim_strsave(p_indk);
9825#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00009826#if defined(FEAT_EVAL)
9827 buf->b_p_fex = vim_strsave(p_fex);
9828#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009829#ifdef FEAT_CRYPT
9830 buf->b_p_key = vim_strsave(p_key);
9831#endif
9832#ifdef FEAT_SEARCHPATH
9833 buf->b_p_sua = vim_strsave(p_sua);
9834#endif
9835#ifdef FEAT_KEYMAP
9836 buf->b_p_keymap = vim_strsave(p_keymap);
9837 buf->b_kmap_state |= KEYMAP_INIT;
9838#endif
9839 /* This isn't really an option, but copying the langmap and IME
9840 * state from the current buffer is better than resetting it. */
9841 buf->b_p_iminsert = p_iminsert;
9842 buf->b_p_imsearch = p_imsearch;
9843
9844 /* options that are normally global but also have a local value
9845 * are not copied, start using the global value */
9846 buf->b_p_ar = -1;
9847#ifdef FEAT_QUICKFIX
9848 buf->b_p_gp = empty_option;
9849 buf->b_p_mp = empty_option;
9850 buf->b_p_efm = empty_option;
9851#endif
9852 buf->b_p_ep = empty_option;
9853 buf->b_p_kp = empty_option;
9854 buf->b_p_path = empty_option;
9855 buf->b_p_tags = empty_option;
9856#ifdef FEAT_FIND_ID
9857 buf->b_p_def = empty_option;
9858 buf->b_p_inc = empty_option;
9859# ifdef FEAT_EVAL
9860 buf->b_p_inex = vim_strsave(p_inex);
9861# endif
9862#endif
9863#ifdef FEAT_INS_EXPAND
9864 buf->b_p_dict = empty_option;
9865 buf->b_p_tsr = empty_option;
9866#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009867#ifdef FEAT_TEXTOBJ
9868 buf->b_p_qe = vim_strsave(p_qe);
9869#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009870#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9871 buf->b_p_bexpr = empty_option;
9872#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +02009873#ifdef FEAT_PERSISTENT_UNDO
9874 buf->b_p_udf = p_udf;
9875#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009876
9877 /*
9878 * Don't copy the options set by ex_help(), use the saved values,
9879 * when going from a help buffer to a non-help buffer.
9880 * Don't touch these at all when BCO_NOHELP is used and going from
9881 * or to a help buffer.
9882 */
9883 if (dont_do_help)
9884 buf->b_p_isk = save_p_isk;
9885 else
9886 {
9887 buf->b_p_isk = vim_strsave(p_isk);
9888 did_isk = TRUE;
9889 buf->b_p_ts = p_ts;
9890 buf->b_help = FALSE;
9891#ifdef FEAT_QUICKFIX
9892 if (buf->b_p_bt[0] == 'h')
9893 clear_string_option(&buf->b_p_bt);
9894#endif
9895 buf->b_p_ma = p_ma;
9896 }
9897 }
9898
9899 /*
9900 * When the options should be copied (ignoring BCO_ALWAYS), set the
9901 * flag that indicates that the options have been initialized.
9902 */
9903 if (should_copy)
9904 buf->b_p_initialized = TRUE;
9905 }
9906
9907 check_buf_options(buf); /* make sure we don't have NULLs */
9908 if (did_isk)
9909 (void)buf_init_chartab(buf, FALSE);
9910}
9911
9912/*
9913 * Reset the 'modifiable' option and its default value.
9914 */
9915 void
9916reset_modifiable()
9917{
9918 int opt_idx;
9919
9920 curbuf->b_p_ma = FALSE;
9921 p_ma = FALSE;
9922 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009923 if (opt_idx >= 0)
9924 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009925}
9926
9927/*
9928 * Set the global value for 'iminsert' to the local value.
9929 */
9930 void
9931set_iminsert_global()
9932{
9933 p_iminsert = curbuf->b_p_iminsert;
9934}
9935
9936/*
9937 * Set the global value for 'imsearch' to the local value.
9938 */
9939 void
9940set_imsearch_global()
9941{
9942 p_imsearch = curbuf->b_p_imsearch;
9943}
9944
9945#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
9946static int expand_option_idx = -1;
9947static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
9948static int expand_option_flags = 0;
9949
9950 void
9951set_context_in_set_cmd(xp, arg, opt_flags)
9952 expand_T *xp;
9953 char_u *arg;
9954 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
9955{
9956 int nextchar;
9957 long_u flags = 0; /* init for GCC */
9958 int opt_idx = 0; /* init for GCC */
9959 char_u *p;
9960 char_u *s;
9961 int is_term_option = FALSE;
9962 int key;
9963
9964 expand_option_flags = opt_flags;
9965
9966 xp->xp_context = EXPAND_SETTINGS;
9967 if (*arg == NUL)
9968 {
9969 xp->xp_pattern = arg;
9970 return;
9971 }
9972 p = arg + STRLEN(arg) - 1;
9973 if (*p == ' ' && *(p - 1) != '\\')
9974 {
9975 xp->xp_pattern = p + 1;
9976 return;
9977 }
9978 while (p > arg)
9979 {
9980 s = p;
9981 /* count number of backslashes before ' ' or ',' */
9982 if (*p == ' ' || *p == ',')
9983 {
9984 while (s > arg && *(s - 1) == '\\')
9985 --s;
9986 }
9987 /* break at a space with an even number of backslashes */
9988 if (*p == ' ' && ((p - s) & 1) == 0)
9989 {
9990 ++p;
9991 break;
9992 }
9993 --p;
9994 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00009995 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009996 {
9997 xp->xp_context = EXPAND_BOOL_SETTINGS;
9998 p += 2;
9999 }
10000 if (STRNCMP(p, "inv", 3) == 0)
10001 {
10002 xp->xp_context = EXPAND_BOOL_SETTINGS;
10003 p += 3;
10004 }
10005 xp->xp_pattern = arg = p;
10006 if (*arg == '<')
10007 {
10008 while (*p != '>')
10009 if (*p++ == NUL) /* expand terminal option name */
10010 return;
10011 key = get_special_key_code(arg + 1);
10012 if (key == 0) /* unknown name */
10013 {
10014 xp->xp_context = EXPAND_NOTHING;
10015 return;
10016 }
10017 nextchar = *++p;
10018 is_term_option = TRUE;
10019 expand_option_name[2] = KEY2TERMCAP0(key);
10020 expand_option_name[3] = KEY2TERMCAP1(key);
10021 }
10022 else
10023 {
10024 if (p[0] == 't' && p[1] == '_')
10025 {
10026 p += 2;
10027 if (*p != NUL)
10028 ++p;
10029 if (*p == NUL)
10030 return; /* expand option name */
10031 nextchar = *++p;
10032 is_term_option = TRUE;
10033 expand_option_name[2] = p[-2];
10034 expand_option_name[3] = p[-1];
10035 }
10036 else
10037 {
10038 /* Allow * wildcard */
10039 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10040 p++;
10041 if (*p == NUL)
10042 return;
10043 nextchar = *p;
10044 *p = NUL;
10045 opt_idx = findoption(arg);
10046 *p = nextchar;
10047 if (opt_idx == -1 || options[opt_idx].var == NULL)
10048 {
10049 xp->xp_context = EXPAND_NOTHING;
10050 return;
10051 }
10052 flags = options[opt_idx].flags;
10053 if (flags & P_BOOL)
10054 {
10055 xp->xp_context = EXPAND_NOTHING;
10056 return;
10057 }
10058 }
10059 }
10060 /* handle "-=" and "+=" */
10061 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10062 {
10063 ++p;
10064 nextchar = '=';
10065 }
10066 if ((nextchar != '=' && nextchar != ':')
10067 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10068 {
10069 xp->xp_context = EXPAND_UNSUCCESSFUL;
10070 return;
10071 }
10072 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10073 {
10074 xp->xp_context = EXPAND_OLD_SETTING;
10075 if (is_term_option)
10076 expand_option_idx = -1;
10077 else
10078 expand_option_idx = opt_idx;
10079 xp->xp_pattern = p + 1;
10080 return;
10081 }
10082 xp->xp_context = EXPAND_NOTHING;
10083 if (is_term_option || (flags & P_NUM))
10084 return;
10085
10086 xp->xp_pattern = p + 1;
10087
10088 if (flags & P_EXPAND)
10089 {
10090 p = options[opt_idx].var;
10091 if (p == (char_u *)&p_bdir
10092 || p == (char_u *)&p_dir
10093 || p == (char_u *)&p_path
10094 || p == (char_u *)&p_rtp
10095#ifdef FEAT_SEARCHPATH
10096 || p == (char_u *)&p_cdpath
10097#endif
10098#ifdef FEAT_SESSION
10099 || p == (char_u *)&p_vdir
10100#endif
10101 )
10102 {
10103 xp->xp_context = EXPAND_DIRECTORIES;
10104 if (p == (char_u *)&p_path
10105#ifdef FEAT_SEARCHPATH
10106 || p == (char_u *)&p_cdpath
10107#endif
10108 )
10109 xp->xp_backslash = XP_BS_THREE;
10110 else
10111 xp->xp_backslash = XP_BS_ONE;
10112 }
10113 else
10114 {
10115 xp->xp_context = EXPAND_FILES;
10116 /* for 'tags' need three backslashes for a space */
10117 if (p == (char_u *)&p_tags)
10118 xp->xp_backslash = XP_BS_THREE;
10119 else
10120 xp->xp_backslash = XP_BS_ONE;
10121 }
10122 }
10123
10124 /* For an option that is a list of file names, find the start of the
10125 * last file name. */
10126 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
10127 {
10128 /* count number of backslashes before ' ' or ',' */
10129 if (*p == ' ' || *p == ',')
10130 {
10131 s = p;
10132 while (s > xp->xp_pattern && *(s - 1) == '\\')
10133 --s;
10134 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10135 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10136 {
10137 xp->xp_pattern = p + 1;
10138 break;
10139 }
10140 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010141
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010142#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010143 /* for 'spellsuggest' start at "file:" */
10144 if (options[opt_idx].var == (char_u *)&p_sps
10145 && STRNCMP(p, "file:", 5) == 0)
10146 {
10147 xp->xp_pattern = p + 5;
10148 break;
10149 }
10150#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010151 }
10152
10153 return;
10154}
10155
10156 int
10157ExpandSettings(xp, regmatch, num_file, file)
10158 expand_T *xp;
10159 regmatch_T *regmatch;
10160 int *num_file;
10161 char_u ***file;
10162{
10163 int num_normal = 0; /* Nr of matching non-term-code settings */
10164 int num_term = 0; /* Nr of matching terminal code settings */
10165 int opt_idx;
10166 int match;
10167 int count = 0;
10168 char_u *str;
10169 int loop;
10170 int is_term_opt;
10171 char_u name_buf[MAX_KEY_NAME_LEN];
10172 static char *(names[]) = {"all", "termcap"};
10173 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10174
10175 /* do this loop twice:
10176 * loop == 0: count the number of matching options
10177 * loop == 1: copy the matching options into allocated memory
10178 */
10179 for (loop = 0; loop <= 1; ++loop)
10180 {
10181 regmatch->rm_ic = ic;
10182 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10183 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000010184 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10185 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010186 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10187 {
10188 if (loop == 0)
10189 num_normal++;
10190 else
10191 (*file)[count++] = vim_strsave((char_u *)names[match]);
10192 }
10193 }
10194 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10195 opt_idx++)
10196 {
10197 if (options[opt_idx].var == NULL)
10198 continue;
10199 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10200 && !(options[opt_idx].flags & P_BOOL))
10201 continue;
10202 is_term_opt = istermoption(&options[opt_idx]);
10203 if (is_term_opt && num_normal > 0)
10204 continue;
10205 match = FALSE;
10206 if (vim_regexec(regmatch, str, (colnr_T)0)
10207 || (options[opt_idx].shortname != NULL
10208 && vim_regexec(regmatch,
10209 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10210 match = TRUE;
10211 else if (is_term_opt)
10212 {
10213 name_buf[0] = '<';
10214 name_buf[1] = 't';
10215 name_buf[2] = '_';
10216 name_buf[3] = str[2];
10217 name_buf[4] = str[3];
10218 name_buf[5] = '>';
10219 name_buf[6] = NUL;
10220 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10221 {
10222 match = TRUE;
10223 str = name_buf;
10224 }
10225 }
10226 if (match)
10227 {
10228 if (loop == 0)
10229 {
10230 if (is_term_opt)
10231 num_term++;
10232 else
10233 num_normal++;
10234 }
10235 else
10236 (*file)[count++] = vim_strsave(str);
10237 }
10238 }
10239 /*
10240 * Check terminal key codes, these are not in the option table
10241 */
10242 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10243 {
10244 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10245 {
10246 if (!isprint(str[0]) || !isprint(str[1]))
10247 continue;
10248
10249 name_buf[0] = 't';
10250 name_buf[1] = '_';
10251 name_buf[2] = str[0];
10252 name_buf[3] = str[1];
10253 name_buf[4] = NUL;
10254
10255 match = FALSE;
10256 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10257 match = TRUE;
10258 else
10259 {
10260 name_buf[0] = '<';
10261 name_buf[1] = 't';
10262 name_buf[2] = '_';
10263 name_buf[3] = str[0];
10264 name_buf[4] = str[1];
10265 name_buf[5] = '>';
10266 name_buf[6] = NUL;
10267
10268 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10269 match = TRUE;
10270 }
10271 if (match)
10272 {
10273 if (loop == 0)
10274 num_term++;
10275 else
10276 (*file)[count++] = vim_strsave(name_buf);
10277 }
10278 }
10279
10280 /*
10281 * Check special key names.
10282 */
10283 regmatch->rm_ic = TRUE; /* ignore case here */
10284 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10285 {
10286 name_buf[0] = '<';
10287 STRCPY(name_buf + 1, str);
10288 STRCAT(name_buf, ">");
10289
10290 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10291 {
10292 if (loop == 0)
10293 num_term++;
10294 else
10295 (*file)[count++] = vim_strsave(name_buf);
10296 }
10297 }
10298 }
10299 if (loop == 0)
10300 {
10301 if (num_normal > 0)
10302 *num_file = num_normal;
10303 else if (num_term > 0)
10304 *num_file = num_term;
10305 else
10306 return OK;
10307 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
10308 if (*file == NULL)
10309 {
10310 *file = (char_u **)"";
10311 return FAIL;
10312 }
10313 }
10314 }
10315 return OK;
10316}
10317
10318 int
10319ExpandOldSetting(num_file, file)
10320 int *num_file;
10321 char_u ***file;
10322{
10323 char_u *var = NULL; /* init for GCC */
10324 char_u *buf;
10325
10326 *num_file = 0;
10327 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
10328 if (*file == NULL)
10329 return FAIL;
10330
10331 /*
10332 * For a terminal key code expand_option_idx is < 0.
10333 */
10334 if (expand_option_idx < 0)
10335 {
10336 var = find_termcode(expand_option_name + 2);
10337 if (var == NULL)
10338 expand_option_idx = findoption(expand_option_name);
10339 }
10340
10341 if (expand_option_idx >= 0)
10342 {
10343 /* put string of option value in NameBuff */
10344 option_value2string(&options[expand_option_idx], expand_option_flags);
10345 var = NameBuff;
10346 }
10347 else if (var == NULL)
10348 var = (char_u *)"";
10349
10350 /* A backslash is required before some characters. This is the reverse of
10351 * what happens in do_set(). */
10352 buf = vim_strsave_escaped(var, escape_chars);
10353
10354 if (buf == NULL)
10355 {
10356 vim_free(*file);
10357 *file = NULL;
10358 return FAIL;
10359 }
10360
10361#ifdef BACKSLASH_IN_FILENAME
10362 /* For MS-Windows et al. we don't double backslashes at the start and
10363 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010364 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010365 if (var[0] == '\\' && var[1] == '\\'
10366 && expand_option_idx >= 0
10367 && (options[expand_option_idx].flags & P_EXPAND)
10368 && vim_isfilec(var[2])
10369 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000010370 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010371#endif
10372
10373 *file[0] = buf;
10374 *num_file = 1;
10375 return OK;
10376}
10377#endif
10378
10379/*
10380 * Get the value for the numeric or string option *opp in a nice format into
10381 * NameBuff[]. Must not be called with a hidden option!
10382 */
10383 static void
10384option_value2string(opp, opt_flags)
10385 struct vimoption *opp;
10386 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10387{
10388 char_u *varp;
10389
10390 varp = get_varp_scope(opp, opt_flags);
10391
10392 if (opp->flags & P_NUM)
10393 {
10394 long wc = 0;
10395
10396 if (wc_use_keyname(varp, &wc))
10397 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
10398 else if (wc != 0)
10399 STRCPY(NameBuff, transchar((int)wc));
10400 else
10401 sprintf((char *)NameBuff, "%ld", *(long *)varp);
10402 }
10403 else /* P_STRING */
10404 {
10405 varp = *(char_u **)(varp);
10406 if (varp == NULL) /* just in case */
10407 NameBuff[0] = NUL;
10408#ifdef FEAT_CRYPT
10409 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000010410 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010411 STRCPY(NameBuff, "*****");
10412#endif
10413 else if (opp->flags & P_EXPAND)
10414 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
10415 /* Translate 'pastetoggle' into special key names */
10416 else if ((char_u **)opp->var == &p_pt)
10417 str2specialbuf(p_pt, NameBuff, MAXPATHL);
10418 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000010419 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010420 }
10421}
10422
10423/*
10424 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
10425 * printed as a keyname.
10426 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
10427 */
10428 static int
10429wc_use_keyname(varp, wcp)
10430 char_u *varp;
10431 long *wcp;
10432{
10433 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
10434 {
10435 *wcp = *(long *)varp;
10436 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
10437 return TRUE;
10438 }
10439 return FALSE;
10440}
10441
10442#ifdef FEAT_LANGMAP
10443/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010444 * Any character has an equivalent 'langmap' character. This is used for
10445 * keyboards that have a special language mode that sends characters above
10446 * 128 (although other characters can be translated too). The "to" field is a
10447 * Vim command character. This avoids having to switch the keyboard back to
10448 * ASCII mode when leaving Insert mode.
10449 *
10450 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
10451 * commands.
10452 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
10453 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
10454 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010455 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010456# ifdef FEAT_MBYTE
10457/*
10458 * With multi-byte support use growarray for 'langmap' chars >= 256
10459 */
10460typedef struct
10461{
10462 int from;
10463 int to;
10464} langmap_entry_T;
10465
10466static garray_T langmap_mapga;
10467static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010468
10469/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010470 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
10471 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010472 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010473 static void
10474langmap_set_entry(from, to)
10475 int from;
10476 int to;
10477{
10478 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020010479 int a = 0;
10480 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010481
10482 /* Do a binary search for an existing entry. */
10483 while (a != b)
10484 {
10485 int i = (a + b) / 2;
10486 int d = entries[i].from - from;
10487
10488 if (d == 0)
10489 {
10490 entries[i].to = to;
10491 return;
10492 }
10493 if (d < 0)
10494 a = i + 1;
10495 else
10496 b = i;
10497 }
10498
10499 if (ga_grow(&langmap_mapga, 1) != OK)
10500 return; /* out of memory */
10501
10502 /* insert new entry at position "a" */
10503 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
10504 mch_memmove(entries + 1, entries,
10505 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
10506 ++langmap_mapga.ga_len;
10507 entries[0].from = from;
10508 entries[0].to = to;
10509}
10510
10511/*
10512 * Apply 'langmap' to multi-byte character "c" and return the result.
10513 */
10514 int
10515langmap_adjust_mb(c)
10516 int c;
10517{
10518 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
10519 int a = 0;
10520 int b = langmap_mapga.ga_len;
10521
10522 while (a != b)
10523 {
10524 int i = (a + b) / 2;
10525 int d = entries[i].from - c;
10526
10527 if (d == 0)
10528 return entries[i].to; /* found matching entry */
10529 if (d < 0)
10530 a = i + 1;
10531 else
10532 b = i;
10533 }
10534 return c; /* no entry found, return "c" unmodified */
10535}
10536# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010537
10538 static void
10539langmap_init()
10540{
10541 int i;
10542
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010543 for (i = 0; i < 256; i++)
10544 langmap_mapchar[i] = i; /* we init with a one-to-one map */
10545# ifdef FEAT_MBYTE
10546 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
10547# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010548}
10549
10550/*
10551 * Called when langmap option is set; the language map can be
10552 * changed at any time!
10553 */
10554 static void
10555langmap_set()
10556{
10557 char_u *p;
10558 char_u *p2;
10559 int from, to;
10560
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010561#ifdef FEAT_MBYTE
10562 ga_clear(&langmap_mapga); /* clear the previous map first */
10563#endif
10564 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565
10566 for (p = p_langmap; p[0] != NUL; )
10567 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010568 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
10569 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570 {
10571 if (p2[0] == '\\' && p2[1] != NUL)
10572 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010573 }
10574 if (p2[0] == ';')
10575 ++p2; /* abcd;ABCD form, p2 points to A */
10576 else
10577 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
10578 while (p[0])
10579 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020010580 if (p[0] == ',')
10581 {
10582 ++p;
10583 break;
10584 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010585 if (p[0] == '\\' && p[1] != NUL)
10586 ++p;
10587#ifdef FEAT_MBYTE
10588 from = (*mb_ptr2char)(p);
10589#else
10590 from = p[0];
10591#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020010592 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010593 if (p2 == NULL)
10594 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010595 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020010596 if (p[0] != ',')
10597 {
10598 if (p[0] == '\\')
10599 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010600#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020010601 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010602#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020010603 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000010604#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020010605 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010606 }
10607 else
10608 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020010609 if (p2[0] != ',')
10610 {
10611 if (p2[0] == '\\')
10612 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010613#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020010614 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010615#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020010616 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000010617#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020010618 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010619 }
10620 if (to == NUL)
10621 {
10622 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
10623 transchar(from));
10624 return;
10625 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010626
10627#ifdef FEAT_MBYTE
10628 if (from >= 256)
10629 langmap_set_entry(from, to);
10630 else
10631#endif
10632 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010633
10634 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010635 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020010636 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010637 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010638 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010639 if (*p == ';')
10640 {
10641 p = p2;
10642 if (p[0] != NUL)
10643 {
10644 if (p[0] != ',')
10645 {
10646 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
10647 return;
10648 }
10649 ++p;
10650 }
10651 break;
10652 }
10653 }
10654 }
10655 }
10656}
10657#endif
10658
10659/*
10660 * Return TRUE if format option 'x' is in effect.
10661 * Take care of no formatting when 'paste' is set.
10662 */
10663 int
10664has_format_option(x)
10665 int x;
10666{
10667 if (p_paste)
10668 return FALSE;
10669 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
10670}
10671
10672/*
10673 * Return TRUE if "x" is present in 'shortmess' option, or
10674 * 'shortmess' contains 'a' and "x" is present in SHM_A.
10675 */
10676 int
10677shortmess(x)
10678 int x;
10679{
10680 return ( vim_strchr(p_shm, x) != NULL
10681 || (vim_strchr(p_shm, 'a') != NULL
10682 && vim_strchr((char_u *)SHM_A, x) != NULL));
10683}
10684
10685/*
10686 * paste_option_changed() - Called after p_paste was set or reset.
10687 */
10688 static void
10689paste_option_changed()
10690{
10691 static int old_p_paste = FALSE;
10692 static int save_sm = 0;
10693#ifdef FEAT_CMDL_INFO
10694 static int save_ru = 0;
10695#endif
10696#ifdef FEAT_RIGHTLEFT
10697 static int save_ri = 0;
10698 static int save_hkmap = 0;
10699#endif
10700 buf_T *buf;
10701
10702 if (p_paste)
10703 {
10704 /*
10705 * Paste switched from off to on.
10706 * Save the current values, so they can be restored later.
10707 */
10708 if (!old_p_paste)
10709 {
10710 /* save options for each buffer */
10711 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10712 {
10713 buf->b_p_tw_nopaste = buf->b_p_tw;
10714 buf->b_p_wm_nopaste = buf->b_p_wm;
10715 buf->b_p_sts_nopaste = buf->b_p_sts;
10716 buf->b_p_ai_nopaste = buf->b_p_ai;
10717 }
10718
10719 /* save global options */
10720 save_sm = p_sm;
10721#ifdef FEAT_CMDL_INFO
10722 save_ru = p_ru;
10723#endif
10724#ifdef FEAT_RIGHTLEFT
10725 save_ri = p_ri;
10726 save_hkmap = p_hkmap;
10727#endif
10728 /* save global values for local buffer options */
10729 p_tw_nopaste = p_tw;
10730 p_wm_nopaste = p_wm;
10731 p_sts_nopaste = p_sts;
10732 p_ai_nopaste = p_ai;
10733 }
10734
10735 /*
10736 * Always set the option values, also when 'paste' is set when it is
10737 * already on.
10738 */
10739 /* set options for each buffer */
10740 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10741 {
10742 buf->b_p_tw = 0; /* textwidth is 0 */
10743 buf->b_p_wm = 0; /* wrapmargin is 0 */
10744 buf->b_p_sts = 0; /* softtabstop is 0 */
10745 buf->b_p_ai = 0; /* no auto-indent */
10746 }
10747
10748 /* set global options */
10749 p_sm = 0; /* no showmatch */
10750#ifdef FEAT_CMDL_INFO
10751# ifdef FEAT_WINDOWS
10752 if (p_ru)
10753 status_redraw_all(); /* redraw to remove the ruler */
10754# endif
10755 p_ru = 0; /* no ruler */
10756#endif
10757#ifdef FEAT_RIGHTLEFT
10758 p_ri = 0; /* no reverse insert */
10759 p_hkmap = 0; /* no Hebrew keyboard */
10760#endif
10761 /* set global values for local buffer options */
10762 p_tw = 0;
10763 p_wm = 0;
10764 p_sts = 0;
10765 p_ai = 0;
10766 }
10767
10768 /*
10769 * Paste switched from on to off: Restore saved values.
10770 */
10771 else if (old_p_paste)
10772 {
10773 /* restore options for each buffer */
10774 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10775 {
10776 buf->b_p_tw = buf->b_p_tw_nopaste;
10777 buf->b_p_wm = buf->b_p_wm_nopaste;
10778 buf->b_p_sts = buf->b_p_sts_nopaste;
10779 buf->b_p_ai = buf->b_p_ai_nopaste;
10780 }
10781
10782 /* restore global options */
10783 p_sm = save_sm;
10784#ifdef FEAT_CMDL_INFO
10785# ifdef FEAT_WINDOWS
10786 if (p_ru != save_ru)
10787 status_redraw_all(); /* redraw to draw the ruler */
10788# endif
10789 p_ru = save_ru;
10790#endif
10791#ifdef FEAT_RIGHTLEFT
10792 p_ri = save_ri;
10793 p_hkmap = save_hkmap;
10794#endif
10795 /* set global values for local buffer options */
10796 p_tw = p_tw_nopaste;
10797 p_wm = p_wm_nopaste;
10798 p_sts = p_sts_nopaste;
10799 p_ai = p_ai_nopaste;
10800 }
10801
10802 old_p_paste = p_paste;
10803}
10804
10805/*
10806 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
10807 *
10808 * Reset 'compatible' and set the values for options that didn't get set yet
10809 * to the Vim defaults.
10810 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000010811 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010812 */
10813 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000010814vimrc_found(fname, envname)
10815 char_u *fname;
10816 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010817{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000010818 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000010819 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000010820 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010821
10822 if (!option_was_set((char_u *)"cp"))
10823 {
10824 p_cp = FALSE;
10825 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
10826 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
10827 set_option_default(opt_idx, OPT_FREE, FALSE);
10828 didset_options();
10829 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000010830
10831 if (fname != NULL)
10832 {
10833 p = vim_getenv(envname, &dofree);
10834 if (p == NULL)
10835 {
10836 /* Set $MYVIMRC to the first vimrc file found. */
10837 p = FullName_save(fname, FALSE);
10838 if (p != NULL)
10839 {
10840 vim_setenv(envname, p);
10841 vim_free(p);
10842 }
10843 }
10844 else if (dofree)
10845 vim_free(p);
10846 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010847}
10848
10849/*
10850 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
10851 */
10852 void
10853change_compatible(on)
10854 int on;
10855{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010856 int opt_idx;
10857
Bram Moolenaar071d4272004-06-13 20:20:40 +000010858 if (p_cp != on)
10859 {
10860 p_cp = on;
10861 compatible_set();
10862 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010863 opt_idx = findoption((char_u *)"cp");
10864 if (opt_idx >= 0)
10865 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010866}
10867
10868/*
10869 * Return TRUE when option "name" has been set.
10870 */
10871 int
10872option_was_set(name)
10873 char_u *name;
10874{
10875 int idx;
10876
10877 idx = findoption(name);
10878 if (idx < 0) /* unknown option */
10879 return FALSE;
10880 if (options[idx].flags & P_WAS_SET)
10881 return TRUE;
10882 return FALSE;
10883}
10884
10885/*
10886 * compatible_set() - Called when 'compatible' has been set or unset.
10887 *
10888 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
10889 * flag) to a Vi compatible value.
10890 * When 'compatible' is unset: Set all options that have a different default
10891 * for Vim (without the P_VI_DEF flag) to that default.
10892 */
10893 static void
10894compatible_set()
10895{
10896 int opt_idx;
10897
10898 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
10899 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
10900 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
10901 set_option_default(opt_idx, OPT_FREE, p_cp);
10902 didset_options();
10903}
10904
10905#ifdef FEAT_LINEBREAK
10906
10907# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
10908 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000010909 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000010910# endif
10911
10912/*
10913 * fill_breakat_flags() -- called when 'breakat' changes value.
10914 */
10915 static void
10916fill_breakat_flags()
10917{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000010918 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010919 int i;
10920
10921 for (i = 0; i < 256; i++)
10922 breakat_flags[i] = FALSE;
10923
10924 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000010925 for (p = p_breakat; *p; p++)
10926 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010927}
10928
10929# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000010930 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000010931# endif
10932
10933#endif
10934
10935/*
10936 * Check an option that can be a range of string values.
10937 *
10938 * Return OK for correct value, FAIL otherwise.
10939 * Empty is always OK.
10940 */
10941 static int
10942check_opt_strings(val, values, list)
10943 char_u *val;
10944 char **values;
10945 int list; /* when TRUE: accept a list of values */
10946{
10947 return opt_strings_flags(val, values, NULL, list);
10948}
10949
10950/*
10951 * Handle an option that can be a range of string values.
10952 * Set a flag in "*flagp" for each string present.
10953 *
10954 * Return OK for correct value, FAIL otherwise.
10955 * Empty is always OK.
10956 */
10957 static int
10958opt_strings_flags(val, values, flagp, list)
10959 char_u *val; /* new value */
10960 char **values; /* array of valid string values */
10961 unsigned *flagp;
10962 int list; /* when TRUE: accept a list of values */
10963{
10964 int i;
10965 int len;
10966 unsigned new_flags = 0;
10967
10968 while (*val)
10969 {
10970 for (i = 0; ; ++i)
10971 {
10972 if (values[i] == NULL) /* val not found in values[] */
10973 return FAIL;
10974
10975 len = (int)STRLEN(values[i]);
10976 if (STRNCMP(values[i], val, len) == 0
10977 && ((list && val[len] == ',') || val[len] == NUL))
10978 {
10979 val += len + (val[len] == ',');
10980 new_flags |= (1 << i);
10981 break; /* check next item in val list */
10982 }
10983 }
10984 }
10985 if (flagp != NULL)
10986 *flagp = new_flags;
10987
10988 return OK;
10989}
10990
10991/*
10992 * Read the 'wildmode' option, fill wim_flags[].
10993 */
10994 static int
10995check_opt_wim()
10996{
10997 char_u new_wim_flags[4];
10998 char_u *p;
10999 int i;
11000 int idx = 0;
11001
11002 for (i = 0; i < 4; ++i)
11003 new_wim_flags[i] = 0;
11004
11005 for (p = p_wim; *p; ++p)
11006 {
11007 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11008 ;
11009 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11010 return FAIL;
11011 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11012 new_wim_flags[idx] |= WIM_LONGEST;
11013 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11014 new_wim_flags[idx] |= WIM_FULL;
11015 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11016 new_wim_flags[idx] |= WIM_LIST;
11017 else
11018 return FAIL;
11019 p += i;
11020 if (*p == NUL)
11021 break;
11022 if (*p == ',')
11023 {
11024 if (idx == 3)
11025 return FAIL;
11026 ++idx;
11027 }
11028 }
11029
11030 /* fill remaining entries with last flag */
11031 while (idx < 3)
11032 {
11033 new_wim_flags[idx + 1] = new_wim_flags[idx];
11034 ++idx;
11035 }
11036
11037 /* only when there are no errors, wim_flags[] is changed */
11038 for (i = 0; i < 4; ++i)
11039 wim_flags[i] = new_wim_flags[i];
11040 return OK;
11041}
11042
11043/*
11044 * Check if backspacing over something is allowed.
11045 */
11046 int
11047can_bs(what)
11048 int what; /* BS_INDENT, BS_EOL or BS_START */
11049{
11050 switch (*p_bs)
11051 {
11052 case '2': return TRUE;
11053 case '1': return (what != BS_START);
11054 case '0': return FALSE;
11055 }
11056 return vim_strchr(p_bs, what) != NULL;
11057}
11058
11059/*
11060 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11061 * the file must be considered changed when the value is different.
11062 */
11063 void
11064save_file_ff(buf)
11065 buf_T *buf;
11066{
11067 buf->b_start_ffc = *buf->b_p_ff;
11068 buf->b_start_eol = buf->b_p_eol;
11069#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011070 buf->b_start_bomb = buf->b_p_bomb;
11071
Bram Moolenaar071d4272004-06-13 20:20:40 +000011072 /* Only use free/alloc when necessary, they take time. */
11073 if (buf->b_start_fenc == NULL
11074 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11075 {
11076 vim_free(buf->b_start_fenc);
11077 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11078 }
11079#endif
11080}
11081
11082/*
11083 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11084 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011085 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11086 * changed and 'binary' is not set.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011087 * Don't consider a new, empty buffer to be changed.
11088 */
11089 int
11090file_ff_differs(buf)
11091 buf_T *buf;
11092{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000011093 /* In a buffer that was never loaded the options are not valid. */
11094 if (buf->b_flags & BF_NEVERLOADED)
11095 return FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011096 if ((buf->b_flags & BF_NEW)
11097 && buf->b_ml.ml_line_count == 1
11098 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
11099 return FALSE;
11100 if (buf->b_start_ffc != *buf->b_p_ff)
11101 return TRUE;
11102 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
11103 return TRUE;
11104#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011105 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
11106 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011107 if (buf->b_start_fenc == NULL)
11108 return (*buf->b_p_fenc != NUL);
11109 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
11110#else
11111 return FALSE;
11112#endif
11113}
11114
11115/*
11116 * return OK if "p" is a valid fileformat name, FAIL otherwise.
11117 */
11118 int
11119check_ff_value(p)
11120 char_u *p;
11121{
11122 return check_opt_strings(p, p_ff_values, FALSE);
11123}