blob: cdb0d67e6afc355c9a877f3026394dbda260bd52 [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 Moolenaar9be7c042017-01-14 14:28:30 +0100110#define PV_FP OPT_BOTH(OPT_BUF(BV_FP))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000111#ifdef FEAT_EVAL
112# define PV_FEX OPT_BUF(BV_FEX)
113#endif
114#define PV_FF OPT_BUF(BV_FF)
115#define PV_FLP OPT_BUF(BV_FLP)
116#define PV_FO OPT_BUF(BV_FO)
117#ifdef FEAT_AUTOCMD
118# define PV_FT OPT_BUF(BV_FT)
119#endif
120#define PV_IMI OPT_BUF(BV_IMI)
121#define PV_IMS OPT_BUF(BV_IMS)
122#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
123# define PV_INDE OPT_BUF(BV_INDE)
124# define PV_INDK OPT_BUF(BV_INDK)
125#endif
126#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
127# define PV_INEX OPT_BUF(BV_INEX)
128#endif
129#define PV_INF OPT_BUF(BV_INF)
130#define PV_ISK OPT_BUF(BV_ISK)
131#ifdef FEAT_CRYPT
132# define PV_KEY OPT_BUF(BV_KEY)
133#endif
134#ifdef FEAT_KEYMAP
135# define PV_KMAP OPT_BUF(BV_KMAP)
136#endif
137#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
138#ifdef FEAT_LISP
139# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100140# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000141#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +0100142#ifdef FEAT_MBYTE
143# define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC))
144#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000145#define PV_MA OPT_BUF(BV_MA)
146#define PV_ML OPT_BUF(BV_ML)
147#define PV_MOD OPT_BUF(BV_MOD)
148#define PV_MPS OPT_BUF(BV_MPS)
149#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000150#ifdef FEAT_COMPL_FUNC
151# define PV_OFU OPT_BUF(BV_OFU)
152#endif
153#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
154#define PV_PI OPT_BUF(BV_PI)
155#ifdef FEAT_TEXTOBJ
156# define PV_QE OPT_BUF(BV_QE)
157#endif
158#define PV_RO OPT_BUF(BV_RO)
159#ifdef FEAT_SMARTINDENT
160# define PV_SI OPT_BUF(BV_SI)
161#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100162#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000163#ifdef FEAT_SYN_HL
164# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000165# define PV_SYN OPT_BUF(BV_SYN)
166#endif
167#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000168# define PV_SPC OPT_BUF(BV_SPC)
169# define PV_SPF OPT_BUF(BV_SPF)
170# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000171#endif
172#define PV_STS OPT_BUF(BV_STS)
173#ifdef FEAT_SEARCHPATH
174# define PV_SUA OPT_BUF(BV_SUA)
175#endif
176#define PV_SW OPT_BUF(BV_SW)
177#define PV_SWF OPT_BUF(BV_SWF)
178#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100179#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000180#define PV_TS OPT_BUF(BV_TS)
181#define PV_TW OPT_BUF(BV_TW)
182#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200183#ifdef FEAT_PERSISTENT_UNDO
184# define PV_UDF OPT_BUF(BV_UDF)
185#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187
188/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000189 * Definition of the PV_ values for window-local options.
190 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000191 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000192#define PV_LIST OPT_WIN(WV_LIST)
193#ifdef FEAT_ARABIC
194# define PV_ARAB OPT_WIN(WV_ARAB)
195#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200196#ifdef FEAT_LINEBREAK
197# define PV_BRI OPT_WIN(WV_BRI)
198# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
199#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000200#ifdef FEAT_DIFF
201# define PV_DIFF OPT_WIN(WV_DIFF)
202#endif
203#ifdef FEAT_FOLDING
204# define PV_FDC OPT_WIN(WV_FDC)
205# define PV_FEN OPT_WIN(WV_FEN)
206# define PV_FDI OPT_WIN(WV_FDI)
207# define PV_FDL OPT_WIN(WV_FDL)
208# define PV_FDM OPT_WIN(WV_FDM)
209# define PV_FML OPT_WIN(WV_FML)
210# define PV_FDN OPT_WIN(WV_FDN)
211# ifdef FEAT_EVAL
212# define PV_FDE OPT_WIN(WV_FDE)
213# define PV_FDT OPT_WIN(WV_FDT)
214# endif
215# define PV_FMR OPT_WIN(WV_FMR)
216#endif
217#ifdef FEAT_LINEBREAK
218# define PV_LBR OPT_WIN(WV_LBR)
219#endif
220#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200221#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000222#ifdef FEAT_LINEBREAK
223# define PV_NUW OPT_WIN(WV_NUW)
224#endif
225#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
226# define PV_PVW OPT_WIN(WV_PVW)
227#endif
228#ifdef FEAT_RIGHTLEFT
229# define PV_RL OPT_WIN(WV_RL)
230# define PV_RLC OPT_WIN(WV_RLC)
231#endif
232#ifdef FEAT_SCROLLBIND
233# define PV_SCBIND OPT_WIN(WV_SCBIND)
234#endif
235#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000237# define PV_SPELL OPT_WIN(WV_SPELL)
238#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#ifdef FEAT_SYN_HL
240# define PV_CUC OPT_WIN(WV_CUC)
241# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200242# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000243#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_STL_OPT
245# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
246#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100247#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#ifdef FEAT_WINDOWS
249# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000250# define PV_WFW OPT_WIN(WV_WFW)
251#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000252#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200253#ifdef FEAT_CURSORBIND
254# define PV_CRBIND OPT_WIN(WV_CRBIND)
255#endif
256#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200257# define PV_COCU OPT_WIN(WV_COCU)
258# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200259#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200260#ifdef FEAT_TERMINAL
261# define PV_TMS OPT_WIN(WV_TMS)
262#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200263#ifdef FEAT_SIGNS
264# define PV_SCL OPT_WIN(WV_SCL)
265#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000266
267/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268typedef enum
269{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000270 PV_NONE = 0,
271 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000272} idopt_T;
273
274/*
275 * Options local to a window have a value local to a buffer and global to all
276 * buffers. Indicate this by setting "var" to VAR_WIN.
277 */
278#define VAR_WIN ((char_u *)-1)
279
280/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000281 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282 * Only to be used in option.c!
283 */
284static int p_ai;
285static int p_bin;
286#ifdef FEAT_MBYTE
287static int p_bomb;
288#endif
289#if defined(FEAT_QUICKFIX)
290static char_u *p_bh;
291static char_u *p_bt;
292#endif
293static int p_bl;
294static int p_ci;
295#ifdef FEAT_CINDENT
296static int p_cin;
297static char_u *p_cink;
298static char_u *p_cino;
299#endif
300#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
301static char_u *p_cinw;
302#endif
303#ifdef FEAT_COMMENTS
304static char_u *p_com;
305#endif
306#ifdef FEAT_FOLDING
307static char_u *p_cms;
308#endif
309#ifdef FEAT_INS_EXPAND
310static char_u *p_cpt;
311#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000312#ifdef FEAT_COMPL_FUNC
313static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000314static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000315#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000316static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200317static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318static int p_et;
319#ifdef FEAT_MBYTE
320static char_u *p_fenc;
321#endif
322static char_u *p_ff;
323static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000324static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325#ifdef FEAT_AUTOCMD
326static char_u *p_ft;
327#endif
328static long p_iminsert;
329static long p_imsearch;
330#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
331static char_u *p_inex;
332#endif
333#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
334static char_u *p_inde;
335static char_u *p_indk;
336#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000337#if defined(FEAT_EVAL)
338static char_u *p_fex;
339#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000340static int p_inf;
341static char_u *p_isk;
342#ifdef FEAT_CRYPT
343static char_u *p_key;
344#endif
345#ifdef FEAT_LISP
346static int p_lisp;
347#endif
348static int p_ml;
349static int p_ma;
350static int p_mod;
351static char_u *p_mps;
352static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000353static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000354#ifdef FEAT_TEXTOBJ
355static char_u *p_qe;
356#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357static int p_ro;
358#ifdef FEAT_SMARTINDENT
359static int p_si;
360#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362static long p_sts;
363#if defined(FEAT_SEARCHPATH)
364static char_u *p_sua;
365#endif
366static long p_sw;
367static int p_swf;
368#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000369static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000371#endif
372#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000373static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000374static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000375static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376#endif
377static long p_ts;
378static long p_tw;
379static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200380#ifdef FEAT_PERSISTENT_UNDO
381static int p_udf;
382#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000383static long p_wm;
384#ifdef FEAT_KEYMAP
385static char_u *p_keymap;
386#endif
387
388/* Saved values for when 'bin' is set. */
389static int p_et_nobin;
390static int p_ml_nobin;
391static long p_tw_nobin;
392static long p_wm_nobin;
393
394/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200395static int p_ai_nopaste;
396static int p_et_nopaste;
397static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000398static long p_tw_nopaste;
399static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400
401struct vimoption
402{
403 char *fullname; /* full option name */
404 char *shortname; /* permissible abbreviation */
405 long_u flags; /* see below */
406 char_u *var; /* global option: pointer to variable;
407 * window-local option: VAR_WIN;
408 * buffer-local option: global value */
409 idopt_T indir; /* global option: PV_NONE;
410 * local option: indirect option index */
411 char_u *def_val[2]; /* default values for variable (vi and vim) */
412#ifdef FEAT_EVAL
413 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000414# define SCRIPTID_INIT , 0
415#else
416# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000417#endif
418};
419
420#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
421#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
422
423/*
424 * Flags
425 */
426#define P_BOOL 0x01 /* the option is boolean */
427#define P_NUM 0x02 /* the option is numeric */
428#define P_STRING 0x04 /* the option is a string */
429#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000430 must use free_string_option() when
431 assigning new value. Not set if default is
432 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
434 never be used for local or hidden options! */
435#define P_NODEFAULT 0x40 /* don't set to default value */
436#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
437 use vim_free() when assigning new value */
438#define P_WAS_SET 0x100 /* option has been set/reset */
439#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
440#define P_VI_DEF 0x400 /* Use Vi default for Vim */
441#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
442
443 /* when option changed, what to display: */
444#define P_RSTAT 0x1000 /* redraw status lines */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100445#define P_RWIN 0x2000 /* redraw current window and recompute text */
446#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447#define P_RALL 0x6000 /* redraw all windows */
448#define P_RCLR 0x7000 /* clear and redraw all */
449
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200450#define P_COMMA 0x8000 /* comma separated list */
451#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
452 * commas */
453#define P_NODUP 0x20000L /* don't allow duplicate strings */
454#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000455
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200456#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
457#define P_GETTEXT 0x100000L /* expand default value with _() */
458#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
459#define P_NFNAME 0x400000L /* only normal file name chars allowed */
460#define P_INSECURE 0x800000L /* option was set from a modeline */
461#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100462 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200463#define P_NO_ML 0x2000000L /* not allowed in modeline */
464#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200465 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100466#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100467#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000468
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000469#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
470
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000471/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
472 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100473#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000474# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000475#else
476# define ISP_LATIN1 (char_u *)"@,161-255"
477#endif
478
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100479/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000480#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100481 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar21020352017-06-13 17:21:04 +0200482 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) \
483 || defined(FEAT_CONCEAL) || defined(FEAT_QUICKFIX)
484# 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,q:QuickFixLine"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000485#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100486# 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 +0000487#endif
488
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +0100489/* Default python version for pyx* commands */
490#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
491# define DEFAULT_PYTHON_VER 0
492#elif defined(FEAT_PYTHON3)
493# define DEFAULT_PYTHON_VER 3
494#elif defined(FEAT_PYTHON)
495# define DEFAULT_PYTHON_VER 2
496#else
497# define DEFAULT_PYTHON_VER 0
498#endif
499
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500/*
501 * options[] is initialized here.
502 * The order of the options MUST be alphabetic for ":set all" and findoption().
503 * All option names MUST start with a lowercase letter (for findoption()).
504 * Exception: "t_" options are at the end.
505 * The options with a NULL variable are 'hidden': a set command for them is
506 * ignored and they are not printed.
507 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100508static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000509{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200510 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000511#ifdef FEAT_RIGHTLEFT
512 (char_u *)&p_aleph, PV_NONE,
513#else
514 (char_u *)NULL, PV_NONE,
515#endif
516 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100517#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518 (char_u *)128L,
519#else
520 (char_u *)224L,
521#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000522 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
524#if defined(FEAT_GUI) && defined(MACOS_X)
525 (char_u *)&p_antialias, PV_NONE,
526 {(char_u *)FALSE, (char_u *)FALSE}
527#else
528 (char_u *)NULL, PV_NONE,
529 {(char_u *)FALSE, (char_u *)FALSE}
530#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000531 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200532 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533#ifdef FEAT_ARABIC
534 (char_u *)VAR_WIN, PV_ARAB,
535#else
536 (char_u *)NULL, PV_NONE,
537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000538 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
540#ifdef FEAT_ARABIC
541 (char_u *)&p_arshape, PV_NONE,
542#else
543 (char_u *)NULL, PV_NONE,
544#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000545 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
547#ifdef FEAT_RIGHTLEFT
548 (char_u *)&p_ari, PV_NONE,
549#else
550 (char_u *)NULL, PV_NONE,
551#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
554#ifdef FEAT_FKMAP
555 (char_u *)&p_altkeymap, PV_NONE,
556#else
557 (char_u *)NULL, PV_NONE,
558#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
561#if defined(FEAT_MBYTE)
562 (char_u *)&p_ambw, PV_NONE,
563 {(char_u *)"single", (char_u *)0L}
564#else
565 (char_u *)NULL, PV_NONE,
566 {(char_u *)0L, (char_u *)0L}
567#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000568 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569 {"autochdir", "acd", P_BOOL|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100570#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000571 (char_u *)&p_acd, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100572 {(char_u *)FALSE, (char_u *)0L}
573#else
574 (char_u *)NULL, PV_NONE,
575 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +0100577 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578 {"autoindent", "ai", P_BOOL|P_VI_DEF,
579 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000580 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581 {"autoprint", "ap", P_BOOL|P_VI_DEF,
582 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000585 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000586 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000587 {"autowrite", "aw", P_BOOL|P_VI_DEF,
588 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000589 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590 {"autowriteall","awa", P_BOOL|P_VI_DEF,
591 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000592 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
594 (char_u *)&p_bg, PV_NONE,
595 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100596#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597 (char_u *)"dark",
598#else
599 (char_u *)"light",
600#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000601 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200602 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000603 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000604 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000605 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
606 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000607 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200608 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200609 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000610#ifdef UNIX
611 {(char_u *)"yes", (char_u *)"auto"}
612#else
613 {(char_u *)"auto", (char_u *)"auto"}
614#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000615 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200616 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
617 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000618 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000619 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000620 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000621 (char_u *)&p_bex, PV_NONE,
622 {
623#ifdef VMS
624 (char_u *)"_",
625#else
626 (char_u *)"~",
627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000628 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200629 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630#ifdef FEAT_WILDIGN
631 (char_u *)&p_bsk, PV_NONE,
632 {(char_u *)"", (char_u *)0L}
633#else
634 (char_u *)NULL, PV_NONE,
635 {(char_u *)0L, (char_u *)0L}
636#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000637 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100639#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +0000640 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100641 {(char_u *)600L, (char_u *)0L}
642#else
643 (char_u *)NULL, PV_NONE,
644 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000645#endif
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100646 SCRIPTID_INIT},
647 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
648#ifdef FEAT_BEVAL
649 (char_u *)&p_beval, PV_NONE,
650 {(char_u *)FALSE, (char_u *)0L}
651#else
652 (char_u *)NULL, PV_NONE,
653 {(char_u *)0L, (char_u *)0L}
654#endif
655 SCRIPTID_INIT},
656 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
657#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
658 (char_u *)&p_bexpr, PV_BEXPR,
659 {(char_u *)"", (char_u *)0L}
660#else
661 (char_u *)NULL, PV_NONE,
662 {(char_u *)0L, (char_u *)0L}
663#endif
664 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000665 {"beautify", "bf", P_BOOL|P_VI_DEF,
666 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000667 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200668 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
669 (char_u *)&p_bo, PV_NONE,
670 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
672 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000673 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000674 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000676 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000677 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
678#ifdef FEAT_MBYTE
679 (char_u *)&p_bomb, PV_BOMB,
680#else
681 (char_u *)NULL, PV_NONE,
682#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000683 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000684 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
685#ifdef FEAT_LINEBREAK
686 (char_u *)&p_breakat, PV_NONE,
687 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
688#else
689 (char_u *)NULL, PV_NONE,
690 {(char_u *)0L, (char_u *)0L}
691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000692 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200693 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
694#ifdef FEAT_LINEBREAK
695 (char_u *)VAR_WIN, PV_BRI,
696 {(char_u *)FALSE, (char_u *)0L}
697#else
698 (char_u *)NULL, PV_NONE,
699 {(char_u *)0L, (char_u *)0L}
700#endif
701 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200702 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
703 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200704#ifdef FEAT_LINEBREAK
705 (char_u *)VAR_WIN, PV_BRIOPT,
706 {(char_u *)"", (char_u *)NULL}
707#else
708 (char_u *)NULL, PV_NONE,
709 {(char_u *)"", (char_u *)NULL}
710#endif
711 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000712 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
713#ifdef FEAT_BROWSE
714 (char_u *)&p_bsdir, PV_NONE,
715 {(char_u *)"last", (char_u *)0L}
716#else
717 (char_u *)NULL, PV_NONE,
718 {(char_u *)0L, (char_u *)0L}
719#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000720 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000721 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
722#if defined(FEAT_QUICKFIX)
723 (char_u *)&p_bh, PV_BH,
724 {(char_u *)"", (char_u *)0L}
725#else
726 (char_u *)NULL, PV_NONE,
727 {(char_u *)0L, (char_u *)0L}
728#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000729 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000730 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
731 (char_u *)&p_bl, PV_BL,
732 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000733 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000734 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
735#if defined(FEAT_QUICKFIX)
736 (char_u *)&p_bt, PV_BT,
737 {(char_u *)"", (char_u *)0L}
738#else
739 (char_u *)NULL, PV_NONE,
740 {(char_u *)0L, (char_u *)0L}
741#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000742 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200743 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000744#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000745 (char_u *)&p_cmp, PV_NONE,
746 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000747#else
748 (char_u *)NULL, PV_NONE,
749 {(char_u *)0L, (char_u *)0L}
750#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000751 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000752 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
753#ifdef FEAT_SEARCHPATH
754 (char_u *)&p_cdpath, PV_NONE,
755 {(char_u *)",,", (char_u *)0L}
756#else
757 (char_u *)NULL, PV_NONE,
758 {(char_u *)0L, (char_u *)0L}
759#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000760 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000761 {"cedit", NULL, P_STRING,
762#ifdef FEAT_CMDWIN
763 (char_u *)&p_cedit, PV_NONE,
764 {(char_u *)"", (char_u *)CTRL_F_STR}
765#else
766 (char_u *)NULL, PV_NONE,
767 {(char_u *)0L, (char_u *)0L}
768#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000769 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000770 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
771#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
772 (char_u *)&p_ccv, PV_NONE,
773 {(char_u *)"", (char_u *)0L}
774#else
775 (char_u *)NULL, PV_NONE,
776 {(char_u *)0L, (char_u *)0L}
777#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000778 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000779 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
780#ifdef FEAT_CINDENT
781 (char_u *)&p_cin, PV_CIN,
782#else
783 (char_u *)NULL, PV_NONE,
784#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000785 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200786 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000787#ifdef FEAT_CINDENT
788 (char_u *)&p_cink, PV_CINK,
789 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
790#else
791 (char_u *)NULL, PV_NONE,
792 {(char_u *)0L, (char_u *)0L}
793#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000794 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200795 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000796#ifdef FEAT_CINDENT
797 (char_u *)&p_cino, PV_CINO,
798#else
799 (char_u *)NULL, PV_NONE,
800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000801 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200802 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000803#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
804 (char_u *)&p_cinw, PV_CINW,
805 {(char_u *)"if,else,while,do,for,switch",
806 (char_u *)0L}
807#else
808 (char_u *)NULL, PV_NONE,
809 {(char_u *)0L, (char_u *)0L}
810#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000811 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200812 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000813#ifdef FEAT_CLIPBOARD
814 (char_u *)&p_cb, PV_NONE,
815# ifdef FEAT_XCLIPBOARD
816 {(char_u *)"autoselect,exclude:cons\\|linux",
817 (char_u *)0L}
818# else
819 {(char_u *)"", (char_u *)0L}
820# endif
821#else
822 (char_u *)NULL, PV_NONE,
823 {(char_u *)"", (char_u *)0L}
824#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000825 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
827 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000828 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000829 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
830#ifdef FEAT_CMDWIN
831 (char_u *)&p_cwh, PV_NONE,
832#else
833 (char_u *)NULL, PV_NONE,
834#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000835 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200836 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200837#ifdef FEAT_SYN_HL
838 (char_u *)VAR_WIN, PV_CC,
839#else
840 (char_u *)NULL, PV_NONE,
841#endif
842 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000843 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
844 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000845 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200846 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
847 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000848#ifdef FEAT_COMMENTS
849 (char_u *)&p_com, PV_COM,
850 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
851 (char_u *)0L}
852#else
853 (char_u *)NULL, PV_NONE,
854 {(char_u *)0L, (char_u *)0L}
855#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000856 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200857 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000858#ifdef FEAT_FOLDING
859 (char_u *)&p_cms, PV_CMS,
860 {(char_u *)"/*%s*/", (char_u *)0L}
861#else
862 (char_u *)NULL, PV_NONE,
863 {(char_u *)0L, (char_u *)0L}
864#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000865 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000866 /* P_PRI_MKRC isn't needed here, optval_default()
867 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000868 {"compatible", "cp", P_BOOL|P_RALL,
869 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000870 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200871 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000872#ifdef FEAT_INS_EXPAND
873 (char_u *)&p_cpt, PV_CPT,
874 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
875#else
876 (char_u *)NULL, PV_NONE,
877 {(char_u *)0L, (char_u *)0L}
878#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000879 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200880 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200881#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200882 (char_u *)VAR_WIN, PV_COCU,
883 {(char_u *)"", (char_u *)NULL}
884#else
885 (char_u *)NULL, PV_NONE,
886 {(char_u *)NULL, (char_u *)0L}
887#endif
888 SCRIPTID_INIT},
889 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
890#ifdef FEAT_CONCEAL
891 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200892#else
893 (char_u *)NULL, PV_NONE,
894#endif
895 {(char_u *)0L, (char_u *)0L}
896 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000897 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
898#ifdef FEAT_COMPL_FUNC
899 (char_u *)&p_cfu, PV_CFU,
900 {(char_u *)"", (char_u *)0L}
901#else
902 (char_u *)NULL, PV_NONE,
903 {(char_u *)0L, (char_u *)0L}
904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000905 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200906 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000907#ifdef FEAT_INS_EXPAND
908 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000909 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000910#else
911 (char_u *)NULL, PV_NONE,
912 {(char_u *)0L, (char_u *)0L}
913#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000914 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000915 {"confirm", "cf", P_BOOL|P_VI_DEF,
916#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
917 (char_u *)&p_confirm, PV_NONE,
918#else
919 (char_u *)NULL, PV_NONE,
920#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000921 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000922 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000923 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000924 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000925 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
926 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000927 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000928 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
929 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000930 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
931 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200932 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200933#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200934 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200935 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200936#else
937 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200938 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200939#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200940 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000941 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
942#ifdef FEAT_CSCOPE
943 (char_u *)&p_cspc, PV_NONE,
944#else
945 (char_u *)NULL, PV_NONE,
946#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000947 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
949#ifdef FEAT_CSCOPE
950 (char_u *)&p_csprg, PV_NONE,
951 {(char_u *)"cscope", (char_u *)0L}
952#else
953 (char_u *)NULL, PV_NONE,
954 {(char_u *)0L, (char_u *)0L}
955#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000956 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200957 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000958#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
959 (char_u *)&p_csqf, PV_NONE,
960 {(char_u *)"", (char_u *)0L}
961#else
962 (char_u *)NULL, PV_NONE,
963 {(char_u *)0L, (char_u *)0L}
964#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000965 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200966 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
967#ifdef FEAT_CSCOPE
968 (char_u *)&p_csre, PV_NONE,
969#else
970 (char_u *)NULL, PV_NONE,
971#endif
972 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000973 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
974#ifdef FEAT_CSCOPE
975 (char_u *)&p_cst, PV_NONE,
976#else
977 (char_u *)NULL, PV_NONE,
978#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000979 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000980 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
981#ifdef FEAT_CSCOPE
982 (char_u *)&p_csto, PV_NONE,
983#else
984 (char_u *)NULL, PV_NONE,
985#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000986 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000987 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
988#ifdef FEAT_CSCOPE
989 (char_u *)&p_csverbose, PV_NONE,
990#else
991 (char_u *)NULL, PV_NONE,
992#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000993 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200994 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
995#ifdef FEAT_CURSORBIND
996 (char_u *)VAR_WIN, PV_CRBIND,
997#else
998 (char_u *)NULL, PV_NONE,
999#endif
1000 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001001 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
1002#ifdef FEAT_SYN_HL
1003 (char_u *)VAR_WIN, PV_CUC,
1004#else
1005 (char_u *)NULL, PV_NONE,
1006#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001007 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +01001008 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001009#ifdef FEAT_SYN_HL
1010 (char_u *)VAR_WIN, PV_CUL,
1011#else
1012 (char_u *)NULL, PV_NONE,
1013#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001014 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001015 {"debug", NULL, P_STRING|P_VI_DEF,
1016 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001017 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001018 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001020 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001021 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001022#else
1023 (char_u *)NULL, PV_NONE,
1024 {(char_u *)NULL, (char_u *)0L}
1025#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001026 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1028#ifdef FEAT_MBYTE
1029 (char_u *)&p_deco, PV_NONE,
1030#else
1031 (char_u *)NULL, PV_NONE,
1032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001033 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001034 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001035#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001036 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037#else
1038 (char_u *)NULL, PV_NONE,
1039#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001040 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1042#ifdef FEAT_DIFF
1043 (char_u *)VAR_WIN, PV_DIFF,
1044#else
1045 (char_u *)NULL, PV_NONE,
1046#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001047 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001048 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1050 (char_u *)&p_dex, PV_NONE,
1051 {(char_u *)"", (char_u *)0L}
1052#else
1053 (char_u *)NULL, PV_NONE,
1054 {(char_u *)0L, (char_u *)0L}
1055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001056 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001057 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1058 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001059#ifdef FEAT_DIFF
1060 (char_u *)&p_dip, PV_NONE,
1061 {(char_u *)"filler", (char_u *)NULL}
1062#else
1063 (char_u *)NULL, PV_NONE,
1064 {(char_u *)"", (char_u *)NULL}
1065#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001066 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001067 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1068#ifdef FEAT_DIGRAPHS
1069 (char_u *)&p_dg, PV_NONE,
1070#else
1071 (char_u *)NULL, PV_NONE,
1072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001074 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1075 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001077 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001078 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001080 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001081 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001082#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 (char_u *)&p_ead, PV_NONE,
1084 {(char_u *)"both", (char_u *)0L}
1085#else
1086 (char_u *)NULL, PV_NONE,
1087 {(char_u *)NULL, (char_u *)0L}
1088#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001089 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001090 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1091 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001092 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001093 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1094#if defined(FEAT_MBYTE)
1095 (char_u *)&p_emoji, PV_NONE,
1096 {(char_u *)TRUE, (char_u *)0L}
1097#else
1098 (char_u *)NULL, PV_NONE,
1099 {(char_u *)0L, (char_u *)0L}
1100#endif
1101 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001102 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103#ifdef FEAT_MBYTE
1104 (char_u *)&p_enc, PV_NONE,
1105 {(char_u *)ENC_DFLT, (char_u *)0L}
1106#else
1107 (char_u *)NULL, PV_NONE,
1108 {(char_u *)0L, (char_u *)0L}
1109#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001110 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001111 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1112 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001113 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1115 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001118 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1121 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001122 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1124#ifdef FEAT_QUICKFIX
1125 (char_u *)&p_ef, PV_NONE,
1126 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1127#else
1128 (char_u *)NULL, PV_NONE,
1129 {(char_u *)NULL, (char_u *)0L}
1130#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001131 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001132 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001134 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001135 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136#else
1137 (char_u *)NULL, PV_NONE,
1138 {(char_u *)NULL, (char_u *)0L}
1139#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001140 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 {"esckeys", "ek", P_BOOL|P_VIM,
1142 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001143 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001144 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145#ifdef FEAT_AUTOCMD
1146 (char_u *)&p_ei, PV_NONE,
1147#else
1148 (char_u *)NULL, PV_NONE,
1149#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001150 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001151 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1152 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001153 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001154 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1155 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001156 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001157 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1158 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001159#ifdef FEAT_MBYTE
1160 (char_u *)&p_fenc, PV_FENC,
1161 {(char_u *)"", (char_u *)0L}
1162#else
1163 (char_u *)NULL, PV_NONE,
1164 {(char_u *)0L, (char_u *)0L}
1165#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001166 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001167 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168#ifdef FEAT_MBYTE
1169 (char_u *)&p_fencs, PV_NONE,
1170 {(char_u *)"ucs-bom", (char_u *)0L}
1171#else
1172 (char_u *)NULL, PV_NONE,
1173 {(char_u *)0L, (char_u *)0L}
1174#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001175 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001176 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1177 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001179 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001180 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001181 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001182 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1183 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001184 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1185 (char_u *)&p_fic, PV_NONE,
1186 {
1187#ifdef CASE_INSENSITIVE_FILENAME
1188 (char_u *)TRUE,
1189#else
1190 (char_u *)FALSE,
1191#endif
1192 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001193 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194#ifdef FEAT_AUTOCMD
1195 (char_u *)&p_ft, PV_FT,
1196 {(char_u *)"", (char_u *)0L}
1197#else
1198 (char_u *)NULL, PV_NONE,
1199 {(char_u *)0L, (char_u *)0L}
1200#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001201 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001202 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1204 (char_u *)&p_fcs, PV_NONE,
1205 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1206#else
1207 (char_u *)NULL, PV_NONE,
1208 {(char_u *)"", (char_u *)0L}
1209#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001210 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001211 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1212 (char_u *)&p_fixeol, PV_FIXEOL,
1213 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001214 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1215#ifdef FEAT_FKMAP
1216 (char_u *)&p_fkmap, PV_NONE,
1217#else
1218 (char_u *)NULL, PV_NONE,
1219#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001220 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001221 {"flash", "fl", P_BOOL|P_VI_DEF,
1222 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001223 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001224 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001225#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001227 {(char_u *)"", (char_u *)0L}
1228#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001229 (char_u *)NULL, PV_NONE,
1230 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001231#endif
1232 SCRIPTID_INIT},
1233 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1234#ifdef FEAT_FOLDING
1235 (char_u *)VAR_WIN, PV_FDC,
1236 {(char_u *)FALSE, (char_u *)0L}
1237#else
1238 (char_u *)NULL, PV_NONE,
1239 {(char_u *)NULL, (char_u *)0L}
1240#endif
1241 SCRIPTID_INIT},
1242 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1243#ifdef FEAT_FOLDING
1244 (char_u *)VAR_WIN, PV_FEN,
1245 {(char_u *)TRUE, (char_u *)0L}
1246#else
1247 (char_u *)NULL, PV_NONE,
1248 {(char_u *)NULL, (char_u *)0L}
1249#endif
1250 SCRIPTID_INIT},
1251 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1252#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1253 (char_u *)VAR_WIN, PV_FDE,
1254 {(char_u *)"0", (char_u *)NULL}
1255#else
1256 (char_u *)NULL, PV_NONE,
1257 {(char_u *)NULL, (char_u *)0L}
1258#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001259 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001261#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001262 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001263 {(char_u *)"#", (char_u *)NULL}
1264#else
1265 (char_u *)NULL, PV_NONE,
1266 {(char_u *)NULL, (char_u *)0L}
1267#endif
1268 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001270#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001272 {(char_u *)0L, (char_u *)0L}
1273#else
1274 (char_u *)NULL, PV_NONE,
1275 {(char_u *)NULL, (char_u *)0L}
1276#endif
1277 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001278 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001279#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001280 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001281 {(char_u *)-1L, (char_u *)0L}
1282#else
1283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
1285#endif
1286 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001288 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001289#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001291 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001292#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293 (char_u *)NULL, PV_NONE,
1294 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001295#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001296 SCRIPTID_INIT},
1297 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1298#ifdef FEAT_FOLDING
1299 (char_u *)VAR_WIN, PV_FDM,
1300 {(char_u *)"manual", (char_u *)NULL}
1301#else
1302 (char_u *)NULL, PV_NONE,
1303 {(char_u *)NULL, (char_u *)0L}
1304#endif
1305 SCRIPTID_INIT},
1306 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1307#ifdef FEAT_FOLDING
1308 (char_u *)VAR_WIN, PV_FML,
1309 {(char_u *)1L, (char_u *)0L}
1310#else
1311 (char_u *)NULL, PV_NONE,
1312 {(char_u *)NULL, (char_u *)0L}
1313#endif
1314 SCRIPTID_INIT},
1315 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1316#ifdef FEAT_FOLDING
1317 (char_u *)VAR_WIN, PV_FDN,
1318 {(char_u *)20L, (char_u *)0L}
1319#else
1320 (char_u *)NULL, PV_NONE,
1321 {(char_u *)NULL, (char_u *)0L}
1322#endif
1323 SCRIPTID_INIT},
1324 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1325#ifdef FEAT_FOLDING
1326 (char_u *)&p_fdo, PV_NONE,
1327 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1328 (char_u *)0L}
1329#else
1330 (char_u *)NULL, PV_NONE,
1331 {(char_u *)NULL, (char_u *)0L}
1332#endif
1333 SCRIPTID_INIT},
1334 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1335#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1336 (char_u *)VAR_WIN, PV_FDT,
1337 {(char_u *)"foldtext()", (char_u *)NULL}
1338#else
1339 (char_u *)NULL, PV_NONE,
1340 {(char_u *)NULL, (char_u *)0L}
1341#endif
1342 SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001343 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001344#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001345 (char_u *)&p_fex, PV_FEX,
1346 {(char_u *)"", (char_u *)0L}
1347#else
1348 (char_u *)NULL, PV_NONE,
1349 {(char_u *)0L, (char_u *)0L}
1350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001351 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001352 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1353 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001354 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1355 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001356 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1357 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001358 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1359 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001361 (char_u *)&p_fp, PV_FP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001362 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001363 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1364#ifdef HAVE_FSYNC
1365 (char_u *)&p_fs, PV_NONE,
1366 {(char_u *)TRUE, (char_u *)0L}
1367#else
1368 (char_u *)NULL, PV_NONE,
1369 {(char_u *)FALSE, (char_u *)0L}
1370#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001371 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1373 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375 {"graphic", "gr", P_BOOL|P_VI_DEF,
1376 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001377 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001378 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001379#ifdef FEAT_QUICKFIX
1380 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001381 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001382#else
1383 (char_u *)NULL, PV_NONE,
1384 {(char_u *)NULL, (char_u *)0L}
1385#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001386 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001387 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1388#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001389 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001390 {
1391# ifdef WIN3264
1392 /* may be changed to "grep -n" in os_win32.c */
1393 (char_u *)"findstr /n",
1394# else
1395# ifdef UNIX
1396 /* Add an extra file name so that grep will always
1397 * insert a file name in the match line. */
1398 (char_u *)"grep -n $* /dev/null",
1399# else
1400# ifdef VMS
1401 (char_u *)"SEARCH/NUMBERS ",
1402# else
1403 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001404# endif
1405# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001407 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408#else
1409 (char_u *)NULL, PV_NONE,
1410 {(char_u *)NULL, (char_u *)0L}
1411#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001412 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001413 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001414#ifdef CURSOR_SHAPE
1415 (char_u *)&p_guicursor, PV_NONE,
1416 {
1417# ifdef FEAT_GUI
1418 (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 +01001419# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001420 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1421# endif
1422 (char_u *)0L}
1423#else
1424 (char_u *)NULL, PV_NONE,
1425 {(char_u *)NULL, (char_u *)0L}
1426#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001427 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001428 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001429#ifdef FEAT_GUI
1430 (char_u *)&p_guifont, PV_NONE,
1431 {(char_u *)"", (char_u *)0L}
1432#else
1433 (char_u *)NULL, PV_NONE,
1434 {(char_u *)NULL, (char_u *)0L}
1435#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001436 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001437 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001438#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1439 (char_u *)&p_guifontset, PV_NONE,
1440 {(char_u *)"", (char_u *)0L}
1441#else
1442 (char_u *)NULL, PV_NONE,
1443 {(char_u *)NULL, (char_u *)0L}
1444#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001445 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001446 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1448 (char_u *)&p_guifontwide, PV_NONE,
1449 {(char_u *)"", (char_u *)0L}
1450#else
1451 (char_u *)NULL, PV_NONE,
1452 {(char_u *)NULL, (char_u *)0L}
1453#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001454 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001455 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001456#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457 (char_u *)&p_ghr, PV_NONE,
1458#else
1459 (char_u *)NULL, PV_NONE,
1460#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001461 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001462 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001463#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464 (char_u *)&p_go, PV_NONE,
1465# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001466 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001467# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001468 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001469# endif
1470#else
1471 (char_u *)NULL, PV_NONE,
1472 {(char_u *)NULL, (char_u *)0L}
1473#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001474 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001475 {"guipty", NULL, P_BOOL|P_VI_DEF,
1476#if defined(FEAT_GUI)
1477 (char_u *)&p_guipty, PV_NONE,
1478#else
1479 (char_u *)NULL, PV_NONE,
1480#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001481 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001482 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001483#if defined(FEAT_GUI_TABLINE)
1484 (char_u *)&p_gtl, PV_NONE,
1485 {(char_u *)"", (char_u *)0L}
1486#else
1487 (char_u *)NULL, PV_NONE,
1488 {(char_u *)NULL, (char_u *)0L}
1489#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001490 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001491 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001492#if defined(FEAT_GUI_TABLINE)
1493 (char_u *)&p_gtt, PV_NONE,
1494 {(char_u *)"", (char_u *)0L}
1495#else
1496 (char_u *)NULL, PV_NONE,
1497 {(char_u *)NULL, (char_u *)0L}
1498#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001499 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001500 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1501 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001502 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001503 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1504 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001505 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1506 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001507 {"helpheight", "hh", P_NUM|P_VI_DEF,
1508#ifdef FEAT_WINDOWS
1509 (char_u *)&p_hh, PV_NONE,
1510#else
1511 (char_u *)NULL, PV_NONE,
1512#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001513 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001514 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001515#ifdef FEAT_MULTI_LANG
1516 (char_u *)&p_hlg, PV_NONE,
1517 {(char_u *)"", (char_u *)0L}
1518#else
1519 (char_u *)NULL, PV_NONE,
1520 {(char_u *)0L, (char_u *)0L}
1521#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001522 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001523 {"hidden", "hid", P_BOOL|P_VI_DEF,
1524 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001525 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001526 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001528 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1529 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"history", "hi", P_NUM|P_VIM,
1531 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001532 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001533 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1534#ifdef FEAT_RIGHTLEFT
1535 (char_u *)&p_hkmap, PV_NONE,
1536#else
1537 (char_u *)NULL, PV_NONE,
1538#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001540 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1541#ifdef FEAT_RIGHTLEFT
1542 (char_u *)&p_hkmapp, PV_NONE,
1543#else
1544 (char_u *)NULL, PV_NONE,
1545#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001547 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1548 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001549 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001550 {"icon", NULL, P_BOOL|P_VI_DEF,
1551#ifdef FEAT_TITLE
1552 (char_u *)&p_icon, PV_NONE,
1553#else
1554 (char_u *)NULL, PV_NONE,
1555#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001557 {"iconstring", NULL, P_STRING|P_VI_DEF,
1558#ifdef FEAT_TITLE
1559 (char_u *)&p_iconstring, PV_NONE,
1560#else
1561 (char_u *)NULL, PV_NONE,
1562#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001563 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001564 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1565 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001566 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001567 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1568# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1569 (char_u *)&p_imaf, PV_NONE,
1570 {(char_u *)"", (char_u *)NULL}
1571# else
1572 (char_u *)NULL, PV_NONE,
1573 {(char_u *)NULL, (char_u *)0L}
1574# endif
1575 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001576 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001577#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001578 (char_u *)&p_imak, PV_NONE,
1579#else
1580 (char_u *)NULL, PV_NONE,
1581#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001582 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001583 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1584#ifdef USE_IM_CONTROL
1585 (char_u *)&p_imcmdline, PV_NONE,
1586#else
1587 (char_u *)NULL, PV_NONE,
1588#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001589 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001590 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1591#ifdef USE_IM_CONTROL
1592 (char_u *)&p_imdisable, PV_NONE,
1593#else
1594 (char_u *)NULL, PV_NONE,
1595#endif
1596#ifdef __sgi
1597 {(char_u *)TRUE, (char_u *)0L}
1598#else
1599 {(char_u *)FALSE, (char_u *)0L}
1600#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001601 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001602 {"iminsert", "imi", P_NUM|P_VI_DEF,
1603 (char_u *)&p_iminsert, PV_IMI,
1604#ifdef B_IMODE_IM
1605 {(char_u *)B_IMODE_IM, (char_u *)0L}
1606#else
1607 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001609 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001610 {"imsearch", "ims", P_NUM|P_VI_DEF,
1611 (char_u *)&p_imsearch, PV_IMS,
1612#ifdef B_IMODE_IM
1613 {(char_u *)B_IMODE_IM, (char_u *)0L}
1614#else
1615 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1616#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001617 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001618 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001619# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1620 (char_u *)&p_imsf, PV_NONE,
1621 {(char_u *)"", (char_u *)NULL}
1622# else
1623 (char_u *)NULL, PV_NONE,
1624 {(char_u *)NULL, (char_u *)0L}
1625# endif
1626 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001627 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1628#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001629 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001630 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1631#else
1632 (char_u *)NULL, PV_NONE,
1633 {(char_u *)0L, (char_u *)0L}
1634#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001635 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001636 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1637#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1638 (char_u *)&p_inex, PV_INEX,
1639 {(char_u *)"", (char_u *)0L}
1640#else
1641 (char_u *)NULL, PV_NONE,
1642 {(char_u *)0L, (char_u *)0L}
1643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001644 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001645 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1646 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001647 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001648 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1649#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1650 (char_u *)&p_inde, PV_INDE,
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 Moolenaar0e7c4b92015-06-20 15:30:03 +02001657 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001658#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1659 (char_u *)&p_indk, PV_INDK,
1660 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1661#else
1662 (char_u *)NULL, PV_NONE,
1663 {(char_u *)0L, (char_u *)0L}
1664#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001665 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001666 {"infercase", "inf", P_BOOL|P_VI_DEF,
1667 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001668 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1670 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001671 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001672 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1673 (char_u *)&p_isf, PV_NONE,
1674 {
1675#ifdef BACKSLASH_IN_FILENAME
1676 /* Excluded are: & and ^ are special in cmd.exe
1677 * ( and ) are used in text separating fnames */
1678 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1679#else
1680# ifdef AMIGA
1681 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1682# else
1683# ifdef VMS
1684 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1685# else /* UNIX et al. */
1686# ifdef EBCDIC
1687 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1688# else
1689 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1690# endif
1691# endif
1692# endif
1693#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001694 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1696 (char_u *)&p_isi, PV_NONE,
1697 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001698#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001699 (char_u *)"@,48-57,_,128-167,224-235",
1700#else
1701# ifdef EBCDIC
1702 /* TODO: EBCDIC Check this! @ == isalpha()*/
1703 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1704 "112-120,128,140-142,156,158,172,"
1705 "174,186,191,203-207,219-225,235-239,"
1706 "251-254",
1707# else
1708 (char_u *)"@,48-57,_,192-255",
1709# endif
1710#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001711 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001712 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1713 (char_u *)&p_isk, PV_ISK,
1714 {
1715#ifdef EBCDIC
1716 (char_u *)"@,240-249,_",
1717 /* TODO: EBCDIC Check this! @ == isalpha()*/
1718 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1719 "112-120,128,140-142,156,158,172,"
1720 "174,186,191,203-207,219-225,235-239,"
1721 "251-254",
1722#else
1723 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001724# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 (char_u *)"@,48-57,_,128-167,224-235"
1726# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001727 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001728# endif
1729#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001730 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001731 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1732 (char_u *)&p_isp, PV_NONE,
1733 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001734#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001735 || defined(VMS)
1736 (char_u *)"@,~-255",
1737#else
1738# ifdef EBCDIC
1739 /* all chars above 63 are printable */
1740 (char_u *)"63-255",
1741# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001742 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001743# endif
1744#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001745 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001746 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1747 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001748 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001749 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1750#ifdef FEAT_CRYPT
1751 (char_u *)&p_key, PV_KEY,
1752 {(char_u *)"", (char_u *)0L}
1753#else
1754 (char_u *)NULL, PV_NONE,
1755 {(char_u *)0L, (char_u *)0L}
1756#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001757 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001758 {"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 +00001759#ifdef FEAT_KEYMAP
1760 (char_u *)&p_keymap, PV_KMAP,
1761 {(char_u *)"", (char_u *)0L}
1762#else
1763 (char_u *)NULL, PV_NONE,
1764 {(char_u *)"", (char_u *)0L}
1765#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001766 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001767 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001768 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001769 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001771 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001773#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774 (char_u *)":help",
1775#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001776# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001777 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001778# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001779# ifdef USEMAN_S
1780 (char_u *)"man -s",
1781# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001782 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001783# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001784# endif
1785#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001786 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001787 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001788#ifdef FEAT_LANGMAP
1789 (char_u *)&p_langmap, PV_NONE,
1790 {(char_u *)"", /* unmatched } */
1791#else
1792 (char_u *)NULL, PV_NONE,
1793 {(char_u *)NULL,
1794#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001795 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001796 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001797#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1798 (char_u *)&p_lm, PV_NONE,
1799#else
1800 (char_u *)NULL, PV_NONE,
1801#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001802 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001803 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1804#ifdef FEAT_LANGMAP
1805 (char_u *)&p_lnr, PV_NONE,
1806#else
1807 (char_u *)NULL, PV_NONE,
1808#endif
1809 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001810 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1811#ifdef FEAT_LANGMAP
1812 (char_u *)&p_lrm, PV_NONE,
1813#else
1814 (char_u *)NULL, PV_NONE,
1815#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001816 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1818#ifdef FEAT_WINDOWS
1819 (char_u *)&p_ls, PV_NONE,
1820#else
1821 (char_u *)NULL, PV_NONE,
1822#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001823 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1825 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001826 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001827 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1828#ifdef FEAT_LINEBREAK
1829 (char_u *)VAR_WIN, PV_LBR,
1830#else
1831 (char_u *)NULL, PV_NONE,
1832#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001833 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001834 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1835 (char_u *)&Rows, PV_NONE,
1836 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001837#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001838 (char_u *)25L,
1839#else
1840 (char_u *)24L,
1841#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001842 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1844#ifdef FEAT_GUI
1845 (char_u *)&p_linespace, PV_NONE,
1846#else
1847 (char_u *)NULL, PV_NONE,
1848#endif
1849#ifdef FEAT_GUI_W32
1850 {(char_u *)1L, (char_u *)0L}
1851#else
1852 {(char_u *)0L, (char_u *)0L}
1853#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001854 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 {"lisp", NULL, P_BOOL|P_VI_DEF,
1856#ifdef FEAT_LISP
1857 (char_u *)&p_lisp, PV_LISP,
1858#else
1859 (char_u *)NULL, PV_NONE,
1860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001861 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001862 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001863#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001864 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1866#else
1867 (char_u *)NULL, PV_NONE,
1868 {(char_u *)"", (char_u *)0L}
1869#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1872 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001874 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001875 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1878 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001879 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001880 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001881#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001882 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001883 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001884#else
1885 (char_u *)NULL, PV_NONE,
1886 {(char_u *)"", (char_u *)0L}
1887#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001888 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001889 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001890#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001891 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001892 {(char_u *)TRUE, (char_u *)0L}
1893#else
1894 (char_u *)NULL, PV_NONE,
1895 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001896#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001897 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001898 {"magic", NULL, P_BOOL|P_VI_DEF,
1899 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001900 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001901 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001902#ifdef FEAT_QUICKFIX
1903 (char_u *)&p_mef, PV_NONE,
1904 {(char_u *)"", (char_u *)0L}
1905#else
1906 (char_u *)NULL, PV_NONE,
1907 {(char_u *)NULL, (char_u *)0L}
1908#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001909 SCRIPTID_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001910 {"makeencoding","menc", P_STRING|P_VI_DEF,
1911#ifdef FEAT_MBYTE
1912 (char_u *)&p_menc, PV_MENC,
1913 {(char_u *)"", (char_u *)0L}
1914#else
1915 (char_u *)NULL, PV_NONE,
1916 {(char_u *)0L, (char_u *)0L}
1917#endif
1918 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001919 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1920#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001921 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001922# ifdef VMS
1923 {(char_u *)"MMS", (char_u *)0L}
1924# else
1925 {(char_u *)"make", (char_u *)0L}
1926# endif
1927#else
1928 (char_u *)NULL, PV_NONE,
1929 {(char_u *)NULL, (char_u *)0L}
1930#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001932 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001934 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1935 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 {"matchtime", "mat", P_NUM|P_VI_DEF,
1937 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001938 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001939 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001940#ifdef FEAT_MBYTE
1941 (char_u *)&p_mco, PV_NONE,
1942#else
1943 (char_u *)NULL, PV_NONE,
1944#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1947#ifdef FEAT_EVAL
1948 (char_u *)&p_mfd, PV_NONE,
1949#else
1950 (char_u *)NULL, PV_NONE,
1951#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001952 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1954 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001956 {"maxmem", "mm", P_NUM|P_VI_DEF,
1957 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001958 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1959 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001960 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1961 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001962 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001963 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1964 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001965 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1966 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001967 {"menuitems", "mis", P_NUM|P_VI_DEF,
1968#ifdef FEAT_MENU
1969 (char_u *)&p_mis, PV_NONE,
1970#else
1971 (char_u *)NULL, PV_NONE,
1972#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001973 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001974 {"mesg", NULL, P_BOOL|P_VI_DEF,
1975 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001976 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001977 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001978#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001979 (char_u *)&p_msm, PV_NONE,
1980 {(char_u *)"460000,2000,500", (char_u *)0L}
1981#else
1982 (char_u *)NULL, PV_NONE,
1983 {(char_u *)0L, (char_u *)0L}
1984#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001985 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001986 {"modeline", "ml", P_BOOL|P_VIM,
1987 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001988 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989 {"modelines", "mls", P_NUM|P_VI_DEF,
1990 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001991 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1993 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001994 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1996 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001997 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 {"more", NULL, P_BOOL|P_VIM,
1999 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002000 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
2002 (char_u *)&p_mouse, PV_NONE,
2003 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002004#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005 (char_u *)"a",
2006#else
2007 (char_u *)"",
2008#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002009 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
2011#ifdef FEAT_GUI
2012 (char_u *)&p_mousef, PV_NONE,
2013#else
2014 (char_u *)NULL, PV_NONE,
2015#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002016 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017 {"mousehide", "mh", P_BOOL|P_VI_DEF,
2018#ifdef FEAT_GUI
2019 (char_u *)&p_mh, PV_NONE,
2020#else
2021 (char_u *)NULL, PV_NONE,
2022#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002023 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002024 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
2025 (char_u *)&p_mousem, PV_NONE,
2026 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002027#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002028 (char_u *)"popup",
2029#else
2030# if defined(MACOS)
2031 (char_u *)"popup_setpos",
2032# else
2033 (char_u *)"extend",
2034# endif
2035#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002036 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002037 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002038#ifdef FEAT_MOUSESHAPE
2039 (char_u *)&p_mouseshape, PV_NONE,
2040 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2041#else
2042 (char_u *)NULL, PV_NONE,
2043 {(char_u *)NULL, (char_u *)0L}
2044#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002045 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2047 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002048 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002049 {"mzquantum", "mzq", P_NUM,
2050#ifdef FEAT_MZSCHEME
2051 (char_u *)&p_mzq, PV_NONE,
2052#else
2053 (char_u *)NULL, PV_NONE,
2054#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002055 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002056 {"novice", NULL, P_BOOL|P_VI_DEF,
2057 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002058 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002059 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002060 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002061 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002062 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002063 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2064 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002065 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002066 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2067#ifdef FEAT_LINEBREAK
2068 (char_u *)VAR_WIN, PV_NUW,
2069#else
2070 (char_u *)NULL, PV_NONE,
2071#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002072 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002073 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002074#ifdef FEAT_COMPL_FUNC
2075 (char_u *)&p_ofu, PV_OFU,
2076 {(char_u *)"", (char_u *)0L}
2077#else
2078 (char_u *)NULL, PV_NONE,
2079 {(char_u *)0L, (char_u *)0L}
2080#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002081 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002082 {"open", NULL, P_BOOL|P_VI_DEF,
2083 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002084 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002085 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002086#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002087 (char_u *)&p_odev, PV_NONE,
2088#else
2089 (char_u *)NULL, PV_NONE,
2090#endif
2091 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002092 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002093 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2094 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002095 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002096 {"optimize", "opt", P_BOOL|P_VI_DEF,
2097 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002098 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002099 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002100 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02002101 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002102 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2103 |P_SECURE,
2104 (char_u *)&p_pp, PV_NONE,
2105 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2106 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002107 {"paragraphs", "para", P_STRING|P_VI_DEF,
2108 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002109 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002111 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002112 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002113 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002114 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2115 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002116 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2118#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2119 (char_u *)&p_pex, PV_NONE,
2120 {(char_u *)"", (char_u *)0L}
2121#else
2122 (char_u *)NULL, PV_NONE,
2123 {(char_u *)0L, (char_u *)0L}
2124#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002125 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002126 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002127 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002128 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002129 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002130 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002131 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002132#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002133 (char_u *)".,,",
2134#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002135 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002137 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002138 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002139#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002140 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002141 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002142#else
2143 (char_u *)NULL, PV_NONE,
2144 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002145#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002146 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2148 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002149 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002150 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002151#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2152 (char_u *)&p_pvh, PV_NONE,
2153#else
2154 (char_u *)NULL, PV_NONE,
2155#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002156 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002157 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2158#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2159 (char_u *)VAR_WIN, PV_PVW,
2160#else
2161 (char_u *)NULL, PV_NONE,
2162#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002163 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002164 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002165#ifdef FEAT_PRINTER
2166 (char_u *)&p_pdev, PV_NONE,
2167 {(char_u *)"", (char_u *)0L}
2168#else
2169 (char_u *)NULL, PV_NONE,
2170 {(char_u *)NULL, (char_u *)0L}
2171#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002172 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173 {"printencoding", "penc", P_STRING|P_VI_DEF,
2174#ifdef FEAT_POSTSCRIPT
2175 (char_u *)&p_penc, PV_NONE,
2176 {(char_u *)"", (char_u *)0L}
2177#else
2178 (char_u *)NULL, PV_NONE,
2179 {(char_u *)NULL, (char_u *)0L}
2180#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002181 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002182 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002183#ifdef FEAT_POSTSCRIPT
2184 (char_u *)&p_pexpr, PV_NONE,
2185 {(char_u *)"", (char_u *)0L}
2186#else
2187 (char_u *)NULL, PV_NONE,
2188 {(char_u *)NULL, (char_u *)0L}
2189#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002190 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002191 {"printfont", "pfn", P_STRING|P_VI_DEF,
2192#ifdef FEAT_PRINTER
2193 (char_u *)&p_pfn, PV_NONE,
2194 {
2195# ifdef MSWIN
2196 (char_u *)"Courier_New:h10",
2197# else
2198 (char_u *)"courier",
2199# endif
2200 (char_u *)0L}
2201#else
2202 (char_u *)NULL, PV_NONE,
2203 {(char_u *)NULL, (char_u *)0L}
2204#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002205 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002206 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2207#ifdef FEAT_PRINTER
2208 (char_u *)&p_header, PV_NONE,
2209 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2210#else
2211 (char_u *)NULL, PV_NONE,
2212 {(char_u *)NULL, (char_u *)0L}
2213#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002214 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002215 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2216#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2217 (char_u *)&p_pmcs, PV_NONE,
2218 {(char_u *)"", (char_u *)0L}
2219#else
2220 (char_u *)NULL, PV_NONE,
2221 {(char_u *)NULL, (char_u *)0L}
2222#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002223 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002224 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2225#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2226 (char_u *)&p_pmfn, PV_NONE,
2227 {(char_u *)"", (char_u *)0L}
2228#else
2229 (char_u *)NULL, PV_NONE,
2230 {(char_u *)NULL, (char_u *)0L}
2231#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002232 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002233 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234#ifdef FEAT_PRINTER
2235 (char_u *)&p_popt, PV_NONE,
2236 {(char_u *)"", (char_u *)0L}
2237#else
2238 (char_u *)NULL, PV_NONE,
2239 {(char_u *)NULL, (char_u *)0L}
2240#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002243 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002245 {"pumheight", "ph", P_NUM|P_VI_DEF,
2246#ifdef FEAT_INS_EXPAND
2247 (char_u *)&p_ph, PV_NONE,
2248#else
2249 (char_u *)NULL, PV_NONE,
2250#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002251 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002252 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002253#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002254 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002255 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002256#else
2257 (char_u *)NULL, PV_NONE,
2258 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002259#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002260 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002261 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002262#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002263 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002264 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002265#else
2266 (char_u *)NULL, PV_NONE,
2267 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002268#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002269 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002270 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2271#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2272 (char_u *)&p_pyx, PV_NONE,
2273#else
2274 (char_u *)NULL, PV_NONE,
2275#endif
2276 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2277 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002278 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2279#ifdef FEAT_TEXTOBJ
2280 (char_u *)&p_qe, PV_QE,
2281 {(char_u *)"\\", (char_u *)0L}
2282#else
2283 (char_u *)NULL, PV_NONE,
2284 {(char_u *)NULL, (char_u *)0L}
2285#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002286 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2288 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002290 {"redraw", NULL, P_BOOL|P_VI_DEF,
2291 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002292 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002293 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2294#ifdef FEAT_RELTIME
2295 (char_u *)&p_rdt, PV_NONE,
2296#else
2297 (char_u *)NULL, PV_NONE,
2298#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002299 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002300 {"regexpengine", "re", P_NUM|P_VI_DEF,
2301 (char_u *)&p_re, PV_NONE,
2302 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002303 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2304 (char_u *)VAR_WIN, PV_RNU,
2305 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002306 {"remap", NULL, P_BOOL|P_VI_DEF,
2307 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002308 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002309 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002310#ifdef FEAT_RENDER_OPTIONS
2311 (char_u *)&p_rop, PV_NONE,
2312 {(char_u *)"", (char_u *)0L}
2313#else
2314 (char_u *)NULL, PV_NONE,
2315 {(char_u *)NULL, (char_u *)0L}
2316#endif
2317 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 {"report", NULL, P_NUM|P_VI_DEF,
2319 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002320 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2322#ifdef WIN3264
2323 (char_u *)&p_rs, PV_NONE,
2324#else
2325 (char_u *)NULL, PV_NONE,
2326#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002327 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2329#ifdef FEAT_RIGHTLEFT
2330 (char_u *)&p_ri, PV_NONE,
2331#else
2332 (char_u *)NULL, PV_NONE,
2333#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002334 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2336#ifdef FEAT_RIGHTLEFT
2337 (char_u *)VAR_WIN, PV_RL,
2338#else
2339 (char_u *)NULL, PV_NONE,
2340#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002341 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002342 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2343#ifdef FEAT_RIGHTLEFT
2344 (char_u *)VAR_WIN, PV_RLC,
2345 {(char_u *)"search", (char_u *)NULL}
2346#else
2347 (char_u *)NULL, PV_NONE,
2348 {(char_u *)NULL, (char_u *)0L}
2349#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002350 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002351 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002352#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002353 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002354 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002355#else
2356 (char_u *)NULL, PV_NONE,
2357 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002358#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002359 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002360 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2361#ifdef FEAT_CMDL_INFO
2362 (char_u *)&p_ru, PV_NONE,
2363#else
2364 (char_u *)NULL, PV_NONE,
2365#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002366 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2368#ifdef FEAT_STL_OPT
2369 (char_u *)&p_ruf, PV_NONE,
2370#else
2371 (char_u *)NULL, PV_NONE,
2372#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002373 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002374 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2375 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2378 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2380 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002381 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2383#ifdef FEAT_SCROLLBIND
2384 (char_u *)VAR_WIN, PV_SCBIND,
2385#else
2386 (char_u *)NULL, PV_NONE,
2387#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002388 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002389 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2390 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002391 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002392 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2393 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002394 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002395 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002396#ifdef FEAT_SCROLLBIND
2397 (char_u *)&p_sbo, PV_NONE,
2398 {(char_u *)"ver,jump", (char_u *)0L}
2399#else
2400 (char_u *)NULL, PV_NONE,
2401 {(char_u *)0L, (char_u *)0L}
2402#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"sections", "sect", P_STRING|P_VI_DEF,
2405 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2407 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2409 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002410 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002411 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002413 {(char_u *)"inclusive", (char_u *)0L}
2414 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002415 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002416 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002417 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002418 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419#ifdef FEAT_SESSION
2420 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002421 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002422 (char_u *)0L}
2423#else
2424 (char_u *)NULL, PV_NONE,
2425 {(char_u *)0L, (char_u *)0L}
2426#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002427 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2429 (char_u *)&p_sh, PV_NONE,
2430 {
2431#ifdef VMS
2432 (char_u *)"-",
2433#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002434# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002436# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438# endif
2439#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002440 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2442 (char_u *)&p_shcf, PV_NONE,
2443 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002444#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 (char_u *)"/c",
2446#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002449 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002450 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2451#ifdef FEAT_QUICKFIX
2452 (char_u *)&p_sp, PV_NONE,
2453 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002454#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456#else
2457 (char_u *)">",
2458#endif
2459 (char_u *)0L}
2460#else
2461 (char_u *)NULL, PV_NONE,
2462 {(char_u *)0L, (char_u *)0L}
2463#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002464 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2466 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2469 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002471 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2472#ifdef BACKSLASH_IN_FILENAME
2473 (char_u *)&p_ssl, PV_NONE,
2474#else
2475 (char_u *)NULL, PV_NONE,
2476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002478 {"shelltemp", "stmp", P_BOOL,
2479 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002480 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 {"shelltype", "st", P_NUM|P_VI_DEF,
2482#ifdef AMIGA
2483 (char_u *)&p_st, PV_NONE,
2484#else
2485 (char_u *)NULL, PV_NONE,
2486#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002487 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2489 (char_u *)&p_sxq, PV_NONE,
2490 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002491#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492 (char_u *)"\"",
2493#else
2494 (char_u *)"",
2495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002496 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002497 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2498 (char_u *)&p_sxe, PV_NONE,
2499 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002500#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002501 (char_u *)"\"&|<>()@^",
2502#else
2503 (char_u *)"",
2504#endif
2505 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2507 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002508 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2510 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002511 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2513 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 {(char_u *)"", (char_u *)"filnxtToO"}
2515 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002518 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2520#ifdef FEAT_LINEBREAK
2521 (char_u *)&p_sbr, PV_NONE,
2522#else
2523 (char_u *)NULL, PV_NONE,
2524#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002525 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002526 {"showcmd", "sc", P_BOOL|P_VIM,
2527#ifdef FEAT_CMDL_INFO
2528 (char_u *)&p_sc, PV_NONE,
2529#else
2530 (char_u *)NULL, PV_NONE,
2531#endif
2532 {(char_u *)FALSE,
2533#ifdef UNIX
2534 (char_u *)FALSE
2535#else
2536 (char_u *)TRUE
2537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002538 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2540 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002541 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2543 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 {"showmode", "smd", P_BOOL|P_VIM,
2546 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002547 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002548 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2549#ifdef FEAT_WINDOWS
2550 (char_u *)&p_stal, PV_NONE,
2551#else
2552 (char_u *)NULL, PV_NONE,
2553#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002554 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002555 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2556 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002557 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002558 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2559 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002560 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002561 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2562#ifdef FEAT_SIGNS
2563 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002564 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002565#else
2566 (char_u *)NULL, PV_NONE,
2567 {(char_u *)NULL, (char_u *)0L}
2568#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002569 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002570 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2571 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002572 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2574 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002575 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2577#ifdef FEAT_SMARTINDENT
2578 (char_u *)&p_si, PV_SI,
2579#else
2580 (char_u *)NULL, PV_NONE,
2581#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002582 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002583 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2584 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002585 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002586 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2587 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2590 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002591 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002592 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002593#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002594 (char_u *)VAR_WIN, PV_SPELL,
2595#else
2596 (char_u *)NULL, PV_NONE,
2597#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002598 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002599 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002600#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002601 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002602 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002603#else
2604 (char_u *)NULL, PV_NONE,
2605 {(char_u *)0L, (char_u *)0L}
2606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002607 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002608 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2609 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002610#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002611 (char_u *)&p_spf, PV_SPF,
2612 {(char_u *)"", (char_u *)0L}
2613#else
2614 (char_u *)NULL, PV_NONE,
2615 {(char_u *)0L, (char_u *)0L}
2616#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002617 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002618 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2619 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002620#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002621 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002622 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002623#else
2624 (char_u *)NULL, PV_NONE,
2625 {(char_u *)0L, (char_u *)0L}
2626#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002627 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002628 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002629#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002630 (char_u *)&p_sps, PV_NONE,
2631 {(char_u *)"best", (char_u *)0L}
2632#else
2633 (char_u *)NULL, PV_NONE,
2634 {(char_u *)0L, (char_u *)0L}
2635#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002636 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002637 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2638#ifdef FEAT_WINDOWS
2639 (char_u *)&p_sb, PV_NONE,
2640#else
2641 (char_u *)NULL, PV_NONE,
2642#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002643 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002645#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002646 (char_u *)&p_spr, PV_NONE,
2647#else
2648 (char_u *)NULL, PV_NONE,
2649#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2652 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002653 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2655#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002656 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657#else
2658 (char_u *)NULL, PV_NONE,
2659#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002660 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002661 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002662 (char_u *)&p_su, PV_NONE,
2663 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002664 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002665 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002666#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667 (char_u *)&p_sua, PV_SUA,
2668 {(char_u *)"", (char_u *)0L}
2669#else
2670 (char_u *)NULL, PV_NONE,
2671 {(char_u *)0L, (char_u *)0L}
2672#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002673 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002674 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2675 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002676 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002677 {"swapsync", "sws", P_STRING|P_VI_DEF,
2678 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002679 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002680 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002682 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002683 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2684#ifdef FEAT_SYN_HL
2685 (char_u *)&p_smc, PV_SMC,
2686 {(char_u *)3000L, (char_u *)0L}
2687#else
2688 (char_u *)NULL, PV_NONE,
2689 {(char_u *)0L, (char_u *)0L}
2690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002691 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002692 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693#ifdef FEAT_SYN_HL
2694 (char_u *)&p_syn, PV_SYN,
2695 {(char_u *)"", (char_u *)0L}
2696#else
2697 (char_u *)NULL, PV_NONE,
2698 {(char_u *)0L, (char_u *)0L}
2699#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002700 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002701 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2702#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002703 (char_u *)&p_tal, PV_NONE,
2704#else
2705 (char_u *)NULL, PV_NONE,
2706#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002707 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002708 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2709#ifdef FEAT_WINDOWS
2710 (char_u *)&p_tpm, PV_NONE,
2711#else
2712 (char_u *)NULL, PV_NONE,
2713#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2716 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002717 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002718 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2719 (char_u *)&p_tbs, PV_NONE,
2720#ifdef VMS /* binary searching doesn't appear to work on VMS */
2721 {(char_u *)0L, (char_u *)0L}
2722#else
2723 {(char_u *)TRUE, (char_u *)0L}
2724#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002725 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002726 {"tagcase", "tc", P_STRING|P_VIM,
2727 (char_u *)&p_tc, PV_TC,
2728 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002729 {"taglength", "tl", P_NUM|P_VI_DEF,
2730 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002731 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 {"tagrelative", "tr", P_BOOL|P_VIM,
2733 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002734 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002735 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002736 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002737 {
2738#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2739 (char_u *)"./tags,./TAGS,tags,TAGS",
2740#else
2741 (char_u *)"./tags,tags",
2742#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002743 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002744 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2745 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002746 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002747 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002748#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002749 (char_u *)&p_tcldll, PV_NONE,
2750 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002751#else
2752 (char_u *)NULL, PV_NONE,
2753 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002754#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002755 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2757 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002758 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2760#ifdef FEAT_ARABIC
2761 (char_u *)&p_tbidi, PV_NONE,
2762#else
2763 (char_u *)NULL, PV_NONE,
2764#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002765 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2767#ifdef FEAT_MBYTE
2768 (char_u *)&p_tenc, PV_NONE,
2769 {(char_u *)"", (char_u *)0L}
2770#else
2771 (char_u *)NULL, PV_NONE,
2772 {(char_u *)0L, (char_u *)0L}
2773#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002774 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002775 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2776#ifdef FEAT_TERMGUICOLORS
2777 (char_u *)&p_tgc, PV_NONE,
2778 {(char_u *)FALSE, (char_u *)FALSE}
2779#else
2780 (char_u*)NULL, PV_NONE,
2781 {(char_u *)FALSE, (char_u *)FALSE}
2782#endif
2783 SCRIPTID_INIT},
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002784 {"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2785#ifdef FEAT_TERMINAL
2786 (char_u *)VAR_WIN, PV_TMS,
2787 {(char_u *)"", (char_u *)NULL}
2788#else
2789 (char_u *)NULL, PV_NONE,
2790 {(char_u *)NULL, (char_u *)0L}
2791#endif
2792 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002793 {"terse", NULL, P_BOOL|P_VI_DEF,
2794 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002795 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002796 {"textauto", "ta", P_BOOL|P_VIM,
2797 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002798 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2799 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2801 (char_u *)&p_tx, PV_TX,
2802 {
2803#ifdef USE_CRNL
2804 (char_u *)TRUE,
2805#else
2806 (char_u *)FALSE,
2807#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002808 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002809 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002810 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002811 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002812 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002814 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815#else
2816 (char_u *)NULL, PV_NONE,
2817#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002818 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002819 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2820 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002821 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822 {"timeout", "to", P_BOOL|P_VI_DEF,
2823 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002824 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002825 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2826 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002827 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002828 {"title", NULL, P_BOOL|P_VI_DEF,
2829#ifdef FEAT_TITLE
2830 (char_u *)&p_title, PV_NONE,
2831#else
2832 (char_u *)NULL, PV_NONE,
2833#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002834 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002835 {"titlelen", NULL, P_NUM|P_VI_DEF,
2836#ifdef FEAT_TITLE
2837 (char_u *)&p_titlelen, PV_NONE,
2838#else
2839 (char_u *)NULL, PV_NONE,
2840#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002841 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002842 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002843#ifdef FEAT_TITLE
2844 (char_u *)&p_titleold, PV_NONE,
2845 {(char_u *)N_("Thanks for flying Vim"),
2846 (char_u *)0L}
2847#else
2848 (char_u *)NULL, PV_NONE,
2849 {(char_u *)0L, (char_u *)0L}
2850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002851 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002852 {"titlestring", NULL, P_STRING|P_VI_DEF,
2853#ifdef FEAT_TITLE
2854 (char_u *)&p_titlestring, PV_NONE,
2855#else
2856 (char_u *)NULL, PV_NONE,
2857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002858 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002859 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002860#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002861 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002862 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002863#else
2864 (char_u *)NULL, PV_NONE,
2865 {(char_u *)0L, (char_u *)0L}
2866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002868 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002869#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002870 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002871 {(char_u *)"small", (char_u *)0L}
2872#else
2873 (char_u *)NULL, PV_NONE,
2874 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002875#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002876 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2878 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002879 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2881 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002882 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002883 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2884 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002885 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002886 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2887 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002888 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002889 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2890#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2891 (char_u *)&p_ttym, PV_NONE,
2892#else
2893 (char_u *)NULL, PV_NONE,
2894#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002895 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002896 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2897 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002898 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2900 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002901 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002902 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2903 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002904#ifdef FEAT_PERSISTENT_UNDO
2905 (char_u *)&p_udir, PV_NONE,
2906 {(char_u *)".", (char_u *)0L}
2907#else
2908 (char_u *)NULL, PV_NONE,
2909 {(char_u *)0L, (char_u *)0L}
2910#endif
2911 SCRIPTID_INIT},
2912 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2913#ifdef FEAT_PERSISTENT_UNDO
2914 (char_u *)&p_udf, PV_UDF,
2915#else
2916 (char_u *)NULL, PV_NONE,
2917#endif
2918 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002920 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002921 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002922#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002923 (char_u *)1000L,
2924#else
2925 (char_u *)100L,
2926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002927 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002928 {"undoreload", "ur", P_NUM|P_VI_DEF,
2929 (char_u *)&p_ur, PV_NONE,
2930 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 {"updatecount", "uc", P_NUM|P_VI_DEF,
2932 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002933 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002934 {"updatetime", "ut", P_NUM|P_VI_DEF,
2935 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002936 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 {"verbose", "vbs", P_NUM|P_VI_DEF,
2938 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002939 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002940 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2941 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002942 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002943 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2944#ifdef FEAT_SESSION
2945 (char_u *)&p_vdir, PV_NONE,
2946 {(char_u *)DFLT_VDIR, (char_u *)0L}
2947#else
2948 (char_u *)NULL, PV_NONE,
2949 {(char_u *)0L, (char_u *)0L}
2950#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002951 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002952 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953#ifdef FEAT_SESSION
2954 (char_u *)&p_vop, PV_NONE,
2955 {(char_u *)"folds,options,cursor", (char_u *)0L}
2956#else
2957 (char_u *)NULL, PV_NONE,
2958 {(char_u *)0L, (char_u *)0L}
2959#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002960 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002961 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002962#ifdef FEAT_VIMINFO
2963 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002964#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002965 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002966#else
2967# ifdef AMIGA
2968 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002969 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002970# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002971 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002972# endif
2973#endif
2974#else
2975 (char_u *)NULL, PV_NONE,
2976 {(char_u *)0L, (char_u *)0L}
2977#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002978 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002979 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2980 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002981#ifdef FEAT_VIRTUALEDIT
2982 (char_u *)&p_ve, PV_NONE,
2983 {(char_u *)"", (char_u *)""}
2984#else
2985 (char_u *)NULL, PV_NONE,
2986 {(char_u *)0L, (char_u *)0L}
2987#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002988 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2990 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002991 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 {"w300", NULL, P_NUM|P_VI_DEF,
2993 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002994 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002995 {"w1200", NULL, P_NUM|P_VI_DEF,
2996 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002997 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002998 {"w9600", NULL, P_NUM|P_VI_DEF,
2999 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003000 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003001 {"warn", NULL, P_BOOL|P_VI_DEF,
3002 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003003 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003004 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
3005 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003006 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003007 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003009 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003010 {"wildchar", "wc", P_NUM|P_VIM,
3011 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003012 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3013 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003014 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003015 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003016 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003017 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018#ifdef FEAT_WILDIGN
3019 (char_u *)&p_wig, PV_NONE,
3020#else
3021 (char_u *)NULL, PV_NONE,
3022#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003023 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003024 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3025 (char_u *)&p_wic, PV_NONE,
3026 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003027 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3028#ifdef FEAT_WILDMENU
3029 (char_u *)&p_wmnu, PV_NONE,
3030#else
3031 (char_u *)NULL, PV_NONE,
3032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003033 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003034 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003035 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003036 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003037 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3038#ifdef FEAT_CMDL_COMPL
3039 (char_u *)&p_wop, PV_NONE,
3040 {(char_u *)"", (char_u *)0L}
3041#else
3042 (char_u *)NULL, PV_NONE,
3043 {(char_u *)NULL, (char_u *)0L}
3044#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003045 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3047#ifdef FEAT_WAK
3048 (char_u *)&p_wak, PV_NONE,
3049 {(char_u *)"menu", (char_u *)0L}
3050#else
3051 (char_u *)NULL, PV_NONE,
3052 {(char_u *)NULL, (char_u *)0L}
3053#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003054 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003055 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003056 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003057 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003058 {"winheight", "wh", P_NUM|P_VI_DEF,
3059#ifdef FEAT_WINDOWS
3060 (char_u *)&p_wh, PV_NONE,
3061#else
3062 (char_u *)NULL, PV_NONE,
3063#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003064 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003065 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003066#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003067 (char_u *)VAR_WIN, PV_WFH,
3068#else
3069 (char_u *)NULL, PV_NONE,
3070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003071 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003072 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003073#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003074 (char_u *)VAR_WIN, PV_WFW,
3075#else
3076 (char_u *)NULL, PV_NONE,
3077#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003078 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003079 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3080#ifdef FEAT_WINDOWS
3081 (char_u *)&p_wmh, PV_NONE,
3082#else
3083 (char_u *)NULL, PV_NONE,
3084#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003085 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003086 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003087#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003088 (char_u *)&p_wmw, PV_NONE,
3089#else
3090 (char_u *)NULL, PV_NONE,
3091#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003092 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003093 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003094#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095 (char_u *)&p_wiw, PV_NONE,
3096#else
3097 (char_u *)NULL, PV_NONE,
3098#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003099 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003100 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3101 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003102 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3104 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003105 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003106 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3107 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003108 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003109 {"write", NULL, P_BOOL|P_VI_DEF,
3110 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003111 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003112 {"writeany", "wa", P_BOOL|P_VI_DEF,
3113 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003114 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3116 (char_u *)&p_wb, PV_NONE,
3117 {
3118#ifdef FEAT_WRITEBACKUP
3119 (char_u *)TRUE,
3120#else
3121 (char_u *)FALSE,
3122#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003123 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003124 {"writedelay", "wd", P_NUM|P_VI_DEF,
3125 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003126 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003127
3128/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003129#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003131 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003132
3133 p_term("t_AB", T_CAB)
3134 p_term("t_AF", T_CAF)
3135 p_term("t_AL", T_CAL)
3136 p_term("t_al", T_AL)
3137 p_term("t_bc", T_BC)
3138 p_term("t_cd", T_CD)
3139 p_term("t_ce", T_CE)
3140 p_term("t_cl", T_CL)
3141 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003142 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003143 p_term("t_Co", T_CCO)
3144 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003145 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003146 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003147#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148 p_term("t_CV", T_CSV)
3149#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003150 p_term("t_da", T_DA)
3151 p_term("t_db", T_DB)
3152 p_term("t_DL", T_CDL)
3153 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02003154 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003155 p_term("t_fs", T_FS)
3156 p_term("t_IE", T_CIE)
3157 p_term("t_IS", T_CIS)
3158 p_term("t_ke", T_KE)
3159 p_term("t_ks", T_KS)
3160 p_term("t_le", T_LE)
3161 p_term("t_mb", T_MB)
3162 p_term("t_md", T_MD)
3163 p_term("t_me", T_ME)
3164 p_term("t_mr", T_MR)
3165 p_term("t_ms", T_MS)
3166 p_term("t_nd", T_ND)
3167 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003168 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003169 p_term("t_RI", T_CRI)
3170 p_term("t_RV", T_CRV)
3171 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003173 p_term("t_Sf", T_CSF)
3174 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003175 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003176 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003177 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178 p_term("t_te", T_TE)
3179 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003180 p_term("t_ts", T_TS)
3181 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003182 p_term("t_ue", T_UE)
3183 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003184 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003185 p_term("t_vb", T_VB)
3186 p_term("t_ve", T_VE)
3187 p_term("t_vi", T_VI)
3188 p_term("t_vs", T_VS)
3189 p_term("t_WP", T_CWP)
Bram Moolenaar9f928862017-04-11 22:44:05 +02003190 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003191 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003192 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003193 p_term("t_xs", T_XS)
3194 p_term("t_ZH", T_CZH)
3195 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003196 p_term("t_8f", T_8F)
3197 p_term("t_8b", T_8B)
Bram Moolenaarec2da362017-01-21 20:04:22 +01003198 p_term("t_BE", T_BE)
3199 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200
3201/* terminal key codes are not in here */
3202
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003203 /* end marker */
3204 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205};
3206
3207#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3208
3209#ifdef FEAT_MBYTE
3210static char *(p_ambw_values[]) = {"single", "double", NULL};
3211#endif
3212static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003213static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003214static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003215#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003216static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003217#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003218#ifdef FEAT_CMDL_COMPL
3219static char *(p_wop_values[]) = {"tagfile", NULL};
3220#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003221#ifdef FEAT_WAK
3222static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3223#endif
3224static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003225static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3226static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003227static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003228#ifdef FEAT_BROWSE
3229static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3230#endif
3231#ifdef FEAT_SCROLLBIND
3232static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3233#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003234static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003235#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003236static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3237#endif
3238#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003239# ifdef FEAT_AUTOCMD
3240static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3241# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003242static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003243# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3245#endif
3246static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3247#ifdef FEAT_FOLDING
3248static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003249# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003250 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003251# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003252 NULL};
3253static char *(p_fcl_values[]) = {"all", NULL};
3254#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003255#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003256static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003257#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003258#ifdef FEAT_SIGNS
3259static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3260#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003261
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003262static void set_option_default(int, int opt_flags, int compatible);
3263static void set_options_default(int opt_flags);
3264static char_u *term_bg_default(void);
3265static void did_set_option(int opt_idx, int opt_flags, int new_value);
3266static char_u *illegal_char(char_u *, int);
3267static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003268#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003269static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003270#endif
3271#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003272static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003273#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003274static char_u *option_expand(int opt_idx, char_u *val);
3275static void didset_options(void);
3276static void didset_options2(void);
3277static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003278#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003279static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003280#else
3281# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3282#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003283static void set_string_option_global(int opt_idx, char_u **varp);
3284static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3285static 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);
3286static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003287#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003288static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003289#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003290#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003291static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003292#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003293#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003294static char_u *did_set_spell_option(int is_spellfile);
3295static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003296#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003297#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003298static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003299#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003300static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3301static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3302static void check_redraw(long_u flags);
3303static int findoption(char_u *);
3304static int find_key_option(char_u *);
3305static void showoptions(int all, int opt_flags);
3306static int optval_default(struct vimoption *, char_u *varp);
3307static void showoneopt(struct vimoption *, int opt_flags);
3308static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3309static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3310static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3311static int istermoption(struct vimoption *);
3312static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3313static char_u *get_varp(struct vimoption *);
3314static void option_value2string(struct vimoption *, int opt_flags);
3315static void check_winopt(winopt_T *wop);
3316static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003317#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003318static void langmap_init(void);
3319static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003320#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003321static void paste_option_changed(void);
3322static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003323#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003324static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003325#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003326static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3327static int check_opt_strings(char_u *val, char **values, int);
3328static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003329#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003330static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003331#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332
3333/*
3334 * Initialize the options, first part.
3335 *
3336 * Called only once from main(), just after creating the first buffer.
3337 */
3338 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003339set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003340{
3341 char_u *p;
3342 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003343 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344
3345#ifdef FEAT_LANGMAP
3346 langmap_init();
3347#endif
3348
3349 /* Be Vi compatible by default */
3350 p_cp = TRUE;
3351
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003352 /* Use POSIX compatibility when $VIM_POSIX is set. */
3353 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003354 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003355 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003356 set_string_default("shm", (char_u *)"A");
3357 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003358
Bram Moolenaar071d4272004-06-13 20:20:40 +00003359 /*
3360 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003361 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003362 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003363 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003364#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003365 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003366# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003367 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003368# endif
3369#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003370 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003371 set_string_default("sh", p);
3372
3373#ifdef FEAT_WILDIGN
3374 /*
3375 * Set the default for 'backupskip' to include environment variables for
3376 * temp files.
3377 */
3378 {
3379# ifdef UNIX
3380 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3381# else
3382 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3383# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003384 int len;
3385 garray_T ga;
3386 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003387
3388 ga_init2(&ga, 1, 100);
3389 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3390 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003391 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003392# ifdef UNIX
3393 if (*names[n] == NUL)
3394 p = (char_u *)"/tmp";
3395 else
3396# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003397 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003398 if (p != NULL && *p != NUL)
3399 {
3400 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003401 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003402 if (ga_grow(&ga, len) == OK)
3403 {
3404 if (ga.ga_len > 0)
3405 STRCAT(ga.ga_data, ",");
3406 STRCAT(ga.ga_data, p);
3407 add_pathsep(ga.ga_data);
3408 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003409 ga.ga_len += len;
3410 }
3411 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003412 if (mustfree)
3413 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003414 }
3415 if (ga.ga_data != NULL)
3416 {
3417 set_string_default("bsk", ga.ga_data);
3418 vim_free(ga.ga_data);
3419 }
3420 }
3421#endif
3422
3423 /*
3424 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3425 */
3426 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003427 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003429#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3430 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3431#endif
3432 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003433#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003434 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003435 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003436#else
3437# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003438 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003439 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003441 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003442# endif
3443#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003444 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003445 opt_idx = findoption((char_u *)"maxmem");
3446 if (opt_idx >= 0)
3447 {
3448#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003449 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3450 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003451#endif
3452 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3453 }
3454 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455 }
3456
Bram Moolenaar071d4272004-06-13 20:20:40 +00003457#ifdef FEAT_SEARCHPATH
3458 {
3459 char_u *cdpath;
3460 char_u *buf;
3461 int i;
3462 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003463 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003464
3465 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003466 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467 if (cdpath != NULL)
3468 {
3469 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3470 if (buf != NULL)
3471 {
3472 buf[0] = ','; /* start with ",", current dir first */
3473 j = 1;
3474 for (i = 0; cdpath[i] != NUL; ++i)
3475 {
3476 if (vim_ispathlistsep(cdpath[i]))
3477 buf[j++] = ',';
3478 else
3479 {
3480 if (cdpath[i] == ' ' || cdpath[i] == ',')
3481 buf[j++] = '\\';
3482 buf[j++] = cdpath[i];
3483 }
3484 }
3485 buf[j] = NUL;
3486 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003487 if (opt_idx >= 0)
3488 {
3489 options[opt_idx].def_val[VI_DEFAULT] = buf;
3490 options[opt_idx].flags |= P_DEF_ALLOCED;
3491 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003492 else
3493 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003495 if (mustfree)
3496 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003497 }
3498 }
3499#endif
3500
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003501#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003502 /* Set print encoding on platforms that don't default to latin1 */
3503 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003504# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003505 (char_u *)"cp1252"
3506# else
3507# ifdef VMS
3508 (char_u *)"dec-mcs"
3509# else
3510# ifdef EBCDIC
3511 (char_u *)"ebcdic-uk"
3512# else
3513# ifdef MAC
3514 (char_u *)"mac-roman"
3515# else /* HPUX */
3516 (char_u *)"hp-roman8"
3517# endif
3518# endif
3519# endif
3520# endif
3521 );
3522#endif
3523
3524#ifdef FEAT_POSTSCRIPT
3525 /* 'printexpr' must be allocated to be able to evaluate it. */
3526 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003527# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003528 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003529# else
3530# ifdef VMS
3531 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3532
3533# else
3534 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3535# endif
3536# endif
3537 );
3538#endif
3539
3540 /*
3541 * Set all the options (except the terminal options) to their default
3542 * value. Also set the global value for local options.
3543 */
3544 set_options_default(0);
3545
3546#ifdef FEAT_GUI
3547 if (found_reverse_arg)
3548 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3549#endif
3550
3551 curbuf->b_p_initialized = TRUE;
3552 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003553 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003554 check_buf_options(curbuf);
3555 check_win_options(curwin);
3556 check_options();
3557
3558 /* Must be before option_expand(), because that one needs vim_isIDc() */
3559 didset_options();
3560
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003561#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003562 /* Use the current chartab for the generic chartab. This is not in
3563 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003564 init_spell_chartab();
3565#endif
3566
Bram Moolenaar071d4272004-06-13 20:20:40 +00003567 /*
3568 * Expand environment variables and things like "~" for the defaults.
3569 * If option_expand() returns non-NULL the variable is expanded. This can
3570 * only happen for non-indirect options.
3571 * Also set the default to the expanded value, so ":set" does not list
3572 * them.
3573 * Don't set the P_ALLOCED flag, because we don't want to free the
3574 * default.
3575 */
3576 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3577 {
3578 if ((options[opt_idx].flags & P_GETTEXT)
3579 && options[opt_idx].var != NULL)
3580 p = (char_u *)_(*(char **)options[opt_idx].var);
3581 else
3582 p = option_expand(opt_idx, NULL);
3583 if (p != NULL && (p = vim_strsave(p)) != NULL)
3584 {
3585 *(char_u **)options[opt_idx].var = p;
3586 /* VIMEXP
3587 * Defaults for all expanded options are currently the same for Vi
3588 * and Vim. When this changes, add some code here! Also need to
3589 * split P_DEF_ALLOCED in two.
3590 */
3591 if (options[opt_idx].flags & P_DEF_ALLOCED)
3592 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3593 options[opt_idx].def_val[VI_DEFAULT] = p;
3594 options[opt_idx].flags |= P_DEF_ALLOCED;
3595 }
3596 }
3597
Bram Moolenaar071d4272004-06-13 20:20:40 +00003598 save_file_ff(curbuf); /* Buffer is unchanged */
3599
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600#if defined(FEAT_ARABIC)
3601 /* Detect use of mlterm.
3602 * Mlterm is a terminal emulator akin to xterm that has some special
3603 * abilities (bidi namely).
3604 * NOTE: mlterm's author is being asked to 'set' a variable
3605 * instead of an environment variable due to inheritance.
3606 */
3607 if (mch_getenv((char_u *)"MLTERM") != NULL)
3608 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3609#endif
3610
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003611 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003612
3613#ifdef FEAT_MBYTE
3614# if defined(WIN3264) && defined(FEAT_GETTEXT)
3615 /*
3616 * If $LANG isn't set, try to get a good value for it. This makes the
3617 * right language be used automatically. Don't do this for English.
3618 */
3619 if (mch_getenv((char_u *)"LANG") == NULL)
3620 {
3621 char buf[20];
3622
3623 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3624 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3625 * only the first two. */
3626 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3627 (LPTSTR)buf, 20);
3628 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3629 {
3630 /* There are a few exceptions (probably more) */
3631 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3632 STRCPY(buf, "zh_TW");
3633 else if (STRNICMP(buf, "chs", 3) == 0
3634 || STRNICMP(buf, "zhc", 3) == 0)
3635 STRCPY(buf, "zh_CN");
3636 else if (STRNICMP(buf, "jp", 2) == 0)
3637 STRCPY(buf, "ja");
3638 else
3639 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003640 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003641 }
3642 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003643# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003644# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003645 /* Moved to os_mac_conv.c to avoid dependency problems. */
3646 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003647# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003648# endif
3649
3650 /* enc_locale() will try to find the encoding of the current locale. */
3651 p = enc_locale();
3652 if (p != NULL)
3653 {
3654 char_u *save_enc;
3655
3656 /* Try setting 'encoding' and check if the value is valid.
3657 * If not, go back to the default "latin1". */
3658 save_enc = p_enc;
3659 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003660 if (STRCMP(p_enc, "gb18030") == 0)
3661 {
3662 /* We don't support "gb18030", but "cp936" is a good substitute
3663 * for practical purposes, thus use that. It's not an alias to
3664 * still support conversion between gb18030 and utf-8. */
3665 p_enc = vim_strsave((char_u *)"cp936");
3666 vim_free(p);
3667 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668 if (mb_init() == NULL)
3669 {
3670 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003671 if (opt_idx >= 0)
3672 {
3673 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3674 options[opt_idx].flags |= P_DEF_ALLOCED;
3675 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003676
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003677#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003678 if (STRCMP(p_enc, "latin1") == 0
3679# ifdef FEAT_MBYTE
3680 || enc_utf8
3681# endif
3682 )
3683 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003684 /* Adjust the default for 'isprint' and 'iskeyword' to match
3685 * latin1. Also set the defaults for when 'nocompatible' is
3686 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003687 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003688 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003689 set_string_option_direct((char_u *)"isk", -1,
3690 ISK_LATIN1, OPT_FREE, SID_NONE);
3691 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003692 if (opt_idx >= 0)
3693 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003694 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003695 if (opt_idx >= 0)
3696 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003697 (void)init_chartab();
3698 }
3699#endif
3700
Bram Moolenaar071d4272004-06-13 20:20:40 +00003701# if defined(WIN3264) && !defined(FEAT_GUI)
3702 /* Win32 console: When GetACP() returns a different value from
3703 * GetConsoleCP() set 'termencoding'. */
3704 if (GetACP() != GetConsoleCP())
3705 {
3706 char buf[50];
3707
3708 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3709 p_tenc = vim_strsave((char_u *)buf);
3710 if (p_tenc != NULL)
3711 {
3712 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003713 if (opt_idx >= 0)
3714 {
3715 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3716 options[opt_idx].flags |= P_DEF_ALLOCED;
3717 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003718 convert_setup(&input_conv, p_tenc, p_enc);
3719 convert_setup(&output_conv, p_enc, p_tenc);
3720 }
3721 else
3722 p_tenc = empty_option;
3723 }
3724# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003725# if defined(WIN3264) && defined(FEAT_MBYTE)
3726 /* $HOME may have characters in active code page. */
3727 init_homedir();
3728# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003729 }
3730 else
3731 {
3732 vim_free(p_enc);
3733 p_enc = save_enc;
3734 }
3735 }
3736#endif
3737
3738#ifdef FEAT_MULTI_LANG
3739 /* Set the default for 'helplang'. */
3740 set_helplang_default(get_mess_lang());
3741#endif
3742}
3743
3744/*
3745 * Set an option to its default value.
3746 * This does not take care of side effects!
3747 */
3748 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003749set_option_default(
3750 int opt_idx,
3751 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3752 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003753{
3754 char_u *varp; /* pointer to variable for current option */
3755 int dvi; /* index in def_val[] */
3756 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003757 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003758 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3759
3760 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3761 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003762 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003763 {
3764 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3765 if (flags & P_STRING)
3766 {
3767 /* Use set_string_option_direct() for local options to handle
3768 * freeing and allocating the value. */
3769 if (options[opt_idx].indir != PV_NONE)
3770 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003771 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003772 else
3773 {
3774 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3775 free_string_option(*(char_u **)(varp));
3776 *(char_u **)varp = options[opt_idx].def_val[dvi];
3777 options[opt_idx].flags &= ~P_ALLOCED;
3778 }
3779 }
3780 else if (flags & P_NUM)
3781 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003782 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003783 win_comp_scroll(curwin);
3784 else
3785 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003786 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003787 /* May also set global value for local option. */
3788 if (both)
3789 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3790 *(long *)varp;
3791 }
3792 }
3793 else /* P_BOOL */
3794 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003795 /* the cast to long is required for Manx C, long_i is needed for
3796 * MSVC */
3797 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003798#ifdef UNIX
3799 /* 'modeline' defaults to off for root */
3800 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3801 *(int *)varp = FALSE;
3802#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003803 /* May also set global value for local option. */
3804 if (both)
3805 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3806 *(int *)varp;
3807 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003808
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003809 /* The default value is not insecure. */
3810 flagsp = insecure_flag(opt_idx, opt_flags);
3811 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003812 }
3813
3814#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003815 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003816#endif
3817}
3818
3819/*
3820 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003821 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003822 */
3823 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003824set_options_default(
3825 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003826{
3827 int i;
3828#ifdef FEAT_WINDOWS
3829 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003830 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003831#endif
3832
3833 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003834 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003835#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003836 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003837 || (TRUE
3838# if defined(FEAT_MBYTE)
3839 && options[i].var != (char_u *)&p_enc
3840# endif
3841# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003842 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003843 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003844# endif
3845 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003846#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003847 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003848 set_option_default(i, opt_flags, p_cp);
3849
3850#ifdef FEAT_WINDOWS
3851 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003852 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003853 win_comp_scroll(wp);
3854#else
3855 win_comp_scroll(curwin);
3856#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003857#ifdef FEAT_CINDENT
3858 parse_cino(curbuf);
3859#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860}
3861
3862/*
3863 * Set the Vi-default value of a string option.
3864 * Used for 'sh', 'backupskip' and 'term'.
3865 */
3866 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003867set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003868{
3869 char_u *p;
3870 int opt_idx;
3871
3872 p = vim_strsave(val);
3873 if (p != NULL) /* we don't want a NULL */
3874 {
3875 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003876 if (opt_idx >= 0)
3877 {
3878 if (options[opt_idx].flags & P_DEF_ALLOCED)
3879 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3880 options[opt_idx].def_val[VI_DEFAULT] = p;
3881 options[opt_idx].flags |= P_DEF_ALLOCED;
3882 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003883 }
3884}
3885
3886/*
3887 * Set the Vi-default value of a number option.
3888 * Used for 'lines' and 'columns'.
3889 */
3890 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003891set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003892{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003893 int opt_idx;
3894
3895 opt_idx = findoption((char_u *)name);
3896 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003897 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003898}
3899
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003900#if defined(EXITFREE) || defined(PROTO)
3901/*
3902 * Free all options.
3903 */
3904 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003905free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003906{
3907 int i;
3908
3909 for (i = 0; !istermoption(&options[i]); i++)
3910 {
3911 if (options[i].indir == PV_NONE)
3912 {
3913 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003914 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003915 free_string_option(*(char_u **)options[i].var);
3916 if (options[i].flags & P_DEF_ALLOCED)
3917 free_string_option(options[i].def_val[VI_DEFAULT]);
3918 }
3919 else if (options[i].var != VAR_WIN
3920 && (options[i].flags & P_STRING))
3921 /* buffer-local option: free global value */
3922 free_string_option(*(char_u **)options[i].var);
3923 }
3924}
3925#endif
3926
3927
Bram Moolenaar071d4272004-06-13 20:20:40 +00003928/*
3929 * Initialize the options, part two: After getting Rows and Columns and
3930 * setting 'term'.
3931 */
3932 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003933set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003934{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003935 int idx;
3936
Bram Moolenaar071d4272004-06-13 20:20:40 +00003937 /*
3938 * 'scroll' defaults to half the window height. Note that this default is
3939 * wrong when the window height changes.
3940 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003941 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003942 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003943 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003944 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003945 comp_col();
3946
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003947 /*
3948 * 'window' is only for backwards compatibility with Vi.
3949 * Default is Rows - 1.
3950 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003951 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003952 p_window = Rows - 1;
3953 set_number_default("window", Rows - 1);
3954
Bram Moolenaarf740b292006-02-16 22:11:02 +00003955 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003956#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003957 /*
3958 * If 'background' wasn't set by the user, try guessing the value,
3959 * depending on the terminal name. Only need to check for terminals
3960 * with a dark background, that can handle color.
3961 */
3962 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003963 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3964 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003965 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003966 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003967 /* don't mark it as set, when starting the GUI it may be
3968 * changed again */
3969 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003970 }
3971#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003972
3973#ifdef CURSOR_SHAPE
3974 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3975#endif
3976#ifdef FEAT_MOUSESHAPE
3977 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3978#endif
3979#ifdef FEAT_PRINTER
3980 (void)parse_printoptions(); /* parse 'printoptions' default value */
3981#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003982}
3983
3984/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003985 * Return "dark" or "light" depending on the kind of terminal.
3986 * This is just guessing! Recognized are:
3987 * "linux" Linux console
3988 * "screen.linux" Linux console with screen
3989 * "cygwin" Cygwin shell
3990 * "putty" Putty program
3991 * We also check the COLORFGBG environment variable, which is set by
3992 * rxvt and derivatives. This variable contains either two or three
3993 * values separated by semicolons; we want the last value in either
3994 * case. If this value is 0-6 or 8, our background is dark.
3995 */
3996 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003997term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003998{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003999#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004000 /* DOS console nearly always black */
4001 return (char_u *)"dark";
4002#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004003 char_u *p;
4004
Bram Moolenaarf740b292006-02-16 22:11:02 +00004005 if (STRCMP(T_NAME, "linux") == 0
4006 || STRCMP(T_NAME, "screen.linux") == 0
4007 || STRCMP(T_NAME, "cygwin") == 0
4008 || STRCMP(T_NAME, "putty") == 0
4009 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4010 && (p = vim_strrchr(p, ';')) != NULL
4011 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4012 && p[2] == NUL))
4013 return (char_u *)"dark";
4014 return (char_u *)"light";
4015#endif
4016}
4017
4018/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004019 * Initialize the options, part three: After reading the .vimrc
4020 */
4021 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004022set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004023{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004024#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004025/*
4026 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4027 * This is done after other initializations, where 'shell' might have been
4028 * set, but only if they have not been set before.
4029 */
4030 char_u *p;
4031 int idx_srr;
4032 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004033# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004034 int idx_sp;
4035 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004036# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004037
4038 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004039 if (idx_srr < 0)
4040 do_srr = FALSE;
4041 else
4042 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004043# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004044 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004045 if (idx_sp < 0)
4046 do_sp = FALSE;
4047 else
4048 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004049# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004050 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004051 if (p != NULL)
4052 {
4053 /*
4054 * Default for p_sp is "| tee", for p_srr is ">".
4055 * For known shells it is changed here to include stderr.
4056 */
4057 if ( fnamecmp(p, "csh") == 0
4058 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004059# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004060 || fnamecmp(p, "csh.exe") == 0
4061 || fnamecmp(p, "tcsh.exe") == 0
4062# endif
4063 )
4064 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004065# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066 if (do_sp)
4067 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004068# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004069 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004070# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004072# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004073 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4074 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004075# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004076 if (do_srr)
4077 {
4078 p_srr = (char_u *)">&";
4079 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4080 }
4081 }
4082 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004083 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004084 if ( fnamecmp(p, "sh") == 0
4085 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004086 || fnamecmp(p, "mksh") == 0
4087 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004089 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004090 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004091 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004092# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004093 || fnamecmp(p, "cmd") == 0
4094 || fnamecmp(p, "sh.exe") == 0
4095 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004096 || fnamecmp(p, "mksh.exe") == 0
4097 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004099 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100 || fnamecmp(p, "bash.exe") == 0
4101 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004103 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004104 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004105# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004106 if (do_sp)
4107 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004108# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004109 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004110# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004111 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004112# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004113 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4114 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004115# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004116 if (do_srr)
4117 {
4118 p_srr = (char_u *)">%s 2>&1";
4119 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4120 }
4121 }
4122 vim_free(p);
4123 }
4124#endif
4125
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004126#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004128 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4129 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004130 * This is done after other initializations, where 'shell' might have been
4131 * set, but only if they have not been set before. Default for p_shcf is
4132 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004133 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004135 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136 {
4137 int idx3;
4138
4139 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004140 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141 {
4142 p_shcf = (char_u *)"-c";
4143 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4144 }
4145
Bram Moolenaar071d4272004-06-13 20:20:40 +00004146 /* Somehow Win32 requires the quotes around the redirection too */
4147 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004148 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004149 {
4150 p_sxq = (char_u *)"\"";
4151 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4152 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004153 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004154 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4155 {
4156 int idx3;
4157
4158 /*
4159 * cmd.exe on Windows will strip the first and last double quote given
4160 * on the command line, e.g. most of the time things like:
4161 * cmd /c "my path/to/echo" "my args to echo"
4162 * become:
4163 * my path/to/echo" "my args to echo
4164 * when executed.
4165 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004166 * To avoid this, set shellxquote to surround the command in
4167 * parenthesis. This appears to make most commands work, without
4168 * breaking commands that worked previously, such as
4169 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004170 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004171 idx3 = findoption((char_u *)"sxq");
4172 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4173 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004174 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004175 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4176 }
4177
Bram Moolenaara64ba222012-02-12 23:23:31 +01004178 idx3 = findoption((char_u *)"shcf");
4179 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4180 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004181 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004182 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4183 }
4184 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004185#endif
4186
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004187 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004188 {
4189 int idx_ffs = findoption((char_u *)"ffs");
4190
4191 /* Apply the first entry of 'fileformats' to the initial buffer. */
4192 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4193 set_fileformat(default_fileformat(), OPT_LOCAL);
4194 }
4195
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196#ifdef FEAT_TITLE
4197 set_title_defaults();
4198#endif
4199}
4200
4201#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4202/*
4203 * When 'helplang' is still at its default value, set it to "lang".
4204 * Only the first two characters of "lang" are used.
4205 */
4206 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004207set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004208{
4209 int idx;
4210
4211 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4212 return;
4213 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004214 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004215 {
4216 if (options[idx].flags & P_ALLOCED)
4217 free_string_option(p_hlg);
4218 p_hlg = vim_strsave(lang);
4219 if (p_hlg == NULL)
4220 p_hlg = empty_option;
4221 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004222 {
4223 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4224 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4225 {
4226 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4227 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4228 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004229 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004230 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004231 options[idx].flags |= P_ALLOCED;
4232 }
4233}
4234#endif
4235
4236#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004237static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004238
4239 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004240gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004241{
4242 if (gui_get_lightness(gui.back_pixel) < 127)
4243 return (char_u *)"dark";
4244 return (char_u *)"light";
4245}
4246
4247/*
4248 * Option initializations that can only be done after opening the GUI window.
4249 */
4250 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004251init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004252{
4253 /* Set the 'background' option according to the lightness of the
4254 * background color, unless the user has set it already. */
4255 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4256 {
4257 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4258 highlight_changed();
4259 }
4260}
4261#endif
4262
4263#ifdef FEAT_TITLE
4264/*
4265 * 'title' and 'icon' only default to true if they have not been set or reset
4266 * in .vimrc and we can read the old value.
4267 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4268 * they can be reset. This reduces startup time when using X on a remote
4269 * machine.
4270 */
4271 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004272set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004273{
4274 int idx1;
4275 long val;
4276
4277 /*
4278 * If GUI is (going to be) used, we can always set the window title and
4279 * icon name. Saves a bit of time, because the X11 display server does
4280 * not need to be contacted.
4281 */
4282 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004283 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004284 {
4285#ifdef FEAT_GUI
4286 if (gui.starting || gui.in_use)
4287 val = TRUE;
4288 else
4289#endif
4290 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004291 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004292 p_title = val;
4293 }
4294 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004295 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004296 {
4297#ifdef FEAT_GUI
4298 if (gui.starting || gui.in_use)
4299 val = TRUE;
4300 else
4301#endif
4302 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004303 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004304 p_icon = val;
4305 }
4306}
4307#endif
4308
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004309#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4310 static void
4311trigger_optionsset_string(
4312 int opt_idx,
4313 int opt_flags,
4314 char_u *oldval,
4315 char_u *newval)
4316{
4317 if (oldval != NULL && newval != NULL)
4318 {
4319 char_u buf_type[7];
4320
4321 sprintf((char *)buf_type, "%s",
4322 (opt_flags & OPT_LOCAL) ? "local" : "global");
4323 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4324 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4325 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4326 apply_autocmds(EVENT_OPTIONSET,
4327 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4328 reset_v_option_vars();
4329 }
4330 vim_free(oldval);
4331 vim_free(newval);
4332}
4333#endif
4334
Bram Moolenaar071d4272004-06-13 20:20:40 +00004335/*
4336 * Parse 'arg' for option settings.
4337 *
4338 * 'arg' may be IObuff, but only when no errors can be present and option
4339 * does not need to be expanded with option_expand().
4340 * "opt_flags":
4341 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004342 * OPT_GLOBAL for ":setglobal"
4343 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004344 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004345 * OPT_WINONLY to only set window-local options
4346 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004347 *
4348 * returns FAIL if an error is detected, OK otherwise
4349 */
4350 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004351do_set(
4352 char_u *arg, /* option string (may be written to!) */
4353 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004354{
4355 int opt_idx;
4356 char_u *errmsg;
4357 char_u errbuf[80];
4358 char_u *startarg;
4359 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4360 int nextchar; /* next non-white char after option name */
4361 int afterchar; /* character just after option name */
4362 int len;
4363 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004364 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004365 int key;
4366 long_u flags; /* flags for current option */
4367 char_u *varp = NULL; /* pointer to variable for current option */
4368 int did_show = FALSE; /* already showed one value */
4369 int adding; /* "opt+=arg" */
4370 int prepending; /* "opt^=arg" */
4371 int removing; /* "opt-=arg" */
4372 int cp_val = 0;
4373 char_u key_name[2];
4374
4375 if (*arg == NUL)
4376 {
4377 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004378 did_show = TRUE;
4379 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004380 }
4381
4382 while (*arg != NUL) /* loop to process all options */
4383 {
4384 errmsg = NULL;
4385 startarg = arg; /* remember for error message */
4386
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004387 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4388 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004389 {
4390 /*
4391 * ":set all" show all options.
4392 * ":set all&" set all options to their default value.
4393 */
4394 arg += 3;
4395 if (*arg == '&')
4396 {
4397 ++arg;
4398 /* Only for :set command set global value of local options. */
4399 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004400 didset_options();
4401 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004402 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004403 }
4404 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004405 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004406 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004407 did_show = TRUE;
4408 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004409 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004410 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004411 {
4412 showoptions(2, opt_flags);
4413 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004414 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004415 arg += 7;
4416 }
4417 else
4418 {
4419 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004420 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004421 {
4422 prefix = 0;
4423 arg += 2;
4424 }
4425 else if (STRNCMP(arg, "inv", 3) == 0)
4426 {
4427 prefix = 2;
4428 arg += 3;
4429 }
4430
4431 /* find end of name */
4432 key = 0;
4433 if (*arg == '<')
4434 {
4435 nextchar = 0;
4436 opt_idx = -1;
4437 /* look out for <t_>;> */
4438 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4439 len = 5;
4440 else
4441 {
4442 len = 1;
4443 while (arg[len] != NUL && arg[len] != '>')
4444 ++len;
4445 }
4446 if (arg[len] != '>')
4447 {
4448 errmsg = e_invarg;
4449 goto skip;
4450 }
4451 arg[len] = NUL; /* put NUL after name */
4452 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4453 opt_idx = findoption(arg + 1);
4454 arg[len++] = '>'; /* restore '>' */
4455 if (opt_idx == -1)
4456 key = find_key_option(arg + 1);
4457 }
4458 else
4459 {
4460 len = 0;
4461 /*
4462 * The two characters after "t_" may not be alphanumeric.
4463 */
4464 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4465 len = 4;
4466 else
4467 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4468 ++len;
4469 nextchar = arg[len];
4470 arg[len] = NUL; /* put NUL after name */
4471 opt_idx = findoption(arg);
4472 arg[len] = nextchar; /* restore nextchar */
4473 if (opt_idx == -1)
4474 key = find_key_option(arg);
4475 }
4476
4477 /* remember character after option name */
4478 afterchar = arg[len];
4479
4480 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004481 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004482 ++len;
4483
4484 adding = FALSE;
4485 prepending = FALSE;
4486 removing = FALSE;
4487 if (arg[len] != NUL && arg[len + 1] == '=')
4488 {
4489 if (arg[len] == '+')
4490 {
4491 adding = TRUE; /* "+=" */
4492 ++len;
4493 }
4494 else if (arg[len] == '^')
4495 {
4496 prepending = TRUE; /* "^=" */
4497 ++len;
4498 }
4499 else if (arg[len] == '-')
4500 {
4501 removing = TRUE; /* "-=" */
4502 ++len;
4503 }
4504 }
4505 nextchar = arg[len];
4506
4507 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4508 {
4509 errmsg = (char_u *)N_("E518: Unknown option");
4510 goto skip;
4511 }
4512
4513 if (opt_idx >= 0)
4514 {
4515 if (options[opt_idx].var == NULL) /* hidden option: skip */
4516 {
4517 /* Only give an error message when requesting the value of
4518 * a hidden option, ignore setting it. */
4519 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4520 && (!(options[opt_idx].flags & P_BOOL)
4521 || nextchar == '?'))
4522 errmsg = (char_u *)N_("E519: Option not supported");
4523 goto skip;
4524 }
4525
4526 flags = options[opt_idx].flags;
4527 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4528 }
4529 else
4530 {
4531 flags = P_STRING;
4532 if (key < 0)
4533 {
4534 key_name[0] = KEY2TERMCAP0(key);
4535 key_name[1] = KEY2TERMCAP1(key);
4536 }
4537 else
4538 {
4539 key_name[0] = KS_KEY;
4540 key_name[1] = (key & 0xff);
4541 }
4542 }
4543
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004544 /* Skip all options that are not window-local (used when showing
4545 * an already loaded buffer in a window). */
4546 if ((opt_flags & OPT_WINONLY)
4547 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4548 goto skip;
4549
Bram Moolenaara3227e22006-03-08 21:32:40 +00004550 /* Skip all options that are window-local (used for :vimgrep). */
4551 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4552 && options[opt_idx].var == VAR_WIN)
4553 goto skip;
4554
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004555 /* Disallow changing some options from modelines. */
4556 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004557 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004558 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004559 {
4560 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4561 goto skip;
4562 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004563#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004564 /* In diff mode some options are overruled. This avoids that
4565 * 'foldmethod' becomes "marker" instead of "diff" and that
4566 * "wrap" gets set. */
4567 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004568 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004569 && (
4570#ifdef FEAT_FOLDING
4571 options[opt_idx].indir == PV_FDM ||
4572#endif
4573 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004574 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004575#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004576 }
4577
4578#ifdef HAVE_SANDBOX
4579 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004580 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004581 {
4582 errmsg = (char_u *)_(e_sandbox);
4583 goto skip;
4584 }
4585#endif
4586
4587 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4588 {
4589 arg += len;
4590 cp_val = p_cp;
4591 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4592 {
4593 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4594 {
4595 cp_val = FALSE;
4596 arg += 3;
4597 }
4598 else /* "opt&vi": set to Vi default */
4599 {
4600 cp_val = TRUE;
4601 arg += 2;
4602 }
4603 }
4604 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004605 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004606 {
4607 errmsg = e_trailing;
4608 goto skip;
4609 }
4610 }
4611
4612 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004613 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4614 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004615 */
4616 if (nextchar == '?'
4617 || (prefix == 1
4618 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4619 && !(flags & P_BOOL)))
4620 {
4621 /*
4622 * print value
4623 */
4624 if (did_show)
4625 msg_putchar('\n'); /* cursor below last one */
4626 else
4627 {
4628 gotocmdline(TRUE); /* cursor at status line */
4629 did_show = TRUE; /* remember that we did a line */
4630 }
4631 if (opt_idx >= 0)
4632 {
4633 showoneopt(&options[opt_idx], opt_flags);
4634#ifdef FEAT_EVAL
4635 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004636 {
4637 /* Mention where the option was last set. */
4638 if (varp == options[opt_idx].var)
4639 last_set_msg(options[opt_idx].scriptID);
4640 else if ((int)options[opt_idx].indir & PV_WIN)
4641 last_set_msg(curwin->w_p_scriptID[
4642 (int)options[opt_idx].indir & PV_MASK]);
4643 else if ((int)options[opt_idx].indir & PV_BUF)
4644 last_set_msg(curbuf->b_p_scriptID[
4645 (int)options[opt_idx].indir & PV_MASK]);
4646 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004647#endif
4648 }
4649 else
4650 {
4651 char_u *p;
4652
4653 p = find_termcode(key_name);
4654 if (p == NULL)
4655 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004656 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004657 goto skip;
4658 }
4659 else
4660 (void)show_one_termcode(key_name, p, TRUE);
4661 }
4662 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004663 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004664 errmsg = e_trailing;
4665 }
4666 else
4667 {
4668 if (flags & P_BOOL) /* boolean */
4669 {
4670 if (nextchar == '=' || nextchar == ':')
4671 {
4672 errmsg = e_invarg;
4673 goto skip;
4674 }
4675
4676 /*
4677 * ":set opt!": invert
4678 * ":set opt&": reset to default value
4679 * ":set opt<": reset to global value
4680 */
4681 if (nextchar == '!')
4682 value = *(int *)(varp) ^ 1;
4683 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004684 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004685 ((flags & P_VI_DEF) || cp_val)
4686 ? VI_DEFAULT : VIM_DEFAULT];
4687 else if (nextchar == '<')
4688 {
4689 /* For 'autoread' -1 means to use global value. */
4690 if ((int *)varp == &curbuf->b_p_ar
4691 && opt_flags == OPT_LOCAL)
4692 value = -1;
4693 else
4694 value = *(int *)get_varp_scope(&(options[opt_idx]),
4695 OPT_GLOBAL);
4696 }
4697 else
4698 {
4699 /*
4700 * ":set invopt": invert
4701 * ":set opt" or ":set noopt": set or reset
4702 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004703 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004704 {
4705 errmsg = e_trailing;
4706 goto skip;
4707 }
4708 if (prefix == 2) /* inv */
4709 value = *(int *)(varp) ^ 1;
4710 else
4711 value = prefix;
4712 }
4713
4714 errmsg = set_bool_option(opt_idx, varp, (int)value,
4715 opt_flags);
4716 }
4717 else /* numeric or string */
4718 {
4719 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4720 || prefix != 1)
4721 {
4722 errmsg = e_invarg;
4723 goto skip;
4724 }
4725
4726 if (flags & P_NUM) /* numeric */
4727 {
4728 /*
4729 * Different ways to set a number option:
4730 * & set to default value
4731 * < set to global value
4732 * <xx> accept special key codes for 'wildchar'
4733 * c accept any non-digit for 'wildchar'
4734 * [-]0-9 set number
4735 * other error
4736 */
4737 ++arg;
4738 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004739 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004740 ((flags & P_VI_DEF) || cp_val)
4741 ? VI_DEFAULT : VIM_DEFAULT];
4742 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004743 {
4744 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4745 * use the global value. */
4746 if ((long *)varp == &curbuf->b_p_ul
4747 && opt_flags == OPT_LOCAL)
4748 value = NO_LOCAL_UNDOLEVEL;
4749 else
4750 value = *(long *)get_varp_scope(
4751 &(options[opt_idx]), OPT_GLOBAL);
4752 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004753 else if (((long *)varp == &p_wc
4754 || (long *)varp == &p_wcm)
4755 && (*arg == '<'
4756 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004757 || (*arg != NUL
4758 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004759 && !VIM_ISDIGIT(*arg))))
4760 {
4761 value = string_to_key(arg);
4762 if (value == 0 && (long *)varp != &p_wcm)
4763 {
4764 errmsg = e_invarg;
4765 goto skip;
4766 }
4767 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004768 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4769 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004770 /* Allow negative (for 'undolevels'), octal and
4771 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004772 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4773 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004774 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004775 {
4776 errmsg = e_invarg;
4777 goto skip;
4778 }
4779 }
4780 else
4781 {
4782 errmsg = (char_u *)N_("E521: Number required after =");
4783 goto skip;
4784 }
4785
4786 if (adding)
4787 value = *(long *)varp + value;
4788 if (prepending)
4789 value = *(long *)varp * value;
4790 if (removing)
4791 value = *(long *)varp - value;
4792 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004793 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004794 }
4795 else if (opt_idx >= 0) /* string */
4796 {
4797 char_u *save_arg = NULL;
4798 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004799 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004800 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004801 char_u *origval = NULL;
4802#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4803 char_u *saved_origval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004804 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004805#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004806 unsigned newlen;
4807 int comma;
4808 int bs;
4809 int new_value_alloced; /* new string option
4810 was allocated */
4811
4812 /* When using ":set opt=val" for a global option
4813 * with a local value the local value will be
4814 * reset, use the global value here. */
4815 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004816 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004817 varp = options[opt_idx].var;
4818
4819 /* The old value is kept until we are sure that the
4820 * new value is valid. */
4821 oldval = *(char_u **)varp;
4822 if (nextchar == '&') /* set to default val */
4823 {
4824 newval = options[opt_idx].def_val[
4825 ((flags & P_VI_DEF) || cp_val)
4826 ? VI_DEFAULT : VIM_DEFAULT];
4827 if ((char_u **)varp == &p_bg)
4828 {
4829 /* guess the value of 'background' */
4830#ifdef FEAT_GUI
4831 if (gui.in_use)
4832 newval = gui_bg_default();
4833 else
4834#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004835 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004836 }
4837
4838 /* expand environment variables and ~ (since the
4839 * default value was already expanded, only
4840 * required when an environment variable was set
4841 * later */
4842 if (newval == NULL)
4843 newval = empty_option;
4844 else
4845 {
4846 s = option_expand(opt_idx, newval);
4847 if (s == NULL)
4848 s = newval;
4849 newval = vim_strsave(s);
4850 }
4851 new_value_alloced = TRUE;
4852 }
4853 else if (nextchar == '<') /* set to global val */
4854 {
4855 newval = vim_strsave(*(char_u **)get_varp_scope(
4856 &(options[opt_idx]), OPT_GLOBAL));
4857 new_value_alloced = TRUE;
4858 }
4859 else
4860 {
4861 ++arg; /* jump to after the '=' or ':' */
4862
4863 /*
4864 * Set 'keywordprg' to ":help" if an empty
4865 * value was passed to :set by the user.
4866 * Misuse errbuf[] for the resulting string.
4867 */
4868 if (varp == (char_u *)&p_kp
4869 && (*arg == NUL || *arg == ' '))
4870 {
4871 STRCPY(errbuf, ":help");
4872 save_arg = arg;
4873 arg = errbuf;
4874 }
4875 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004876 * Convert 'backspace' number to string, for
4877 * adding, prepending and removing string.
4878 */
4879 else if (varp == (char_u *)&p_bs
4880 && VIM_ISDIGIT(**(char_u **)varp))
4881 {
4882 i = getdigits((char_u **)varp);
4883 switch (i)
4884 {
4885 case 0:
4886 *(char_u **)varp = empty_option;
4887 break;
4888 case 1:
4889 *(char_u **)varp = vim_strsave(
4890 (char_u *)"indent,eol");
4891 break;
4892 case 2:
4893 *(char_u **)varp = vim_strsave(
4894 (char_u *)"indent,eol,start");
4895 break;
4896 }
4897 vim_free(oldval);
4898 oldval = *(char_u **)varp;
4899 }
4900 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004901 * Convert 'whichwrap' number to string, for
4902 * backwards compatibility with Vim 3.0.
4903 * Misuse errbuf[] for the resulting string.
4904 */
4905 else if (varp == (char_u *)&p_ww
4906 && VIM_ISDIGIT(*arg))
4907 {
4908 *errbuf = NUL;
4909 i = getdigits(&arg);
4910 if (i & 1)
4911 STRCAT(errbuf, "b,");
4912 if (i & 2)
4913 STRCAT(errbuf, "s,");
4914 if (i & 4)
4915 STRCAT(errbuf, "h,l,");
4916 if (i & 8)
4917 STRCAT(errbuf, "<,>,");
4918 if (i & 16)
4919 STRCAT(errbuf, "[,],");
4920 if (*errbuf != NUL) /* remove trailing , */
4921 errbuf[STRLEN(errbuf) - 1] = NUL;
4922 save_arg = arg;
4923 arg = errbuf;
4924 }
4925 /*
4926 * Remove '>' before 'dir' and 'bdir', for
4927 * backwards compatibility with version 3.0
4928 */
4929 else if ( *arg == '>'
4930 && (varp == (char_u *)&p_dir
4931 || varp == (char_u *)&p_bdir))
4932 {
4933 ++arg;
4934 }
4935
4936 /* When setting the local value of a global
4937 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004938 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004939 && (opt_flags & OPT_LOCAL))
4940 origval = *(char_u **)get_varp(
4941 &options[opt_idx]);
4942 else
4943 origval = oldval;
4944
4945 /*
4946 * Copy the new string into allocated memory.
4947 * Can't use set_string_option_direct(), because
4948 * we need to remove the backslashes.
4949 */
4950 /* get a bit too much */
4951 newlen = (unsigned)STRLEN(arg) + 1;
4952 if (adding || prepending || removing)
4953 newlen += (unsigned)STRLEN(origval) + 1;
4954 newval = alloc(newlen);
4955 if (newval == NULL) /* out of mem, don't change */
4956 break;
4957 s = newval;
4958
4959 /*
4960 * Copy the string, skip over escaped chars.
4961 * For MS-DOS and WIN32 backslashes before normal
4962 * file name characters are not removed, and keep
4963 * backslash at start, for "\\machine\path", but
4964 * do remove it for "\\\\machine\\path".
4965 * The reverse is found in ExpandOldSetting().
4966 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004967 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004968 {
4969 if (*arg == '\\' && arg[1] != NUL
4970#ifdef BACKSLASH_IN_FILENAME
4971 && !((flags & P_EXPAND)
4972 && vim_isfilec(arg[1])
4973 && (arg[1] != '\\'
4974 || (s == newval
4975 && arg[2] != '\\')))
4976#endif
4977 )
4978 ++arg; /* remove backslash */
4979#ifdef FEAT_MBYTE
4980 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004981 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004982 {
4983 /* copy multibyte char */
4984 mch_memmove(s, arg, (size_t)i);
4985 arg += i;
4986 s += i;
4987 }
4988 else
4989#endif
4990 *s++ = *arg++;
4991 }
4992 *s = NUL;
4993
4994 /*
4995 * Expand environment variables and ~.
4996 * Don't do it when adding without inserting a
4997 * comma.
4998 */
4999 if (!(adding || prepending || removing)
5000 || (flags & P_COMMA))
5001 {
5002 s = option_expand(opt_idx, newval);
5003 if (s != NULL)
5004 {
5005 vim_free(newval);
5006 newlen = (unsigned)STRLEN(s) + 1;
5007 if (adding || prepending || removing)
5008 newlen += (unsigned)STRLEN(origval) + 1;
5009 newval = alloc(newlen);
5010 if (newval == NULL)
5011 break;
5012 STRCPY(newval, s);
5013 }
5014 }
5015
5016 /* locate newval[] in origval[] when removing it
5017 * and when adding to avoid duplicates */
5018 i = 0; /* init for GCC */
5019 if (removing || (flags & P_NODUP))
5020 {
5021 i = (int)STRLEN(newval);
5022 bs = 0;
5023 for (s = origval; *s; ++s)
5024 {
5025 if ((!(flags & P_COMMA)
5026 || s == origval
5027 || (s[-1] == ',' && !(bs & 1)))
5028 && STRNCMP(s, newval, i) == 0
5029 && (!(flags & P_COMMA)
5030 || s[i] == ','
5031 || s[i] == NUL))
5032 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005033 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005034 * even number of backslashes or a single
5035 * backslash preceded by a comma before it
5036 * is recognized as a separator */
5037 if ((s > origval + 1
5038 && s[-1] == '\\'
5039 && s[-2] != ',')
5040 || (s == origval + 1
5041 && s[-1] == '\\'))
5042
Bram Moolenaar071d4272004-06-13 20:20:40 +00005043 ++bs;
5044 else
5045 bs = 0;
5046 }
5047
5048 /* do not add if already there */
5049 if ((adding || prepending) && *s)
5050 {
5051 prepending = FALSE;
5052 adding = FALSE;
5053 STRCPY(newval, origval);
5054 }
5055 }
5056
5057 /* concatenate the two strings; add a ',' if
5058 * needed */
5059 if (adding || prepending)
5060 {
5061 comma = ((flags & P_COMMA) && *origval != NUL
5062 && *newval != NUL);
5063 if (adding)
5064 {
5065 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005066 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005067 if (comma && i > 1
5068 && (flags & P_ONECOMMA) == P_ONECOMMA
5069 && origval[i - 1] == ','
5070 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005071 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005072 mch_memmove(newval + i + comma, newval,
5073 STRLEN(newval) + 1);
5074 mch_memmove(newval, origval, (size_t)i);
5075 }
5076 else
5077 {
5078 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005079 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005080 }
5081 if (comma)
5082 newval[i] = ',';
5083 }
5084
5085 /* Remove newval[] from origval[]. (Note: "i" has
5086 * been set above and is used here). */
5087 if (removing)
5088 {
5089 STRCPY(newval, origval);
5090 if (*s)
5091 {
5092 /* may need to remove a comma */
5093 if (flags & P_COMMA)
5094 {
5095 if (s == origval)
5096 {
5097 /* include comma after string */
5098 if (s[i] == ',')
5099 ++i;
5100 }
5101 else
5102 {
5103 /* include comma before string */
5104 --s;
5105 ++i;
5106 }
5107 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005108 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005109 }
5110 }
5111
5112 if (flags & P_FLAGLIST)
5113 {
5114 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005115 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005116 {
5117 /* if options have P_FLAGLIST and
5118 * P_ONECOMMA such as 'whichwrap' */
5119 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005120 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005121 if (*s != ',' && *(s + 1) == ','
5122 && vim_strchr(s + 2, *s) != NULL)
5123 {
5124 /* Remove the duplicated value and
5125 * the next comma. */
5126 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005127 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005128 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005129 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005130 else
5131 {
5132 if ((!(flags & P_COMMA) || *s != ',')
5133 && vim_strchr(s + 1, *s) != NULL)
5134 {
5135 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005136 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005137 }
5138 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005139 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005140 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005141 }
5142
5143 if (save_arg != NULL) /* number for 'whichwrap' */
5144 arg = save_arg;
5145 new_value_alloced = TRUE;
5146 }
5147
5148 /* Set the new value. */
5149 *(char_u **)(varp) = newval;
5150
Bram Moolenaar53744302015-07-17 17:38:22 +02005151#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005152 if (!starting
5153# ifdef FEAT_CRYPT
5154 && options[opt_idx].indir != PV_KEY
5155# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005156 && origval != NULL && newval != NULL)
5157 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005158 /* origval may be freed by
5159 * did_set_string_option(), make a copy. */
5160 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005161 /* newval (and varp) may become invalid if the
5162 * buffer is closed by autocommands. */
5163 saved_newval = vim_strsave(newval);
5164 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005165#endif
5166
Bram Moolenaar071d4272004-06-13 20:20:40 +00005167 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005168 * ":set" on local options. Note: when setting 'syntax'
5169 * or 'filetype' autocommands may be triggered that can
5170 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005171 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5172 new_value_alloced, oldval, errbuf, opt_flags);
5173
5174 /* If error detected, print the error message. */
5175 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01005176 {
5177#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5178 vim_free(saved_origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005179 vim_free(saved_newval);
Bram Moolenaara9884962015-12-13 15:08:56 +01005180#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005181 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01005182 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005183#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005184 trigger_optionsset_string(opt_idx, opt_flags,
5185 saved_origval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005186#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005187 }
5188 else /* key code option */
5189 {
5190 char_u *p;
5191
5192 if (nextchar == '&')
5193 {
5194 if (add_termcap_entry(key_name, TRUE) == FAIL)
5195 errmsg = (char_u *)N_("E522: Not found in termcap");
5196 }
5197 else
5198 {
5199 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005200 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005201 if (*p == '\\' && p[1] != NUL)
5202 ++p;
5203 nextchar = *p;
5204 *p = NUL;
5205 add_termcode(key_name, arg, FALSE);
5206 *p = nextchar;
5207 }
5208 if (full_screen)
5209 ttest(FALSE);
5210 redraw_all_later(CLEAR);
5211 }
5212 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005213
Bram Moolenaar071d4272004-06-13 20:20:40 +00005214 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005215 did_set_option(opt_idx, opt_flags,
5216 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005217 }
5218
5219skip:
5220 /*
5221 * Advance to next argument.
5222 * - skip until a blank found, taking care of backslashes
5223 * - skip blanks
5224 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5225 */
5226 for (i = 0; i < 2 ; ++i)
5227 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005228 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005229 if (*arg++ == '\\' && *arg != NUL)
5230 ++arg;
5231 arg = skipwhite(arg);
5232 if (*arg != '=')
5233 break;
5234 }
5235 }
5236
5237 if (errmsg != NULL)
5238 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005239 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005240 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005241 if (i + (arg - startarg) < IOSIZE)
5242 {
5243 /* append the argument with the error */
5244 STRCAT(IObuff, ": ");
5245 mch_memmove(IObuff + i, startarg, (arg - startarg));
5246 IObuff[i + (arg - startarg)] = NUL;
5247 }
5248 /* make sure all characters are printable */
5249 trans_characters(IObuff, IOSIZE);
5250
5251 ++no_wait_return; /* wait_return done later */
5252 emsg(IObuff); /* show error highlighted */
5253 --no_wait_return;
5254
5255 return FAIL;
5256 }
5257
5258 arg = skipwhite(arg);
5259 }
5260
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005261theend:
5262 if (silent_mode && did_show)
5263 {
5264 /* After displaying option values in silent mode. */
5265 silent_mode = FALSE;
5266 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5267 msg_putchar('\n');
5268 cursor_on(); /* msg_start() switches it off */
5269 out_flush();
5270 silent_mode = TRUE;
5271 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5272 }
5273
Bram Moolenaar071d4272004-06-13 20:20:40 +00005274 return OK;
5275}
5276
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005277/*
5278 * Call this when an option has been given a new value through a user command.
5279 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5280 */
5281 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005282did_set_option(
5283 int opt_idx,
5284 int opt_flags, /* possibly with OPT_MODELINE */
5285 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005286{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005287 long_u *p;
5288
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005289 options[opt_idx].flags |= P_WAS_SET;
5290
5291 /* When an option is set in the sandbox, from a modeline or in secure mode
5292 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005293 * flag. */
5294 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005295 if (secure
5296#ifdef HAVE_SANDBOX
5297 || sandbox != 0
5298#endif
5299 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005300 *p = *p | P_INSECURE;
5301 else if (new_value)
5302 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005303}
5304
Bram Moolenaar071d4272004-06-13 20:20:40 +00005305 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005306illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005307{
5308 if (errbuf == NULL)
5309 return (char_u *)"";
5310 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005311 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005312 return errbuf;
5313}
5314
5315/*
5316 * Convert a key name or string into a key value.
5317 * Used for 'wildchar' and 'cedit' options.
5318 */
5319 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005320string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005321{
5322 if (*arg == '<')
5323 return find_key_option(arg + 1);
5324 if (*arg == '^')
5325 return Ctrl_chr(arg[1]);
5326 return *arg;
5327}
5328
5329#ifdef FEAT_CMDWIN
5330/*
5331 * Check value of 'cedit' and set cedit_key.
5332 * Returns NULL if value is OK, error message otherwise.
5333 */
5334 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005335check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005336{
5337 int n;
5338
5339 if (*p_cedit == NUL)
5340 cedit_key = -1;
5341 else
5342 {
5343 n = string_to_key(p_cedit);
5344 if (vim_isprintc(n))
5345 return e_invarg;
5346 cedit_key = n;
5347 }
5348 return NULL;
5349}
5350#endif
5351
5352#ifdef FEAT_TITLE
5353/*
5354 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5355 * maketitle() to create and display it.
5356 * When switching the title or icon off, call mch_restore_title() to get
5357 * the old value back.
5358 */
5359 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005360did_set_title(
5361 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005362{
5363 if (starting != NO_SCREEN
5364#ifdef FEAT_GUI
5365 && !gui.starting
5366#endif
5367 )
5368 {
5369 maketitle();
5370 if (icon)
5371 {
5372 if (!p_icon)
5373 mch_restore_title(2);
5374 }
5375 else
5376 {
5377 if (!p_title)
5378 mch_restore_title(1);
5379 }
5380 }
5381}
5382#endif
5383
5384/*
5385 * set_options_bin - called when 'bin' changes value.
5386 */
5387 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005388set_options_bin(
5389 int oldval,
5390 int newval,
5391 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005392{
5393 /*
5394 * The option values that are changed when 'bin' changes are
5395 * copied when 'bin is set and restored when 'bin' is reset.
5396 */
5397 if (newval)
5398 {
5399 if (!oldval) /* switched on */
5400 {
5401 if (!(opt_flags & OPT_GLOBAL))
5402 {
5403 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5404 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5405 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5406 curbuf->b_p_et_nobin = curbuf->b_p_et;
5407 }
5408 if (!(opt_flags & OPT_LOCAL))
5409 {
5410 p_tw_nobin = p_tw;
5411 p_wm_nobin = p_wm;
5412 p_ml_nobin = p_ml;
5413 p_et_nobin = p_et;
5414 }
5415 }
5416
5417 if (!(opt_flags & OPT_GLOBAL))
5418 {
5419 curbuf->b_p_tw = 0; /* no automatic line wrap */
5420 curbuf->b_p_wm = 0; /* no automatic line wrap */
5421 curbuf->b_p_ml = 0; /* no modelines */
5422 curbuf->b_p_et = 0; /* no expandtab */
5423 }
5424 if (!(opt_flags & OPT_LOCAL))
5425 {
5426 p_tw = 0;
5427 p_wm = 0;
5428 p_ml = FALSE;
5429 p_et = FALSE;
5430 p_bin = TRUE; /* needed when called for the "-b" argument */
5431 }
5432 }
5433 else if (oldval) /* switched off */
5434 {
5435 if (!(opt_flags & OPT_GLOBAL))
5436 {
5437 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5438 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5439 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5440 curbuf->b_p_et = curbuf->b_p_et_nobin;
5441 }
5442 if (!(opt_flags & OPT_LOCAL))
5443 {
5444 p_tw = p_tw_nobin;
5445 p_wm = p_wm_nobin;
5446 p_ml = p_ml_nobin;
5447 p_et = p_et_nobin;
5448 }
5449 }
5450}
5451
5452#ifdef FEAT_VIMINFO
5453/*
5454 * Find the parameter represented by the given character (eg ', :, ", or /),
5455 * and return its associated value in the 'viminfo' string.
5456 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005457 * If the parameter is not specified in the string or there is no following
5458 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005459 */
5460 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005461get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005462{
5463 char_u *p;
5464
5465 p = find_viminfo_parameter(type);
5466 if (p != NULL && VIM_ISDIGIT(*p))
5467 return atoi((char *)p);
5468 return -1;
5469}
5470
5471/*
5472 * Find the parameter represented by the given character (eg ''', ':', '"', or
5473 * '/') in the 'viminfo' option and return a pointer to the string after it.
5474 * Return NULL if the parameter is not specified in the string.
5475 */
5476 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005477find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005478{
5479 char_u *p;
5480
5481 for (p = p_viminfo; *p; ++p)
5482 {
5483 if (*p == type)
5484 return p + 1;
5485 if (*p == 'n') /* 'n' is always the last one */
5486 break;
5487 p = vim_strchr(p, ','); /* skip until next ',' */
5488 if (p == NULL) /* hit the end without finding parameter */
5489 break;
5490 }
5491 return NULL;
5492}
5493#endif
5494
5495/*
5496 * Expand environment variables for some string options.
5497 * These string options cannot be indirect!
5498 * If "val" is NULL expand the current value of the option.
5499 * Return pointer to NameBuff, or NULL when not expanded.
5500 */
5501 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005502option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005503{
5504 /* if option doesn't need expansion nothing to do */
5505 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5506 return NULL;
5507
5508 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5509 * expand_env() would truncate the string. */
5510 if (val != NULL && STRLEN(val) > MAXPATHL)
5511 return NULL;
5512
5513 if (val == NULL)
5514 val = *(char_u **)options[opt_idx].var;
5515
5516 /*
5517 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5518 * Escape spaces when expanding 'tags', they are used to separate file
5519 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005520 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005521 */
5522 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005523 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005524#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005525 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5526#endif
5527 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005528 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5529 return NULL;
5530
5531 return NameBuff;
5532}
5533
5534/*
5535 * After setting various option values: recompute variables that depend on
5536 * option values.
5537 */
5538 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005539didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005540{
5541 /* initialize the table for 'iskeyword' et.al. */
5542 (void)init_chartab();
5543
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005544#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005545 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005546#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005547 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005548 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005549#ifdef FEAT_SESSION
5550 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5551 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5552#endif
5553#ifdef FEAT_FOLDING
5554 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5555#endif
5556 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005557 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005558#ifdef FEAT_VIRTUALEDIT
5559 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5560#endif
5561#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5562 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5563#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005564#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005565 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005566 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005567 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005568 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005569#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005570#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5571 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5572#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005573#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005574 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5575#endif
5576#ifdef FEAT_CMDWIN
5577 /* set cedit_key */
5578 (void)check_cedit();
5579#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005580#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005581 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005582#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005583#ifdef FEAT_LINEBREAK
5584 /* initialize the table for 'breakat'. */
5585 fill_breakat_flags();
5586#endif
5587
5588}
5589
5590/*
5591 * More side effects of setting options.
5592 */
5593 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005594didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005595{
5596 /* Initialize the highlight_attr[] table. */
5597 (void)highlight_changed();
5598
5599 /* Parse default for 'wildmode' */
5600 check_opt_wim();
5601
5602 (void)set_chars_option(&p_lcs);
5603#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5604 /* Parse default for 'fillchars'. */
5605 (void)set_chars_option(&p_fcs);
5606#endif
5607
5608#ifdef FEAT_CLIPBOARD
5609 /* Parse default for 'clipboard' */
5610 (void)check_clipboard_option();
5611#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005612}
5613
5614/*
5615 * Check for string options that are NULL (normally only termcap options).
5616 */
5617 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005618check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005619{
5620 int opt_idx;
5621
5622 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5623 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5624 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5625}
5626
5627/*
5628 * Check string options in a buffer for NULL value.
5629 */
5630 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005631check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005632{
5633#if defined(FEAT_QUICKFIX)
5634 check_string_option(&buf->b_p_bh);
5635 check_string_option(&buf->b_p_bt);
5636#endif
5637#ifdef FEAT_MBYTE
5638 check_string_option(&buf->b_p_fenc);
5639#endif
5640 check_string_option(&buf->b_p_ff);
5641#ifdef FEAT_FIND_ID
5642 check_string_option(&buf->b_p_def);
5643 check_string_option(&buf->b_p_inc);
5644# ifdef FEAT_EVAL
5645 check_string_option(&buf->b_p_inex);
5646# endif
5647#endif
5648#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5649 check_string_option(&buf->b_p_inde);
5650 check_string_option(&buf->b_p_indk);
5651#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005652#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5653 check_string_option(&buf->b_p_bexpr);
5654#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005655#if defined(FEAT_CRYPT)
5656 check_string_option(&buf->b_p_cm);
5657#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005658 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005659#if defined(FEAT_EVAL)
5660 check_string_option(&buf->b_p_fex);
5661#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005662#ifdef FEAT_CRYPT
5663 check_string_option(&buf->b_p_key);
5664#endif
5665 check_string_option(&buf->b_p_kp);
5666 check_string_option(&buf->b_p_mps);
5667 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005668 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005669 check_string_option(&buf->b_p_isk);
5670#ifdef FEAT_COMMENTS
5671 check_string_option(&buf->b_p_com);
5672#endif
5673#ifdef FEAT_FOLDING
5674 check_string_option(&buf->b_p_cms);
5675#endif
5676 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005677#ifdef FEAT_TEXTOBJ
5678 check_string_option(&buf->b_p_qe);
5679#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005680#ifdef FEAT_SYN_HL
5681 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005682 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005683#endif
5684#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005685 check_string_option(&buf->b_s.b_p_spc);
5686 check_string_option(&buf->b_s.b_p_spf);
5687 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005688#endif
5689#ifdef FEAT_SEARCHPATH
5690 check_string_option(&buf->b_p_sua);
5691#endif
5692#ifdef FEAT_CINDENT
5693 check_string_option(&buf->b_p_cink);
5694 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005695 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005696#endif
5697#ifdef FEAT_AUTOCMD
5698 check_string_option(&buf->b_p_ft);
5699#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005700#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5701 check_string_option(&buf->b_p_cinw);
5702#endif
5703#ifdef FEAT_INS_EXPAND
5704 check_string_option(&buf->b_p_cpt);
5705#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005706#ifdef FEAT_COMPL_FUNC
5707 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005708 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005709#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005710#ifdef FEAT_KEYMAP
5711 check_string_option(&buf->b_p_keymap);
5712#endif
5713#ifdef FEAT_QUICKFIX
5714 check_string_option(&buf->b_p_gp);
5715 check_string_option(&buf->b_p_mp);
5716 check_string_option(&buf->b_p_efm);
5717#endif
5718 check_string_option(&buf->b_p_ep);
5719 check_string_option(&buf->b_p_path);
5720 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005721 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005722#ifdef FEAT_INS_EXPAND
5723 check_string_option(&buf->b_p_dict);
5724 check_string_option(&buf->b_p_tsr);
5725#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005726#ifdef FEAT_LISP
5727 check_string_option(&buf->b_p_lw);
5728#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005729 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005730#ifdef FEAT_MBYTE
5731 check_string_option(&buf->b_p_menc);
5732#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005733}
5734
5735/*
5736 * Free the string allocated for an option.
5737 * Checks for the string being empty_option. This may happen if we're out of
5738 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5739 * check_options().
5740 * Does NOT check for P_ALLOCED flag!
5741 */
5742 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005743free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005744{
5745 if (p != empty_option)
5746 vim_free(p);
5747}
5748
5749 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005750clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005751{
5752 if (*pp != empty_option)
5753 vim_free(*pp);
5754 *pp = empty_option;
5755}
5756
5757 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005758check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005759{
5760 if (*pp == NULL)
5761 *pp = empty_option;
5762}
5763
5764/*
5765 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5766 */
5767 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005768set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005769{
5770 int opt_idx;
5771
5772 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5773 if (options[opt_idx].var == (char_u *)p)
5774 {
5775 options[opt_idx].flags |= P_ALLOCED;
5776 return;
5777 }
5778 return; /* cannot happen: didn't find it! */
5779}
5780
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005781#if defined(FEAT_EVAL) || defined(PROTO)
5782/*
5783 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5784 * Return FALSE when it wasn't.
5785 * Return -1 for an unknown option.
5786 */
5787 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005788was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005789{
5790 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005791 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005792
5793 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005794 {
5795 flagp = insecure_flag(idx, opt_flags);
5796 return (*flagp & P_INSECURE) != 0;
5797 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005798 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005799 return -1;
5800}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005801
5802/*
5803 * Get a pointer to the flags used for the P_INSECURE flag of option
5804 * "opt_idx". For some local options a local flags field is used.
5805 */
5806 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005807insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005808{
5809 if (opt_flags & OPT_LOCAL)
5810 switch ((int)options[opt_idx].indir)
5811 {
5812#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005813 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005814#endif
5815#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005816# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005817 case PV_FDE: return &curwin->w_p_fde_flags;
5818 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005819# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005820# ifdef FEAT_BEVAL
5821 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5822# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005823# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005824 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005825# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005826 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005827# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005828 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005829# endif
5830#endif
5831 }
5832
5833 /* Nothing special, return global flags field. */
5834 return &options[opt_idx].flags;
5835}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005836#endif
5837
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005838#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005839static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005840
5841/*
5842 * Redraw the window title and/or tab page text later.
5843 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005844static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005845{
5846 need_maketitle = TRUE;
5847# ifdef FEAT_WINDOWS
5848 redraw_tabline = TRUE;
5849# endif
5850}
5851#endif
5852
Bram Moolenaar071d4272004-06-13 20:20:40 +00005853/*
5854 * Set a string option to a new value (without checking the effect).
5855 * The string is copied into allocated memory.
5856 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005857 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005858 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005859 */
5860 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005861set_string_option_direct(
5862 char_u *name,
5863 int opt_idx,
5864 char_u *val,
5865 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5866 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005867{
5868 char_u *s;
5869 char_u **varp;
5870 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005871 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005872
Bram Moolenaar89d40322006-08-29 15:30:07 +00005873 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005874 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005875 idx = findoption(name);
5876 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005877 {
5878 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005879 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005880 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005881 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005882 }
5883
Bram Moolenaar89d40322006-08-29 15:30:07 +00005884 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005885 return;
5886
5887 s = vim_strsave(val);
5888 if (s != NULL)
5889 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005890 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005891 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005892 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005893 free_string_option(*varp);
5894 *varp = s;
5895
5896 /* For buffer/window local option may also set the global value. */
5897 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005898 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005899
Bram Moolenaar89d40322006-08-29 15:30:07 +00005900 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005901
5902 /* When setting both values of a global option with a local value,
5903 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005904 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005905 {
5906 free_string_option(*varp);
5907 *varp = empty_option;
5908 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005909# ifdef FEAT_EVAL
5910 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005911 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005912 set_sid == 0 ? current_SID : set_sid);
5913# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005914 }
5915}
5916
5917/*
5918 * Set global value for string option when it's a local option.
5919 */
5920 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005921set_string_option_global(
5922 int opt_idx, /* option index */
5923 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005924{
5925 char_u **p, *s;
5926
5927 /* the global value is always allocated */
5928 if (options[opt_idx].var == VAR_WIN)
5929 p = (char_u **)GLOBAL_WO(varp);
5930 else
5931 p = (char_u **)options[opt_idx].var;
5932 if (options[opt_idx].indir != PV_NONE
5933 && p != varp
5934 && (s = vim_strsave(*varp)) != NULL)
5935 {
5936 free_string_option(*p);
5937 *p = s;
5938 }
5939}
5940
5941/*
5942 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005943 *
5944 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005945 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005946 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005947set_string_option(
5948 int opt_idx,
5949 char_u *value,
5950 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005951{
5952 char_u *s;
5953 char_u **varp;
5954 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005955#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5956 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005957 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005958#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005959 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005960
5961 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005962 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005963
5964 s = vim_strsave(value);
5965 if (s != NULL)
5966 {
5967 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5968 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005969 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005970 ? OPT_GLOBAL : OPT_LOCAL)
5971 : opt_flags);
5972 oldval = *varp;
5973 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005974
5975#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005976 if (!starting
5977# ifdef FEAT_CRYPT
5978 && options[opt_idx].indir != PV_KEY
5979# endif
5980 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005981 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005982 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005983 saved_newval = vim_strsave(s);
5984 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005985#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005986 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5987 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005988 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005989
Bram Moolenaar53744302015-07-17 17:38:22 +02005990#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005991 /* call autocommand after handling side effects */
5992 trigger_optionsset_string(opt_idx, opt_flags,
5993 saved_oldval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005994#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005995 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005996 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005997}
5998
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005999#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006000/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006001 * Return TRUE if "val" is a valid 'filetype' name.
6002 * Also used for 'syntax' and 'keymap'.
6003 */
6004 static int
6005valid_filetype(char_u *val)
6006{
6007 char_u *s;
6008
6009 for (s = val; *s != NUL; ++s)
6010 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6011 return FALSE;
6012 return TRUE;
6013}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006014#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006015
6016/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006017 * Handle string options that need some action to perform when changed.
6018 * Returns NULL for success, or an error message for an error.
6019 */
6020 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006021did_set_string_option(
6022 int opt_idx, /* index in options[] table */
6023 char_u **varp, /* pointer to the option variable */
6024 int new_value_alloced, /* new value was allocated */
6025 char_u *oldval, /* previous value of the option */
6026 char_u *errbuf, /* buffer for errors, or NULL */
6027 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006028{
6029 char_u *errmsg = NULL;
6030 char_u *s, *p;
6031 int did_chartab = FALSE;
6032 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006033 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006034#ifdef FEAT_GUI
6035 /* set when changing an option that only requires a redraw in the GUI */
6036 int redraw_gui_only = FALSE;
6037#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006038#ifdef FEAT_AUTOCMD
6039 int ft_changed = FALSE;
6040#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006041
6042 /* Get the global option to compare with, otherwise we would have to check
6043 * two values for all local options. */
6044 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6045
6046 /* Disallow changing some options from secure mode */
6047 if ((secure
6048#ifdef HAVE_SANDBOX
6049 || sandbox != 0
6050#endif
6051 ) && (options[opt_idx].flags & P_SECURE))
6052 {
6053 errmsg = e_secure;
6054 }
6055
Bram Moolenaar7554da42016-11-25 22:04:13 +01006056 /* Check for a "normal" directory or file name in some options. Disallow a
6057 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006058 * are often illegal in a file name. Be more permissive if "secure" is off.
6059 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006060 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006061 && vim_strpbrk(*varp, (char_u *)(secure
6062 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006063 || ((options[opt_idx].flags & P_NDNAME)
6064 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006065 {
6066 errmsg = e_invarg;
6067 }
6068
Bram Moolenaar071d4272004-06-13 20:20:40 +00006069 /* 'term' */
6070 else if (varp == &T_NAME)
6071 {
6072 if (T_NAME[0] == NUL)
6073 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6074#ifdef FEAT_GUI
6075 if (gui.in_use)
6076 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6077 else if (term_is_gui(T_NAME))
6078 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6079#endif
6080 else if (set_termname(T_NAME) == FAIL)
6081 errmsg = (char_u *)N_("E522: Not found in termcap");
6082 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006083 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006084 /* Screen colors may have changed. */
6085 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006086
6087 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6088 * P_ALLOCED flag on 'term'. */
6089 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006090 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006091 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006092 }
6093
6094 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006095 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006096 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006097 char_u *bkc = p_bkc;
6098 unsigned int *flags = &bkc_flags;
6099
6100 if (opt_flags & OPT_LOCAL)
6101 {
6102 bkc = curbuf->b_p_bkc;
6103 flags = &curbuf->b_bkc_flags;
6104 }
6105
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006106 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6107 /* make the local value empty: use the global value */
6108 *flags = 0;
6109 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006110 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006111 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6112 errmsg = e_invarg;
6113 if ((((int)*flags & BKC_AUTO) != 0)
6114 + (((int)*flags & BKC_YES) != 0)
6115 + (((int)*flags & BKC_NO) != 0) != 1)
6116 {
6117 /* Must have exactly one of "auto", "yes" and "no". */
6118 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6119 errmsg = e_invarg;
6120 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006121 }
6122 }
6123
6124 /* 'backupext' and 'patchmode' */
6125 else if (varp == &p_bex || varp == &p_pm)
6126 {
6127 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6128 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6129 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6130 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006131#ifdef FEAT_LINEBREAK
6132 /* 'breakindentopt' */
6133 else if (varp == &curwin->w_p_briopt)
6134 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006135 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006136 errmsg = e_invarg;
6137 }
6138#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006139
6140 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006141 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006142 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006143 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006144 */
6145 else if ( varp == &p_isi
6146 || varp == &(curbuf->b_p_isk)
6147 || varp == &p_isp
6148 || varp == &p_isf)
6149 {
6150 if (init_chartab() == FAIL)
6151 {
6152 did_chartab = TRUE; /* need to restore it below */
6153 errmsg = e_invarg; /* error in value */
6154 }
6155 }
6156
6157 /* 'helpfile' */
6158 else if (varp == &p_hf)
6159 {
6160 /* May compute new values for $VIM and $VIMRUNTIME */
6161 if (didset_vim)
6162 {
6163 vim_setenv((char_u *)"VIM", (char_u *)"");
6164 didset_vim = FALSE;
6165 }
6166 if (didset_vimruntime)
6167 {
6168 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6169 didset_vimruntime = FALSE;
6170 }
6171 }
6172
Bram Moolenaar1a384422010-07-14 19:53:30 +02006173#ifdef FEAT_SYN_HL
6174 /* 'colorcolumn' */
6175 else if (varp == &curwin->w_p_cc)
6176 errmsg = check_colorcolumn(curwin);
6177#endif
6178
Bram Moolenaar071d4272004-06-13 20:20:40 +00006179#ifdef FEAT_MULTI_LANG
6180 /* 'helplang' */
6181 else if (varp == &p_hlg)
6182 {
6183 /* Check for "", "ab", "ab,cd", etc. */
6184 for (s = p_hlg; *s != NUL; s += 3)
6185 {
6186 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6187 {
6188 errmsg = e_invarg;
6189 break;
6190 }
6191 if (s[2] == NUL)
6192 break;
6193 }
6194 }
6195#endif
6196
6197 /* 'highlight' */
6198 else if (varp == &p_hl)
6199 {
6200 if (highlight_changed() == FAIL)
6201 errmsg = e_invarg; /* invalid flags */
6202 }
6203
6204 /* 'nrformats' */
6205 else if (gvarp == &p_nf)
6206 {
6207 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6208 errmsg = e_invarg;
6209 }
6210
6211#ifdef FEAT_SESSION
6212 /* 'sessionoptions' */
6213 else if (varp == &p_ssop)
6214 {
6215 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6216 errmsg = e_invarg;
6217 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6218 {
6219 /* Don't allow both "sesdir" and "curdir". */
6220 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6221 errmsg = e_invarg;
6222 }
6223 }
6224 /* 'viewoptions' */
6225 else if (varp == &p_vop)
6226 {
6227 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6228 errmsg = e_invarg;
6229 }
6230#endif
6231
6232 /* 'scrollopt' */
6233#ifdef FEAT_SCROLLBIND
6234 else if (varp == &p_sbo)
6235 {
6236 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6237 errmsg = e_invarg;
6238 }
6239#endif
6240
6241 /* 'ambiwidth' */
6242#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006243 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006244 {
6245 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6246 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006247 else if (set_chars_option(&p_lcs) != NULL)
6248 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6249# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6250 else if (set_chars_option(&p_fcs) != NULL)
6251 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6252# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006253 }
6254#endif
6255
6256 /* 'background' */
6257 else if (varp == &p_bg)
6258 {
6259 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6260 {
6261#ifdef FEAT_EVAL
6262 int dark = (*p_bg == 'd');
6263#endif
6264
6265 init_highlight(FALSE, FALSE);
6266
6267#ifdef FEAT_EVAL
6268 if (dark != (*p_bg == 'd')
6269 && get_var_value((char_u *)"g:colors_name") != NULL)
6270 {
6271 /* The color scheme must have set 'background' back to another
6272 * value, that's not what we want here. Disable the color
6273 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006274 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006275 free_string_option(p_bg);
6276 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6277 check_string_option(&p_bg);
6278 init_highlight(FALSE, FALSE);
6279 }
6280#endif
6281 }
6282 else
6283 errmsg = e_invarg;
6284 }
6285
6286 /* 'wildmode' */
6287 else if (varp == &p_wim)
6288 {
6289 if (check_opt_wim() == FAIL)
6290 errmsg = e_invarg;
6291 }
6292
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006293#ifdef FEAT_CMDL_COMPL
6294 /* 'wildoptions' */
6295 else if (varp == &p_wop)
6296 {
6297 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6298 errmsg = e_invarg;
6299 }
6300#endif
6301
Bram Moolenaar071d4272004-06-13 20:20:40 +00006302#ifdef FEAT_WAK
6303 /* 'winaltkeys' */
6304 else if (varp == &p_wak)
6305 {
6306 if (*p_wak == NUL
6307 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6308 errmsg = e_invarg;
6309# ifdef FEAT_MENU
6310# ifdef FEAT_GUI_MOTIF
6311 else if (gui.in_use)
6312 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6313# else
6314# ifdef FEAT_GUI_GTK
6315 else if (gui.in_use)
6316 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6317# endif
6318# endif
6319# endif
6320 }
6321#endif
6322
6323#ifdef FEAT_AUTOCMD
6324 /* 'eventignore' */
6325 else if (varp == &p_ei)
6326 {
6327 if (check_ei() == FAIL)
6328 errmsg = e_invarg;
6329 }
6330#endif
6331
6332#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006333 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6334 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6335 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006336 {
6337 if (gvarp == &p_fenc)
6338 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006339 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006340 errmsg = e_modifiable;
6341 else if (vim_strchr(*varp, ',') != NULL)
6342 /* No comma allowed in 'fileencoding'; catches confusing it
6343 * with 'fileencodings'. */
6344 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006345 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006346 {
6347# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006348 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006349 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006350# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006351 /* Add 'fileencoding' to the swap file. */
6352 ml_setflags(curbuf);
6353 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006354 }
6355 if (errmsg == NULL)
6356 {
6357 /* canonize the value, so that STRCMP() can be used on it */
6358 p = enc_canonize(*varp);
6359 if (p != NULL)
6360 {
6361 vim_free(*varp);
6362 *varp = p;
6363 }
6364 if (varp == &p_enc)
6365 {
6366 errmsg = mb_init();
6367# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006368 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006369# endif
6370 }
6371 }
6372
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006373# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006374 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6375 {
6376 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6377 if (STRCMP(p_tenc, "utf-8") != 0)
6378 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6379 }
6380# endif
6381
6382 if (errmsg == NULL)
6383 {
6384# ifdef FEAT_KEYMAP
6385 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6386 * (with another encoding). */
6387 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6388 (void)keymap_init();
6389# endif
6390
6391 /* When 'termencoding' is not empty and 'encoding' changes or when
6392 * 'termencoding' changes, need to setup for keyboard input and
6393 * display output conversion. */
6394 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6395 {
6396 convert_setup(&input_conv, p_tenc, p_enc);
6397 convert_setup(&output_conv, p_enc, p_tenc);
6398 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006399
6400# if defined(WIN3264) && defined(FEAT_MBYTE)
6401 /* $HOME may have characters in active code page. */
6402 if (varp == &p_enc)
6403 init_homedir();
6404# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006405 }
6406 }
6407#endif
6408
6409#if defined(FEAT_POSTSCRIPT)
6410 else if (varp == &p_penc)
6411 {
6412 /* Canonize printencoding if VIM standard one */
6413 p = enc_canonize(p_penc);
6414 if (p != NULL)
6415 {
6416 vim_free(p_penc);
6417 p_penc = p;
6418 }
6419 else
6420 {
6421 /* Ensure lower case and '-' for '_' */
6422 for (s = p_penc; *s != NUL; s++)
6423 {
6424 if (*s == '_')
6425 *s = '-';
6426 else
6427 *s = TOLOWER_ASC(*s);
6428 }
6429 }
6430 }
6431#endif
6432
Bram Moolenaar9372a112005-12-06 19:59:18 +00006433#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006434 else if (varp == &p_imak)
6435 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006436 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006437 errmsg = e_invarg;
6438 }
6439#endif
6440
6441#ifdef FEAT_KEYMAP
6442 else if (varp == &curbuf->b_p_keymap)
6443 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006444 if (!valid_filetype(*varp))
6445 errmsg = e_invarg;
6446 else
6447 /* load or unload key mapping tables */
6448 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006449
Bram Moolenaarfab06232009-03-04 03:13:35 +00006450 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006451 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006452 if (*curbuf->b_p_keymap != NUL)
6453 {
6454 /* Installed a new keymap, switch on using it. */
6455 curbuf->b_p_iminsert = B_IMODE_LMAP;
6456 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6457 curbuf->b_p_imsearch = B_IMODE_LMAP;
6458 }
6459 else
6460 {
6461 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6462 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6463 curbuf->b_p_iminsert = B_IMODE_NONE;
6464 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6465 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6466 }
6467 if ((opt_flags & OPT_LOCAL) == 0)
6468 {
6469 set_iminsert_global();
6470 set_imsearch_global();
6471 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006472# ifdef FEAT_WINDOWS
6473 status_redraw_curbuf();
6474# endif
6475 }
6476 }
6477#endif
6478
6479 /* 'fileformat' */
6480 else if (gvarp == &p_ff)
6481 {
6482 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6483 errmsg = e_modifiable;
6484 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6485 errmsg = e_invarg;
6486 else
6487 {
6488 /* may also change 'textmode' */
6489 if (get_fileformat(curbuf) == EOL_DOS)
6490 curbuf->b_p_tx = TRUE;
6491 else
6492 curbuf->b_p_tx = FALSE;
6493#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006494 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006495#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006496 /* update flag in swap file */
6497 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006498 /* Redraw needed when switching to/from "mac": a CR in the text
6499 * will be displayed differently. */
6500 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6501 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006502 }
6503 }
6504
6505 /* 'fileformats' */
6506 else if (varp == &p_ffs)
6507 {
6508 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6509 errmsg = e_invarg;
6510 else
6511 {
6512 /* also change 'textauto' */
6513 if (*p_ffs == NUL)
6514 p_ta = FALSE;
6515 else
6516 p_ta = TRUE;
6517 }
6518 }
6519
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006520#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006521 /* 'cryptkey' */
6522 else if (gvarp == &p_key)
6523 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006524# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006525 /* Make sure the ":set" command doesn't show the new value in the
6526 * history. */
6527 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006528# endif
6529 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6530 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006531 ml_set_crypt_key(curbuf, oldval,
6532 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006533 }
6534
6535 else if (gvarp == &p_cm)
6536 {
6537 if (opt_flags & OPT_LOCAL)
6538 p = curbuf->b_p_cm;
6539 else
6540 p = p_cm;
6541 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6542 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006543 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006544 errmsg = e_invarg;
6545 else
6546 {
6547 /* When setting the global value to empty, make it "zip". */
6548 if (*p_cm == NUL)
6549 {
6550 if (new_value_alloced)
6551 free_string_option(p_cm);
6552 p_cm = vim_strsave((char_u *)"zip");
6553 new_value_alloced = TRUE;
6554 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006555 /* When using ":set cm=name" the local value is going to be empty.
6556 * Do that here, otherwise the crypt functions will still use the
6557 * local value. */
6558 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6559 {
6560 free_string_option(curbuf->b_p_cm);
6561 curbuf->b_p_cm = empty_option;
6562 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006563
6564 /* Need to update the swapfile when the effective method changed.
6565 * Set "s" to the effective old value, "p" to the effective new
6566 * method and compare. */
6567 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6568 s = p_cm; /* was previously using the global value */
6569 else
6570 s = oldval;
6571 if (*curbuf->b_p_cm == NUL)
6572 p = p_cm; /* is now using the global value */
6573 else
6574 p = curbuf->b_p_cm;
6575 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006576 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006577
6578 /* If the global value changes need to update the swapfile for all
6579 * buffers using that value. */
6580 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6581 {
6582 buf_T *buf;
6583
Bram Moolenaar29323592016-07-24 22:04:11 +02006584 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006585 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006586 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006587 }
6588 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006589 }
6590#endif
6591
6592 /* 'matchpairs' */
6593 else if (gvarp == &p_mps)
6594 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006595#ifdef FEAT_MBYTE
6596 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006597 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006598 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006599 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006600 int x2 = -1;
6601 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006602
6603 if (*p != NUL)
6604 p += mb_ptr2len(p);
6605 if (*p != NUL)
6606 x2 = *p++;
6607 if (*p != NUL)
6608 {
6609 x3 = mb_ptr2char(p);
6610 p += mb_ptr2len(p);
6611 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006612 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006613 {
6614 errmsg = e_invarg;
6615 break;
6616 }
6617 if (*p == NUL)
6618 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006619 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006620 }
6621 else
6622#endif
6623 {
6624 /* Check for "x:y,x:y" */
6625 for (p = *varp; *p != NUL; p += 4)
6626 {
6627 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6628 {
6629 errmsg = e_invarg;
6630 break;
6631 }
6632 if (p[3] == NUL)
6633 break;
6634 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006635 }
6636 }
6637
6638#ifdef FEAT_COMMENTS
6639 /* 'comments' */
6640 else if (gvarp == &p_com)
6641 {
6642 for (s = *varp; *s; )
6643 {
6644 while (*s && *s != ':')
6645 {
6646 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6647 && !VIM_ISDIGIT(*s) && *s != '-')
6648 {
6649 errmsg = illegal_char(errbuf, *s);
6650 break;
6651 }
6652 ++s;
6653 }
6654 if (*s++ == NUL)
6655 errmsg = (char_u *)N_("E524: Missing colon");
6656 else if (*s == ',' || *s == NUL)
6657 errmsg = (char_u *)N_("E525: Zero length string");
6658 if (errmsg != NULL)
6659 break;
6660 while (*s && *s != ',')
6661 {
6662 if (*s == '\\' && s[1] != NUL)
6663 ++s;
6664 ++s;
6665 }
6666 s = skip_to_option_part(s);
6667 }
6668 }
6669#endif
6670
6671 /* 'listchars' */
6672 else if (varp == &p_lcs)
6673 {
6674 errmsg = set_chars_option(varp);
6675 }
6676
6677#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6678 /* 'fillchars' */
6679 else if (varp == &p_fcs)
6680 {
6681 errmsg = set_chars_option(varp);
6682 }
6683#endif
6684
6685#ifdef FEAT_CMDWIN
6686 /* 'cedit' */
6687 else if (varp == &p_cedit)
6688 {
6689 errmsg = check_cedit();
6690 }
6691#endif
6692
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006693 /* 'verbosefile' */
6694 else if (varp == &p_vfile)
6695 {
6696 verbose_stop();
6697 if (*p_vfile != NUL && verbose_open() == FAIL)
6698 errmsg = e_invarg;
6699 }
6700
Bram Moolenaar071d4272004-06-13 20:20:40 +00006701#ifdef FEAT_VIMINFO
6702 /* 'viminfo' */
6703 else if (varp == &p_viminfo)
6704 {
6705 for (s = p_viminfo; *s;)
6706 {
6707 /* Check it's a valid character */
6708 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6709 {
6710 errmsg = illegal_char(errbuf, *s);
6711 break;
6712 }
6713 if (*s == 'n') /* name is always last one */
6714 {
6715 break;
6716 }
6717 else if (*s == 'r') /* skip until next ',' */
6718 {
6719 while (*++s && *s != ',')
6720 ;
6721 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006722 else if (*s == '%')
6723 {
6724 /* optional number */
6725 while (vim_isdigit(*++s))
6726 ;
6727 }
6728 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006729 ++s; /* no extra chars */
6730 else /* must have a number */
6731 {
6732 while (vim_isdigit(*++s))
6733 ;
6734
6735 if (!VIM_ISDIGIT(*(s - 1)))
6736 {
6737 if (errbuf != NULL)
6738 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006739 sprintf((char *)errbuf,
6740 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006741 transchar_byte(*(s - 1)));
6742 errmsg = errbuf;
6743 }
6744 else
6745 errmsg = (char_u *)"";
6746 break;
6747 }
6748 }
6749 if (*s == ',')
6750 ++s;
6751 else if (*s)
6752 {
6753 if (errbuf != NULL)
6754 errmsg = (char_u *)N_("E527: Missing comma");
6755 else
6756 errmsg = (char_u *)"";
6757 break;
6758 }
6759 }
6760 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6761 errmsg = (char_u *)N_("E528: Must specify a ' value");
6762 }
6763#endif /* FEAT_VIMINFO */
6764
6765 /* terminal options */
6766 else if (istermoption(&options[opt_idx]) && full_screen)
6767 {
6768 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6769 if (varp == &T_CCO)
6770 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006771 int colors = atoi((char *)T_CCO);
6772
6773 /* Only reinitialize colors if t_Co value has really changed to
6774 * avoid expensive reload of colorscheme if t_Co is set to the
6775 * same value multiple times. */
6776 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006777 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006778 t_colors = colors;
6779 if (t_colors <= 1)
6780 {
6781 if (new_value_alloced)
6782 vim_free(T_CCO);
6783 T_CCO = empty_option;
6784 }
6785 /* We now have a different color setup, initialize it again. */
6786 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006787 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006788 }
6789 ttest(FALSE);
6790 if (varp == &T_ME)
6791 {
6792 out_str(T_ME);
6793 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006794#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006795 /* Since t_me has been set, this probably means that the user
6796 * wants to use this as default colors. Need to reset default
6797 * background/foreground colors. */
6798 mch_set_normal_colors();
6799#endif
6800 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006801 if (varp == &T_BE && termcap_active)
6802 {
6803 if (*T_BE == NUL)
6804 /* When clearing t_BE we assume the user no longer wants
6805 * bracketed paste, thus disable it by writing t_BD. */
6806 out_str(T_BD);
6807 else
6808 out_str(T_BE);
6809 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006810 }
6811
6812#ifdef FEAT_LINEBREAK
6813 /* 'showbreak' */
6814 else if (varp == &p_sbr)
6815 {
6816 for (s = p_sbr; *s; )
6817 {
6818 if (ptr2cells(s) != 1)
6819 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006820 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006821 }
6822 }
6823#endif
6824
6825#ifdef FEAT_GUI
6826 /* 'guifont' */
6827 else if (varp == &p_guifont)
6828 {
6829 if (gui.in_use)
6830 {
6831 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006832# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006833 /*
6834 * Put up a font dialog and let the user select a new value.
6835 * If this is cancelled go back to the old value but don't
6836 * give an error message.
6837 */
6838 if (STRCMP(p, "*") == 0)
6839 {
6840 p = gui_mch_font_dialog(oldval);
6841
6842 if (new_value_alloced)
6843 free_string_option(p_guifont);
6844
6845 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6846 new_value_alloced = TRUE;
6847 }
6848# endif
6849 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6850 {
6851# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6852 if (STRCMP(p_guifont, "*") == 0)
6853 {
6854 /* Dialog was cancelled: Keep the old value without giving
6855 * an error message. */
6856 if (new_value_alloced)
6857 free_string_option(p_guifont);
6858 p_guifont = vim_strsave(oldval);
6859 new_value_alloced = TRUE;
6860 }
6861 else
6862# endif
6863 errmsg = (char_u *)N_("E596: Invalid font(s)");
6864 }
6865 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006866 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006867 }
6868# ifdef FEAT_XFONTSET
6869 else if (varp == &p_guifontset)
6870 {
6871 if (STRCMP(p_guifontset, "*") == 0)
6872 errmsg = (char_u *)N_("E597: can't select fontset");
6873 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6874 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006875 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006876 }
6877# endif
6878# ifdef FEAT_MBYTE
6879 else if (varp == &p_guifontwide)
6880 {
6881 if (STRCMP(p_guifontwide, "*") == 0)
6882 errmsg = (char_u *)N_("E533: can't select wide font");
6883 else if (gui_get_wide_font() == FAIL)
6884 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006885 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006886 }
6887# endif
6888#endif
6889
6890#ifdef CURSOR_SHAPE
6891 /* 'guicursor' */
6892 else if (varp == &p_guicursor)
6893 errmsg = parse_shape_opt(SHAPE_CURSOR);
6894#endif
6895
6896#ifdef FEAT_MOUSESHAPE
6897 /* 'mouseshape' */
6898 else if (varp == &p_mouseshape)
6899 {
6900 errmsg = parse_shape_opt(SHAPE_MOUSE);
6901 update_mouseshape(-1);
6902 }
6903#endif
6904
6905#ifdef FEAT_PRINTER
6906 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006907 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006908# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006909 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006910 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006911# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006912#endif
6913
6914#ifdef FEAT_LANGMAP
6915 /* 'langmap' */
6916 else if (varp == &p_langmap)
6917 langmap_set();
6918#endif
6919
6920#ifdef FEAT_LINEBREAK
6921 /* 'breakat' */
6922 else if (varp == &p_breakat)
6923 fill_breakat_flags();
6924#endif
6925
6926#ifdef FEAT_TITLE
6927 /* 'titlestring' and 'iconstring' */
6928 else if (varp == &p_titlestring || varp == &p_iconstring)
6929 {
6930# ifdef FEAT_STL_OPT
6931 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6932
6933 /* NULL => statusline syntax */
6934 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6935 stl_syntax |= flagval;
6936 else
6937 stl_syntax &= ~flagval;
6938# endif
6939 did_set_title(varp == &p_iconstring);
6940
6941 }
6942#endif
6943
6944#ifdef FEAT_GUI
6945 /* 'guioptions' */
6946 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006947 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006948 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006949 redraw_gui_only = TRUE;
6950 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006951#endif
6952
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006953#if defined(FEAT_GUI_TABLINE)
6954 /* 'guitablabel' */
6955 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006956 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006957 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006958 redraw_gui_only = TRUE;
6959 }
6960 /* 'guitabtooltip' */
6961 else if (varp == &p_gtt)
6962 {
6963 redraw_gui_only = TRUE;
6964 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006965#endif
6966
Bram Moolenaar071d4272004-06-13 20:20:40 +00006967#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6968 /* 'ttymouse' */
6969 else if (varp == &p_ttym)
6970 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006971 /* Switch the mouse off before changing the escape sequences used for
6972 * that. */
6973 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006974 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6975 errmsg = e_invarg;
6976 else
6977 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006978 if (termcap_active)
6979 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006980 }
6981#endif
6982
Bram Moolenaar071d4272004-06-13 20:20:40 +00006983 /* 'selection' */
6984 else if (varp == &p_sel)
6985 {
6986 if (*p_sel == NUL
6987 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6988 errmsg = e_invarg;
6989 }
6990
6991 /* 'selectmode' */
6992 else if (varp == &p_slm)
6993 {
6994 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6995 errmsg = e_invarg;
6996 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006997
6998#ifdef FEAT_BROWSE
6999 /* 'browsedir' */
7000 else if (varp == &p_bsdir)
7001 {
7002 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7003 && !mch_isdir(p_bsdir))
7004 errmsg = e_invarg;
7005 }
7006#endif
7007
Bram Moolenaar071d4272004-06-13 20:20:40 +00007008 /* 'keymodel' */
7009 else if (varp == &p_km)
7010 {
7011 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7012 errmsg = e_invarg;
7013 else
7014 {
7015 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7016 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7017 }
7018 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007019
7020 /* 'mousemodel' */
7021 else if (varp == &p_mousem)
7022 {
7023 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7024 errmsg = e_invarg;
7025#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7026 else if (*p_mousem != *oldval)
7027 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7028 * to create or delete the popup menus. */
7029 gui_motif_update_mousemodel(root_menu);
7030#endif
7031 }
7032
7033 /* 'switchbuf' */
7034 else if (varp == &p_swb)
7035 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007036 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007037 errmsg = e_invarg;
7038 }
7039
7040 /* 'debug' */
7041 else if (varp == &p_debug)
7042 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007043 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007044 errmsg = e_invarg;
7045 }
7046
7047 /* 'display' */
7048 else if (varp == &p_dy)
7049 {
7050 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7051 errmsg = e_invarg;
7052 else
7053 (void)init_chartab();
7054
7055 }
7056
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007057#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007058 /* 'eadirection' */
7059 else if (varp == &p_ead)
7060 {
7061 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7062 errmsg = e_invarg;
7063 }
7064#endif
7065
7066#ifdef FEAT_CLIPBOARD
7067 /* 'clipboard' */
7068 else if (varp == &p_cb)
7069 errmsg = check_clipboard_option();
7070#endif
7071
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007072#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007073 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7074 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007075 else if (varp == &(curwin->w_s->b_p_spl)
7076 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007077 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007078 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007079 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007080 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007081 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007082 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007083 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007084 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007085 /* 'spellsuggest' */
7086 else if (varp == &p_sps)
7087 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007088 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007089 errmsg = e_invarg;
7090 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007091 /* 'mkspellmem' */
7092 else if (varp == &p_msm)
7093 {
7094 if (spell_check_msm() != OK)
7095 errmsg = e_invarg;
7096 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007097#endif
7098
Bram Moolenaar071d4272004-06-13 20:20:40 +00007099#ifdef FEAT_QUICKFIX
7100 /* When 'bufhidden' is set, check for valid value. */
7101 else if (gvarp == &p_bh)
7102 {
7103 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7104 errmsg = e_invarg;
7105 }
7106
7107 /* When 'buftype' is set, check for valid value. */
7108 else if (gvarp == &p_bt)
7109 {
7110 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7111 errmsg = e_invarg;
7112 else
7113 {
7114# ifdef FEAT_WINDOWS
7115 if (curwin->w_status_height)
7116 {
7117 curwin->w_redr_status = TRUE;
7118 redraw_later(VALID);
7119 }
7120# endif
7121 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007122# ifdef FEAT_TITLE
7123 redraw_titles();
7124# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007125 }
7126 }
7127#endif
7128
7129#ifdef FEAT_STL_OPT
7130 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007131 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007132 {
7133 int wid;
7134
7135 if (varp == &p_ruf) /* reset ru_wid first */
7136 ru_wid = 0;
7137 s = *varp;
7138 if (varp == &p_ruf && *s == '%')
7139 {
7140 /* set ru_wid if 'ruf' starts with "%99(" */
7141 if (*++s == '-') /* ignore a '-' */
7142 s++;
7143 wid = getdigits(&s);
7144 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7145 ru_wid = wid;
7146 else
7147 errmsg = check_stl_option(p_ruf);
7148 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007149 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007150 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007151 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007152 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007153 comp_col();
7154 }
7155#endif
7156
7157#ifdef FEAT_INS_EXPAND
7158 /* check if it is a valid value for 'complete' -- Acevedo */
7159 else if (gvarp == &p_cpt)
7160 {
7161 for (s = *varp; *s;)
7162 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007163 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007164 s++;
7165 if (!*s)
7166 break;
7167 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7168 {
7169 errmsg = illegal_char(errbuf, *s);
7170 break;
7171 }
7172 if (*++s != NUL && *s != ',' && *s != ' ')
7173 {
7174 if (s[-1] == 'k' || s[-1] == 's')
7175 {
7176 /* skip optional filename after 'k' and 's' */
7177 while (*s && *s != ',' && *s != ' ')
7178 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007179 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007180 ++s;
7181 ++s;
7182 }
7183 }
7184 else
7185 {
7186 if (errbuf != NULL)
7187 {
7188 sprintf((char *)errbuf,
7189 _("E535: Illegal character after <%c>"),
7190 *--s);
7191 errmsg = errbuf;
7192 }
7193 else
7194 errmsg = (char_u *)"";
7195 break;
7196 }
7197 }
7198 }
7199 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007200
7201 /* 'completeopt' */
7202 else if (varp == &p_cot)
7203 {
7204 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7205 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007206 else
7207 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007208 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007209#endif /* FEAT_INS_EXPAND */
7210
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007211#ifdef FEAT_SIGNS
7212 /* 'signcolumn' */
7213 else if (varp == &curwin->w_p_scl)
7214 {
7215 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7216 errmsg = e_invarg;
7217 }
7218#endif
7219
Bram Moolenaar071d4272004-06-13 20:20:40 +00007220
7221#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007222 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007223 else if (varp == &p_toolbar)
7224 {
7225 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7226 &toolbar_flags, TRUE) != OK)
7227 errmsg = e_invarg;
7228 else
7229 {
7230 out_flush();
7231 gui_mch_show_toolbar((toolbar_flags &
7232 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7233 }
7234 }
7235#endif
7236
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007237#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007238 /* 'toolbariconsize': GTK+ 2 only */
7239 else if (varp == &p_tbis)
7240 {
7241 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7242 errmsg = e_invarg;
7243 else
7244 {
7245 out_flush();
7246 gui_mch_show_toolbar((toolbar_flags &
7247 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7248 }
7249 }
7250#endif
7251
7252 /* 'pastetoggle': translate key codes like in a mapping */
7253 else if (varp == &p_pt)
7254 {
7255 if (*p_pt)
7256 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007257 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007258 if (p != NULL)
7259 {
7260 if (new_value_alloced)
7261 free_string_option(p_pt);
7262 p_pt = p;
7263 new_value_alloced = TRUE;
7264 }
7265 }
7266 }
7267
7268 /* 'backspace' */
7269 else if (varp == &p_bs)
7270 {
7271 if (VIM_ISDIGIT(*p_bs))
7272 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007273 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007274 errmsg = e_invarg;
7275 }
7276 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7277 errmsg = e_invarg;
7278 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007279 else if (varp == &p_bo)
7280 {
7281 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7282 errmsg = e_invarg;
7283 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007284
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007285 /* 'tagcase' */
7286 else if (gvarp == &p_tc)
7287 {
7288 unsigned int *flags;
7289
7290 if (opt_flags & OPT_LOCAL)
7291 {
7292 p = curbuf->b_p_tc;
7293 flags = &curbuf->b_tc_flags;
7294 }
7295 else
7296 {
7297 p = p_tc;
7298 flags = &tc_flags;
7299 }
7300
7301 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7302 /* make the local value empty: use the global value */
7303 *flags = 0;
7304 else if (*p == NUL
7305 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7306 errmsg = e_invarg;
7307 }
7308
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007309#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007310 /* 'casemap' */
7311 else if (varp == &p_cmp)
7312 {
7313 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7314 errmsg = e_invarg;
7315 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007316#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007317
7318#ifdef FEAT_DIFF
7319 /* 'diffopt' */
7320 else if (varp == &p_dip)
7321 {
7322 if (diffopt_changed() == FAIL)
7323 errmsg = e_invarg;
7324 }
7325#endif
7326
7327#ifdef FEAT_FOLDING
7328 /* 'foldmethod' */
7329 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7330 {
7331 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7332 || *curwin->w_p_fdm == NUL)
7333 errmsg = e_invarg;
7334 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007335 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007336 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007337 if (foldmethodIsDiff(curwin))
7338 newFoldLevel();
7339 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007340 }
7341# ifdef FEAT_EVAL
7342 /* 'foldexpr' */
7343 else if (varp == &curwin->w_p_fde)
7344 {
7345 if (foldmethodIsExpr(curwin))
7346 foldUpdateAll(curwin);
7347 }
7348# endif
7349 /* 'foldmarker' */
7350 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7351 {
7352 p = vim_strchr(*varp, ',');
7353 if (p == NULL)
7354 errmsg = (char_u *)N_("E536: comma required");
7355 else if (p == *varp || p[1] == NUL)
7356 errmsg = e_invarg;
7357 else if (foldmethodIsMarker(curwin))
7358 foldUpdateAll(curwin);
7359 }
7360 /* 'commentstring' */
7361 else if (gvarp == &p_cms)
7362 {
7363 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7364 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7365 }
7366 /* 'foldopen' */
7367 else if (varp == &p_fdo)
7368 {
7369 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7370 errmsg = e_invarg;
7371 }
7372 /* 'foldclose' */
7373 else if (varp == &p_fcl)
7374 {
7375 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7376 errmsg = e_invarg;
7377 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007378 /* 'foldignore' */
7379 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7380 {
7381 if (foldmethodIsIndent(curwin))
7382 foldUpdateAll(curwin);
7383 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007384#endif
7385
7386#ifdef FEAT_VIRTUALEDIT
7387 /* 'virtualedit' */
7388 else if (varp == &p_ve)
7389 {
7390 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7391 errmsg = e_invarg;
7392 else if (STRCMP(p_ve, oldval) != 0)
7393 {
7394 /* Recompute cursor position in case the new 've' setting
7395 * changes something. */
7396 validate_virtcol();
7397 coladvance(curwin->w_virtcol);
7398 }
7399 }
7400#endif
7401
7402#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7403 else if (varp == &p_csqf)
7404 {
7405 if (p_csqf != NULL)
7406 {
7407 p = p_csqf;
7408 while (*p != NUL)
7409 {
7410 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7411 || p[1] == NUL
7412 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7413 || (p[2] != NUL && p[2] != ','))
7414 {
7415 errmsg = e_invarg;
7416 break;
7417 }
7418 else if (p[2] == NUL)
7419 break;
7420 else
7421 p += 3;
7422 }
7423 }
7424 }
7425#endif
7426
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007427#ifdef FEAT_CINDENT
7428 /* 'cinoptions' */
7429 else if (gvarp == &p_cino)
7430 {
7431 /* TODO: recognize errors */
7432 parse_cino(curbuf);
7433 }
7434#endif
7435
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007436#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007437 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007438 else if (varp == &p_rop && gui.in_use)
7439 {
7440 if (!gui_mch_set_rendering_options(p_rop))
7441 errmsg = e_invarg;
7442 }
7443#endif
7444
Bram Moolenaard0b51382016-11-04 15:23:45 +01007445#ifdef FEAT_AUTOCMD
7446 else if (gvarp == &p_ft)
7447 {
7448 if (!valid_filetype(*varp))
7449 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007450 else
7451 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007452 }
7453#endif
7454
7455#ifdef FEAT_SYN_HL
7456 else if (gvarp == &p_syn)
7457 {
7458 if (!valid_filetype(*varp))
7459 errmsg = e_invarg;
7460 }
7461#endif
7462
Bram Moolenaar071d4272004-06-13 20:20:40 +00007463 /* Options that are a list of flags. */
7464 else
7465 {
7466 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007467 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007468 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007469 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007470 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007471 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007472 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007473 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007474 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007475#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007476 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007477 p = (char_u *)COCU_ALL;
7478#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007479 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007480 {
7481#ifdef FEAT_MOUSE
7482 p = (char_u *)MOUSE_ALL;
7483#else
7484 if (*p_mouse != NUL)
7485 errmsg = (char_u *)N_("E538: No mouse support");
7486#endif
7487 }
7488#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007489 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007490 p = (char_u *)GO_ALL;
7491#endif
7492 if (p != NULL)
7493 {
7494 for (s = *varp; *s; ++s)
7495 if (vim_strchr(p, *s) == NULL)
7496 {
7497 errmsg = illegal_char(errbuf, *s);
7498 break;
7499 }
7500 }
7501 }
7502
7503 /*
7504 * If error detected, restore the previous value.
7505 */
7506 if (errmsg != NULL)
7507 {
7508 if (new_value_alloced)
7509 free_string_option(*varp);
7510 *varp = oldval;
7511 /*
7512 * When resetting some values, need to act on it.
7513 */
7514 if (did_chartab)
7515 (void)init_chartab();
7516 if (varp == &p_hl)
7517 (void)highlight_changed();
7518 }
7519 else
7520 {
7521#ifdef FEAT_EVAL
7522 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007523 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007524#endif
7525 /*
7526 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007527 * Use "free_oldval", because recursiveness may change the flags under
7528 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007529 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007530 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007531 free_string_option(oldval);
7532 if (new_value_alloced)
7533 options[opt_idx].flags |= P_ALLOCED;
7534 else
7535 options[opt_idx].flags &= ~P_ALLOCED;
7536
7537 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007538 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007539 {
7540 /* global option with local value set to use global value; free
7541 * the local value and make it empty */
7542 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7543 free_string_option(*(char_u **)p);
7544 *(char_u **)p = empty_option;
7545 }
7546
7547 /* May set global value for local option. */
7548 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7549 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007550
7551#ifdef FEAT_AUTOCMD
7552 /*
7553 * Trigger the autocommand only after setting the flags.
7554 */
7555# ifdef FEAT_SYN_HL
7556 /* When 'syntax' is set, load the syntax of that name */
7557 if (varp == &(curbuf->b_p_syn))
7558 {
7559 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7560 curbuf->b_fname, TRUE, curbuf);
7561 }
7562# endif
7563 else if (varp == &(curbuf->b_p_ft))
7564 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007565 /* 'filetype' is set, trigger the FileType autocommand.
7566 * Skip this when called from a modeline and the filetype was
7567 * already set to this value. */
7568 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7569 {
7570 did_filetype = TRUE;
7571 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007572 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar163095f2017-07-09 15:41:53 +02007573 /* Just in case the old "curbuf" is now invalid. */
7574 if (varp != &(curbuf->b_p_ft))
7575 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007576 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007577 }
7578#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007579#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007580 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007581 {
7582 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007583 char_u *q = curwin->w_s->b_p_spl;
7584
7585 /* Skip the first name if it is "cjk". */
7586 if (STRNCMP(q, "cjk,", 4) == 0)
7587 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007588
7589 /*
7590 * Source the spell/LANG.vim in 'runtimepath'.
7591 * They could set 'spellcapcheck' depending on the language.
7592 * Use the first name in 'spelllang' up to '_region' or
7593 * '.encoding'.
7594 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007595 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007596 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7597 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007598 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007599 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007600 }
7601#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007602 }
7603
7604#ifdef FEAT_MOUSE
7605 if (varp == &p_mouse)
7606 {
7607# ifdef FEAT_MOUSE_TTY
7608 if (*p_mouse == NUL)
7609 mch_setmouse(FALSE); /* switch mouse off */
7610 else
7611# endif
7612 setmouse(); /* in case 'mouse' changed */
7613 }
7614#endif
7615
Bram Moolenaar913077c2012-03-28 19:59:04 +02007616 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007617 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007618 curwin->w_set_curswant = TRUE;
7619
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007620#ifdef FEAT_GUI
7621 /* check redraw when it's not a GUI option or the GUI is active. */
7622 if (!redraw_gui_only || gui.in_use)
7623#endif
7624 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007625
7626 return errmsg;
7627}
7628
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007629#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007630/*
7631 * Simple int comparison function for use with qsort()
7632 */
7633 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007634int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007635{
7636 return *(const int *)a - *(const int *)b;
7637}
7638
7639/*
7640 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7641 * Returns error message, NULL if it's OK.
7642 */
7643 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007644check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007645{
7646 char_u *s;
7647 int col;
7648 int count = 0;
7649 int color_cols[256];
7650 int i;
7651 int j = 0;
7652
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007653 if (wp->w_buffer == NULL)
7654 return NULL; /* buffer was closed */
7655
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007656 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007657 {
7658 if (*s == '-' || *s == '+')
7659 {
7660 /* -N and +N: add to 'textwidth' */
7661 col = (*s == '-') ? -1 : 1;
7662 ++s;
7663 if (!VIM_ISDIGIT(*s))
7664 return e_invarg;
7665 col = col * getdigits(&s);
7666 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007667 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007668 col += wp->w_buffer->b_p_tw;
7669 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007670 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007671 }
7672 else if (VIM_ISDIGIT(*s))
7673 col = getdigits(&s);
7674 else
7675 return e_invarg;
7676 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007677skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007678 if (*s == NUL)
7679 break;
7680 if (*s != ',')
7681 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007682 if (*++s == NUL)
7683 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007684 }
7685
7686 vim_free(wp->w_p_cc_cols);
7687 if (count == 0)
7688 wp->w_p_cc_cols = NULL;
7689 else
7690 {
7691 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7692 if (wp->w_p_cc_cols != NULL)
7693 {
7694 /* sort the columns for faster usage on screen redraw inside
7695 * win_line() */
7696 qsort(color_cols, count, sizeof(int), int_cmp);
7697
7698 for (i = 0; i < count; ++i)
7699 /* skip duplicates */
7700 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7701 wp->w_p_cc_cols[j++] = color_cols[i];
7702 wp->w_p_cc_cols[j] = -1; /* end marker */
7703 }
7704 }
7705
7706 return NULL; /* no error */
7707}
7708#endif
7709
Bram Moolenaar071d4272004-06-13 20:20:40 +00007710/*
7711 * Handle setting 'listchars' or 'fillchars'.
7712 * Returns error message, NULL if it's OK.
7713 */
7714 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007715set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007716{
7717 int round, i, len, entries;
7718 char_u *p, *s;
7719 int c1, c2 = 0;
7720 struct charstab
7721 {
7722 int *cp;
7723 char *name;
7724 };
7725#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7726 static struct charstab filltab[] =
7727 {
7728 {&fill_stl, "stl"},
7729 {&fill_stlnc, "stlnc"},
7730 {&fill_vert, "vert"},
7731 {&fill_fold, "fold"},
7732 {&fill_diff, "diff"},
7733 };
7734#endif
7735 static struct charstab lcstab[] =
7736 {
7737 {&lcs_eol, "eol"},
7738 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007739 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007740 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007741 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007742 {&lcs_tab2, "tab"},
7743 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007744#ifdef FEAT_CONCEAL
7745 {&lcs_conceal, "conceal"},
7746#else
7747 {NULL, "conceal"},
7748#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007749 };
7750 struct charstab *tab;
7751
7752#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7753 if (varp == &p_lcs)
7754#endif
7755 {
7756 tab = lcstab;
7757 entries = sizeof(lcstab) / sizeof(struct charstab);
7758 }
7759#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7760 else
7761 {
7762 tab = filltab;
7763 entries = sizeof(filltab) / sizeof(struct charstab);
7764 }
7765#endif
7766
7767 /* first round: check for valid value, second round: assign values */
7768 for (round = 0; round <= 1; ++round)
7769 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007770 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007771 {
7772 /* After checking that the value is valid: set defaults: space for
7773 * 'fillchars', NUL for 'listchars' */
7774 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007775 if (tab[i].cp != NULL)
7776 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007777 if (varp == &p_lcs)
7778 lcs_tab1 = NUL;
7779#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7780 else
7781 fill_diff = '-';
7782#endif
7783 }
7784 p = *varp;
7785 while (*p)
7786 {
7787 for (i = 0; i < entries; ++i)
7788 {
7789 len = (int)STRLEN(tab[i].name);
7790 if (STRNCMP(p, tab[i].name, len) == 0
7791 && p[len] == ':'
7792 && p[len + 1] != NUL)
7793 {
7794 s = p + len + 1;
7795#ifdef FEAT_MBYTE
7796 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007797 if (mb_char2cells(c1) > 1)
7798 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007799#else
7800 c1 = *s++;
7801#endif
7802 if (tab[i].cp == &lcs_tab2)
7803 {
7804 if (*s == NUL)
7805 continue;
7806#ifdef FEAT_MBYTE
7807 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007808 if (mb_char2cells(c2) > 1)
7809 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007810#else
7811 c2 = *s++;
7812#endif
7813 }
7814 if (*s == ',' || *s == NUL)
7815 {
7816 if (round)
7817 {
7818 if (tab[i].cp == &lcs_tab2)
7819 {
7820 lcs_tab1 = c1;
7821 lcs_tab2 = c2;
7822 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007823 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007824 *(tab[i].cp) = c1;
7825
7826 }
7827 p = s;
7828 break;
7829 }
7830 }
7831 }
7832
7833 if (i == entries)
7834 return e_invarg;
7835 if (*p == ',')
7836 ++p;
7837 }
7838 }
7839
7840 return NULL; /* no error */
7841}
7842
7843#ifdef FEAT_STL_OPT
7844/*
7845 * Check validity of options with the 'statusline' format.
7846 * Return error message or NULL.
7847 */
7848 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007849check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007850{
7851 int itemcnt = 0;
7852 int groupdepth = 0;
7853 static char_u errbuf[80];
7854
7855 while (*s && itemcnt < STL_MAX_ITEM)
7856 {
7857 /* Check for valid keys after % sequences */
7858 while (*s && *s != '%')
7859 s++;
7860 if (!*s)
7861 break;
7862 s++;
7863 if (*s != '%' && *s != ')')
7864 ++itemcnt;
7865 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7866 {
7867 s++;
7868 continue;
7869 }
7870 if (*s == ')')
7871 {
7872 s++;
7873 if (--groupdepth < 0)
7874 break;
7875 continue;
7876 }
7877 if (*s == '-')
7878 s++;
7879 while (VIM_ISDIGIT(*s))
7880 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007881 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007882 continue;
7883 if (*s == '.')
7884 {
7885 s++;
7886 while (*s && VIM_ISDIGIT(*s))
7887 s++;
7888 }
7889 if (*s == '(')
7890 {
7891 groupdepth++;
7892 continue;
7893 }
7894 if (vim_strchr(STL_ALL, *s) == NULL)
7895 {
7896 return illegal_char(errbuf, *s);
7897 }
7898 if (*s == '{')
7899 {
7900 s++;
7901 while (*s != '}' && *s)
7902 s++;
7903 if (*s != '}')
7904 return (char_u *)N_("E540: Unclosed expression sequence");
7905 }
7906 }
7907 if (itemcnt >= STL_MAX_ITEM)
7908 return (char_u *)N_("E541: too many items");
7909 if (groupdepth != 0)
7910 return (char_u *)N_("E542: unbalanced groups");
7911 return NULL;
7912}
7913#endif
7914
7915#ifdef FEAT_CLIPBOARD
7916/*
7917 * Extract the items in the 'clipboard' option and set global values.
7918 */
7919 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007920check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007921{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007922 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007923 int new_autoselect_star = FALSE;
7924 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007925 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007926 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007927 regprog_T *new_exclude_prog = NULL;
7928 char_u *errmsg = NULL;
7929 char_u *p;
7930
7931 for (p = p_cb; *p != NUL; )
7932 {
7933 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7934 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007935 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007936 p += 7;
7937 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007938 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007939 && (p[11] == ',' || p[11] == NUL))
7940 {
7941 new_unnamed |= CLIP_UNNAMED_PLUS;
7942 p += 11;
7943 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007944 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007945 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007946 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007947 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007948 p += 10;
7949 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007950 else if (STRNCMP(p, "autoselectplus", 14) == 0
7951 && (p[14] == ',' || p[14] == NUL))
7952 {
7953 new_autoselect_plus = TRUE;
7954 p += 14;
7955 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007956 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007957 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007958 {
7959 new_autoselectml = TRUE;
7960 p += 12;
7961 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007962 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7963 {
7964 new_html = TRUE;
7965 p += 4;
7966 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007967 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7968 {
7969 p += 8;
7970 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7971 if (new_exclude_prog == NULL)
7972 errmsg = e_invarg;
7973 break;
7974 }
7975 else
7976 {
7977 errmsg = e_invarg;
7978 break;
7979 }
7980 if (*p == ',')
7981 ++p;
7982 }
7983 if (errmsg == NULL)
7984 {
7985 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007986 clip_autoselect_star = new_autoselect_star;
7987 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007988 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007989 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007990 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007991 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007992#ifdef FEAT_GUI_GTK
7993 if (gui.in_use)
7994 {
7995 gui_gtk_set_selection_targets();
7996 gui_gtk_set_dnd_targets();
7997 }
7998#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007999 }
8000 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008001 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008002
8003 return errmsg;
8004}
8005#endif
8006
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008007#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008008 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008009did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008010{
8011 char_u *errmsg = NULL;
8012 win_T *wp;
8013 int l;
8014
8015 if (is_spellfile)
8016 {
8017 l = (int)STRLEN(curwin->w_s->b_p_spf);
8018 if (l > 0 && (l < 4
8019 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8020 errmsg = e_invarg;
8021 }
8022
8023 if (errmsg == NULL)
8024 {
8025 FOR_ALL_WINDOWS(wp)
8026 if (wp->w_buffer == curbuf && wp->w_p_spell)
8027 {
8028 errmsg = did_set_spelllang(wp);
8029# ifdef FEAT_WINDOWS
8030 break;
8031# endif
8032 }
8033 }
8034 return errmsg;
8035}
8036
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008037/*
8038 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8039 * Return error message when failed, NULL when OK.
8040 */
8041 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008042compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008043{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008044 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008045 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008046
Bram Moolenaar860cae12010-06-05 23:22:07 +02008047 if (*synblock->b_p_spc == NUL)
8048 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008049 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008050 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008051 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008052 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008053 if (re != NULL)
8054 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008055 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008056 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008057 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008058 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008059 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008060 return e_invarg;
8061 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008062 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008063 }
8064
Bram Moolenaar473de612013-06-08 18:19:48 +02008065 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008066 return NULL;
8067}
8068#endif
8069
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008070#if defined(FEAT_EVAL) || defined(PROTO)
8071/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008072 * Set the scriptID for an option, taking care of setting the buffer- or
8073 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008074 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008075 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008076set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008077{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008078 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8079 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008080
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008081 /* Remember where the option was set. For local options need to do that
8082 * in the buffer or window structure. */
8083 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008084 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008085 if (both || (opt_flags & OPT_LOCAL))
8086 {
8087 if (indir & PV_BUF)
8088 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8089 else if (indir & PV_WIN)
8090 curwin->w_p_scriptID[indir & PV_MASK] = id;
8091 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008092}
8093#endif
8094
Bram Moolenaar071d4272004-06-13 20:20:40 +00008095/*
8096 * Set the value of a boolean option, and take care of side effects.
8097 * Returns NULL for success, or an error message for an error.
8098 */
8099 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008100set_bool_option(
8101 int opt_idx, /* index in options[] table */
8102 char_u *varp, /* pointer to the option variable */
8103 int value, /* new value */
8104 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008105{
8106 int old_value = *(int *)varp;
8107
Bram Moolenaar071d4272004-06-13 20:20:40 +00008108 /* Disallow changing some options from secure mode */
8109 if ((secure
8110#ifdef HAVE_SANDBOX
8111 || sandbox != 0
8112#endif
8113 ) && (options[opt_idx].flags & P_SECURE))
8114 return e_secure;
8115
8116 *(int *)varp = value; /* set the new value */
8117#ifdef FEAT_EVAL
8118 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008119 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008120#endif
8121
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008122#ifdef FEAT_GUI
8123 need_mouse_correct = TRUE;
8124#endif
8125
Bram Moolenaar071d4272004-06-13 20:20:40 +00008126 /* May set global value for local option. */
8127 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8128 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8129
8130 /*
8131 * Handle side effects of changing a bool option.
8132 */
8133
8134 /* 'compatible' */
8135 if ((int *)varp == &p_cp)
8136 {
8137 compatible_set();
8138 }
8139
Bram Moolenaar920694c2016-08-21 17:45:02 +02008140#ifdef FEAT_LANGMAP
8141 if ((int *)varp == &p_lrm)
8142 /* 'langremap' -> !'langnoremap' */
8143 p_lnr = !p_lrm;
8144 else if ((int *)varp == &p_lnr)
8145 /* 'langnoremap' -> !'langremap' */
8146 p_lrm = !p_lnr;
8147#endif
8148
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008149#ifdef FEAT_PERSISTENT_UNDO
8150 /* 'undofile' */
8151 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8152 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008153 /* Only take action when the option was set. When reset we do not
8154 * delete the undo file, the option may be set again without making
8155 * any changes in between. */
8156 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008157 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008158 char_u hash[UNDO_HASH_SIZE];
8159 buf_T *save_curbuf = curbuf;
8160
Bram Moolenaar29323592016-07-24 22:04:11 +02008161 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008162 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008163 /* When 'undofile' is set globally: for every buffer, otherwise
8164 * only for the current buffer: Try to read in the undofile,
8165 * if one exists, the buffer wasn't changed and the buffer was
8166 * loaded */
8167 if ((curbuf == save_curbuf
8168 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8169 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8170 {
8171 u_compute_hash(hash);
8172 u_read_undo(NULL, hash, curbuf->b_fname);
8173 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008174 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008175 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008176 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008177 }
8178#endif
8179
Bram Moolenaar071d4272004-06-13 20:20:40 +00008180 else if ((int *)varp == &curbuf->b_p_ro)
8181 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008182 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008183 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8184 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008185
8186 /* when 'readonly' is set may give W10 again */
8187 if (curbuf->b_p_ro)
8188 curbuf->b_did_warn = FALSE;
8189
Bram Moolenaar071d4272004-06-13 20:20:40 +00008190#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008191 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008192#endif
8193 }
8194
Bram Moolenaar9c449722010-07-20 18:44:27 +02008195#ifdef FEAT_GUI
8196 else if ((int *)varp == &p_mh)
8197 {
8198 if (!p_mh)
8199 gui_mch_mousehide(FALSE);
8200 }
8201#endif
8202
Bram Moolenaara539df02010-08-01 14:35:05 +02008203#ifdef FEAT_TITLE
8204 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008205 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008206 {
8207 redraw_titles();
8208 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008209 /* when 'endofline' is changed, redraw the window title */
8210 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008211 {
8212 redraw_titles();
8213 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008214 /* when 'fixeol' is changed, redraw the window title */
8215 else if ((int *)varp == &curbuf->b_p_fixeol)
8216 {
8217 redraw_titles();
8218 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008219# ifdef FEAT_MBYTE
8220 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008221 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008222 {
8223 redraw_titles();
8224 }
8225# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008226#endif
8227
8228 /* when 'bin' is set also set some other options */
8229 else if ((int *)varp == &curbuf->b_p_bin)
8230 {
8231 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8232#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008233 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008234#endif
8235 }
8236
8237#ifdef FEAT_AUTOCMD
8238 /* when 'buflisted' changes, trigger autocommands */
8239 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8240 {
8241 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8242 NULL, NULL, TRUE, curbuf);
8243 }
8244#endif
8245
8246 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8247 else if ((int *)varp == &curbuf->b_p_swf)
8248 {
8249 if (curbuf->b_p_swf && p_uc)
8250 ml_open_file(curbuf); /* create the swap file */
8251 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008252 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8253 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008254 mf_close_file(curbuf, TRUE); /* remove the swap file */
8255 }
8256
8257 /* when 'terse' is set change 'shortmess' */
8258 else if ((int *)varp == &p_terse)
8259 {
8260 char_u *p;
8261
8262 p = vim_strchr(p_shm, SHM_SEARCH);
8263
8264 /* insert 's' in p_shm */
8265 if (p_terse && p == NULL)
8266 {
8267 STRCPY(IObuff, p_shm);
8268 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008269 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008270 }
8271 /* remove 's' from p_shm */
8272 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008273 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008274 }
8275
8276 /* when 'paste' is set or reset also change other options */
8277 else if ((int *)varp == &p_paste)
8278 {
8279 paste_option_changed();
8280 }
8281
8282 /* when 'insertmode' is set from an autocommand need to do work here */
8283 else if ((int *)varp == &p_im)
8284 {
8285 if (p_im)
8286 {
8287 if ((State & INSERT) == 0)
8288 need_start_insertmode = TRUE;
8289 stop_insert_mode = FALSE;
8290 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008291 /* only reset if it was set previously */
8292 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008293 {
8294 need_start_insertmode = FALSE;
8295 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008296 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008297 clear_cmdline = TRUE; /* remove "(insert)" */
8298 restart_edit = 0;
8299 }
8300 }
8301
8302 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8303 else if ((int *)varp == &p_ic && p_hls)
8304 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008305 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008306 }
8307
8308#ifdef FEAT_SEARCH_EXTRA
8309 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8310 else if ((int *)varp == &p_hls)
8311 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008312 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008313 }
8314#endif
8315
8316#ifdef FEAT_SCROLLBIND
8317 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8318 * at the end of normal_cmd() */
8319 else if ((int *)varp == &curwin->w_p_scb)
8320 {
8321 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008322 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008323 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008324 curwin->w_scbind_pos = curwin->w_topline;
8325 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008326 }
8327#endif
8328
8329#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8330 /* There can be only one window with 'previewwindow' set. */
8331 else if ((int *)varp == &curwin->w_p_pvw)
8332 {
8333 if (curwin->w_p_pvw)
8334 {
8335 win_T *win;
8336
Bram Moolenaar29323592016-07-24 22:04:11 +02008337 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008338 if (win->w_p_pvw && win != curwin)
8339 {
8340 curwin->w_p_pvw = FALSE;
8341 return (char_u *)N_("E590: A preview window already exists");
8342 }
8343 }
8344 }
8345#endif
8346
8347 /* when 'textmode' is set or reset also change 'fileformat' */
8348 else if ((int *)varp == &curbuf->b_p_tx)
8349 {
8350 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8351 }
8352
8353 /* when 'textauto' is set or reset also change 'fileformats' */
8354 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008355 set_string_option_direct((char_u *)"ffs", -1,
8356 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008357 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358
8359 /*
8360 * When 'lisp' option changes include/exclude '-' in
8361 * keyword characters.
8362 */
8363#ifdef FEAT_LISP
8364 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8365 {
8366 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8367 }
8368#endif
8369
8370#ifdef FEAT_TITLE
8371 /* when 'title' changed, may need to change the title; same for 'icon' */
8372 else if ((int *)varp == &p_title)
8373 {
8374 did_set_title(FALSE);
8375 }
8376
8377 else if ((int *)varp == &p_icon)
8378 {
8379 did_set_title(TRUE);
8380 }
8381#endif
8382
8383 else if ((int *)varp == &curbuf->b_changed)
8384 {
8385 if (!value)
8386 save_file_ff(curbuf); /* Buffer is unchanged */
8387#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008388 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008389#endif
8390#ifdef FEAT_AUTOCMD
8391 modified_was_set = value;
8392#endif
8393 }
8394
8395#ifdef BACKSLASH_IN_FILENAME
8396 else if ((int *)varp == &p_ssl)
8397 {
8398 if (p_ssl)
8399 {
8400 psepc = '/';
8401 psepcN = '\\';
8402 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008403 }
8404 else
8405 {
8406 psepc = '\\';
8407 psepcN = '/';
8408 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008409 }
8410
8411 /* need to adjust the file name arguments and buffer names. */
8412 buflist_slash_adjust();
8413 alist_slash_adjust();
8414# ifdef FEAT_EVAL
8415 scriptnames_slash_adjust();
8416# endif
8417 }
8418#endif
8419
8420 /* If 'wrap' is set, set w_leftcol to zero. */
8421 else if ((int *)varp == &curwin->w_p_wrap)
8422 {
8423 if (curwin->w_p_wrap)
8424 curwin->w_leftcol = 0;
8425 }
8426
8427#ifdef FEAT_WINDOWS
8428 else if ((int *)varp == &p_ea)
8429 {
8430 if (p_ea && !old_value)
8431 win_equal(curwin, FALSE, 0);
8432 }
8433#endif
8434
8435 else if ((int *)varp == &p_wiv)
8436 {
8437 /*
8438 * When 'weirdinvert' changed, set/reset 't_xs'.
8439 * Then set 'weirdinvert' according to value of 't_xs'.
8440 */
8441 if (p_wiv && !old_value)
8442 T_XS = (char_u *)"y";
8443 else if (!p_wiv && old_value)
8444 T_XS = empty_option;
8445 p_wiv = (*T_XS != NUL);
8446 }
8447
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008448#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008449 else if ((int *)varp == &p_beval)
8450 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008451 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008452 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008453 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008454 gui_mch_disable_beval_area(balloonEval);
8455 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008456#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008457
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008458#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008459 else if ((int *)varp == &p_acd)
8460 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008461 /* Change directories when the 'acd' option is set now. */
8462 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008463 }
8464#endif
8465
8466#ifdef FEAT_DIFF
8467 /* 'diff' */
8468 else if ((int *)varp == &curwin->w_p_diff)
8469 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008470 /* May add or remove the buffer from the list of diff buffers. */
8471 diff_buf_adjust(curwin);
8472# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008473 if (foldmethodIsDiff(curwin))
8474 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008475# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008476 }
8477#endif
8478
8479#ifdef USE_IM_CONTROL
8480 /* 'imdisable' */
8481 else if ((int *)varp == &p_imdisable)
8482 {
8483 /* Only de-activate it here, it will be enabled when changing mode. */
8484 if (p_imdisable)
8485 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008486 else if (State & INSERT)
8487 /* When the option is set from an autocommand, it may need to take
8488 * effect right away. */
8489 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008490 }
8491#endif
8492
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008493#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008494 /* 'spell' */
8495 else if ((int *)varp == &curwin->w_p_spell)
8496 {
8497 if (curwin->w_p_spell)
8498 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008499 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008500 if (errmsg != NULL)
8501 EMSG(_(errmsg));
8502 }
8503 }
8504#endif
8505
Bram Moolenaar071d4272004-06-13 20:20:40 +00008506#ifdef FEAT_FKMAP
8507 else if ((int *)varp == &p_altkeymap)
8508 {
8509 if (old_value != p_altkeymap)
8510 {
8511 if (!p_altkeymap)
8512 {
8513 p_hkmap = p_fkmap;
8514 p_fkmap = 0;
8515 }
8516 else
8517 {
8518 p_fkmap = p_hkmap;
8519 p_hkmap = 0;
8520 }
8521 (void)init_chartab();
8522 }
8523 }
8524
8525 /*
8526 * In case some second language keymapping options have changed, check
8527 * and correct the setting in a consistent way.
8528 */
8529
8530 /*
8531 * If hkmap or fkmap are set, reset Arabic keymapping.
8532 */
8533 if ((p_hkmap || p_fkmap) && p_altkeymap)
8534 {
8535 p_altkeymap = p_fkmap;
8536# ifdef FEAT_ARABIC
8537 curwin->w_p_arab = FALSE;
8538# endif
8539 (void)init_chartab();
8540 }
8541
8542 /*
8543 * If hkmap set, reset Farsi keymapping.
8544 */
8545 if (p_hkmap && p_altkeymap)
8546 {
8547 p_altkeymap = 0;
8548 p_fkmap = 0;
8549# ifdef FEAT_ARABIC
8550 curwin->w_p_arab = FALSE;
8551# endif
8552 (void)init_chartab();
8553 }
8554
8555 /*
8556 * If fkmap set, reset Hebrew keymapping.
8557 */
8558 if (p_fkmap && !p_altkeymap)
8559 {
8560 p_altkeymap = 1;
8561 p_hkmap = 0;
8562# ifdef FEAT_ARABIC
8563 curwin->w_p_arab = FALSE;
8564# endif
8565 (void)init_chartab();
8566 }
8567#endif
8568
8569#ifdef FEAT_ARABIC
8570 if ((int *)varp == &curwin->w_p_arab)
8571 {
8572 if (curwin->w_p_arab)
8573 {
8574 /*
8575 * 'arabic' is set, handle various sub-settings.
8576 */
8577 if (!p_tbidi)
8578 {
8579 /* set rightleft mode */
8580 if (!curwin->w_p_rl)
8581 {
8582 curwin->w_p_rl = TRUE;
8583 changed_window_setting();
8584 }
8585
8586 /* Enable Arabic shaping (major part of what Arabic requires) */
8587 if (!p_arshape)
8588 {
8589 p_arshape = TRUE;
8590 redraw_later_clear();
8591 }
8592 }
8593
8594 /* Arabic requires a utf-8 encoding, inform the user if its not
8595 * set. */
8596 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008597 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008598 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8599
Bram Moolenaar8820b482017-03-16 17:23:31 +01008600 msg_source(HL_ATTR(HLF_W));
8601 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008602#ifdef FEAT_EVAL
8603 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8604#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008605 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008606
8607# ifdef FEAT_MBYTE
8608 /* set 'delcombine' */
8609 p_deco = TRUE;
8610# endif
8611
8612# ifdef FEAT_KEYMAP
8613 /* Force-set the necessary keymap for arabic */
8614 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8615 OPT_LOCAL);
8616# endif
8617# ifdef FEAT_FKMAP
8618 p_altkeymap = 0;
8619 p_hkmap = 0;
8620 p_fkmap = 0;
8621 (void)init_chartab();
8622# endif
8623 }
8624 else
8625 {
8626 /*
8627 * 'arabic' is reset, handle various sub-settings.
8628 */
8629 if (!p_tbidi)
8630 {
8631 /* reset rightleft mode */
8632 if (curwin->w_p_rl)
8633 {
8634 curwin->w_p_rl = FALSE;
8635 changed_window_setting();
8636 }
8637
8638 /* 'arabicshape' isn't reset, it is a global option and
8639 * another window may still need it "on". */
8640 }
8641
8642 /* 'delcombine' isn't reset, it is a global option and another
8643 * window may still want it "on". */
8644
8645# ifdef FEAT_KEYMAP
8646 /* Revert to the default keymap */
8647 curbuf->b_p_iminsert = B_IMODE_NONE;
8648 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8649# endif
8650 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008651 }
8652
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008653#endif
8654
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008655#ifdef FEAT_TERMGUICOLORS
8656 /* 'termguicolors' */
8657 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008658 {
8659# ifdef FEAT_GUI
8660 if (!gui.in_use && !gui.starting)
8661# endif
8662 highlight_gui_started();
8663 }
8664#endif
8665
Bram Moolenaar071d4272004-06-13 20:20:40 +00008666 /*
8667 * End of handling side effects for bool options.
8668 */
8669
Bram Moolenaar53744302015-07-17 17:38:22 +02008670 /* after handling side effects, call autocommand */
8671
Bram Moolenaar071d4272004-06-13 20:20:40 +00008672 options[opt_idx].flags |= P_WAS_SET;
8673
Bram Moolenaar53744302015-07-17 17:38:22 +02008674#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8675 if (!starting)
8676 {
8677 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008678 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8679 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8680 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008681 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8682 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8683 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8684 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8685 reset_v_option_vars();
8686 }
8687#endif
8688
Bram Moolenaar071d4272004-06-13 20:20:40 +00008689 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008690 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008691 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008692 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008693 check_redraw(options[opt_idx].flags);
8694
8695 return NULL;
8696}
8697
8698/*
8699 * Set the value of a number option, and take care of side effects.
8700 * Returns NULL for success, or an error message for an error.
8701 */
8702 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008703set_num_option(
8704 int opt_idx, /* index in options[] table */
8705 char_u *varp, /* pointer to the option variable */
8706 long value, /* new value */
8707 char_u *errbuf, /* buffer for error messages */
8708 size_t errbuflen, /* length of "errbuf" */
8709 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008710 OPT_MODELINE */
8711{
8712 char_u *errmsg = NULL;
8713 long old_value = *(long *)varp;
8714 long old_Rows = Rows; /* remember old Rows */
8715 long old_Columns = Columns; /* remember old Columns */
8716 long *pp = (long *)varp;
8717
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008718 /* Disallow changing some options from secure mode. */
8719 if ((secure
8720#ifdef HAVE_SANDBOX
8721 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008722#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008723 ) && (options[opt_idx].flags & P_SECURE))
8724 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008725
8726 *pp = value;
8727#ifdef FEAT_EVAL
8728 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008729 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008730#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008731#ifdef FEAT_GUI
8732 need_mouse_correct = TRUE;
8733#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008734
Bram Moolenaar14f24742012-08-08 18:01:05 +02008735 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008736 {
8737 errmsg = e_positive;
8738 curbuf->b_p_sw = curbuf->b_p_ts;
8739 }
8740
8741 /*
8742 * Number options that need some action when changed
8743 */
8744#ifdef FEAT_WINDOWS
8745 if (pp == &p_wh || pp == &p_hh)
8746 {
8747 if (p_wh < 1)
8748 {
8749 errmsg = e_positive;
8750 p_wh = 1;
8751 }
8752 if (p_wmh > p_wh)
8753 {
8754 errmsg = e_winheight;
8755 p_wh = p_wmh;
8756 }
8757 if (p_hh < 0)
8758 {
8759 errmsg = e_positive;
8760 p_hh = 0;
8761 }
8762
8763 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008764 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008765 {
8766 if (pp == &p_wh && curwin->w_height < p_wh)
8767 win_setheight((int)p_wh);
8768 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8769 win_setheight((int)p_hh);
8770 }
8771 }
8772
8773 /* 'winminheight' */
8774 else if (pp == &p_wmh)
8775 {
8776 if (p_wmh < 0)
8777 {
8778 errmsg = e_positive;
8779 p_wmh = 0;
8780 }
8781 if (p_wmh > p_wh)
8782 {
8783 errmsg = e_winheight;
8784 p_wmh = p_wh;
8785 }
8786 win_setminheight();
8787 }
8788
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008789# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008790 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008791 {
8792 if (p_wiw < 1)
8793 {
8794 errmsg = e_positive;
8795 p_wiw = 1;
8796 }
8797 if (p_wmw > p_wiw)
8798 {
8799 errmsg = e_winwidth;
8800 p_wiw = p_wmw;
8801 }
8802
8803 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008804 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008805 win_setwidth((int)p_wiw);
8806 }
8807
8808 /* 'winminwidth' */
8809 else if (pp == &p_wmw)
8810 {
8811 if (p_wmw < 0)
8812 {
8813 errmsg = e_positive;
8814 p_wmw = 0;
8815 }
8816 if (p_wmw > p_wiw)
8817 {
8818 errmsg = e_winwidth;
8819 p_wmw = p_wiw;
8820 }
8821 win_setminheight();
8822 }
8823# endif
8824
8825#endif
8826
8827#ifdef FEAT_WINDOWS
8828 /* (re)set last window status line */
8829 else if (pp == &p_ls)
8830 {
8831 last_status(FALSE);
8832 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008833
8834 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008835 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008836 {
8837 shell_new_rows(); /* recompute window positions and heights */
8838 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008839#endif
8840
8841#ifdef FEAT_GUI
8842 else if (pp == &p_linespace)
8843 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008844 /* Recompute gui.char_height and resize the Vim window to keep the
8845 * same number of lines. */
8846 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008847 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008848 }
8849#endif
8850
8851#ifdef FEAT_FOLDING
8852 /* 'foldlevel' */
8853 else if (pp == &curwin->w_p_fdl)
8854 {
8855 if (curwin->w_p_fdl < 0)
8856 curwin->w_p_fdl = 0;
8857 newFoldLevel();
8858 }
8859
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008860 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008861 else if (pp == &curwin->w_p_fml)
8862 {
8863 foldUpdateAll(curwin);
8864 }
8865
8866 /* 'foldnestmax' */
8867 else if (pp == &curwin->w_p_fdn)
8868 {
8869 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8870 foldUpdateAll(curwin);
8871 }
8872
8873 /* 'foldcolumn' */
8874 else if (pp == &curwin->w_p_fdc)
8875 {
8876 if (curwin->w_p_fdc < 0)
8877 {
8878 errmsg = e_positive;
8879 curwin->w_p_fdc = 0;
8880 }
8881 else if (curwin->w_p_fdc > 12)
8882 {
8883 errmsg = e_invarg;
8884 curwin->w_p_fdc = 12;
8885 }
8886 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008887#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008888
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008889#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008890 /* 'shiftwidth' or 'tabstop' */
8891 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8892 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008893# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008894 if (foldmethodIsIndent(curwin))
8895 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008896# endif
8897# ifdef FEAT_CINDENT
8898 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8899 * parse 'cinoptions'. */
8900 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8901 parse_cino(curbuf);
8902# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008903 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008904#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008905
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008906#ifdef FEAT_MBYTE
8907 /* 'maxcombine' */
8908 else if (pp == &p_mco)
8909 {
8910 if (p_mco > MAX_MCO)
8911 p_mco = MAX_MCO;
8912 else if (p_mco < 0)
8913 p_mco = 0;
8914 screenclear(); /* will re-allocate the screen */
8915 }
8916#endif
8917
Bram Moolenaar071d4272004-06-13 20:20:40 +00008918 else if (pp == &curbuf->b_p_iminsert)
8919 {
8920 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8921 {
8922 errmsg = e_invarg;
8923 curbuf->b_p_iminsert = B_IMODE_NONE;
8924 }
8925 p_iminsert = curbuf->b_p_iminsert;
8926 if (termcap_active) /* don't do this in the alternate screen */
8927 showmode();
8928#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8929 /* Show/unshow value of 'keymap' in status lines. */
8930 status_redraw_curbuf();
8931#endif
8932 }
8933
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008934 else if (pp == &p_window)
8935 {
8936 if (p_window < 1)
8937 p_window = 1;
8938 else if (p_window >= Rows)
8939 p_window = Rows - 1;
8940 }
8941
Bram Moolenaar071d4272004-06-13 20:20:40 +00008942 else if (pp == &curbuf->b_p_imsearch)
8943 {
8944 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8945 {
8946 errmsg = e_invarg;
8947 curbuf->b_p_imsearch = B_IMODE_NONE;
8948 }
8949 p_imsearch = curbuf->b_p_imsearch;
8950 }
8951
8952#ifdef FEAT_TITLE
8953 /* if 'titlelen' has changed, redraw the title */
8954 else if (pp == &p_titlelen)
8955 {
8956 if (p_titlelen < 0)
8957 {
8958 errmsg = e_positive;
8959 p_titlelen = 85;
8960 }
8961 if (starting != NO_SCREEN && old_value != p_titlelen)
8962 need_maketitle = TRUE;
8963 }
8964#endif
8965
8966 /* if p_ch changed value, change the command line height */
8967 else if (pp == &p_ch)
8968 {
8969 if (p_ch < 1)
8970 {
8971 errmsg = e_positive;
8972 p_ch = 1;
8973 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008974 if (p_ch > Rows - min_rows() + 1)
8975 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008976
8977 /* Only compute the new window layout when startup has been
8978 * completed. Otherwise the frame sizes may be wrong. */
8979 if (p_ch != old_value && full_screen
8980#ifdef FEAT_GUI
8981 && !gui.starting
8982#endif
8983 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008984 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008985 }
8986
8987 /* when 'updatecount' changes from zero to non-zero, open swap files */
8988 else if (pp == &p_uc)
8989 {
8990 if (p_uc < 0)
8991 {
8992 errmsg = e_positive;
8993 p_uc = 100;
8994 }
8995 if (p_uc && !old_value)
8996 ml_open_files();
8997 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008998#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008999 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009000 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009001 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009002 {
9003 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009004 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009005 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009006 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009007 {
9008 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009009 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009010 }
9011 }
9012#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009013#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009014 else if (pp == &p_mzq)
9015 mzvim_reset_timer();
9016#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009017
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009018#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9019 /* 'pyxversion' */
9020 else if (pp == &p_pyx)
9021 {
9022 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9023 errmsg = e_invarg;
9024 }
9025#endif
9026
Bram Moolenaar071d4272004-06-13 20:20:40 +00009027 /* sync undo before 'undolevels' changes */
9028 else if (pp == &p_ul)
9029 {
9030 /* use the old value, otherwise u_sync() may not work properly */
9031 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009032 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009033 p_ul = value;
9034 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009035 else if (pp == &curbuf->b_p_ul)
9036 {
9037 /* use the old value, otherwise u_sync() may not work properly */
9038 curbuf->b_p_ul = old_value;
9039 u_sync(TRUE);
9040 curbuf->b_p_ul = value;
9041 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009042
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009043#ifdef FEAT_LINEBREAK
9044 /* 'numberwidth' must be positive */
9045 else if (pp == &curwin->w_p_nuw)
9046 {
9047 if (curwin->w_p_nuw < 1)
9048 {
9049 errmsg = e_positive;
9050 curwin->w_p_nuw = 1;
9051 }
9052 if (curwin->w_p_nuw > 10)
9053 {
9054 errmsg = e_invarg;
9055 curwin->w_p_nuw = 10;
9056 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009057 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009058 }
9059#endif
9060
Bram Moolenaar1a384422010-07-14 19:53:30 +02009061 else if (pp == &curbuf->b_p_tw)
9062 {
9063 if (curbuf->b_p_tw < 0)
9064 {
9065 errmsg = e_positive;
9066 curbuf->b_p_tw = 0;
9067 }
9068#ifdef FEAT_SYN_HL
9069# ifdef FEAT_WINDOWS
9070 {
9071 win_T *wp;
9072 tabpage_T *tp;
9073
9074 FOR_ALL_TAB_WINDOWS(tp, wp)
9075 check_colorcolumn(wp);
9076 }
9077# else
9078 check_colorcolumn(curwin);
9079# endif
9080#endif
9081 }
9082
Bram Moolenaar071d4272004-06-13 20:20:40 +00009083 /*
9084 * Check the bounds for numeric options here
9085 */
9086 if (Rows < min_rows() && full_screen)
9087 {
9088 if (errbuf != NULL)
9089 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009090 vim_snprintf((char *)errbuf, errbuflen,
9091 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009092 errmsg = errbuf;
9093 }
9094 Rows = min_rows();
9095 }
9096 if (Columns < MIN_COLUMNS && full_screen)
9097 {
9098 if (errbuf != NULL)
9099 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009100 vim_snprintf((char *)errbuf, errbuflen,
9101 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009102 errmsg = errbuf;
9103 }
9104 Columns = MIN_COLUMNS;
9105 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009106 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009107
Bram Moolenaar071d4272004-06-13 20:20:40 +00009108 /*
9109 * If the screen (shell) height has been changed, assume it is the
9110 * physical screenheight.
9111 */
9112 if (old_Rows != Rows || old_Columns != Columns)
9113 {
9114 /* Changing the screen size is not allowed while updating the screen. */
9115 if (updating_screen)
9116 *pp = old_value;
9117 else if (full_screen
9118#ifdef FEAT_GUI
9119 && !gui.starting
9120#endif
9121 )
9122 set_shellsize((int)Columns, (int)Rows, TRUE);
9123 else
9124 {
9125 /* Postpone the resizing; check the size and cmdline position for
9126 * messages. */
9127 check_shellsize();
9128 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9129 cmdline_row = Rows - p_ch;
9130 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009131 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009132 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009133 }
9134
Bram Moolenaar071d4272004-06-13 20:20:40 +00009135 if (curbuf->b_p_ts <= 0)
9136 {
9137 errmsg = e_positive;
9138 curbuf->b_p_ts = 8;
9139 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009140 if (p_tm < 0)
9141 {
9142 errmsg = e_positive;
9143 p_tm = 0;
9144 }
9145 if ((curwin->w_p_scr <= 0
9146 || (curwin->w_p_scr > curwin->w_height
9147 && curwin->w_height > 0))
9148 && full_screen)
9149 {
9150 if (pp == &(curwin->w_p_scr))
9151 {
9152 if (curwin->w_p_scr != 0)
9153 errmsg = e_scroll;
9154 win_comp_scroll(curwin);
9155 }
9156 /* If 'scroll' became invalid because of a side effect silently adjust
9157 * it. */
9158 else if (curwin->w_p_scr <= 0)
9159 curwin->w_p_scr = 1;
9160 else /* curwin->w_p_scr > curwin->w_height */
9161 curwin->w_p_scr = curwin->w_height;
9162 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009163 if (p_hi < 0)
9164 {
9165 errmsg = e_positive;
9166 p_hi = 0;
9167 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009168 else if (p_hi > 10000)
9169 {
9170 errmsg = e_invarg;
9171 p_hi = 10000;
9172 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009173 if (p_re < 0 || p_re > 2)
9174 {
9175 errmsg = e_invarg;
9176 p_re = 0;
9177 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009178 if (p_report < 0)
9179 {
9180 errmsg = e_positive;
9181 p_report = 1;
9182 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009183 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009184 {
9185 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9186 p_sj = Rows / 2;
9187 else
9188 {
9189 errmsg = e_scroll;
9190 p_sj = 1;
9191 }
9192 }
9193 if (p_so < 0 && full_screen)
9194 {
9195 errmsg = e_scroll;
9196 p_so = 0;
9197 }
9198 if (p_siso < 0 && full_screen)
9199 {
9200 errmsg = e_positive;
9201 p_siso = 0;
9202 }
9203#ifdef FEAT_CMDWIN
9204 if (p_cwh < 1)
9205 {
9206 errmsg = e_positive;
9207 p_cwh = 1;
9208 }
9209#endif
9210 if (p_ut < 0)
9211 {
9212 errmsg = e_positive;
9213 p_ut = 2000;
9214 }
9215 if (p_ss < 0)
9216 {
9217 errmsg = e_positive;
9218 p_ss = 0;
9219 }
9220
9221 /* May set global value for local option. */
9222 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9223 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9224
9225 options[opt_idx].flags |= P_WAS_SET;
9226
Bram Moolenaar53744302015-07-17 17:38:22 +02009227#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9228 if (!starting && errmsg == NULL)
9229 {
9230 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009231 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9232 vim_snprintf((char *)buf_new, 10, "%ld", value);
9233 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009234 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9235 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9236 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9237 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9238 reset_v_option_vars();
9239 }
9240#endif
9241
Bram Moolenaar071d4272004-06-13 20:20:40 +00009242 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009243 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009244 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009245 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009246 check_redraw(options[opt_idx].flags);
9247
9248 return errmsg;
9249}
9250
9251/*
9252 * Called after an option changed: check if something needs to be redrawn.
9253 */
9254 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009255check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009256{
9257 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009258 int doclear = (flags & P_RCLR) == P_RCLR;
9259 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009260
9261#ifdef FEAT_WINDOWS
9262 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9263 status_redraw_all();
9264#endif
9265
9266 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9267 changed_window_setting();
9268 if (flags & P_RBUF)
9269 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009270 if (flags & P_RWINONLY)
9271 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009272 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009273 redraw_all_later(CLEAR);
9274 else if (all)
9275 redraw_all_later(NOT_VALID);
9276}
9277
9278/*
9279 * Find index for option 'arg'.
9280 * Return -1 if not found.
9281 */
9282 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009283findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009284{
9285 int opt_idx;
9286 char *s, *p;
9287 static short quick_tab[27] = {0, 0}; /* quick access table */
9288 int is_term_opt;
9289
9290 /*
9291 * For first call: Initialize the quick-access table.
9292 * It contains the index for the first option that starts with a certain
9293 * letter. There are 26 letters, plus the first "t_" option.
9294 */
9295 if (quick_tab[1] == 0)
9296 {
9297 p = options[0].fullname;
9298 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9299 {
9300 if (s[0] != p[0])
9301 {
9302 if (s[0] == 't' && s[1] == '_')
9303 quick_tab[26] = opt_idx;
9304 else
9305 quick_tab[CharOrdLow(s[0])] = opt_idx;
9306 }
9307 p = s;
9308 }
9309 }
9310
9311 /*
9312 * Check for name starting with an illegal character.
9313 */
9314#ifdef EBCDIC
9315 if (!islower(arg[0]))
9316#else
9317 if (arg[0] < 'a' || arg[0] > 'z')
9318#endif
9319 return -1;
9320
9321 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9322 if (is_term_opt)
9323 opt_idx = quick_tab[26];
9324 else
9325 opt_idx = quick_tab[CharOrdLow(arg[0])];
9326 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9327 {
9328 if (STRCMP(arg, s) == 0) /* match full name */
9329 break;
9330 }
9331 if (s == NULL && !is_term_opt)
9332 {
9333 opt_idx = quick_tab[CharOrdLow(arg[0])];
9334 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9335 {
9336 s = options[opt_idx].shortname;
9337 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9338 break;
9339 s = NULL;
9340 }
9341 }
9342 if (s == NULL)
9343 opt_idx = -1;
9344 return opt_idx;
9345}
9346
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009347#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009348/*
9349 * Get the value for an option.
9350 *
9351 * Returns:
9352 * Number or Toggle option: 1, *numval gets value.
9353 * String option: 0, *stringval gets allocated string.
9354 * Hidden Number or Toggle option: -1.
9355 * hidden String option: -2.
9356 * unknown option: -3.
9357 */
9358 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009359get_option_value(
9360 char_u *name,
9361 long *numval,
9362 char_u **stringval, /* NULL when only checking existence */
9363 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009364{
9365 int opt_idx;
9366 char_u *varp;
9367
9368 opt_idx = findoption(name);
9369 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009370 {
9371 int key;
9372
9373 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9374 && (key = find_key_option(name)) != 0)
9375 {
9376 char_u key_name[2];
9377 char_u *p;
9378
9379 if (key < 0)
9380 {
9381 key_name[0] = KEY2TERMCAP0(key);
9382 key_name[1] = KEY2TERMCAP1(key);
9383 }
9384 else
9385 {
9386 key_name[0] = KS_KEY;
9387 key_name[1] = (key & 0xff);
9388 }
9389 p = find_termcode(key_name);
9390 if (p != NULL)
9391 {
9392 if (stringval != NULL)
9393 *stringval = vim_strsave(p);
9394 return 0;
9395 }
9396 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009397 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009398 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009399
9400 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9401
9402 if (options[opt_idx].flags & P_STRING)
9403 {
9404 if (varp == NULL) /* hidden option */
9405 return -2;
9406 if (stringval != NULL)
9407 {
9408#ifdef FEAT_CRYPT
9409 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009410 if ((char_u **)varp == &curbuf->b_p_key
9411 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009412 *stringval = vim_strsave((char_u *)"*****");
9413 else
9414#endif
9415 *stringval = vim_strsave(*(char_u **)(varp));
9416 }
9417 return 0;
9418 }
9419
9420 if (varp == NULL) /* hidden option */
9421 return -1;
9422 if (options[opt_idx].flags & P_NUM)
9423 *numval = *(long *)varp;
9424 else
9425 {
9426 /* Special case: 'modified' is b_changed, but we also want to consider
9427 * it set when 'ff' or 'fenc' changed. */
9428 if ((int *)varp == &curbuf->b_changed)
9429 *numval = curbufIsChanged();
9430 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009431 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009432 }
9433 return 1;
9434}
9435#endif
9436
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009437#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009438/*
9439 * Returns the option attributes and its value. Unlike the above function it
9440 * will return either global value or local value of the option depending on
9441 * what was requested, but it will never return global value if it was
9442 * requested to return local one and vice versa. Neither it will return
9443 * buffer-local value if it was requested to return window-local one.
9444 *
9445 * Pretends that option is absent if it is not present in the requested scope
9446 * (i.e. has no global, window-local or buffer-local value depending on
9447 * opt_type). Uses
9448 *
9449 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009450 * 0 hidden or unknown option, also option that does not have requested
9451 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009452 * see SOPT_* in vim.h for other flags
9453 *
9454 * Possible opt_type values: see SREQ_* in vim.h
9455 */
9456 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009457get_option_value_strict(
9458 char_u *name,
9459 long *numval,
9460 char_u **stringval, /* NULL when only obtaining attributes */
9461 int opt_type,
9462 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009463{
9464 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009465 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009466 struct vimoption *p;
9467 int r = 0;
9468
9469 opt_idx = findoption(name);
9470 if (opt_idx < 0)
9471 return 0;
9472
9473 p = &(options[opt_idx]);
9474
9475 /* Hidden option */
9476 if (p->var == NULL)
9477 return 0;
9478
9479 if (p->flags & P_BOOL)
9480 r |= SOPT_BOOL;
9481 else if (p->flags & P_NUM)
9482 r |= SOPT_NUM;
9483 else if (p->flags & P_STRING)
9484 r |= SOPT_STRING;
9485
9486 if (p->indir == PV_NONE)
9487 {
9488 if (opt_type == SREQ_GLOBAL)
9489 r |= SOPT_GLOBAL;
9490 else
9491 return 0; /* Did not request global-only option */
9492 }
9493 else
9494 {
9495 if (p->indir & PV_BOTH)
9496 r |= SOPT_GLOBAL;
9497 else if (opt_type == SREQ_GLOBAL)
9498 return 0; /* Requested global option */
9499
9500 if (p->indir & PV_WIN)
9501 {
9502 if (opt_type == SREQ_BUF)
9503 return 0; /* Did not request window-local option */
9504 else
9505 r |= SOPT_WIN;
9506 }
9507 else if (p->indir & PV_BUF)
9508 {
9509 if (opt_type == SREQ_WIN)
9510 return 0; /* Did not request buffer-local option */
9511 else
9512 r |= SOPT_BUF;
9513 }
9514 }
9515
9516 if (stringval == NULL)
9517 return r;
9518
9519 if (opt_type == SREQ_GLOBAL)
9520 varp = p->var;
9521 else
9522 {
9523 if (opt_type == SREQ_BUF)
9524 {
9525 /* Special case: 'modified' is b_changed, but we also want to
9526 * consider it set when 'ff' or 'fenc' changed. */
9527 if (p->indir == PV_MOD)
9528 {
9529 *numval = bufIsChanged((buf_T *) from);
9530 varp = NULL;
9531 }
9532#ifdef FEAT_CRYPT
9533 else if (p->indir == PV_KEY)
9534 {
9535 /* never return the value of the crypt key */
9536 *stringval = NULL;
9537 varp = NULL;
9538 }
9539#endif
9540 else
9541 {
9542 aco_save_T aco;
9543 aucmd_prepbuf(&aco, (buf_T *) from);
9544 varp = get_varp(p);
9545 aucmd_restbuf(&aco);
9546 }
9547 }
9548 else if (opt_type == SREQ_WIN)
9549 {
9550 win_T *save_curwin;
9551 save_curwin = curwin;
9552 curwin = (win_T *) from;
9553 curbuf = curwin->w_buffer;
9554 varp = get_varp(p);
9555 curwin = save_curwin;
9556 curbuf = curwin->w_buffer;
9557 }
9558 if (varp == p->var)
9559 return (r | SOPT_UNSET);
9560 }
9561
9562 if (varp != NULL)
9563 {
9564 if (p->flags & P_STRING)
9565 *stringval = vim_strsave(*(char_u **)(varp));
9566 else if (p->flags & P_NUM)
9567 *numval = *(long *) varp;
9568 else
9569 *numval = *(int *)varp;
9570 }
9571
9572 return r;
9573}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009574
9575/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009576 * Iterate over options. First argument is a pointer to a pointer to a
9577 * structure inside options[] array, second is option type like in the above
9578 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009579 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009580 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009581 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009582 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009583 * first argument to NULL.
9584 *
9585 * Returns full option name for current option on each call.
9586 */
9587 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009588option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009589{
9590 struct vimoption *ret = NULL;
9591 do
9592 {
9593 if (*option == NULL)
9594 *option = (void *) options;
9595 else if (((struct vimoption *) (*option))->fullname == NULL)
9596 {
9597 *option = NULL;
9598 return NULL;
9599 }
9600 else
9601 *option = (void *) (((struct vimoption *) (*option)) + 1);
9602
9603 ret = ((struct vimoption *) (*option));
9604
9605 /* Hidden option */
9606 if (ret->var == NULL)
9607 {
9608 ret = NULL;
9609 continue;
9610 }
9611
9612 switch (opt_type)
9613 {
9614 case SREQ_GLOBAL:
9615 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9616 ret = NULL;
9617 break;
9618 case SREQ_BUF:
9619 if (!(ret->indir & PV_BUF))
9620 ret = NULL;
9621 break;
9622 case SREQ_WIN:
9623 if (!(ret->indir & PV_WIN))
9624 ret = NULL;
9625 break;
9626 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009627 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009628 return NULL;
9629 }
9630 }
9631 while (ret == NULL);
9632
9633 return (char_u *)ret->fullname;
9634}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009635#endif
9636
Bram Moolenaar071d4272004-06-13 20:20:40 +00009637/*
9638 * Set the value of option "name".
9639 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009640 *
9641 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009642 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009643 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009644set_option_value(
9645 char_u *name,
9646 long number,
9647 char_u *string,
9648 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009649{
9650 int opt_idx;
9651 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009652 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009653
9654 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009655 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009656 {
9657 int key;
9658
9659 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9660 && (key = find_key_option(name)) != 0)
9661 {
9662 char_u key_name[2];
9663
9664 if (key < 0)
9665 {
9666 key_name[0] = KEY2TERMCAP0(key);
9667 key_name[1] = KEY2TERMCAP1(key);
9668 }
9669 else
9670 {
9671 key_name[0] = KS_KEY;
9672 key_name[1] = (key & 0xff);
9673 }
9674 add_termcode(key_name, string, FALSE);
9675 if (full_screen)
9676 ttest(FALSE);
9677 redraw_all_later(CLEAR);
9678 return NULL;
9679 }
9680
Bram Moolenaar071d4272004-06-13 20:20:40 +00009681 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009682 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009683 else
9684 {
9685 flags = options[opt_idx].flags;
9686#ifdef HAVE_SANDBOX
9687 /* Disallow changing some options in the sandbox */
9688 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009689 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009690 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009691 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009692 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009693#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009694 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009695 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009696 else
9697 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009698 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009699 if (varp != NULL) /* hidden option is not changed */
9700 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009701 if (number == 0 && string != NULL)
9702 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009703 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009704
9705 /* Either we are given a string or we are setting option
9706 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009707 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009708 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009709 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009710 {
9711 /* There's another character after zeros or the string
9712 * is empty. In both cases, we are trying to set a
9713 * num option using a string. */
9714 EMSG3(_("E521: Number required: &%s = '%s'"),
9715 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009716 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009717
9718 }
9719 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009720 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009721 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009722 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009723 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009724 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009725 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009726 }
9727 }
9728 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009729 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009730}
9731
9732/*
9733 * Get the terminal code for a terminal option.
9734 * Returns NULL when not found.
9735 */
9736 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009737get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009738{
9739 int opt_idx;
9740 char_u *varp;
9741
9742 if (tname[0] != 't' || tname[1] != '_' ||
9743 tname[2] == NUL || tname[3] == NUL)
9744 return NULL;
9745 if ((opt_idx = findoption(tname)) >= 0)
9746 {
9747 varp = get_varp(&(options[opt_idx]));
9748 if (varp != NULL)
9749 varp = *(char_u **)(varp);
9750 return varp;
9751 }
9752 return find_termcode(tname + 2);
9753}
9754
9755 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009756get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009757{
9758 int i;
9759
9760 i = findoption((char_u *)"hl");
9761 if (i >= 0)
9762 return options[i].def_val[VI_DEFAULT];
9763 return (char_u *)NULL;
9764}
9765
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009766#if defined(FEAT_MBYTE) || defined(PROTO)
9767 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009768get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009769{
9770 int i;
9771
9772 i = findoption((char_u *)"enc");
9773 if (i >= 0)
9774 return options[i].def_val[VI_DEFAULT];
9775 return (char_u *)NULL;
9776}
9777#endif
9778
Bram Moolenaar071d4272004-06-13 20:20:40 +00009779/*
9780 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9781 */
9782 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009783find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009784{
9785 int key;
9786 int modifiers;
9787
9788 /*
9789 * Don't use get_special_key_code() for t_xx, we don't want it to call
9790 * add_termcap_entry().
9791 */
9792 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9793 key = TERMCAP2KEY(arg[2], arg[3]);
9794 else
9795 {
9796 --arg; /* put arg at the '<' */
9797 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009798 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009799 if (modifiers) /* can't handle modifiers here */
9800 key = 0;
9801 }
9802 return key;
9803}
9804
9805/*
9806 * if 'all' == 0: show changed options
9807 * if 'all' == 1: show all normal options
9808 * if 'all' == 2: show all terminal options
9809 */
9810 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009811showoptions(
9812 int all,
9813 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009814{
9815 struct vimoption *p;
9816 int col;
9817 int isterm;
9818 char_u *varp;
9819 struct vimoption **items;
9820 int item_count;
9821 int run;
9822 int row, rows;
9823 int cols;
9824 int i;
9825 int len;
9826
9827#define INC 20
9828#define GAP 3
9829
9830 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9831 PARAM_COUNT));
9832 if (items == NULL)
9833 return;
9834
9835 /* Highlight title */
9836 if (all == 2)
9837 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9838 else if (opt_flags & OPT_GLOBAL)
9839 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9840 else if (opt_flags & OPT_LOCAL)
9841 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9842 else
9843 MSG_PUTS_TITLE(_("\n--- Options ---"));
9844
9845 /*
9846 * do the loop two times:
9847 * 1. display the short items
9848 * 2. display the long items (only strings and numbers)
9849 */
9850 for (run = 1; run <= 2 && !got_int; ++run)
9851 {
9852 /*
9853 * collect the items in items[]
9854 */
9855 item_count = 0;
9856 for (p = &options[0]; p->fullname != NULL; p++)
9857 {
9858 varp = NULL;
9859 isterm = istermoption(p);
9860 if (opt_flags != 0)
9861 {
9862 if (p->indir != PV_NONE && !isterm)
9863 varp = get_varp_scope(p, opt_flags);
9864 }
9865 else
9866 varp = get_varp(p);
9867 if (varp != NULL
9868 && ((all == 2 && isterm)
9869 || (all == 1 && !isterm)
9870 || (all == 0 && !optval_default(p, varp))))
9871 {
9872 if (p->flags & P_BOOL)
9873 len = 1; /* a toggle option fits always */
9874 else
9875 {
9876 option_value2string(p, opt_flags);
9877 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9878 }
9879 if ((len <= INC - GAP && run == 1) ||
9880 (len > INC - GAP && run == 2))
9881 items[item_count++] = p;
9882 }
9883 }
9884
9885 /*
9886 * display the items
9887 */
9888 if (run == 1)
9889 {
9890 cols = (Columns + GAP - 3) / INC;
9891 if (cols == 0)
9892 cols = 1;
9893 rows = (item_count + cols - 1) / cols;
9894 }
9895 else /* run == 2 */
9896 rows = item_count;
9897 for (row = 0; row < rows && !got_int; ++row)
9898 {
9899 msg_putchar('\n'); /* go to next line */
9900 if (got_int) /* 'q' typed in more */
9901 break;
9902 col = 0;
9903 for (i = row; i < item_count; i += rows)
9904 {
9905 msg_col = col; /* make columns */
9906 showoneopt(items[i], opt_flags);
9907 col += INC;
9908 }
9909 out_flush();
9910 ui_breakcheck();
9911 }
9912 }
9913 vim_free(items);
9914}
9915
9916/*
9917 * Return TRUE if option "p" has its default value.
9918 */
9919 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009920optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009921{
9922 int dvi;
9923
9924 if (varp == NULL)
9925 return TRUE; /* hidden option is always at default */
9926 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9927 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009928 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009929 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009930 /* the cast to long is required for Manx C, long_i is
9931 * needed for MSVC */
9932 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009933 /* P_STRING */
9934 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9935}
9936
9937/*
9938 * showoneopt: show the value of one option
9939 * must not be called with a hidden option!
9940 */
9941 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009942showoneopt(
9943 struct vimoption *p,
9944 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009945{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009946 char_u *varp;
9947 int save_silent = silent_mode;
9948
9949 silent_mode = FALSE;
9950 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009951
9952 varp = get_varp_scope(p, opt_flags);
9953
9954 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9955 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9956 ? !curbufIsChanged() : !*(int *)varp))
9957 MSG_PUTS("no");
9958 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9959 MSG_PUTS("--");
9960 else
9961 MSG_PUTS(" ");
9962 MSG_PUTS(p->fullname);
9963 if (!(p->flags & P_BOOL))
9964 {
9965 msg_putchar('=');
9966 /* put value string in NameBuff */
9967 option_value2string(p, opt_flags);
9968 msg_outtrans(NameBuff);
9969 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009970
9971 silent_mode = save_silent;
9972 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009973}
9974
9975/*
9976 * Write modified options as ":set" commands to a file.
9977 *
9978 * There are three values for "opt_flags":
9979 * OPT_GLOBAL: Write global option values and fresh values of
9980 * buffer-local options (used for start of a session
9981 * file).
9982 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9983 * curwin (used for a vimrc file).
9984 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9985 * and local values for window-local options of
9986 * curwin. Local values are also written when at the
9987 * default value, because a modeline or autocommand
9988 * may have set them when doing ":edit file" and the
9989 * user has set them back at the default or fresh
9990 * value.
9991 * When "local_only" is TRUE, don't write fresh
9992 * values, only local values (for ":mkview").
9993 * (fresh value = value used for a new buffer or window for a local option).
9994 *
9995 * Return FAIL on error, OK otherwise.
9996 */
9997 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009998makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009999{
10000 struct vimoption *p;
10001 char_u *varp; /* currently used value */
10002 char_u *varp_fresh; /* local value */
10003 char_u *varp_local = NULL; /* fresh value */
10004 char *cmd;
10005 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010006 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010007
10008 /*
10009 * The options that don't have a default (terminal name, columns, lines)
10010 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010011 * Do the loop over "options[]" twice: once for options with the
10012 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010013 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010014 for (pri = 1; pri >= 0; --pri)
10015 {
10016 for (p = &options[0]; !istermoption(p); p++)
10017 if (!(p->flags & P_NO_MKRC)
10018 && !istermoption(p)
10019 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010020 {
10021 /* skip global option when only doing locals */
10022 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10023 continue;
10024
10025 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10026 * file, they are always buffer-specific. */
10027 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10028 continue;
10029
10030 /* Global values are only written when not at the default value. */
10031 varp = get_varp_scope(p, opt_flags);
10032 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10033 continue;
10034
10035 round = 2;
10036 if (p->indir != PV_NONE)
10037 {
10038 if (p->var == VAR_WIN)
10039 {
10040 /* skip window-local option when only doing globals */
10041 if (!(opt_flags & OPT_LOCAL))
10042 continue;
10043 /* When fresh value of window-local option is not at the
10044 * default, need to write it too. */
10045 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10046 {
10047 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10048 if (!optval_default(p, varp_fresh))
10049 {
10050 round = 1;
10051 varp_local = varp;
10052 varp = varp_fresh;
10053 }
10054 }
10055 }
10056 }
10057
10058 /* Round 1: fresh value for window-local options.
10059 * Round 2: other values */
10060 for ( ; round <= 2; varp = varp_local, ++round)
10061 {
10062 if (round == 1 || (opt_flags & OPT_GLOBAL))
10063 cmd = "set";
10064 else
10065 cmd = "setlocal";
10066
10067 if (p->flags & P_BOOL)
10068 {
10069 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10070 return FAIL;
10071 }
10072 else if (p->flags & P_NUM)
10073 {
10074 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10075 return FAIL;
10076 }
10077 else /* P_STRING */
10078 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010079#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10080 int do_endif = FALSE;
10081
Bram Moolenaar071d4272004-06-13 20:20:40 +000010082 /* Don't set 'syntax' and 'filetype' again if the value is
10083 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010084 if (
10085# if defined(FEAT_SYN_HL)
10086 p->indir == PV_SYN
10087# if defined(FEAT_AUTOCMD)
10088 ||
10089# endif
10090# endif
10091# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010092 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010093# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010094 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010095 {
10096 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10097 *(char_u **)(varp)) < 0
10098 || put_eol(fd) < 0)
10099 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010100 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010101 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010102#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010103 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10104 (p->flags & P_EXPAND) != 0) == FAIL)
10105 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010106#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10107 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010108 {
10109 if (put_line(fd, "endif") == FAIL)
10110 return FAIL;
10111 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010112#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010113 }
10114 }
10115 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010116 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010117 return OK;
10118}
10119
10120#if defined(FEAT_FOLDING) || defined(PROTO)
10121/*
10122 * Generate set commands for the local fold options only. Used when
10123 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10124 */
10125 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010126makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010127{
10128 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10129# ifdef FEAT_EVAL
10130 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10131 == FAIL
10132# endif
10133 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10134 == FAIL
10135 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10136 == FAIL
10137 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10138 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10139 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10140 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10141 )
10142 return FAIL;
10143
10144 return OK;
10145}
10146#endif
10147
10148 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010149put_setstring(
10150 FILE *fd,
10151 char *cmd,
10152 char *name,
10153 char_u **valuep,
10154 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010155{
10156 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010157 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010158
10159 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10160 return FAIL;
10161 if (*valuep != NULL)
10162 {
10163 /* Output 'pastetoggle' as key names. For other
10164 * options some characters have to be escaped with
10165 * CTRL-V or backslash */
10166 if (valuep == &p_pt)
10167 {
10168 s = *valuep;
10169 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010170 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010171 return FAIL;
10172 }
10173 else if (expand)
10174 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010175 buf = alloc(MAXPATHL);
10176 if (buf == NULL)
10177 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010178 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10179 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010180 {
10181 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010182 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010183 }
10184 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010185 }
10186 else if (put_escstr(fd, *valuep, 2) == FAIL)
10187 return FAIL;
10188 }
10189 if (put_eol(fd) < 0)
10190 return FAIL;
10191 return OK;
10192}
10193
10194 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010195put_setnum(
10196 FILE *fd,
10197 char *cmd,
10198 char *name,
10199 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010200{
10201 long wc;
10202
10203 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10204 return FAIL;
10205 if (wc_use_keyname((char_u *)valuep, &wc))
10206 {
10207 /* print 'wildchar' and 'wildcharm' as a key name */
10208 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10209 return FAIL;
10210 }
10211 else if (fprintf(fd, "%ld", *valuep) < 0)
10212 return FAIL;
10213 if (put_eol(fd) < 0)
10214 return FAIL;
10215 return OK;
10216}
10217
10218 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010219put_setbool(
10220 FILE *fd,
10221 char *cmd,
10222 char *name,
10223 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010224{
Bram Moolenaar893de922007-10-02 18:40:57 +000010225 if (value < 0) /* global/local option using global value */
10226 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010227 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10228 || put_eol(fd) < 0)
10229 return FAIL;
10230 return OK;
10231}
10232
10233/*
10234 * Clear all the terminal options.
10235 * If the option has been allocated, free the memory.
10236 * Terminal options are never hidden or indirect.
10237 */
10238 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010239clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010240{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010241 /*
10242 * Reset a few things before clearing the old options. This may cause
10243 * outputting a few things that the terminal doesn't understand, but the
10244 * screen will be cleared later, so this is OK.
10245 */
10246#ifdef FEAT_MOUSE_TTY
10247 mch_setmouse(FALSE); /* switch mouse off */
10248#endif
10249#ifdef FEAT_TITLE
10250 mch_restore_title(3); /* restore window titles */
10251#endif
10252#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10253 /* When starting the GUI close the display opened for the clipboard.
10254 * After restoring the title, because that will need the display. */
10255 if (gui.starting)
10256 clear_xterm_clip();
10257#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010258 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010259
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010260 free_termoptions();
10261}
10262
10263 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010264free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010265{
10266 struct vimoption *p;
10267
Bram Moolenaar071d4272004-06-13 20:20:40 +000010268 for (p = &options[0]; p->fullname != NULL; p++)
10269 if (istermoption(p))
10270 {
10271 if (p->flags & P_ALLOCED)
10272 free_string_option(*(char_u **)(p->var));
10273 if (p->flags & P_DEF_ALLOCED)
10274 free_string_option(p->def_val[VI_DEFAULT]);
10275 *(char_u **)(p->var) = empty_option;
10276 p->def_val[VI_DEFAULT] = empty_option;
10277 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10278 }
10279 clear_termcodes();
10280}
10281
10282/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010283 * Free the string for one term option, if it was allocated.
10284 * Set the string to empty_option and clear allocated flag.
10285 * "var" points to the option value.
10286 */
10287 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010288free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010289{
10290 struct vimoption *p;
10291
10292 for (p = &options[0]; p->fullname != NULL; p++)
10293 if (p->var == var)
10294 {
10295 if (p->flags & P_ALLOCED)
10296 free_string_option(*(char_u **)(p->var));
10297 *(char_u **)(p->var) = empty_option;
10298 p->flags &= ~P_ALLOCED;
10299 break;
10300 }
10301}
10302
10303/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010304 * Set the terminal option defaults to the current value.
10305 * Used after setting the terminal name.
10306 */
10307 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010308set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010309{
10310 struct vimoption *p;
10311
10312 for (p = &options[0]; p->fullname != NULL; p++)
10313 {
10314 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10315 {
10316 if (p->flags & P_DEF_ALLOCED)
10317 {
10318 free_string_option(p->def_val[VI_DEFAULT]);
10319 p->flags &= ~P_DEF_ALLOCED;
10320 }
10321 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10322 if (p->flags & P_ALLOCED)
10323 {
10324 p->flags |= P_DEF_ALLOCED;
10325 p->flags &= ~P_ALLOCED; /* don't free the value now */
10326 }
10327 }
10328 }
10329}
10330
10331/*
10332 * return TRUE if 'p' starts with 't_'
10333 */
10334 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010335istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010336{
10337 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10338}
10339
10340/*
10341 * Compute columns for ruler and shown command. 'sc_col' is also used to
10342 * decide what the maximum length of a message on the status line can be.
10343 * If there is a status line for the last window, 'sc_col' is independent
10344 * of 'ru_col'.
10345 */
10346
10347#define COL_RULER 17 /* columns needed by standard ruler */
10348
10349 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010350comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010351{
10352#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010353 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010354
10355 sc_col = 0;
10356 ru_col = 0;
10357 if (p_ru)
10358 {
10359#ifdef FEAT_STL_OPT
10360 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10361#else
10362 ru_col = COL_RULER + 1;
10363#endif
10364 /* no last status line, adjust sc_col */
10365 if (!last_has_status)
10366 sc_col = ru_col;
10367 }
10368 if (p_sc)
10369 {
10370 sc_col += SHOWCMD_COLS;
10371 if (!p_ru || last_has_status) /* no need for separating space */
10372 ++sc_col;
10373 }
10374 sc_col = Columns - sc_col;
10375 ru_col = Columns - ru_col;
10376 if (sc_col <= 0) /* screen too narrow, will become a mess */
10377 sc_col = 1;
10378 if (ru_col <= 0)
10379 ru_col = 1;
10380#else
10381 sc_col = Columns;
10382 ru_col = Columns;
10383#endif
10384}
10385
10386/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010387 * Unset local option value, similar to ":set opt<".
10388 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010389 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010390unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010391{
10392 struct vimoption *p;
10393 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010394 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010395
10396 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010397 if (opt_idx < 0)
10398 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010399 p = &(options[opt_idx]);
10400
10401 switch ((int)p->indir)
10402 {
10403 /* global option with local value: use local value if it's been set */
10404 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010405 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010406 break;
10407 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010408 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010409 break;
10410 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010411 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010412 break;
10413 case PV_AR:
10414 buf->b_p_ar = -1;
10415 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010416 case PV_BKC:
10417 clear_string_option(&buf->b_p_bkc);
10418 buf->b_bkc_flags = 0;
10419 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010420 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010421 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010422 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010423 case PV_TC:
10424 clear_string_option(&buf->b_p_tc);
10425 buf->b_tc_flags = 0;
10426 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010427#ifdef FEAT_FIND_ID
10428 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010429 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010430 break;
10431 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010432 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010433 break;
10434#endif
10435#ifdef FEAT_INS_EXPAND
10436 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010437 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010438 break;
10439 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010440 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010441 break;
10442#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010443 case PV_FP:
10444 clear_string_option(&buf->b_p_fp);
10445 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010446#ifdef FEAT_QUICKFIX
10447 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010448 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010449 break;
10450 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010451 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010452 break;
10453 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010454 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010455 break;
10456#endif
10457#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10458 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010459 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010460 break;
10461#endif
10462#if defined(FEAT_CRYPT)
10463 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010464 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010465 break;
10466#endif
10467#ifdef FEAT_STL_OPT
10468 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010469 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010470 break;
10471#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010472 case PV_UL:
10473 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10474 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010475#ifdef FEAT_LISP
10476 case PV_LW:
10477 clear_string_option(&buf->b_p_lw);
10478 break;
10479#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010480#ifdef FEAT_MBYTE
10481 case PV_MENC:
10482 clear_string_option(&buf->b_p_menc);
10483 break;
10484#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010485 }
10486}
10487
10488/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010489 * Get pointer to option variable, depending on local or global scope.
10490 */
10491 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010492get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010493{
10494 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10495 {
10496 if (p->var == VAR_WIN)
10497 return (char_u *)GLOBAL_WO(get_varp(p));
10498 return p->var;
10499 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010500 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010501 {
10502 switch ((int)p->indir)
10503 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010504 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010505#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010506 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10507 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10508 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010509#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010510 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10511 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10512 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010513 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010514 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010515 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010516#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010517 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10518 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010519#endif
10520#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010521 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10522 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010523#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010524#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10525 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10526#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010527#if defined(FEAT_CRYPT)
10528 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10529#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010530#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010531 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010532#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010533 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010534#ifdef FEAT_LISP
10535 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10536#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010537 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010538#ifdef FEAT_MBYTE
10539 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10540#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010541 }
10542 return NULL; /* "cannot happen" */
10543 }
10544 return get_varp(p);
10545}
10546
10547/*
10548 * Get pointer to option variable.
10549 */
10550 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010551get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010552{
10553 /* hidden option, always return NULL */
10554 if (p->var == NULL)
10555 return NULL;
10556
10557 switch ((int)p->indir)
10558 {
10559 case PV_NONE: return p->var;
10560
10561 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010562 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010563 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010564 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010566 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010567 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010568 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010569 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010570 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010571 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010572 case PV_TC: return *curbuf->b_p_tc != NUL
10573 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010574 case PV_BKC: return *curbuf->b_p_bkc != NUL
10575 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010576#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010577 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010578 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010579 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010580 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10581#endif
10582#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010583 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010584 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010585 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010586 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10587#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010588 case PV_FP: return *curbuf->b_p_fp != NUL
10589 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010590#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010591 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010592 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010593 case PV_GP: return *curbuf->b_p_gp != NUL
10594 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10595 case PV_MP: return *curbuf->b_p_mp != NUL
10596 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010597#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010598#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10599 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10600 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10601#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010602#if defined(FEAT_CRYPT)
10603 case PV_CM: return *curbuf->b_p_cm != NUL
10604 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10605#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010606#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010607 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010608 ? (char_u *)&(curwin->w_p_stl) : p->var;
10609#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010610 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10611 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010612#ifdef FEAT_LISP
10613 case PV_LW: return *curbuf->b_p_lw != NUL
10614 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10615#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010616#ifdef FEAT_MBYTE
10617 case PV_MENC: return *curbuf->b_p_menc != NUL
10618 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10619#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010620
10621#ifdef FEAT_ARABIC
10622 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10623#endif
10624 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010625#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010626 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10627#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010628#ifdef FEAT_SYN_HL
10629 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10630 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010631 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010632#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010633#ifdef FEAT_DIFF
10634 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10635#endif
10636#ifdef FEAT_FOLDING
10637 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10638 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10639 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10640 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10641 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10642 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10643 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10644# ifdef FEAT_EVAL
10645 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10646 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10647# endif
10648 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10649#endif
10650 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010651 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010652#ifdef FEAT_LINEBREAK
10653 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10654#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010655#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010656 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010657 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10658#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010659#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10660 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10661#endif
10662#ifdef FEAT_RIGHTLEFT
10663 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10664 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10665#endif
10666 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10667 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10668#ifdef FEAT_LINEBREAK
10669 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010670 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10671 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010672#endif
10673#ifdef FEAT_SCROLLBIND
10674 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10675#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010676#ifdef FEAT_CURSORBIND
10677 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10678#endif
10679#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010680 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10681 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10682#endif
10683#ifdef FEAT_TERMINAL
10684 case PV_TMS: return (char_u *)&(curwin->w_p_tms);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010685#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010686
10687 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10688 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10689#ifdef FEAT_MBYTE
10690 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10691#endif
10692#if defined(FEAT_QUICKFIX)
10693 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10694 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10695#endif
10696 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10697 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10698#ifdef FEAT_CINDENT
10699 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10700 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10701 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10702#endif
10703#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10704 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10705#endif
10706#ifdef FEAT_COMMENTS
10707 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10708#endif
10709#ifdef FEAT_FOLDING
10710 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10711#endif
10712#ifdef FEAT_INS_EXPAND
10713 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10714#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010715#ifdef FEAT_COMPL_FUNC
10716 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010717 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010719 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010720 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010721 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10722#ifdef FEAT_MBYTE
10723 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10724#endif
10725 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10726#ifdef FEAT_AUTOCMD
10727 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10728#endif
10729 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010730 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010731 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10732 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10733 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10734 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10735#ifdef FEAT_FIND_ID
10736# ifdef FEAT_EVAL
10737 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10738# endif
10739#endif
10740#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10741 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10742 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10743#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010744#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010745 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10746#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010747#ifdef FEAT_CRYPT
10748 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10749#endif
10750#ifdef FEAT_LISP
10751 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10752#endif
10753 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10754 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10755 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10756 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10757 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010758 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010759#ifdef FEAT_TEXTOBJ
10760 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10761#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010762 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10763#ifdef FEAT_SMARTINDENT
10764 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10765#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010766 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010767 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10768#ifdef FEAT_SEARCHPATH
10769 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10770#endif
10771 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10772#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010773 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010774 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10775#endif
10776#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010777 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10778 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10779 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010780#endif
10781 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10782 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10783 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10784 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010785#ifdef FEAT_PERSISTENT_UNDO
10786 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10787#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010788 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10789#ifdef FEAT_KEYMAP
10790 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10791#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010792#ifdef FEAT_SIGNS
10793 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10794#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010795 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010796 }
10797 /* always return a valid pointer to avoid a crash! */
10798 return (char_u *)&(curbuf->b_p_wm);
10799}
10800
10801/*
10802 * Get the value of 'equalprg', either the buffer-local one or the global one.
10803 */
10804 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010805get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010806{
10807 if (*curbuf->b_p_ep == NUL)
10808 return p_ep;
10809 return curbuf->b_p_ep;
10810}
10811
10812#if defined(FEAT_WINDOWS) || defined(PROTO)
10813/*
10814 * Copy options from one window to another.
10815 * Used when splitting a window.
10816 */
10817 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010818win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010819{
10820 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10821 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10822# ifdef FEAT_RIGHTLEFT
10823# ifdef FEAT_FKMAP
10824 /* Is this right? */
10825 wp_to->w_farsi = wp_from->w_farsi;
10826# endif
10827# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010828#if defined(FEAT_LINEBREAK)
10829 briopt_check(wp_to);
10830#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010831}
10832#endif
10833
10834/*
10835 * Copy the options from one winopt_T to another.
10836 * Doesn't free the old option values in "to", use clear_winopt() for that.
10837 * The 'scroll' option is not copied, because it depends on the window height.
10838 * The 'previewwindow' option is reset, there can be only one preview window.
10839 */
10840 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010841copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010842{
10843#ifdef FEAT_ARABIC
10844 to->wo_arab = from->wo_arab;
10845#endif
10846 to->wo_list = from->wo_list;
10847 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010848 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010849#ifdef FEAT_LINEBREAK
10850 to->wo_nuw = from->wo_nuw;
10851#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010852#ifdef FEAT_RIGHTLEFT
10853 to->wo_rl = from->wo_rl;
10854 to->wo_rlc = vim_strsave(from->wo_rlc);
10855#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010856#ifdef FEAT_STL_OPT
10857 to->wo_stl = vim_strsave(from->wo_stl);
10858#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010859 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010860#ifdef FEAT_DIFF
10861 to->wo_wrap_save = from->wo_wrap_save;
10862#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010863#ifdef FEAT_LINEBREAK
10864 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010865 to->wo_bri = from->wo_bri;
10866 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010867#endif
10868#ifdef FEAT_SCROLLBIND
10869 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010870 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010871#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010872#ifdef FEAT_CURSORBIND
10873 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010874 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010875#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010876#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010877 to->wo_spell = from->wo_spell;
10878#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010879#ifdef FEAT_SYN_HL
10880 to->wo_cuc = from->wo_cuc;
10881 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010882 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010883#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010884#ifdef FEAT_DIFF
10885 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010886 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010887#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010888#ifdef FEAT_CONCEAL
10889 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010890 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010891#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010892#ifdef FEAT_TERMINAL
10893 to->wo_tms = vim_strsave(from->wo_tms);
10894#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010895#ifdef FEAT_FOLDING
10896 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010897 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010898 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010899 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010900 to->wo_fdi = vim_strsave(from->wo_fdi);
10901 to->wo_fml = from->wo_fml;
10902 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010903 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010904 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010905 to->wo_fdm_save = from->wo_diff_saved
10906 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010907 to->wo_fdn = from->wo_fdn;
10908# ifdef FEAT_EVAL
10909 to->wo_fde = vim_strsave(from->wo_fde);
10910 to->wo_fdt = vim_strsave(from->wo_fdt);
10911# endif
10912 to->wo_fmr = vim_strsave(from->wo_fmr);
10913#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010914#ifdef FEAT_SIGNS
10915 to->wo_scl = vim_strsave(from->wo_scl);
10916#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010917 check_winopt(to); /* don't want NULL pointers */
10918}
10919
10920/*
10921 * Check string options in a window for a NULL value.
10922 */
10923 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010924check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010925{
10926 check_winopt(&win->w_onebuf_opt);
10927 check_winopt(&win->w_allbuf_opt);
10928}
10929
10930/*
10931 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10932 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010933 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010934check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010935{
10936#ifdef FEAT_FOLDING
10937 check_string_option(&wop->wo_fdi);
10938 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010939 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010940# ifdef FEAT_EVAL
10941 check_string_option(&wop->wo_fde);
10942 check_string_option(&wop->wo_fdt);
10943# endif
10944 check_string_option(&wop->wo_fmr);
10945#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010946#ifdef FEAT_SIGNS
10947 check_string_option(&wop->wo_scl);
10948#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010949#ifdef FEAT_RIGHTLEFT
10950 check_string_option(&wop->wo_rlc);
10951#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010952#ifdef FEAT_STL_OPT
10953 check_string_option(&wop->wo_stl);
10954#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010955#ifdef FEAT_SYN_HL
10956 check_string_option(&wop->wo_cc);
10957#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010958#ifdef FEAT_CONCEAL
10959 check_string_option(&wop->wo_cocu);
10960#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010961#ifdef FEAT_TERMINAL
10962 check_string_option(&wop->wo_tms);
10963#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010964#ifdef FEAT_LINEBREAK
10965 check_string_option(&wop->wo_briopt);
10966#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010967}
10968
10969/*
10970 * Free the allocated memory inside a winopt_T.
10971 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010972 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010973clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010974{
10975#ifdef FEAT_FOLDING
10976 clear_string_option(&wop->wo_fdi);
10977 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010978 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010979# ifdef FEAT_EVAL
10980 clear_string_option(&wop->wo_fde);
10981 clear_string_option(&wop->wo_fdt);
10982# endif
10983 clear_string_option(&wop->wo_fmr);
10984#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010985#ifdef FEAT_SIGNS
10986 clear_string_option(&wop->wo_scl);
10987#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010988#ifdef FEAT_LINEBREAK
10989 clear_string_option(&wop->wo_briopt);
10990#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010991#ifdef FEAT_RIGHTLEFT
10992 clear_string_option(&wop->wo_rlc);
10993#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010994#ifdef FEAT_STL_OPT
10995 clear_string_option(&wop->wo_stl);
10996#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010997#ifdef FEAT_SYN_HL
10998 clear_string_option(&wop->wo_cc);
10999#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011000#ifdef FEAT_CONCEAL
11001 clear_string_option(&wop->wo_cocu);
11002#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011003#ifdef FEAT_TERMINAL
11004 clear_string_option(&wop->wo_tms);
11005#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011006}
11007
11008/*
11009 * Copy global option values to local options for one buffer.
11010 * Used when creating a new buffer and sometimes when entering a buffer.
11011 * flags:
11012 * BCO_ENTER We will enter the buf buffer.
11013 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11014 * appropriate.
11015 * BCO_NOHELP Don't copy the values to a help buffer.
11016 */
11017 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011018buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011019{
11020 int should_copy = TRUE;
11021 char_u *save_p_isk = NULL; /* init for GCC */
11022 int dont_do_help;
11023 int did_isk = FALSE;
11024
11025 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011026 * Skip this when the option defaults have not been set yet. Happens when
11027 * main() allocates the first buffer.
11028 */
11029 if (p_cpo != NULL)
11030 {
11031 /*
11032 * Always copy when entering and 'cpo' contains 'S'.
11033 * Don't copy when already initialized.
11034 * Don't copy when 'cpo' contains 's' and not entering.
11035 * 'S' BCO_ENTER initialized 's' should_copy
11036 * yes yes X X TRUE
11037 * yes no yes X FALSE
11038 * no X yes X FALSE
11039 * X no no yes FALSE
11040 * X no no no TRUE
11041 * no yes no X TRUE
11042 */
11043 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11044 && (buf->b_p_initialized
11045 || (!(flags & BCO_ENTER)
11046 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11047 should_copy = FALSE;
11048
11049 if (should_copy || (flags & BCO_ALWAYS))
11050 {
11051 /* Don't copy the options specific to a help buffer when
11052 * BCO_NOHELP is given or the options were initialized already
11053 * (jumping back to a help file with CTRL-T or CTRL-O) */
11054 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11055 || buf->b_p_initialized;
11056 if (dont_do_help) /* don't free b_p_isk */
11057 {
11058 save_p_isk = buf->b_p_isk;
11059 buf->b_p_isk = NULL;
11060 }
11061 /*
11062 * Always free the allocated strings.
11063 * If not already initialized, set 'readonly' and copy 'fileformat'.
11064 */
11065 if (!buf->b_p_initialized)
11066 {
11067 free_buf_options(buf, TRUE);
11068 buf->b_p_ro = FALSE; /* don't copy readonly */
11069 buf->b_p_tx = p_tx;
11070#ifdef FEAT_MBYTE
11071 buf->b_p_fenc = vim_strsave(p_fenc);
11072#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011073 switch (*p_ffs)
11074 {
11075 case 'm':
11076 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11077 case 'd':
11078 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11079 case 'u':
11080 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11081 default:
11082 buf->b_p_ff = vim_strsave(p_ff);
11083 }
11084 if (buf->b_p_ff != NULL)
11085 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011086#if defined(FEAT_QUICKFIX)
11087 buf->b_p_bh = empty_option;
11088 buf->b_p_bt = empty_option;
11089#endif
11090 }
11091 else
11092 free_buf_options(buf, FALSE);
11093
11094 buf->b_p_ai = p_ai;
11095 buf->b_p_ai_nopaste = p_ai_nopaste;
11096 buf->b_p_sw = p_sw;
11097 buf->b_p_tw = p_tw;
11098 buf->b_p_tw_nopaste = p_tw_nopaste;
11099 buf->b_p_tw_nobin = p_tw_nobin;
11100 buf->b_p_wm = p_wm;
11101 buf->b_p_wm_nopaste = p_wm_nopaste;
11102 buf->b_p_wm_nobin = p_wm_nobin;
11103 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011104#ifdef FEAT_MBYTE
11105 buf->b_p_bomb = p_bomb;
11106#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011107 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011108 buf->b_p_et = p_et;
11109 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011110 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011111 buf->b_p_ml = p_ml;
11112 buf->b_p_ml_nobin = p_ml_nobin;
11113 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011114 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011115#ifdef FEAT_INS_EXPAND
11116 buf->b_p_cpt = vim_strsave(p_cpt);
11117#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011118#ifdef FEAT_COMPL_FUNC
11119 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011120 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011121#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011122 buf->b_p_sts = p_sts;
11123 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011124 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011125#ifdef FEAT_COMMENTS
11126 buf->b_p_com = vim_strsave(p_com);
11127#endif
11128#ifdef FEAT_FOLDING
11129 buf->b_p_cms = vim_strsave(p_cms);
11130#endif
11131 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011132 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011133 buf->b_p_nf = vim_strsave(p_nf);
11134 buf->b_p_mps = vim_strsave(p_mps);
11135#ifdef FEAT_SMARTINDENT
11136 buf->b_p_si = p_si;
11137#endif
11138 buf->b_p_ci = p_ci;
11139#ifdef FEAT_CINDENT
11140 buf->b_p_cin = p_cin;
11141 buf->b_p_cink = vim_strsave(p_cink);
11142 buf->b_p_cino = vim_strsave(p_cino);
11143#endif
11144#ifdef FEAT_AUTOCMD
11145 /* Don't copy 'filetype', it must be detected */
11146 buf->b_p_ft = empty_option;
11147#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011148 buf->b_p_pi = p_pi;
11149#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11150 buf->b_p_cinw = vim_strsave(p_cinw);
11151#endif
11152#ifdef FEAT_LISP
11153 buf->b_p_lisp = p_lisp;
11154#endif
11155#ifdef FEAT_SYN_HL
11156 /* Don't copy 'syntax', it must be set */
11157 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011158 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011159 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011160#endif
11161#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011162 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011163 (void)compile_cap_prog(&buf->b_s);
11164 buf->b_s.b_p_spf = vim_strsave(p_spf);
11165 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011166#endif
11167#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11168 buf->b_p_inde = vim_strsave(p_inde);
11169 buf->b_p_indk = vim_strsave(p_indk);
11170#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011171 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011172#if defined(FEAT_EVAL)
11173 buf->b_p_fex = vim_strsave(p_fex);
11174#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011175#ifdef FEAT_CRYPT
11176 buf->b_p_key = vim_strsave(p_key);
11177#endif
11178#ifdef FEAT_SEARCHPATH
11179 buf->b_p_sua = vim_strsave(p_sua);
11180#endif
11181#ifdef FEAT_KEYMAP
11182 buf->b_p_keymap = vim_strsave(p_keymap);
11183 buf->b_kmap_state |= KEYMAP_INIT;
11184#endif
11185 /* This isn't really an option, but copying the langmap and IME
11186 * state from the current buffer is better than resetting it. */
11187 buf->b_p_iminsert = p_iminsert;
11188 buf->b_p_imsearch = p_imsearch;
11189
11190 /* options that are normally global but also have a local value
11191 * are not copied, start using the global value */
11192 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011193 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011194 buf->b_p_bkc = empty_option;
11195 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011196#ifdef FEAT_QUICKFIX
11197 buf->b_p_gp = empty_option;
11198 buf->b_p_mp = empty_option;
11199 buf->b_p_efm = empty_option;
11200#endif
11201 buf->b_p_ep = empty_option;
11202 buf->b_p_kp = empty_option;
11203 buf->b_p_path = empty_option;
11204 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011205 buf->b_p_tc = empty_option;
11206 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011207#ifdef FEAT_FIND_ID
11208 buf->b_p_def = empty_option;
11209 buf->b_p_inc = empty_option;
11210# ifdef FEAT_EVAL
11211 buf->b_p_inex = vim_strsave(p_inex);
11212# endif
11213#endif
11214#ifdef FEAT_INS_EXPAND
11215 buf->b_p_dict = empty_option;
11216 buf->b_p_tsr = empty_option;
11217#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011218#ifdef FEAT_TEXTOBJ
11219 buf->b_p_qe = vim_strsave(p_qe);
11220#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011221#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11222 buf->b_p_bexpr = empty_option;
11223#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011224#if defined(FEAT_CRYPT)
11225 buf->b_p_cm = empty_option;
11226#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011227#ifdef FEAT_PERSISTENT_UNDO
11228 buf->b_p_udf = p_udf;
11229#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011230#ifdef FEAT_LISP
11231 buf->b_p_lw = empty_option;
11232#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011233#ifdef FEAT_MBYTE
11234 buf->b_p_menc = empty_option;
11235#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011236
11237 /*
11238 * Don't copy the options set by ex_help(), use the saved values,
11239 * when going from a help buffer to a non-help buffer.
11240 * Don't touch these at all when BCO_NOHELP is used and going from
11241 * or to a help buffer.
11242 */
11243 if (dont_do_help)
11244 buf->b_p_isk = save_p_isk;
11245 else
11246 {
11247 buf->b_p_isk = vim_strsave(p_isk);
11248 did_isk = TRUE;
11249 buf->b_p_ts = p_ts;
11250 buf->b_help = FALSE;
11251#ifdef FEAT_QUICKFIX
11252 if (buf->b_p_bt[0] == 'h')
11253 clear_string_option(&buf->b_p_bt);
11254#endif
11255 buf->b_p_ma = p_ma;
11256 }
11257 }
11258
11259 /*
11260 * When the options should be copied (ignoring BCO_ALWAYS), set the
11261 * flag that indicates that the options have been initialized.
11262 */
11263 if (should_copy)
11264 buf->b_p_initialized = TRUE;
11265 }
11266
11267 check_buf_options(buf); /* make sure we don't have NULLs */
11268 if (did_isk)
11269 (void)buf_init_chartab(buf, FALSE);
11270}
11271
11272/*
11273 * Reset the 'modifiable' option and its default value.
11274 */
11275 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011276reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011277{
11278 int opt_idx;
11279
11280 curbuf->b_p_ma = FALSE;
11281 p_ma = FALSE;
11282 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011283 if (opt_idx >= 0)
11284 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011285}
11286
11287/*
11288 * Set the global value for 'iminsert' to the local value.
11289 */
11290 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011291set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011292{
11293 p_iminsert = curbuf->b_p_iminsert;
11294}
11295
11296/*
11297 * Set the global value for 'imsearch' to the local value.
11298 */
11299 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011300set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011301{
11302 p_imsearch = curbuf->b_p_imsearch;
11303}
11304
11305#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11306static int expand_option_idx = -1;
11307static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11308static int expand_option_flags = 0;
11309
11310 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011311set_context_in_set_cmd(
11312 expand_T *xp,
11313 char_u *arg,
11314 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011315{
11316 int nextchar;
11317 long_u flags = 0; /* init for GCC */
11318 int opt_idx = 0; /* init for GCC */
11319 char_u *p;
11320 char_u *s;
11321 int is_term_option = FALSE;
11322 int key;
11323
11324 expand_option_flags = opt_flags;
11325
11326 xp->xp_context = EXPAND_SETTINGS;
11327 if (*arg == NUL)
11328 {
11329 xp->xp_pattern = arg;
11330 return;
11331 }
11332 p = arg + STRLEN(arg) - 1;
11333 if (*p == ' ' && *(p - 1) != '\\')
11334 {
11335 xp->xp_pattern = p + 1;
11336 return;
11337 }
11338 while (p > arg)
11339 {
11340 s = p;
11341 /* count number of backslashes before ' ' or ',' */
11342 if (*p == ' ' || *p == ',')
11343 {
11344 while (s > arg && *(s - 1) == '\\')
11345 --s;
11346 }
11347 /* break at a space with an even number of backslashes */
11348 if (*p == ' ' && ((p - s) & 1) == 0)
11349 {
11350 ++p;
11351 break;
11352 }
11353 --p;
11354 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011355 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011356 {
11357 xp->xp_context = EXPAND_BOOL_SETTINGS;
11358 p += 2;
11359 }
11360 if (STRNCMP(p, "inv", 3) == 0)
11361 {
11362 xp->xp_context = EXPAND_BOOL_SETTINGS;
11363 p += 3;
11364 }
11365 xp->xp_pattern = arg = p;
11366 if (*arg == '<')
11367 {
11368 while (*p != '>')
11369 if (*p++ == NUL) /* expand terminal option name */
11370 return;
11371 key = get_special_key_code(arg + 1);
11372 if (key == 0) /* unknown name */
11373 {
11374 xp->xp_context = EXPAND_NOTHING;
11375 return;
11376 }
11377 nextchar = *++p;
11378 is_term_option = TRUE;
11379 expand_option_name[2] = KEY2TERMCAP0(key);
11380 expand_option_name[3] = KEY2TERMCAP1(key);
11381 }
11382 else
11383 {
11384 if (p[0] == 't' && p[1] == '_')
11385 {
11386 p += 2;
11387 if (*p != NUL)
11388 ++p;
11389 if (*p == NUL)
11390 return; /* expand option name */
11391 nextchar = *++p;
11392 is_term_option = TRUE;
11393 expand_option_name[2] = p[-2];
11394 expand_option_name[3] = p[-1];
11395 }
11396 else
11397 {
11398 /* Allow * wildcard */
11399 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11400 p++;
11401 if (*p == NUL)
11402 return;
11403 nextchar = *p;
11404 *p = NUL;
11405 opt_idx = findoption(arg);
11406 *p = nextchar;
11407 if (opt_idx == -1 || options[opt_idx].var == NULL)
11408 {
11409 xp->xp_context = EXPAND_NOTHING;
11410 return;
11411 }
11412 flags = options[opt_idx].flags;
11413 if (flags & P_BOOL)
11414 {
11415 xp->xp_context = EXPAND_NOTHING;
11416 return;
11417 }
11418 }
11419 }
11420 /* handle "-=" and "+=" */
11421 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11422 {
11423 ++p;
11424 nextchar = '=';
11425 }
11426 if ((nextchar != '=' && nextchar != ':')
11427 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11428 {
11429 xp->xp_context = EXPAND_UNSUCCESSFUL;
11430 return;
11431 }
11432 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11433 {
11434 xp->xp_context = EXPAND_OLD_SETTING;
11435 if (is_term_option)
11436 expand_option_idx = -1;
11437 else
11438 expand_option_idx = opt_idx;
11439 xp->xp_pattern = p + 1;
11440 return;
11441 }
11442 xp->xp_context = EXPAND_NOTHING;
11443 if (is_term_option || (flags & P_NUM))
11444 return;
11445
11446 xp->xp_pattern = p + 1;
11447
11448 if (flags & P_EXPAND)
11449 {
11450 p = options[opt_idx].var;
11451 if (p == (char_u *)&p_bdir
11452 || p == (char_u *)&p_dir
11453 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011454 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011455 || p == (char_u *)&p_rtp
11456#ifdef FEAT_SEARCHPATH
11457 || p == (char_u *)&p_cdpath
11458#endif
11459#ifdef FEAT_SESSION
11460 || p == (char_u *)&p_vdir
11461#endif
11462 )
11463 {
11464 xp->xp_context = EXPAND_DIRECTORIES;
11465 if (p == (char_u *)&p_path
11466#ifdef FEAT_SEARCHPATH
11467 || p == (char_u *)&p_cdpath
11468#endif
11469 )
11470 xp->xp_backslash = XP_BS_THREE;
11471 else
11472 xp->xp_backslash = XP_BS_ONE;
11473 }
11474 else
11475 {
11476 xp->xp_context = EXPAND_FILES;
11477 /* for 'tags' need three backslashes for a space */
11478 if (p == (char_u *)&p_tags)
11479 xp->xp_backslash = XP_BS_THREE;
11480 else
11481 xp->xp_backslash = XP_BS_ONE;
11482 }
11483 }
11484
11485 /* For an option that is a list of file names, find the start of the
11486 * last file name. */
11487 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11488 {
11489 /* count number of backslashes before ' ' or ',' */
11490 if (*p == ' ' || *p == ',')
11491 {
11492 s = p;
11493 while (s > xp->xp_pattern && *(s - 1) == '\\')
11494 --s;
11495 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11496 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11497 {
11498 xp->xp_pattern = p + 1;
11499 break;
11500 }
11501 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011502
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011503#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011504 /* for 'spellsuggest' start at "file:" */
11505 if (options[opt_idx].var == (char_u *)&p_sps
11506 && STRNCMP(p, "file:", 5) == 0)
11507 {
11508 xp->xp_pattern = p + 5;
11509 break;
11510 }
11511#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011512 }
11513
11514 return;
11515}
11516
11517 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011518ExpandSettings(
11519 expand_T *xp,
11520 regmatch_T *regmatch,
11521 int *num_file,
11522 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011523{
11524 int num_normal = 0; /* Nr of matching non-term-code settings */
11525 int num_term = 0; /* Nr of matching terminal code settings */
11526 int opt_idx;
11527 int match;
11528 int count = 0;
11529 char_u *str;
11530 int loop;
11531 int is_term_opt;
11532 char_u name_buf[MAX_KEY_NAME_LEN];
11533 static char *(names[]) = {"all", "termcap"};
11534 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11535
11536 /* do this loop twice:
11537 * loop == 0: count the number of matching options
11538 * loop == 1: copy the matching options into allocated memory
11539 */
11540 for (loop = 0; loop <= 1; ++loop)
11541 {
11542 regmatch->rm_ic = ic;
11543 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11544 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011545 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11546 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011547 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11548 {
11549 if (loop == 0)
11550 num_normal++;
11551 else
11552 (*file)[count++] = vim_strsave((char_u *)names[match]);
11553 }
11554 }
11555 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11556 opt_idx++)
11557 {
11558 if (options[opt_idx].var == NULL)
11559 continue;
11560 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11561 && !(options[opt_idx].flags & P_BOOL))
11562 continue;
11563 is_term_opt = istermoption(&options[opt_idx]);
11564 if (is_term_opt && num_normal > 0)
11565 continue;
11566 match = FALSE;
11567 if (vim_regexec(regmatch, str, (colnr_T)0)
11568 || (options[opt_idx].shortname != NULL
11569 && vim_regexec(regmatch,
11570 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11571 match = TRUE;
11572 else if (is_term_opt)
11573 {
11574 name_buf[0] = '<';
11575 name_buf[1] = 't';
11576 name_buf[2] = '_';
11577 name_buf[3] = str[2];
11578 name_buf[4] = str[3];
11579 name_buf[5] = '>';
11580 name_buf[6] = NUL;
11581 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11582 {
11583 match = TRUE;
11584 str = name_buf;
11585 }
11586 }
11587 if (match)
11588 {
11589 if (loop == 0)
11590 {
11591 if (is_term_opt)
11592 num_term++;
11593 else
11594 num_normal++;
11595 }
11596 else
11597 (*file)[count++] = vim_strsave(str);
11598 }
11599 }
11600 /*
11601 * Check terminal key codes, these are not in the option table
11602 */
11603 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11604 {
11605 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11606 {
11607 if (!isprint(str[0]) || !isprint(str[1]))
11608 continue;
11609
11610 name_buf[0] = 't';
11611 name_buf[1] = '_';
11612 name_buf[2] = str[0];
11613 name_buf[3] = str[1];
11614 name_buf[4] = NUL;
11615
11616 match = FALSE;
11617 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11618 match = TRUE;
11619 else
11620 {
11621 name_buf[0] = '<';
11622 name_buf[1] = 't';
11623 name_buf[2] = '_';
11624 name_buf[3] = str[0];
11625 name_buf[4] = str[1];
11626 name_buf[5] = '>';
11627 name_buf[6] = NUL;
11628
11629 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11630 match = TRUE;
11631 }
11632 if (match)
11633 {
11634 if (loop == 0)
11635 num_term++;
11636 else
11637 (*file)[count++] = vim_strsave(name_buf);
11638 }
11639 }
11640
11641 /*
11642 * Check special key names.
11643 */
11644 regmatch->rm_ic = TRUE; /* ignore case here */
11645 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11646 {
11647 name_buf[0] = '<';
11648 STRCPY(name_buf + 1, str);
11649 STRCAT(name_buf, ">");
11650
11651 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11652 {
11653 if (loop == 0)
11654 num_term++;
11655 else
11656 (*file)[count++] = vim_strsave(name_buf);
11657 }
11658 }
11659 }
11660 if (loop == 0)
11661 {
11662 if (num_normal > 0)
11663 *num_file = num_normal;
11664 else if (num_term > 0)
11665 *num_file = num_term;
11666 else
11667 return OK;
11668 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11669 if (*file == NULL)
11670 {
11671 *file = (char_u **)"";
11672 return FAIL;
11673 }
11674 }
11675 }
11676 return OK;
11677}
11678
11679 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011680ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011681{
11682 char_u *var = NULL; /* init for GCC */
11683 char_u *buf;
11684
11685 *num_file = 0;
11686 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11687 if (*file == NULL)
11688 return FAIL;
11689
11690 /*
11691 * For a terminal key code expand_option_idx is < 0.
11692 */
11693 if (expand_option_idx < 0)
11694 {
11695 var = find_termcode(expand_option_name + 2);
11696 if (var == NULL)
11697 expand_option_idx = findoption(expand_option_name);
11698 }
11699
11700 if (expand_option_idx >= 0)
11701 {
11702 /* put string of option value in NameBuff */
11703 option_value2string(&options[expand_option_idx], expand_option_flags);
11704 var = NameBuff;
11705 }
11706 else if (var == NULL)
11707 var = (char_u *)"";
11708
11709 /* A backslash is required before some characters. This is the reverse of
11710 * what happens in do_set(). */
11711 buf = vim_strsave_escaped(var, escape_chars);
11712
11713 if (buf == NULL)
11714 {
11715 vim_free(*file);
11716 *file = NULL;
11717 return FAIL;
11718 }
11719
11720#ifdef BACKSLASH_IN_FILENAME
11721 /* For MS-Windows et al. we don't double backslashes at the start and
11722 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011723 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011724 if (var[0] == '\\' && var[1] == '\\'
11725 && expand_option_idx >= 0
11726 && (options[expand_option_idx].flags & P_EXPAND)
11727 && vim_isfilec(var[2])
11728 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011729 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011730#endif
11731
11732 *file[0] = buf;
11733 *num_file = 1;
11734 return OK;
11735}
11736#endif
11737
11738/*
11739 * Get the value for the numeric or string option *opp in a nice format into
11740 * NameBuff[]. Must not be called with a hidden option!
11741 */
11742 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011743option_value2string(
11744 struct vimoption *opp,
11745 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011746{
11747 char_u *varp;
11748
11749 varp = get_varp_scope(opp, opt_flags);
11750
11751 if (opp->flags & P_NUM)
11752 {
11753 long wc = 0;
11754
11755 if (wc_use_keyname(varp, &wc))
11756 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11757 else if (wc != 0)
11758 STRCPY(NameBuff, transchar((int)wc));
11759 else
11760 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11761 }
11762 else /* P_STRING */
11763 {
11764 varp = *(char_u **)(varp);
11765 if (varp == NULL) /* just in case */
11766 NameBuff[0] = NUL;
11767#ifdef FEAT_CRYPT
11768 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011769 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011770 STRCPY(NameBuff, "*****");
11771#endif
11772 else if (opp->flags & P_EXPAND)
11773 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11774 /* Translate 'pastetoggle' into special key names */
11775 else if ((char_u **)opp->var == &p_pt)
11776 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11777 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011778 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011779 }
11780}
11781
11782/*
11783 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11784 * printed as a keyname.
11785 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11786 */
11787 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011788wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011789{
11790 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11791 {
11792 *wcp = *(long *)varp;
11793 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11794 return TRUE;
11795 }
11796 return FALSE;
11797}
11798
Bram Moolenaar01615492015-02-03 13:00:38 +010011799#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011800/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011801 * Any character has an equivalent 'langmap' character. This is used for
11802 * keyboards that have a special language mode that sends characters above
11803 * 128 (although other characters can be translated too). The "to" field is a
11804 * Vim command character. This avoids having to switch the keyboard back to
11805 * ASCII mode when leaving Insert mode.
11806 *
11807 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11808 * commands.
11809 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11810 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11811 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011812 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011813# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011814/*
11815 * With multi-byte support use growarray for 'langmap' chars >= 256
11816 */
11817typedef struct
11818{
11819 int from;
11820 int to;
11821} langmap_entry_T;
11822
11823static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011824static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011825
11826/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011827 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11828 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011829 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011830 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011831langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011832{
11833 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011834 int a = 0;
11835 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011836
11837 /* Do a binary search for an existing entry. */
11838 while (a != b)
11839 {
11840 int i = (a + b) / 2;
11841 int d = entries[i].from - from;
11842
11843 if (d == 0)
11844 {
11845 entries[i].to = to;
11846 return;
11847 }
11848 if (d < 0)
11849 a = i + 1;
11850 else
11851 b = i;
11852 }
11853
11854 if (ga_grow(&langmap_mapga, 1) != OK)
11855 return; /* out of memory */
11856
11857 /* insert new entry at position "a" */
11858 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11859 mch_memmove(entries + 1, entries,
11860 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11861 ++langmap_mapga.ga_len;
11862 entries[0].from = from;
11863 entries[0].to = to;
11864}
11865
11866/*
11867 * Apply 'langmap' to multi-byte character "c" and return the result.
11868 */
11869 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011870langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011871{
11872 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11873 int a = 0;
11874 int b = langmap_mapga.ga_len;
11875
11876 while (a != b)
11877 {
11878 int i = (a + b) / 2;
11879 int d = entries[i].from - c;
11880
11881 if (d == 0)
11882 return entries[i].to; /* found matching entry */
11883 if (d < 0)
11884 a = i + 1;
11885 else
11886 b = i;
11887 }
11888 return c; /* no entry found, return "c" unmodified */
11889}
11890# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011891
11892 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011893langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011894{
11895 int i;
11896
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011897 for (i = 0; i < 256; i++)
11898 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11899# ifdef FEAT_MBYTE
11900 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11901# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011902}
11903
11904/*
11905 * Called when langmap option is set; the language map can be
11906 * changed at any time!
11907 */
11908 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011909langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011910{
11911 char_u *p;
11912 char_u *p2;
11913 int from, to;
11914
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011915#ifdef FEAT_MBYTE
11916 ga_clear(&langmap_mapga); /* clear the previous map first */
11917#endif
11918 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011919
11920 for (p = p_langmap; p[0] != NUL; )
11921 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011922 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011923 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011924 {
11925 if (p2[0] == '\\' && p2[1] != NUL)
11926 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011927 }
11928 if (p2[0] == ';')
11929 ++p2; /* abcd;ABCD form, p2 points to A */
11930 else
11931 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11932 while (p[0])
11933 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011934 if (p[0] == ',')
11935 {
11936 ++p;
11937 break;
11938 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011939 if (p[0] == '\\' && p[1] != NUL)
11940 ++p;
11941#ifdef FEAT_MBYTE
11942 from = (*mb_ptr2char)(p);
11943#else
11944 from = p[0];
11945#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011946 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011947 if (p2 == NULL)
11948 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011949 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011950 if (p[0] != ',')
11951 {
11952 if (p[0] == '\\')
11953 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011954#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011955 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011956#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011957 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011958#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011959 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011960 }
11961 else
11962 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011963 if (p2[0] != ',')
11964 {
11965 if (p2[0] == '\\')
11966 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011967#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011968 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011969#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011970 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011971#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011972 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011973 }
11974 if (to == NUL)
11975 {
11976 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11977 transchar(from));
11978 return;
11979 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011980
11981#ifdef FEAT_MBYTE
11982 if (from >= 256)
11983 langmap_set_entry(from, to);
11984 else
11985#endif
11986 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011987
11988 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011989 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011990 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011991 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011992 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011993 if (*p == ';')
11994 {
11995 p = p2;
11996 if (p[0] != NUL)
11997 {
11998 if (p[0] != ',')
11999 {
12000 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12001 return;
12002 }
12003 ++p;
12004 }
12005 break;
12006 }
12007 }
12008 }
12009 }
12010}
12011#endif
12012
12013/*
12014 * Return TRUE if format option 'x' is in effect.
12015 * Take care of no formatting when 'paste' is set.
12016 */
12017 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012018has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012019{
12020 if (p_paste)
12021 return FALSE;
12022 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12023}
12024
12025/*
12026 * Return TRUE if "x" is present in 'shortmess' option, or
12027 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12028 */
12029 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012030shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012031{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012032 return p_shm != NULL &&
12033 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012034 || (vim_strchr(p_shm, 'a') != NULL
12035 && vim_strchr((char_u *)SHM_A, x) != NULL));
12036}
12037
12038/*
12039 * paste_option_changed() - Called after p_paste was set or reset.
12040 */
12041 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012042paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012043{
12044 static int old_p_paste = FALSE;
12045 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012046 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012047#ifdef FEAT_CMDL_INFO
12048 static int save_ru = 0;
12049#endif
12050#ifdef FEAT_RIGHTLEFT
12051 static int save_ri = 0;
12052 static int save_hkmap = 0;
12053#endif
12054 buf_T *buf;
12055
12056 if (p_paste)
12057 {
12058 /*
12059 * Paste switched from off to on.
12060 * Save the current values, so they can be restored later.
12061 */
12062 if (!old_p_paste)
12063 {
12064 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012065 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012066 {
12067 buf->b_p_tw_nopaste = buf->b_p_tw;
12068 buf->b_p_wm_nopaste = buf->b_p_wm;
12069 buf->b_p_sts_nopaste = buf->b_p_sts;
12070 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012071 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012072 }
12073
12074 /* save global options */
12075 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012076 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012077#ifdef FEAT_CMDL_INFO
12078 save_ru = p_ru;
12079#endif
12080#ifdef FEAT_RIGHTLEFT
12081 save_ri = p_ri;
12082 save_hkmap = p_hkmap;
12083#endif
12084 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012085 p_ai_nopaste = p_ai;
12086 p_et_nopaste = p_et;
12087 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012088 p_tw_nopaste = p_tw;
12089 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012090 }
12091
12092 /*
12093 * Always set the option values, also when 'paste' is set when it is
12094 * already on.
12095 */
12096 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012097 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012098 {
12099 buf->b_p_tw = 0; /* textwidth is 0 */
12100 buf->b_p_wm = 0; /* wrapmargin is 0 */
12101 buf->b_p_sts = 0; /* softtabstop is 0 */
12102 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012103 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012104 }
12105
12106 /* set global options */
12107 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012108 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012109#ifdef FEAT_CMDL_INFO
12110# ifdef FEAT_WINDOWS
12111 if (p_ru)
12112 status_redraw_all(); /* redraw to remove the ruler */
12113# endif
12114 p_ru = 0; /* no ruler */
12115#endif
12116#ifdef FEAT_RIGHTLEFT
12117 p_ri = 0; /* no reverse insert */
12118 p_hkmap = 0; /* no Hebrew keyboard */
12119#endif
12120 /* set global values for local buffer options */
12121 p_tw = 0;
12122 p_wm = 0;
12123 p_sts = 0;
12124 p_ai = 0;
12125 }
12126
12127 /*
12128 * Paste switched from on to off: Restore saved values.
12129 */
12130 else if (old_p_paste)
12131 {
12132 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012133 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012134 {
12135 buf->b_p_tw = buf->b_p_tw_nopaste;
12136 buf->b_p_wm = buf->b_p_wm_nopaste;
12137 buf->b_p_sts = buf->b_p_sts_nopaste;
12138 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012139 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012140 }
12141
12142 /* restore global options */
12143 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012144 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012145#ifdef FEAT_CMDL_INFO
12146# ifdef FEAT_WINDOWS
12147 if (p_ru != save_ru)
12148 status_redraw_all(); /* redraw to draw the ruler */
12149# endif
12150 p_ru = save_ru;
12151#endif
12152#ifdef FEAT_RIGHTLEFT
12153 p_ri = save_ri;
12154 p_hkmap = save_hkmap;
12155#endif
12156 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012157 p_ai = p_ai_nopaste;
12158 p_et = p_et_nopaste;
12159 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012160 p_tw = p_tw_nopaste;
12161 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012162 }
12163
12164 old_p_paste = p_paste;
12165}
12166
12167/*
12168 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12169 *
12170 * Reset 'compatible' and set the values for options that didn't get set yet
12171 * to the Vim defaults.
12172 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012173 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012174 */
12175 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012176vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012177{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012178 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012179 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012180 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012181
12182 if (!option_was_set((char_u *)"cp"))
12183 {
12184 p_cp = FALSE;
12185 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12186 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12187 set_option_default(opt_idx, OPT_FREE, FALSE);
12188 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012189 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012190 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012191
12192 if (fname != NULL)
12193 {
12194 p = vim_getenv(envname, &dofree);
12195 if (p == NULL)
12196 {
12197 /* Set $MYVIMRC to the first vimrc file found. */
12198 p = FullName_save(fname, FALSE);
12199 if (p != NULL)
12200 {
12201 vim_setenv(envname, p);
12202 vim_free(p);
12203 }
12204 }
12205 else if (dofree)
12206 vim_free(p);
12207 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012208}
12209
12210/*
12211 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12212 */
12213 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012214change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012215{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012216 int opt_idx;
12217
Bram Moolenaar071d4272004-06-13 20:20:40 +000012218 if (p_cp != on)
12219 {
12220 p_cp = on;
12221 compatible_set();
12222 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012223 opt_idx = findoption((char_u *)"cp");
12224 if (opt_idx >= 0)
12225 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012226}
12227
12228/*
12229 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012230 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012231 */
12232 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012233option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012234{
12235 int idx;
12236
12237 idx = findoption(name);
12238 if (idx < 0) /* unknown option */
12239 return FALSE;
12240 if (options[idx].flags & P_WAS_SET)
12241 return TRUE;
12242 return FALSE;
12243}
12244
12245/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012246 * Reset the flag indicating option "name" was set.
12247 */
12248 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012249reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012250{
12251 int idx = findoption(name);
12252
12253 if (idx >= 0)
12254 options[idx].flags &= ~P_WAS_SET;
12255}
12256
12257/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012258 * compatible_set() - Called when 'compatible' has been set or unset.
12259 *
12260 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12261 * flag) to a Vi compatible value.
12262 * When 'compatible' is unset: Set all options that have a different default
12263 * for Vim (without the P_VI_DEF flag) to that default.
12264 */
12265 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012266compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012267{
12268 int opt_idx;
12269
12270 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12271 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12272 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12273 set_option_default(opt_idx, OPT_FREE, p_cp);
12274 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012275 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012276}
12277
12278#ifdef FEAT_LINEBREAK
12279
12280# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12281 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012282 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012283# endif
12284
12285/*
12286 * fill_breakat_flags() -- called when 'breakat' changes value.
12287 */
12288 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012289fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012290{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012291 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012292 int i;
12293
12294 for (i = 0; i < 256; i++)
12295 breakat_flags[i] = FALSE;
12296
12297 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012298 for (p = p_breakat; *p; p++)
12299 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012300}
12301
12302# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012303 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012304# endif
12305
12306#endif
12307
12308/*
12309 * Check an option that can be a range of string values.
12310 *
12311 * Return OK for correct value, FAIL otherwise.
12312 * Empty is always OK.
12313 */
12314 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012315check_opt_strings(
12316 char_u *val,
12317 char **values,
12318 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012319{
12320 return opt_strings_flags(val, values, NULL, list);
12321}
12322
12323/*
12324 * Handle an option that can be a range of string values.
12325 * Set a flag in "*flagp" for each string present.
12326 *
12327 * Return OK for correct value, FAIL otherwise.
12328 * Empty is always OK.
12329 */
12330 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012331opt_strings_flags(
12332 char_u *val, /* new value */
12333 char **values, /* array of valid string values */
12334 unsigned *flagp,
12335 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012336{
12337 int i;
12338 int len;
12339 unsigned new_flags = 0;
12340
12341 while (*val)
12342 {
12343 for (i = 0; ; ++i)
12344 {
12345 if (values[i] == NULL) /* val not found in values[] */
12346 return FAIL;
12347
12348 len = (int)STRLEN(values[i]);
12349 if (STRNCMP(values[i], val, len) == 0
12350 && ((list && val[len] == ',') || val[len] == NUL))
12351 {
12352 val += len + (val[len] == ',');
12353 new_flags |= (1 << i);
12354 break; /* check next item in val list */
12355 }
12356 }
12357 }
12358 if (flagp != NULL)
12359 *flagp = new_flags;
12360
12361 return OK;
12362}
12363
12364/*
12365 * Read the 'wildmode' option, fill wim_flags[].
12366 */
12367 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012368check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012369{
12370 char_u new_wim_flags[4];
12371 char_u *p;
12372 int i;
12373 int idx = 0;
12374
12375 for (i = 0; i < 4; ++i)
12376 new_wim_flags[i] = 0;
12377
12378 for (p = p_wim; *p; ++p)
12379 {
12380 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12381 ;
12382 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12383 return FAIL;
12384 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12385 new_wim_flags[idx] |= WIM_LONGEST;
12386 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12387 new_wim_flags[idx] |= WIM_FULL;
12388 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12389 new_wim_flags[idx] |= WIM_LIST;
12390 else
12391 return FAIL;
12392 p += i;
12393 if (*p == NUL)
12394 break;
12395 if (*p == ',')
12396 {
12397 if (idx == 3)
12398 return FAIL;
12399 ++idx;
12400 }
12401 }
12402
12403 /* fill remaining entries with last flag */
12404 while (idx < 3)
12405 {
12406 new_wim_flags[idx + 1] = new_wim_flags[idx];
12407 ++idx;
12408 }
12409
12410 /* only when there are no errors, wim_flags[] is changed */
12411 for (i = 0; i < 4; ++i)
12412 wim_flags[i] = new_wim_flags[i];
12413 return OK;
12414}
12415
12416/*
12417 * Check if backspacing over something is allowed.
12418 */
12419 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012420can_bs(
12421 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012422{
12423 switch (*p_bs)
12424 {
12425 case '2': return TRUE;
12426 case '1': return (what != BS_START);
12427 case '0': return FALSE;
12428 }
12429 return vim_strchr(p_bs, what) != NULL;
12430}
12431
12432/*
12433 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12434 * the file must be considered changed when the value is different.
12435 */
12436 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012437save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012438{
12439 buf->b_start_ffc = *buf->b_p_ff;
12440 buf->b_start_eol = buf->b_p_eol;
12441#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012442 buf->b_start_bomb = buf->b_p_bomb;
12443
Bram Moolenaar071d4272004-06-13 20:20:40 +000012444 /* Only use free/alloc when necessary, they take time. */
12445 if (buf->b_start_fenc == NULL
12446 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12447 {
12448 vim_free(buf->b_start_fenc);
12449 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12450 }
12451#endif
12452}
12453
12454/*
12455 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12456 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012457 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12458 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012459 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012460 * When "ignore_empty" is true don't consider a new, empty buffer to be
12461 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012462 */
12463 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012464file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012465{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012466 /* In a buffer that was never loaded the options are not valid. */
12467 if (buf->b_flags & BF_NEVERLOADED)
12468 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012469 if (ignore_empty
12470 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012471 && buf->b_ml.ml_line_count == 1
12472 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12473 return FALSE;
12474 if (buf->b_start_ffc != *buf->b_p_ff)
12475 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012476 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012477 return TRUE;
12478#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012479 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12480 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012481 if (buf->b_start_fenc == NULL)
12482 return (*buf->b_p_fenc != NUL);
12483 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12484#else
12485 return FALSE;
12486#endif
12487}
12488
12489/*
12490 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12491 */
12492 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012493check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012494{
12495 return check_opt_strings(p, p_ff_values, FALSE);
12496}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012497
12498/*
12499 * Return the effective shiftwidth value for current buffer, using the
12500 * 'tabstop' value when 'shiftwidth' is zero.
12501 */
12502 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012503get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012504{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012505 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012506}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012507
12508/*
12509 * Return the effective softtabstop value for the current buffer, using the
12510 * 'tabstop' value when 'softtabstop' is negative.
12511 */
12512 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012513get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012514{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012515 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012516}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012517
12518/*
12519 * Check matchpairs option for "*initc".
12520 * If there is a match set "*initc" to the matching character and "*findc" to
12521 * the opposite character. Set "*backwards" to the direction.
12522 * When "switchit" is TRUE swap the direction.
12523 */
12524 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012525find_mps_values(
12526 int *initc,
12527 int *findc,
12528 int *backwards,
12529 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012530{
12531 char_u *ptr;
12532
12533 ptr = curbuf->b_p_mps;
12534 while (*ptr != NUL)
12535 {
12536#ifdef FEAT_MBYTE
12537 if (has_mbyte)
12538 {
12539 char_u *prev;
12540
12541 if (mb_ptr2char(ptr) == *initc)
12542 {
12543 if (switchit)
12544 {
12545 *findc = *initc;
12546 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12547 *backwards = TRUE;
12548 }
12549 else
12550 {
12551 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12552 *backwards = FALSE;
12553 }
12554 return;
12555 }
12556 prev = ptr;
12557 ptr += mb_ptr2len(ptr) + 1;
12558 if (mb_ptr2char(ptr) == *initc)
12559 {
12560 if (switchit)
12561 {
12562 *findc = *initc;
12563 *initc = mb_ptr2char(prev);
12564 *backwards = FALSE;
12565 }
12566 else
12567 {
12568 *findc = mb_ptr2char(prev);
12569 *backwards = TRUE;
12570 }
12571 return;
12572 }
12573 ptr += mb_ptr2len(ptr);
12574 }
12575 else
12576#endif
12577 {
12578 if (*ptr == *initc)
12579 {
12580 if (switchit)
12581 {
12582 *backwards = TRUE;
12583 *findc = *initc;
12584 *initc = ptr[2];
12585 }
12586 else
12587 {
12588 *backwards = FALSE;
12589 *findc = ptr[2];
12590 }
12591 return;
12592 }
12593 ptr += 2;
12594 if (*ptr == *initc)
12595 {
12596 if (switchit)
12597 {
12598 *backwards = FALSE;
12599 *findc = *initc;
12600 *initc = ptr[-2];
12601 }
12602 else
12603 {
12604 *backwards = TRUE;
12605 *findc = ptr[-2];
12606 }
12607 return;
12608 }
12609 ++ptr;
12610 }
12611 if (*ptr == ',')
12612 ++ptr;
12613 }
12614}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012615
12616#if defined(FEAT_LINEBREAK) || defined(PROTO)
12617/*
12618 * This is called when 'breakindentopt' is changed and when a window is
12619 * initialized.
12620 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012621 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012622briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012623{
12624 char_u *p;
12625 int bri_shift = 0;
12626 long bri_min = 20;
12627 int bri_sbr = FALSE;
12628
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012629 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012630 while (*p != NUL)
12631 {
12632 if (STRNCMP(p, "shift:", 6) == 0
12633 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12634 {
12635 p += 6;
12636 bri_shift = getdigits(&p);
12637 }
12638 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12639 {
12640 p += 4;
12641 bri_min = getdigits(&p);
12642 }
12643 else if (STRNCMP(p, "sbr", 3) == 0)
12644 {
12645 p += 3;
12646 bri_sbr = TRUE;
12647 }
12648 if (*p != ',' && *p != NUL)
12649 return FAIL;
12650 if (*p == ',')
12651 ++p;
12652 }
12653
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012654 wp->w_p_brishift = bri_shift;
12655 wp->w_p_brimin = bri_min;
12656 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012657
12658 return OK;
12659}
12660#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012661
12662/*
12663 * Get the local or global value of 'backupcopy'.
12664 */
12665 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012666get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012667{
12668 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12669}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012670
12671#if defined(FEAT_SIGNS) || defined(PROTO)
12672/*
12673 * Return TRUE when window "wp" has a column to draw signs in.
12674 */
12675 int
12676signcolumn_on(win_T *wp)
12677{
12678 if (*wp->w_p_scl == 'n')
12679 return FALSE;
12680 if (*wp->w_p_scl == 'y')
12681 return TRUE;
12682 return (wp->w_buffer->b_signlist != NULL
12683# ifdef FEAT_NETBEANS_INTG
12684 || wp->w_buffer->b_has_sign_column
12685# endif
12686 );
12687}
12688#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012689
12690#if defined(FEAT_EVAL) || defined(PROTO)
12691/*
12692 * Get window or buffer local options.
12693 */
12694 dict_T *
12695get_winbuf_options(int bufopt)
12696{
12697 dict_T *d;
12698 int opt_idx;
12699
12700 d = dict_alloc();
12701 if (d == NULL)
12702 return NULL;
12703
12704 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12705 {
12706 struct vimoption *opt = &options[opt_idx];
12707
12708 if ((bufopt && (opt->indir & PV_BUF))
12709 || (!bufopt && (opt->indir & PV_WIN)))
12710 {
12711 char_u *varp = get_varp(opt);
12712
12713 if (varp != NULL)
12714 {
12715 if (opt->flags & P_STRING)
12716 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012717 else if (opt->flags & P_NUM)
12718 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012719 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012720 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012721 }
12722 }
12723 }
12724
12725 return d;
12726}
12727#endif