blob: 7356816b6b512336bbd257a62ad78b7d4707d687 [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
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.
Bram Moolenaarcea912a2016-10-12 14:20:24 +020025 * - Add documentation! One line in doc/quickref.txt, full description in
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 * 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 Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000060#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000061# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062# define PV_BT OPT_BUF(BV_BT)
63# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000110#ifdef FEAT_EVAL
111# define PV_FEX OPT_BUF(BV_FEX)
112#endif
113#define PV_FF OPT_BUF(BV_FF)
114#define PV_FLP OPT_BUF(BV_FLP)
115#define PV_FO OPT_BUF(BV_FO)
116#ifdef FEAT_AUTOCMD
117# define PV_FT OPT_BUF(BV_FT)
118#endif
119#define PV_IMI OPT_BUF(BV_IMI)
120#define PV_IMS OPT_BUF(BV_IMS)
121#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
122# define PV_INDE OPT_BUF(BV_INDE)
123# define PV_INDK OPT_BUF(BV_INDK)
124#endif
125#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
126# define PV_INEX OPT_BUF(BV_INEX)
127#endif
128#define PV_INF OPT_BUF(BV_INF)
129#define PV_ISK OPT_BUF(BV_ISK)
130#ifdef FEAT_CRYPT
131# define PV_KEY OPT_BUF(BV_KEY)
132#endif
133#ifdef FEAT_KEYMAP
134# define PV_KMAP OPT_BUF(BV_KMAP)
135#endif
136#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
137#ifdef FEAT_LISP
138# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100139# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000140#endif
141#define PV_MA OPT_BUF(BV_MA)
142#define PV_ML OPT_BUF(BV_ML)
143#define PV_MOD OPT_BUF(BV_MOD)
144#define PV_MPS OPT_BUF(BV_MPS)
145#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000146#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
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100158#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000159#ifdef FEAT_SYN_HL
160# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000161# define PV_SYN OPT_BUF(BV_SYN)
162#endif
163#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000164# define PV_SPC OPT_BUF(BV_SPC)
165# define PV_SPF OPT_BUF(BV_SPF)
166# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000167#endif
168#define PV_STS OPT_BUF(BV_STS)
169#ifdef FEAT_SEARCHPATH
170# define PV_SUA OPT_BUF(BV_SUA)
171#endif
172#define PV_SW OPT_BUF(BV_SW)
173#define PV_SWF OPT_BUF(BV_SWF)
174#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100175#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000176#define PV_TS OPT_BUF(BV_TS)
177#define PV_TW OPT_BUF(BV_TW)
178#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200179#ifdef FEAT_PERSISTENT_UNDO
180# define PV_UDF OPT_BUF(BV_UDF)
181#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000182#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000183
184/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000185 * Definition of the PV_ values for window-local options.
186 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188#define PV_LIST OPT_WIN(WV_LIST)
189#ifdef FEAT_ARABIC
190# define PV_ARAB OPT_WIN(WV_ARAB)
191#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200192#ifdef FEAT_LINEBREAK
193# define PV_BRI OPT_WIN(WV_BRI)
194# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
195#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000196#ifdef FEAT_DIFF
197# define PV_DIFF OPT_WIN(WV_DIFF)
198#endif
199#ifdef FEAT_FOLDING
200# define PV_FDC OPT_WIN(WV_FDC)
201# define PV_FEN OPT_WIN(WV_FEN)
202# define PV_FDI OPT_WIN(WV_FDI)
203# define PV_FDL OPT_WIN(WV_FDL)
204# define PV_FDM OPT_WIN(WV_FDM)
205# define PV_FML OPT_WIN(WV_FML)
206# define PV_FDN OPT_WIN(WV_FDN)
207# ifdef FEAT_EVAL
208# define PV_FDE OPT_WIN(WV_FDE)
209# define PV_FDT OPT_WIN(WV_FDT)
210# endif
211# define PV_FMR OPT_WIN(WV_FMR)
212#endif
213#ifdef FEAT_LINEBREAK
214# define PV_LBR OPT_WIN(WV_LBR)
215#endif
216#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200217#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000218#ifdef FEAT_LINEBREAK
219# define PV_NUW OPT_WIN(WV_NUW)
220#endif
221#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
222# define PV_PVW OPT_WIN(WV_PVW)
223#endif
224#ifdef FEAT_RIGHTLEFT
225# define PV_RL OPT_WIN(WV_RL)
226# define PV_RLC OPT_WIN(WV_RLC)
227#endif
228#ifdef FEAT_SCROLLBIND
229# define PV_SCBIND OPT_WIN(WV_SCBIND)
230#endif
231#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000232#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000233# define PV_SPELL OPT_WIN(WV_SPELL)
234#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000235#ifdef FEAT_SYN_HL
236# define PV_CUC OPT_WIN(WV_CUC)
237# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200238# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000240#ifdef FEAT_STL_OPT
241# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
242#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100243#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_WINDOWS
245# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000246# define PV_WFW OPT_WIN(WV_WFW)
247#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200249#ifdef FEAT_CURSORBIND
250# define PV_CRBIND OPT_WIN(WV_CRBIND)
251#endif
252#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200253# define PV_COCU OPT_WIN(WV_COCU)
254# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200255#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200256#ifdef FEAT_SIGNS
257# define PV_SCL OPT_WIN(WV_SCL)
258#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000259
260/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261typedef enum
262{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000263 PV_NONE = 0,
264 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265} idopt_T;
266
267/*
268 * Options local to a window have a value local to a buffer and global to all
269 * buffers. Indicate this by setting "var" to VAR_WIN.
270 */
271#define VAR_WIN ((char_u *)-1)
272
273/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000274 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275 * Only to be used in option.c!
276 */
277static int p_ai;
278static int p_bin;
279#ifdef FEAT_MBYTE
280static int p_bomb;
281#endif
282#if defined(FEAT_QUICKFIX)
283static char_u *p_bh;
284static char_u *p_bt;
285#endif
286static int p_bl;
287static int p_ci;
288#ifdef FEAT_CINDENT
289static int p_cin;
290static char_u *p_cink;
291static char_u *p_cino;
292#endif
293#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
294static char_u *p_cinw;
295#endif
296#ifdef FEAT_COMMENTS
297static char_u *p_com;
298#endif
299#ifdef FEAT_FOLDING
300static char_u *p_cms;
301#endif
302#ifdef FEAT_INS_EXPAND
303static char_u *p_cpt;
304#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000305#ifdef FEAT_COMPL_FUNC
306static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000307static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200310static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311static int p_et;
312#ifdef FEAT_MBYTE
313static char_u *p_fenc;
314#endif
315static char_u *p_ff;
316static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000317static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318#ifdef FEAT_AUTOCMD
319static char_u *p_ft;
320#endif
321static long p_iminsert;
322static long p_imsearch;
323#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
324static char_u *p_inex;
325#endif
326#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
327static char_u *p_inde;
328static char_u *p_indk;
329#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000330#if defined(FEAT_EVAL)
331static char_u *p_fex;
332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333static int p_inf;
334static char_u *p_isk;
335#ifdef FEAT_CRYPT
336static char_u *p_key;
337#endif
338#ifdef FEAT_LISP
339static int p_lisp;
340#endif
341static int p_ml;
342static int p_ma;
343static int p_mod;
344static char_u *p_mps;
345static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000347#ifdef FEAT_TEXTOBJ
348static char_u *p_qe;
349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_ro;
351#ifdef FEAT_SMARTINDENT
352static int p_si;
353#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355static 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 */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200388static int p_ai_nopaste;
389static int p_et_nopaste;
390static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391static long p_tw_nopaste;
392static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393
394struct vimoption
395{
396 char *fullname; /* full option name */
397 char *shortname; /* permissible abbreviation */
398 long_u flags; /* see below */
399 char_u *var; /* global option: pointer to variable;
400 * window-local option: VAR_WIN;
401 * buffer-local option: global value */
402 idopt_T indir; /* global option: PV_NONE;
403 * local option: indirect option index */
404 char_u *def_val[2]; /* default values for variable (vi and vim) */
405#ifdef FEAT_EVAL
406 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000407# define SCRIPTID_INIT , 0
408#else
409# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000410#endif
411};
412
413#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
414#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
415
416/*
417 * Flags
418 */
419#define P_BOOL 0x01 /* the option is boolean */
420#define P_NUM 0x02 /* the option is numeric */
421#define P_STRING 0x04 /* the option is a string */
422#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000423 must use free_string_option() when
424 assigning new value. Not set if default is
425 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
427 never be used for local or hidden options! */
428#define P_NODEFAULT 0x40 /* don't set to default value */
429#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
430 use vim_free() when assigning new value */
431#define P_WAS_SET 0x100 /* option has been set/reset */
432#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
433#define P_VI_DEF 0x400 /* Use Vi default for Vim */
434#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
435
436 /* when option changed, what to display: */
437#define P_RSTAT 0x1000 /* redraw status lines */
438#define P_RWIN 0x2000 /* redraw current window */
439#define P_RBUF 0x4000 /* redraw current buffer */
440#define P_RALL 0x6000 /* redraw all windows */
441#define P_RCLR 0x7000 /* clear and redraw all */
442
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200443#define P_COMMA 0x8000 /* comma separated list */
444#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
445 * commas */
446#define P_NODUP 0x20000L /* don't allow duplicate strings */
447#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200449#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
450#define P_GETTEXT 0x100000L /* expand default value with _() */
451#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
452#define P_NFNAME 0x400000L /* only normal file name chars allowed */
453#define P_INSECURE 0x800000L /* option was set from a modeline */
454#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100455 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200456#define P_NO_ML 0x2000000L /* not allowed in modeline */
457#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200458 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100459#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000461#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
462
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000463/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
464 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100465#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000466# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000467#else
468# define ISP_LATIN1 (char_u *)"@,161-255"
469#endif
470
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100471/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000472#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100473 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200474 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar58b85342016-08-14 19:54:54 +0200475# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000476#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100477# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000478#endif
479
Bram Moolenaar071d4272004-06-13 20:20:40 +0000480/*
481 * options[] is initialized here.
482 * The order of the options MUST be alphabetic for ":set all" and findoption().
483 * All option names MUST start with a lowercase letter (for findoption()).
484 * Exception: "t_" options are at the end.
485 * The options with a NULL variable are 'hidden': a set command for them is
486 * ignored and they are not printed.
487 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100488static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000489{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200490 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000491#ifdef FEAT_RIGHTLEFT
492 (char_u *)&p_aleph, PV_NONE,
493#else
494 (char_u *)NULL, PV_NONE,
495#endif
496 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100497#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498 (char_u *)128L,
499#else
500 (char_u *)224L,
501#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000502 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
504#if defined(FEAT_GUI) && defined(MACOS_X)
505 (char_u *)&p_antialias, PV_NONE,
506 {(char_u *)FALSE, (char_u *)FALSE}
507#else
508 (char_u *)NULL, PV_NONE,
509 {(char_u *)FALSE, (char_u *)FALSE}
510#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000511 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200512 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513#ifdef FEAT_ARABIC
514 (char_u *)VAR_WIN, PV_ARAB,
515#else
516 (char_u *)NULL, PV_NONE,
517#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000518 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
520#ifdef FEAT_ARABIC
521 (char_u *)&p_arshape, PV_NONE,
522#else
523 (char_u *)NULL, PV_NONE,
524#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000525 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
527#ifdef FEAT_RIGHTLEFT
528 (char_u *)&p_ari, PV_NONE,
529#else
530 (char_u *)NULL, PV_NONE,
531#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000532 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
534#ifdef FEAT_FKMAP
535 (char_u *)&p_altkeymap, PV_NONE,
536#else
537 (char_u *)NULL, PV_NONE,
538#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
541#if defined(FEAT_MBYTE)
542 (char_u *)&p_ambw, PV_NONE,
543 {(char_u *)"single", (char_u *)0L}
544#else
545 (char_u *)NULL, PV_NONE,
546 {(char_u *)0L, (char_u *)0L}
547#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000548 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000549#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550 {"autochdir", "acd", P_BOOL|P_VI_DEF,
551 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553#endif
554 {"autoindent", "ai", P_BOOL|P_VI_DEF,
555 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 {"autoprint", "ap", P_BOOL|P_VI_DEF,
558 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000561 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000563 {"autowrite", "aw", P_BOOL|P_VI_DEF,
564 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000565 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566 {"autowriteall","awa", P_BOOL|P_VI_DEF,
567 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
570 (char_u *)&p_bg, PV_NONE,
571 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100572#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573 (char_u *)"dark",
574#else
575 (char_u *)"light",
576#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000577 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200578 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000580 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
582 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200584 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200585 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586#ifdef UNIX
587 {(char_u *)"yes", (char_u *)"auto"}
588#else
589 {(char_u *)"auto", (char_u *)"auto"}
590#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000591 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200592 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
593 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000595 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000596 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597 (char_u *)&p_bex, PV_NONE,
598 {
599#ifdef VMS
600 (char_u *)"_",
601#else
602 (char_u *)"~",
603#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000604 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200605 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606#ifdef FEAT_WILDIGN
607 (char_u *)&p_bsk, PV_NONE,
608 {(char_u *)"", (char_u *)0L}
609#else
610 (char_u *)NULL, PV_NONE,
611 {(char_u *)0L, (char_u *)0L}
612#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000613 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614#ifdef FEAT_BEVAL
615 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
616 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000617 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000618 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
619 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000620 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000621# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000622 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000623 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000624 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000625# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626#endif
627 {"beautify", "bf", P_BOOL|P_VI_DEF,
628 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200630 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
631 (char_u *)&p_bo, PV_NONE,
632 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000633 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
634 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000635 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000636 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000638 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000639 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
640#ifdef FEAT_MBYTE
641 (char_u *)&p_bomb, PV_BOMB,
642#else
643 (char_u *)NULL, PV_NONE,
644#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000645 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000646 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
647#ifdef FEAT_LINEBREAK
648 (char_u *)&p_breakat, PV_NONE,
649 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
650#else
651 (char_u *)NULL, PV_NONE,
652 {(char_u *)0L, (char_u *)0L}
653#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000654 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200655 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
656#ifdef FEAT_LINEBREAK
657 (char_u *)VAR_WIN, PV_BRI,
658 {(char_u *)FALSE, (char_u *)0L}
659#else
660 (char_u *)NULL, PV_NONE,
661 {(char_u *)0L, (char_u *)0L}
662#endif
663 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200664 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
665 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200666#ifdef FEAT_LINEBREAK
667 (char_u *)VAR_WIN, PV_BRIOPT,
668 {(char_u *)"", (char_u *)NULL}
669#else
670 (char_u *)NULL, PV_NONE,
671 {(char_u *)"", (char_u *)NULL}
672#endif
673 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000674 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
675#ifdef FEAT_BROWSE
676 (char_u *)&p_bsdir, PV_NONE,
677 {(char_u *)"last", (char_u *)0L}
678#else
679 (char_u *)NULL, PV_NONE,
680 {(char_u *)0L, (char_u *)0L}
681#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000682 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000683 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
684#if defined(FEAT_QUICKFIX)
685 (char_u *)&p_bh, PV_BH,
686 {(char_u *)"", (char_u *)0L}
687#else
688 (char_u *)NULL, PV_NONE,
689 {(char_u *)0L, (char_u *)0L}
690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000691 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000692 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
693 (char_u *)&p_bl, PV_BL,
694 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000695 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000696 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
697#if defined(FEAT_QUICKFIX)
698 (char_u *)&p_bt, PV_BT,
699 {(char_u *)"", (char_u *)0L}
700#else
701 (char_u *)NULL, PV_NONE,
702 {(char_u *)0L, (char_u *)0L}
703#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000704 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200705 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000706#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000707 (char_u *)&p_cmp, PV_NONE,
708 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000709#else
710 (char_u *)NULL, PV_NONE,
711 {(char_u *)0L, (char_u *)0L}
712#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000713 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000714 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
715#ifdef FEAT_SEARCHPATH
716 (char_u *)&p_cdpath, PV_NONE,
717 {(char_u *)",,", (char_u *)0L}
718#else
719 (char_u *)NULL, PV_NONE,
720 {(char_u *)0L, (char_u *)0L}
721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000722 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723 {"cedit", NULL, P_STRING,
724#ifdef FEAT_CMDWIN
725 (char_u *)&p_cedit, PV_NONE,
726 {(char_u *)"", (char_u *)CTRL_F_STR}
727#else
728 (char_u *)NULL, PV_NONE,
729 {(char_u *)0L, (char_u *)0L}
730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000731 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000732 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
733#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
734 (char_u *)&p_ccv, PV_NONE,
735 {(char_u *)"", (char_u *)0L}
736#else
737 (char_u *)NULL, PV_NONE,
738 {(char_u *)0L, (char_u *)0L}
739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000740 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
742#ifdef FEAT_CINDENT
743 (char_u *)&p_cin, PV_CIN,
744#else
745 (char_u *)NULL, PV_NONE,
746#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000747 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200748 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000749#ifdef FEAT_CINDENT
750 (char_u *)&p_cink, PV_CINK,
751 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
752#else
753 (char_u *)NULL, PV_NONE,
754 {(char_u *)0L, (char_u *)0L}
755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000756 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200757 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758#ifdef FEAT_CINDENT
759 (char_u *)&p_cino, PV_CINO,
760#else
761 (char_u *)NULL, PV_NONE,
762#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000763 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200764 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000765#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
766 (char_u *)&p_cinw, PV_CINW,
767 {(char_u *)"if,else,while,do,for,switch",
768 (char_u *)0L}
769#else
770 (char_u *)NULL, PV_NONE,
771 {(char_u *)0L, (char_u *)0L}
772#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000773 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200774 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775#ifdef FEAT_CLIPBOARD
776 (char_u *)&p_cb, PV_NONE,
777# ifdef FEAT_XCLIPBOARD
778 {(char_u *)"autoselect,exclude:cons\\|linux",
779 (char_u *)0L}
780# else
781 {(char_u *)"", (char_u *)0L}
782# endif
783#else
784 (char_u *)NULL, PV_NONE,
785 {(char_u *)"", (char_u *)0L}
786#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000787 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000788 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
789 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000790 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000791 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
792#ifdef FEAT_CMDWIN
793 (char_u *)&p_cwh, PV_NONE,
794#else
795 (char_u *)NULL, PV_NONE,
796#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000797 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200798 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200799#ifdef FEAT_SYN_HL
800 (char_u *)VAR_WIN, PV_CC,
801#else
802 (char_u *)NULL, PV_NONE,
803#endif
804 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000805 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
806 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000807 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200808 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
809 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000810#ifdef FEAT_COMMENTS
811 (char_u *)&p_com, PV_COM,
812 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
813 (char_u *)0L}
814#else
815 (char_u *)NULL, PV_NONE,
816 {(char_u *)0L, (char_u *)0L}
817#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000818 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200819 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000820#ifdef FEAT_FOLDING
821 (char_u *)&p_cms, PV_CMS,
822 {(char_u *)"/*%s*/", (char_u *)0L}
823#else
824 (char_u *)NULL, PV_NONE,
825 {(char_u *)0L, (char_u *)0L}
826#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000827 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000828 /* P_PRI_MKRC isn't needed here, optval_default()
829 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000830 {"compatible", "cp", P_BOOL|P_RALL,
831 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000832 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200833 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000834#ifdef FEAT_INS_EXPAND
835 (char_u *)&p_cpt, PV_CPT,
836 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
837#else
838 (char_u *)NULL, PV_NONE,
839 {(char_u *)0L, (char_u *)0L}
840#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200842 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200843#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200844 (char_u *)VAR_WIN, PV_COCU,
845 {(char_u *)"", (char_u *)NULL}
846#else
847 (char_u *)NULL, PV_NONE,
848 {(char_u *)NULL, (char_u *)0L}
849#endif
850 SCRIPTID_INIT},
851 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
852#ifdef FEAT_CONCEAL
853 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200854#else
855 (char_u *)NULL, PV_NONE,
856#endif
857 {(char_u *)0L, (char_u *)0L}
858 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000859 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
860#ifdef FEAT_COMPL_FUNC
861 (char_u *)&p_cfu, PV_CFU,
862 {(char_u *)"", (char_u *)0L}
863#else
864 (char_u *)NULL, PV_NONE,
865 {(char_u *)0L, (char_u *)0L}
866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000867 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200868 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000869#ifdef FEAT_INS_EXPAND
870 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000871 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000872#else
873 (char_u *)NULL, PV_NONE,
874 {(char_u *)0L, (char_u *)0L}
875#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000876 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000877 {"confirm", "cf", P_BOOL|P_VI_DEF,
878#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
879 (char_u *)&p_confirm, PV_NONE,
880#else
881 (char_u *)NULL, PV_NONE,
882#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000883 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000884 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000885 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000886 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000887 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
888 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000889 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000890 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
891 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000892 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
893 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200894 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200895#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200896 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200897 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200898#else
899 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200900 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200901#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200902 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000903 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
904#ifdef FEAT_CSCOPE
905 (char_u *)&p_cspc, PV_NONE,
906#else
907 (char_u *)NULL, PV_NONE,
908#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000909 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000910 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
911#ifdef FEAT_CSCOPE
912 (char_u *)&p_csprg, PV_NONE,
913 {(char_u *)"cscope", (char_u *)0L}
914#else
915 (char_u *)NULL, PV_NONE,
916 {(char_u *)0L, (char_u *)0L}
917#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000918 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200919 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
921 (char_u *)&p_csqf, PV_NONE,
922 {(char_u *)"", (char_u *)0L}
923#else
924 (char_u *)NULL, PV_NONE,
925 {(char_u *)0L, (char_u *)0L}
926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000927 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200928 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
929#ifdef FEAT_CSCOPE
930 (char_u *)&p_csre, PV_NONE,
931#else
932 (char_u *)NULL, PV_NONE,
933#endif
934 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000935 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
936#ifdef FEAT_CSCOPE
937 (char_u *)&p_cst, PV_NONE,
938#else
939 (char_u *)NULL, PV_NONE,
940#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000941 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000942 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
943#ifdef FEAT_CSCOPE
944 (char_u *)&p_csto, PV_NONE,
945#else
946 (char_u *)NULL, PV_NONE,
947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000948 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000949 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
950#ifdef FEAT_CSCOPE
951 (char_u *)&p_csverbose, PV_NONE,
952#else
953 (char_u *)NULL, PV_NONE,
954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000955 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200956 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
957#ifdef FEAT_CURSORBIND
958 (char_u *)VAR_WIN, PV_CRBIND,
959#else
960 (char_u *)NULL, PV_NONE,
961#endif
962 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000963 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
964#ifdef FEAT_SYN_HL
965 (char_u *)VAR_WIN, PV_CUC,
966#else
967 (char_u *)NULL, PV_NONE,
968#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000969 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000970 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
971#ifdef FEAT_SYN_HL
972 (char_u *)VAR_WIN, PV_CUL,
973#else
974 (char_u *)NULL, PV_NONE,
975#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000976 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 {"debug", NULL, P_STRING|P_VI_DEF,
978 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000979 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200980 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000981#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000982 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000983 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000984#else
985 (char_u *)NULL, PV_NONE,
986 {(char_u *)NULL, (char_u *)0L}
987#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000988 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000989 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
990#ifdef FEAT_MBYTE
991 (char_u *)&p_deco, PV_NONE,
992#else
993 (char_u *)NULL, PV_NONE,
994#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000995 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +0100996 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000998 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000999#else
1000 (char_u *)NULL, PV_NONE,
1001#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001002 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001003 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1004#ifdef FEAT_DIFF
1005 (char_u *)VAR_WIN, PV_DIFF,
1006#else
1007 (char_u *)NULL, PV_NONE,
1008#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001009 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001010 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001011#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1012 (char_u *)&p_dex, PV_NONE,
1013 {(char_u *)"", (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 Moolenaar0e7c4b92015-06-20 15:30:03 +02001019 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1020 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001021#ifdef FEAT_DIFF
1022 (char_u *)&p_dip, PV_NONE,
1023 {(char_u *)"filler", (char_u *)NULL}
1024#else
1025 (char_u *)NULL, PV_NONE,
1026 {(char_u *)"", (char_u *)NULL}
1027#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001028 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001029 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1030#ifdef FEAT_DIGRAPHS
1031 (char_u *)&p_dg, PV_NONE,
1032#else
1033 (char_u *)NULL, PV_NONE,
1034#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001035 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001036 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1037 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001039 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001040 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001042 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001044#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 (char_u *)&p_ead, PV_NONE,
1046 {(char_u *)"both", (char_u *)0L}
1047#else
1048 (char_u *)NULL, PV_NONE,
1049 {(char_u *)NULL, (char_u *)0L}
1050#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001051 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1053 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001054 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001055 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1056#if defined(FEAT_MBYTE)
1057 (char_u *)&p_emoji, PV_NONE,
1058 {(char_u *)TRUE, (char_u *)0L}
1059#else
1060 (char_u *)NULL, PV_NONE,
1061 {(char_u *)0L, (char_u *)0L}
1062#endif
1063 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001064 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065#ifdef FEAT_MBYTE
1066 (char_u *)&p_enc, PV_NONE,
1067 {(char_u *)ENC_DFLT, (char_u *)0L}
1068#else
1069 (char_u *)NULL, PV_NONE,
1070 {(char_u *)0L, (char_u *)0L}
1071#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001072 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1074 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001075 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1077 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001078 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001080 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001081 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001082 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1083 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001084 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1086#ifdef FEAT_QUICKFIX
1087 (char_u *)&p_ef, PV_NONE,
1088 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1089#else
1090 (char_u *)NULL, PV_NONE,
1091 {(char_u *)NULL, (char_u *)0L}
1092#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001093 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001094 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001096 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001097 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098#else
1099 (char_u *)NULL, PV_NONE,
1100 {(char_u *)NULL, (char_u *)0L}
1101#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001102 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 {"esckeys", "ek", P_BOOL|P_VIM,
1104 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001105 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001106 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107#ifdef FEAT_AUTOCMD
1108 (char_u *)&p_ei, PV_NONE,
1109#else
1110 (char_u *)NULL, PV_NONE,
1111#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001112 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1114 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001115 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1117 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001118 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001119 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1120 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121#ifdef FEAT_MBYTE
1122 (char_u *)&p_fenc, PV_FENC,
1123 {(char_u *)"", (char_u *)0L}
1124#else
1125 (char_u *)NULL, PV_NONE,
1126 {(char_u *)0L, (char_u *)0L}
1127#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001128 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001129 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130#ifdef FEAT_MBYTE
1131 (char_u *)&p_fencs, PV_NONE,
1132 {(char_u *)"ucs-bom", (char_u *)0L}
1133#else
1134 (char_u *)NULL, PV_NONE,
1135 {(char_u *)0L, (char_u *)0L}
1136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001137 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001138 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1139 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001140 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001141 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001142 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001144 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1145 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001146 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1147 (char_u *)&p_fic, PV_NONE,
1148 {
1149#ifdef CASE_INSENSITIVE_FILENAME
1150 (char_u *)TRUE,
1151#else
1152 (char_u *)FALSE,
1153#endif
1154 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001155 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156#ifdef FEAT_AUTOCMD
1157 (char_u *)&p_ft, PV_FT,
1158 {(char_u *)"", (char_u *)0L}
1159#else
1160 (char_u *)NULL, PV_NONE,
1161 {(char_u *)0L, (char_u *)0L}
1162#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001163 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001164 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1166 (char_u *)&p_fcs, PV_NONE,
1167 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1168#else
1169 (char_u *)NULL, PV_NONE,
1170 {(char_u *)"", (char_u *)0L}
1171#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001173 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1174 (char_u *)&p_fixeol, PV_FIXEOL,
1175 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1177#ifdef FEAT_FKMAP
1178 (char_u *)&p_fkmap, PV_NONE,
1179#else
1180 (char_u *)NULL, PV_NONE,
1181#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001182 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001183 {"flash", "fl", P_BOOL|P_VI_DEF,
1184 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001185 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001186#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001187 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001188 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001189 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1191 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001192 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1194 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001195 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001196 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1197# ifdef FEAT_EVAL
1198 (char_u *)VAR_WIN, PV_FDE,
1199 {(char_u *)"0", (char_u *)NULL}
1200# else
1201 (char_u *)NULL, PV_NONE,
1202 {(char_u *)NULL, (char_u *)0L}
1203# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001204 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001205 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1206 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001207 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1209 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001210 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001211 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001213 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001214 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001215 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001217 {(char_u *)"{{{,}}}", (char_u *)NULL}
1218 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001219 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1220 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001221 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1223 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001224 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001225 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1226 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001227 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001228 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001229 (char_u *)&p_fdo, PV_NONE,
1230 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001231 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001232 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1233# ifdef FEAT_EVAL
1234 (char_u *)VAR_WIN, PV_FDT,
1235 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001236# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237 (char_u *)NULL, PV_NONE,
1238 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001239# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001240 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001241#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001242 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001243#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001244 (char_u *)&p_fex, PV_FEX,
1245 {(char_u *)"", (char_u *)0L}
1246#else
1247 (char_u *)NULL, PV_NONE,
1248 {(char_u *)0L, (char_u *)0L}
1249#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001250 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1252 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001253 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1254 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001255 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1256 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001257 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1258 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1260 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001261 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001262 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1263#ifdef HAVE_FSYNC
1264 (char_u *)&p_fs, PV_NONE,
1265 {(char_u *)TRUE, (char_u *)0L}
1266#else
1267 (char_u *)NULL, PV_NONE,
1268 {(char_u *)FALSE, (char_u *)0L}
1269#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001270 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1272 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001273 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 {"graphic", "gr", P_BOOL|P_VI_DEF,
1275 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001276 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001277 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278#ifdef FEAT_QUICKFIX
1279 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001280 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281#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 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1287#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001288 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001289 {
1290# ifdef WIN3264
1291 /* may be changed to "grep -n" in os_win32.c */
1292 (char_u *)"findstr /n",
1293# else
1294# ifdef UNIX
1295 /* Add an extra file name so that grep will always
1296 * insert a file name in the match line. */
1297 (char_u *)"grep -n $* /dev/null",
1298# else
1299# ifdef VMS
1300 (char_u *)"SEARCH/NUMBERS ",
1301# else
1302 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001303# endif
1304# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001305# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001306 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001307#else
1308 (char_u *)NULL, PV_NONE,
1309 {(char_u *)NULL, (char_u *)0L}
1310#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001311 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001312 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001313#ifdef CURSOR_SHAPE
1314 (char_u *)&p_guicursor, PV_NONE,
1315 {
1316# ifdef FEAT_GUI
1317 (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",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001318# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001319 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1320# endif
1321 (char_u *)0L}
1322#else
1323 (char_u *)NULL, PV_NONE,
1324 {(char_u *)NULL, (char_u *)0L}
1325#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001326 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001327 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001328#ifdef FEAT_GUI
1329 (char_u *)&p_guifont, PV_NONE,
1330 {(char_u *)"", (char_u *)0L}
1331#else
1332 (char_u *)NULL, PV_NONE,
1333 {(char_u *)NULL, (char_u *)0L}
1334#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001335 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001336 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1338 (char_u *)&p_guifontset, PV_NONE,
1339 {(char_u *)"", (char_u *)0L}
1340#else
1341 (char_u *)NULL, PV_NONE,
1342 {(char_u *)NULL, (char_u *)0L}
1343#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001344 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001345 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001346#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1347 (char_u *)&p_guifontwide, PV_NONE,
1348 {(char_u *)"", (char_u *)0L}
1349#else
1350 (char_u *)NULL, PV_NONE,
1351 {(char_u *)NULL, (char_u *)0L}
1352#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001353 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001355#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001356 (char_u *)&p_ghr, PV_NONE,
1357#else
1358 (char_u *)NULL, PV_NONE,
1359#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001360 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001362#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001363 (char_u *)&p_go, PV_NONE,
1364# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001365 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001366# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001367 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368# endif
1369#else
1370 (char_u *)NULL, PV_NONE,
1371 {(char_u *)NULL, (char_u *)0L}
1372#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001373 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001374 {"guipty", NULL, P_BOOL|P_VI_DEF,
1375#if defined(FEAT_GUI)
1376 (char_u *)&p_guipty, PV_NONE,
1377#else
1378 (char_u *)NULL, PV_NONE,
1379#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001380 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001381 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001382#if defined(FEAT_GUI_TABLINE)
1383 (char_u *)&p_gtl, PV_NONE,
1384 {(char_u *)"", (char_u *)0L}
1385#else
1386 (char_u *)NULL, PV_NONE,
1387 {(char_u *)NULL, (char_u *)0L}
1388#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001389 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001390 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001391#if defined(FEAT_GUI_TABLINE)
1392 (char_u *)&p_gtt, PV_NONE,
1393 {(char_u *)"", (char_u *)0L}
1394#else
1395 (char_u *)NULL, PV_NONE,
1396 {(char_u *)NULL, (char_u *)0L}
1397#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001398 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1400 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001401 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1403 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001404 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1405 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406 {"helpheight", "hh", P_NUM|P_VI_DEF,
1407#ifdef FEAT_WINDOWS
1408 (char_u *)&p_hh, PV_NONE,
1409#else
1410 (char_u *)NULL, PV_NONE,
1411#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001412 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001413 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001414#ifdef FEAT_MULTI_LANG
1415 (char_u *)&p_hlg, PV_NONE,
1416 {(char_u *)"", (char_u *)0L}
1417#else
1418 (char_u *)NULL, PV_NONE,
1419 {(char_u *)0L, (char_u *)0L}
1420#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001421 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001422 {"hidden", "hid", P_BOOL|P_VI_DEF,
1423 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001424 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001425 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001427 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1428 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001429 {"history", "hi", P_NUM|P_VIM,
1430 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001431 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001432 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1433#ifdef FEAT_RIGHTLEFT
1434 (char_u *)&p_hkmap, PV_NONE,
1435#else
1436 (char_u *)NULL, PV_NONE,
1437#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001438 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001439 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1440#ifdef FEAT_RIGHTLEFT
1441 (char_u *)&p_hkmapp, PV_NONE,
1442#else
1443 (char_u *)NULL, PV_NONE,
1444#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001445 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001446 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1447 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001449 {"icon", NULL, P_BOOL|P_VI_DEF,
1450#ifdef FEAT_TITLE
1451 (char_u *)&p_icon, PV_NONE,
1452#else
1453 (char_u *)NULL, PV_NONE,
1454#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001455 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001456 {"iconstring", NULL, P_STRING|P_VI_DEF,
1457#ifdef FEAT_TITLE
1458 (char_u *)&p_iconstring, PV_NONE,
1459#else
1460 (char_u *)NULL, PV_NONE,
1461#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001462 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001463 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1464 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001465 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001466 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1467# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1468 (char_u *)&p_imaf, PV_NONE,
1469 {(char_u *)"", (char_u *)NULL}
1470# else
1471 (char_u *)NULL, PV_NONE,
1472 {(char_u *)NULL, (char_u *)0L}
1473# endif
1474 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001475 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001476#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001477 (char_u *)&p_imak, PV_NONE,
1478#else
1479 (char_u *)NULL, PV_NONE,
1480#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001481 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001482 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1483#ifdef USE_IM_CONTROL
1484 (char_u *)&p_imcmdline, PV_NONE,
1485#else
1486 (char_u *)NULL, PV_NONE,
1487#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001488 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001489 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1490#ifdef USE_IM_CONTROL
1491 (char_u *)&p_imdisable, PV_NONE,
1492#else
1493 (char_u *)NULL, PV_NONE,
1494#endif
1495#ifdef __sgi
1496 {(char_u *)TRUE, (char_u *)0L}
1497#else
1498 {(char_u *)FALSE, (char_u *)0L}
1499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001500 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001501 {"iminsert", "imi", P_NUM|P_VI_DEF,
1502 (char_u *)&p_iminsert, PV_IMI,
1503#ifdef B_IMODE_IM
1504 {(char_u *)B_IMODE_IM, (char_u *)0L}
1505#else
1506 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1507#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001508 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001509 {"imsearch", "ims", P_NUM|P_VI_DEF,
1510 (char_u *)&p_imsearch, PV_IMS,
1511#ifdef B_IMODE_IM
1512 {(char_u *)B_IMODE_IM, (char_u *)0L}
1513#else
1514 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1515#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001516 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001517 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001518# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1519 (char_u *)&p_imsf, PV_NONE,
1520 {(char_u *)"", (char_u *)NULL}
1521# else
1522 (char_u *)NULL, PV_NONE,
1523 {(char_u *)NULL, (char_u *)0L}
1524# endif
1525 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001526 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1527#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001528 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001529 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1530#else
1531 (char_u *)NULL, PV_NONE,
1532 {(char_u *)0L, (char_u *)0L}
1533#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001534 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001535 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1536#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1537 (char_u *)&p_inex, PV_INEX,
1538 {(char_u *)"", (char_u *)0L}
1539#else
1540 (char_u *)NULL, PV_NONE,
1541 {(char_u *)0L, (char_u *)0L}
1542#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001543 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001544 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1545 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001547 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1548#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1549 (char_u *)&p_inde, PV_INDE,
1550 {(char_u *)"", (char_u *)0L}
1551#else
1552 (char_u *)NULL, PV_NONE,
1553 {(char_u *)0L, (char_u *)0L}
1554#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001555 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001556 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001557#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1558 (char_u *)&p_indk, PV_INDK,
1559 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1560#else
1561 (char_u *)NULL, PV_NONE,
1562 {(char_u *)0L, (char_u *)0L}
1563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001564 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001565 {"infercase", "inf", P_BOOL|P_VI_DEF,
1566 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001568 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1569 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001571 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1572 (char_u *)&p_isf, PV_NONE,
1573 {
1574#ifdef BACKSLASH_IN_FILENAME
1575 /* Excluded are: & and ^ are special in cmd.exe
1576 * ( and ) are used in text separating fnames */
1577 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1578#else
1579# ifdef AMIGA
1580 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1581# else
1582# ifdef VMS
1583 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1584# else /* UNIX et al. */
1585# ifdef EBCDIC
1586 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1587# else
1588 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1589# endif
1590# endif
1591# endif
1592#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001593 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001594 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1595 (char_u *)&p_isi, PV_NONE,
1596 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001597#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 (char_u *)"@,48-57,_,128-167,224-235",
1599#else
1600# ifdef EBCDIC
1601 /* TODO: EBCDIC Check this! @ == isalpha()*/
1602 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1603 "112-120,128,140-142,156,158,172,"
1604 "174,186,191,203-207,219-225,235-239,"
1605 "251-254",
1606# else
1607 (char_u *)"@,48-57,_,192-255",
1608# endif
1609#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001610 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001611 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1612 (char_u *)&p_isk, PV_ISK,
1613 {
1614#ifdef EBCDIC
1615 (char_u *)"@,240-249,_",
1616 /* TODO: EBCDIC Check this! @ == isalpha()*/
1617 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1618 "112-120,128,140-142,156,158,172,"
1619 "174,186,191,203-207,219-225,235-239,"
1620 "251-254",
1621#else
1622 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001623# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001624 (char_u *)"@,48-57,_,128-167,224-235"
1625# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001626 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001627# endif
1628#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001629 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001630 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1631 (char_u *)&p_isp, PV_NONE,
1632 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001633#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001634 || defined(VMS)
1635 (char_u *)"@,~-255",
1636#else
1637# ifdef EBCDIC
1638 /* all chars above 63 are printable */
1639 (char_u *)"63-255",
1640# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001641 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001642# endif
1643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001644 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001645 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1646 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001647 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001648 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1649#ifdef FEAT_CRYPT
1650 (char_u *)&p_key, PV_KEY,
1651 {(char_u *)"", (char_u *)0L}
1652#else
1653 (char_u *)NULL, PV_NONE,
1654 {(char_u *)0L, (char_u *)0L}
1655#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001656 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001657 {"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 +00001658#ifdef FEAT_KEYMAP
1659 (char_u *)&p_keymap, PV_KMAP,
1660 {(char_u *)"", (char_u *)0L}
1661#else
1662 (char_u *)NULL, PV_NONE,
1663 {(char_u *)"", (char_u *)0L}
1664#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001665 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001666 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001667 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001668 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001670 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001671 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001672#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673 (char_u *)":help",
1674#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001675# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001676 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001677# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001678# ifdef USEMAN_S
1679 (char_u *)"man -s",
1680# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001681 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001682# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001683# endif
1684#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001685 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001686 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001687#ifdef FEAT_LANGMAP
1688 (char_u *)&p_langmap, PV_NONE,
1689 {(char_u *)"", /* unmatched } */
1690#else
1691 (char_u *)NULL, PV_NONE,
1692 {(char_u *)NULL,
1693#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001694 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001695 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1697 (char_u *)&p_lm, PV_NONE,
1698#else
1699 (char_u *)NULL, PV_NONE,
1700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001701 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001702 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1703#ifdef FEAT_LANGMAP
1704 (char_u *)&p_lnr, PV_NONE,
1705#else
1706 (char_u *)NULL, PV_NONE,
1707#endif
1708 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001709 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1710#ifdef FEAT_LANGMAP
1711 (char_u *)&p_lrm, PV_NONE,
1712#else
1713 (char_u *)NULL, PV_NONE,
1714#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001715 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001716 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1717#ifdef FEAT_WINDOWS
1718 (char_u *)&p_ls, PV_NONE,
1719#else
1720 (char_u *)NULL, PV_NONE,
1721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001722 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001723 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1724 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001725 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001726 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1727#ifdef FEAT_LINEBREAK
1728 (char_u *)VAR_WIN, PV_LBR,
1729#else
1730 (char_u *)NULL, PV_NONE,
1731#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001732 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1734 (char_u *)&Rows, PV_NONE,
1735 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001736#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001737 (char_u *)25L,
1738#else
1739 (char_u *)24L,
1740#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001741 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1743#ifdef FEAT_GUI
1744 (char_u *)&p_linespace, PV_NONE,
1745#else
1746 (char_u *)NULL, PV_NONE,
1747#endif
1748#ifdef FEAT_GUI_W32
1749 {(char_u *)1L, (char_u *)0L}
1750#else
1751 {(char_u *)0L, (char_u *)0L}
1752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001753 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001754 {"lisp", NULL, P_BOOL|P_VI_DEF,
1755#ifdef FEAT_LISP
1756 (char_u *)&p_lisp, PV_LISP,
1757#else
1758 (char_u *)NULL, PV_NONE,
1759#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001760 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001761 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001762#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001763 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1765#else
1766 (char_u *)NULL, PV_NONE,
1767 {(char_u *)"", (char_u *)0L}
1768#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001769 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1771 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001772 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001773 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001775 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1777 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001778 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001779#if defined(DYNAMIC_LUA)
Bram Moolenaara6e42502016-04-20 16:19:52 +02001780 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01001781 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001782 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
1783 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01001784#endif
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001785#ifdef FEAT_GUI_MAC
1786 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1787 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001788 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001789#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790 {"magic", NULL, P_BOOL|P_VI_DEF,
1791 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001793 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001794#ifdef FEAT_QUICKFIX
1795 (char_u *)&p_mef, PV_NONE,
1796 {(char_u *)"", (char_u *)0L}
1797#else
1798 (char_u *)NULL, PV_NONE,
1799 {(char_u *)NULL, (char_u *)0L}
1800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001801 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1803#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001804 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805# ifdef VMS
1806 {(char_u *)"MMS", (char_u *)0L}
1807# else
1808 {(char_u *)"make", (char_u *)0L}
1809# endif
1810#else
1811 (char_u *)NULL, PV_NONE,
1812 {(char_u *)NULL, (char_u *)0L}
1813#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001814 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001815 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001816 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001817 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1818 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 {"matchtime", "mat", P_NUM|P_VI_DEF,
1820 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001821 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001822 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001823#ifdef FEAT_MBYTE
1824 (char_u *)&p_mco, PV_NONE,
1825#else
1826 (char_u *)NULL, PV_NONE,
1827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001828 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1830#ifdef FEAT_EVAL
1831 (char_u *)&p_mfd, PV_NONE,
1832#else
1833 (char_u *)NULL, PV_NONE,
1834#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001835 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001836 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1837 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001838 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 {"maxmem", "mm", P_NUM|P_VI_DEF,
1840 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1842 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001843 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1844 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001845 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1847 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001848 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1849 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 {"menuitems", "mis", P_NUM|P_VI_DEF,
1851#ifdef FEAT_MENU
1852 (char_u *)&p_mis, PV_NONE,
1853#else
1854 (char_u *)NULL, PV_NONE,
1855#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001856 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 {"mesg", NULL, P_BOOL|P_VI_DEF,
1858 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001859 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001860 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001861#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001862 (char_u *)&p_msm, PV_NONE,
1863 {(char_u *)"460000,2000,500", (char_u *)0L}
1864#else
1865 (char_u *)NULL, PV_NONE,
1866 {(char_u *)0L, (char_u *)0L}
1867#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001868 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001869 {"modeline", "ml", P_BOOL|P_VIM,
1870 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001871 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 {"modelines", "mls", P_NUM|P_VI_DEF,
1873 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001874 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001875 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1876 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001877 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1879 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001880 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 {"more", NULL, P_BOOL|P_VIM,
1882 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001883 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001884 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1885 (char_u *)&p_mouse, PV_NONE,
1886 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001887#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001888 (char_u *)"a",
1889#else
1890 (char_u *)"",
1891#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001892 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1894#ifdef FEAT_GUI
1895 (char_u *)&p_mousef, PV_NONE,
1896#else
1897 (char_u *)NULL, PV_NONE,
1898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1901#ifdef FEAT_GUI
1902 (char_u *)&p_mh, PV_NONE,
1903#else
1904 (char_u *)NULL, PV_NONE,
1905#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001906 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1908 (char_u *)&p_mousem, PV_NONE,
1909 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001910#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 (char_u *)"popup",
1912#else
1913# if defined(MACOS)
1914 (char_u *)"popup_setpos",
1915# else
1916 (char_u *)"extend",
1917# endif
1918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001919 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001920 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921#ifdef FEAT_MOUSESHAPE
1922 (char_u *)&p_mouseshape, PV_NONE,
1923 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1924#else
1925 (char_u *)NULL, PV_NONE,
1926 {(char_u *)NULL, (char_u *)0L}
1927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001928 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1930 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001932 {"mzquantum", "mzq", P_NUM,
1933#ifdef FEAT_MZSCHEME
1934 (char_u *)&p_mzq, PV_NONE,
1935#else
1936 (char_u *)NULL, PV_NONE,
1937#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001938 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 {"novice", NULL, P_BOOL|P_VI_DEF,
1940 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001941 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001942 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01001944 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1947 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001949 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1950#ifdef FEAT_LINEBREAK
1951 (char_u *)VAR_WIN, PV_NUW,
1952#else
1953 (char_u *)NULL, PV_NONE,
1954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001956 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001957#ifdef FEAT_COMPL_FUNC
1958 (char_u *)&p_ofu, PV_OFU,
1959 {(char_u *)"", (char_u *)0L}
1960#else
1961 (char_u *)NULL, PV_NONE,
1962 {(char_u *)0L, (char_u *)0L}
1963#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001964 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001965 {"open", NULL, P_BOOL|P_VI_DEF,
1966 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001967 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001968 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001969#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00001970 (char_u *)&p_odev, PV_NONE,
1971#else
1972 (char_u *)NULL, PV_NONE,
1973#endif
1974 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001975 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001976 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1977 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001978 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 {"optimize", "opt", P_BOOL|P_VI_DEF,
1980 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001984 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01001985 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
1986 |P_SECURE,
1987 (char_u *)&p_pp, PV_NONE,
1988 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
1989 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 {"paragraphs", "para", P_STRING|P_VI_DEF,
1991 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001992 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001993 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001994 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1998 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2001#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2002 (char_u *)&p_pex, PV_NONE,
2003 {(char_u *)"", (char_u *)0L}
2004#else
2005 (char_u *)NULL, PV_NONE,
2006 {(char_u *)0L, (char_u *)0L}
2007#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002008 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002009 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002011 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002012 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002013 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002014 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002015#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 (char_u *)".,,",
2017#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002020 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002021#if defined(DYNAMIC_PERL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002022 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002023 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002024 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
2025 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002026#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002027 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2028 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002029 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002030 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2032 (char_u *)&p_pvh, PV_NONE,
2033#else
2034 (char_u *)NULL, PV_NONE,
2035#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002036 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002037 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2038#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2039 (char_u *)VAR_WIN, PV_PVW,
2040#else
2041 (char_u *)NULL, PV_NONE,
2042#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002043 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002044 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002045#ifdef FEAT_PRINTER
2046 (char_u *)&p_pdev, PV_NONE,
2047 {(char_u *)"", (char_u *)0L}
2048#else
2049 (char_u *)NULL, PV_NONE,
2050 {(char_u *)NULL, (char_u *)0L}
2051#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002052 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002053 {"printencoding", "penc", P_STRING|P_VI_DEF,
2054#ifdef FEAT_POSTSCRIPT
2055 (char_u *)&p_penc, PV_NONE,
2056 {(char_u *)"", (char_u *)0L}
2057#else
2058 (char_u *)NULL, PV_NONE,
2059 {(char_u *)NULL, (char_u *)0L}
2060#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002061 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002062 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002063#ifdef FEAT_POSTSCRIPT
2064 (char_u *)&p_pexpr, PV_NONE,
2065 {(char_u *)"", (char_u *)0L}
2066#else
2067 (char_u *)NULL, PV_NONE,
2068 {(char_u *)NULL, (char_u *)0L}
2069#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002070 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002071 {"printfont", "pfn", P_STRING|P_VI_DEF,
2072#ifdef FEAT_PRINTER
2073 (char_u *)&p_pfn, PV_NONE,
2074 {
2075# ifdef MSWIN
2076 (char_u *)"Courier_New:h10",
2077# else
2078 (char_u *)"courier",
2079# endif
2080 (char_u *)0L}
2081#else
2082 (char_u *)NULL, PV_NONE,
2083 {(char_u *)NULL, (char_u *)0L}
2084#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2087#ifdef FEAT_PRINTER
2088 (char_u *)&p_header, PV_NONE,
2089 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
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 Moolenaar8299df92004-07-10 09:47:34 +00002095 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2096#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2097 (char_u *)&p_pmcs, PV_NONE,
2098 {(char_u *)"", (char_u *)0L}
2099#else
2100 (char_u *)NULL, PV_NONE,
2101 {(char_u *)NULL, (char_u *)0L}
2102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002103 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002104 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2105#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2106 (char_u *)&p_pmfn, PV_NONE,
2107 {(char_u *)"", (char_u *)0L}
2108#else
2109 (char_u *)NULL, PV_NONE,
2110 {(char_u *)NULL, (char_u *)0L}
2111#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002112 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002113 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002114#ifdef FEAT_PRINTER
2115 (char_u *)&p_popt, PV_NONE,
2116 {(char_u *)"", (char_u *)0L}
2117#else
2118 (char_u *)NULL, PV_NONE,
2119 {(char_u *)NULL, (char_u *)0L}
2120#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002121 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002122 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002123 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002124 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002125 {"pumheight", "ph", P_NUM|P_VI_DEF,
2126#ifdef FEAT_INS_EXPAND
2127 (char_u *)&p_ph, PV_NONE,
2128#else
2129 (char_u *)NULL, PV_NONE,
2130#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002131 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002132#if defined(DYNAMIC_PYTHON3)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002133 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002134 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002135 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
2136 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002137#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002138#if defined(DYNAMIC_PYTHON)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002139 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002140 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002141 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
2142 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002143#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002144 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2145#ifdef FEAT_TEXTOBJ
2146 (char_u *)&p_qe, PV_QE,
2147 {(char_u *)"\\", (char_u *)0L}
2148#else
2149 (char_u *)NULL, PV_NONE,
2150 {(char_u *)NULL, (char_u *)0L}
2151#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002152 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002153 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2154 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002155 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002156 {"redraw", NULL, P_BOOL|P_VI_DEF,
2157 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002158 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002159 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2160#ifdef FEAT_RELTIME
2161 (char_u *)&p_rdt, PV_NONE,
2162#else
2163 (char_u *)NULL, PV_NONE,
2164#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002165 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002166 {"regexpengine", "re", P_NUM|P_VI_DEF,
2167 (char_u *)&p_re, PV_NONE,
2168 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002169 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2170 (char_u *)VAR_WIN, PV_RNU,
2171 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172 {"remap", NULL, P_BOOL|P_VI_DEF,
2173 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002174 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002175 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002176#ifdef FEAT_RENDER_OPTIONS
2177 (char_u *)&p_rop, PV_NONE,
2178 {(char_u *)"", (char_u *)0L}
2179#else
2180 (char_u *)NULL, PV_NONE,
2181 {(char_u *)NULL, (char_u *)0L}
2182#endif
2183 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002184 {"report", NULL, P_NUM|P_VI_DEF,
2185 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002186 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002187 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2188#ifdef WIN3264
2189 (char_u *)&p_rs, PV_NONE,
2190#else
2191 (char_u *)NULL, PV_NONE,
2192#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002193 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2195#ifdef FEAT_RIGHTLEFT
2196 (char_u *)&p_ri, PV_NONE,
2197#else
2198 (char_u *)NULL, PV_NONE,
2199#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002200 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002201 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2202#ifdef FEAT_RIGHTLEFT
2203 (char_u *)VAR_WIN, PV_RL,
2204#else
2205 (char_u *)NULL, PV_NONE,
2206#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002207 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002208 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2209#ifdef FEAT_RIGHTLEFT
2210 (char_u *)VAR_WIN, PV_RLC,
2211 {(char_u *)"search", (char_u *)NULL}
2212#else
2213 (char_u *)NULL, PV_NONE,
2214 {(char_u *)NULL, (char_u *)0L}
2215#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002216 SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002217#if defined(DYNAMIC_RUBY)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002218 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002219 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002220 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
2221 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002222#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2224#ifdef FEAT_CMDL_INFO
2225 (char_u *)&p_ru, PV_NONE,
2226#else
2227 (char_u *)NULL, PV_NONE,
2228#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002229 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002230 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2231#ifdef FEAT_STL_OPT
2232 (char_u *)&p_ruf, PV_NONE,
2233#else
2234 (char_u *)NULL, PV_NONE,
2235#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002236 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002237 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2238 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002240 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2243 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2246#ifdef FEAT_SCROLLBIND
2247 (char_u *)VAR_WIN, PV_SCBIND,
2248#else
2249 (char_u *)NULL, PV_NONE,
2250#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002251 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2253 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002254 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002255 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2256 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002257 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002258 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259#ifdef FEAT_SCROLLBIND
2260 (char_u *)&p_sbo, PV_NONE,
2261 {(char_u *)"ver,jump", (char_u *)0L}
2262#else
2263 (char_u *)NULL, PV_NONE,
2264 {(char_u *)0L, (char_u *)0L}
2265#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002266 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267 {"sections", "sect", P_STRING|P_VI_DEF,
2268 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002269 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2270 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002271 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2272 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002273 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002274 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002276 {(char_u *)"inclusive", (char_u *)0L}
2277 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002278 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002279 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002280 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002281 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282#ifdef FEAT_SESSION
2283 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002284 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002285 (char_u *)0L}
2286#else
2287 (char_u *)NULL, PV_NONE,
2288 {(char_u *)0L, (char_u *)0L}
2289#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002290 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2292 (char_u *)&p_sh, PV_NONE,
2293 {
2294#ifdef VMS
2295 (char_u *)"-",
2296#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002297# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002299# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301# endif
2302#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002303 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2305 (char_u *)&p_shcf, PV_NONE,
2306 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002307#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 (char_u *)"/c",
2309#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002310 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002312 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002313 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2314#ifdef FEAT_QUICKFIX
2315 (char_u *)&p_sp, PV_NONE,
2316 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002317#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002319#else
2320 (char_u *)">",
2321#endif
2322 (char_u *)0L}
2323#else
2324 (char_u *)NULL, PV_NONE,
2325 {(char_u *)0L, (char_u *)0L}
2326#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002327 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2329 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002330 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002331 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2332 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002333 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2335#ifdef BACKSLASH_IN_FILENAME
2336 (char_u *)&p_ssl, PV_NONE,
2337#else
2338 (char_u *)NULL, PV_NONE,
2339#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002340 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002341 {"shelltemp", "stmp", P_BOOL,
2342 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002343 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002344 {"shelltype", "st", P_NUM|P_VI_DEF,
2345#ifdef AMIGA
2346 (char_u *)&p_st, PV_NONE,
2347#else
2348 (char_u *)NULL, PV_NONE,
2349#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002350 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002351 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2352 (char_u *)&p_sxq, PV_NONE,
2353 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002354#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002355 (char_u *)"\"",
2356#else
2357 (char_u *)"",
2358#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002359 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002360 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2361 (char_u *)&p_sxe, PV_NONE,
2362 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002363#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002364 (char_u *)"\"&|<>()@^",
2365#else
2366 (char_u *)"",
2367#endif
2368 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002369 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2370 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002371 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2373 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002374 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002375 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2376 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 {(char_u *)"", (char_u *)"filnxtToO"}
2378 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002381 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2383#ifdef FEAT_LINEBREAK
2384 (char_u *)&p_sbr, PV_NONE,
2385#else
2386 (char_u *)NULL, PV_NONE,
2387#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002388 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002389 {"showcmd", "sc", P_BOOL|P_VIM,
2390#ifdef FEAT_CMDL_INFO
2391 (char_u *)&p_sc, PV_NONE,
2392#else
2393 (char_u *)NULL, PV_NONE,
2394#endif
2395 {(char_u *)FALSE,
2396#ifdef UNIX
2397 (char_u *)FALSE
2398#else
2399 (char_u *)TRUE
2400#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002401 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2403 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002404 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2406 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002407 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408 {"showmode", "smd", P_BOOL|P_VIM,
2409 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002410 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002411 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2412#ifdef FEAT_WINDOWS
2413 (char_u *)&p_stal, PV_NONE,
2414#else
2415 (char_u *)NULL, PV_NONE,
2416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002417 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2419 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002420 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002421 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2422 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002423 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002424 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2425#ifdef FEAT_SIGNS
2426 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002427 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002428#else
2429 (char_u *)NULL, PV_NONE,
2430 {(char_u *)NULL, (char_u *)0L}
2431#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002432 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2434 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2437 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2440#ifdef FEAT_SMARTINDENT
2441 (char_u *)&p_si, PV_SI,
2442#else
2443 (char_u *)NULL, PV_NONE,
2444#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002445 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2447 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002449 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2450 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002451 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2453 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002454 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002455 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002456#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002457 (char_u *)VAR_WIN, PV_SPELL,
2458#else
2459 (char_u *)NULL, PV_NONE,
2460#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002461 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002462 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002463#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002464 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002465 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002466#else
2467 (char_u *)NULL, PV_NONE,
2468 {(char_u *)0L, (char_u *)0L}
2469#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002471 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2472 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002473#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002474 (char_u *)&p_spf, PV_SPF,
2475 {(char_u *)"", (char_u *)0L}
2476#else
2477 (char_u *)NULL, PV_NONE,
2478 {(char_u *)0L, (char_u *)0L}
2479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002480 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002481 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2482 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002483#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002484 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002485 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002486#else
2487 (char_u *)NULL, PV_NONE,
2488 {(char_u *)0L, (char_u *)0L}
2489#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002490 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002491 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002492#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002493 (char_u *)&p_sps, PV_NONE,
2494 {(char_u *)"best", (char_u *)0L}
2495#else
2496 (char_u *)NULL, PV_NONE,
2497 {(char_u *)0L, (char_u *)0L}
2498#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002499 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002500 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2501#ifdef FEAT_WINDOWS
2502 (char_u *)&p_sb, PV_NONE,
2503#else
2504 (char_u *)NULL, PV_NONE,
2505#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002506 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002508#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 (char_u *)&p_spr, PV_NONE,
2510#else
2511 (char_u *)NULL, PV_NONE,
2512#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002513 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2515 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002516 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2518#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002519 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520#else
2521 (char_u *)NULL, PV_NONE,
2522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002523 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002524 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002525 (char_u *)&p_su, PV_NONE,
2526 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002527 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002528 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002529#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 (char_u *)&p_sua, PV_SUA,
2531 {(char_u *)"", (char_u *)0L}
2532#else
2533 (char_u *)NULL, PV_NONE,
2534 {(char_u *)0L, (char_u *)0L}
2535#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002536 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2538 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002539 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002540 {"swapsync", "sws", P_STRING|P_VI_DEF,
2541 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002542 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002543 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002544 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002545 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002546 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2547#ifdef FEAT_SYN_HL
2548 (char_u *)&p_smc, PV_SMC,
2549 {(char_u *)3000L, (char_u *)0L}
2550#else
2551 (char_u *)NULL, PV_NONE,
2552 {(char_u *)0L, (char_u *)0L}
2553#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002554 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002555 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002556#ifdef FEAT_SYN_HL
2557 (char_u *)&p_syn, PV_SYN,
2558 {(char_u *)"", (char_u *)0L}
2559#else
2560 (char_u *)NULL, PV_NONE,
2561 {(char_u *)0L, (char_u *)0L}
2562#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002563 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002564 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2565#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002566 (char_u *)&p_tal, PV_NONE,
2567#else
2568 (char_u *)NULL, PV_NONE,
2569#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002570 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002571 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2572#ifdef FEAT_WINDOWS
2573 (char_u *)&p_tpm, PV_NONE,
2574#else
2575 (char_u *)NULL, PV_NONE,
2576#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002577 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002578 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2579 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002580 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002581 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2582 (char_u *)&p_tbs, PV_NONE,
2583#ifdef VMS /* binary searching doesn't appear to work on VMS */
2584 {(char_u *)0L, (char_u *)0L}
2585#else
2586 {(char_u *)TRUE, (char_u *)0L}
2587#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002589 {"tagcase", "tc", P_STRING|P_VIM,
2590 (char_u *)&p_tc, PV_TC,
2591 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002592 {"taglength", "tl", P_NUM|P_VI_DEF,
2593 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002594 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002595 {"tagrelative", "tr", P_BOOL|P_VIM,
2596 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002597 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002598 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002599 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002600 {
2601#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2602 (char_u *)"./tags,./TAGS,tags,TAGS",
2603#else
2604 (char_u *)"./tags,tags",
2605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002606 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2608 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002609 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002610#if defined(DYNAMIC_TCL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002611 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002612 (char_u *)&p_tcldll, PV_NONE,
2613 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
2614 SCRIPTID_INIT},
2615#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2617 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002619 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2620#ifdef FEAT_ARABIC
2621 (char_u *)&p_tbidi, PV_NONE,
2622#else
2623 (char_u *)NULL, PV_NONE,
2624#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2627#ifdef FEAT_MBYTE
2628 (char_u *)&p_tenc, PV_NONE,
2629 {(char_u *)"", (char_u *)0L}
2630#else
2631 (char_u *)NULL, PV_NONE,
2632 {(char_u *)0L, (char_u *)0L}
2633#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002634 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002635 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2636#ifdef FEAT_TERMGUICOLORS
2637 (char_u *)&p_tgc, PV_NONE,
2638 {(char_u *)FALSE, (char_u *)FALSE}
2639#else
2640 (char_u*)NULL, PV_NONE,
2641 {(char_u *)FALSE, (char_u *)FALSE}
2642#endif
2643 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644 {"terse", NULL, P_BOOL|P_VI_DEF,
2645 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002646 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 {"textauto", "ta", P_BOOL|P_VIM,
2648 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002649 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2650 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2652 (char_u *)&p_tx, PV_TX,
2653 {
2654#ifdef USE_CRNL
2655 (char_u *)TRUE,
2656#else
2657 (char_u *)FALSE,
2658#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002659 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002660 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002662 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002663 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002665 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666#else
2667 (char_u *)NULL, PV_NONE,
2668#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2671 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002672 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673 {"timeout", "to", P_BOOL|P_VI_DEF,
2674 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002675 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002676 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2677 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002678 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679 {"title", NULL, P_BOOL|P_VI_DEF,
2680#ifdef FEAT_TITLE
2681 (char_u *)&p_title, PV_NONE,
2682#else
2683 (char_u *)NULL, PV_NONE,
2684#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002685 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002686 {"titlelen", NULL, P_NUM|P_VI_DEF,
2687#ifdef FEAT_TITLE
2688 (char_u *)&p_titlelen, PV_NONE,
2689#else
2690 (char_u *)NULL, PV_NONE,
2691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002692 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002693 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002694#ifdef FEAT_TITLE
2695 (char_u *)&p_titleold, PV_NONE,
2696 {(char_u *)N_("Thanks for flying Vim"),
2697 (char_u *)0L}
2698#else
2699 (char_u *)NULL, PV_NONE,
2700 {(char_u *)0L, (char_u *)0L}
2701#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002702 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002703 {"titlestring", NULL, P_STRING|P_VI_DEF,
2704#ifdef FEAT_TITLE
2705 (char_u *)&p_titlestring, PV_NONE,
2706#else
2707 (char_u *)NULL, PV_NONE,
2708#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002709 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002710#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002711 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002713 {(char_u *)"icons,tooltips", (char_u *)0L}
2714 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002716#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002717 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2718 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002719 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002720#endif
2721 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2722 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002723 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2725 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002726 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2728 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002729 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002730 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2731 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002732 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2734#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2735 (char_u *)&p_ttym, PV_NONE,
2736#else
2737 (char_u *)NULL, PV_NONE,
2738#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002739 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002740 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2741 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002742 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2744 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002745 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002746 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2747 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002748#ifdef FEAT_PERSISTENT_UNDO
2749 (char_u *)&p_udir, PV_NONE,
2750 {(char_u *)".", (char_u *)0L}
2751#else
2752 (char_u *)NULL, PV_NONE,
2753 {(char_u *)0L, (char_u *)0L}
2754#endif
2755 SCRIPTID_INIT},
2756 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2757#ifdef FEAT_PERSISTENT_UNDO
2758 (char_u *)&p_udf, PV_UDF,
2759#else
2760 (char_u *)NULL, PV_NONE,
2761#endif
2762 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002764 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002765 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002766#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767 (char_u *)1000L,
2768#else
2769 (char_u *)100L,
2770#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002771 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002772 {"undoreload", "ur", P_NUM|P_VI_DEF,
2773 (char_u *)&p_ur, PV_NONE,
2774 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002775 {"updatecount", "uc", P_NUM|P_VI_DEF,
2776 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002777 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002778 {"updatetime", "ut", P_NUM|P_VI_DEF,
2779 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002780 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781 {"verbose", "vbs", P_NUM|P_VI_DEF,
2782 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002783 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002784 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2785 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002786 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002787 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2788#ifdef FEAT_SESSION
2789 (char_u *)&p_vdir, PV_NONE,
2790 {(char_u *)DFLT_VDIR, (char_u *)0L}
2791#else
2792 (char_u *)NULL, PV_NONE,
2793 {(char_u *)0L, (char_u *)0L}
2794#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002795 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002796 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797#ifdef FEAT_SESSION
2798 (char_u *)&p_vop, PV_NONE,
2799 {(char_u *)"folds,options,cursor", (char_u *)0L}
2800#else
2801 (char_u *)NULL, PV_NONE,
2802 {(char_u *)0L, (char_u *)0L}
2803#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002805 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806#ifdef FEAT_VIMINFO
2807 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002808#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002809 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002810#else
2811# ifdef AMIGA
2812 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002813 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002815 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816# endif
2817#endif
2818#else
2819 (char_u *)NULL, PV_NONE,
2820 {(char_u *)0L, (char_u *)0L}
2821#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002823 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2824 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002825#ifdef FEAT_VIRTUALEDIT
2826 (char_u *)&p_ve, PV_NONE,
2827 {(char_u *)"", (char_u *)""}
2828#else
2829 (char_u *)NULL, PV_NONE,
2830 {(char_u *)0L, (char_u *)0L}
2831#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002832 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002833 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2834 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002835 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002836 {"w300", NULL, P_NUM|P_VI_DEF,
2837 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002838 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002839 {"w1200", NULL, P_NUM|P_VI_DEF,
2840 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002841 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002842 {"w9600", NULL, P_NUM|P_VI_DEF,
2843 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002844 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845 {"warn", NULL, P_BOOL|P_VI_DEF,
2846 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002847 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002848 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2849 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002850 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002851 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002852 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002853 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002854 {"wildchar", "wc", P_NUM|P_VIM,
2855 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002856 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2857 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002858 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002860 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002861 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862#ifdef FEAT_WILDIGN
2863 (char_u *)&p_wig, PV_NONE,
2864#else
2865 (char_u *)NULL, PV_NONE,
2866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002868 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2869 (char_u *)&p_wic, PV_NONE,
2870 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2872#ifdef FEAT_WILDMENU
2873 (char_u *)&p_wmnu, PV_NONE,
2874#else
2875 (char_u *)NULL, PV_NONE,
2876#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002877 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002878 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002879 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002880 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002881 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2882#ifdef FEAT_CMDL_COMPL
2883 (char_u *)&p_wop, PV_NONE,
2884 {(char_u *)"", (char_u *)0L}
2885#else
2886 (char_u *)NULL, PV_NONE,
2887 {(char_u *)NULL, (char_u *)0L}
2888#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002889 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002890 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2891#ifdef FEAT_WAK
2892 (char_u *)&p_wak, PV_NONE,
2893 {(char_u *)"menu", (char_u *)0L}
2894#else
2895 (char_u *)NULL, PV_NONE,
2896 {(char_u *)NULL, (char_u *)0L}
2897#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002898 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002900 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002901 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002902 {"winheight", "wh", P_NUM|P_VI_DEF,
2903#ifdef FEAT_WINDOWS
2904 (char_u *)&p_wh, PV_NONE,
2905#else
2906 (char_u *)NULL, PV_NONE,
2907#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002908 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002909 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002910#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002911 (char_u *)VAR_WIN, PV_WFH,
2912#else
2913 (char_u *)NULL, PV_NONE,
2914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002916 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002917#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002918 (char_u *)VAR_WIN, PV_WFW,
2919#else
2920 (char_u *)NULL, PV_NONE,
2921#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002922 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002923 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2924#ifdef FEAT_WINDOWS
2925 (char_u *)&p_wmh, PV_NONE,
2926#else
2927 (char_u *)NULL, PV_NONE,
2928#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002929 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002931#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002932 (char_u *)&p_wmw, PV_NONE,
2933#else
2934 (char_u *)NULL, PV_NONE,
2935#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002936 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002938#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939 (char_u *)&p_wiw, PV_NONE,
2940#else
2941 (char_u *)NULL, PV_NONE,
2942#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002943 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2945 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002946 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002947 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2948 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002949 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002950 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2951 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002952 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953 {"write", NULL, P_BOOL|P_VI_DEF,
2954 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002955 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002956 {"writeany", "wa", P_BOOL|P_VI_DEF,
2957 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002958 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002959 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2960 (char_u *)&p_wb, PV_NONE,
2961 {
2962#ifdef FEAT_WRITEBACKUP
2963 (char_u *)TRUE,
2964#else
2965 (char_u *)FALSE,
2966#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002967 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002968 {"writedelay", "wd", P_NUM|P_VI_DEF,
2969 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002970 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971
2972/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002973#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002974 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002975 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976
2977 p_term("t_AB", T_CAB)
2978 p_term("t_AF", T_CAF)
2979 p_term("t_AL", T_CAL)
2980 p_term("t_al", T_AL)
2981 p_term("t_bc", T_BC)
2982 p_term("t_cd", T_CD)
2983 p_term("t_ce", T_CE)
2984 p_term("t_cl", T_CL)
2985 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002986 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987 p_term("t_Co", T_CCO)
2988 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002989 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002990 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002991#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 p_term("t_CV", T_CSV)
2993#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002994 p_term("t_da", T_DA)
2995 p_term("t_db", T_DB)
2996 p_term("t_DL", T_CDL)
2997 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002998 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 p_term("t_fs", T_FS)
3000 p_term("t_IE", T_CIE)
3001 p_term("t_IS", T_CIS)
3002 p_term("t_ke", T_KE)
3003 p_term("t_ks", T_KS)
3004 p_term("t_le", T_LE)
3005 p_term("t_mb", T_MB)
3006 p_term("t_md", T_MD)
3007 p_term("t_me", T_ME)
3008 p_term("t_mr", T_MR)
3009 p_term("t_ms", T_MS)
3010 p_term("t_nd", T_ND)
3011 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003012 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003013 p_term("t_RI", T_CRI)
3014 p_term("t_RV", T_CRV)
3015 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003016 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003017 p_term("t_Sf", T_CSF)
3018 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003019 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003020 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003021 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003022 p_term("t_te", T_TE)
3023 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003024 p_term("t_ts", T_TS)
3025 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003026 p_term("t_ue", T_UE)
3027 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003028 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003029 p_term("t_vb", T_VB)
3030 p_term("t_ve", T_VE)
3031 p_term("t_vi", T_VI)
3032 p_term("t_vs", T_VS)
3033 p_term("t_WP", T_CWP)
3034 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003035 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003036 p_term("t_xs", T_XS)
3037 p_term("t_ZH", T_CZH)
3038 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003039 p_term("t_8f", T_8F)
3040 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041
3042/* terminal key codes are not in here */
3043
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003044 /* end marker */
3045 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046};
3047
3048#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3049
3050#ifdef FEAT_MBYTE
3051static char *(p_ambw_values[]) = {"single", "double", NULL};
3052#endif
3053static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003054static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003055static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003056#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003057static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003058#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003059#ifdef FEAT_CMDL_COMPL
3060static char *(p_wop_values[]) = {"tagfile", NULL};
3061#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003062#ifdef FEAT_WAK
3063static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3064#endif
3065static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003066static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3067static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003068static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003069#ifdef FEAT_BROWSE
3070static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3071#endif
3072#ifdef FEAT_SCROLLBIND
3073static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3074#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003075static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003076#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003077static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3078#endif
3079#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003080# ifdef FEAT_AUTOCMD
3081static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3082# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003084# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003085static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3086#endif
3087static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3088#ifdef FEAT_FOLDING
3089static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003090# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003091 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003092# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003093 NULL};
3094static char *(p_fcl_values[]) = {"all", NULL};
3095#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003096#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003097static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003098#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003099#ifdef FEAT_SIGNS
3100static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3101#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003102
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003103static void set_option_default(int, int opt_flags, int compatible);
3104static void set_options_default(int opt_flags);
3105static char_u *term_bg_default(void);
3106static void did_set_option(int opt_idx, int opt_flags, int new_value);
3107static char_u *illegal_char(char_u *, int);
3108static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003109#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003110static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003111#endif
3112#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003113static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003115static char_u *option_expand(int opt_idx, char_u *val);
3116static void didset_options(void);
3117static void didset_options2(void);
3118static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003119#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003120static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003121#else
3122# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3123#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003124static void set_string_option_global(int opt_idx, char_u **varp);
3125static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3126static char_u *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags);
3127static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003128#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003129static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003130#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003131#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003132static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003134#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003135static char_u *did_set_spell_option(int is_spellfile);
3136static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003137#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003138#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003139static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003140#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003141static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3142static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3143static void check_redraw(long_u flags);
3144static int findoption(char_u *);
3145static int find_key_option(char_u *);
3146static void showoptions(int all, int opt_flags);
3147static int optval_default(struct vimoption *, char_u *varp);
3148static void showoneopt(struct vimoption *, int opt_flags);
3149static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3150static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3151static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3152static int istermoption(struct vimoption *);
3153static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3154static char_u *get_varp(struct vimoption *);
3155static void option_value2string(struct vimoption *, int opt_flags);
3156static void check_winopt(winopt_T *wop);
3157static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003159static void langmap_init(void);
3160static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003161#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003162static void paste_option_changed(void);
3163static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003164#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003165static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003166#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003167static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3168static int check_opt_strings(char_u *val, char **values, int);
3169static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003170#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003171static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003172#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003173
3174/*
3175 * Initialize the options, first part.
3176 *
3177 * Called only once from main(), just after creating the first buffer.
3178 */
3179 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003180set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003181{
3182 char_u *p;
3183 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003184 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003185
3186#ifdef FEAT_LANGMAP
3187 langmap_init();
3188#endif
3189
3190 /* Be Vi compatible by default */
3191 p_cp = TRUE;
3192
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003193 /* Use POSIX compatibility when $VIM_POSIX is set. */
3194 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003195 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003196 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003197 set_string_default("shm", (char_u *)"A");
3198 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003199
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200 /*
3201 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003202 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003204 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003205#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003206 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003208 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209# endif
3210#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003211 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003212 set_string_default("sh", p);
3213
3214#ifdef FEAT_WILDIGN
3215 /*
3216 * Set the default for 'backupskip' to include environment variables for
3217 * temp files.
3218 */
3219 {
3220# ifdef UNIX
3221 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3222# else
3223 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3224# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003225 int len;
3226 garray_T ga;
3227 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003228
3229 ga_init2(&ga, 1, 100);
3230 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3231 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003232 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003233# ifdef UNIX
3234 if (*names[n] == NUL)
3235 p = (char_u *)"/tmp";
3236 else
3237# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003238 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003239 if (p != NULL && *p != NUL)
3240 {
3241 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003242 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003243 if (ga_grow(&ga, len) == OK)
3244 {
3245 if (ga.ga_len > 0)
3246 STRCAT(ga.ga_data, ",");
3247 STRCAT(ga.ga_data, p);
3248 add_pathsep(ga.ga_data);
3249 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003250 ga.ga_len += len;
3251 }
3252 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003253 if (mustfree)
3254 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255 }
3256 if (ga.ga_data != NULL)
3257 {
3258 set_string_default("bsk", ga.ga_data);
3259 vim_free(ga.ga_data);
3260 }
3261 }
3262#endif
3263
3264 /*
3265 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3266 */
3267 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003268 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003270#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3271 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3272#endif
3273 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003275 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003276 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003277#else
3278# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003279 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003280 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003282 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003283# endif
3284#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003285 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003286 opt_idx = findoption((char_u *)"maxmem");
3287 if (opt_idx >= 0)
3288 {
3289#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003290 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3291 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003292#endif
3293 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3294 }
3295 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003296 }
3297
Bram Moolenaar071d4272004-06-13 20:20:40 +00003298#ifdef FEAT_SEARCHPATH
3299 {
3300 char_u *cdpath;
3301 char_u *buf;
3302 int i;
3303 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003304 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003305
3306 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003307 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308 if (cdpath != NULL)
3309 {
3310 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3311 if (buf != NULL)
3312 {
3313 buf[0] = ','; /* start with ",", current dir first */
3314 j = 1;
3315 for (i = 0; cdpath[i] != NUL; ++i)
3316 {
3317 if (vim_ispathlistsep(cdpath[i]))
3318 buf[j++] = ',';
3319 else
3320 {
3321 if (cdpath[i] == ' ' || cdpath[i] == ',')
3322 buf[j++] = '\\';
3323 buf[j++] = cdpath[i];
3324 }
3325 }
3326 buf[j] = NUL;
3327 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003328 if (opt_idx >= 0)
3329 {
3330 options[opt_idx].def_val[VI_DEFAULT] = buf;
3331 options[opt_idx].flags |= P_DEF_ALLOCED;
3332 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003333 else
3334 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003335 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003336 if (mustfree)
3337 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003338 }
3339 }
3340#endif
3341
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003342#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343 /* Set print encoding on platforms that don't default to latin1 */
3344 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003345# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346 (char_u *)"cp1252"
3347# else
3348# ifdef VMS
3349 (char_u *)"dec-mcs"
3350# else
3351# ifdef EBCDIC
3352 (char_u *)"ebcdic-uk"
3353# else
3354# ifdef MAC
3355 (char_u *)"mac-roman"
3356# else /* HPUX */
3357 (char_u *)"hp-roman8"
3358# endif
3359# endif
3360# endif
3361# endif
3362 );
3363#endif
3364
3365#ifdef FEAT_POSTSCRIPT
3366 /* 'printexpr' must be allocated to be able to evaluate it. */
3367 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003368# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003369 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370# else
3371# ifdef VMS
3372 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3373
3374# else
3375 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3376# endif
3377# endif
3378 );
3379#endif
3380
3381 /*
3382 * Set all the options (except the terminal options) to their default
3383 * value. Also set the global value for local options.
3384 */
3385 set_options_default(0);
3386
3387#ifdef FEAT_GUI
3388 if (found_reverse_arg)
3389 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3390#endif
3391
3392 curbuf->b_p_initialized = TRUE;
3393 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003394 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395 check_buf_options(curbuf);
3396 check_win_options(curwin);
3397 check_options();
3398
3399 /* Must be before option_expand(), because that one needs vim_isIDc() */
3400 didset_options();
3401
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003402#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003403 /* Use the current chartab for the generic chartab. This is not in
3404 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003405 init_spell_chartab();
3406#endif
3407
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408 /*
3409 * Expand environment variables and things like "~" for the defaults.
3410 * If option_expand() returns non-NULL the variable is expanded. This can
3411 * only happen for non-indirect options.
3412 * Also set the default to the expanded value, so ":set" does not list
3413 * them.
3414 * Don't set the P_ALLOCED flag, because we don't want to free the
3415 * default.
3416 */
3417 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3418 {
3419 if ((options[opt_idx].flags & P_GETTEXT)
3420 && options[opt_idx].var != NULL)
3421 p = (char_u *)_(*(char **)options[opt_idx].var);
3422 else
3423 p = option_expand(opt_idx, NULL);
3424 if (p != NULL && (p = vim_strsave(p)) != NULL)
3425 {
3426 *(char_u **)options[opt_idx].var = p;
3427 /* VIMEXP
3428 * Defaults for all expanded options are currently the same for Vi
3429 * and Vim. When this changes, add some code here! Also need to
3430 * split P_DEF_ALLOCED in two.
3431 */
3432 if (options[opt_idx].flags & P_DEF_ALLOCED)
3433 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3434 options[opt_idx].def_val[VI_DEFAULT] = p;
3435 options[opt_idx].flags |= P_DEF_ALLOCED;
3436 }
3437 }
3438
Bram Moolenaar071d4272004-06-13 20:20:40 +00003439 save_file_ff(curbuf); /* Buffer is unchanged */
3440
Bram Moolenaar071d4272004-06-13 20:20:40 +00003441#if defined(FEAT_ARABIC)
3442 /* Detect use of mlterm.
3443 * Mlterm is a terminal emulator akin to xterm that has some special
3444 * abilities (bidi namely).
3445 * NOTE: mlterm's author is being asked to 'set' a variable
3446 * instead of an environment variable due to inheritance.
3447 */
3448 if (mch_getenv((char_u *)"MLTERM") != NULL)
3449 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3450#endif
3451
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003452 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003453
3454#ifdef FEAT_MBYTE
3455# if defined(WIN3264) && defined(FEAT_GETTEXT)
3456 /*
3457 * If $LANG isn't set, try to get a good value for it. This makes the
3458 * right language be used automatically. Don't do this for English.
3459 */
3460 if (mch_getenv((char_u *)"LANG") == NULL)
3461 {
3462 char buf[20];
3463
3464 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3465 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3466 * only the first two. */
3467 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3468 (LPTSTR)buf, 20);
3469 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3470 {
3471 /* There are a few exceptions (probably more) */
3472 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3473 STRCPY(buf, "zh_TW");
3474 else if (STRNICMP(buf, "chs", 3) == 0
3475 || STRNICMP(buf, "zhc", 3) == 0)
3476 STRCPY(buf, "zh_CN");
3477 else if (STRNICMP(buf, "jp", 2) == 0)
3478 STRCPY(buf, "ja");
3479 else
3480 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003481 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482 }
3483 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003484# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003485# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003486 /* Moved to os_mac_conv.c to avoid dependency problems. */
3487 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003488# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003489# endif
3490
3491 /* enc_locale() will try to find the encoding of the current locale. */
3492 p = enc_locale();
3493 if (p != NULL)
3494 {
3495 char_u *save_enc;
3496
3497 /* Try setting 'encoding' and check if the value is valid.
3498 * If not, go back to the default "latin1". */
3499 save_enc = p_enc;
3500 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003501 if (STRCMP(p_enc, "gb18030") == 0)
3502 {
3503 /* We don't support "gb18030", but "cp936" is a good substitute
3504 * for practical purposes, thus use that. It's not an alias to
3505 * still support conversion between gb18030 and utf-8. */
3506 p_enc = vim_strsave((char_u *)"cp936");
3507 vim_free(p);
3508 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003509 if (mb_init() == NULL)
3510 {
3511 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003512 if (opt_idx >= 0)
3513 {
3514 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3515 options[opt_idx].flags |= P_DEF_ALLOCED;
3516 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003517
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003518#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003519 if (STRCMP(p_enc, "latin1") == 0
3520# ifdef FEAT_MBYTE
3521 || enc_utf8
3522# endif
3523 )
3524 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003525 /* Adjust the default for 'isprint' and 'iskeyword' to match
3526 * latin1. Also set the defaults for when 'nocompatible' is
3527 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003528 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003529 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003530 set_string_option_direct((char_u *)"isk", -1,
3531 ISK_LATIN1, OPT_FREE, SID_NONE);
3532 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003533 if (opt_idx >= 0)
3534 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003535 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003536 if (opt_idx >= 0)
3537 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003538 (void)init_chartab();
3539 }
3540#endif
3541
Bram Moolenaar071d4272004-06-13 20:20:40 +00003542# if defined(WIN3264) && !defined(FEAT_GUI)
3543 /* Win32 console: When GetACP() returns a different value from
3544 * GetConsoleCP() set 'termencoding'. */
3545 if (GetACP() != GetConsoleCP())
3546 {
3547 char buf[50];
3548
3549 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3550 p_tenc = vim_strsave((char_u *)buf);
3551 if (p_tenc != NULL)
3552 {
3553 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003554 if (opt_idx >= 0)
3555 {
3556 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3557 options[opt_idx].flags |= P_DEF_ALLOCED;
3558 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003559 convert_setup(&input_conv, p_tenc, p_enc);
3560 convert_setup(&output_conv, p_enc, p_tenc);
3561 }
3562 else
3563 p_tenc = empty_option;
3564 }
3565# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003566# if defined(WIN3264) && defined(FEAT_MBYTE)
3567 /* $HOME may have characters in active code page. */
3568 init_homedir();
3569# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003570 }
3571 else
3572 {
3573 vim_free(p_enc);
3574 p_enc = save_enc;
3575 }
3576 }
3577#endif
3578
3579#ifdef FEAT_MULTI_LANG
3580 /* Set the default for 'helplang'. */
3581 set_helplang_default(get_mess_lang());
3582#endif
3583}
3584
3585/*
3586 * Set an option to its default value.
3587 * This does not take care of side effects!
3588 */
3589 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003590set_option_default(
3591 int opt_idx,
3592 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3593 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003594{
3595 char_u *varp; /* pointer to variable for current option */
3596 int dvi; /* index in def_val[] */
3597 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003598 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003599 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3600
3601 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3602 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003603 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003604 {
3605 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3606 if (flags & P_STRING)
3607 {
3608 /* Use set_string_option_direct() for local options to handle
3609 * freeing and allocating the value. */
3610 if (options[opt_idx].indir != PV_NONE)
3611 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003612 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003613 else
3614 {
3615 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3616 free_string_option(*(char_u **)(varp));
3617 *(char_u **)varp = options[opt_idx].def_val[dvi];
3618 options[opt_idx].flags &= ~P_ALLOCED;
3619 }
3620 }
3621 else if (flags & P_NUM)
3622 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003623 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624 win_comp_scroll(curwin);
3625 else
3626 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003627 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003628 /* May also set global value for local option. */
3629 if (both)
3630 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3631 *(long *)varp;
3632 }
3633 }
3634 else /* P_BOOL */
3635 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003636 /* the cast to long is required for Manx C, long_i is needed for
3637 * MSVC */
3638 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003639#ifdef UNIX
3640 /* 'modeline' defaults to off for root */
3641 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3642 *(int *)varp = FALSE;
3643#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003644 /* May also set global value for local option. */
3645 if (both)
3646 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3647 *(int *)varp;
3648 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003649
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003650 /* The default value is not insecure. */
3651 flagsp = insecure_flag(opt_idx, opt_flags);
3652 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003653 }
3654
3655#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003656 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657#endif
3658}
3659
3660/*
3661 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003662 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003663 */
3664 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003665set_options_default(
3666 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003667{
3668 int i;
3669#ifdef FEAT_WINDOWS
3670 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003671 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672#endif
3673
3674 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003675 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003676#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003677 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003678 || (TRUE
3679# if defined(FEAT_MBYTE)
3680 && options[i].var != (char_u *)&p_enc
3681# endif
3682# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003683 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003684 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003685# endif
3686 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003687#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003688 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003689 set_option_default(i, opt_flags, p_cp);
3690
3691#ifdef FEAT_WINDOWS
3692 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003693 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003694 win_comp_scroll(wp);
3695#else
3696 win_comp_scroll(curwin);
3697#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003698#ifdef FEAT_CINDENT
3699 parse_cino(curbuf);
3700#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003701}
3702
3703/*
3704 * Set the Vi-default value of a string option.
3705 * Used for 'sh', 'backupskip' and 'term'.
3706 */
3707 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003708set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709{
3710 char_u *p;
3711 int opt_idx;
3712
3713 p = vim_strsave(val);
3714 if (p != NULL) /* we don't want a NULL */
3715 {
3716 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003717 if (opt_idx >= 0)
3718 {
3719 if (options[opt_idx].flags & P_DEF_ALLOCED)
3720 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3721 options[opt_idx].def_val[VI_DEFAULT] = p;
3722 options[opt_idx].flags |= P_DEF_ALLOCED;
3723 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003724 }
3725}
3726
3727/*
3728 * Set the Vi-default value of a number option.
3729 * Used for 'lines' and 'columns'.
3730 */
3731 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003732set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003733{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003734 int opt_idx;
3735
3736 opt_idx = findoption((char_u *)name);
3737 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003738 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003739}
3740
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003741#if defined(EXITFREE) || defined(PROTO)
3742/*
3743 * Free all options.
3744 */
3745 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003746free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003747{
3748 int i;
3749
3750 for (i = 0; !istermoption(&options[i]); i++)
3751 {
3752 if (options[i].indir == PV_NONE)
3753 {
3754 /* global option: free value and default value. */
3755 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3756 free_string_option(*(char_u **)options[i].var);
3757 if (options[i].flags & P_DEF_ALLOCED)
3758 free_string_option(options[i].def_val[VI_DEFAULT]);
3759 }
3760 else if (options[i].var != VAR_WIN
3761 && (options[i].flags & P_STRING))
3762 /* buffer-local option: free global value */
3763 free_string_option(*(char_u **)options[i].var);
3764 }
3765}
3766#endif
3767
3768
Bram Moolenaar071d4272004-06-13 20:20:40 +00003769/*
3770 * Initialize the options, part two: After getting Rows and Columns and
3771 * setting 'term'.
3772 */
3773 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003774set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003775{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003776 int idx;
3777
Bram Moolenaar071d4272004-06-13 20:20:40 +00003778 /*
3779 * 'scroll' defaults to half the window height. Note that this default is
3780 * wrong when the window height changes.
3781 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003782 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003783 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003784 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003785 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003786 comp_col();
3787
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003788 /*
3789 * 'window' is only for backwards compatibility with Vi.
3790 * Default is Rows - 1.
3791 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003792 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003793 p_window = Rows - 1;
3794 set_number_default("window", Rows - 1);
3795
Bram Moolenaarf740b292006-02-16 22:11:02 +00003796 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003797#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003798 /*
3799 * If 'background' wasn't set by the user, try guessing the value,
3800 * depending on the terminal name. Only need to check for terminals
3801 * with a dark background, that can handle color.
3802 */
3803 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003804 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3805 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003806 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003807 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003808 /* don't mark it as set, when starting the GUI it may be
3809 * changed again */
3810 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003811 }
3812#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003813
3814#ifdef CURSOR_SHAPE
3815 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3816#endif
3817#ifdef FEAT_MOUSESHAPE
3818 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3819#endif
3820#ifdef FEAT_PRINTER
3821 (void)parse_printoptions(); /* parse 'printoptions' default value */
3822#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003823}
3824
3825/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003826 * Return "dark" or "light" depending on the kind of terminal.
3827 * This is just guessing! Recognized are:
3828 * "linux" Linux console
3829 * "screen.linux" Linux console with screen
3830 * "cygwin" Cygwin shell
3831 * "putty" Putty program
3832 * We also check the COLORFGBG environment variable, which is set by
3833 * rxvt and derivatives. This variable contains either two or three
3834 * values separated by semicolons; we want the last value in either
3835 * case. If this value is 0-6 or 8, our background is dark.
3836 */
3837 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003838term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003839{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003840#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003841 /* DOS console nearly always black */
3842 return (char_u *)"dark";
3843#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003844 char_u *p;
3845
Bram Moolenaarf740b292006-02-16 22:11:02 +00003846 if (STRCMP(T_NAME, "linux") == 0
3847 || STRCMP(T_NAME, "screen.linux") == 0
3848 || STRCMP(T_NAME, "cygwin") == 0
3849 || STRCMP(T_NAME, "putty") == 0
3850 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3851 && (p = vim_strrchr(p, ';')) != NULL
3852 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3853 && p[2] == NUL))
3854 return (char_u *)"dark";
3855 return (char_u *)"light";
3856#endif
3857}
3858
3859/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860 * Initialize the options, part three: After reading the .vimrc
3861 */
3862 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003863set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003864{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003865#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003866/*
3867 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3868 * This is done after other initializations, where 'shell' might have been
3869 * set, but only if they have not been set before.
3870 */
3871 char_u *p;
3872 int idx_srr;
3873 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003874# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003875 int idx_sp;
3876 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003877# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878
3879 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003880 if (idx_srr < 0)
3881 do_srr = FALSE;
3882 else
3883 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003884# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003885 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003886 if (idx_sp < 0)
3887 do_sp = FALSE;
3888 else
3889 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003890# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003891 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003892 if (p != NULL)
3893 {
3894 /*
3895 * Default for p_sp is "| tee", for p_srr is ">".
3896 * For known shells it is changed here to include stderr.
3897 */
3898 if ( fnamecmp(p, "csh") == 0
3899 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003900# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003901 || fnamecmp(p, "csh.exe") == 0
3902 || fnamecmp(p, "tcsh.exe") == 0
3903# endif
3904 )
3905 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003906# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003907 if (do_sp)
3908 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003909# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003910 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003911# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003912 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003913# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3915 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003916# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003917 if (do_srr)
3918 {
3919 p_srr = (char_u *)">&";
3920 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3921 }
3922 }
3923 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003924 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925 if ( fnamecmp(p, "sh") == 0
3926 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003927 || fnamecmp(p, "mksh") == 0
3928 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003929 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003930 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003931 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003932 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003933# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003934 || fnamecmp(p, "cmd") == 0
3935 || fnamecmp(p, "sh.exe") == 0
3936 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003937 || fnamecmp(p, "mksh.exe") == 0
3938 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003939 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003940 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003941 || fnamecmp(p, "bash.exe") == 0
3942 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003943# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003944 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003945 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003946# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003947 if (do_sp)
3948 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003949# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003950 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003951# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003953# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003954 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3955 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003956# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003957 if (do_srr)
3958 {
3959 p_srr = (char_u *)">%s 2>&1";
3960 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3961 }
3962 }
3963 vim_free(p);
3964 }
3965#endif
3966
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003967#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003969 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3970 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003971 * This is done after other initializations, where 'shell' might have been
3972 * set, but only if they have not been set before. Default for p_shcf is
3973 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003974 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003975 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003976 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003977 {
3978 int idx3;
3979
3980 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003981 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003982 {
3983 p_shcf = (char_u *)"-c";
3984 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3985 }
3986
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003987# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003988 /* Somehow Win32 requires the quotes around the redirection too */
3989 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003990 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003991 {
3992 p_sxq = (char_u *)"\"";
3993 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3994 }
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003995# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003997 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003998 {
3999 p_shq = (char_u *)"\"";
4000 options[idx3].def_val[VI_DEFAULT] = p_shq;
4001 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004002# endif
4003 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004004 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4005 {
4006 int idx3;
4007
4008 /*
4009 * cmd.exe on Windows will strip the first and last double quote given
4010 * on the command line, e.g. most of the time things like:
4011 * cmd /c "my path/to/echo" "my args to echo"
4012 * become:
4013 * my path/to/echo" "my args to echo
4014 * when executed.
4015 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004016 * To avoid this, set shellxquote to surround the command in
4017 * parenthesis. This appears to make most commands work, without
4018 * breaking commands that worked previously, such as
4019 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004020 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004021 idx3 = findoption((char_u *)"sxq");
4022 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4023 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004024 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004025 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4026 }
4027
Bram Moolenaara64ba222012-02-12 23:23:31 +01004028 idx3 = findoption((char_u *)"shcf");
4029 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4030 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004031 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004032 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4033 }
4034 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035#endif
4036
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004037 if (bufempty())
4038 {
4039 int idx_ffs = findoption((char_u *)"ffs");
4040
4041 /* Apply the first entry of 'fileformats' to the initial buffer. */
4042 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4043 set_fileformat(default_fileformat(), OPT_LOCAL);
4044 }
4045
Bram Moolenaar071d4272004-06-13 20:20:40 +00004046#ifdef FEAT_TITLE
4047 set_title_defaults();
4048#endif
4049}
4050
4051#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4052/*
4053 * When 'helplang' is still at its default value, set it to "lang".
4054 * Only the first two characters of "lang" are used.
4055 */
4056 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004057set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004058{
4059 int idx;
4060
4061 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4062 return;
4063 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004064 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004065 {
4066 if (options[idx].flags & P_ALLOCED)
4067 free_string_option(p_hlg);
4068 p_hlg = vim_strsave(lang);
4069 if (p_hlg == NULL)
4070 p_hlg = empty_option;
4071 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004072 {
4073 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4074 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4075 {
4076 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4077 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4078 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004079 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004080 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081 options[idx].flags |= P_ALLOCED;
4082 }
4083}
4084#endif
4085
4086#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004087static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088
4089 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004090gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004091{
4092 if (gui_get_lightness(gui.back_pixel) < 127)
4093 return (char_u *)"dark";
4094 return (char_u *)"light";
4095}
4096
4097/*
4098 * Option initializations that can only be done after opening the GUI window.
4099 */
4100 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004101init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102{
4103 /* Set the 'background' option according to the lightness of the
4104 * background color, unless the user has set it already. */
4105 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4106 {
4107 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4108 highlight_changed();
4109 }
4110}
4111#endif
4112
4113#ifdef FEAT_TITLE
4114/*
4115 * 'title' and 'icon' only default to true if they have not been set or reset
4116 * in .vimrc and we can read the old value.
4117 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4118 * they can be reset. This reduces startup time when using X on a remote
4119 * machine.
4120 */
4121 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004122set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004123{
4124 int idx1;
4125 long val;
4126
4127 /*
4128 * If GUI is (going to be) used, we can always set the window title and
4129 * icon name. Saves a bit of time, because the X11 display server does
4130 * not need to be contacted.
4131 */
4132 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004133 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 {
4135#ifdef FEAT_GUI
4136 if (gui.starting || gui.in_use)
4137 val = TRUE;
4138 else
4139#endif
4140 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004141 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004142 p_title = val;
4143 }
4144 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004145 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004146 {
4147#ifdef FEAT_GUI
4148 if (gui.starting || gui.in_use)
4149 val = TRUE;
4150 else
4151#endif
4152 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004153 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154 p_icon = val;
4155 }
4156}
4157#endif
4158
4159/*
4160 * Parse 'arg' for option settings.
4161 *
4162 * 'arg' may be IObuff, but only when no errors can be present and option
4163 * does not need to be expanded with option_expand().
4164 * "opt_flags":
4165 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004166 * OPT_GLOBAL for ":setglobal"
4167 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004168 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004169 * OPT_WINONLY to only set window-local options
4170 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004171 *
4172 * returns FAIL if an error is detected, OK otherwise
4173 */
4174 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004175do_set(
4176 char_u *arg, /* option string (may be written to!) */
4177 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004178{
4179 int opt_idx;
4180 char_u *errmsg;
4181 char_u errbuf[80];
4182 char_u *startarg;
4183 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4184 int nextchar; /* next non-white char after option name */
4185 int afterchar; /* character just after option name */
4186 int len;
4187 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004188 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189 int key;
4190 long_u flags; /* flags for current option */
4191 char_u *varp = NULL; /* pointer to variable for current option */
4192 int did_show = FALSE; /* already showed one value */
4193 int adding; /* "opt+=arg" */
4194 int prepending; /* "opt^=arg" */
4195 int removing; /* "opt-=arg" */
4196 int cp_val = 0;
4197 char_u key_name[2];
4198
4199 if (*arg == NUL)
4200 {
4201 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004202 did_show = TRUE;
4203 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004204 }
4205
4206 while (*arg != NUL) /* loop to process all options */
4207 {
4208 errmsg = NULL;
4209 startarg = arg; /* remember for error message */
4210
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004211 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4212 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213 {
4214 /*
4215 * ":set all" show all options.
4216 * ":set all&" set all options to their default value.
4217 */
4218 arg += 3;
4219 if (*arg == '&')
4220 {
4221 ++arg;
4222 /* Only for :set command set global value of local options. */
4223 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004224 didset_options();
4225 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004226 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004227 }
4228 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004229 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004230 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004231 did_show = TRUE;
4232 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004233 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004234 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004235 {
4236 showoptions(2, opt_flags);
4237 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004238 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239 arg += 7;
4240 }
4241 else
4242 {
4243 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004244 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004245 {
4246 prefix = 0;
4247 arg += 2;
4248 }
4249 else if (STRNCMP(arg, "inv", 3) == 0)
4250 {
4251 prefix = 2;
4252 arg += 3;
4253 }
4254
4255 /* find end of name */
4256 key = 0;
4257 if (*arg == '<')
4258 {
4259 nextchar = 0;
4260 opt_idx = -1;
4261 /* look out for <t_>;> */
4262 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4263 len = 5;
4264 else
4265 {
4266 len = 1;
4267 while (arg[len] != NUL && arg[len] != '>')
4268 ++len;
4269 }
4270 if (arg[len] != '>')
4271 {
4272 errmsg = e_invarg;
4273 goto skip;
4274 }
4275 arg[len] = NUL; /* put NUL after name */
4276 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4277 opt_idx = findoption(arg + 1);
4278 arg[len++] = '>'; /* restore '>' */
4279 if (opt_idx == -1)
4280 key = find_key_option(arg + 1);
4281 }
4282 else
4283 {
4284 len = 0;
4285 /*
4286 * The two characters after "t_" may not be alphanumeric.
4287 */
4288 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4289 len = 4;
4290 else
4291 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4292 ++len;
4293 nextchar = arg[len];
4294 arg[len] = NUL; /* put NUL after name */
4295 opt_idx = findoption(arg);
4296 arg[len] = nextchar; /* restore nextchar */
4297 if (opt_idx == -1)
4298 key = find_key_option(arg);
4299 }
4300
4301 /* remember character after option name */
4302 afterchar = arg[len];
4303
4304 /* skip white space, allow ":set ai ?" */
4305 while (vim_iswhite(arg[len]))
4306 ++len;
4307
4308 adding = FALSE;
4309 prepending = FALSE;
4310 removing = FALSE;
4311 if (arg[len] != NUL && arg[len + 1] == '=')
4312 {
4313 if (arg[len] == '+')
4314 {
4315 adding = TRUE; /* "+=" */
4316 ++len;
4317 }
4318 else if (arg[len] == '^')
4319 {
4320 prepending = TRUE; /* "^=" */
4321 ++len;
4322 }
4323 else if (arg[len] == '-')
4324 {
4325 removing = TRUE; /* "-=" */
4326 ++len;
4327 }
4328 }
4329 nextchar = arg[len];
4330
4331 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4332 {
4333 errmsg = (char_u *)N_("E518: Unknown option");
4334 goto skip;
4335 }
4336
4337 if (opt_idx >= 0)
4338 {
4339 if (options[opt_idx].var == NULL) /* hidden option: skip */
4340 {
4341 /* Only give an error message when requesting the value of
4342 * a hidden option, ignore setting it. */
4343 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4344 && (!(options[opt_idx].flags & P_BOOL)
4345 || nextchar == '?'))
4346 errmsg = (char_u *)N_("E519: Option not supported");
4347 goto skip;
4348 }
4349
4350 flags = options[opt_idx].flags;
4351 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4352 }
4353 else
4354 {
4355 flags = P_STRING;
4356 if (key < 0)
4357 {
4358 key_name[0] = KEY2TERMCAP0(key);
4359 key_name[1] = KEY2TERMCAP1(key);
4360 }
4361 else
4362 {
4363 key_name[0] = KS_KEY;
4364 key_name[1] = (key & 0xff);
4365 }
4366 }
4367
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004368 /* Skip all options that are not window-local (used when showing
4369 * an already loaded buffer in a window). */
4370 if ((opt_flags & OPT_WINONLY)
4371 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4372 goto skip;
4373
Bram Moolenaara3227e22006-03-08 21:32:40 +00004374 /* Skip all options that are window-local (used for :vimgrep). */
4375 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4376 && options[opt_idx].var == VAR_WIN)
4377 goto skip;
4378
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004379 /* Disallow changing some options from modelines. */
4380 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004381 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004382 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004383 {
4384 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4385 goto skip;
4386 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004387#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004388 /* In diff mode some options are overruled. This avoids that
4389 * 'foldmethod' becomes "marker" instead of "diff" and that
4390 * "wrap" gets set. */
4391 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004392 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004393 && (options[opt_idx].indir == PV_FDM
4394 || options[opt_idx].indir == PV_WRAP))
4395 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004396#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004397 }
4398
4399#ifdef HAVE_SANDBOX
4400 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004401 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004402 {
4403 errmsg = (char_u *)_(e_sandbox);
4404 goto skip;
4405 }
4406#endif
4407
4408 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4409 {
4410 arg += len;
4411 cp_val = p_cp;
4412 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4413 {
4414 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4415 {
4416 cp_val = FALSE;
4417 arg += 3;
4418 }
4419 else /* "opt&vi": set to Vi default */
4420 {
4421 cp_val = TRUE;
4422 arg += 2;
4423 }
4424 }
4425 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4426 && arg[1] != NUL && !vim_iswhite(arg[1]))
4427 {
4428 errmsg = e_trailing;
4429 goto skip;
4430 }
4431 }
4432
4433 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004434 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4435 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004436 */
4437 if (nextchar == '?'
4438 || (prefix == 1
4439 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4440 && !(flags & P_BOOL)))
4441 {
4442 /*
4443 * print value
4444 */
4445 if (did_show)
4446 msg_putchar('\n'); /* cursor below last one */
4447 else
4448 {
4449 gotocmdline(TRUE); /* cursor at status line */
4450 did_show = TRUE; /* remember that we did a line */
4451 }
4452 if (opt_idx >= 0)
4453 {
4454 showoneopt(&options[opt_idx], opt_flags);
4455#ifdef FEAT_EVAL
4456 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004457 {
4458 /* Mention where the option was last set. */
4459 if (varp == options[opt_idx].var)
4460 last_set_msg(options[opt_idx].scriptID);
4461 else if ((int)options[opt_idx].indir & PV_WIN)
4462 last_set_msg(curwin->w_p_scriptID[
4463 (int)options[opt_idx].indir & PV_MASK]);
4464 else if ((int)options[opt_idx].indir & PV_BUF)
4465 last_set_msg(curbuf->b_p_scriptID[
4466 (int)options[opt_idx].indir & PV_MASK]);
4467 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004468#endif
4469 }
4470 else
4471 {
4472 char_u *p;
4473
4474 p = find_termcode(key_name);
4475 if (p == NULL)
4476 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004477 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004478 goto skip;
4479 }
4480 else
4481 (void)show_one_termcode(key_name, p, TRUE);
4482 }
4483 if (nextchar != '?'
4484 && nextchar != NUL && !vim_iswhite(afterchar))
4485 errmsg = e_trailing;
4486 }
4487 else
4488 {
4489 if (flags & P_BOOL) /* boolean */
4490 {
4491 if (nextchar == '=' || nextchar == ':')
4492 {
4493 errmsg = e_invarg;
4494 goto skip;
4495 }
4496
4497 /*
4498 * ":set opt!": invert
4499 * ":set opt&": reset to default value
4500 * ":set opt<": reset to global value
4501 */
4502 if (nextchar == '!')
4503 value = *(int *)(varp) ^ 1;
4504 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004505 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004506 ((flags & P_VI_DEF) || cp_val)
4507 ? VI_DEFAULT : VIM_DEFAULT];
4508 else if (nextchar == '<')
4509 {
4510 /* For 'autoread' -1 means to use global value. */
4511 if ((int *)varp == &curbuf->b_p_ar
4512 && opt_flags == OPT_LOCAL)
4513 value = -1;
4514 else
4515 value = *(int *)get_varp_scope(&(options[opt_idx]),
4516 OPT_GLOBAL);
4517 }
4518 else
4519 {
4520 /*
4521 * ":set invopt": invert
4522 * ":set opt" or ":set noopt": set or reset
4523 */
4524 if (nextchar != NUL && !vim_iswhite(afterchar))
4525 {
4526 errmsg = e_trailing;
4527 goto skip;
4528 }
4529 if (prefix == 2) /* inv */
4530 value = *(int *)(varp) ^ 1;
4531 else
4532 value = prefix;
4533 }
4534
4535 errmsg = set_bool_option(opt_idx, varp, (int)value,
4536 opt_flags);
4537 }
4538 else /* numeric or string */
4539 {
4540 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4541 || prefix != 1)
4542 {
4543 errmsg = e_invarg;
4544 goto skip;
4545 }
4546
4547 if (flags & P_NUM) /* numeric */
4548 {
4549 /*
4550 * Different ways to set a number option:
4551 * & set to default value
4552 * < set to global value
4553 * <xx> accept special key codes for 'wildchar'
4554 * c accept any non-digit for 'wildchar'
4555 * [-]0-9 set number
4556 * other error
4557 */
4558 ++arg;
4559 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004560 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004561 ((flags & P_VI_DEF) || cp_val)
4562 ? VI_DEFAULT : VIM_DEFAULT];
4563 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004564 {
4565 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4566 * use the global value. */
4567 if ((long *)varp == &curbuf->b_p_ul
4568 && opt_flags == OPT_LOCAL)
4569 value = NO_LOCAL_UNDOLEVEL;
4570 else
4571 value = *(long *)get_varp_scope(
4572 &(options[opt_idx]), OPT_GLOBAL);
4573 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004574 else if (((long *)varp == &p_wc
4575 || (long *)varp == &p_wcm)
4576 && (*arg == '<'
4577 || *arg == '^'
4578 || ((!arg[1] || vim_iswhite(arg[1]))
4579 && !VIM_ISDIGIT(*arg))))
4580 {
4581 value = string_to_key(arg);
4582 if (value == 0 && (long *)varp != &p_wcm)
4583 {
4584 errmsg = e_invarg;
4585 goto skip;
4586 }
4587 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004588 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4589 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004590 /* Allow negative (for 'undolevels'), octal and
4591 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004592 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4593 &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004594 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4595 {
4596 errmsg = e_invarg;
4597 goto skip;
4598 }
4599 }
4600 else
4601 {
4602 errmsg = (char_u *)N_("E521: Number required after =");
4603 goto skip;
4604 }
4605
4606 if (adding)
4607 value = *(long *)varp + value;
4608 if (prepending)
4609 value = *(long *)varp * value;
4610 if (removing)
4611 value = *(long *)varp - value;
4612 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004613 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004614 }
4615 else if (opt_idx >= 0) /* string */
4616 {
4617 char_u *save_arg = NULL;
4618 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004619 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004620 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004621 char_u *origval = NULL;
4622#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4623 char_u *saved_origval = NULL;
4624#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004625 unsigned newlen;
4626 int comma;
4627 int bs;
4628 int new_value_alloced; /* new string option
4629 was allocated */
4630
4631 /* When using ":set opt=val" for a global option
4632 * with a local value the local value will be
4633 * reset, use the global value here. */
4634 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004635 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004636 varp = options[opt_idx].var;
4637
4638 /* The old value is kept until we are sure that the
4639 * new value is valid. */
4640 oldval = *(char_u **)varp;
4641 if (nextchar == '&') /* set to default val */
4642 {
4643 newval = options[opt_idx].def_val[
4644 ((flags & P_VI_DEF) || cp_val)
4645 ? VI_DEFAULT : VIM_DEFAULT];
4646 if ((char_u **)varp == &p_bg)
4647 {
4648 /* guess the value of 'background' */
4649#ifdef FEAT_GUI
4650 if (gui.in_use)
4651 newval = gui_bg_default();
4652 else
4653#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004654 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004655 }
4656
4657 /* expand environment variables and ~ (since the
4658 * default value was already expanded, only
4659 * required when an environment variable was set
4660 * later */
4661 if (newval == NULL)
4662 newval = empty_option;
4663 else
4664 {
4665 s = option_expand(opt_idx, newval);
4666 if (s == NULL)
4667 s = newval;
4668 newval = vim_strsave(s);
4669 }
4670 new_value_alloced = TRUE;
4671 }
4672 else if (nextchar == '<') /* set to global val */
4673 {
4674 newval = vim_strsave(*(char_u **)get_varp_scope(
4675 &(options[opt_idx]), OPT_GLOBAL));
4676 new_value_alloced = TRUE;
4677 }
4678 else
4679 {
4680 ++arg; /* jump to after the '=' or ':' */
4681
4682 /*
4683 * Set 'keywordprg' to ":help" if an empty
4684 * value was passed to :set by the user.
4685 * Misuse errbuf[] for the resulting string.
4686 */
4687 if (varp == (char_u *)&p_kp
4688 && (*arg == NUL || *arg == ' '))
4689 {
4690 STRCPY(errbuf, ":help");
4691 save_arg = arg;
4692 arg = errbuf;
4693 }
4694 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004695 * Convert 'backspace' number to string, for
4696 * adding, prepending and removing string.
4697 */
4698 else if (varp == (char_u *)&p_bs
4699 && VIM_ISDIGIT(**(char_u **)varp))
4700 {
4701 i = getdigits((char_u **)varp);
4702 switch (i)
4703 {
4704 case 0:
4705 *(char_u **)varp = empty_option;
4706 break;
4707 case 1:
4708 *(char_u **)varp = vim_strsave(
4709 (char_u *)"indent,eol");
4710 break;
4711 case 2:
4712 *(char_u **)varp = vim_strsave(
4713 (char_u *)"indent,eol,start");
4714 break;
4715 }
4716 vim_free(oldval);
4717 oldval = *(char_u **)varp;
4718 }
4719 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004720 * Convert 'whichwrap' number to string, for
4721 * backwards compatibility with Vim 3.0.
4722 * Misuse errbuf[] for the resulting string.
4723 */
4724 else if (varp == (char_u *)&p_ww
4725 && VIM_ISDIGIT(*arg))
4726 {
4727 *errbuf = NUL;
4728 i = getdigits(&arg);
4729 if (i & 1)
4730 STRCAT(errbuf, "b,");
4731 if (i & 2)
4732 STRCAT(errbuf, "s,");
4733 if (i & 4)
4734 STRCAT(errbuf, "h,l,");
4735 if (i & 8)
4736 STRCAT(errbuf, "<,>,");
4737 if (i & 16)
4738 STRCAT(errbuf, "[,],");
4739 if (*errbuf != NUL) /* remove trailing , */
4740 errbuf[STRLEN(errbuf) - 1] = NUL;
4741 save_arg = arg;
4742 arg = errbuf;
4743 }
4744 /*
4745 * Remove '>' before 'dir' and 'bdir', for
4746 * backwards compatibility with version 3.0
4747 */
4748 else if ( *arg == '>'
4749 && (varp == (char_u *)&p_dir
4750 || varp == (char_u *)&p_bdir))
4751 {
4752 ++arg;
4753 }
4754
4755 /* When setting the local value of a global
4756 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004757 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004758 && (opt_flags & OPT_LOCAL))
4759 origval = *(char_u **)get_varp(
4760 &options[opt_idx]);
4761 else
4762 origval = oldval;
4763
4764 /*
4765 * Copy the new string into allocated memory.
4766 * Can't use set_string_option_direct(), because
4767 * we need to remove the backslashes.
4768 */
4769 /* get a bit too much */
4770 newlen = (unsigned)STRLEN(arg) + 1;
4771 if (adding || prepending || removing)
4772 newlen += (unsigned)STRLEN(origval) + 1;
4773 newval = alloc(newlen);
4774 if (newval == NULL) /* out of mem, don't change */
4775 break;
4776 s = newval;
4777
4778 /*
4779 * Copy the string, skip over escaped chars.
4780 * For MS-DOS and WIN32 backslashes before normal
4781 * file name characters are not removed, and keep
4782 * backslash at start, for "\\machine\path", but
4783 * do remove it for "\\\\machine\\path".
4784 * The reverse is found in ExpandOldSetting().
4785 */
4786 while (*arg && !vim_iswhite(*arg))
4787 {
4788 if (*arg == '\\' && arg[1] != NUL
4789#ifdef BACKSLASH_IN_FILENAME
4790 && !((flags & P_EXPAND)
4791 && vim_isfilec(arg[1])
4792 && (arg[1] != '\\'
4793 || (s == newval
4794 && arg[2] != '\\')))
4795#endif
4796 )
4797 ++arg; /* remove backslash */
4798#ifdef FEAT_MBYTE
4799 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004800 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004801 {
4802 /* copy multibyte char */
4803 mch_memmove(s, arg, (size_t)i);
4804 arg += i;
4805 s += i;
4806 }
4807 else
4808#endif
4809 *s++ = *arg++;
4810 }
4811 *s = NUL;
4812
4813 /*
4814 * Expand environment variables and ~.
4815 * Don't do it when adding without inserting a
4816 * comma.
4817 */
4818 if (!(adding || prepending || removing)
4819 || (flags & P_COMMA))
4820 {
4821 s = option_expand(opt_idx, newval);
4822 if (s != NULL)
4823 {
4824 vim_free(newval);
4825 newlen = (unsigned)STRLEN(s) + 1;
4826 if (adding || prepending || removing)
4827 newlen += (unsigned)STRLEN(origval) + 1;
4828 newval = alloc(newlen);
4829 if (newval == NULL)
4830 break;
4831 STRCPY(newval, s);
4832 }
4833 }
4834
4835 /* locate newval[] in origval[] when removing it
4836 * and when adding to avoid duplicates */
4837 i = 0; /* init for GCC */
4838 if (removing || (flags & P_NODUP))
4839 {
4840 i = (int)STRLEN(newval);
4841 bs = 0;
4842 for (s = origval; *s; ++s)
4843 {
4844 if ((!(flags & P_COMMA)
4845 || s == origval
4846 || (s[-1] == ',' && !(bs & 1)))
4847 && STRNCMP(s, newval, i) == 0
4848 && (!(flags & P_COMMA)
4849 || s[i] == ','
4850 || s[i] == NUL))
4851 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004852 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01004853 * even number of backslashes or a single
4854 * backslash preceded by a comma before it
4855 * is recognized as a separator */
4856 if ((s > origval + 1
4857 && s[-1] == '\\'
4858 && s[-2] != ',')
4859 || (s == origval + 1
4860 && s[-1] == '\\'))
4861
Bram Moolenaar071d4272004-06-13 20:20:40 +00004862 ++bs;
4863 else
4864 bs = 0;
4865 }
4866
4867 /* do not add if already there */
4868 if ((adding || prepending) && *s)
4869 {
4870 prepending = FALSE;
4871 adding = FALSE;
4872 STRCPY(newval, origval);
4873 }
4874 }
4875
4876 /* concatenate the two strings; add a ',' if
4877 * needed */
4878 if (adding || prepending)
4879 {
4880 comma = ((flags & P_COMMA) && *origval != NUL
4881 && *newval != NUL);
4882 if (adding)
4883 {
4884 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004885 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01004886 if (comma && i > 1
4887 && (flags & P_ONECOMMA) == P_ONECOMMA
4888 && origval[i - 1] == ','
4889 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004890 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004891 mch_memmove(newval + i + comma, newval,
4892 STRLEN(newval) + 1);
4893 mch_memmove(newval, origval, (size_t)i);
4894 }
4895 else
4896 {
4897 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004898 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004899 }
4900 if (comma)
4901 newval[i] = ',';
4902 }
4903
4904 /* Remove newval[] from origval[]. (Note: "i" has
4905 * been set above and is used here). */
4906 if (removing)
4907 {
4908 STRCPY(newval, origval);
4909 if (*s)
4910 {
4911 /* may need to remove a comma */
4912 if (flags & P_COMMA)
4913 {
4914 if (s == origval)
4915 {
4916 /* include comma after string */
4917 if (s[i] == ',')
4918 ++i;
4919 }
4920 else
4921 {
4922 /* include comma before string */
4923 --s;
4924 ++i;
4925 }
4926 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004927 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004928 }
4929 }
4930
4931 if (flags & P_FLAGLIST)
4932 {
4933 /* Remove flags that appear twice. */
4934 for (s = newval; *s; ++s)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004935 {
4936 /* if options have P_FLAGLIST and
4937 * P_ONECOMMA such as 'whichwrap' */
4938 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004939 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004940 if (*s != ',' && *(s + 1) == ','
4941 && vim_strchr(s + 2, *s) != NULL)
4942 {
4943 /* Remove the duplicated value and
4944 * the next comma. */
4945 STRMOVE(s, s + 2);
4946 s -= 2;
4947 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004948 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004949 else
4950 {
4951 if ((!(flags & P_COMMA) || *s != ',')
4952 && vim_strchr(s + 1, *s) != NULL)
4953 {
4954 STRMOVE(s, s + 1);
4955 --s;
4956 }
4957 }
4958 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004959 }
4960
4961 if (save_arg != NULL) /* number for 'whichwrap' */
4962 arg = save_arg;
4963 new_value_alloced = TRUE;
4964 }
4965
4966 /* Set the new value. */
4967 *(char_u **)(varp) = newval;
4968
Bram Moolenaar53744302015-07-17 17:38:22 +02004969#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004970 if (!starting
4971# ifdef FEAT_CRYPT
4972 && options[opt_idx].indir != PV_KEY
4973# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004974 && origval != NULL)
4975 /* origval may be freed by
4976 * did_set_string_option(), make a copy. */
4977 saved_origval = vim_strsave(origval);
4978#endif
4979
Bram Moolenaar071d4272004-06-13 20:20:40 +00004980 /* Handle side effects, and set the global value for
4981 * ":set" on local options. */
4982 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4983 new_value_alloced, oldval, errbuf, opt_flags);
4984
4985 /* If error detected, print the error message. */
4986 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01004987 {
4988#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4989 vim_free(saved_origval);
4990#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004991 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01004992 }
Bram Moolenaar53744302015-07-17 17:38:22 +02004993#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4994 if (saved_origval != NULL)
4995 {
4996 char_u buf_type[7];
4997
4998 sprintf((char *)buf_type, "%s",
4999 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005000 set_vim_var_string(VV_OPTION_NEW,
5001 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005002 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
5003 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5004 apply_autocmds(EVENT_OPTIONSET,
5005 (char_u *)options[opt_idx].fullname,
5006 NULL, FALSE, NULL);
5007 reset_v_option_vars();
5008 vim_free(saved_origval);
5009 }
5010#endif
5011
Bram Moolenaar071d4272004-06-13 20:20:40 +00005012 }
5013 else /* key code option */
5014 {
5015 char_u *p;
5016
5017 if (nextchar == '&')
5018 {
5019 if (add_termcap_entry(key_name, TRUE) == FAIL)
5020 errmsg = (char_u *)N_("E522: Not found in termcap");
5021 }
5022 else
5023 {
5024 ++arg; /* jump to after the '=' or ':' */
5025 for (p = arg; *p && !vim_iswhite(*p); ++p)
5026 if (*p == '\\' && p[1] != NUL)
5027 ++p;
5028 nextchar = *p;
5029 *p = NUL;
5030 add_termcode(key_name, arg, FALSE);
5031 *p = nextchar;
5032 }
5033 if (full_screen)
5034 ttest(FALSE);
5035 redraw_all_later(CLEAR);
5036 }
5037 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005038
Bram Moolenaar071d4272004-06-13 20:20:40 +00005039 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005040 did_set_option(opt_idx, opt_flags,
5041 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005042 }
5043
5044skip:
5045 /*
5046 * Advance to next argument.
5047 * - skip until a blank found, taking care of backslashes
5048 * - skip blanks
5049 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5050 */
5051 for (i = 0; i < 2 ; ++i)
5052 {
5053 while (*arg != NUL && !vim_iswhite(*arg))
5054 if (*arg++ == '\\' && *arg != NUL)
5055 ++arg;
5056 arg = skipwhite(arg);
5057 if (*arg != '=')
5058 break;
5059 }
5060 }
5061
5062 if (errmsg != NULL)
5063 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005064 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005065 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005066 if (i + (arg - startarg) < IOSIZE)
5067 {
5068 /* append the argument with the error */
5069 STRCAT(IObuff, ": ");
5070 mch_memmove(IObuff + i, startarg, (arg - startarg));
5071 IObuff[i + (arg - startarg)] = NUL;
5072 }
5073 /* make sure all characters are printable */
5074 trans_characters(IObuff, IOSIZE);
5075
5076 ++no_wait_return; /* wait_return done later */
5077 emsg(IObuff); /* show error highlighted */
5078 --no_wait_return;
5079
5080 return FAIL;
5081 }
5082
5083 arg = skipwhite(arg);
5084 }
5085
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005086theend:
5087 if (silent_mode && did_show)
5088 {
5089 /* After displaying option values in silent mode. */
5090 silent_mode = FALSE;
5091 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5092 msg_putchar('\n');
5093 cursor_on(); /* msg_start() switches it off */
5094 out_flush();
5095 silent_mode = TRUE;
5096 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5097 }
5098
Bram Moolenaar071d4272004-06-13 20:20:40 +00005099 return OK;
5100}
5101
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005102/*
5103 * Call this when an option has been given a new value through a user command.
5104 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5105 */
5106 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005107did_set_option(
5108 int opt_idx,
5109 int opt_flags, /* possibly with OPT_MODELINE */
5110 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005111{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005112 long_u *p;
5113
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005114 options[opt_idx].flags |= P_WAS_SET;
5115
5116 /* When an option is set in the sandbox, from a modeline or in secure mode
5117 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005118 * flag. */
5119 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005120 if (secure
5121#ifdef HAVE_SANDBOX
5122 || sandbox != 0
5123#endif
5124 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005125 *p = *p | P_INSECURE;
5126 else if (new_value)
5127 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005128}
5129
Bram Moolenaar071d4272004-06-13 20:20:40 +00005130 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005131illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005132{
5133 if (errbuf == NULL)
5134 return (char_u *)"";
5135 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005136 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005137 return errbuf;
5138}
5139
5140/*
5141 * Convert a key name or string into a key value.
5142 * Used for 'wildchar' and 'cedit' options.
5143 */
5144 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005145string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005146{
5147 if (*arg == '<')
5148 return find_key_option(arg + 1);
5149 if (*arg == '^')
5150 return Ctrl_chr(arg[1]);
5151 return *arg;
5152}
5153
5154#ifdef FEAT_CMDWIN
5155/*
5156 * Check value of 'cedit' and set cedit_key.
5157 * Returns NULL if value is OK, error message otherwise.
5158 */
5159 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005160check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005161{
5162 int n;
5163
5164 if (*p_cedit == NUL)
5165 cedit_key = -1;
5166 else
5167 {
5168 n = string_to_key(p_cedit);
5169 if (vim_isprintc(n))
5170 return e_invarg;
5171 cedit_key = n;
5172 }
5173 return NULL;
5174}
5175#endif
5176
5177#ifdef FEAT_TITLE
5178/*
5179 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5180 * maketitle() to create and display it.
5181 * When switching the title or icon off, call mch_restore_title() to get
5182 * the old value back.
5183 */
5184 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005185did_set_title(
5186 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005187{
5188 if (starting != NO_SCREEN
5189#ifdef FEAT_GUI
5190 && !gui.starting
5191#endif
5192 )
5193 {
5194 maketitle();
5195 if (icon)
5196 {
5197 if (!p_icon)
5198 mch_restore_title(2);
5199 }
5200 else
5201 {
5202 if (!p_title)
5203 mch_restore_title(1);
5204 }
5205 }
5206}
5207#endif
5208
5209/*
5210 * set_options_bin - called when 'bin' changes value.
5211 */
5212 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005213set_options_bin(
5214 int oldval,
5215 int newval,
5216 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005217{
5218 /*
5219 * The option values that are changed when 'bin' changes are
5220 * copied when 'bin is set and restored when 'bin' is reset.
5221 */
5222 if (newval)
5223 {
5224 if (!oldval) /* switched on */
5225 {
5226 if (!(opt_flags & OPT_GLOBAL))
5227 {
5228 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5229 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5230 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5231 curbuf->b_p_et_nobin = curbuf->b_p_et;
5232 }
5233 if (!(opt_flags & OPT_LOCAL))
5234 {
5235 p_tw_nobin = p_tw;
5236 p_wm_nobin = p_wm;
5237 p_ml_nobin = p_ml;
5238 p_et_nobin = p_et;
5239 }
5240 }
5241
5242 if (!(opt_flags & OPT_GLOBAL))
5243 {
5244 curbuf->b_p_tw = 0; /* no automatic line wrap */
5245 curbuf->b_p_wm = 0; /* no automatic line wrap */
5246 curbuf->b_p_ml = 0; /* no modelines */
5247 curbuf->b_p_et = 0; /* no expandtab */
5248 }
5249 if (!(opt_flags & OPT_LOCAL))
5250 {
5251 p_tw = 0;
5252 p_wm = 0;
5253 p_ml = FALSE;
5254 p_et = FALSE;
5255 p_bin = TRUE; /* needed when called for the "-b" argument */
5256 }
5257 }
5258 else if (oldval) /* switched off */
5259 {
5260 if (!(opt_flags & OPT_GLOBAL))
5261 {
5262 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5263 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5264 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5265 curbuf->b_p_et = curbuf->b_p_et_nobin;
5266 }
5267 if (!(opt_flags & OPT_LOCAL))
5268 {
5269 p_tw = p_tw_nobin;
5270 p_wm = p_wm_nobin;
5271 p_ml = p_ml_nobin;
5272 p_et = p_et_nobin;
5273 }
5274 }
5275}
5276
5277#ifdef FEAT_VIMINFO
5278/*
5279 * Find the parameter represented by the given character (eg ', :, ", or /),
5280 * and return its associated value in the 'viminfo' string.
5281 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005282 * If the parameter is not specified in the string or there is no following
5283 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005284 */
5285 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005286get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005287{
5288 char_u *p;
5289
5290 p = find_viminfo_parameter(type);
5291 if (p != NULL && VIM_ISDIGIT(*p))
5292 return atoi((char *)p);
5293 return -1;
5294}
5295
5296/*
5297 * Find the parameter represented by the given character (eg ''', ':', '"', or
5298 * '/') in the 'viminfo' option and return a pointer to the string after it.
5299 * Return NULL if the parameter is not specified in the string.
5300 */
5301 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005302find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005303{
5304 char_u *p;
5305
5306 for (p = p_viminfo; *p; ++p)
5307 {
5308 if (*p == type)
5309 return p + 1;
5310 if (*p == 'n') /* 'n' is always the last one */
5311 break;
5312 p = vim_strchr(p, ','); /* skip until next ',' */
5313 if (p == NULL) /* hit the end without finding parameter */
5314 break;
5315 }
5316 return NULL;
5317}
5318#endif
5319
5320/*
5321 * Expand environment variables for some string options.
5322 * These string options cannot be indirect!
5323 * If "val" is NULL expand the current value of the option.
5324 * Return pointer to NameBuff, or NULL when not expanded.
5325 */
5326 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005327option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005328{
5329 /* if option doesn't need expansion nothing to do */
5330 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5331 return NULL;
5332
5333 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5334 * expand_env() would truncate the string. */
5335 if (val != NULL && STRLEN(val) > MAXPATHL)
5336 return NULL;
5337
5338 if (val == NULL)
5339 val = *(char_u **)options[opt_idx].var;
5340
5341 /*
5342 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5343 * Escape spaces when expanding 'tags', they are used to separate file
5344 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005345 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005346 */
5347 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005348 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005349#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005350 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5351#endif
5352 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005353 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5354 return NULL;
5355
5356 return NameBuff;
5357}
5358
5359/*
5360 * After setting various option values: recompute variables that depend on
5361 * option values.
5362 */
5363 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005364didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005365{
5366 /* initialize the table for 'iskeyword' et.al. */
5367 (void)init_chartab();
5368
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005369#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005370 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005371#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005372 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005373 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005374#ifdef FEAT_SESSION
5375 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5376 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5377#endif
5378#ifdef FEAT_FOLDING
5379 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5380#endif
5381 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005382 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005383#ifdef FEAT_VIRTUALEDIT
5384 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5385#endif
5386#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5387 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5388#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005389#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005390 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005391 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005392 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005393 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005394#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005395#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5396 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5397#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005398#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005399 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5400#endif
5401#ifdef FEAT_CMDWIN
5402 /* set cedit_key */
5403 (void)check_cedit();
5404#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005405#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005406 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005407#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005408#ifdef FEAT_LINEBREAK
5409 /* initialize the table for 'breakat'. */
5410 fill_breakat_flags();
5411#endif
5412
5413}
5414
5415/*
5416 * More side effects of setting options.
5417 */
5418 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005419didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005420{
5421 /* Initialize the highlight_attr[] table. */
5422 (void)highlight_changed();
5423
5424 /* Parse default for 'wildmode' */
5425 check_opt_wim();
5426
5427 (void)set_chars_option(&p_lcs);
5428#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5429 /* Parse default for 'fillchars'. */
5430 (void)set_chars_option(&p_fcs);
5431#endif
5432
5433#ifdef FEAT_CLIPBOARD
5434 /* Parse default for 'clipboard' */
5435 (void)check_clipboard_option();
5436#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005437}
5438
5439/*
5440 * Check for string options that are NULL (normally only termcap options).
5441 */
5442 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005443check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005444{
5445 int opt_idx;
5446
5447 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5448 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5449 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5450}
5451
5452/*
5453 * Check string options in a buffer for NULL value.
5454 */
5455 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005456check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005457{
5458#if defined(FEAT_QUICKFIX)
5459 check_string_option(&buf->b_p_bh);
5460 check_string_option(&buf->b_p_bt);
5461#endif
5462#ifdef FEAT_MBYTE
5463 check_string_option(&buf->b_p_fenc);
5464#endif
5465 check_string_option(&buf->b_p_ff);
5466#ifdef FEAT_FIND_ID
5467 check_string_option(&buf->b_p_def);
5468 check_string_option(&buf->b_p_inc);
5469# ifdef FEAT_EVAL
5470 check_string_option(&buf->b_p_inex);
5471# endif
5472#endif
5473#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5474 check_string_option(&buf->b_p_inde);
5475 check_string_option(&buf->b_p_indk);
5476#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005477#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5478 check_string_option(&buf->b_p_bexpr);
5479#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005480#if defined(FEAT_CRYPT)
5481 check_string_option(&buf->b_p_cm);
5482#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005483#if defined(FEAT_EVAL)
5484 check_string_option(&buf->b_p_fex);
5485#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005486#ifdef FEAT_CRYPT
5487 check_string_option(&buf->b_p_key);
5488#endif
5489 check_string_option(&buf->b_p_kp);
5490 check_string_option(&buf->b_p_mps);
5491 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005492 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005493 check_string_option(&buf->b_p_isk);
5494#ifdef FEAT_COMMENTS
5495 check_string_option(&buf->b_p_com);
5496#endif
5497#ifdef FEAT_FOLDING
5498 check_string_option(&buf->b_p_cms);
5499#endif
5500 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005501#ifdef FEAT_TEXTOBJ
5502 check_string_option(&buf->b_p_qe);
5503#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005504#ifdef FEAT_SYN_HL
5505 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005506 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005507#endif
5508#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005509 check_string_option(&buf->b_s.b_p_spc);
5510 check_string_option(&buf->b_s.b_p_spf);
5511 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005512#endif
5513#ifdef FEAT_SEARCHPATH
5514 check_string_option(&buf->b_p_sua);
5515#endif
5516#ifdef FEAT_CINDENT
5517 check_string_option(&buf->b_p_cink);
5518 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005519 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005520#endif
5521#ifdef FEAT_AUTOCMD
5522 check_string_option(&buf->b_p_ft);
5523#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005524#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5525 check_string_option(&buf->b_p_cinw);
5526#endif
5527#ifdef FEAT_INS_EXPAND
5528 check_string_option(&buf->b_p_cpt);
5529#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005530#ifdef FEAT_COMPL_FUNC
5531 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005532 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005533#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005534#ifdef FEAT_KEYMAP
5535 check_string_option(&buf->b_p_keymap);
5536#endif
5537#ifdef FEAT_QUICKFIX
5538 check_string_option(&buf->b_p_gp);
5539 check_string_option(&buf->b_p_mp);
5540 check_string_option(&buf->b_p_efm);
5541#endif
5542 check_string_option(&buf->b_p_ep);
5543 check_string_option(&buf->b_p_path);
5544 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005545 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005546#ifdef FEAT_INS_EXPAND
5547 check_string_option(&buf->b_p_dict);
5548 check_string_option(&buf->b_p_tsr);
5549#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005550#ifdef FEAT_LISP
5551 check_string_option(&buf->b_p_lw);
5552#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005553 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005554}
5555
5556/*
5557 * Free the string allocated for an option.
5558 * Checks for the string being empty_option. This may happen if we're out of
5559 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5560 * check_options().
5561 * Does NOT check for P_ALLOCED flag!
5562 */
5563 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005564free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005565{
5566 if (p != empty_option)
5567 vim_free(p);
5568}
5569
5570 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005571clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005572{
5573 if (*pp != empty_option)
5574 vim_free(*pp);
5575 *pp = empty_option;
5576}
5577
5578 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005579check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005580{
5581 if (*pp == NULL)
5582 *pp = empty_option;
5583}
5584
5585/*
5586 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5587 */
5588 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005589set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005590{
5591 int opt_idx;
5592
5593 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5594 if (options[opt_idx].var == (char_u *)p)
5595 {
5596 options[opt_idx].flags |= P_ALLOCED;
5597 return;
5598 }
5599 return; /* cannot happen: didn't find it! */
5600}
5601
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005602#if defined(FEAT_EVAL) || defined(PROTO)
5603/*
5604 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5605 * Return FALSE when it wasn't.
5606 * Return -1 for an unknown option.
5607 */
5608 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005609was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005610{
5611 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005612 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005613
5614 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005615 {
5616 flagp = insecure_flag(idx, opt_flags);
5617 return (*flagp & P_INSECURE) != 0;
5618 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005619 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005620 return -1;
5621}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005622
5623/*
5624 * Get a pointer to the flags used for the P_INSECURE flag of option
5625 * "opt_idx". For some local options a local flags field is used.
5626 */
5627 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005628insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005629{
5630 if (opt_flags & OPT_LOCAL)
5631 switch ((int)options[opt_idx].indir)
5632 {
5633#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005634 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005635#endif
5636#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005637# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005638 case PV_FDE: return &curwin->w_p_fde_flags;
5639 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005640# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005641# ifdef FEAT_BEVAL
5642 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5643# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005644# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005645 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005646# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005647 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005648# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005649 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005650# endif
5651#endif
5652 }
5653
5654 /* Nothing special, return global flags field. */
5655 return &options[opt_idx].flags;
5656}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005657#endif
5658
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005659#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005660static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005661
5662/*
5663 * Redraw the window title and/or tab page text later.
5664 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005665static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005666{
5667 need_maketitle = TRUE;
5668# ifdef FEAT_WINDOWS
5669 redraw_tabline = TRUE;
5670# endif
5671}
5672#endif
5673
Bram Moolenaar071d4272004-06-13 20:20:40 +00005674/*
5675 * Set a string option to a new value (without checking the effect).
5676 * The string is copied into allocated memory.
5677 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005678 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005679 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005680 */
5681 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005682set_string_option_direct(
5683 char_u *name,
5684 int opt_idx,
5685 char_u *val,
5686 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5687 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005688{
5689 char_u *s;
5690 char_u **varp;
5691 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005692 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005693
Bram Moolenaar89d40322006-08-29 15:30:07 +00005694 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005695 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005696 idx = findoption(name);
5697 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005698 {
5699 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005700 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005701 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005702 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005703 }
5704
Bram Moolenaar89d40322006-08-29 15:30:07 +00005705 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005706 return;
5707
5708 s = vim_strsave(val);
5709 if (s != NULL)
5710 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005711 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005712 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005713 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005714 free_string_option(*varp);
5715 *varp = s;
5716
5717 /* For buffer/window local option may also set the global value. */
5718 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005719 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005720
Bram Moolenaar89d40322006-08-29 15:30:07 +00005721 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005722
5723 /* When setting both values of a global option with a local value,
5724 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005725 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005726 {
5727 free_string_option(*varp);
5728 *varp = empty_option;
5729 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005730# ifdef FEAT_EVAL
5731 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005732 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005733 set_sid == 0 ? current_SID : set_sid);
5734# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005735 }
5736}
5737
5738/*
5739 * Set global value for string option when it's a local option.
5740 */
5741 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005742set_string_option_global(
5743 int opt_idx, /* option index */
5744 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005745{
5746 char_u **p, *s;
5747
5748 /* the global value is always allocated */
5749 if (options[opt_idx].var == VAR_WIN)
5750 p = (char_u **)GLOBAL_WO(varp);
5751 else
5752 p = (char_u **)options[opt_idx].var;
5753 if (options[opt_idx].indir != PV_NONE
5754 && p != varp
5755 && (s = vim_strsave(*varp)) != NULL)
5756 {
5757 free_string_option(*p);
5758 *p = s;
5759 }
5760}
5761
5762/*
5763 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005764 *
5765 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005766 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005767 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005768set_string_option(
5769 int opt_idx,
5770 char_u *value,
5771 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005772{
5773 char_u *s;
5774 char_u **varp;
5775 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005776#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5777 char_u *saved_oldval = NULL;
5778#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005779 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005780
5781 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005782 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005783
5784 s = vim_strsave(value);
5785 if (s != NULL)
5786 {
5787 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5788 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005789 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005790 ? OPT_GLOBAL : OPT_LOCAL)
5791 : opt_flags);
5792 oldval = *varp;
5793 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005794
5795#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005796 if (!starting
5797# ifdef FEAT_CRYPT
5798 && options[opt_idx].indir != PV_KEY
5799# endif
5800 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005801 saved_oldval = vim_strsave(oldval);
5802#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005803 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5804 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005805 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005806
5807 /* call autocomamnd after handling side effects */
5808#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5809 if (saved_oldval != NULL)
5810 {
5811 char_u buf_type[7];
5812 sprintf((char *)buf_type, "%s",
5813 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005814 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5815 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005816 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5817 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5818 reset_v_option_vars();
5819 vim_free(saved_oldval);
5820 }
5821#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005822 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005823 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005824}
5825
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005826#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005827/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01005828 * Return TRUE if "val" is a valid 'filetype' name.
5829 * Also used for 'syntax' and 'keymap'.
5830 */
5831 static int
5832valid_filetype(char_u *val)
5833{
5834 char_u *s;
5835
5836 for (s = val; *s != NUL; ++s)
5837 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
5838 return FALSE;
5839 return TRUE;
5840}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005841#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01005842
5843/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00005844 * Handle string options that need some action to perform when changed.
5845 * Returns NULL for success, or an error message for an error.
5846 */
5847 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005848did_set_string_option(
5849 int opt_idx, /* index in options[] table */
5850 char_u **varp, /* pointer to the option variable */
5851 int new_value_alloced, /* new value was allocated */
5852 char_u *oldval, /* previous value of the option */
5853 char_u *errbuf, /* buffer for errors, or NULL */
5854 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005855{
5856 char_u *errmsg = NULL;
5857 char_u *s, *p;
5858 int did_chartab = FALSE;
5859 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005860 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005861#ifdef FEAT_GUI
5862 /* set when changing an option that only requires a redraw in the GUI */
5863 int redraw_gui_only = FALSE;
5864#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005865
5866 /* Get the global option to compare with, otherwise we would have to check
5867 * two values for all local options. */
5868 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5869
5870 /* Disallow changing some options from secure mode */
5871 if ((secure
5872#ifdef HAVE_SANDBOX
5873 || sandbox != 0
5874#endif
5875 ) && (options[opt_idx].flags & P_SECURE))
5876 {
5877 errmsg = e_secure;
5878 }
5879
Bram Moolenaar7554da42016-11-25 22:04:13 +01005880 /* Check for a "normal" directory or file name in some options. Disallow a
5881 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01005882 * are often illegal in a file name. Be more permissive if "secure" is off.
5883 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01005884 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01005885 && vim_strpbrk(*varp, (char_u *)(secure
5886 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01005887 || ((options[opt_idx].flags & P_NDNAME)
5888 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005889 {
5890 errmsg = e_invarg;
5891 }
5892
Bram Moolenaar071d4272004-06-13 20:20:40 +00005893 /* 'term' */
5894 else if (varp == &T_NAME)
5895 {
5896 if (T_NAME[0] == NUL)
5897 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5898#ifdef FEAT_GUI
5899 if (gui.in_use)
5900 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5901 else if (term_is_gui(T_NAME))
5902 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5903#endif
5904 else if (set_termname(T_NAME) == FAIL)
5905 errmsg = (char_u *)N_("E522: Not found in termcap");
5906 else
5907 /* Screen colors may have changed. */
5908 redraw_later_clear();
5909 }
5910
5911 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005912 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005913 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005914 char_u *bkc = p_bkc;
5915 unsigned int *flags = &bkc_flags;
5916
5917 if (opt_flags & OPT_LOCAL)
5918 {
5919 bkc = curbuf->b_p_bkc;
5920 flags = &curbuf->b_bkc_flags;
5921 }
5922
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005923 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5924 /* make the local value empty: use the global value */
5925 *flags = 0;
5926 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005927 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005928 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5929 errmsg = e_invarg;
5930 if ((((int)*flags & BKC_AUTO) != 0)
5931 + (((int)*flags & BKC_YES) != 0)
5932 + (((int)*flags & BKC_NO) != 0) != 1)
5933 {
5934 /* Must have exactly one of "auto", "yes" and "no". */
5935 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5936 errmsg = e_invarg;
5937 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005938 }
5939 }
5940
5941 /* 'backupext' and 'patchmode' */
5942 else if (varp == &p_bex || varp == &p_pm)
5943 {
5944 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5945 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5946 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5947 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005948#ifdef FEAT_LINEBREAK
5949 /* 'breakindentopt' */
5950 else if (varp == &curwin->w_p_briopt)
5951 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005952 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005953 errmsg = e_invarg;
5954 }
5955#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005956
5957 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005958 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00005959 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005960 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00005961 */
5962 else if ( varp == &p_isi
5963 || varp == &(curbuf->b_p_isk)
5964 || varp == &p_isp
5965 || varp == &p_isf)
5966 {
5967 if (init_chartab() == FAIL)
5968 {
5969 did_chartab = TRUE; /* need to restore it below */
5970 errmsg = e_invarg; /* error in value */
5971 }
5972 }
5973
5974 /* 'helpfile' */
5975 else if (varp == &p_hf)
5976 {
5977 /* May compute new values for $VIM and $VIMRUNTIME */
5978 if (didset_vim)
5979 {
5980 vim_setenv((char_u *)"VIM", (char_u *)"");
5981 didset_vim = FALSE;
5982 }
5983 if (didset_vimruntime)
5984 {
5985 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5986 didset_vimruntime = FALSE;
5987 }
5988 }
5989
Bram Moolenaar1a384422010-07-14 19:53:30 +02005990#ifdef FEAT_SYN_HL
5991 /* 'colorcolumn' */
5992 else if (varp == &curwin->w_p_cc)
5993 errmsg = check_colorcolumn(curwin);
5994#endif
5995
Bram Moolenaar071d4272004-06-13 20:20:40 +00005996#ifdef FEAT_MULTI_LANG
5997 /* 'helplang' */
5998 else if (varp == &p_hlg)
5999 {
6000 /* Check for "", "ab", "ab,cd", etc. */
6001 for (s = p_hlg; *s != NUL; s += 3)
6002 {
6003 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6004 {
6005 errmsg = e_invarg;
6006 break;
6007 }
6008 if (s[2] == NUL)
6009 break;
6010 }
6011 }
6012#endif
6013
6014 /* 'highlight' */
6015 else if (varp == &p_hl)
6016 {
6017 if (highlight_changed() == FAIL)
6018 errmsg = e_invarg; /* invalid flags */
6019 }
6020
6021 /* 'nrformats' */
6022 else if (gvarp == &p_nf)
6023 {
6024 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6025 errmsg = e_invarg;
6026 }
6027
6028#ifdef FEAT_SESSION
6029 /* 'sessionoptions' */
6030 else if (varp == &p_ssop)
6031 {
6032 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6033 errmsg = e_invarg;
6034 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6035 {
6036 /* Don't allow both "sesdir" and "curdir". */
6037 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6038 errmsg = e_invarg;
6039 }
6040 }
6041 /* 'viewoptions' */
6042 else if (varp == &p_vop)
6043 {
6044 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6045 errmsg = e_invarg;
6046 }
6047#endif
6048
6049 /* 'scrollopt' */
6050#ifdef FEAT_SCROLLBIND
6051 else if (varp == &p_sbo)
6052 {
6053 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6054 errmsg = e_invarg;
6055 }
6056#endif
6057
6058 /* 'ambiwidth' */
6059#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006060 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006061 {
6062 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6063 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006064 else if (set_chars_option(&p_lcs) != NULL)
6065 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6066# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6067 else if (set_chars_option(&p_fcs) != NULL)
6068 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6069# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006070 }
6071#endif
6072
6073 /* 'background' */
6074 else if (varp == &p_bg)
6075 {
6076 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6077 {
6078#ifdef FEAT_EVAL
6079 int dark = (*p_bg == 'd');
6080#endif
6081
6082 init_highlight(FALSE, FALSE);
6083
6084#ifdef FEAT_EVAL
6085 if (dark != (*p_bg == 'd')
6086 && get_var_value((char_u *)"g:colors_name") != NULL)
6087 {
6088 /* The color scheme must have set 'background' back to another
6089 * value, that's not what we want here. Disable the color
6090 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006091 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006092 free_string_option(p_bg);
6093 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6094 check_string_option(&p_bg);
6095 init_highlight(FALSE, FALSE);
6096 }
6097#endif
6098 }
6099 else
6100 errmsg = e_invarg;
6101 }
6102
6103 /* 'wildmode' */
6104 else if (varp == &p_wim)
6105 {
6106 if (check_opt_wim() == FAIL)
6107 errmsg = e_invarg;
6108 }
6109
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006110#ifdef FEAT_CMDL_COMPL
6111 /* 'wildoptions' */
6112 else if (varp == &p_wop)
6113 {
6114 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6115 errmsg = e_invarg;
6116 }
6117#endif
6118
Bram Moolenaar071d4272004-06-13 20:20:40 +00006119#ifdef FEAT_WAK
6120 /* 'winaltkeys' */
6121 else if (varp == &p_wak)
6122 {
6123 if (*p_wak == NUL
6124 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6125 errmsg = e_invarg;
6126# ifdef FEAT_MENU
6127# ifdef FEAT_GUI_MOTIF
6128 else if (gui.in_use)
6129 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6130# else
6131# ifdef FEAT_GUI_GTK
6132 else if (gui.in_use)
6133 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6134# endif
6135# endif
6136# endif
6137 }
6138#endif
6139
6140#ifdef FEAT_AUTOCMD
6141 /* 'eventignore' */
6142 else if (varp == &p_ei)
6143 {
6144 if (check_ei() == FAIL)
6145 errmsg = e_invarg;
6146 }
6147#endif
6148
6149#ifdef FEAT_MBYTE
6150 /* 'encoding' and 'fileencoding' */
6151 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6152 {
6153 if (gvarp == &p_fenc)
6154 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006155 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006156 errmsg = e_modifiable;
6157 else if (vim_strchr(*varp, ',') != NULL)
6158 /* No comma allowed in 'fileencoding'; catches confusing it
6159 * with 'fileencodings'. */
6160 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006161 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006162 {
6163# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006164 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006165 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006166# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006167 /* Add 'fileencoding' to the swap file. */
6168 ml_setflags(curbuf);
6169 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006170 }
6171 if (errmsg == NULL)
6172 {
6173 /* canonize the value, so that STRCMP() can be used on it */
6174 p = enc_canonize(*varp);
6175 if (p != NULL)
6176 {
6177 vim_free(*varp);
6178 *varp = p;
6179 }
6180 if (varp == &p_enc)
6181 {
6182 errmsg = mb_init();
6183# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006184 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006185# endif
6186 }
6187 }
6188
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006189# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006190 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6191 {
6192 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6193 if (STRCMP(p_tenc, "utf-8") != 0)
6194 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6195 }
6196# endif
6197
6198 if (errmsg == NULL)
6199 {
6200# ifdef FEAT_KEYMAP
6201 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6202 * (with another encoding). */
6203 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6204 (void)keymap_init();
6205# endif
6206
6207 /* When 'termencoding' is not empty and 'encoding' changes or when
6208 * 'termencoding' changes, need to setup for keyboard input and
6209 * display output conversion. */
6210 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6211 {
6212 convert_setup(&input_conv, p_tenc, p_enc);
6213 convert_setup(&output_conv, p_enc, p_tenc);
6214 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006215
6216# if defined(WIN3264) && defined(FEAT_MBYTE)
6217 /* $HOME may have characters in active code page. */
6218 if (varp == &p_enc)
6219 init_homedir();
6220# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006221 }
6222 }
6223#endif
6224
6225#if defined(FEAT_POSTSCRIPT)
6226 else if (varp == &p_penc)
6227 {
6228 /* Canonize printencoding if VIM standard one */
6229 p = enc_canonize(p_penc);
6230 if (p != NULL)
6231 {
6232 vim_free(p_penc);
6233 p_penc = p;
6234 }
6235 else
6236 {
6237 /* Ensure lower case and '-' for '_' */
6238 for (s = p_penc; *s != NUL; s++)
6239 {
6240 if (*s == '_')
6241 *s = '-';
6242 else
6243 *s = TOLOWER_ASC(*s);
6244 }
6245 }
6246 }
6247#endif
6248
Bram Moolenaar9372a112005-12-06 19:59:18 +00006249#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006250 else if (varp == &p_imak)
6251 {
6252 if (gui.in_use && !im_xim_isvalid_imactivate())
6253 errmsg = e_invarg;
6254 }
6255#endif
6256
6257#ifdef FEAT_KEYMAP
6258 else if (varp == &curbuf->b_p_keymap)
6259 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006260 if (!valid_filetype(*varp))
6261 errmsg = e_invarg;
6262 else
6263 /* load or unload key mapping tables */
6264 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006265
Bram Moolenaarfab06232009-03-04 03:13:35 +00006266 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006267 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006268 if (*curbuf->b_p_keymap != NUL)
6269 {
6270 /* Installed a new keymap, switch on using it. */
6271 curbuf->b_p_iminsert = B_IMODE_LMAP;
6272 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6273 curbuf->b_p_imsearch = B_IMODE_LMAP;
6274 }
6275 else
6276 {
6277 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6278 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6279 curbuf->b_p_iminsert = B_IMODE_NONE;
6280 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6281 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6282 }
6283 if ((opt_flags & OPT_LOCAL) == 0)
6284 {
6285 set_iminsert_global();
6286 set_imsearch_global();
6287 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006288# ifdef FEAT_WINDOWS
6289 status_redraw_curbuf();
6290# endif
6291 }
6292 }
6293#endif
6294
6295 /* 'fileformat' */
6296 else if (gvarp == &p_ff)
6297 {
6298 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6299 errmsg = e_modifiable;
6300 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6301 errmsg = e_invarg;
6302 else
6303 {
6304 /* may also change 'textmode' */
6305 if (get_fileformat(curbuf) == EOL_DOS)
6306 curbuf->b_p_tx = TRUE;
6307 else
6308 curbuf->b_p_tx = FALSE;
6309#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006310 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006311#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006312 /* update flag in swap file */
6313 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006314 /* Redraw needed when switching to/from "mac": a CR in the text
6315 * will be displayed differently. */
6316 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6317 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006318 }
6319 }
6320
6321 /* 'fileformats' */
6322 else if (varp == &p_ffs)
6323 {
6324 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6325 errmsg = e_invarg;
6326 else
6327 {
6328 /* also change 'textauto' */
6329 if (*p_ffs == NUL)
6330 p_ta = FALSE;
6331 else
6332 p_ta = TRUE;
6333 }
6334 }
6335
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006336#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006337 /* 'cryptkey' */
6338 else if (gvarp == &p_key)
6339 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006340# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006341 /* Make sure the ":set" command doesn't show the new value in the
6342 * history. */
6343 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006344# endif
6345 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6346 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006347 ml_set_crypt_key(curbuf, oldval,
6348 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006349 }
6350
6351 else if (gvarp == &p_cm)
6352 {
6353 if (opt_flags & OPT_LOCAL)
6354 p = curbuf->b_p_cm;
6355 else
6356 p = p_cm;
6357 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6358 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006359 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006360 errmsg = e_invarg;
6361 else
6362 {
6363 /* When setting the global value to empty, make it "zip". */
6364 if (*p_cm == NUL)
6365 {
6366 if (new_value_alloced)
6367 free_string_option(p_cm);
6368 p_cm = vim_strsave((char_u *)"zip");
6369 new_value_alloced = TRUE;
6370 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006371 /* When using ":set cm=name" the local value is going to be empty.
6372 * Do that here, otherwise the crypt functions will still use the
6373 * local value. */
6374 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6375 {
6376 free_string_option(curbuf->b_p_cm);
6377 curbuf->b_p_cm = empty_option;
6378 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006379
6380 /* Need to update the swapfile when the effective method changed.
6381 * Set "s" to the effective old value, "p" to the effective new
6382 * method and compare. */
6383 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6384 s = p_cm; /* was previously using the global value */
6385 else
6386 s = oldval;
6387 if (*curbuf->b_p_cm == NUL)
6388 p = p_cm; /* is now using the global value */
6389 else
6390 p = curbuf->b_p_cm;
6391 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006392 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006393
6394 /* If the global value changes need to update the swapfile for all
6395 * buffers using that value. */
6396 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6397 {
6398 buf_T *buf;
6399
Bram Moolenaar29323592016-07-24 22:04:11 +02006400 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006401 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006402 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006403 }
6404 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006405 }
6406#endif
6407
6408 /* 'matchpairs' */
6409 else if (gvarp == &p_mps)
6410 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006411#ifdef FEAT_MBYTE
6412 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006413 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006414 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006415 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006416 int x2 = -1;
6417 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006418
6419 if (*p != NUL)
6420 p += mb_ptr2len(p);
6421 if (*p != NUL)
6422 x2 = *p++;
6423 if (*p != NUL)
6424 {
6425 x3 = mb_ptr2char(p);
6426 p += mb_ptr2len(p);
6427 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006428 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006429 {
6430 errmsg = e_invarg;
6431 break;
6432 }
6433 if (*p == NUL)
6434 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006435 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006436 }
6437 else
6438#endif
6439 {
6440 /* Check for "x:y,x:y" */
6441 for (p = *varp; *p != NUL; p += 4)
6442 {
6443 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6444 {
6445 errmsg = e_invarg;
6446 break;
6447 }
6448 if (p[3] == NUL)
6449 break;
6450 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006451 }
6452 }
6453
6454#ifdef FEAT_COMMENTS
6455 /* 'comments' */
6456 else if (gvarp == &p_com)
6457 {
6458 for (s = *varp; *s; )
6459 {
6460 while (*s && *s != ':')
6461 {
6462 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6463 && !VIM_ISDIGIT(*s) && *s != '-')
6464 {
6465 errmsg = illegal_char(errbuf, *s);
6466 break;
6467 }
6468 ++s;
6469 }
6470 if (*s++ == NUL)
6471 errmsg = (char_u *)N_("E524: Missing colon");
6472 else if (*s == ',' || *s == NUL)
6473 errmsg = (char_u *)N_("E525: Zero length string");
6474 if (errmsg != NULL)
6475 break;
6476 while (*s && *s != ',')
6477 {
6478 if (*s == '\\' && s[1] != NUL)
6479 ++s;
6480 ++s;
6481 }
6482 s = skip_to_option_part(s);
6483 }
6484 }
6485#endif
6486
6487 /* 'listchars' */
6488 else if (varp == &p_lcs)
6489 {
6490 errmsg = set_chars_option(varp);
6491 }
6492
6493#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6494 /* 'fillchars' */
6495 else if (varp == &p_fcs)
6496 {
6497 errmsg = set_chars_option(varp);
6498 }
6499#endif
6500
6501#ifdef FEAT_CMDWIN
6502 /* 'cedit' */
6503 else if (varp == &p_cedit)
6504 {
6505 errmsg = check_cedit();
6506 }
6507#endif
6508
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006509 /* 'verbosefile' */
6510 else if (varp == &p_vfile)
6511 {
6512 verbose_stop();
6513 if (*p_vfile != NUL && verbose_open() == FAIL)
6514 errmsg = e_invarg;
6515 }
6516
Bram Moolenaar071d4272004-06-13 20:20:40 +00006517#ifdef FEAT_VIMINFO
6518 /* 'viminfo' */
6519 else if (varp == &p_viminfo)
6520 {
6521 for (s = p_viminfo; *s;)
6522 {
6523 /* Check it's a valid character */
6524 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6525 {
6526 errmsg = illegal_char(errbuf, *s);
6527 break;
6528 }
6529 if (*s == 'n') /* name is always last one */
6530 {
6531 break;
6532 }
6533 else if (*s == 'r') /* skip until next ',' */
6534 {
6535 while (*++s && *s != ',')
6536 ;
6537 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006538 else if (*s == '%')
6539 {
6540 /* optional number */
6541 while (vim_isdigit(*++s))
6542 ;
6543 }
6544 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006545 ++s; /* no extra chars */
6546 else /* must have a number */
6547 {
6548 while (vim_isdigit(*++s))
6549 ;
6550
6551 if (!VIM_ISDIGIT(*(s - 1)))
6552 {
6553 if (errbuf != NULL)
6554 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006555 sprintf((char *)errbuf,
6556 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006557 transchar_byte(*(s - 1)));
6558 errmsg = errbuf;
6559 }
6560 else
6561 errmsg = (char_u *)"";
6562 break;
6563 }
6564 }
6565 if (*s == ',')
6566 ++s;
6567 else if (*s)
6568 {
6569 if (errbuf != NULL)
6570 errmsg = (char_u *)N_("E527: Missing comma");
6571 else
6572 errmsg = (char_u *)"";
6573 break;
6574 }
6575 }
6576 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6577 errmsg = (char_u *)N_("E528: Must specify a ' value");
6578 }
6579#endif /* FEAT_VIMINFO */
6580
6581 /* terminal options */
6582 else if (istermoption(&options[opt_idx]) && full_screen)
6583 {
6584 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6585 if (varp == &T_CCO)
6586 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006587 int colors = atoi((char *)T_CCO);
6588
6589 /* Only reinitialize colors if t_Co value has really changed to
6590 * avoid expensive reload of colorscheme if t_Co is set to the
6591 * same value multiple times. */
6592 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006593 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006594 t_colors = colors;
6595 if (t_colors <= 1)
6596 {
6597 if (new_value_alloced)
6598 vim_free(T_CCO);
6599 T_CCO = empty_option;
6600 }
6601 /* We now have a different color setup, initialize it again. */
6602 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006603 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006604 }
6605 ttest(FALSE);
6606 if (varp == &T_ME)
6607 {
6608 out_str(T_ME);
6609 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006610#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006611 /* Since t_me has been set, this probably means that the user
6612 * wants to use this as default colors. Need to reset default
6613 * background/foreground colors. */
6614 mch_set_normal_colors();
6615#endif
6616 }
6617 }
6618
6619#ifdef FEAT_LINEBREAK
6620 /* 'showbreak' */
6621 else if (varp == &p_sbr)
6622 {
6623 for (s = p_sbr; *s; )
6624 {
6625 if (ptr2cells(s) != 1)
6626 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006627 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006628 }
6629 }
6630#endif
6631
6632#ifdef FEAT_GUI
6633 /* 'guifont' */
6634 else if (varp == &p_guifont)
6635 {
6636 if (gui.in_use)
6637 {
6638 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006639# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006640 /*
6641 * Put up a font dialog and let the user select a new value.
6642 * If this is cancelled go back to the old value but don't
6643 * give an error message.
6644 */
6645 if (STRCMP(p, "*") == 0)
6646 {
6647 p = gui_mch_font_dialog(oldval);
6648
6649 if (new_value_alloced)
6650 free_string_option(p_guifont);
6651
6652 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6653 new_value_alloced = TRUE;
6654 }
6655# endif
6656 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6657 {
6658# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6659 if (STRCMP(p_guifont, "*") == 0)
6660 {
6661 /* Dialog was cancelled: Keep the old value without giving
6662 * an error message. */
6663 if (new_value_alloced)
6664 free_string_option(p_guifont);
6665 p_guifont = vim_strsave(oldval);
6666 new_value_alloced = TRUE;
6667 }
6668 else
6669# endif
6670 errmsg = (char_u *)N_("E596: Invalid font(s)");
6671 }
6672 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006673 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006674 }
6675# ifdef FEAT_XFONTSET
6676 else if (varp == &p_guifontset)
6677 {
6678 if (STRCMP(p_guifontset, "*") == 0)
6679 errmsg = (char_u *)N_("E597: can't select fontset");
6680 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6681 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006682 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006683 }
6684# endif
6685# ifdef FEAT_MBYTE
6686 else if (varp == &p_guifontwide)
6687 {
6688 if (STRCMP(p_guifontwide, "*") == 0)
6689 errmsg = (char_u *)N_("E533: can't select wide font");
6690 else if (gui_get_wide_font() == FAIL)
6691 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006692 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006693 }
6694# endif
6695#endif
6696
6697#ifdef CURSOR_SHAPE
6698 /* 'guicursor' */
6699 else if (varp == &p_guicursor)
6700 errmsg = parse_shape_opt(SHAPE_CURSOR);
6701#endif
6702
6703#ifdef FEAT_MOUSESHAPE
6704 /* 'mouseshape' */
6705 else if (varp == &p_mouseshape)
6706 {
6707 errmsg = parse_shape_opt(SHAPE_MOUSE);
6708 update_mouseshape(-1);
6709 }
6710#endif
6711
6712#ifdef FEAT_PRINTER
6713 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006714 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006715# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006716 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006717 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006718# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006719#endif
6720
6721#ifdef FEAT_LANGMAP
6722 /* 'langmap' */
6723 else if (varp == &p_langmap)
6724 langmap_set();
6725#endif
6726
6727#ifdef FEAT_LINEBREAK
6728 /* 'breakat' */
6729 else if (varp == &p_breakat)
6730 fill_breakat_flags();
6731#endif
6732
6733#ifdef FEAT_TITLE
6734 /* 'titlestring' and 'iconstring' */
6735 else if (varp == &p_titlestring || varp == &p_iconstring)
6736 {
6737# ifdef FEAT_STL_OPT
6738 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6739
6740 /* NULL => statusline syntax */
6741 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6742 stl_syntax |= flagval;
6743 else
6744 stl_syntax &= ~flagval;
6745# endif
6746 did_set_title(varp == &p_iconstring);
6747
6748 }
6749#endif
6750
6751#ifdef FEAT_GUI
6752 /* 'guioptions' */
6753 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006754 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006755 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006756 redraw_gui_only = TRUE;
6757 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006758#endif
6759
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006760#if defined(FEAT_GUI_TABLINE)
6761 /* 'guitablabel' */
6762 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006763 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006764 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006765 redraw_gui_only = TRUE;
6766 }
6767 /* 'guitabtooltip' */
6768 else if (varp == &p_gtt)
6769 {
6770 redraw_gui_only = TRUE;
6771 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006772#endif
6773
Bram Moolenaar071d4272004-06-13 20:20:40 +00006774#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6775 /* 'ttymouse' */
6776 else if (varp == &p_ttym)
6777 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006778 /* Switch the mouse off before changing the escape sequences used for
6779 * that. */
6780 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006781 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6782 errmsg = e_invarg;
6783 else
6784 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006785 if (termcap_active)
6786 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006787 }
6788#endif
6789
Bram Moolenaar071d4272004-06-13 20:20:40 +00006790 /* 'selection' */
6791 else if (varp == &p_sel)
6792 {
6793 if (*p_sel == NUL
6794 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6795 errmsg = e_invarg;
6796 }
6797
6798 /* 'selectmode' */
6799 else if (varp == &p_slm)
6800 {
6801 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6802 errmsg = e_invarg;
6803 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006804
6805#ifdef FEAT_BROWSE
6806 /* 'browsedir' */
6807 else if (varp == &p_bsdir)
6808 {
6809 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6810 && !mch_isdir(p_bsdir))
6811 errmsg = e_invarg;
6812 }
6813#endif
6814
Bram Moolenaar071d4272004-06-13 20:20:40 +00006815 /* 'keymodel' */
6816 else if (varp == &p_km)
6817 {
6818 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6819 errmsg = e_invarg;
6820 else
6821 {
6822 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6823 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6824 }
6825 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006826
6827 /* 'mousemodel' */
6828 else if (varp == &p_mousem)
6829 {
6830 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6831 errmsg = e_invarg;
6832#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6833 else if (*p_mousem != *oldval)
6834 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6835 * to create or delete the popup menus. */
6836 gui_motif_update_mousemodel(root_menu);
6837#endif
6838 }
6839
6840 /* 'switchbuf' */
6841 else if (varp == &p_swb)
6842 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006843 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006844 errmsg = e_invarg;
6845 }
6846
6847 /* 'debug' */
6848 else if (varp == &p_debug)
6849 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006850 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006851 errmsg = e_invarg;
6852 }
6853
6854 /* 'display' */
6855 else if (varp == &p_dy)
6856 {
6857 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6858 errmsg = e_invarg;
6859 else
6860 (void)init_chartab();
6861
6862 }
6863
Bram Moolenaar44a2f922016-03-19 22:11:51 +01006864#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00006865 /* 'eadirection' */
6866 else if (varp == &p_ead)
6867 {
6868 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6869 errmsg = e_invarg;
6870 }
6871#endif
6872
6873#ifdef FEAT_CLIPBOARD
6874 /* 'clipboard' */
6875 else if (varp == &p_cb)
6876 errmsg = check_clipboard_option();
6877#endif
6878
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006879#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006880 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6881 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006882 else if (varp == &(curwin->w_s->b_p_spl)
6883 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006884 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02006885 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00006886 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006887 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006888 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006889 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006890 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006891 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006892 /* 'spellsuggest' */
6893 else if (varp == &p_sps)
6894 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006895 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006896 errmsg = e_invarg;
6897 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006898 /* 'mkspellmem' */
6899 else if (varp == &p_msm)
6900 {
6901 if (spell_check_msm() != OK)
6902 errmsg = e_invarg;
6903 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006904#endif
6905
Bram Moolenaar071d4272004-06-13 20:20:40 +00006906#ifdef FEAT_QUICKFIX
6907 /* When 'bufhidden' is set, check for valid value. */
6908 else if (gvarp == &p_bh)
6909 {
6910 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6911 errmsg = e_invarg;
6912 }
6913
6914 /* When 'buftype' is set, check for valid value. */
6915 else if (gvarp == &p_bt)
6916 {
6917 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6918 errmsg = e_invarg;
6919 else
6920 {
6921# ifdef FEAT_WINDOWS
6922 if (curwin->w_status_height)
6923 {
6924 curwin->w_redr_status = TRUE;
6925 redraw_later(VALID);
6926 }
6927# endif
6928 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006929# ifdef FEAT_TITLE
6930 redraw_titles();
6931# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006932 }
6933 }
6934#endif
6935
6936#ifdef FEAT_STL_OPT
6937 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006938 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006939 {
6940 int wid;
6941
6942 if (varp == &p_ruf) /* reset ru_wid first */
6943 ru_wid = 0;
6944 s = *varp;
6945 if (varp == &p_ruf && *s == '%')
6946 {
6947 /* set ru_wid if 'ruf' starts with "%99(" */
6948 if (*++s == '-') /* ignore a '-' */
6949 s++;
6950 wid = getdigits(&s);
6951 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6952 ru_wid = wid;
6953 else
6954 errmsg = check_stl_option(p_ruf);
6955 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006956 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006957 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006958 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006959 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006960 comp_col();
6961 }
6962#endif
6963
6964#ifdef FEAT_INS_EXPAND
6965 /* check if it is a valid value for 'complete' -- Acevedo */
6966 else if (gvarp == &p_cpt)
6967 {
6968 for (s = *varp; *s;)
6969 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006970 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006971 s++;
6972 if (!*s)
6973 break;
6974 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6975 {
6976 errmsg = illegal_char(errbuf, *s);
6977 break;
6978 }
6979 if (*++s != NUL && *s != ',' && *s != ' ')
6980 {
6981 if (s[-1] == 'k' || s[-1] == 's')
6982 {
6983 /* skip optional filename after 'k' and 's' */
6984 while (*s && *s != ',' && *s != ' ')
6985 {
6986 if (*s == '\\')
6987 ++s;
6988 ++s;
6989 }
6990 }
6991 else
6992 {
6993 if (errbuf != NULL)
6994 {
6995 sprintf((char *)errbuf,
6996 _("E535: Illegal character after <%c>"),
6997 *--s);
6998 errmsg = errbuf;
6999 }
7000 else
7001 errmsg = (char_u *)"";
7002 break;
7003 }
7004 }
7005 }
7006 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007007
7008 /* 'completeopt' */
7009 else if (varp == &p_cot)
7010 {
7011 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7012 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007013 else
7014 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007015 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007016#endif /* FEAT_INS_EXPAND */
7017
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007018#ifdef FEAT_SIGNS
7019 /* 'signcolumn' */
7020 else if (varp == &curwin->w_p_scl)
7021 {
7022 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7023 errmsg = e_invarg;
7024 }
7025#endif
7026
Bram Moolenaar071d4272004-06-13 20:20:40 +00007027
7028#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007029 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007030 else if (varp == &p_toolbar)
7031 {
7032 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7033 &toolbar_flags, TRUE) != OK)
7034 errmsg = e_invarg;
7035 else
7036 {
7037 out_flush();
7038 gui_mch_show_toolbar((toolbar_flags &
7039 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7040 }
7041 }
7042#endif
7043
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007044#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007045 /* 'toolbariconsize': GTK+ 2 only */
7046 else if (varp == &p_tbis)
7047 {
7048 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7049 errmsg = e_invarg;
7050 else
7051 {
7052 out_flush();
7053 gui_mch_show_toolbar((toolbar_flags &
7054 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7055 }
7056 }
7057#endif
7058
7059 /* 'pastetoggle': translate key codes like in a mapping */
7060 else if (varp == &p_pt)
7061 {
7062 if (*p_pt)
7063 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007064 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007065 if (p != NULL)
7066 {
7067 if (new_value_alloced)
7068 free_string_option(p_pt);
7069 p_pt = p;
7070 new_value_alloced = TRUE;
7071 }
7072 }
7073 }
7074
7075 /* 'backspace' */
7076 else if (varp == &p_bs)
7077 {
7078 if (VIM_ISDIGIT(*p_bs))
7079 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007080 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007081 errmsg = e_invarg;
7082 }
7083 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7084 errmsg = e_invarg;
7085 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007086 else if (varp == &p_bo)
7087 {
7088 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7089 errmsg = e_invarg;
7090 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007091
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007092 /* 'tagcase' */
7093 else if (gvarp == &p_tc)
7094 {
7095 unsigned int *flags;
7096
7097 if (opt_flags & OPT_LOCAL)
7098 {
7099 p = curbuf->b_p_tc;
7100 flags = &curbuf->b_tc_flags;
7101 }
7102 else
7103 {
7104 p = p_tc;
7105 flags = &tc_flags;
7106 }
7107
7108 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7109 /* make the local value empty: use the global value */
7110 *flags = 0;
7111 else if (*p == NUL
7112 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7113 errmsg = e_invarg;
7114 }
7115
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007116#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007117 /* 'casemap' */
7118 else if (varp == &p_cmp)
7119 {
7120 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7121 errmsg = e_invarg;
7122 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007123#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007124
7125#ifdef FEAT_DIFF
7126 /* 'diffopt' */
7127 else if (varp == &p_dip)
7128 {
7129 if (diffopt_changed() == FAIL)
7130 errmsg = e_invarg;
7131 }
7132#endif
7133
7134#ifdef FEAT_FOLDING
7135 /* 'foldmethod' */
7136 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7137 {
7138 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7139 || *curwin->w_p_fdm == NUL)
7140 errmsg = e_invarg;
7141 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007142 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007143 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007144 if (foldmethodIsDiff(curwin))
7145 newFoldLevel();
7146 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007147 }
7148# ifdef FEAT_EVAL
7149 /* 'foldexpr' */
7150 else if (varp == &curwin->w_p_fde)
7151 {
7152 if (foldmethodIsExpr(curwin))
7153 foldUpdateAll(curwin);
7154 }
7155# endif
7156 /* 'foldmarker' */
7157 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7158 {
7159 p = vim_strchr(*varp, ',');
7160 if (p == NULL)
7161 errmsg = (char_u *)N_("E536: comma required");
7162 else if (p == *varp || p[1] == NUL)
7163 errmsg = e_invarg;
7164 else if (foldmethodIsMarker(curwin))
7165 foldUpdateAll(curwin);
7166 }
7167 /* 'commentstring' */
7168 else if (gvarp == &p_cms)
7169 {
7170 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7171 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7172 }
7173 /* 'foldopen' */
7174 else if (varp == &p_fdo)
7175 {
7176 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7177 errmsg = e_invarg;
7178 }
7179 /* 'foldclose' */
7180 else if (varp == &p_fcl)
7181 {
7182 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7183 errmsg = e_invarg;
7184 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007185 /* 'foldignore' */
7186 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7187 {
7188 if (foldmethodIsIndent(curwin))
7189 foldUpdateAll(curwin);
7190 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007191#endif
7192
7193#ifdef FEAT_VIRTUALEDIT
7194 /* 'virtualedit' */
7195 else if (varp == &p_ve)
7196 {
7197 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7198 errmsg = e_invarg;
7199 else if (STRCMP(p_ve, oldval) != 0)
7200 {
7201 /* Recompute cursor position in case the new 've' setting
7202 * changes something. */
7203 validate_virtcol();
7204 coladvance(curwin->w_virtcol);
7205 }
7206 }
7207#endif
7208
7209#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7210 else if (varp == &p_csqf)
7211 {
7212 if (p_csqf != NULL)
7213 {
7214 p = p_csqf;
7215 while (*p != NUL)
7216 {
7217 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7218 || p[1] == NUL
7219 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7220 || (p[2] != NUL && p[2] != ','))
7221 {
7222 errmsg = e_invarg;
7223 break;
7224 }
7225 else if (p[2] == NUL)
7226 break;
7227 else
7228 p += 3;
7229 }
7230 }
7231 }
7232#endif
7233
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007234#ifdef FEAT_CINDENT
7235 /* 'cinoptions' */
7236 else if (gvarp == &p_cino)
7237 {
7238 /* TODO: recognize errors */
7239 parse_cino(curbuf);
7240 }
7241#endif
7242
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007243#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007244 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007245 else if (varp == &p_rop && gui.in_use)
7246 {
7247 if (!gui_mch_set_rendering_options(p_rop))
7248 errmsg = e_invarg;
7249 }
7250#endif
7251
Bram Moolenaard0b51382016-11-04 15:23:45 +01007252#ifdef FEAT_AUTOCMD
7253 else if (gvarp == &p_ft)
7254 {
7255 if (!valid_filetype(*varp))
7256 errmsg = e_invarg;
7257 }
7258#endif
7259
7260#ifdef FEAT_SYN_HL
7261 else if (gvarp == &p_syn)
7262 {
7263 if (!valid_filetype(*varp))
7264 errmsg = e_invarg;
7265 }
7266#endif
7267
Bram Moolenaar071d4272004-06-13 20:20:40 +00007268 /* Options that are a list of flags. */
7269 else
7270 {
7271 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007272 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007273 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007274 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007275 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007276 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007277 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007278 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007279 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007280#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007281 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007282 p = (char_u *)COCU_ALL;
7283#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007284 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007285 {
7286#ifdef FEAT_MOUSE
7287 p = (char_u *)MOUSE_ALL;
7288#else
7289 if (*p_mouse != NUL)
7290 errmsg = (char_u *)N_("E538: No mouse support");
7291#endif
7292 }
7293#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007294 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007295 p = (char_u *)GO_ALL;
7296#endif
7297 if (p != NULL)
7298 {
7299 for (s = *varp; *s; ++s)
7300 if (vim_strchr(p, *s) == NULL)
7301 {
7302 errmsg = illegal_char(errbuf, *s);
7303 break;
7304 }
7305 }
7306 }
7307
7308 /*
7309 * If error detected, restore the previous value.
7310 */
7311 if (errmsg != NULL)
7312 {
7313 if (new_value_alloced)
7314 free_string_option(*varp);
7315 *varp = oldval;
7316 /*
7317 * When resetting some values, need to act on it.
7318 */
7319 if (did_chartab)
7320 (void)init_chartab();
7321 if (varp == &p_hl)
7322 (void)highlight_changed();
7323 }
7324 else
7325 {
7326#ifdef FEAT_EVAL
7327 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007328 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007329#endif
7330 /*
7331 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007332 * Use "free_oldval", because recursiveness may change the flags under
7333 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007334 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007335 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007336 free_string_option(oldval);
7337 if (new_value_alloced)
7338 options[opt_idx].flags |= P_ALLOCED;
7339 else
7340 options[opt_idx].flags &= ~P_ALLOCED;
7341
7342 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007343 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007344 {
7345 /* global option with local value set to use global value; free
7346 * the local value and make it empty */
7347 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7348 free_string_option(*(char_u **)p);
7349 *(char_u **)p = empty_option;
7350 }
7351
7352 /* May set global value for local option. */
7353 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7354 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007355
7356#ifdef FEAT_AUTOCMD
7357 /*
7358 * Trigger the autocommand only after setting the flags.
7359 */
7360# ifdef FEAT_SYN_HL
7361 /* When 'syntax' is set, load the syntax of that name */
7362 if (varp == &(curbuf->b_p_syn))
7363 {
7364 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7365 curbuf->b_fname, TRUE, curbuf);
7366 }
7367# endif
7368 else if (varp == &(curbuf->b_p_ft))
7369 {
7370 /* 'filetype' is set, trigger the FileType autocommand */
7371 did_filetype = TRUE;
7372 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7373 curbuf->b_fname, TRUE, curbuf);
7374 }
7375#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007376#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007377 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007378 {
7379 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007380 char_u *q = curwin->w_s->b_p_spl;
7381
7382 /* Skip the first name if it is "cjk". */
7383 if (STRNCMP(q, "cjk,", 4) == 0)
7384 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007385
7386 /*
7387 * Source the spell/LANG.vim in 'runtimepath'.
7388 * They could set 'spellcapcheck' depending on the language.
7389 * Use the first name in 'spelllang' up to '_region' or
7390 * '.encoding'.
7391 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007392 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007393 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7394 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007395 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007396 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007397 }
7398#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007399 }
7400
7401#ifdef FEAT_MOUSE
7402 if (varp == &p_mouse)
7403 {
7404# ifdef FEAT_MOUSE_TTY
7405 if (*p_mouse == NUL)
7406 mch_setmouse(FALSE); /* switch mouse off */
7407 else
7408# endif
7409 setmouse(); /* in case 'mouse' changed */
7410 }
7411#endif
7412
Bram Moolenaar913077c2012-03-28 19:59:04 +02007413 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007414 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007415 curwin->w_set_curswant = TRUE;
7416
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007417#ifdef FEAT_GUI
7418 /* check redraw when it's not a GUI option or the GUI is active. */
7419 if (!redraw_gui_only || gui.in_use)
7420#endif
7421 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007422
7423 return errmsg;
7424}
7425
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007426#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007427/*
7428 * Simple int comparison function for use with qsort()
7429 */
7430 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007431int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007432{
7433 return *(const int *)a - *(const int *)b;
7434}
7435
7436/*
7437 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7438 * Returns error message, NULL if it's OK.
7439 */
7440 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007441check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007442{
7443 char_u *s;
7444 int col;
7445 int count = 0;
7446 int color_cols[256];
7447 int i;
7448 int j = 0;
7449
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007450 if (wp->w_buffer == NULL)
7451 return NULL; /* buffer was closed */
7452
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007453 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007454 {
7455 if (*s == '-' || *s == '+')
7456 {
7457 /* -N and +N: add to 'textwidth' */
7458 col = (*s == '-') ? -1 : 1;
7459 ++s;
7460 if (!VIM_ISDIGIT(*s))
7461 return e_invarg;
7462 col = col * getdigits(&s);
7463 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007464 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007465 col += wp->w_buffer->b_p_tw;
7466 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007467 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007468 }
7469 else if (VIM_ISDIGIT(*s))
7470 col = getdigits(&s);
7471 else
7472 return e_invarg;
7473 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007474skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007475 if (*s == NUL)
7476 break;
7477 if (*s != ',')
7478 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007479 if (*++s == NUL)
7480 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007481 }
7482
7483 vim_free(wp->w_p_cc_cols);
7484 if (count == 0)
7485 wp->w_p_cc_cols = NULL;
7486 else
7487 {
7488 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7489 if (wp->w_p_cc_cols != NULL)
7490 {
7491 /* sort the columns for faster usage on screen redraw inside
7492 * win_line() */
7493 qsort(color_cols, count, sizeof(int), int_cmp);
7494
7495 for (i = 0; i < count; ++i)
7496 /* skip duplicates */
7497 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7498 wp->w_p_cc_cols[j++] = color_cols[i];
7499 wp->w_p_cc_cols[j] = -1; /* end marker */
7500 }
7501 }
7502
7503 return NULL; /* no error */
7504}
7505#endif
7506
Bram Moolenaar071d4272004-06-13 20:20:40 +00007507/*
7508 * Handle setting 'listchars' or 'fillchars'.
7509 * Returns error message, NULL if it's OK.
7510 */
7511 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007512set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007513{
7514 int round, i, len, entries;
7515 char_u *p, *s;
7516 int c1, c2 = 0;
7517 struct charstab
7518 {
7519 int *cp;
7520 char *name;
7521 };
7522#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7523 static struct charstab filltab[] =
7524 {
7525 {&fill_stl, "stl"},
7526 {&fill_stlnc, "stlnc"},
7527 {&fill_vert, "vert"},
7528 {&fill_fold, "fold"},
7529 {&fill_diff, "diff"},
7530 };
7531#endif
7532 static struct charstab lcstab[] =
7533 {
7534 {&lcs_eol, "eol"},
7535 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007536 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007537 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007538 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007539 {&lcs_tab2, "tab"},
7540 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007541#ifdef FEAT_CONCEAL
7542 {&lcs_conceal, "conceal"},
7543#else
7544 {NULL, "conceal"},
7545#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007546 };
7547 struct charstab *tab;
7548
7549#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7550 if (varp == &p_lcs)
7551#endif
7552 {
7553 tab = lcstab;
7554 entries = sizeof(lcstab) / sizeof(struct charstab);
7555 }
7556#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7557 else
7558 {
7559 tab = filltab;
7560 entries = sizeof(filltab) / sizeof(struct charstab);
7561 }
7562#endif
7563
7564 /* first round: check for valid value, second round: assign values */
7565 for (round = 0; round <= 1; ++round)
7566 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007567 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007568 {
7569 /* After checking that the value is valid: set defaults: space for
7570 * 'fillchars', NUL for 'listchars' */
7571 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007572 if (tab[i].cp != NULL)
7573 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007574 if (varp == &p_lcs)
7575 lcs_tab1 = NUL;
7576#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7577 else
7578 fill_diff = '-';
7579#endif
7580 }
7581 p = *varp;
7582 while (*p)
7583 {
7584 for (i = 0; i < entries; ++i)
7585 {
7586 len = (int)STRLEN(tab[i].name);
7587 if (STRNCMP(p, tab[i].name, len) == 0
7588 && p[len] == ':'
7589 && p[len + 1] != NUL)
7590 {
7591 s = p + len + 1;
7592#ifdef FEAT_MBYTE
7593 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007594 if (mb_char2cells(c1) > 1)
7595 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007596#else
7597 c1 = *s++;
7598#endif
7599 if (tab[i].cp == &lcs_tab2)
7600 {
7601 if (*s == NUL)
7602 continue;
7603#ifdef FEAT_MBYTE
7604 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007605 if (mb_char2cells(c2) > 1)
7606 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007607#else
7608 c2 = *s++;
7609#endif
7610 }
7611 if (*s == ',' || *s == NUL)
7612 {
7613 if (round)
7614 {
7615 if (tab[i].cp == &lcs_tab2)
7616 {
7617 lcs_tab1 = c1;
7618 lcs_tab2 = c2;
7619 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007620 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007621 *(tab[i].cp) = c1;
7622
7623 }
7624 p = s;
7625 break;
7626 }
7627 }
7628 }
7629
7630 if (i == entries)
7631 return e_invarg;
7632 if (*p == ',')
7633 ++p;
7634 }
7635 }
7636
7637 return NULL; /* no error */
7638}
7639
7640#ifdef FEAT_STL_OPT
7641/*
7642 * Check validity of options with the 'statusline' format.
7643 * Return error message or NULL.
7644 */
7645 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007646check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007647{
7648 int itemcnt = 0;
7649 int groupdepth = 0;
7650 static char_u errbuf[80];
7651
7652 while (*s && itemcnt < STL_MAX_ITEM)
7653 {
7654 /* Check for valid keys after % sequences */
7655 while (*s && *s != '%')
7656 s++;
7657 if (!*s)
7658 break;
7659 s++;
7660 if (*s != '%' && *s != ')')
7661 ++itemcnt;
7662 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7663 {
7664 s++;
7665 continue;
7666 }
7667 if (*s == ')')
7668 {
7669 s++;
7670 if (--groupdepth < 0)
7671 break;
7672 continue;
7673 }
7674 if (*s == '-')
7675 s++;
7676 while (VIM_ISDIGIT(*s))
7677 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007678 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007679 continue;
7680 if (*s == '.')
7681 {
7682 s++;
7683 while (*s && VIM_ISDIGIT(*s))
7684 s++;
7685 }
7686 if (*s == '(')
7687 {
7688 groupdepth++;
7689 continue;
7690 }
7691 if (vim_strchr(STL_ALL, *s) == NULL)
7692 {
7693 return illegal_char(errbuf, *s);
7694 }
7695 if (*s == '{')
7696 {
7697 s++;
7698 while (*s != '}' && *s)
7699 s++;
7700 if (*s != '}')
7701 return (char_u *)N_("E540: Unclosed expression sequence");
7702 }
7703 }
7704 if (itemcnt >= STL_MAX_ITEM)
7705 return (char_u *)N_("E541: too many items");
7706 if (groupdepth != 0)
7707 return (char_u *)N_("E542: unbalanced groups");
7708 return NULL;
7709}
7710#endif
7711
7712#ifdef FEAT_CLIPBOARD
7713/*
7714 * Extract the items in the 'clipboard' option and set global values.
7715 */
7716 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007717check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007718{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007719 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007720 int new_autoselect_star = FALSE;
7721 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007722 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007723 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007724 regprog_T *new_exclude_prog = NULL;
7725 char_u *errmsg = NULL;
7726 char_u *p;
7727
7728 for (p = p_cb; *p != NUL; )
7729 {
7730 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7731 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007732 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007733 p += 7;
7734 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007735 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007736 && (p[11] == ',' || p[11] == NUL))
7737 {
7738 new_unnamed |= CLIP_UNNAMED_PLUS;
7739 p += 11;
7740 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007741 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007742 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007743 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007744 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007745 p += 10;
7746 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007747 else if (STRNCMP(p, "autoselectplus", 14) == 0
7748 && (p[14] == ',' || p[14] == NUL))
7749 {
7750 new_autoselect_plus = TRUE;
7751 p += 14;
7752 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007753 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007754 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007755 {
7756 new_autoselectml = TRUE;
7757 p += 12;
7758 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007759 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7760 {
7761 new_html = TRUE;
7762 p += 4;
7763 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007764 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7765 {
7766 p += 8;
7767 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7768 if (new_exclude_prog == NULL)
7769 errmsg = e_invarg;
7770 break;
7771 }
7772 else
7773 {
7774 errmsg = e_invarg;
7775 break;
7776 }
7777 if (*p == ',')
7778 ++p;
7779 }
7780 if (errmsg == NULL)
7781 {
7782 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007783 clip_autoselect_star = new_autoselect_star;
7784 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007785 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007786 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007787 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007788 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007789#ifdef FEAT_GUI_GTK
7790 if (gui.in_use)
7791 {
7792 gui_gtk_set_selection_targets();
7793 gui_gtk_set_dnd_targets();
7794 }
7795#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007796 }
7797 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007798 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007799
7800 return errmsg;
7801}
7802#endif
7803
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007804#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007805 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007806did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007807{
7808 char_u *errmsg = NULL;
7809 win_T *wp;
7810 int l;
7811
7812 if (is_spellfile)
7813 {
7814 l = (int)STRLEN(curwin->w_s->b_p_spf);
7815 if (l > 0 && (l < 4
7816 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7817 errmsg = e_invarg;
7818 }
7819
7820 if (errmsg == NULL)
7821 {
7822 FOR_ALL_WINDOWS(wp)
7823 if (wp->w_buffer == curbuf && wp->w_p_spell)
7824 {
7825 errmsg = did_set_spelllang(wp);
7826# ifdef FEAT_WINDOWS
7827 break;
7828# endif
7829 }
7830 }
7831 return errmsg;
7832}
7833
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007834/*
7835 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7836 * Return error message when failed, NULL when OK.
7837 */
7838 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007839compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007840{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007841 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007842 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007843
Bram Moolenaar860cae12010-06-05 23:22:07 +02007844 if (*synblock->b_p_spc == NUL)
7845 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007846 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007847 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007848 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007849 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007850 if (re != NULL)
7851 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007852 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007853 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007854 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007855 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007856 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007857 return e_invarg;
7858 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007859 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007860 }
7861
Bram Moolenaar473de612013-06-08 18:19:48 +02007862 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007863 return NULL;
7864}
7865#endif
7866
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007867#if defined(FEAT_EVAL) || defined(PROTO)
7868/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007869 * Set the scriptID for an option, taking care of setting the buffer- or
7870 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007871 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007872 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01007873set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007874{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007875 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7876 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007877
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007878 /* Remember where the option was set. For local options need to do that
7879 * in the buffer or window structure. */
7880 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007881 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007882 if (both || (opt_flags & OPT_LOCAL))
7883 {
7884 if (indir & PV_BUF)
7885 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7886 else if (indir & PV_WIN)
7887 curwin->w_p_scriptID[indir & PV_MASK] = id;
7888 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007889}
7890#endif
7891
Bram Moolenaar071d4272004-06-13 20:20:40 +00007892/*
7893 * Set the value of a boolean option, and take care of side effects.
7894 * Returns NULL for success, or an error message for an error.
7895 */
7896 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007897set_bool_option(
7898 int opt_idx, /* index in options[] table */
7899 char_u *varp, /* pointer to the option variable */
7900 int value, /* new value */
7901 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007902{
7903 int old_value = *(int *)varp;
7904
Bram Moolenaar071d4272004-06-13 20:20:40 +00007905 /* Disallow changing some options from secure mode */
7906 if ((secure
7907#ifdef HAVE_SANDBOX
7908 || sandbox != 0
7909#endif
7910 ) && (options[opt_idx].flags & P_SECURE))
7911 return e_secure;
7912
7913 *(int *)varp = value; /* set the new value */
7914#ifdef FEAT_EVAL
7915 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007916 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007917#endif
7918
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007919#ifdef FEAT_GUI
7920 need_mouse_correct = TRUE;
7921#endif
7922
Bram Moolenaar071d4272004-06-13 20:20:40 +00007923 /* May set global value for local option. */
7924 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7925 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7926
7927 /*
7928 * Handle side effects of changing a bool option.
7929 */
7930
7931 /* 'compatible' */
7932 if ((int *)varp == &p_cp)
7933 {
7934 compatible_set();
7935 }
7936
Bram Moolenaar920694c2016-08-21 17:45:02 +02007937#ifdef FEAT_LANGMAP
7938 if ((int *)varp == &p_lrm)
7939 /* 'langremap' -> !'langnoremap' */
7940 p_lnr = !p_lrm;
7941 else if ((int *)varp == &p_lnr)
7942 /* 'langnoremap' -> !'langremap' */
7943 p_lrm = !p_lnr;
7944#endif
7945
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007946#ifdef FEAT_PERSISTENT_UNDO
7947 /* 'undofile' */
7948 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7949 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007950 /* Only take action when the option was set. When reset we do not
7951 * delete the undo file, the option may be set again without making
7952 * any changes in between. */
7953 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007954 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007955 char_u hash[UNDO_HASH_SIZE];
7956 buf_T *save_curbuf = curbuf;
7957
Bram Moolenaar29323592016-07-24 22:04:11 +02007958 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007959 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007960 /* When 'undofile' is set globally: for every buffer, otherwise
7961 * only for the current buffer: Try to read in the undofile,
7962 * if one exists, the buffer wasn't changed and the buffer was
7963 * loaded */
7964 if ((curbuf == save_curbuf
7965 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7966 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7967 {
7968 u_compute_hash(hash);
7969 u_read_undo(NULL, hash, curbuf->b_fname);
7970 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007971 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007972 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007973 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007974 }
7975#endif
7976
Bram Moolenaar071d4272004-06-13 20:20:40 +00007977 else if ((int *)varp == &curbuf->b_p_ro)
7978 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007979 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007980 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7981 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007982
7983 /* when 'readonly' is set may give W10 again */
7984 if (curbuf->b_p_ro)
7985 curbuf->b_did_warn = FALSE;
7986
Bram Moolenaar071d4272004-06-13 20:20:40 +00007987#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007988 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007989#endif
7990 }
7991
Bram Moolenaar9c449722010-07-20 18:44:27 +02007992#ifdef FEAT_GUI
7993 else if ((int *)varp == &p_mh)
7994 {
7995 if (!p_mh)
7996 gui_mch_mousehide(FALSE);
7997 }
7998#endif
7999
Bram Moolenaara539df02010-08-01 14:35:05 +02008000#ifdef FEAT_TITLE
8001 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008002 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008003 {
8004 redraw_titles();
8005 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008006 /* when 'endofline' is changed, redraw the window title */
8007 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008008 {
8009 redraw_titles();
8010 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008011 /* when 'fixeol' is changed, redraw the window title */
8012 else if ((int *)varp == &curbuf->b_p_fixeol)
8013 {
8014 redraw_titles();
8015 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008016# ifdef FEAT_MBYTE
8017 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008018 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008019 {
8020 redraw_titles();
8021 }
8022# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008023#endif
8024
8025 /* when 'bin' is set also set some other options */
8026 else if ((int *)varp == &curbuf->b_p_bin)
8027 {
8028 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8029#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008030 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008031#endif
8032 }
8033
8034#ifdef FEAT_AUTOCMD
8035 /* when 'buflisted' changes, trigger autocommands */
8036 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8037 {
8038 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8039 NULL, NULL, TRUE, curbuf);
8040 }
8041#endif
8042
8043 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8044 else if ((int *)varp == &curbuf->b_p_swf)
8045 {
8046 if (curbuf->b_p_swf && p_uc)
8047 ml_open_file(curbuf); /* create the swap file */
8048 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008049 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8050 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008051 mf_close_file(curbuf, TRUE); /* remove the swap file */
8052 }
8053
8054 /* when 'terse' is set change 'shortmess' */
8055 else if ((int *)varp == &p_terse)
8056 {
8057 char_u *p;
8058
8059 p = vim_strchr(p_shm, SHM_SEARCH);
8060
8061 /* insert 's' in p_shm */
8062 if (p_terse && p == NULL)
8063 {
8064 STRCPY(IObuff, p_shm);
8065 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008066 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008067 }
8068 /* remove 's' from p_shm */
8069 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008070 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008071 }
8072
8073 /* when 'paste' is set or reset also change other options */
8074 else if ((int *)varp == &p_paste)
8075 {
8076 paste_option_changed();
8077 }
8078
8079 /* when 'insertmode' is set from an autocommand need to do work here */
8080 else if ((int *)varp == &p_im)
8081 {
8082 if (p_im)
8083 {
8084 if ((State & INSERT) == 0)
8085 need_start_insertmode = TRUE;
8086 stop_insert_mode = FALSE;
8087 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008088 /* only reset if it was set previously */
8089 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008090 {
8091 need_start_insertmode = FALSE;
8092 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008093 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008094 clear_cmdline = TRUE; /* remove "(insert)" */
8095 restart_edit = 0;
8096 }
8097 }
8098
8099 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8100 else if ((int *)varp == &p_ic && p_hls)
8101 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008102 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008103 }
8104
8105#ifdef FEAT_SEARCH_EXTRA
8106 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8107 else if ((int *)varp == &p_hls)
8108 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008109 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008110 }
8111#endif
8112
8113#ifdef FEAT_SCROLLBIND
8114 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8115 * at the end of normal_cmd() */
8116 else if ((int *)varp == &curwin->w_p_scb)
8117 {
8118 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008119 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008120 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008121 curwin->w_scbind_pos = curwin->w_topline;
8122 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008123 }
8124#endif
8125
8126#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8127 /* There can be only one window with 'previewwindow' set. */
8128 else if ((int *)varp == &curwin->w_p_pvw)
8129 {
8130 if (curwin->w_p_pvw)
8131 {
8132 win_T *win;
8133
Bram Moolenaar29323592016-07-24 22:04:11 +02008134 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008135 if (win->w_p_pvw && win != curwin)
8136 {
8137 curwin->w_p_pvw = FALSE;
8138 return (char_u *)N_("E590: A preview window already exists");
8139 }
8140 }
8141 }
8142#endif
8143
8144 /* when 'textmode' is set or reset also change 'fileformat' */
8145 else if ((int *)varp == &curbuf->b_p_tx)
8146 {
8147 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8148 }
8149
8150 /* when 'textauto' is set or reset also change 'fileformats' */
8151 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008152 set_string_option_direct((char_u *)"ffs", -1,
8153 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008154 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008155
8156 /*
8157 * When 'lisp' option changes include/exclude '-' in
8158 * keyword characters.
8159 */
8160#ifdef FEAT_LISP
8161 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8162 {
8163 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8164 }
8165#endif
8166
8167#ifdef FEAT_TITLE
8168 /* when 'title' changed, may need to change the title; same for 'icon' */
8169 else if ((int *)varp == &p_title)
8170 {
8171 did_set_title(FALSE);
8172 }
8173
8174 else if ((int *)varp == &p_icon)
8175 {
8176 did_set_title(TRUE);
8177 }
8178#endif
8179
8180 else if ((int *)varp == &curbuf->b_changed)
8181 {
8182 if (!value)
8183 save_file_ff(curbuf); /* Buffer is unchanged */
8184#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008185 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008186#endif
8187#ifdef FEAT_AUTOCMD
8188 modified_was_set = value;
8189#endif
8190 }
8191
8192#ifdef BACKSLASH_IN_FILENAME
8193 else if ((int *)varp == &p_ssl)
8194 {
8195 if (p_ssl)
8196 {
8197 psepc = '/';
8198 psepcN = '\\';
8199 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008200 }
8201 else
8202 {
8203 psepc = '\\';
8204 psepcN = '/';
8205 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008206 }
8207
8208 /* need to adjust the file name arguments and buffer names. */
8209 buflist_slash_adjust();
8210 alist_slash_adjust();
8211# ifdef FEAT_EVAL
8212 scriptnames_slash_adjust();
8213# endif
8214 }
8215#endif
8216
8217 /* If 'wrap' is set, set w_leftcol to zero. */
8218 else if ((int *)varp == &curwin->w_p_wrap)
8219 {
8220 if (curwin->w_p_wrap)
8221 curwin->w_leftcol = 0;
8222 }
8223
8224#ifdef FEAT_WINDOWS
8225 else if ((int *)varp == &p_ea)
8226 {
8227 if (p_ea && !old_value)
8228 win_equal(curwin, FALSE, 0);
8229 }
8230#endif
8231
8232 else if ((int *)varp == &p_wiv)
8233 {
8234 /*
8235 * When 'weirdinvert' changed, set/reset 't_xs'.
8236 * Then set 'weirdinvert' according to value of 't_xs'.
8237 */
8238 if (p_wiv && !old_value)
8239 T_XS = (char_u *)"y";
8240 else if (!p_wiv && old_value)
8241 T_XS = empty_option;
8242 p_wiv = (*T_XS != NUL);
8243 }
8244
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008245#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008246 else if ((int *)varp == &p_beval)
8247 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008248 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008249 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008250 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008251 gui_mch_disable_beval_area(balloonEval);
8252 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008253#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008254
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008255#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008256 else if ((int *)varp == &p_acd)
8257 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008258 /* Change directories when the 'acd' option is set now. */
8259 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008260 }
8261#endif
8262
8263#ifdef FEAT_DIFF
8264 /* 'diff' */
8265 else if ((int *)varp == &curwin->w_p_diff)
8266 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008267 /* May add or remove the buffer from the list of diff buffers. */
8268 diff_buf_adjust(curwin);
8269# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008270 if (foldmethodIsDiff(curwin))
8271 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008272# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008273 }
8274#endif
8275
8276#ifdef USE_IM_CONTROL
8277 /* 'imdisable' */
8278 else if ((int *)varp == &p_imdisable)
8279 {
8280 /* Only de-activate it here, it will be enabled when changing mode. */
8281 if (p_imdisable)
8282 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008283 else if (State & INSERT)
8284 /* When the option is set from an autocommand, it may need to take
8285 * effect right away. */
8286 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008287 }
8288#endif
8289
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008290#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008291 /* 'spell' */
8292 else if ((int *)varp == &curwin->w_p_spell)
8293 {
8294 if (curwin->w_p_spell)
8295 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008296 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008297 if (errmsg != NULL)
8298 EMSG(_(errmsg));
8299 }
8300 }
8301#endif
8302
Bram Moolenaar071d4272004-06-13 20:20:40 +00008303#ifdef FEAT_FKMAP
8304 else if ((int *)varp == &p_altkeymap)
8305 {
8306 if (old_value != p_altkeymap)
8307 {
8308 if (!p_altkeymap)
8309 {
8310 p_hkmap = p_fkmap;
8311 p_fkmap = 0;
8312 }
8313 else
8314 {
8315 p_fkmap = p_hkmap;
8316 p_hkmap = 0;
8317 }
8318 (void)init_chartab();
8319 }
8320 }
8321
8322 /*
8323 * In case some second language keymapping options have changed, check
8324 * and correct the setting in a consistent way.
8325 */
8326
8327 /*
8328 * If hkmap or fkmap are set, reset Arabic keymapping.
8329 */
8330 if ((p_hkmap || p_fkmap) && p_altkeymap)
8331 {
8332 p_altkeymap = p_fkmap;
8333# ifdef FEAT_ARABIC
8334 curwin->w_p_arab = FALSE;
8335# endif
8336 (void)init_chartab();
8337 }
8338
8339 /*
8340 * If hkmap set, reset Farsi keymapping.
8341 */
8342 if (p_hkmap && p_altkeymap)
8343 {
8344 p_altkeymap = 0;
8345 p_fkmap = 0;
8346# ifdef FEAT_ARABIC
8347 curwin->w_p_arab = FALSE;
8348# endif
8349 (void)init_chartab();
8350 }
8351
8352 /*
8353 * If fkmap set, reset Hebrew keymapping.
8354 */
8355 if (p_fkmap && !p_altkeymap)
8356 {
8357 p_altkeymap = 1;
8358 p_hkmap = 0;
8359# ifdef FEAT_ARABIC
8360 curwin->w_p_arab = FALSE;
8361# endif
8362 (void)init_chartab();
8363 }
8364#endif
8365
8366#ifdef FEAT_ARABIC
8367 if ((int *)varp == &curwin->w_p_arab)
8368 {
8369 if (curwin->w_p_arab)
8370 {
8371 /*
8372 * 'arabic' is set, handle various sub-settings.
8373 */
8374 if (!p_tbidi)
8375 {
8376 /* set rightleft mode */
8377 if (!curwin->w_p_rl)
8378 {
8379 curwin->w_p_rl = TRUE;
8380 changed_window_setting();
8381 }
8382
8383 /* Enable Arabic shaping (major part of what Arabic requires) */
8384 if (!p_arshape)
8385 {
8386 p_arshape = TRUE;
8387 redraw_later_clear();
8388 }
8389 }
8390
8391 /* Arabic requires a utf-8 encoding, inform the user if its not
8392 * set. */
8393 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008394 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008395 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8396
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008397 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008398 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8399#ifdef FEAT_EVAL
8400 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8401#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008402 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008403
8404# ifdef FEAT_MBYTE
8405 /* set 'delcombine' */
8406 p_deco = TRUE;
8407# endif
8408
8409# ifdef FEAT_KEYMAP
8410 /* Force-set the necessary keymap for arabic */
8411 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8412 OPT_LOCAL);
8413# endif
8414# ifdef FEAT_FKMAP
8415 p_altkeymap = 0;
8416 p_hkmap = 0;
8417 p_fkmap = 0;
8418 (void)init_chartab();
8419# endif
8420 }
8421 else
8422 {
8423 /*
8424 * 'arabic' is reset, handle various sub-settings.
8425 */
8426 if (!p_tbidi)
8427 {
8428 /* reset rightleft mode */
8429 if (curwin->w_p_rl)
8430 {
8431 curwin->w_p_rl = FALSE;
8432 changed_window_setting();
8433 }
8434
8435 /* 'arabicshape' isn't reset, it is a global option and
8436 * another window may still need it "on". */
8437 }
8438
8439 /* 'delcombine' isn't reset, it is a global option and another
8440 * window may still want it "on". */
8441
8442# ifdef FEAT_KEYMAP
8443 /* Revert to the default keymap */
8444 curbuf->b_p_iminsert = B_IMODE_NONE;
8445 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8446# endif
8447 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008448 }
8449
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008450#endif
8451
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008452#ifdef FEAT_TERMGUICOLORS
8453 /* 'termguicolors' */
8454 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008455 {
8456# ifdef FEAT_GUI
8457 if (!gui.in_use && !gui.starting)
8458# endif
8459 highlight_gui_started();
8460 }
8461#endif
8462
Bram Moolenaar071d4272004-06-13 20:20:40 +00008463 /*
8464 * End of handling side effects for bool options.
8465 */
8466
Bram Moolenaar53744302015-07-17 17:38:22 +02008467 /* after handling side effects, call autocommand */
8468
Bram Moolenaar071d4272004-06-13 20:20:40 +00008469 options[opt_idx].flags |= P_WAS_SET;
8470
Bram Moolenaar53744302015-07-17 17:38:22 +02008471#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8472 if (!starting)
8473 {
8474 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008475 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8476 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8477 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008478 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8479 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8480 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8481 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8482 reset_v_option_vars();
8483 }
8484#endif
8485
Bram Moolenaar071d4272004-06-13 20:20:40 +00008486 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008487 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008488 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008489 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008490 check_redraw(options[opt_idx].flags);
8491
8492 return NULL;
8493}
8494
8495/*
8496 * Set the value of a number option, and take care of side effects.
8497 * Returns NULL for success, or an error message for an error.
8498 */
8499 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008500set_num_option(
8501 int opt_idx, /* index in options[] table */
8502 char_u *varp, /* pointer to the option variable */
8503 long value, /* new value */
8504 char_u *errbuf, /* buffer for error messages */
8505 size_t errbuflen, /* length of "errbuf" */
8506 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008507 OPT_MODELINE */
8508{
8509 char_u *errmsg = NULL;
8510 long old_value = *(long *)varp;
8511 long old_Rows = Rows; /* remember old Rows */
8512 long old_Columns = Columns; /* remember old Columns */
8513 long *pp = (long *)varp;
8514
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008515 /* Disallow changing some options from secure mode. */
8516 if ((secure
8517#ifdef HAVE_SANDBOX
8518 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008519#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008520 ) && (options[opt_idx].flags & P_SECURE))
8521 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008522
8523 *pp = value;
8524#ifdef FEAT_EVAL
8525 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008526 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008527#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008528#ifdef FEAT_GUI
8529 need_mouse_correct = TRUE;
8530#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008531
Bram Moolenaar14f24742012-08-08 18:01:05 +02008532 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008533 {
8534 errmsg = e_positive;
8535 curbuf->b_p_sw = curbuf->b_p_ts;
8536 }
8537
8538 /*
8539 * Number options that need some action when changed
8540 */
8541#ifdef FEAT_WINDOWS
8542 if (pp == &p_wh || pp == &p_hh)
8543 {
8544 if (p_wh < 1)
8545 {
8546 errmsg = e_positive;
8547 p_wh = 1;
8548 }
8549 if (p_wmh > p_wh)
8550 {
8551 errmsg = e_winheight;
8552 p_wh = p_wmh;
8553 }
8554 if (p_hh < 0)
8555 {
8556 errmsg = e_positive;
8557 p_hh = 0;
8558 }
8559
8560 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008561 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008562 {
8563 if (pp == &p_wh && curwin->w_height < p_wh)
8564 win_setheight((int)p_wh);
8565 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8566 win_setheight((int)p_hh);
8567 }
8568 }
8569
8570 /* 'winminheight' */
8571 else if (pp == &p_wmh)
8572 {
8573 if (p_wmh < 0)
8574 {
8575 errmsg = e_positive;
8576 p_wmh = 0;
8577 }
8578 if (p_wmh > p_wh)
8579 {
8580 errmsg = e_winheight;
8581 p_wmh = p_wh;
8582 }
8583 win_setminheight();
8584 }
8585
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008586# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008587 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008588 {
8589 if (p_wiw < 1)
8590 {
8591 errmsg = e_positive;
8592 p_wiw = 1;
8593 }
8594 if (p_wmw > p_wiw)
8595 {
8596 errmsg = e_winwidth;
8597 p_wiw = p_wmw;
8598 }
8599
8600 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008601 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008602 win_setwidth((int)p_wiw);
8603 }
8604
8605 /* 'winminwidth' */
8606 else if (pp == &p_wmw)
8607 {
8608 if (p_wmw < 0)
8609 {
8610 errmsg = e_positive;
8611 p_wmw = 0;
8612 }
8613 if (p_wmw > p_wiw)
8614 {
8615 errmsg = e_winwidth;
8616 p_wmw = p_wiw;
8617 }
8618 win_setminheight();
8619 }
8620# endif
8621
8622#endif
8623
8624#ifdef FEAT_WINDOWS
8625 /* (re)set last window status line */
8626 else if (pp == &p_ls)
8627 {
8628 last_status(FALSE);
8629 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008630
8631 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008632 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008633 {
8634 shell_new_rows(); /* recompute window positions and heights */
8635 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008636#endif
8637
8638#ifdef FEAT_GUI
8639 else if (pp == &p_linespace)
8640 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008641 /* Recompute gui.char_height and resize the Vim window to keep the
8642 * same number of lines. */
8643 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008644 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008645 }
8646#endif
8647
8648#ifdef FEAT_FOLDING
8649 /* 'foldlevel' */
8650 else if (pp == &curwin->w_p_fdl)
8651 {
8652 if (curwin->w_p_fdl < 0)
8653 curwin->w_p_fdl = 0;
8654 newFoldLevel();
8655 }
8656
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008657 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008658 else if (pp == &curwin->w_p_fml)
8659 {
8660 foldUpdateAll(curwin);
8661 }
8662
8663 /* 'foldnestmax' */
8664 else if (pp == &curwin->w_p_fdn)
8665 {
8666 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8667 foldUpdateAll(curwin);
8668 }
8669
8670 /* 'foldcolumn' */
8671 else if (pp == &curwin->w_p_fdc)
8672 {
8673 if (curwin->w_p_fdc < 0)
8674 {
8675 errmsg = e_positive;
8676 curwin->w_p_fdc = 0;
8677 }
8678 else if (curwin->w_p_fdc > 12)
8679 {
8680 errmsg = e_invarg;
8681 curwin->w_p_fdc = 12;
8682 }
8683 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008684#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008685
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008686#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008687 /* 'shiftwidth' or 'tabstop' */
8688 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8689 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008690# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008691 if (foldmethodIsIndent(curwin))
8692 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008693# endif
8694# ifdef FEAT_CINDENT
8695 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8696 * parse 'cinoptions'. */
8697 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8698 parse_cino(curbuf);
8699# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008700 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008701#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008702
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008703#ifdef FEAT_MBYTE
8704 /* 'maxcombine' */
8705 else if (pp == &p_mco)
8706 {
8707 if (p_mco > MAX_MCO)
8708 p_mco = MAX_MCO;
8709 else if (p_mco < 0)
8710 p_mco = 0;
8711 screenclear(); /* will re-allocate the screen */
8712 }
8713#endif
8714
Bram Moolenaar071d4272004-06-13 20:20:40 +00008715 else if (pp == &curbuf->b_p_iminsert)
8716 {
8717 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8718 {
8719 errmsg = e_invarg;
8720 curbuf->b_p_iminsert = B_IMODE_NONE;
8721 }
8722 p_iminsert = curbuf->b_p_iminsert;
8723 if (termcap_active) /* don't do this in the alternate screen */
8724 showmode();
8725#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8726 /* Show/unshow value of 'keymap' in status lines. */
8727 status_redraw_curbuf();
8728#endif
8729 }
8730
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008731 else if (pp == &p_window)
8732 {
8733 if (p_window < 1)
8734 p_window = 1;
8735 else if (p_window >= Rows)
8736 p_window = Rows - 1;
8737 }
8738
Bram Moolenaar071d4272004-06-13 20:20:40 +00008739 else if (pp == &curbuf->b_p_imsearch)
8740 {
8741 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8742 {
8743 errmsg = e_invarg;
8744 curbuf->b_p_imsearch = B_IMODE_NONE;
8745 }
8746 p_imsearch = curbuf->b_p_imsearch;
8747 }
8748
8749#ifdef FEAT_TITLE
8750 /* if 'titlelen' has changed, redraw the title */
8751 else if (pp == &p_titlelen)
8752 {
8753 if (p_titlelen < 0)
8754 {
8755 errmsg = e_positive;
8756 p_titlelen = 85;
8757 }
8758 if (starting != NO_SCREEN && old_value != p_titlelen)
8759 need_maketitle = TRUE;
8760 }
8761#endif
8762
8763 /* if p_ch changed value, change the command line height */
8764 else if (pp == &p_ch)
8765 {
8766 if (p_ch < 1)
8767 {
8768 errmsg = e_positive;
8769 p_ch = 1;
8770 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008771 if (p_ch > Rows - min_rows() + 1)
8772 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008773
8774 /* Only compute the new window layout when startup has been
8775 * completed. Otherwise the frame sizes may be wrong. */
8776 if (p_ch != old_value && full_screen
8777#ifdef FEAT_GUI
8778 && !gui.starting
8779#endif
8780 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008781 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008782 }
8783
8784 /* when 'updatecount' changes from zero to non-zero, open swap files */
8785 else if (pp == &p_uc)
8786 {
8787 if (p_uc < 0)
8788 {
8789 errmsg = e_positive;
8790 p_uc = 100;
8791 }
8792 if (p_uc && !old_value)
8793 ml_open_files();
8794 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008795#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008796 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008797 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008798 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008799 {
8800 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008801 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008802 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008803 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008804 {
8805 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008806 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008807 }
8808 }
8809#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008810#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008811 else if (pp == &p_mzq)
8812 mzvim_reset_timer();
8813#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008814
8815 /* sync undo before 'undolevels' changes */
8816 else if (pp == &p_ul)
8817 {
8818 /* use the old value, otherwise u_sync() may not work properly */
8819 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008820 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008821 p_ul = value;
8822 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008823 else if (pp == &curbuf->b_p_ul)
8824 {
8825 /* use the old value, otherwise u_sync() may not work properly */
8826 curbuf->b_p_ul = old_value;
8827 u_sync(TRUE);
8828 curbuf->b_p_ul = value;
8829 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008830
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008831#ifdef FEAT_LINEBREAK
8832 /* 'numberwidth' must be positive */
8833 else if (pp == &curwin->w_p_nuw)
8834 {
8835 if (curwin->w_p_nuw < 1)
8836 {
8837 errmsg = e_positive;
8838 curwin->w_p_nuw = 1;
8839 }
8840 if (curwin->w_p_nuw > 10)
8841 {
8842 errmsg = e_invarg;
8843 curwin->w_p_nuw = 10;
8844 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008845 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008846 }
8847#endif
8848
Bram Moolenaar1a384422010-07-14 19:53:30 +02008849 else if (pp == &curbuf->b_p_tw)
8850 {
8851 if (curbuf->b_p_tw < 0)
8852 {
8853 errmsg = e_positive;
8854 curbuf->b_p_tw = 0;
8855 }
8856#ifdef FEAT_SYN_HL
8857# ifdef FEAT_WINDOWS
8858 {
8859 win_T *wp;
8860 tabpage_T *tp;
8861
8862 FOR_ALL_TAB_WINDOWS(tp, wp)
8863 check_colorcolumn(wp);
8864 }
8865# else
8866 check_colorcolumn(curwin);
8867# endif
8868#endif
8869 }
8870
Bram Moolenaar071d4272004-06-13 20:20:40 +00008871 /*
8872 * Check the bounds for numeric options here
8873 */
8874 if (Rows < min_rows() && full_screen)
8875 {
8876 if (errbuf != NULL)
8877 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008878 vim_snprintf((char *)errbuf, errbuflen,
8879 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008880 errmsg = errbuf;
8881 }
8882 Rows = min_rows();
8883 }
8884 if (Columns < MIN_COLUMNS && full_screen)
8885 {
8886 if (errbuf != NULL)
8887 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008888 vim_snprintf((char *)errbuf, errbuflen,
8889 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008890 errmsg = errbuf;
8891 }
8892 Columns = MIN_COLUMNS;
8893 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008894 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008895
Bram Moolenaar071d4272004-06-13 20:20:40 +00008896 /*
8897 * If the screen (shell) height has been changed, assume it is the
8898 * physical screenheight.
8899 */
8900 if (old_Rows != Rows || old_Columns != Columns)
8901 {
8902 /* Changing the screen size is not allowed while updating the screen. */
8903 if (updating_screen)
8904 *pp = old_value;
8905 else if (full_screen
8906#ifdef FEAT_GUI
8907 && !gui.starting
8908#endif
8909 )
8910 set_shellsize((int)Columns, (int)Rows, TRUE);
8911 else
8912 {
8913 /* Postpone the resizing; check the size and cmdline position for
8914 * messages. */
8915 check_shellsize();
8916 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8917 cmdline_row = Rows - p_ch;
8918 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008919 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008920 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008921 }
8922
Bram Moolenaar071d4272004-06-13 20:20:40 +00008923 if (curbuf->b_p_ts <= 0)
8924 {
8925 errmsg = e_positive;
8926 curbuf->b_p_ts = 8;
8927 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008928 if (p_tm < 0)
8929 {
8930 errmsg = e_positive;
8931 p_tm = 0;
8932 }
8933 if ((curwin->w_p_scr <= 0
8934 || (curwin->w_p_scr > curwin->w_height
8935 && curwin->w_height > 0))
8936 && full_screen)
8937 {
8938 if (pp == &(curwin->w_p_scr))
8939 {
8940 if (curwin->w_p_scr != 0)
8941 errmsg = e_scroll;
8942 win_comp_scroll(curwin);
8943 }
8944 /* If 'scroll' became invalid because of a side effect silently adjust
8945 * it. */
8946 else if (curwin->w_p_scr <= 0)
8947 curwin->w_p_scr = 1;
8948 else /* curwin->w_p_scr > curwin->w_height */
8949 curwin->w_p_scr = curwin->w_height;
8950 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008951 if (p_hi < 0)
8952 {
8953 errmsg = e_positive;
8954 p_hi = 0;
8955 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008956 else if (p_hi > 10000)
8957 {
8958 errmsg = e_invarg;
8959 p_hi = 10000;
8960 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008961 if (p_re < 0 || p_re > 2)
8962 {
8963 errmsg = e_invarg;
8964 p_re = 0;
8965 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008966 if (p_report < 0)
8967 {
8968 errmsg = e_positive;
8969 p_report = 1;
8970 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008971 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008972 {
8973 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8974 p_sj = Rows / 2;
8975 else
8976 {
8977 errmsg = e_scroll;
8978 p_sj = 1;
8979 }
8980 }
8981 if (p_so < 0 && full_screen)
8982 {
8983 errmsg = e_scroll;
8984 p_so = 0;
8985 }
8986 if (p_siso < 0 && full_screen)
8987 {
8988 errmsg = e_positive;
8989 p_siso = 0;
8990 }
8991#ifdef FEAT_CMDWIN
8992 if (p_cwh < 1)
8993 {
8994 errmsg = e_positive;
8995 p_cwh = 1;
8996 }
8997#endif
8998 if (p_ut < 0)
8999 {
9000 errmsg = e_positive;
9001 p_ut = 2000;
9002 }
9003 if (p_ss < 0)
9004 {
9005 errmsg = e_positive;
9006 p_ss = 0;
9007 }
9008
9009 /* May set global value for local option. */
9010 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9011 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9012
9013 options[opt_idx].flags |= P_WAS_SET;
9014
Bram Moolenaar53744302015-07-17 17:38:22 +02009015#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9016 if (!starting && errmsg == NULL)
9017 {
9018 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009019 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9020 vim_snprintf((char *)buf_new, 10, "%ld", value);
9021 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009022 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9023 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9024 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9025 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9026 reset_v_option_vars();
9027 }
9028#endif
9029
Bram Moolenaar071d4272004-06-13 20:20:40 +00009030 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009031 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009032 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009033 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009034 check_redraw(options[opt_idx].flags);
9035
9036 return errmsg;
9037}
9038
9039/*
9040 * Called after an option changed: check if something needs to be redrawn.
9041 */
9042 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009043check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009044{
9045 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009046 int doclear = (flags & P_RCLR) == P_RCLR;
9047 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009048
9049#ifdef FEAT_WINDOWS
9050 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9051 status_redraw_all();
9052#endif
9053
9054 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9055 changed_window_setting();
9056 if (flags & P_RBUF)
9057 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009058 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009059 redraw_all_later(CLEAR);
9060 else if (all)
9061 redraw_all_later(NOT_VALID);
9062}
9063
9064/*
9065 * Find index for option 'arg'.
9066 * Return -1 if not found.
9067 */
9068 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009069findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009070{
9071 int opt_idx;
9072 char *s, *p;
9073 static short quick_tab[27] = {0, 0}; /* quick access table */
9074 int is_term_opt;
9075
9076 /*
9077 * For first call: Initialize the quick-access table.
9078 * It contains the index for the first option that starts with a certain
9079 * letter. There are 26 letters, plus the first "t_" option.
9080 */
9081 if (quick_tab[1] == 0)
9082 {
9083 p = options[0].fullname;
9084 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9085 {
9086 if (s[0] != p[0])
9087 {
9088 if (s[0] == 't' && s[1] == '_')
9089 quick_tab[26] = opt_idx;
9090 else
9091 quick_tab[CharOrdLow(s[0])] = opt_idx;
9092 }
9093 p = s;
9094 }
9095 }
9096
9097 /*
9098 * Check for name starting with an illegal character.
9099 */
9100#ifdef EBCDIC
9101 if (!islower(arg[0]))
9102#else
9103 if (arg[0] < 'a' || arg[0] > 'z')
9104#endif
9105 return -1;
9106
9107 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9108 if (is_term_opt)
9109 opt_idx = quick_tab[26];
9110 else
9111 opt_idx = quick_tab[CharOrdLow(arg[0])];
9112 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9113 {
9114 if (STRCMP(arg, s) == 0) /* match full name */
9115 break;
9116 }
9117 if (s == NULL && !is_term_opt)
9118 {
9119 opt_idx = quick_tab[CharOrdLow(arg[0])];
9120 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9121 {
9122 s = options[opt_idx].shortname;
9123 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9124 break;
9125 s = NULL;
9126 }
9127 }
9128 if (s == NULL)
9129 opt_idx = -1;
9130 return opt_idx;
9131}
9132
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009133#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009134/*
9135 * Get the value for an option.
9136 *
9137 * Returns:
9138 * Number or Toggle option: 1, *numval gets value.
9139 * String option: 0, *stringval gets allocated string.
9140 * Hidden Number or Toggle option: -1.
9141 * hidden String option: -2.
9142 * unknown option: -3.
9143 */
9144 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009145get_option_value(
9146 char_u *name,
9147 long *numval,
9148 char_u **stringval, /* NULL when only checking existence */
9149 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009150{
9151 int opt_idx;
9152 char_u *varp;
9153
9154 opt_idx = findoption(name);
9155 if (opt_idx < 0) /* unknown option */
9156 return -3;
9157
9158 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9159
9160 if (options[opt_idx].flags & P_STRING)
9161 {
9162 if (varp == NULL) /* hidden option */
9163 return -2;
9164 if (stringval != NULL)
9165 {
9166#ifdef FEAT_CRYPT
9167 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009168 if ((char_u **)varp == &curbuf->b_p_key
9169 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009170 *stringval = vim_strsave((char_u *)"*****");
9171 else
9172#endif
9173 *stringval = vim_strsave(*(char_u **)(varp));
9174 }
9175 return 0;
9176 }
9177
9178 if (varp == NULL) /* hidden option */
9179 return -1;
9180 if (options[opt_idx].flags & P_NUM)
9181 *numval = *(long *)varp;
9182 else
9183 {
9184 /* Special case: 'modified' is b_changed, but we also want to consider
9185 * it set when 'ff' or 'fenc' changed. */
9186 if ((int *)varp == &curbuf->b_changed)
9187 *numval = curbufIsChanged();
9188 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009189 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009190 }
9191 return 1;
9192}
9193#endif
9194
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009195#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009196/*
9197 * Returns the option attributes and its value. Unlike the above function it
9198 * will return either global value or local value of the option depending on
9199 * what was requested, but it will never return global value if it was
9200 * requested to return local one and vice versa. Neither it will return
9201 * buffer-local value if it was requested to return window-local one.
9202 *
9203 * Pretends that option is absent if it is not present in the requested scope
9204 * (i.e. has no global, window-local or buffer-local value depending on
9205 * opt_type). Uses
9206 *
9207 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009208 * 0 hidden or unknown option, also option that does not have requested
9209 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009210 * see SOPT_* in vim.h for other flags
9211 *
9212 * Possible opt_type values: see SREQ_* in vim.h
9213 */
9214 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009215get_option_value_strict(
9216 char_u *name,
9217 long *numval,
9218 char_u **stringval, /* NULL when only obtaining attributes */
9219 int opt_type,
9220 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009221{
9222 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009223 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009224 struct vimoption *p;
9225 int r = 0;
9226
9227 opt_idx = findoption(name);
9228 if (opt_idx < 0)
9229 return 0;
9230
9231 p = &(options[opt_idx]);
9232
9233 /* Hidden option */
9234 if (p->var == NULL)
9235 return 0;
9236
9237 if (p->flags & P_BOOL)
9238 r |= SOPT_BOOL;
9239 else if (p->flags & P_NUM)
9240 r |= SOPT_NUM;
9241 else if (p->flags & P_STRING)
9242 r |= SOPT_STRING;
9243
9244 if (p->indir == PV_NONE)
9245 {
9246 if (opt_type == SREQ_GLOBAL)
9247 r |= SOPT_GLOBAL;
9248 else
9249 return 0; /* Did not request global-only option */
9250 }
9251 else
9252 {
9253 if (p->indir & PV_BOTH)
9254 r |= SOPT_GLOBAL;
9255 else if (opt_type == SREQ_GLOBAL)
9256 return 0; /* Requested global option */
9257
9258 if (p->indir & PV_WIN)
9259 {
9260 if (opt_type == SREQ_BUF)
9261 return 0; /* Did not request window-local option */
9262 else
9263 r |= SOPT_WIN;
9264 }
9265 else if (p->indir & PV_BUF)
9266 {
9267 if (opt_type == SREQ_WIN)
9268 return 0; /* Did not request buffer-local option */
9269 else
9270 r |= SOPT_BUF;
9271 }
9272 }
9273
9274 if (stringval == NULL)
9275 return r;
9276
9277 if (opt_type == SREQ_GLOBAL)
9278 varp = p->var;
9279 else
9280 {
9281 if (opt_type == SREQ_BUF)
9282 {
9283 /* Special case: 'modified' is b_changed, but we also want to
9284 * consider it set when 'ff' or 'fenc' changed. */
9285 if (p->indir == PV_MOD)
9286 {
9287 *numval = bufIsChanged((buf_T *) from);
9288 varp = NULL;
9289 }
9290#ifdef FEAT_CRYPT
9291 else if (p->indir == PV_KEY)
9292 {
9293 /* never return the value of the crypt key */
9294 *stringval = NULL;
9295 varp = NULL;
9296 }
9297#endif
9298 else
9299 {
9300 aco_save_T aco;
9301 aucmd_prepbuf(&aco, (buf_T *) from);
9302 varp = get_varp(p);
9303 aucmd_restbuf(&aco);
9304 }
9305 }
9306 else if (opt_type == SREQ_WIN)
9307 {
9308 win_T *save_curwin;
9309 save_curwin = curwin;
9310 curwin = (win_T *) from;
9311 curbuf = curwin->w_buffer;
9312 varp = get_varp(p);
9313 curwin = save_curwin;
9314 curbuf = curwin->w_buffer;
9315 }
9316 if (varp == p->var)
9317 return (r | SOPT_UNSET);
9318 }
9319
9320 if (varp != NULL)
9321 {
9322 if (p->flags & P_STRING)
9323 *stringval = vim_strsave(*(char_u **)(varp));
9324 else if (p->flags & P_NUM)
9325 *numval = *(long *) varp;
9326 else
9327 *numval = *(int *)varp;
9328 }
9329
9330 return r;
9331}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009332
9333/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009334 * Iterate over options. First argument is a pointer to a pointer to a
9335 * structure inside options[] array, second is option type like in the above
9336 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009337 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009338 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009339 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009340 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009341 * first argument to NULL.
9342 *
9343 * Returns full option name for current option on each call.
9344 */
9345 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009346option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009347{
9348 struct vimoption *ret = NULL;
9349 do
9350 {
9351 if (*option == NULL)
9352 *option = (void *) options;
9353 else if (((struct vimoption *) (*option))->fullname == NULL)
9354 {
9355 *option = NULL;
9356 return NULL;
9357 }
9358 else
9359 *option = (void *) (((struct vimoption *) (*option)) + 1);
9360
9361 ret = ((struct vimoption *) (*option));
9362
9363 /* Hidden option */
9364 if (ret->var == NULL)
9365 {
9366 ret = NULL;
9367 continue;
9368 }
9369
9370 switch (opt_type)
9371 {
9372 case SREQ_GLOBAL:
9373 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9374 ret = NULL;
9375 break;
9376 case SREQ_BUF:
9377 if (!(ret->indir & PV_BUF))
9378 ret = NULL;
9379 break;
9380 case SREQ_WIN:
9381 if (!(ret->indir & PV_WIN))
9382 ret = NULL;
9383 break;
9384 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009385 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009386 return NULL;
9387 }
9388 }
9389 while (ret == NULL);
9390
9391 return (char_u *)ret->fullname;
9392}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009393#endif
9394
Bram Moolenaar071d4272004-06-13 20:20:40 +00009395/*
9396 * Set the value of option "name".
9397 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009398 *
9399 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009400 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009401 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009402set_option_value(
9403 char_u *name,
9404 long number,
9405 char_u *string,
9406 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009407{
9408 int opt_idx;
9409 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009410 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009411
9412 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009413 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009414 EMSG2(_("E355: Unknown option: %s"), name);
9415 else
9416 {
9417 flags = options[opt_idx].flags;
9418#ifdef HAVE_SANDBOX
9419 /* Disallow changing some options in the sandbox */
9420 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009421 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009422 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009423 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009424 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009425#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009426 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009427 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009428 else
9429 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009430 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009431 if (varp != NULL) /* hidden option is not changed */
9432 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009433 if (number == 0 && string != NULL)
9434 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009435 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009436
9437 /* Either we are given a string or we are setting option
9438 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009439 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009440 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009441 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009442 {
9443 /* There's another character after zeros or the string
9444 * is empty. In both cases, we are trying to set a
9445 * num option using a string. */
9446 EMSG3(_("E521: Number required: &%s = '%s'"),
9447 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009448 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009449
9450 }
9451 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009452 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009453 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009454 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009455 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009456 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009457 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009458 }
9459 }
9460 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009461 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009462}
9463
9464/*
9465 * Get the terminal code for a terminal option.
9466 * Returns NULL when not found.
9467 */
9468 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009469get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009470{
9471 int opt_idx;
9472 char_u *varp;
9473
9474 if (tname[0] != 't' || tname[1] != '_' ||
9475 tname[2] == NUL || tname[3] == NUL)
9476 return NULL;
9477 if ((opt_idx = findoption(tname)) >= 0)
9478 {
9479 varp = get_varp(&(options[opt_idx]));
9480 if (varp != NULL)
9481 varp = *(char_u **)(varp);
9482 return varp;
9483 }
9484 return find_termcode(tname + 2);
9485}
9486
9487 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009488get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009489{
9490 int i;
9491
9492 i = findoption((char_u *)"hl");
9493 if (i >= 0)
9494 return options[i].def_val[VI_DEFAULT];
9495 return (char_u *)NULL;
9496}
9497
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009498#if defined(FEAT_MBYTE) || defined(PROTO)
9499 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009500get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009501{
9502 int i;
9503
9504 i = findoption((char_u *)"enc");
9505 if (i >= 0)
9506 return options[i].def_val[VI_DEFAULT];
9507 return (char_u *)NULL;
9508}
9509#endif
9510
Bram Moolenaar071d4272004-06-13 20:20:40 +00009511/*
9512 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9513 */
9514 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009515find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009516{
9517 int key;
9518 int modifiers;
9519
9520 /*
9521 * Don't use get_special_key_code() for t_xx, we don't want it to call
9522 * add_termcap_entry().
9523 */
9524 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9525 key = TERMCAP2KEY(arg[2], arg[3]);
9526 else
9527 {
9528 --arg; /* put arg at the '<' */
9529 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009530 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009531 if (modifiers) /* can't handle modifiers here */
9532 key = 0;
9533 }
9534 return key;
9535}
9536
9537/*
9538 * if 'all' == 0: show changed options
9539 * if 'all' == 1: show all normal options
9540 * if 'all' == 2: show all terminal options
9541 */
9542 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009543showoptions(
9544 int all,
9545 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009546{
9547 struct vimoption *p;
9548 int col;
9549 int isterm;
9550 char_u *varp;
9551 struct vimoption **items;
9552 int item_count;
9553 int run;
9554 int row, rows;
9555 int cols;
9556 int i;
9557 int len;
9558
9559#define INC 20
9560#define GAP 3
9561
9562 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9563 PARAM_COUNT));
9564 if (items == NULL)
9565 return;
9566
9567 /* Highlight title */
9568 if (all == 2)
9569 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9570 else if (opt_flags & OPT_GLOBAL)
9571 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9572 else if (opt_flags & OPT_LOCAL)
9573 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9574 else
9575 MSG_PUTS_TITLE(_("\n--- Options ---"));
9576
9577 /*
9578 * do the loop two times:
9579 * 1. display the short items
9580 * 2. display the long items (only strings and numbers)
9581 */
9582 for (run = 1; run <= 2 && !got_int; ++run)
9583 {
9584 /*
9585 * collect the items in items[]
9586 */
9587 item_count = 0;
9588 for (p = &options[0]; p->fullname != NULL; p++)
9589 {
9590 varp = NULL;
9591 isterm = istermoption(p);
9592 if (opt_flags != 0)
9593 {
9594 if (p->indir != PV_NONE && !isterm)
9595 varp = get_varp_scope(p, opt_flags);
9596 }
9597 else
9598 varp = get_varp(p);
9599 if (varp != NULL
9600 && ((all == 2 && isterm)
9601 || (all == 1 && !isterm)
9602 || (all == 0 && !optval_default(p, varp))))
9603 {
9604 if (p->flags & P_BOOL)
9605 len = 1; /* a toggle option fits always */
9606 else
9607 {
9608 option_value2string(p, opt_flags);
9609 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9610 }
9611 if ((len <= INC - GAP && run == 1) ||
9612 (len > INC - GAP && run == 2))
9613 items[item_count++] = p;
9614 }
9615 }
9616
9617 /*
9618 * display the items
9619 */
9620 if (run == 1)
9621 {
9622 cols = (Columns + GAP - 3) / INC;
9623 if (cols == 0)
9624 cols = 1;
9625 rows = (item_count + cols - 1) / cols;
9626 }
9627 else /* run == 2 */
9628 rows = item_count;
9629 for (row = 0; row < rows && !got_int; ++row)
9630 {
9631 msg_putchar('\n'); /* go to next line */
9632 if (got_int) /* 'q' typed in more */
9633 break;
9634 col = 0;
9635 for (i = row; i < item_count; i += rows)
9636 {
9637 msg_col = col; /* make columns */
9638 showoneopt(items[i], opt_flags);
9639 col += INC;
9640 }
9641 out_flush();
9642 ui_breakcheck();
9643 }
9644 }
9645 vim_free(items);
9646}
9647
9648/*
9649 * Return TRUE if option "p" has its default value.
9650 */
9651 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009652optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009653{
9654 int dvi;
9655
9656 if (varp == NULL)
9657 return TRUE; /* hidden option is always at default */
9658 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9659 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009660 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009661 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009662 /* the cast to long is required for Manx C, long_i is
9663 * needed for MSVC */
9664 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009665 /* P_STRING */
9666 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9667}
9668
9669/*
9670 * showoneopt: show the value of one option
9671 * must not be called with a hidden option!
9672 */
9673 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009674showoneopt(
9675 struct vimoption *p,
9676 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009677{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009678 char_u *varp;
9679 int save_silent = silent_mode;
9680
9681 silent_mode = FALSE;
9682 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009683
9684 varp = get_varp_scope(p, opt_flags);
9685
9686 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9687 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9688 ? !curbufIsChanged() : !*(int *)varp))
9689 MSG_PUTS("no");
9690 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9691 MSG_PUTS("--");
9692 else
9693 MSG_PUTS(" ");
9694 MSG_PUTS(p->fullname);
9695 if (!(p->flags & P_BOOL))
9696 {
9697 msg_putchar('=');
9698 /* put value string in NameBuff */
9699 option_value2string(p, opt_flags);
9700 msg_outtrans(NameBuff);
9701 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009702
9703 silent_mode = save_silent;
9704 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009705}
9706
9707/*
9708 * Write modified options as ":set" commands to a file.
9709 *
9710 * There are three values for "opt_flags":
9711 * OPT_GLOBAL: Write global option values and fresh values of
9712 * buffer-local options (used for start of a session
9713 * file).
9714 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9715 * curwin (used for a vimrc file).
9716 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9717 * and local values for window-local options of
9718 * curwin. Local values are also written when at the
9719 * default value, because a modeline or autocommand
9720 * may have set them when doing ":edit file" and the
9721 * user has set them back at the default or fresh
9722 * value.
9723 * When "local_only" is TRUE, don't write fresh
9724 * values, only local values (for ":mkview").
9725 * (fresh value = value used for a new buffer or window for a local option).
9726 *
9727 * Return FAIL on error, OK otherwise.
9728 */
9729 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009730makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009731{
9732 struct vimoption *p;
9733 char_u *varp; /* currently used value */
9734 char_u *varp_fresh; /* local value */
9735 char_u *varp_local = NULL; /* fresh value */
9736 char *cmd;
9737 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009738 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009739
9740 /*
9741 * The options that don't have a default (terminal name, columns, lines)
9742 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009743 * Do the loop over "options[]" twice: once for options with the
9744 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009745 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009746 for (pri = 1; pri >= 0; --pri)
9747 {
9748 for (p = &options[0]; !istermoption(p); p++)
9749 if (!(p->flags & P_NO_MKRC)
9750 && !istermoption(p)
9751 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009752 {
9753 /* skip global option when only doing locals */
9754 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9755 continue;
9756
9757 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9758 * file, they are always buffer-specific. */
9759 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9760 continue;
9761
9762 /* Global values are only written when not at the default value. */
9763 varp = get_varp_scope(p, opt_flags);
9764 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9765 continue;
9766
9767 round = 2;
9768 if (p->indir != PV_NONE)
9769 {
9770 if (p->var == VAR_WIN)
9771 {
9772 /* skip window-local option when only doing globals */
9773 if (!(opt_flags & OPT_LOCAL))
9774 continue;
9775 /* When fresh value of window-local option is not at the
9776 * default, need to write it too. */
9777 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9778 {
9779 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9780 if (!optval_default(p, varp_fresh))
9781 {
9782 round = 1;
9783 varp_local = varp;
9784 varp = varp_fresh;
9785 }
9786 }
9787 }
9788 }
9789
9790 /* Round 1: fresh value for window-local options.
9791 * Round 2: other values */
9792 for ( ; round <= 2; varp = varp_local, ++round)
9793 {
9794 if (round == 1 || (opt_flags & OPT_GLOBAL))
9795 cmd = "set";
9796 else
9797 cmd = "setlocal";
9798
9799 if (p->flags & P_BOOL)
9800 {
9801 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9802 return FAIL;
9803 }
9804 else if (p->flags & P_NUM)
9805 {
9806 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9807 return FAIL;
9808 }
9809 else /* P_STRING */
9810 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009811#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9812 int do_endif = FALSE;
9813
Bram Moolenaar071d4272004-06-13 20:20:40 +00009814 /* Don't set 'syntax' and 'filetype' again if the value is
9815 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009816 if (
9817# if defined(FEAT_SYN_HL)
9818 p->indir == PV_SYN
9819# if defined(FEAT_AUTOCMD)
9820 ||
9821# endif
9822# endif
9823# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009824 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009825# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009826 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009827 {
9828 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9829 *(char_u **)(varp)) < 0
9830 || put_eol(fd) < 0)
9831 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009832 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009833 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009834#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009835 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9836 (p->flags & P_EXPAND) != 0) == FAIL)
9837 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009838#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9839 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009840 {
9841 if (put_line(fd, "endif") == FAIL)
9842 return FAIL;
9843 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009844#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009845 }
9846 }
9847 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009848 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009849 return OK;
9850}
9851
9852#if defined(FEAT_FOLDING) || defined(PROTO)
9853/*
9854 * Generate set commands for the local fold options only. Used when
9855 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9856 */
9857 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009858makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009859{
9860 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9861# ifdef FEAT_EVAL
9862 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9863 == FAIL
9864# endif
9865 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9866 == FAIL
9867 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9868 == FAIL
9869 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9870 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9871 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9872 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9873 )
9874 return FAIL;
9875
9876 return OK;
9877}
9878#endif
9879
9880 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009881put_setstring(
9882 FILE *fd,
9883 char *cmd,
9884 char *name,
9885 char_u **valuep,
9886 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009887{
9888 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009889 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009890
9891 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9892 return FAIL;
9893 if (*valuep != NULL)
9894 {
9895 /* Output 'pastetoggle' as key names. For other
9896 * options some characters have to be escaped with
9897 * CTRL-V or backslash */
9898 if (valuep == &p_pt)
9899 {
9900 s = *valuep;
9901 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009902 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009903 return FAIL;
9904 }
9905 else if (expand)
9906 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009907 buf = alloc(MAXPATHL);
9908 if (buf == NULL)
9909 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009910 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9911 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009912 {
9913 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009914 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009915 }
9916 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009917 }
9918 else if (put_escstr(fd, *valuep, 2) == FAIL)
9919 return FAIL;
9920 }
9921 if (put_eol(fd) < 0)
9922 return FAIL;
9923 return OK;
9924}
9925
9926 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009927put_setnum(
9928 FILE *fd,
9929 char *cmd,
9930 char *name,
9931 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009932{
9933 long wc;
9934
9935 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9936 return FAIL;
9937 if (wc_use_keyname((char_u *)valuep, &wc))
9938 {
9939 /* print 'wildchar' and 'wildcharm' as a key name */
9940 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9941 return FAIL;
9942 }
9943 else if (fprintf(fd, "%ld", *valuep) < 0)
9944 return FAIL;
9945 if (put_eol(fd) < 0)
9946 return FAIL;
9947 return OK;
9948}
9949
9950 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009951put_setbool(
9952 FILE *fd,
9953 char *cmd,
9954 char *name,
9955 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009956{
Bram Moolenaar893de922007-10-02 18:40:57 +00009957 if (value < 0) /* global/local option using global value */
9958 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009959 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9960 || put_eol(fd) < 0)
9961 return FAIL;
9962 return OK;
9963}
9964
9965/*
9966 * Clear all the terminal options.
9967 * If the option has been allocated, free the memory.
9968 * Terminal options are never hidden or indirect.
9969 */
9970 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009971clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009972{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009973 /*
9974 * Reset a few things before clearing the old options. This may cause
9975 * outputting a few things that the terminal doesn't understand, but the
9976 * screen will be cleared later, so this is OK.
9977 */
9978#ifdef FEAT_MOUSE_TTY
9979 mch_setmouse(FALSE); /* switch mouse off */
9980#endif
9981#ifdef FEAT_TITLE
9982 mch_restore_title(3); /* restore window titles */
9983#endif
9984#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9985 /* When starting the GUI close the display opened for the clipboard.
9986 * After restoring the title, because that will need the display. */
9987 if (gui.starting)
9988 clear_xterm_clip();
9989#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +02009990 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009991
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009992 free_termoptions();
9993}
9994
9995 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009996free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009997{
9998 struct vimoption *p;
9999
Bram Moolenaar071d4272004-06-13 20:20:40 +000010000 for (p = &options[0]; p->fullname != NULL; p++)
10001 if (istermoption(p))
10002 {
10003 if (p->flags & P_ALLOCED)
10004 free_string_option(*(char_u **)(p->var));
10005 if (p->flags & P_DEF_ALLOCED)
10006 free_string_option(p->def_val[VI_DEFAULT]);
10007 *(char_u **)(p->var) = empty_option;
10008 p->def_val[VI_DEFAULT] = empty_option;
10009 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10010 }
10011 clear_termcodes();
10012}
10013
10014/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010015 * Free the string for one term option, if it was allocated.
10016 * Set the string to empty_option and clear allocated flag.
10017 * "var" points to the option value.
10018 */
10019 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010020free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010021{
10022 struct vimoption *p;
10023
10024 for (p = &options[0]; p->fullname != NULL; p++)
10025 if (p->var == var)
10026 {
10027 if (p->flags & P_ALLOCED)
10028 free_string_option(*(char_u **)(p->var));
10029 *(char_u **)(p->var) = empty_option;
10030 p->flags &= ~P_ALLOCED;
10031 break;
10032 }
10033}
10034
10035/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010036 * Set the terminal option defaults to the current value.
10037 * Used after setting the terminal name.
10038 */
10039 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010040set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010041{
10042 struct vimoption *p;
10043
10044 for (p = &options[0]; p->fullname != NULL; p++)
10045 {
10046 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10047 {
10048 if (p->flags & P_DEF_ALLOCED)
10049 {
10050 free_string_option(p->def_val[VI_DEFAULT]);
10051 p->flags &= ~P_DEF_ALLOCED;
10052 }
10053 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10054 if (p->flags & P_ALLOCED)
10055 {
10056 p->flags |= P_DEF_ALLOCED;
10057 p->flags &= ~P_ALLOCED; /* don't free the value now */
10058 }
10059 }
10060 }
10061}
10062
10063/*
10064 * return TRUE if 'p' starts with 't_'
10065 */
10066 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010067istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010068{
10069 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10070}
10071
10072/*
10073 * Compute columns for ruler and shown command. 'sc_col' is also used to
10074 * decide what the maximum length of a message on the status line can be.
10075 * If there is a status line for the last window, 'sc_col' is independent
10076 * of 'ru_col'.
10077 */
10078
10079#define COL_RULER 17 /* columns needed by standard ruler */
10080
10081 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010082comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010083{
10084#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010085 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010086
10087 sc_col = 0;
10088 ru_col = 0;
10089 if (p_ru)
10090 {
10091#ifdef FEAT_STL_OPT
10092 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10093#else
10094 ru_col = COL_RULER + 1;
10095#endif
10096 /* no last status line, adjust sc_col */
10097 if (!last_has_status)
10098 sc_col = ru_col;
10099 }
10100 if (p_sc)
10101 {
10102 sc_col += SHOWCMD_COLS;
10103 if (!p_ru || last_has_status) /* no need for separating space */
10104 ++sc_col;
10105 }
10106 sc_col = Columns - sc_col;
10107 ru_col = Columns - ru_col;
10108 if (sc_col <= 0) /* screen too narrow, will become a mess */
10109 sc_col = 1;
10110 if (ru_col <= 0)
10111 ru_col = 1;
10112#else
10113 sc_col = Columns;
10114 ru_col = Columns;
10115#endif
10116}
10117
10118/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010119 * Unset local option value, similar to ":set opt<".
10120 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010121 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010122unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010123{
10124 struct vimoption *p;
10125 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010126 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010127
10128 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010129 if (opt_idx < 0)
10130 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010131 p = &(options[opt_idx]);
10132
10133 switch ((int)p->indir)
10134 {
10135 /* global option with local value: use local value if it's been set */
10136 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010137 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010138 break;
10139 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010140 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010141 break;
10142 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010143 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010144 break;
10145 case PV_AR:
10146 buf->b_p_ar = -1;
10147 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010148 case PV_BKC:
10149 clear_string_option(&buf->b_p_bkc);
10150 buf->b_bkc_flags = 0;
10151 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010152 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010153 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010154 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010155 case PV_TC:
10156 clear_string_option(&buf->b_p_tc);
10157 buf->b_tc_flags = 0;
10158 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010159#ifdef FEAT_FIND_ID
10160 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010161 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010162 break;
10163 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010164 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010165 break;
10166#endif
10167#ifdef FEAT_INS_EXPAND
10168 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010169 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010170 break;
10171 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010172 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010173 break;
10174#endif
10175#ifdef FEAT_QUICKFIX
10176 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010177 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010178 break;
10179 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010180 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010181 break;
10182 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010183 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010184 break;
10185#endif
10186#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10187 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010188 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010189 break;
10190#endif
10191#if defined(FEAT_CRYPT)
10192 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010193 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010194 break;
10195#endif
10196#ifdef FEAT_STL_OPT
10197 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010198 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010199 break;
10200#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010201 case PV_UL:
10202 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10203 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010204#ifdef FEAT_LISP
10205 case PV_LW:
10206 clear_string_option(&buf->b_p_lw);
10207 break;
10208#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010209 }
10210}
10211
10212/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010213 * Get pointer to option variable, depending on local or global scope.
10214 */
10215 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010216get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010217{
10218 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10219 {
10220 if (p->var == VAR_WIN)
10221 return (char_u *)GLOBAL_WO(get_varp(p));
10222 return p->var;
10223 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010224 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010225 {
10226 switch ((int)p->indir)
10227 {
10228#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010229 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10230 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10231 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010232#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010233 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10234 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10235 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010236 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010237 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010238 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010239#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010240 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10241 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010242#endif
10243#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010244 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10245 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010246#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010247#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10248 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10249#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010250#if defined(FEAT_CRYPT)
10251 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10252#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010253#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010254 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010255#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010256 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010257#ifdef FEAT_LISP
10258 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10259#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010260 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010261 }
10262 return NULL; /* "cannot happen" */
10263 }
10264 return get_varp(p);
10265}
10266
10267/*
10268 * Get pointer to option variable.
10269 */
10270 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010271get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010272{
10273 /* hidden option, always return NULL */
10274 if (p->var == NULL)
10275 return NULL;
10276
10277 switch ((int)p->indir)
10278 {
10279 case PV_NONE: return p->var;
10280
10281 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010282 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010283 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010284 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010285 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010286 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010287 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010288 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010289 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010290 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010291 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010292 case PV_TC: return *curbuf->b_p_tc != NUL
10293 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010294 case PV_BKC: return *curbuf->b_p_bkc != NUL
10295 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010296#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010297 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010298 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010299 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010300 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10301#endif
10302#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010303 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010304 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010305 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010306 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10307#endif
10308#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010309 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010310 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010311 case PV_GP: return *curbuf->b_p_gp != NUL
10312 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10313 case PV_MP: return *curbuf->b_p_mp != NUL
10314 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010315#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010316#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10317 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10318 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10319#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010320#if defined(FEAT_CRYPT)
10321 case PV_CM: return *curbuf->b_p_cm != NUL
10322 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10323#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010324#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010325 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010326 ? (char_u *)&(curwin->w_p_stl) : p->var;
10327#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010328 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10329 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010330#ifdef FEAT_LISP
10331 case PV_LW: return *curbuf->b_p_lw != NUL
10332 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10333#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010334
10335#ifdef FEAT_ARABIC
10336 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10337#endif
10338 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010339#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010340 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10341#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010342#ifdef FEAT_SYN_HL
10343 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10344 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010345 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010346#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010347#ifdef FEAT_DIFF
10348 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10349#endif
10350#ifdef FEAT_FOLDING
10351 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10352 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10353 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10354 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10355 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10356 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10357 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10358# ifdef FEAT_EVAL
10359 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10360 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10361# endif
10362 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10363#endif
10364 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010365 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010366#ifdef FEAT_LINEBREAK
10367 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10368#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010369#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010370 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010371 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10372#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010373#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10374 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10375#endif
10376#ifdef FEAT_RIGHTLEFT
10377 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10378 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10379#endif
10380 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10381 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10382#ifdef FEAT_LINEBREAK
10383 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010384 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10385 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010386#endif
10387#ifdef FEAT_SCROLLBIND
10388 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10389#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010390#ifdef FEAT_CURSORBIND
10391 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10392#endif
10393#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010394 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10395 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010396#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010397
10398 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10399 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10400#ifdef FEAT_MBYTE
10401 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10402#endif
10403#if defined(FEAT_QUICKFIX)
10404 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10405 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10406#endif
10407 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10408 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10409#ifdef FEAT_CINDENT
10410 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10411 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10412 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10413#endif
10414#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10415 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10416#endif
10417#ifdef FEAT_COMMENTS
10418 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10419#endif
10420#ifdef FEAT_FOLDING
10421 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10422#endif
10423#ifdef FEAT_INS_EXPAND
10424 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10425#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010426#ifdef FEAT_COMPL_FUNC
10427 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010428 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010429#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010430 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010431 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010432 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10433#ifdef FEAT_MBYTE
10434 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10435#endif
10436 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10437#ifdef FEAT_AUTOCMD
10438 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10439#endif
10440 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010441 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010442 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10443 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10444 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10445 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10446#ifdef FEAT_FIND_ID
10447# ifdef FEAT_EVAL
10448 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10449# endif
10450#endif
10451#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10452 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10453 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10454#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010455#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010456 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10457#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010458#ifdef FEAT_CRYPT
10459 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10460#endif
10461#ifdef FEAT_LISP
10462 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10463#endif
10464 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10465 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10466 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10467 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10468 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010469 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010470#ifdef FEAT_TEXTOBJ
10471 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10472#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010473 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10474#ifdef FEAT_SMARTINDENT
10475 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10476#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010477 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010478 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10479#ifdef FEAT_SEARCHPATH
10480 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10481#endif
10482 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10483#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010484 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010485 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10486#endif
10487#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010488 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10489 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10490 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010491#endif
10492 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10493 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10494 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10495 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010496#ifdef FEAT_PERSISTENT_UNDO
10497 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10498#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010499 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10500#ifdef FEAT_KEYMAP
10501 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10502#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010503#ifdef FEAT_SIGNS
10504 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10505#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010506 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010507 }
10508 /* always return a valid pointer to avoid a crash! */
10509 return (char_u *)&(curbuf->b_p_wm);
10510}
10511
10512/*
10513 * Get the value of 'equalprg', either the buffer-local one or the global one.
10514 */
10515 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010516get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010517{
10518 if (*curbuf->b_p_ep == NUL)
10519 return p_ep;
10520 return curbuf->b_p_ep;
10521}
10522
10523#if defined(FEAT_WINDOWS) || defined(PROTO)
10524/*
10525 * Copy options from one window to another.
10526 * Used when splitting a window.
10527 */
10528 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010529win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010530{
10531 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10532 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10533# ifdef FEAT_RIGHTLEFT
10534# ifdef FEAT_FKMAP
10535 /* Is this right? */
10536 wp_to->w_farsi = wp_from->w_farsi;
10537# endif
10538# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010539#if defined(FEAT_LINEBREAK)
10540 briopt_check(wp_to);
10541#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010542}
10543#endif
10544
10545/*
10546 * Copy the options from one winopt_T to another.
10547 * Doesn't free the old option values in "to", use clear_winopt() for that.
10548 * The 'scroll' option is not copied, because it depends on the window height.
10549 * The 'previewwindow' option is reset, there can be only one preview window.
10550 */
10551 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010552copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010553{
10554#ifdef FEAT_ARABIC
10555 to->wo_arab = from->wo_arab;
10556#endif
10557 to->wo_list = from->wo_list;
10558 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010559 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010560#ifdef FEAT_LINEBREAK
10561 to->wo_nuw = from->wo_nuw;
10562#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010563#ifdef FEAT_RIGHTLEFT
10564 to->wo_rl = from->wo_rl;
10565 to->wo_rlc = vim_strsave(from->wo_rlc);
10566#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010567#ifdef FEAT_STL_OPT
10568 to->wo_stl = vim_strsave(from->wo_stl);
10569#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010571#ifdef FEAT_DIFF
10572 to->wo_wrap_save = from->wo_wrap_save;
10573#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010574#ifdef FEAT_LINEBREAK
10575 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010576 to->wo_bri = from->wo_bri;
10577 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010578#endif
10579#ifdef FEAT_SCROLLBIND
10580 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010581 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010582#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010583#ifdef FEAT_CURSORBIND
10584 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010585 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010586#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010587#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010588 to->wo_spell = from->wo_spell;
10589#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010590#ifdef FEAT_SYN_HL
10591 to->wo_cuc = from->wo_cuc;
10592 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010593 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010594#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010595#ifdef FEAT_DIFF
10596 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010597 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010598#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010599#ifdef FEAT_CONCEAL
10600 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010601 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010602#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010603#ifdef FEAT_FOLDING
10604 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010605 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010606 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010607 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010608 to->wo_fdi = vim_strsave(from->wo_fdi);
10609 to->wo_fml = from->wo_fml;
10610 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010611 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010612 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010613 to->wo_fdm_save = from->wo_diff_saved
10614 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010615 to->wo_fdn = from->wo_fdn;
10616# ifdef FEAT_EVAL
10617 to->wo_fde = vim_strsave(from->wo_fde);
10618 to->wo_fdt = vim_strsave(from->wo_fdt);
10619# endif
10620 to->wo_fmr = vim_strsave(from->wo_fmr);
10621#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010622#ifdef FEAT_SIGNS
10623 to->wo_scl = vim_strsave(from->wo_scl);
10624#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010625 check_winopt(to); /* don't want NULL pointers */
10626}
10627
10628/*
10629 * Check string options in a window for a NULL value.
10630 */
10631 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010632check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010633{
10634 check_winopt(&win->w_onebuf_opt);
10635 check_winopt(&win->w_allbuf_opt);
10636}
10637
10638/*
10639 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10640 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010641 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010642check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010643{
10644#ifdef FEAT_FOLDING
10645 check_string_option(&wop->wo_fdi);
10646 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010647 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010648# ifdef FEAT_EVAL
10649 check_string_option(&wop->wo_fde);
10650 check_string_option(&wop->wo_fdt);
10651# endif
10652 check_string_option(&wop->wo_fmr);
10653#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010654#ifdef FEAT_SIGNS
10655 check_string_option(&wop->wo_scl);
10656#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010657#ifdef FEAT_RIGHTLEFT
10658 check_string_option(&wop->wo_rlc);
10659#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010660#ifdef FEAT_STL_OPT
10661 check_string_option(&wop->wo_stl);
10662#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010663#ifdef FEAT_SYN_HL
10664 check_string_option(&wop->wo_cc);
10665#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010666#ifdef FEAT_CONCEAL
10667 check_string_option(&wop->wo_cocu);
10668#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010669#ifdef FEAT_LINEBREAK
10670 check_string_option(&wop->wo_briopt);
10671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010672}
10673
10674/*
10675 * Free the allocated memory inside a winopt_T.
10676 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010677 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010678clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010679{
10680#ifdef FEAT_FOLDING
10681 clear_string_option(&wop->wo_fdi);
10682 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010683 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010684# ifdef FEAT_EVAL
10685 clear_string_option(&wop->wo_fde);
10686 clear_string_option(&wop->wo_fdt);
10687# endif
10688 clear_string_option(&wop->wo_fmr);
10689#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010690#ifdef FEAT_SIGNS
10691 clear_string_option(&wop->wo_scl);
10692#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010693#ifdef FEAT_LINEBREAK
10694 clear_string_option(&wop->wo_briopt);
10695#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010696#ifdef FEAT_RIGHTLEFT
10697 clear_string_option(&wop->wo_rlc);
10698#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010699#ifdef FEAT_STL_OPT
10700 clear_string_option(&wop->wo_stl);
10701#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010702#ifdef FEAT_SYN_HL
10703 clear_string_option(&wop->wo_cc);
10704#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010705#ifdef FEAT_CONCEAL
10706 clear_string_option(&wop->wo_cocu);
10707#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010708}
10709
10710/*
10711 * Copy global option values to local options for one buffer.
10712 * Used when creating a new buffer and sometimes when entering a buffer.
10713 * flags:
10714 * BCO_ENTER We will enter the buf buffer.
10715 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10716 * appropriate.
10717 * BCO_NOHELP Don't copy the values to a help buffer.
10718 */
10719 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010720buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010721{
10722 int should_copy = TRUE;
10723 char_u *save_p_isk = NULL; /* init for GCC */
10724 int dont_do_help;
10725 int did_isk = FALSE;
10726
10727 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010728 * Skip this when the option defaults have not been set yet. Happens when
10729 * main() allocates the first buffer.
10730 */
10731 if (p_cpo != NULL)
10732 {
10733 /*
10734 * Always copy when entering and 'cpo' contains 'S'.
10735 * Don't copy when already initialized.
10736 * Don't copy when 'cpo' contains 's' and not entering.
10737 * 'S' BCO_ENTER initialized 's' should_copy
10738 * yes yes X X TRUE
10739 * yes no yes X FALSE
10740 * no X yes X FALSE
10741 * X no no yes FALSE
10742 * X no no no TRUE
10743 * no yes no X TRUE
10744 */
10745 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10746 && (buf->b_p_initialized
10747 || (!(flags & BCO_ENTER)
10748 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10749 should_copy = FALSE;
10750
10751 if (should_copy || (flags & BCO_ALWAYS))
10752 {
10753 /* Don't copy the options specific to a help buffer when
10754 * BCO_NOHELP is given or the options were initialized already
10755 * (jumping back to a help file with CTRL-T or CTRL-O) */
10756 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10757 || buf->b_p_initialized;
10758 if (dont_do_help) /* don't free b_p_isk */
10759 {
10760 save_p_isk = buf->b_p_isk;
10761 buf->b_p_isk = NULL;
10762 }
10763 /*
10764 * Always free the allocated strings.
10765 * If not already initialized, set 'readonly' and copy 'fileformat'.
10766 */
10767 if (!buf->b_p_initialized)
10768 {
10769 free_buf_options(buf, TRUE);
10770 buf->b_p_ro = FALSE; /* don't copy readonly */
10771 buf->b_p_tx = p_tx;
10772#ifdef FEAT_MBYTE
10773 buf->b_p_fenc = vim_strsave(p_fenc);
10774#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020010775 switch (*p_ffs)
10776 {
10777 case 'm':
10778 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
10779 case 'd':
10780 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
10781 case 'u':
10782 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
10783 default:
10784 buf->b_p_ff = vim_strsave(p_ff);
10785 }
10786 if (buf->b_p_ff != NULL)
10787 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010788#if defined(FEAT_QUICKFIX)
10789 buf->b_p_bh = empty_option;
10790 buf->b_p_bt = empty_option;
10791#endif
10792 }
10793 else
10794 free_buf_options(buf, FALSE);
10795
10796 buf->b_p_ai = p_ai;
10797 buf->b_p_ai_nopaste = p_ai_nopaste;
10798 buf->b_p_sw = p_sw;
10799 buf->b_p_tw = p_tw;
10800 buf->b_p_tw_nopaste = p_tw_nopaste;
10801 buf->b_p_tw_nobin = p_tw_nobin;
10802 buf->b_p_wm = p_wm;
10803 buf->b_p_wm_nopaste = p_wm_nopaste;
10804 buf->b_p_wm_nobin = p_wm_nobin;
10805 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010806#ifdef FEAT_MBYTE
10807 buf->b_p_bomb = p_bomb;
10808#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010809 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010810 buf->b_p_et = p_et;
10811 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020010812 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010813 buf->b_p_ml = p_ml;
10814 buf->b_p_ml_nobin = p_ml_nobin;
10815 buf->b_p_inf = p_inf;
10816 buf->b_p_swf = p_swf;
10817#ifdef FEAT_INS_EXPAND
10818 buf->b_p_cpt = vim_strsave(p_cpt);
10819#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010820#ifdef FEAT_COMPL_FUNC
10821 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010822 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010823#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824 buf->b_p_sts = p_sts;
10825 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010826 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010827#ifdef FEAT_COMMENTS
10828 buf->b_p_com = vim_strsave(p_com);
10829#endif
10830#ifdef FEAT_FOLDING
10831 buf->b_p_cms = vim_strsave(p_cms);
10832#endif
10833 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010834 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010835 buf->b_p_nf = vim_strsave(p_nf);
10836 buf->b_p_mps = vim_strsave(p_mps);
10837#ifdef FEAT_SMARTINDENT
10838 buf->b_p_si = p_si;
10839#endif
10840 buf->b_p_ci = p_ci;
10841#ifdef FEAT_CINDENT
10842 buf->b_p_cin = p_cin;
10843 buf->b_p_cink = vim_strsave(p_cink);
10844 buf->b_p_cino = vim_strsave(p_cino);
10845#endif
10846#ifdef FEAT_AUTOCMD
10847 /* Don't copy 'filetype', it must be detected */
10848 buf->b_p_ft = empty_option;
10849#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010850 buf->b_p_pi = p_pi;
10851#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10852 buf->b_p_cinw = vim_strsave(p_cinw);
10853#endif
10854#ifdef FEAT_LISP
10855 buf->b_p_lisp = p_lisp;
10856#endif
10857#ifdef FEAT_SYN_HL
10858 /* Don't copy 'syntax', it must be set */
10859 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010860 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010010861 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010862#endif
10863#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010864 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010865 (void)compile_cap_prog(&buf->b_s);
10866 buf->b_s.b_p_spf = vim_strsave(p_spf);
10867 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010868#endif
10869#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10870 buf->b_p_inde = vim_strsave(p_inde);
10871 buf->b_p_indk = vim_strsave(p_indk);
10872#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010873#if defined(FEAT_EVAL)
10874 buf->b_p_fex = vim_strsave(p_fex);
10875#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010876#ifdef FEAT_CRYPT
10877 buf->b_p_key = vim_strsave(p_key);
10878#endif
10879#ifdef FEAT_SEARCHPATH
10880 buf->b_p_sua = vim_strsave(p_sua);
10881#endif
10882#ifdef FEAT_KEYMAP
10883 buf->b_p_keymap = vim_strsave(p_keymap);
10884 buf->b_kmap_state |= KEYMAP_INIT;
10885#endif
10886 /* This isn't really an option, but copying the langmap and IME
10887 * state from the current buffer is better than resetting it. */
10888 buf->b_p_iminsert = p_iminsert;
10889 buf->b_p_imsearch = p_imsearch;
10890
10891 /* options that are normally global but also have a local value
10892 * are not copied, start using the global value */
10893 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010894 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010895 buf->b_p_bkc = empty_option;
10896 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010897#ifdef FEAT_QUICKFIX
10898 buf->b_p_gp = empty_option;
10899 buf->b_p_mp = empty_option;
10900 buf->b_p_efm = empty_option;
10901#endif
10902 buf->b_p_ep = empty_option;
10903 buf->b_p_kp = empty_option;
10904 buf->b_p_path = empty_option;
10905 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010906 buf->b_p_tc = empty_option;
10907 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010908#ifdef FEAT_FIND_ID
10909 buf->b_p_def = empty_option;
10910 buf->b_p_inc = empty_option;
10911# ifdef FEAT_EVAL
10912 buf->b_p_inex = vim_strsave(p_inex);
10913# endif
10914#endif
10915#ifdef FEAT_INS_EXPAND
10916 buf->b_p_dict = empty_option;
10917 buf->b_p_tsr = empty_option;
10918#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010919#ifdef FEAT_TEXTOBJ
10920 buf->b_p_qe = vim_strsave(p_qe);
10921#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010922#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10923 buf->b_p_bexpr = empty_option;
10924#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010925#if defined(FEAT_CRYPT)
10926 buf->b_p_cm = empty_option;
10927#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010928#ifdef FEAT_PERSISTENT_UNDO
10929 buf->b_p_udf = p_udf;
10930#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010931#ifdef FEAT_LISP
10932 buf->b_p_lw = empty_option;
10933#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010934
10935 /*
10936 * Don't copy the options set by ex_help(), use the saved values,
10937 * when going from a help buffer to a non-help buffer.
10938 * Don't touch these at all when BCO_NOHELP is used and going from
10939 * or to a help buffer.
10940 */
10941 if (dont_do_help)
10942 buf->b_p_isk = save_p_isk;
10943 else
10944 {
10945 buf->b_p_isk = vim_strsave(p_isk);
10946 did_isk = TRUE;
10947 buf->b_p_ts = p_ts;
10948 buf->b_help = FALSE;
10949#ifdef FEAT_QUICKFIX
10950 if (buf->b_p_bt[0] == 'h')
10951 clear_string_option(&buf->b_p_bt);
10952#endif
10953 buf->b_p_ma = p_ma;
10954 }
10955 }
10956
10957 /*
10958 * When the options should be copied (ignoring BCO_ALWAYS), set the
10959 * flag that indicates that the options have been initialized.
10960 */
10961 if (should_copy)
10962 buf->b_p_initialized = TRUE;
10963 }
10964
10965 check_buf_options(buf); /* make sure we don't have NULLs */
10966 if (did_isk)
10967 (void)buf_init_chartab(buf, FALSE);
10968}
10969
10970/*
10971 * Reset the 'modifiable' option and its default value.
10972 */
10973 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010974reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010975{
10976 int opt_idx;
10977
10978 curbuf->b_p_ma = FALSE;
10979 p_ma = FALSE;
10980 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010981 if (opt_idx >= 0)
10982 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010983}
10984
10985/*
10986 * Set the global value for 'iminsert' to the local value.
10987 */
10988 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010989set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010990{
10991 p_iminsert = curbuf->b_p_iminsert;
10992}
10993
10994/*
10995 * Set the global value for 'imsearch' to the local value.
10996 */
10997 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010998set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010999{
11000 p_imsearch = curbuf->b_p_imsearch;
11001}
11002
11003#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11004static int expand_option_idx = -1;
11005static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11006static int expand_option_flags = 0;
11007
11008 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011009set_context_in_set_cmd(
11010 expand_T *xp,
11011 char_u *arg,
11012 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011013{
11014 int nextchar;
11015 long_u flags = 0; /* init for GCC */
11016 int opt_idx = 0; /* init for GCC */
11017 char_u *p;
11018 char_u *s;
11019 int is_term_option = FALSE;
11020 int key;
11021
11022 expand_option_flags = opt_flags;
11023
11024 xp->xp_context = EXPAND_SETTINGS;
11025 if (*arg == NUL)
11026 {
11027 xp->xp_pattern = arg;
11028 return;
11029 }
11030 p = arg + STRLEN(arg) - 1;
11031 if (*p == ' ' && *(p - 1) != '\\')
11032 {
11033 xp->xp_pattern = p + 1;
11034 return;
11035 }
11036 while (p > arg)
11037 {
11038 s = p;
11039 /* count number of backslashes before ' ' or ',' */
11040 if (*p == ' ' || *p == ',')
11041 {
11042 while (s > arg && *(s - 1) == '\\')
11043 --s;
11044 }
11045 /* break at a space with an even number of backslashes */
11046 if (*p == ' ' && ((p - s) & 1) == 0)
11047 {
11048 ++p;
11049 break;
11050 }
11051 --p;
11052 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011053 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011054 {
11055 xp->xp_context = EXPAND_BOOL_SETTINGS;
11056 p += 2;
11057 }
11058 if (STRNCMP(p, "inv", 3) == 0)
11059 {
11060 xp->xp_context = EXPAND_BOOL_SETTINGS;
11061 p += 3;
11062 }
11063 xp->xp_pattern = arg = p;
11064 if (*arg == '<')
11065 {
11066 while (*p != '>')
11067 if (*p++ == NUL) /* expand terminal option name */
11068 return;
11069 key = get_special_key_code(arg + 1);
11070 if (key == 0) /* unknown name */
11071 {
11072 xp->xp_context = EXPAND_NOTHING;
11073 return;
11074 }
11075 nextchar = *++p;
11076 is_term_option = TRUE;
11077 expand_option_name[2] = KEY2TERMCAP0(key);
11078 expand_option_name[3] = KEY2TERMCAP1(key);
11079 }
11080 else
11081 {
11082 if (p[0] == 't' && p[1] == '_')
11083 {
11084 p += 2;
11085 if (*p != NUL)
11086 ++p;
11087 if (*p == NUL)
11088 return; /* expand option name */
11089 nextchar = *++p;
11090 is_term_option = TRUE;
11091 expand_option_name[2] = p[-2];
11092 expand_option_name[3] = p[-1];
11093 }
11094 else
11095 {
11096 /* Allow * wildcard */
11097 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11098 p++;
11099 if (*p == NUL)
11100 return;
11101 nextchar = *p;
11102 *p = NUL;
11103 opt_idx = findoption(arg);
11104 *p = nextchar;
11105 if (opt_idx == -1 || options[opt_idx].var == NULL)
11106 {
11107 xp->xp_context = EXPAND_NOTHING;
11108 return;
11109 }
11110 flags = options[opt_idx].flags;
11111 if (flags & P_BOOL)
11112 {
11113 xp->xp_context = EXPAND_NOTHING;
11114 return;
11115 }
11116 }
11117 }
11118 /* handle "-=" and "+=" */
11119 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11120 {
11121 ++p;
11122 nextchar = '=';
11123 }
11124 if ((nextchar != '=' && nextchar != ':')
11125 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11126 {
11127 xp->xp_context = EXPAND_UNSUCCESSFUL;
11128 return;
11129 }
11130 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11131 {
11132 xp->xp_context = EXPAND_OLD_SETTING;
11133 if (is_term_option)
11134 expand_option_idx = -1;
11135 else
11136 expand_option_idx = opt_idx;
11137 xp->xp_pattern = p + 1;
11138 return;
11139 }
11140 xp->xp_context = EXPAND_NOTHING;
11141 if (is_term_option || (flags & P_NUM))
11142 return;
11143
11144 xp->xp_pattern = p + 1;
11145
11146 if (flags & P_EXPAND)
11147 {
11148 p = options[opt_idx].var;
11149 if (p == (char_u *)&p_bdir
11150 || p == (char_u *)&p_dir
11151 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011152 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011153 || p == (char_u *)&p_rtp
11154#ifdef FEAT_SEARCHPATH
11155 || p == (char_u *)&p_cdpath
11156#endif
11157#ifdef FEAT_SESSION
11158 || p == (char_u *)&p_vdir
11159#endif
11160 )
11161 {
11162 xp->xp_context = EXPAND_DIRECTORIES;
11163 if (p == (char_u *)&p_path
11164#ifdef FEAT_SEARCHPATH
11165 || p == (char_u *)&p_cdpath
11166#endif
11167 )
11168 xp->xp_backslash = XP_BS_THREE;
11169 else
11170 xp->xp_backslash = XP_BS_ONE;
11171 }
11172 else
11173 {
11174 xp->xp_context = EXPAND_FILES;
11175 /* for 'tags' need three backslashes for a space */
11176 if (p == (char_u *)&p_tags)
11177 xp->xp_backslash = XP_BS_THREE;
11178 else
11179 xp->xp_backslash = XP_BS_ONE;
11180 }
11181 }
11182
11183 /* For an option that is a list of file names, find the start of the
11184 * last file name. */
11185 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11186 {
11187 /* count number of backslashes before ' ' or ',' */
11188 if (*p == ' ' || *p == ',')
11189 {
11190 s = p;
11191 while (s > xp->xp_pattern && *(s - 1) == '\\')
11192 --s;
11193 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11194 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11195 {
11196 xp->xp_pattern = p + 1;
11197 break;
11198 }
11199 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011200
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011201#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011202 /* for 'spellsuggest' start at "file:" */
11203 if (options[opt_idx].var == (char_u *)&p_sps
11204 && STRNCMP(p, "file:", 5) == 0)
11205 {
11206 xp->xp_pattern = p + 5;
11207 break;
11208 }
11209#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011210 }
11211
11212 return;
11213}
11214
11215 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011216ExpandSettings(
11217 expand_T *xp,
11218 regmatch_T *regmatch,
11219 int *num_file,
11220 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011221{
11222 int num_normal = 0; /* Nr of matching non-term-code settings */
11223 int num_term = 0; /* Nr of matching terminal code settings */
11224 int opt_idx;
11225 int match;
11226 int count = 0;
11227 char_u *str;
11228 int loop;
11229 int is_term_opt;
11230 char_u name_buf[MAX_KEY_NAME_LEN];
11231 static char *(names[]) = {"all", "termcap"};
11232 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11233
11234 /* do this loop twice:
11235 * loop == 0: count the number of matching options
11236 * loop == 1: copy the matching options into allocated memory
11237 */
11238 for (loop = 0; loop <= 1; ++loop)
11239 {
11240 regmatch->rm_ic = ic;
11241 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11242 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011243 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11244 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011245 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11246 {
11247 if (loop == 0)
11248 num_normal++;
11249 else
11250 (*file)[count++] = vim_strsave((char_u *)names[match]);
11251 }
11252 }
11253 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11254 opt_idx++)
11255 {
11256 if (options[opt_idx].var == NULL)
11257 continue;
11258 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11259 && !(options[opt_idx].flags & P_BOOL))
11260 continue;
11261 is_term_opt = istermoption(&options[opt_idx]);
11262 if (is_term_opt && num_normal > 0)
11263 continue;
11264 match = FALSE;
11265 if (vim_regexec(regmatch, str, (colnr_T)0)
11266 || (options[opt_idx].shortname != NULL
11267 && vim_regexec(regmatch,
11268 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11269 match = TRUE;
11270 else if (is_term_opt)
11271 {
11272 name_buf[0] = '<';
11273 name_buf[1] = 't';
11274 name_buf[2] = '_';
11275 name_buf[3] = str[2];
11276 name_buf[4] = str[3];
11277 name_buf[5] = '>';
11278 name_buf[6] = NUL;
11279 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11280 {
11281 match = TRUE;
11282 str = name_buf;
11283 }
11284 }
11285 if (match)
11286 {
11287 if (loop == 0)
11288 {
11289 if (is_term_opt)
11290 num_term++;
11291 else
11292 num_normal++;
11293 }
11294 else
11295 (*file)[count++] = vim_strsave(str);
11296 }
11297 }
11298 /*
11299 * Check terminal key codes, these are not in the option table
11300 */
11301 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11302 {
11303 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11304 {
11305 if (!isprint(str[0]) || !isprint(str[1]))
11306 continue;
11307
11308 name_buf[0] = 't';
11309 name_buf[1] = '_';
11310 name_buf[2] = str[0];
11311 name_buf[3] = str[1];
11312 name_buf[4] = NUL;
11313
11314 match = FALSE;
11315 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11316 match = TRUE;
11317 else
11318 {
11319 name_buf[0] = '<';
11320 name_buf[1] = 't';
11321 name_buf[2] = '_';
11322 name_buf[3] = str[0];
11323 name_buf[4] = str[1];
11324 name_buf[5] = '>';
11325 name_buf[6] = NUL;
11326
11327 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11328 match = TRUE;
11329 }
11330 if (match)
11331 {
11332 if (loop == 0)
11333 num_term++;
11334 else
11335 (*file)[count++] = vim_strsave(name_buf);
11336 }
11337 }
11338
11339 /*
11340 * Check special key names.
11341 */
11342 regmatch->rm_ic = TRUE; /* ignore case here */
11343 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11344 {
11345 name_buf[0] = '<';
11346 STRCPY(name_buf + 1, str);
11347 STRCAT(name_buf, ">");
11348
11349 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11350 {
11351 if (loop == 0)
11352 num_term++;
11353 else
11354 (*file)[count++] = vim_strsave(name_buf);
11355 }
11356 }
11357 }
11358 if (loop == 0)
11359 {
11360 if (num_normal > 0)
11361 *num_file = num_normal;
11362 else if (num_term > 0)
11363 *num_file = num_term;
11364 else
11365 return OK;
11366 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11367 if (*file == NULL)
11368 {
11369 *file = (char_u **)"";
11370 return FAIL;
11371 }
11372 }
11373 }
11374 return OK;
11375}
11376
11377 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011378ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011379{
11380 char_u *var = NULL; /* init for GCC */
11381 char_u *buf;
11382
11383 *num_file = 0;
11384 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11385 if (*file == NULL)
11386 return FAIL;
11387
11388 /*
11389 * For a terminal key code expand_option_idx is < 0.
11390 */
11391 if (expand_option_idx < 0)
11392 {
11393 var = find_termcode(expand_option_name + 2);
11394 if (var == NULL)
11395 expand_option_idx = findoption(expand_option_name);
11396 }
11397
11398 if (expand_option_idx >= 0)
11399 {
11400 /* put string of option value in NameBuff */
11401 option_value2string(&options[expand_option_idx], expand_option_flags);
11402 var = NameBuff;
11403 }
11404 else if (var == NULL)
11405 var = (char_u *)"";
11406
11407 /* A backslash is required before some characters. This is the reverse of
11408 * what happens in do_set(). */
11409 buf = vim_strsave_escaped(var, escape_chars);
11410
11411 if (buf == NULL)
11412 {
11413 vim_free(*file);
11414 *file = NULL;
11415 return FAIL;
11416 }
11417
11418#ifdef BACKSLASH_IN_FILENAME
11419 /* For MS-Windows et al. we don't double backslashes at the start and
11420 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011421 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011422 if (var[0] == '\\' && var[1] == '\\'
11423 && expand_option_idx >= 0
11424 && (options[expand_option_idx].flags & P_EXPAND)
11425 && vim_isfilec(var[2])
11426 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011427 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011428#endif
11429
11430 *file[0] = buf;
11431 *num_file = 1;
11432 return OK;
11433}
11434#endif
11435
11436/*
11437 * Get the value for the numeric or string option *opp in a nice format into
11438 * NameBuff[]. Must not be called with a hidden option!
11439 */
11440 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011441option_value2string(
11442 struct vimoption *opp,
11443 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011444{
11445 char_u *varp;
11446
11447 varp = get_varp_scope(opp, opt_flags);
11448
11449 if (opp->flags & P_NUM)
11450 {
11451 long wc = 0;
11452
11453 if (wc_use_keyname(varp, &wc))
11454 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11455 else if (wc != 0)
11456 STRCPY(NameBuff, transchar((int)wc));
11457 else
11458 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11459 }
11460 else /* P_STRING */
11461 {
11462 varp = *(char_u **)(varp);
11463 if (varp == NULL) /* just in case */
11464 NameBuff[0] = NUL;
11465#ifdef FEAT_CRYPT
11466 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011467 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011468 STRCPY(NameBuff, "*****");
11469#endif
11470 else if (opp->flags & P_EXPAND)
11471 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11472 /* Translate 'pastetoggle' into special key names */
11473 else if ((char_u **)opp->var == &p_pt)
11474 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11475 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011476 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011477 }
11478}
11479
11480/*
11481 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11482 * printed as a keyname.
11483 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11484 */
11485 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011486wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011487{
11488 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11489 {
11490 *wcp = *(long *)varp;
11491 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11492 return TRUE;
11493 }
11494 return FALSE;
11495}
11496
Bram Moolenaar01615492015-02-03 13:00:38 +010011497#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011498/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011499 * Any character has an equivalent 'langmap' character. This is used for
11500 * keyboards that have a special language mode that sends characters above
11501 * 128 (although other characters can be translated too). The "to" field is a
11502 * Vim command character. This avoids having to switch the keyboard back to
11503 * ASCII mode when leaving Insert mode.
11504 *
11505 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11506 * commands.
11507 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11508 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11509 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011510 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011511# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011512/*
11513 * With multi-byte support use growarray for 'langmap' chars >= 256
11514 */
11515typedef struct
11516{
11517 int from;
11518 int to;
11519} langmap_entry_T;
11520
11521static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011522static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011523
11524/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011525 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11526 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011527 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011528 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011529langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011530{
11531 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011532 int a = 0;
11533 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011534
11535 /* Do a binary search for an existing entry. */
11536 while (a != b)
11537 {
11538 int i = (a + b) / 2;
11539 int d = entries[i].from - from;
11540
11541 if (d == 0)
11542 {
11543 entries[i].to = to;
11544 return;
11545 }
11546 if (d < 0)
11547 a = i + 1;
11548 else
11549 b = i;
11550 }
11551
11552 if (ga_grow(&langmap_mapga, 1) != OK)
11553 return; /* out of memory */
11554
11555 /* insert new entry at position "a" */
11556 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11557 mch_memmove(entries + 1, entries,
11558 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11559 ++langmap_mapga.ga_len;
11560 entries[0].from = from;
11561 entries[0].to = to;
11562}
11563
11564/*
11565 * Apply 'langmap' to multi-byte character "c" and return the result.
11566 */
11567 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011568langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011569{
11570 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11571 int a = 0;
11572 int b = langmap_mapga.ga_len;
11573
11574 while (a != b)
11575 {
11576 int i = (a + b) / 2;
11577 int d = entries[i].from - c;
11578
11579 if (d == 0)
11580 return entries[i].to; /* found matching entry */
11581 if (d < 0)
11582 a = i + 1;
11583 else
11584 b = i;
11585 }
11586 return c; /* no entry found, return "c" unmodified */
11587}
11588# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011589
11590 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011591langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011592{
11593 int i;
11594
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011595 for (i = 0; i < 256; i++)
11596 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11597# ifdef FEAT_MBYTE
11598 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11599# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011600}
11601
11602/*
11603 * Called when langmap option is set; the language map can be
11604 * changed at any time!
11605 */
11606 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011607langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011608{
11609 char_u *p;
11610 char_u *p2;
11611 int from, to;
11612
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011613#ifdef FEAT_MBYTE
11614 ga_clear(&langmap_mapga); /* clear the previous map first */
11615#endif
11616 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011617
11618 for (p = p_langmap; p[0] != NUL; )
11619 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011620 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11621 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011622 {
11623 if (p2[0] == '\\' && p2[1] != NUL)
11624 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011625 }
11626 if (p2[0] == ';')
11627 ++p2; /* abcd;ABCD form, p2 points to A */
11628 else
11629 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11630 while (p[0])
11631 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011632 if (p[0] == ',')
11633 {
11634 ++p;
11635 break;
11636 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011637 if (p[0] == '\\' && p[1] != NUL)
11638 ++p;
11639#ifdef FEAT_MBYTE
11640 from = (*mb_ptr2char)(p);
11641#else
11642 from = p[0];
11643#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011644 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011645 if (p2 == NULL)
11646 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011647 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011648 if (p[0] != ',')
11649 {
11650 if (p[0] == '\\')
11651 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011652#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011653 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011654#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011655 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011656#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011657 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011658 }
11659 else
11660 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011661 if (p2[0] != ',')
11662 {
11663 if (p2[0] == '\\')
11664 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011665#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011666 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011667#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011668 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011669#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011670 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011671 }
11672 if (to == NUL)
11673 {
11674 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11675 transchar(from));
11676 return;
11677 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011678
11679#ifdef FEAT_MBYTE
11680 if (from >= 256)
11681 langmap_set_entry(from, to);
11682 else
11683#endif
11684 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011685
11686 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011687 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011688 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011689 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011690 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011691 if (*p == ';')
11692 {
11693 p = p2;
11694 if (p[0] != NUL)
11695 {
11696 if (p[0] != ',')
11697 {
11698 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11699 return;
11700 }
11701 ++p;
11702 }
11703 break;
11704 }
11705 }
11706 }
11707 }
11708}
11709#endif
11710
11711/*
11712 * Return TRUE if format option 'x' is in effect.
11713 * Take care of no formatting when 'paste' is set.
11714 */
11715 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011716has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011717{
11718 if (p_paste)
11719 return FALSE;
11720 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11721}
11722
11723/*
11724 * Return TRUE if "x" is present in 'shortmess' option, or
11725 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11726 */
11727 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011728shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011729{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011730 return p_shm != NULL &&
11731 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011732 || (vim_strchr(p_shm, 'a') != NULL
11733 && vim_strchr((char_u *)SHM_A, x) != NULL));
11734}
11735
11736/*
11737 * paste_option_changed() - Called after p_paste was set or reset.
11738 */
11739 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011740paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011741{
11742 static int old_p_paste = FALSE;
11743 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011744 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011745#ifdef FEAT_CMDL_INFO
11746 static int save_ru = 0;
11747#endif
11748#ifdef FEAT_RIGHTLEFT
11749 static int save_ri = 0;
11750 static int save_hkmap = 0;
11751#endif
11752 buf_T *buf;
11753
11754 if (p_paste)
11755 {
11756 /*
11757 * Paste switched from off to on.
11758 * Save the current values, so they can be restored later.
11759 */
11760 if (!old_p_paste)
11761 {
11762 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011763 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011764 {
11765 buf->b_p_tw_nopaste = buf->b_p_tw;
11766 buf->b_p_wm_nopaste = buf->b_p_wm;
11767 buf->b_p_sts_nopaste = buf->b_p_sts;
11768 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011769 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011770 }
11771
11772 /* save global options */
11773 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011774 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011775#ifdef FEAT_CMDL_INFO
11776 save_ru = p_ru;
11777#endif
11778#ifdef FEAT_RIGHTLEFT
11779 save_ri = p_ri;
11780 save_hkmap = p_hkmap;
11781#endif
11782 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011783 p_ai_nopaste = p_ai;
11784 p_et_nopaste = p_et;
11785 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011786 p_tw_nopaste = p_tw;
11787 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011788 }
11789
11790 /*
11791 * Always set the option values, also when 'paste' is set when it is
11792 * already on.
11793 */
11794 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011795 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011796 {
11797 buf->b_p_tw = 0; /* textwidth is 0 */
11798 buf->b_p_wm = 0; /* wrapmargin is 0 */
11799 buf->b_p_sts = 0; /* softtabstop is 0 */
11800 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011801 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011802 }
11803
11804 /* set global options */
11805 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011806 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011807#ifdef FEAT_CMDL_INFO
11808# ifdef FEAT_WINDOWS
11809 if (p_ru)
11810 status_redraw_all(); /* redraw to remove the ruler */
11811# endif
11812 p_ru = 0; /* no ruler */
11813#endif
11814#ifdef FEAT_RIGHTLEFT
11815 p_ri = 0; /* no reverse insert */
11816 p_hkmap = 0; /* no Hebrew keyboard */
11817#endif
11818 /* set global values for local buffer options */
11819 p_tw = 0;
11820 p_wm = 0;
11821 p_sts = 0;
11822 p_ai = 0;
11823 }
11824
11825 /*
11826 * Paste switched from on to off: Restore saved values.
11827 */
11828 else if (old_p_paste)
11829 {
11830 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011831 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011832 {
11833 buf->b_p_tw = buf->b_p_tw_nopaste;
11834 buf->b_p_wm = buf->b_p_wm_nopaste;
11835 buf->b_p_sts = buf->b_p_sts_nopaste;
11836 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011837 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011838 }
11839
11840 /* restore global options */
11841 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011842 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011843#ifdef FEAT_CMDL_INFO
11844# ifdef FEAT_WINDOWS
11845 if (p_ru != save_ru)
11846 status_redraw_all(); /* redraw to draw the ruler */
11847# endif
11848 p_ru = save_ru;
11849#endif
11850#ifdef FEAT_RIGHTLEFT
11851 p_ri = save_ri;
11852 p_hkmap = save_hkmap;
11853#endif
11854 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011855 p_ai = p_ai_nopaste;
11856 p_et = p_et_nopaste;
11857 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011858 p_tw = p_tw_nopaste;
11859 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011860 }
11861
11862 old_p_paste = p_paste;
11863}
11864
11865/*
11866 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11867 *
11868 * Reset 'compatible' and set the values for options that didn't get set yet
11869 * to the Vim defaults.
11870 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011871 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011872 */
11873 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011874vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011875{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011876 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011877 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011878 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011879
11880 if (!option_was_set((char_u *)"cp"))
11881 {
11882 p_cp = FALSE;
11883 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11884 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11885 set_option_default(opt_idx, OPT_FREE, FALSE);
11886 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011887 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011888 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011889
11890 if (fname != NULL)
11891 {
11892 p = vim_getenv(envname, &dofree);
11893 if (p == NULL)
11894 {
11895 /* Set $MYVIMRC to the first vimrc file found. */
11896 p = FullName_save(fname, FALSE);
11897 if (p != NULL)
11898 {
11899 vim_setenv(envname, p);
11900 vim_free(p);
11901 }
11902 }
11903 else if (dofree)
11904 vim_free(p);
11905 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011906}
11907
11908/*
11909 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11910 */
11911 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011912change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011913{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011914 int opt_idx;
11915
Bram Moolenaar071d4272004-06-13 20:20:40 +000011916 if (p_cp != on)
11917 {
11918 p_cp = on;
11919 compatible_set();
11920 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011921 opt_idx = findoption((char_u *)"cp");
11922 if (opt_idx >= 0)
11923 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011924}
11925
11926/*
11927 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011928 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011929 */
11930 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011931option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011932{
11933 int idx;
11934
11935 idx = findoption(name);
11936 if (idx < 0) /* unknown option */
11937 return FALSE;
11938 if (options[idx].flags & P_WAS_SET)
11939 return TRUE;
11940 return FALSE;
11941}
11942
11943/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011944 * Reset the flag indicating option "name" was set.
11945 */
11946 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011947reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011948{
11949 int idx = findoption(name);
11950
11951 if (idx >= 0)
11952 options[idx].flags &= ~P_WAS_SET;
11953}
11954
11955/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011956 * compatible_set() - Called when 'compatible' has been set or unset.
11957 *
11958 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11959 * flag) to a Vi compatible value.
11960 * When 'compatible' is unset: Set all options that have a different default
11961 * for Vim (without the P_VI_DEF flag) to that default.
11962 */
11963 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011964compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011965{
11966 int opt_idx;
11967
11968 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11969 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11970 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11971 set_option_default(opt_idx, OPT_FREE, p_cp);
11972 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011973 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011974}
11975
11976#ifdef FEAT_LINEBREAK
11977
11978# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11979 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011980 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011981# endif
11982
11983/*
11984 * fill_breakat_flags() -- called when 'breakat' changes value.
11985 */
11986 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011987fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011988{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011989 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011990 int i;
11991
11992 for (i = 0; i < 256; i++)
11993 breakat_flags[i] = FALSE;
11994
11995 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011996 for (p = p_breakat; *p; p++)
11997 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011998}
11999
12000# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012001 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012002# endif
12003
12004#endif
12005
12006/*
12007 * Check an option that can be a range of string values.
12008 *
12009 * Return OK for correct value, FAIL otherwise.
12010 * Empty is always OK.
12011 */
12012 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012013check_opt_strings(
12014 char_u *val,
12015 char **values,
12016 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012017{
12018 return opt_strings_flags(val, values, NULL, list);
12019}
12020
12021/*
12022 * Handle an option that can be a range of string values.
12023 * Set a flag in "*flagp" for each string present.
12024 *
12025 * Return OK for correct value, FAIL otherwise.
12026 * Empty is always OK.
12027 */
12028 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012029opt_strings_flags(
12030 char_u *val, /* new value */
12031 char **values, /* array of valid string values */
12032 unsigned *flagp,
12033 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012034{
12035 int i;
12036 int len;
12037 unsigned new_flags = 0;
12038
12039 while (*val)
12040 {
12041 for (i = 0; ; ++i)
12042 {
12043 if (values[i] == NULL) /* val not found in values[] */
12044 return FAIL;
12045
12046 len = (int)STRLEN(values[i]);
12047 if (STRNCMP(values[i], val, len) == 0
12048 && ((list && val[len] == ',') || val[len] == NUL))
12049 {
12050 val += len + (val[len] == ',');
12051 new_flags |= (1 << i);
12052 break; /* check next item in val list */
12053 }
12054 }
12055 }
12056 if (flagp != NULL)
12057 *flagp = new_flags;
12058
12059 return OK;
12060}
12061
12062/*
12063 * Read the 'wildmode' option, fill wim_flags[].
12064 */
12065 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012066check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012067{
12068 char_u new_wim_flags[4];
12069 char_u *p;
12070 int i;
12071 int idx = 0;
12072
12073 for (i = 0; i < 4; ++i)
12074 new_wim_flags[i] = 0;
12075
12076 for (p = p_wim; *p; ++p)
12077 {
12078 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12079 ;
12080 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12081 return FAIL;
12082 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12083 new_wim_flags[idx] |= WIM_LONGEST;
12084 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12085 new_wim_flags[idx] |= WIM_FULL;
12086 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12087 new_wim_flags[idx] |= WIM_LIST;
12088 else
12089 return FAIL;
12090 p += i;
12091 if (*p == NUL)
12092 break;
12093 if (*p == ',')
12094 {
12095 if (idx == 3)
12096 return FAIL;
12097 ++idx;
12098 }
12099 }
12100
12101 /* fill remaining entries with last flag */
12102 while (idx < 3)
12103 {
12104 new_wim_flags[idx + 1] = new_wim_flags[idx];
12105 ++idx;
12106 }
12107
12108 /* only when there are no errors, wim_flags[] is changed */
12109 for (i = 0; i < 4; ++i)
12110 wim_flags[i] = new_wim_flags[i];
12111 return OK;
12112}
12113
12114/*
12115 * Check if backspacing over something is allowed.
12116 */
12117 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012118can_bs(
12119 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012120{
12121 switch (*p_bs)
12122 {
12123 case '2': return TRUE;
12124 case '1': return (what != BS_START);
12125 case '0': return FALSE;
12126 }
12127 return vim_strchr(p_bs, what) != NULL;
12128}
12129
12130/*
12131 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12132 * the file must be considered changed when the value is different.
12133 */
12134 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012135save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012136{
12137 buf->b_start_ffc = *buf->b_p_ff;
12138 buf->b_start_eol = buf->b_p_eol;
12139#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012140 buf->b_start_bomb = buf->b_p_bomb;
12141
Bram Moolenaar071d4272004-06-13 20:20:40 +000012142 /* Only use free/alloc when necessary, they take time. */
12143 if (buf->b_start_fenc == NULL
12144 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12145 {
12146 vim_free(buf->b_start_fenc);
12147 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12148 }
12149#endif
12150}
12151
12152/*
12153 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12154 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012155 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12156 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012157 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012158 * When "ignore_empty" is true don't consider a new, empty buffer to be
12159 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012160 */
12161 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012162file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012163{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012164 /* In a buffer that was never loaded the options are not valid. */
12165 if (buf->b_flags & BF_NEVERLOADED)
12166 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012167 if (ignore_empty
12168 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012169 && buf->b_ml.ml_line_count == 1
12170 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12171 return FALSE;
12172 if (buf->b_start_ffc != *buf->b_p_ff)
12173 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012174 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012175 return TRUE;
12176#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012177 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12178 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012179 if (buf->b_start_fenc == NULL)
12180 return (*buf->b_p_fenc != NUL);
12181 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12182#else
12183 return FALSE;
12184#endif
12185}
12186
12187/*
12188 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12189 */
12190 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012191check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012192{
12193 return check_opt_strings(p, p_ff_values, FALSE);
12194}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012195
12196/*
12197 * Return the effective shiftwidth value for current buffer, using the
12198 * 'tabstop' value when 'shiftwidth' is zero.
12199 */
12200 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012201get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012202{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012203 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012204}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012205
12206/*
12207 * Return the effective softtabstop value for the current buffer, using the
12208 * 'tabstop' value when 'softtabstop' is negative.
12209 */
12210 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012211get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012212{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012213 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012214}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012215
12216/*
12217 * Check matchpairs option for "*initc".
12218 * If there is a match set "*initc" to the matching character and "*findc" to
12219 * the opposite character. Set "*backwards" to the direction.
12220 * When "switchit" is TRUE swap the direction.
12221 */
12222 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012223find_mps_values(
12224 int *initc,
12225 int *findc,
12226 int *backwards,
12227 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012228{
12229 char_u *ptr;
12230
12231 ptr = curbuf->b_p_mps;
12232 while (*ptr != NUL)
12233 {
12234#ifdef FEAT_MBYTE
12235 if (has_mbyte)
12236 {
12237 char_u *prev;
12238
12239 if (mb_ptr2char(ptr) == *initc)
12240 {
12241 if (switchit)
12242 {
12243 *findc = *initc;
12244 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12245 *backwards = TRUE;
12246 }
12247 else
12248 {
12249 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12250 *backwards = FALSE;
12251 }
12252 return;
12253 }
12254 prev = ptr;
12255 ptr += mb_ptr2len(ptr) + 1;
12256 if (mb_ptr2char(ptr) == *initc)
12257 {
12258 if (switchit)
12259 {
12260 *findc = *initc;
12261 *initc = mb_ptr2char(prev);
12262 *backwards = FALSE;
12263 }
12264 else
12265 {
12266 *findc = mb_ptr2char(prev);
12267 *backwards = TRUE;
12268 }
12269 return;
12270 }
12271 ptr += mb_ptr2len(ptr);
12272 }
12273 else
12274#endif
12275 {
12276 if (*ptr == *initc)
12277 {
12278 if (switchit)
12279 {
12280 *backwards = TRUE;
12281 *findc = *initc;
12282 *initc = ptr[2];
12283 }
12284 else
12285 {
12286 *backwards = FALSE;
12287 *findc = ptr[2];
12288 }
12289 return;
12290 }
12291 ptr += 2;
12292 if (*ptr == *initc)
12293 {
12294 if (switchit)
12295 {
12296 *backwards = FALSE;
12297 *findc = *initc;
12298 *initc = ptr[-2];
12299 }
12300 else
12301 {
12302 *backwards = TRUE;
12303 *findc = ptr[-2];
12304 }
12305 return;
12306 }
12307 ++ptr;
12308 }
12309 if (*ptr == ',')
12310 ++ptr;
12311 }
12312}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012313
12314#if defined(FEAT_LINEBREAK) || defined(PROTO)
12315/*
12316 * This is called when 'breakindentopt' is changed and when a window is
12317 * initialized.
12318 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012319 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012320briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012321{
12322 char_u *p;
12323 int bri_shift = 0;
12324 long bri_min = 20;
12325 int bri_sbr = FALSE;
12326
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012327 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012328 while (*p != NUL)
12329 {
12330 if (STRNCMP(p, "shift:", 6) == 0
12331 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12332 {
12333 p += 6;
12334 bri_shift = getdigits(&p);
12335 }
12336 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12337 {
12338 p += 4;
12339 bri_min = getdigits(&p);
12340 }
12341 else if (STRNCMP(p, "sbr", 3) == 0)
12342 {
12343 p += 3;
12344 bri_sbr = TRUE;
12345 }
12346 if (*p != ',' && *p != NUL)
12347 return FAIL;
12348 if (*p == ',')
12349 ++p;
12350 }
12351
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012352 wp->w_p_brishift = bri_shift;
12353 wp->w_p_brimin = bri_min;
12354 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012355
12356 return OK;
12357}
12358#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012359
12360/*
12361 * Get the local or global value of 'backupcopy'.
12362 */
12363 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012364get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012365{
12366 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12367}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012368
12369#if defined(FEAT_SIGNS) || defined(PROTO)
12370/*
12371 * Return TRUE when window "wp" has a column to draw signs in.
12372 */
12373 int
12374signcolumn_on(win_T *wp)
12375{
12376 if (*wp->w_p_scl == 'n')
12377 return FALSE;
12378 if (*wp->w_p_scl == 'y')
12379 return TRUE;
12380 return (wp->w_buffer->b_signlist != NULL
12381# ifdef FEAT_NETBEANS_INTG
12382 || wp->w_buffer->b_has_sign_column
12383# endif
12384 );
12385}
12386#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012387
12388#if defined(FEAT_EVAL) || defined(PROTO)
12389/*
12390 * Get window or buffer local options.
12391 */
12392 dict_T *
12393get_winbuf_options(int bufopt)
12394{
12395 dict_T *d;
12396 int opt_idx;
12397
12398 d = dict_alloc();
12399 if (d == NULL)
12400 return NULL;
12401
12402 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12403 {
12404 struct vimoption *opt = &options[opt_idx];
12405
12406 if ((bufopt && (opt->indir & PV_BUF))
12407 || (!bufopt && (opt->indir & PV_WIN)))
12408 {
12409 char_u *varp = get_varp(opt);
12410
12411 if (varp != NULL)
12412 {
12413 if (opt->flags & P_STRING)
12414 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012415 else if (opt->flags & P_NUM)
12416 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012417 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012418 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012419 }
12420 }
12421 }
12422
12423 return d;
12424}
12425#endif