blob: a65149785a4a2764bef024d0ebe941c87eda554a [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 Moolenaar81bdd6a2017-07-23 22:57:00 +020060#define PV_BH OPT_BUF(BV_BH)
61#define PV_BT OPT_BUF(BV_BT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000063# 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
Bram Moolenaar1b0675c2017-07-15 14:04:01 +0200261# define PV_TK OPT_WIN(WV_TK)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200262# define PV_TMS OPT_WIN(WV_TMS)
263#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200264#ifdef FEAT_SIGNS
265# define PV_SCL OPT_WIN(WV_SCL)
266#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000267
268/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269typedef enum
270{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000271 PV_NONE = 0,
272 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000273} idopt_T;
274
275/*
276 * Options local to a window have a value local to a buffer and global to all
277 * buffers. Indicate this by setting "var" to VAR_WIN.
278 */
279#define VAR_WIN ((char_u *)-1)
280
281/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000282 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283 * Only to be used in option.c!
284 */
285static int p_ai;
286static int p_bin;
287#ifdef FEAT_MBYTE
288static int p_bomb;
289#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290static char_u *p_bh;
291static char_u *p_bt;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292static int p_bl;
293static int p_ci;
294#ifdef FEAT_CINDENT
295static int p_cin;
296static char_u *p_cink;
297static char_u *p_cino;
298#endif
299#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
300static char_u *p_cinw;
301#endif
302#ifdef FEAT_COMMENTS
303static char_u *p_com;
304#endif
305#ifdef FEAT_FOLDING
306static char_u *p_cms;
307#endif
308#ifdef FEAT_INS_EXPAND
309static char_u *p_cpt;
310#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000311#ifdef FEAT_COMPL_FUNC
312static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000313static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000314#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200316static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000317static int p_et;
318#ifdef FEAT_MBYTE
319static char_u *p_fenc;
320#endif
321static char_u *p_ff;
322static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000323static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000324#ifdef FEAT_AUTOCMD
325static char_u *p_ft;
326#endif
327static long p_iminsert;
328static long p_imsearch;
329#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
330static char_u *p_inex;
331#endif
332#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
333static char_u *p_inde;
334static char_u *p_indk;
335#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000336#if defined(FEAT_EVAL)
337static char_u *p_fex;
338#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000339static int p_inf;
340static char_u *p_isk;
341#ifdef FEAT_CRYPT
342static char_u *p_key;
343#endif
344#ifdef FEAT_LISP
345static int p_lisp;
346#endif
347static int p_ml;
348static int p_ma;
349static int p_mod;
350static char_u *p_mps;
351static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000353#ifdef FEAT_TEXTOBJ
354static char_u *p_qe;
355#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356static int p_ro;
357#ifdef FEAT_SMARTINDENT
358static int p_si;
359#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361static long p_sts;
362#if defined(FEAT_SEARCHPATH)
363static char_u *p_sua;
364#endif
365static long p_sw;
366static int p_swf;
367#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000368static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000370#endif
371#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000372static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000373static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000374static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000375#endif
376static long p_ts;
377static long p_tw;
378static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200379#ifdef FEAT_PERSISTENT_UNDO
380static int p_udf;
381#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382static long p_wm;
383#ifdef FEAT_KEYMAP
384static char_u *p_keymap;
385#endif
386
387/* Saved values for when 'bin' is set. */
388static int p_et_nobin;
389static int p_ml_nobin;
390static long p_tw_nobin;
391static long p_wm_nobin;
392
393/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200394static int p_ai_nopaste;
395static int p_et_nopaste;
396static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397static long p_tw_nopaste;
398static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399
400struct vimoption
401{
402 char *fullname; /* full option name */
403 char *shortname; /* permissible abbreviation */
404 long_u flags; /* see below */
405 char_u *var; /* global option: pointer to variable;
406 * window-local option: VAR_WIN;
407 * buffer-local option: global value */
408 idopt_T indir; /* global option: PV_NONE;
409 * local option: indirect option index */
410 char_u *def_val[2]; /* default values for variable (vi and vim) */
411#ifdef FEAT_EVAL
412 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000413# define SCRIPTID_INIT , 0
414#else
415# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416#endif
417};
418
419#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
420#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
421
422/*
423 * Flags
424 */
425#define P_BOOL 0x01 /* the option is boolean */
426#define P_NUM 0x02 /* the option is numeric */
427#define P_STRING 0x04 /* the option is a string */
428#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000429 must use free_string_option() when
430 assigning new value. Not set if default is
431 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
433 never be used for local or hidden options! */
434#define P_NODEFAULT 0x40 /* don't set to default value */
435#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
436 use vim_free() when assigning new value */
437#define P_WAS_SET 0x100 /* option has been set/reset */
438#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
439#define P_VI_DEF 0x400 /* Use Vi default for Vim */
440#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
441
442 /* when option changed, what to display: */
443#define P_RSTAT 0x1000 /* redraw status lines */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100444#define P_RWIN 0x2000 /* redraw current window and recompute text */
445#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446#define P_RALL 0x6000 /* redraw all windows */
447#define P_RCLR 0x7000 /* clear and redraw all */
448
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200449#define P_COMMA 0x8000 /* comma separated list */
450#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
451 * commas */
452#define P_NODUP 0x20000L /* don't allow duplicate strings */
453#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200455#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
456#define P_GETTEXT 0x100000L /* expand default value with _() */
457#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
458#define P_NFNAME 0x400000L /* only normal file name chars allowed */
459#define P_INSECURE 0x800000L /* option was set from a modeline */
460#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100461 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200462#define P_NO_ML 0x2000000L /* not allowed in modeline */
463#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200464 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100465#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100466#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000468#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
469
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000470/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
471 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100472#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000473# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000474#else
475# define ISP_LATIN1 (char_u *)"@,161-255"
476#endif
477
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100478/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000479#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100480 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar21020352017-06-13 17:21:04 +0200481 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) \
Bram Moolenaar3633cf52017-07-31 22:29:35 +0200482 || defined(FEAT_CONCEAL) || defined(FEAT_QUICKFIX) \
483 || defined(FEAT_TERMINAL)
Bram Moolenaar05fbfdc2017-08-14 22:35:08 +0200484# 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,z:StatusLineTerm,Z:StatusLineTermNC"
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,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000722 (char_u *)&p_bh, PV_BH,
723 {(char_u *)"", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000724 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000725 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
726 (char_u *)&p_bl, PV_BL,
727 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000728 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000729 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000730 (char_u *)&p_bt, PV_BT,
731 {(char_u *)"", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000732 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200733 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000734#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000735 (char_u *)&p_cmp, PV_NONE,
736 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000737#else
738 (char_u *)NULL, PV_NONE,
739 {(char_u *)0L, (char_u *)0L}
740#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000741 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000742 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
743#ifdef FEAT_SEARCHPATH
744 (char_u *)&p_cdpath, PV_NONE,
745 {(char_u *)",,", (char_u *)0L}
746#else
747 (char_u *)NULL, PV_NONE,
748 {(char_u *)0L, (char_u *)0L}
749#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000750 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000751 {"cedit", NULL, P_STRING,
752#ifdef FEAT_CMDWIN
753 (char_u *)&p_cedit, PV_NONE,
754 {(char_u *)"", (char_u *)CTRL_F_STR}
755#else
756 (char_u *)NULL, PV_NONE,
757 {(char_u *)0L, (char_u *)0L}
758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000759 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000760 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
761#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
762 (char_u *)&p_ccv, PV_NONE,
763 {(char_u *)"", (char_u *)0L}
764#else
765 (char_u *)NULL, PV_NONE,
766 {(char_u *)0L, (char_u *)0L}
767#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000768 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000769 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
770#ifdef FEAT_CINDENT
771 (char_u *)&p_cin, PV_CIN,
772#else
773 (char_u *)NULL, PV_NONE,
774#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000775 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200776 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000777#ifdef FEAT_CINDENT
778 (char_u *)&p_cink, PV_CINK,
779 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
780#else
781 (char_u *)NULL, PV_NONE,
782 {(char_u *)0L, (char_u *)0L}
783#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000784 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200785 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000786#ifdef FEAT_CINDENT
787 (char_u *)&p_cino, PV_CINO,
788#else
789 (char_u *)NULL, PV_NONE,
790#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000791 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200792 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000793#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
794 (char_u *)&p_cinw, PV_CINW,
795 {(char_u *)"if,else,while,do,for,switch",
796 (char_u *)0L}
797#else
798 (char_u *)NULL, PV_NONE,
799 {(char_u *)0L, (char_u *)0L}
800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000801 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200802 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000803#ifdef FEAT_CLIPBOARD
804 (char_u *)&p_cb, PV_NONE,
805# ifdef FEAT_XCLIPBOARD
806 {(char_u *)"autoselect,exclude:cons\\|linux",
807 (char_u *)0L}
808# else
809 {(char_u *)"", (char_u *)0L}
810# endif
811#else
812 (char_u *)NULL, PV_NONE,
813 {(char_u *)"", (char_u *)0L}
814#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000815 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000816 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
817 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000818 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000819 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
820#ifdef FEAT_CMDWIN
821 (char_u *)&p_cwh, PV_NONE,
822#else
823 (char_u *)NULL, PV_NONE,
824#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000825 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200826 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200827#ifdef FEAT_SYN_HL
828 (char_u *)VAR_WIN, PV_CC,
829#else
830 (char_u *)NULL, PV_NONE,
831#endif
832 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000833 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
834 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000835 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200836 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
837 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000838#ifdef FEAT_COMMENTS
839 (char_u *)&p_com, PV_COM,
840 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
841 (char_u *)0L}
842#else
843 (char_u *)NULL, PV_NONE,
844 {(char_u *)0L, (char_u *)0L}
845#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000846 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200847 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000848#ifdef FEAT_FOLDING
849 (char_u *)&p_cms, PV_CMS,
850 {(char_u *)"/*%s*/", (char_u *)0L}
851#else
852 (char_u *)NULL, PV_NONE,
853 {(char_u *)0L, (char_u *)0L}
854#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000855 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000856 /* P_PRI_MKRC isn't needed here, optval_default()
857 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000858 {"compatible", "cp", P_BOOL|P_RALL,
859 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000860 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200861 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000862#ifdef FEAT_INS_EXPAND
863 (char_u *)&p_cpt, PV_CPT,
864 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
865#else
866 (char_u *)NULL, PV_NONE,
867 {(char_u *)0L, (char_u *)0L}
868#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000869 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200870 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200871#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200872 (char_u *)VAR_WIN, PV_COCU,
873 {(char_u *)"", (char_u *)NULL}
874#else
875 (char_u *)NULL, PV_NONE,
876 {(char_u *)NULL, (char_u *)0L}
877#endif
878 SCRIPTID_INIT},
879 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
880#ifdef FEAT_CONCEAL
881 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200882#else
883 (char_u *)NULL, PV_NONE,
884#endif
885 {(char_u *)0L, (char_u *)0L}
886 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000887 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
888#ifdef FEAT_COMPL_FUNC
889 (char_u *)&p_cfu, PV_CFU,
890 {(char_u *)"", (char_u *)0L}
891#else
892 (char_u *)NULL, PV_NONE,
893 {(char_u *)0L, (char_u *)0L}
894#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000895 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200896 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000897#ifdef FEAT_INS_EXPAND
898 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000899 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000900#else
901 (char_u *)NULL, PV_NONE,
902 {(char_u *)0L, (char_u *)0L}
903#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000904 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000905 {"confirm", "cf", P_BOOL|P_VI_DEF,
906#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
907 (char_u *)&p_confirm, PV_NONE,
908#else
909 (char_u *)NULL, PV_NONE,
910#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000911 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000912 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000913 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000914 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000915 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
916 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000917 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000918 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
919 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000920 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
921 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200922 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200923#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200924 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200925 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200926#else
927 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200928 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200929#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200930 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000931 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
932#ifdef FEAT_CSCOPE
933 (char_u *)&p_cspc, PV_NONE,
934#else
935 (char_u *)NULL, PV_NONE,
936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000937 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000938 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
939#ifdef FEAT_CSCOPE
940 (char_u *)&p_csprg, PV_NONE,
941 {(char_u *)"cscope", (char_u *)0L}
942#else
943 (char_u *)NULL, PV_NONE,
944 {(char_u *)0L, (char_u *)0L}
945#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000946 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200947 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
949 (char_u *)&p_csqf, PV_NONE,
950 {(char_u *)"", (char_u *)0L}
951#else
952 (char_u *)NULL, PV_NONE,
953 {(char_u *)0L, (char_u *)0L}
954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000955 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200956 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
957#ifdef FEAT_CSCOPE
958 (char_u *)&p_csre, PV_NONE,
959#else
960 (char_u *)NULL, PV_NONE,
961#endif
962 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000963 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
964#ifdef FEAT_CSCOPE
965 (char_u *)&p_cst, PV_NONE,
966#else
967 (char_u *)NULL, PV_NONE,
968#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000969 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000970 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
971#ifdef FEAT_CSCOPE
972 (char_u *)&p_csto, PV_NONE,
973#else
974 (char_u *)NULL, PV_NONE,
975#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000976 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
978#ifdef FEAT_CSCOPE
979 (char_u *)&p_csverbose, PV_NONE,
980#else
981 (char_u *)NULL, PV_NONE,
982#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000983 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200984 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
985#ifdef FEAT_CURSORBIND
986 (char_u *)VAR_WIN, PV_CRBIND,
987#else
988 (char_u *)NULL, PV_NONE,
989#endif
990 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000991 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
992#ifdef FEAT_SYN_HL
993 (char_u *)VAR_WIN, PV_CUC,
994#else
995 (char_u *)NULL, PV_NONE,
996#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000997 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100998 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000999#ifdef FEAT_SYN_HL
1000 (char_u *)VAR_WIN, PV_CUL,
1001#else
1002 (char_u *)NULL, PV_NONE,
1003#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001004 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001005 {"debug", NULL, P_STRING|P_VI_DEF,
1006 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001007 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001008 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001010 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001011 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012#else
1013 (char_u *)NULL, PV_NONE,
1014 {(char_u *)NULL, (char_u *)0L}
1015#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001016 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001017 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1018#ifdef FEAT_MBYTE
1019 (char_u *)&p_deco, PV_NONE,
1020#else
1021 (char_u *)NULL, PV_NONE,
1022#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001023 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001024 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001025#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001026 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027#else
1028 (char_u *)NULL, PV_NONE,
1029#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001030 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1032#ifdef FEAT_DIFF
1033 (char_u *)VAR_WIN, PV_DIFF,
1034#else
1035 (char_u *)NULL, PV_NONE,
1036#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001037 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001038 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1040 (char_u *)&p_dex, PV_NONE,
1041 {(char_u *)"", (char_u *)0L}
1042#else
1043 (char_u *)NULL, PV_NONE,
1044 {(char_u *)0L, (char_u *)0L}
1045#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001046 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001047 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1048 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049#ifdef FEAT_DIFF
1050 (char_u *)&p_dip, PV_NONE,
1051 {(char_u *)"filler", (char_u *)NULL}
1052#else
1053 (char_u *)NULL, PV_NONE,
1054 {(char_u *)"", (char_u *)NULL}
1055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001056 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001057 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1058#ifdef FEAT_DIGRAPHS
1059 (char_u *)&p_dg, PV_NONE,
1060#else
1061 (char_u *)NULL, PV_NONE,
1062#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001063 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001064 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1065 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001067 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001068 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001070 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001072#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 (char_u *)&p_ead, PV_NONE,
1074 {(char_u *)"both", (char_u *)0L}
1075#else
1076 (char_u *)NULL, PV_NONE,
1077 {(char_u *)NULL, (char_u *)0L}
1078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1081 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001083 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1084#if defined(FEAT_MBYTE)
1085 (char_u *)&p_emoji, PV_NONE,
1086 {(char_u *)TRUE, (char_u *)0L}
1087#else
1088 (char_u *)NULL, PV_NONE,
1089 {(char_u *)0L, (char_u *)0L}
1090#endif
1091 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001092 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001093#ifdef FEAT_MBYTE
1094 (char_u *)&p_enc, PV_NONE,
1095 {(char_u *)ENC_DFLT, (char_u *)0L}
1096#else
1097 (char_u *)NULL, PV_NONE,
1098 {(char_u *)0L, (char_u *)0L}
1099#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001100 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1102 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1105 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001108 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1111 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001112 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1114#ifdef FEAT_QUICKFIX
1115 (char_u *)&p_ef, PV_NONE,
1116 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1117#else
1118 (char_u *)NULL, PV_NONE,
1119 {(char_u *)NULL, (char_u *)0L}
1120#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001121 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001122 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001124 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001125 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001126#else
1127 (char_u *)NULL, PV_NONE,
1128 {(char_u *)NULL, (char_u *)0L}
1129#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001130 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 {"esckeys", "ek", P_BOOL|P_VIM,
1132 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001133 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001134 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001135#ifdef FEAT_AUTOCMD
1136 (char_u *)&p_ei, PV_NONE,
1137#else
1138 (char_u *)NULL, PV_NONE,
1139#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001140 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1142 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001143 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1145 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001146 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001147 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1148 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149#ifdef FEAT_MBYTE
1150 (char_u *)&p_fenc, PV_FENC,
1151 {(char_u *)"", (char_u *)0L}
1152#else
1153 (char_u *)NULL, PV_NONE,
1154 {(char_u *)0L, (char_u *)0L}
1155#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001156 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001157 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158#ifdef FEAT_MBYTE
1159 (char_u *)&p_fencs, PV_NONE,
1160 {(char_u *)"ucs-bom", (char_u *)0L}
1161#else
1162 (char_u *)NULL, PV_NONE,
1163 {(char_u *)0L, (char_u *)0L}
1164#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001165 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001166 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1167 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001169 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001170 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1173 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001174 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1175 (char_u *)&p_fic, PV_NONE,
1176 {
1177#ifdef CASE_INSENSITIVE_FILENAME
1178 (char_u *)TRUE,
1179#else
1180 (char_u *)FALSE,
1181#endif
1182 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001183 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184#ifdef FEAT_AUTOCMD
1185 (char_u *)&p_ft, PV_FT,
1186 {(char_u *)"", (char_u *)0L}
1187#else
1188 (char_u *)NULL, PV_NONE,
1189 {(char_u *)0L, (char_u *)0L}
1190#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001191 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001192 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1194 (char_u *)&p_fcs, PV_NONE,
1195 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1196#else
1197 (char_u *)NULL, PV_NONE,
1198 {(char_u *)"", (char_u *)0L}
1199#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001200 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001201 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1202 (char_u *)&p_fixeol, PV_FIXEOL,
1203 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1205#ifdef FEAT_FKMAP
1206 (char_u *)&p_fkmap, PV_NONE,
1207#else
1208 (char_u *)NULL, PV_NONE,
1209#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001210 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 {"flash", "fl", P_BOOL|P_VI_DEF,
1212 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001213 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001214 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001215#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001217 {(char_u *)"", (char_u *)0L}
1218#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001219 (char_u *)NULL, PV_NONE,
1220 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001221#endif
1222 SCRIPTID_INIT},
1223 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1224#ifdef FEAT_FOLDING
1225 (char_u *)VAR_WIN, PV_FDC,
1226 {(char_u *)FALSE, (char_u *)0L}
1227#else
1228 (char_u *)NULL, PV_NONE,
1229 {(char_u *)NULL, (char_u *)0L}
1230#endif
1231 SCRIPTID_INIT},
1232 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1233#ifdef FEAT_FOLDING
1234 (char_u *)VAR_WIN, PV_FEN,
1235 {(char_u *)TRUE, (char_u *)0L}
1236#else
1237 (char_u *)NULL, PV_NONE,
1238 {(char_u *)NULL, (char_u *)0L}
1239#endif
1240 SCRIPTID_INIT},
1241 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1242#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1243 (char_u *)VAR_WIN, PV_FDE,
1244 {(char_u *)"0", (char_u *)NULL}
1245#else
1246 (char_u *)NULL, PV_NONE,
1247 {(char_u *)NULL, (char_u *)0L}
1248#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001249 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001250 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001251#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001253 {(char_u *)"#", (char_u *)NULL}
1254#else
1255 (char_u *)NULL, PV_NONE,
1256 {(char_u *)NULL, (char_u *)0L}
1257#endif
1258 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001260#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001261 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001262 {(char_u *)0L, (char_u *)0L}
1263#else
1264 (char_u *)NULL, PV_NONE,
1265 {(char_u *)NULL, (char_u *)0L}
1266#endif
1267 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001268 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001269#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001270 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001271 {(char_u *)-1L, (char_u *)0L}
1272#else
1273 (char_u *)NULL, PV_NONE,
1274 {(char_u *)NULL, (char_u *)0L}
1275#endif
1276 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001278 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001279#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001280 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001281 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001282#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001286 SCRIPTID_INIT},
1287 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1288#ifdef FEAT_FOLDING
1289 (char_u *)VAR_WIN, PV_FDM,
1290 {(char_u *)"manual", (char_u *)NULL}
1291#else
1292 (char_u *)NULL, PV_NONE,
1293 {(char_u *)NULL, (char_u *)0L}
1294#endif
1295 SCRIPTID_INIT},
1296 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1297#ifdef FEAT_FOLDING
1298 (char_u *)VAR_WIN, PV_FML,
1299 {(char_u *)1L, (char_u *)0L}
1300#else
1301 (char_u *)NULL, PV_NONE,
1302 {(char_u *)NULL, (char_u *)0L}
1303#endif
1304 SCRIPTID_INIT},
1305 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1306#ifdef FEAT_FOLDING
1307 (char_u *)VAR_WIN, PV_FDN,
1308 {(char_u *)20L, (char_u *)0L}
1309#else
1310 (char_u *)NULL, PV_NONE,
1311 {(char_u *)NULL, (char_u *)0L}
1312#endif
1313 SCRIPTID_INIT},
1314 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1315#ifdef FEAT_FOLDING
1316 (char_u *)&p_fdo, PV_NONE,
1317 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1318 (char_u *)0L}
1319#else
1320 (char_u *)NULL, PV_NONE,
1321 {(char_u *)NULL, (char_u *)0L}
1322#endif
1323 SCRIPTID_INIT},
1324 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1325#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1326 (char_u *)VAR_WIN, PV_FDT,
1327 {(char_u *)"foldtext()", (char_u *)NULL}
1328#else
1329 (char_u *)NULL, PV_NONE,
1330 {(char_u *)NULL, (char_u *)0L}
1331#endif
1332 SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001333 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001334#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001335 (char_u *)&p_fex, PV_FEX,
1336 {(char_u *)"", (char_u *)0L}
1337#else
1338 (char_u *)NULL, PV_NONE,
1339 {(char_u *)0L, (char_u *)0L}
1340#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001341 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001342 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1343 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001344 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1345 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001346 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1347 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001348 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1349 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001350 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001351 (char_u *)&p_fp, PV_FP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001352 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001353 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1354#ifdef HAVE_FSYNC
1355 (char_u *)&p_fs, PV_NONE,
1356 {(char_u *)TRUE, (char_u *)0L}
1357#else
1358 (char_u *)NULL, PV_NONE,
1359 {(char_u *)FALSE, (char_u *)0L}
1360#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001361 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1363 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001364 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 {"graphic", "gr", P_BOOL|P_VI_DEF,
1366 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001367 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001368 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369#ifdef FEAT_QUICKFIX
1370 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001371 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372#else
1373 (char_u *)NULL, PV_NONE,
1374 {(char_u *)NULL, (char_u *)0L}
1375#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001376 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001377 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1378#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001379 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001380 {
1381# ifdef WIN3264
1382 /* may be changed to "grep -n" in os_win32.c */
1383 (char_u *)"findstr /n",
1384# else
1385# ifdef UNIX
1386 /* Add an extra file name so that grep will always
1387 * insert a file name in the match line. */
1388 (char_u *)"grep -n $* /dev/null",
1389# else
1390# ifdef VMS
1391 (char_u *)"SEARCH/NUMBERS ",
1392# else
1393 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001394# endif
1395# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001396# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001397 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001398#else
1399 (char_u *)NULL, PV_NONE,
1400 {(char_u *)NULL, (char_u *)0L}
1401#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001403 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001404#ifdef CURSOR_SHAPE
1405 (char_u *)&p_guicursor, PV_NONE,
1406 {
1407# ifdef FEAT_GUI
1408 (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 +01001409# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1411# endif
1412 (char_u *)0L}
1413#else
1414 (char_u *)NULL, PV_NONE,
1415 {(char_u *)NULL, (char_u *)0L}
1416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001417 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001418 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001419#ifdef FEAT_GUI
1420 (char_u *)&p_guifont, PV_NONE,
1421 {(char_u *)"", (char_u *)0L}
1422#else
1423 (char_u *)NULL, PV_NONE,
1424 {(char_u *)NULL, (char_u *)0L}
1425#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001426 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001427 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001428#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1429 (char_u *)&p_guifontset, PV_NONE,
1430 {(char_u *)"", (char_u *)0L}
1431#else
1432 (char_u *)NULL, PV_NONE,
1433 {(char_u *)NULL, (char_u *)0L}
1434#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001435 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001436 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001437#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1438 (char_u *)&p_guifontwide, PV_NONE,
1439 {(char_u *)"", (char_u *)0L}
1440#else
1441 (char_u *)NULL, PV_NONE,
1442 {(char_u *)NULL, (char_u *)0L}
1443#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001444 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001445 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001446#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447 (char_u *)&p_ghr, PV_NONE,
1448#else
1449 (char_u *)NULL, PV_NONE,
1450#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001451 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001452 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001453#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001454 (char_u *)&p_go, PV_NONE,
1455# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001456 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001458 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001459# endif
1460#else
1461 (char_u *)NULL, PV_NONE,
1462 {(char_u *)NULL, (char_u *)0L}
1463#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001464 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001465 {"guipty", NULL, P_BOOL|P_VI_DEF,
1466#if defined(FEAT_GUI)
1467 (char_u *)&p_guipty, PV_NONE,
1468#else
1469 (char_u *)NULL, PV_NONE,
1470#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001471 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001472 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001473#if defined(FEAT_GUI_TABLINE)
1474 (char_u *)&p_gtl, PV_NONE,
1475 {(char_u *)"", (char_u *)0L}
1476#else
1477 (char_u *)NULL, PV_NONE,
1478 {(char_u *)NULL, (char_u *)0L}
1479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001480 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001481 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001482#if defined(FEAT_GUI_TABLINE)
1483 (char_u *)&p_gtt, PV_NONE,
1484 {(char_u *)"", (char_u *)0L}
1485#else
1486 (char_u *)NULL, PV_NONE,
1487 {(char_u *)NULL, (char_u *)0L}
1488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001489 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001490 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1491 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001492 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001493 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1494 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001495 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1496 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001497 {"helpheight", "hh", P_NUM|P_VI_DEF,
1498#ifdef FEAT_WINDOWS
1499 (char_u *)&p_hh, PV_NONE,
1500#else
1501 (char_u *)NULL, PV_NONE,
1502#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001503 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001504 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001505#ifdef FEAT_MULTI_LANG
1506 (char_u *)&p_hlg, PV_NONE,
1507 {(char_u *)"", (char_u *)0L}
1508#else
1509 (char_u *)NULL, PV_NONE,
1510 {(char_u *)0L, (char_u *)0L}
1511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001512 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001513 {"hidden", "hid", P_BOOL|P_VI_DEF,
1514 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001515 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001516 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001517 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001518 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1519 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001520 {"history", "hi", P_NUM|P_VIM,
1521 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001522 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001523 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1524#ifdef FEAT_RIGHTLEFT
1525 (char_u *)&p_hkmap, PV_NONE,
1526#else
1527 (char_u *)NULL, PV_NONE,
1528#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001529 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1531#ifdef FEAT_RIGHTLEFT
1532 (char_u *)&p_hkmapp, PV_NONE,
1533#else
1534 (char_u *)NULL, PV_NONE,
1535#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001536 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001537 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1538 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001540 {"icon", NULL, P_BOOL|P_VI_DEF,
1541#ifdef FEAT_TITLE
1542 (char_u *)&p_icon, 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 {"iconstring", NULL, P_STRING|P_VI_DEF,
1548#ifdef FEAT_TITLE
1549 (char_u *)&p_iconstring, PV_NONE,
1550#else
1551 (char_u *)NULL, PV_NONE,
1552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001553 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001554 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1555 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001557 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1558# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1559 (char_u *)&p_imaf, PV_NONE,
1560 {(char_u *)"", (char_u *)NULL}
1561# else
1562 (char_u *)NULL, PV_NONE,
1563 {(char_u *)NULL, (char_u *)0L}
1564# endif
1565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001566 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001567#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001568 (char_u *)&p_imak, PV_NONE,
1569#else
1570 (char_u *)NULL, PV_NONE,
1571#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001572 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001573 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1574#ifdef USE_IM_CONTROL
1575 (char_u *)&p_imcmdline, PV_NONE,
1576#else
1577 (char_u *)NULL, PV_NONE,
1578#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001579 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001580 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1581#ifdef USE_IM_CONTROL
1582 (char_u *)&p_imdisable, PV_NONE,
1583#else
1584 (char_u *)NULL, PV_NONE,
1585#endif
1586#ifdef __sgi
1587 {(char_u *)TRUE, (char_u *)0L}
1588#else
1589 {(char_u *)FALSE, (char_u *)0L}
1590#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001591 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001592 {"iminsert", "imi", P_NUM|P_VI_DEF,
1593 (char_u *)&p_iminsert, PV_IMI,
1594#ifdef B_IMODE_IM
1595 {(char_u *)B_IMODE_IM, (char_u *)0L}
1596#else
1597 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1598#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001599 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001600 {"imsearch", "ims", P_NUM|P_VI_DEF,
1601 (char_u *)&p_imsearch, PV_IMS,
1602#ifdef B_IMODE_IM
1603 {(char_u *)B_IMODE_IM, (char_u *)0L}
1604#else
1605 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001607 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001608 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001609# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1610 (char_u *)&p_imsf, PV_NONE,
1611 {(char_u *)"", (char_u *)NULL}
1612# else
1613 (char_u *)NULL, PV_NONE,
1614 {(char_u *)NULL, (char_u *)0L}
1615# endif
1616 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001617 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1618#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001619 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001620 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1621#else
1622 (char_u *)NULL, PV_NONE,
1623 {(char_u *)0L, (char_u *)0L}
1624#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001625 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001626 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1627#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1628 (char_u *)&p_inex, PV_INEX,
1629 {(char_u *)"", (char_u *)0L}
1630#else
1631 (char_u *)NULL, PV_NONE,
1632 {(char_u *)0L, (char_u *)0L}
1633#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001634 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001635 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1636 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001637 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001638 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1639#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1640 (char_u *)&p_inde, PV_INDE,
1641 {(char_u *)"", (char_u *)0L}
1642#else
1643 (char_u *)NULL, PV_NONE,
1644 {(char_u *)0L, (char_u *)0L}
1645#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001646 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001647 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001648#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1649 (char_u *)&p_indk, PV_INDK,
1650 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1651#else
1652 (char_u *)NULL, PV_NONE,
1653 {(char_u *)0L, (char_u *)0L}
1654#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001655 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001656 {"infercase", "inf", P_BOOL|P_VI_DEF,
1657 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001658 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001659 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1660 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001661 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001662 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1663 (char_u *)&p_isf, PV_NONE,
1664 {
1665#ifdef BACKSLASH_IN_FILENAME
1666 /* Excluded are: & and ^ are special in cmd.exe
1667 * ( and ) are used in text separating fnames */
1668 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1669#else
1670# ifdef AMIGA
1671 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1672# else
1673# ifdef VMS
1674 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1675# else /* UNIX et al. */
1676# ifdef EBCDIC
1677 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1678# else
1679 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1680# endif
1681# endif
1682# endif
1683#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001684 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001685 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1686 (char_u *)&p_isi, PV_NONE,
1687 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001688#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001689 (char_u *)"@,48-57,_,128-167,224-235",
1690#else
1691# ifdef EBCDIC
1692 /* TODO: EBCDIC Check this! @ == isalpha()*/
1693 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1694 "112-120,128,140-142,156,158,172,"
1695 "174,186,191,203-207,219-225,235-239,"
1696 "251-254",
1697# else
1698 (char_u *)"@,48-57,_,192-255",
1699# endif
1700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001701 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1703 (char_u *)&p_isk, PV_ISK,
1704 {
1705#ifdef EBCDIC
1706 (char_u *)"@,240-249,_",
1707 /* TODO: EBCDIC Check this! @ == isalpha()*/
1708 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1709 "112-120,128,140-142,156,158,172,"
1710 "174,186,191,203-207,219-225,235-239,"
1711 "251-254",
1712#else
1713 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001714# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 (char_u *)"@,48-57,_,128-167,224-235"
1716# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001717 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718# endif
1719#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001720 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001721 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1722 (char_u *)&p_isp, PV_NONE,
1723 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001724#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 || defined(VMS)
1726 (char_u *)"@,~-255",
1727#else
1728# ifdef EBCDIC
1729 /* all chars above 63 are printable */
1730 (char_u *)"63-255",
1731# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001732 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733# endif
1734#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001735 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1737 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001738 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1740#ifdef FEAT_CRYPT
1741 (char_u *)&p_key, PV_KEY,
1742 {(char_u *)"", (char_u *)0L}
1743#else
1744 (char_u *)NULL, PV_NONE,
1745 {(char_u *)0L, (char_u *)0L}
1746#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001747 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001748 {"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 +00001749#ifdef FEAT_KEYMAP
1750 (char_u *)&p_keymap, PV_KMAP,
1751 {(char_u *)"", (char_u *)0L}
1752#else
1753 (char_u *)NULL, PV_NONE,
1754 {(char_u *)"", (char_u *)0L}
1755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001756 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001757 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001760 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001761 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001762 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001763#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 (char_u *)":help",
1765#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001766# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001768# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001769# ifdef USEMAN_S
1770 (char_u *)"man -s",
1771# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001773# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774# endif
1775#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001776 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001777 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778#ifdef FEAT_LANGMAP
1779 (char_u *)&p_langmap, PV_NONE,
1780 {(char_u *)"", /* unmatched } */
1781#else
1782 (char_u *)NULL, PV_NONE,
1783 {(char_u *)NULL,
1784#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001785 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001786 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1788 (char_u *)&p_lm, PV_NONE,
1789#else
1790 (char_u *)NULL, PV_NONE,
1791#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001793 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1794#ifdef FEAT_LANGMAP
1795 (char_u *)&p_lnr, PV_NONE,
1796#else
1797 (char_u *)NULL, PV_NONE,
1798#endif
1799 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001800 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1801#ifdef FEAT_LANGMAP
1802 (char_u *)&p_lrm, PV_NONE,
1803#else
1804 (char_u *)NULL, PV_NONE,
1805#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001806 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001807 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1808#ifdef FEAT_WINDOWS
1809 (char_u *)&p_ls, PV_NONE,
1810#else
1811 (char_u *)NULL, PV_NONE,
1812#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001813 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1815 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001816 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1818#ifdef FEAT_LINEBREAK
1819 (char_u *)VAR_WIN, PV_LBR,
1820#else
1821 (char_u *)NULL, PV_NONE,
1822#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001823 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1825 (char_u *)&Rows, PV_NONE,
1826 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001827#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 (char_u *)25L,
1829#else
1830 (char_u *)24L,
1831#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001832 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1834#ifdef FEAT_GUI
1835 (char_u *)&p_linespace, PV_NONE,
1836#else
1837 (char_u *)NULL, PV_NONE,
1838#endif
1839#ifdef FEAT_GUI_W32
1840 {(char_u *)1L, (char_u *)0L}
1841#else
1842 {(char_u *)0L, (char_u *)0L}
1843#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 {"lisp", NULL, P_BOOL|P_VI_DEF,
1846#ifdef FEAT_LISP
1847 (char_u *)&p_lisp, PV_LISP,
1848#else
1849 (char_u *)NULL, PV_NONE,
1850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001851 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001852 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001854 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1856#else
1857 (char_u *)NULL, PV_NONE,
1858 {(char_u *)"", (char_u *)0L}
1859#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001860 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001861 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1862 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001863 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001864 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001866 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1868 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001869 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001870 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001871#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001872 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001873 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001874#else
1875 (char_u *)NULL, PV_NONE,
1876 {(char_u *)"", (char_u *)0L}
1877#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001878 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001879 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001880#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001881 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001882 {(char_u *)TRUE, (char_u *)0L}
1883#else
1884 (char_u *)NULL, PV_NONE,
1885 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001886#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001887 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001888 {"magic", NULL, P_BOOL|P_VI_DEF,
1889 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001890 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001891 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001892#ifdef FEAT_QUICKFIX
1893 (char_u *)&p_mef, PV_NONE,
1894 {(char_u *)"", (char_u *)0L}
1895#else
1896 (char_u *)NULL, PV_NONE,
1897 {(char_u *)NULL, (char_u *)0L}
1898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 SCRIPTID_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001900 {"makeencoding","menc", P_STRING|P_VI_DEF,
1901#ifdef FEAT_MBYTE
1902 (char_u *)&p_menc, PV_MENC,
1903 {(char_u *)"", (char_u *)0L}
1904#else
1905 (char_u *)NULL, PV_NONE,
1906 {(char_u *)0L, (char_u *)0L}
1907#endif
1908 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001909 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1910#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001911 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912# ifdef VMS
1913 {(char_u *)"MMS", (char_u *)0L}
1914# else
1915 {(char_u *)"make", (char_u *)0L}
1916# endif
1917#else
1918 (char_u *)NULL, PV_NONE,
1919 {(char_u *)NULL, (char_u *)0L}
1920#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001921 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001922 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001924 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1925 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001926 {"matchtime", "mat", P_NUM|P_VI_DEF,
1927 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001928 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001929 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001930#ifdef FEAT_MBYTE
1931 (char_u *)&p_mco, PV_NONE,
1932#else
1933 (char_u *)NULL, PV_NONE,
1934#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001935 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1937#ifdef FEAT_EVAL
1938 (char_u *)&p_mfd, PV_NONE,
1939#else
1940 (char_u *)NULL, PV_NONE,
1941#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001942 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1944 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 {"maxmem", "mm", P_NUM|P_VI_DEF,
1947 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1949 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001950 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1951 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001952 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1954 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1956 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001957 {"menuitems", "mis", P_NUM|P_VI_DEF,
1958#ifdef FEAT_MENU
1959 (char_u *)&p_mis, PV_NONE,
1960#else
1961 (char_u *)NULL, PV_NONE,
1962#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 {"mesg", NULL, P_BOOL|P_VI_DEF,
1965 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001966 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001967 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001968#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001969 (char_u *)&p_msm, PV_NONE,
1970 {(char_u *)"460000,2000,500", (char_u *)0L}
1971#else
1972 (char_u *)NULL, PV_NONE,
1973 {(char_u *)0L, (char_u *)0L}
1974#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001975 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001976 {"modeline", "ml", P_BOOL|P_VIM,
1977 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001978 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 {"modelines", "mls", P_NUM|P_VI_DEF,
1980 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1983 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001985 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1986 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"more", NULL, P_BOOL|P_VIM,
1989 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001990 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1992 (char_u *)&p_mouse, PV_NONE,
1993 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001994#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 (char_u *)"a",
1996#else
1997 (char_u *)"",
1998#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
2001#ifdef FEAT_GUI
2002 (char_u *)&p_mousef, PV_NONE,
2003#else
2004 (char_u *)NULL, PV_NONE,
2005#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002006 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 {"mousehide", "mh", P_BOOL|P_VI_DEF,
2008#ifdef FEAT_GUI
2009 (char_u *)&p_mh, PV_NONE,
2010#else
2011 (char_u *)NULL, PV_NONE,
2012#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002013 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002014 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
2015 (char_u *)&p_mousem, PV_NONE,
2016 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002017#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018 (char_u *)"popup",
2019#else
2020# if defined(MACOS)
2021 (char_u *)"popup_setpos",
2022# else
2023 (char_u *)"extend",
2024# endif
2025#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002026 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002027 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002028#ifdef FEAT_MOUSESHAPE
2029 (char_u *)&p_mouseshape, PV_NONE,
2030 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2031#else
2032 (char_u *)NULL, PV_NONE,
2033 {(char_u *)NULL, (char_u *)0L}
2034#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002035 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002036 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2037 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002038 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002039 {"mzquantum", "mzq", P_NUM,
2040#ifdef FEAT_MZSCHEME
2041 (char_u *)&p_mzq, PV_NONE,
2042#else
2043 (char_u *)NULL, PV_NONE,
2044#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002045 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046 {"novice", NULL, P_BOOL|P_VI_DEF,
2047 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002048 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002049 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002050 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002051 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002052 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002053 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2054 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002055 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002056 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2057#ifdef FEAT_LINEBREAK
2058 (char_u *)VAR_WIN, PV_NUW,
2059#else
2060 (char_u *)NULL, PV_NONE,
2061#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002062 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002063 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002064#ifdef FEAT_COMPL_FUNC
2065 (char_u *)&p_ofu, PV_OFU,
2066 {(char_u *)"", (char_u *)0L}
2067#else
2068 (char_u *)NULL, PV_NONE,
2069 {(char_u *)0L, (char_u *)0L}
2070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002071 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 {"open", NULL, P_BOOL|P_VI_DEF,
2073 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002074 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002075 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002076#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002077 (char_u *)&p_odev, PV_NONE,
2078#else
2079 (char_u *)NULL, PV_NONE,
2080#endif
2081 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002082 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002083 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2084 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086 {"optimize", "opt", P_BOOL|P_VI_DEF,
2087 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002089 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002090 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02002091 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002092 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2093 |P_SECURE,
2094 (char_u *)&p_pp, PV_NONE,
2095 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2096 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002097 {"paragraphs", "para", P_STRING|P_VI_DEF,
2098 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002099 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002100 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002101 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002102 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002103 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002104 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2105 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002106 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002107 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2108#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2109 (char_u *)&p_pex, PV_NONE,
2110 {(char_u *)"", (char_u *)0L}
2111#else
2112 (char_u *)NULL, PV_NONE,
2113 {(char_u *)0L, (char_u *)0L}
2114#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002115 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002116 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002118 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002119 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002120 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002121 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002122#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 (char_u *)".,,",
2124#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002125 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002127 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002128 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002129#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002130 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002131 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002132#else
2133 (char_u *)NULL, PV_NONE,
2134 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002135#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002136 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002137 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2138 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002139 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002140 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002141#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2142 (char_u *)&p_pvh, PV_NONE,
2143#else
2144 (char_u *)NULL, PV_NONE,
2145#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002146 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2148#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2149 (char_u *)VAR_WIN, PV_PVW,
2150#else
2151 (char_u *)NULL, PV_NONE,
2152#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002153 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002154 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155#ifdef FEAT_PRINTER
2156 (char_u *)&p_pdev, PV_NONE,
2157 {(char_u *)"", (char_u *)0L}
2158#else
2159 (char_u *)NULL, PV_NONE,
2160 {(char_u *)NULL, (char_u *)0L}
2161#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002162 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002163 {"printencoding", "penc", P_STRING|P_VI_DEF,
2164#ifdef FEAT_POSTSCRIPT
2165 (char_u *)&p_penc, PV_NONE,
2166 {(char_u *)"", (char_u *)0L}
2167#else
2168 (char_u *)NULL, PV_NONE,
2169 {(char_u *)NULL, (char_u *)0L}
2170#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002171 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002172 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173#ifdef FEAT_POSTSCRIPT
2174 (char_u *)&p_pexpr, PV_NONE,
2175 {(char_u *)"", (char_u *)0L}
2176#else
2177 (char_u *)NULL, PV_NONE,
2178 {(char_u *)NULL, (char_u *)0L}
2179#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002180 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002181 {"printfont", "pfn", P_STRING|P_VI_DEF,
2182#ifdef FEAT_PRINTER
2183 (char_u *)&p_pfn, PV_NONE,
2184 {
2185# ifdef MSWIN
2186 (char_u *)"Courier_New:h10",
2187# else
2188 (char_u *)"courier",
2189# endif
2190 (char_u *)0L}
2191#else
2192 (char_u *)NULL, PV_NONE,
2193 {(char_u *)NULL, (char_u *)0L}
2194#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002195 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002196 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2197#ifdef FEAT_PRINTER
2198 (char_u *)&p_header, PV_NONE,
2199 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2200#else
2201 (char_u *)NULL, PV_NONE,
2202 {(char_u *)NULL, (char_u *)0L}
2203#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002204 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002205 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2206#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2207 (char_u *)&p_pmcs, PV_NONE,
2208 {(char_u *)"", (char_u *)0L}
2209#else
2210 (char_u *)NULL, PV_NONE,
2211 {(char_u *)NULL, (char_u *)0L}
2212#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002213 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002214 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2215#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2216 (char_u *)&p_pmfn, PV_NONE,
2217 {(char_u *)"", (char_u *)0L}
2218#else
2219 (char_u *)NULL, PV_NONE,
2220 {(char_u *)NULL, (char_u *)0L}
2221#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002222 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002223 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002224#ifdef FEAT_PRINTER
2225 (char_u *)&p_popt, PV_NONE,
2226 {(char_u *)"", (char_u *)0L}
2227#else
2228 (char_u *)NULL, PV_NONE,
2229 {(char_u *)NULL, (char_u *)0L}
2230#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002231 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002232 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002233 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002234 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002235 {"pumheight", "ph", P_NUM|P_VI_DEF,
2236#ifdef FEAT_INS_EXPAND
2237 (char_u *)&p_ph, PV_NONE,
2238#else
2239 (char_u *)NULL, PV_NONE,
2240#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002242 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002243#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002244 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002245 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002246#else
2247 (char_u *)NULL, PV_NONE,
2248 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002249#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002250 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002251 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002252#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002253 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002254 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002255#else
2256 (char_u *)NULL, PV_NONE,
2257 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002258#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002259 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002260 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2261#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2262 (char_u *)&p_pyx, PV_NONE,
2263#else
2264 (char_u *)NULL, PV_NONE,
2265#endif
2266 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2267 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002268 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2269#ifdef FEAT_TEXTOBJ
2270 (char_u *)&p_qe, PV_QE,
2271 {(char_u *)"\\", (char_u *)0L}
2272#else
2273 (char_u *)NULL, PV_NONE,
2274 {(char_u *)NULL, (char_u *)0L}
2275#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002276 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002277 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2278 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002279 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002280 {"redraw", NULL, P_BOOL|P_VI_DEF,
2281 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002282 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002283 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2284#ifdef FEAT_RELTIME
2285 (char_u *)&p_rdt, PV_NONE,
2286#else
2287 (char_u *)NULL, PV_NONE,
2288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002290 {"regexpengine", "re", P_NUM|P_VI_DEF,
2291 (char_u *)&p_re, PV_NONE,
2292 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002293 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2294 (char_u *)VAR_WIN, PV_RNU,
2295 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002296 {"remap", NULL, P_BOOL|P_VI_DEF,
2297 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002298 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002299 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002300#ifdef FEAT_RENDER_OPTIONS
2301 (char_u *)&p_rop, PV_NONE,
2302 {(char_u *)"", (char_u *)0L}
2303#else
2304 (char_u *)NULL, PV_NONE,
2305 {(char_u *)NULL, (char_u *)0L}
2306#endif
2307 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 {"report", NULL, P_NUM|P_VI_DEF,
2309 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002310 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2312#ifdef WIN3264
2313 (char_u *)&p_rs, PV_NONE,
2314#else
2315 (char_u *)NULL, PV_NONE,
2316#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002317 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2319#ifdef FEAT_RIGHTLEFT
2320 (char_u *)&p_ri, PV_NONE,
2321#else
2322 (char_u *)NULL, PV_NONE,
2323#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002324 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2326#ifdef FEAT_RIGHTLEFT
2327 (char_u *)VAR_WIN, PV_RL,
2328#else
2329 (char_u *)NULL, PV_NONE,
2330#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002331 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002332 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2333#ifdef FEAT_RIGHTLEFT
2334 (char_u *)VAR_WIN, PV_RLC,
2335 {(char_u *)"search", (char_u *)NULL}
2336#else
2337 (char_u *)NULL, PV_NONE,
2338 {(char_u *)NULL, (char_u *)0L}
2339#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002340 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002341 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002342#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002343 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002344 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002345#else
2346 (char_u *)NULL, PV_NONE,
2347 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002348#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002349 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002350 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2351#ifdef FEAT_CMDL_INFO
2352 (char_u *)&p_ru, PV_NONE,
2353#else
2354 (char_u *)NULL, PV_NONE,
2355#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002356 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002357 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2358#ifdef FEAT_STL_OPT
2359 (char_u *)&p_ruf, PV_NONE,
2360#else
2361 (char_u *)NULL, PV_NONE,
2362#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002363 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002364 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2365 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002366 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002367 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2368 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002369 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2370 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002371 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2373#ifdef FEAT_SCROLLBIND
2374 (char_u *)VAR_WIN, PV_SCBIND,
2375#else
2376 (char_u *)NULL, PV_NONE,
2377#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2380 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002381 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2383 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002384 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002385 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386#ifdef FEAT_SCROLLBIND
2387 (char_u *)&p_sbo, PV_NONE,
2388 {(char_u *)"ver,jump", (char_u *)0L}
2389#else
2390 (char_u *)NULL, PV_NONE,
2391 {(char_u *)0L, (char_u *)0L}
2392#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002393 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394 {"sections", "sect", P_STRING|P_VI_DEF,
2395 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002396 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2397 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002398 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2399 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)"inclusive", (char_u *)0L}
2404 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002405 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002406 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002407 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002408 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409#ifdef FEAT_SESSION
2410 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002411 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 (char_u *)0L}
2413#else
2414 (char_u *)NULL, PV_NONE,
2415 {(char_u *)0L, (char_u *)0L}
2416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002417 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2419 (char_u *)&p_sh, PV_NONE,
2420 {
2421#ifdef VMS
2422 (char_u *)"-",
2423#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002424# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002426# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002427 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428# endif
2429#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002430 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2432 (char_u *)&p_shcf, PV_NONE,
2433 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002434#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 (char_u *)"/c",
2436#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002439 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002440 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2441#ifdef FEAT_QUICKFIX
2442 (char_u *)&p_sp, PV_NONE,
2443 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002444#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446#else
2447 (char_u *)">",
2448#endif
2449 (char_u *)0L}
2450#else
2451 (char_u *)NULL, PV_NONE,
2452 {(char_u *)0L, (char_u *)0L}
2453#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002454 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2456 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002457 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2459 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002460 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2462#ifdef BACKSLASH_IN_FILENAME
2463 (char_u *)&p_ssl, PV_NONE,
2464#else
2465 (char_u *)NULL, PV_NONE,
2466#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002468 {"shelltemp", "stmp", P_BOOL,
2469 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002471 {"shelltype", "st", P_NUM|P_VI_DEF,
2472#ifdef AMIGA
2473 (char_u *)&p_st, PV_NONE,
2474#else
2475 (char_u *)NULL, PV_NONE,
2476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002478 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2479 (char_u *)&p_sxq, PV_NONE,
2480 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002481#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 (char_u *)"\"",
2483#else
2484 (char_u *)"",
2485#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002486 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002487 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2488 (char_u *)&p_sxe, PV_NONE,
2489 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002490#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002491 (char_u *)"\"&|<>()@^",
2492#else
2493 (char_u *)"",
2494#endif
2495 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2497 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002498 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002499 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2500 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002501 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2503 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002504 {(char_u *)"", (char_u *)"filnxtToO"}
2505 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002508 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2510#ifdef FEAT_LINEBREAK
2511 (char_u *)&p_sbr, PV_NONE,
2512#else
2513 (char_u *)NULL, PV_NONE,
2514#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002515 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"showcmd", "sc", P_BOOL|P_VIM,
2517#ifdef FEAT_CMDL_INFO
2518 (char_u *)&p_sc, PV_NONE,
2519#else
2520 (char_u *)NULL, PV_NONE,
2521#endif
2522 {(char_u *)FALSE,
2523#ifdef UNIX
2524 (char_u *)FALSE
2525#else
2526 (char_u *)TRUE
2527#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002528 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002529 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2530 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002531 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2533 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002534 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002535 {"showmode", "smd", P_BOOL|P_VIM,
2536 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002537 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002538 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2539#ifdef FEAT_WINDOWS
2540 (char_u *)&p_stal, PV_NONE,
2541#else
2542 (char_u *)NULL, PV_NONE,
2543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2546 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002547 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002548 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2549 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002550 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002551 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2552#ifdef FEAT_SIGNS
2553 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002554 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002555#else
2556 (char_u *)NULL, PV_NONE,
2557 {(char_u *)NULL, (char_u *)0L}
2558#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002559 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002560 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2561 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2564 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002565 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2567#ifdef FEAT_SMARTINDENT
2568 (char_u *)&p_si, PV_SI,
2569#else
2570 (char_u *)NULL, PV_NONE,
2571#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002572 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2574 (char_u *)&p_sta, 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 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2577 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2580 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002582 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002583#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002584 (char_u *)VAR_WIN, PV_SPELL,
2585#else
2586 (char_u *)NULL, PV_NONE,
2587#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002589 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002590#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002591 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002592 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002593#else
2594 (char_u *)NULL, PV_NONE,
2595 {(char_u *)0L, (char_u *)0L}
2596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002597 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002598 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2599 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002600#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002601 (char_u *)&p_spf, PV_SPF,
2602 {(char_u *)"", (char_u *)0L}
2603#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 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2609 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002610#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002611 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002612 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002613#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 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002619#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002620 (char_u *)&p_sps, PV_NONE,
2621 {(char_u *)"best", (char_u *)0L}
2622#else
2623 (char_u *)NULL, PV_NONE,
2624 {(char_u *)0L, (char_u *)0L}
2625#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002626 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2628#ifdef FEAT_WINDOWS
2629 (char_u *)&p_sb, PV_NONE,
2630#else
2631 (char_u *)NULL, PV_NONE,
2632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002633 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002635#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 (char_u *)&p_spr, PV_NONE,
2637#else
2638 (char_u *)NULL, PV_NONE,
2639#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002640 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2642 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002643 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2645#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002646 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647#else
2648 (char_u *)NULL, PV_NONE,
2649#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002651 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002652 (char_u *)&p_su, PV_NONE,
2653 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002654 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002655 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002656#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657 (char_u *)&p_sua, PV_SUA,
2658 {(char_u *)"", (char_u *)0L}
2659#else
2660 (char_u *)NULL, PV_NONE,
2661 {(char_u *)0L, (char_u *)0L}
2662#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002663 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2665 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002666 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667 {"swapsync", "sws", P_STRING|P_VI_DEF,
2668 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002670 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002671 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002672 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002673 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2674#ifdef FEAT_SYN_HL
2675 (char_u *)&p_smc, PV_SMC,
2676 {(char_u *)3000L, (char_u *)0L}
2677#else
2678 (char_u *)NULL, PV_NONE,
2679 {(char_u *)0L, (char_u *)0L}
2680#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002681 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002682 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002683#ifdef FEAT_SYN_HL
2684 (char_u *)&p_syn, PV_SYN,
2685 {(char_u *)"", (char_u *)0L}
2686#else
2687 (char_u *)NULL, PV_NONE,
2688 {(char_u *)0L, (char_u *)0L}
2689#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002690 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002691 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2692#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002693 (char_u *)&p_tal, PV_NONE,
2694#else
2695 (char_u *)NULL, PV_NONE,
2696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002697 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002698 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2699#ifdef FEAT_WINDOWS
2700 (char_u *)&p_tpm, PV_NONE,
2701#else
2702 (char_u *)NULL, PV_NONE,
2703#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002704 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002705 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2706 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002707 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002708 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2709 (char_u *)&p_tbs, PV_NONE,
2710#ifdef VMS /* binary searching doesn't appear to work on VMS */
2711 {(char_u *)0L, (char_u *)0L}
2712#else
2713 {(char_u *)TRUE, (char_u *)0L}
2714#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002715 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002716 {"tagcase", "tc", P_STRING|P_VIM,
2717 (char_u *)&p_tc, PV_TC,
2718 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719 {"taglength", "tl", P_NUM|P_VI_DEF,
2720 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002721 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002722 {"tagrelative", "tr", P_BOOL|P_VIM,
2723 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002724 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002725 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002726 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {
2728#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2729 (char_u *)"./tags,./TAGS,tags,TAGS",
2730#else
2731 (char_u *)"./tags,tags",
2732#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002733 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2735 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002736 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002737 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002738#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002739 (char_u *)&p_tcldll, PV_NONE,
2740 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002741#else
2742 (char_u *)NULL, PV_NONE,
2743 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002744#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002745 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002746 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2747 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002748 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002749 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2750#ifdef FEAT_ARABIC
2751 (char_u *)&p_tbidi, PV_NONE,
2752#else
2753 (char_u *)NULL, PV_NONE,
2754#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2757#ifdef FEAT_MBYTE
2758 (char_u *)&p_tenc, PV_NONE,
2759 {(char_u *)"", (char_u *)0L}
2760#else
2761 (char_u *)NULL, PV_NONE,
2762 {(char_u *)0L, (char_u *)0L}
2763#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002764 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002765 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2766#ifdef FEAT_TERMGUICOLORS
2767 (char_u *)&p_tgc, PV_NONE,
2768 {(char_u *)FALSE, (char_u *)FALSE}
2769#else
2770 (char_u*)NULL, PV_NONE,
2771 {(char_u *)FALSE, (char_u *)FALSE}
2772#endif
2773 SCRIPTID_INIT},
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002774 {"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2775#ifdef FEAT_TERMINAL
2776 (char_u *)VAR_WIN, PV_TK,
Bram Moolenaar1f28b4c2017-07-28 13:48:34 +02002777 {(char_u *)"", (char_u *)NULL}
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002778#else
2779 (char_u *)NULL, PV_NONE,
2780 {(char_u *)NULL, (char_u *)0L}
2781#endif
2782 SCRIPTID_INIT},
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002783 {"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2784#ifdef FEAT_TERMINAL
2785 (char_u *)VAR_WIN, PV_TMS,
2786 {(char_u *)"", (char_u *)NULL}
2787#else
2788 (char_u *)NULL, PV_NONE,
2789 {(char_u *)NULL, (char_u *)0L}
2790#endif
2791 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002792 {"terse", NULL, P_BOOL|P_VI_DEF,
2793 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002794 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002795 {"textauto", "ta", P_BOOL|P_VIM,
2796 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002797 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2798 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002799 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2800 (char_u *)&p_tx, PV_TX,
2801 {
2802#ifdef USE_CRNL
2803 (char_u *)TRUE,
2804#else
2805 (char_u *)FALSE,
2806#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002808 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002811 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002813 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814#else
2815 (char_u *)NULL, PV_NONE,
2816#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002817 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002818 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2819 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002820 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 {"timeout", "to", P_BOOL|P_VI_DEF,
2822 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002823 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2825 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002826 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002827 {"title", NULL, P_BOOL|P_VI_DEF,
2828#ifdef FEAT_TITLE
2829 (char_u *)&p_title, PV_NONE,
2830#else
2831 (char_u *)NULL, PV_NONE,
2832#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002833 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002834 {"titlelen", NULL, P_NUM|P_VI_DEF,
2835#ifdef FEAT_TITLE
2836 (char_u *)&p_titlelen, PV_NONE,
2837#else
2838 (char_u *)NULL, PV_NONE,
2839#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002840 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002841 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002842#ifdef FEAT_TITLE
2843 (char_u *)&p_titleold, PV_NONE,
2844 {(char_u *)N_("Thanks for flying Vim"),
2845 (char_u *)0L}
2846#else
2847 (char_u *)NULL, PV_NONE,
2848 {(char_u *)0L, (char_u *)0L}
2849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002850 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002851 {"titlestring", NULL, P_STRING|P_VI_DEF,
2852#ifdef FEAT_TITLE
2853 (char_u *)&p_titlestring, PV_NONE,
2854#else
2855 (char_u *)NULL, PV_NONE,
2856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002857 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002858 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002859#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002860 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002862#else
2863 (char_u *)NULL, PV_NONE,
2864 {(char_u *)0L, (char_u *)0L}
2865#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002866 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002868#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002869 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002870 {(char_u *)"small", (char_u *)0L}
2871#else
2872 (char_u *)NULL, PV_NONE,
2873 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002875 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002876 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2877 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002878 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002879 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2880 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002881 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002882 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2883 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002884 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002885 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2886 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002887 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002888 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2889#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2890 (char_u *)&p_ttym, PV_NONE,
2891#else
2892 (char_u *)NULL, PV_NONE,
2893#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002894 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002895 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2896 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002897 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2899 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002900 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002901 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2902 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002903#ifdef FEAT_PERSISTENT_UNDO
2904 (char_u *)&p_udir, PV_NONE,
2905 {(char_u *)".", (char_u *)0L}
2906#else
2907 (char_u *)NULL, PV_NONE,
2908 {(char_u *)0L, (char_u *)0L}
2909#endif
2910 SCRIPTID_INIT},
2911 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2912#ifdef FEAT_PERSISTENT_UNDO
2913 (char_u *)&p_udf, PV_UDF,
2914#else
2915 (char_u *)NULL, PV_NONE,
2916#endif
2917 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002918 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002919 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002920 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002921#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 (char_u *)1000L,
2923#else
2924 (char_u *)100L,
2925#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002926 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002927 {"undoreload", "ur", P_NUM|P_VI_DEF,
2928 (char_u *)&p_ur, PV_NONE,
2929 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930 {"updatecount", "uc", P_NUM|P_VI_DEF,
2931 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002932 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002933 {"updatetime", "ut", P_NUM|P_VI_DEF,
2934 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002935 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002936 {"verbose", "vbs", P_NUM|P_VI_DEF,
2937 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002938 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002939 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2940 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002941 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002942 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2943#ifdef FEAT_SESSION
2944 (char_u *)&p_vdir, PV_NONE,
2945 {(char_u *)DFLT_VDIR, (char_u *)0L}
2946#else
2947 (char_u *)NULL, PV_NONE,
2948 {(char_u *)0L, (char_u *)0L}
2949#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002950 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002951 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002952#ifdef FEAT_SESSION
2953 (char_u *)&p_vop, PV_NONE,
2954 {(char_u *)"folds,options,cursor", (char_u *)0L}
2955#else
2956 (char_u *)NULL, PV_NONE,
2957 {(char_u *)0L, (char_u *)0L}
2958#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002959 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002960 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002961#ifdef FEAT_VIMINFO
2962 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002963#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002964 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002965#else
2966# ifdef AMIGA
2967 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002968 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002969# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002970 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971# endif
2972#endif
2973#else
2974 (char_u *)NULL, PV_NONE,
2975 {(char_u *)0L, (char_u *)0L}
2976#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002977 SCRIPTID_INIT},
Bram Moolenaarc4da1132017-07-15 19:39:43 +02002978 {"viminfofile", "vif", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE|P_VI_DEF,
2979#ifdef FEAT_VIMINFO
2980 (char_u *)&p_viminfofile, PV_NONE,
2981 {(char_u *)"", (char_u *)0L}
2982#else
2983 (char_u *)NULL, PV_NONE,
2984 {(char_u *)0L, (char_u *)0L}
2985#endif
2986 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002987 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2988 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989#ifdef FEAT_VIRTUALEDIT
2990 (char_u *)&p_ve, PV_NONE,
2991 {(char_u *)"", (char_u *)""}
2992#else
2993 (char_u *)NULL, PV_NONE,
2994 {(char_u *)0L, (char_u *)0L}
2995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002996 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002997 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2998 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002999 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003000 {"w300", NULL, P_NUM|P_VI_DEF,
3001 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003002 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 {"w1200", NULL, P_NUM|P_VI_DEF,
3004 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003005 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003006 {"w9600", NULL, P_NUM|P_VI_DEF,
3007 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003008 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003009 {"warn", NULL, P_BOOL|P_VI_DEF,
3010 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003011 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
3013 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003014 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003015 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003016 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003017 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018 {"wildchar", "wc", P_NUM|P_VIM,
3019 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003020 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3021 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003022 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003024 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003025 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003026#ifdef FEAT_WILDIGN
3027 (char_u *)&p_wig, PV_NONE,
3028#else
3029 (char_u *)NULL, PV_NONE,
3030#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003031 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003032 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3033 (char_u *)&p_wic, PV_NONE,
3034 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003035 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3036#ifdef FEAT_WILDMENU
3037 (char_u *)&p_wmnu, PV_NONE,
3038#else
3039 (char_u *)NULL, PV_NONE,
3040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003041 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003042 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003043 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003044 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003045 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3046#ifdef FEAT_CMDL_COMPL
3047 (char_u *)&p_wop, PV_NONE,
3048 {(char_u *)"", (char_u *)0L}
3049#else
3050 (char_u *)NULL, PV_NONE,
3051 {(char_u *)NULL, (char_u *)0L}
3052#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003053 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3055#ifdef FEAT_WAK
3056 (char_u *)&p_wak, PV_NONE,
3057 {(char_u *)"menu", (char_u *)0L}
3058#else
3059 (char_u *)NULL, PV_NONE,
3060 {(char_u *)NULL, (char_u *)0L}
3061#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003062 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003063 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003064 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003065 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003066 {"winheight", "wh", P_NUM|P_VI_DEF,
3067#ifdef FEAT_WINDOWS
3068 (char_u *)&p_wh, PV_NONE,
3069#else
3070 (char_u *)NULL, PV_NONE,
3071#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003072 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003074#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003075 (char_u *)VAR_WIN, PV_WFH,
3076#else
3077 (char_u *)NULL, PV_NONE,
3078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003079 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003080 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003081#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003082 (char_u *)VAR_WIN, PV_WFW,
3083#else
3084 (char_u *)NULL, PV_NONE,
3085#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003086 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3088#ifdef FEAT_WINDOWS
3089 (char_u *)&p_wmh, PV_NONE,
3090#else
3091 (char_u *)NULL, PV_NONE,
3092#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003093 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003095#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096 (char_u *)&p_wmw, PV_NONE,
3097#else
3098 (char_u *)NULL, PV_NONE,
3099#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003100 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9e13aa72017-08-16 23:14:08 +02003101 {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar84ed4ad2017-08-17 11:33:42 +02003102#if defined(WIN3264) && defined(FEAT_TERMINAL)
Bram Moolenaar9e13aa72017-08-16 23:14:08 +02003103 (char_u *)&p_winptydll, PV_NONE, {
3104# ifdef _WIN64
3105 (char_u *)"winpty64.dll",
3106# else
3107 (char_u *)"winpty32.dll",
3108# endif
3109 (char_u *)0L}
3110#else
3111 (char_u *)NULL, PV_NONE,
3112 {(char_u *)0L, (char_u *)0L}
3113#endif
3114 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003116#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117 (char_u *)&p_wiw, PV_NONE,
3118#else
3119 (char_u *)NULL, PV_NONE,
3120#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003121 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003122 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3123 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003124 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003125 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3126 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003127 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003128 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3129 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003130 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003131 {"write", NULL, P_BOOL|P_VI_DEF,
3132 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003133 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003134 {"writeany", "wa", P_BOOL|P_VI_DEF,
3135 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003136 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3138 (char_u *)&p_wb, PV_NONE,
3139 {
3140#ifdef FEAT_WRITEBACKUP
3141 (char_u *)TRUE,
3142#else
3143 (char_u *)FALSE,
3144#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003145 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003146 {"writedelay", "wd", P_NUM|P_VI_DEF,
3147 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003148 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003149
3150/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003151#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003152 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003153 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003154
3155 p_term("t_AB", T_CAB)
3156 p_term("t_AF", T_CAF)
3157 p_term("t_AL", T_CAL)
3158 p_term("t_al", T_AL)
3159 p_term("t_bc", T_BC)
3160 p_term("t_cd", T_CD)
3161 p_term("t_ce", T_CE)
3162 p_term("t_cl", T_CL)
3163 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003164 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165 p_term("t_Co", T_CCO)
3166 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003167 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003169#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170 p_term("t_CV", T_CSV)
3171#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172 p_term("t_da", T_DA)
3173 p_term("t_db", T_DB)
3174 p_term("t_DL", T_CDL)
3175 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02003176 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003177 p_term("t_fs", T_FS)
3178 p_term("t_IE", T_CIE)
Bram Moolenaar3cd43cc2017-08-12 19:51:41 +02003179 p_term("t_SC", T_CSC)
3180 p_term("t_EC", T_CEC)
3181 p_term("t_SH", T_CSH)
Bram Moolenaar3eee06e2017-08-19 19:40:50 +02003182 p_term("t_RS", T_CRS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003183 p_term("t_IS", T_CIS)
3184 p_term("t_ke", T_KE)
3185 p_term("t_ks", T_KS)
3186 p_term("t_le", T_LE)
3187 p_term("t_mb", T_MB)
3188 p_term("t_md", T_MD)
3189 p_term("t_me", T_ME)
3190 p_term("t_mr", T_MR)
3191 p_term("t_ms", T_MS)
3192 p_term("t_nd", T_ND)
3193 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003194 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195 p_term("t_RI", T_CRI)
3196 p_term("t_RV", T_CRV)
3197 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003198 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003199 p_term("t_Sf", T_CSF)
3200 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003201 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003202 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003204 p_term("t_te", T_TE)
3205 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003206 p_term("t_ts", T_TS)
3207 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208 p_term("t_ue", T_UE)
3209 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003210 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211 p_term("t_vb", T_VB)
3212 p_term("t_ve", T_VE)
3213 p_term("t_vi", T_VI)
3214 p_term("t_vs", T_VS)
3215 p_term("t_WP", T_CWP)
Bram Moolenaar9f928862017-04-11 22:44:05 +02003216 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003217 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003218 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003219 p_term("t_xs", T_XS)
3220 p_term("t_ZH", T_CZH)
3221 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003222 p_term("t_8f", T_8F)
3223 p_term("t_8b", T_8B)
Bram Moolenaarec2da362017-01-21 20:04:22 +01003224 p_term("t_BE", T_BE)
3225 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003226
3227/* terminal key codes are not in here */
3228
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003229 /* end marker */
3230 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003231};
3232
3233#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3234
3235#ifdef FEAT_MBYTE
3236static char *(p_ambw_values[]) = {"single", "double", NULL};
3237#endif
3238static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003239static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003241#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003242static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003243#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003244#ifdef FEAT_CMDL_COMPL
3245static char *(p_wop_values[]) = {"tagfile", NULL};
3246#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003247#ifdef FEAT_WAK
3248static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3249#endif
3250static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3252static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254#ifdef FEAT_BROWSE
3255static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3256#endif
3257#ifdef FEAT_SCROLLBIND
3258static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3259#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003260static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003261#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3263#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003264#ifdef FEAT_AUTOCMD
3265static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL};
3266#else
3267static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003268#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003269static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003270static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3271#ifdef FEAT_FOLDING
3272static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003273# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003275# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003276 NULL};
3277static char *(p_fcl_values[]) = {"all", NULL};
3278#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003279#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003280static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003281#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003282#ifdef FEAT_SIGNS
3283static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3284#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003285
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003286static void set_option_default(int, int opt_flags, int compatible);
3287static void set_options_default(int opt_flags);
3288static char_u *term_bg_default(void);
3289static void did_set_option(int opt_idx, int opt_flags, int new_value);
3290static char_u *illegal_char(char_u *, int);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003291#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003292static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003293#endif
3294#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003295static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003296#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003297static char_u *option_expand(int opt_idx, char_u *val);
3298static void didset_options(void);
3299static void didset_options2(void);
3300static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003301#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003302static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003303#else
3304# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3305#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003306static void set_string_option_global(int opt_idx, char_u **varp);
3307static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3308static 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);
3309static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003310#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003311static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003312#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003314static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003315#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003316#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003317static char_u *did_set_spell_option(int is_spellfile);
3318static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003319#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003320#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003321static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003322#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003323static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3324static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3325static void check_redraw(long_u flags);
3326static int findoption(char_u *);
3327static int find_key_option(char_u *);
3328static void showoptions(int all, int opt_flags);
3329static int optval_default(struct vimoption *, char_u *varp);
3330static void showoneopt(struct vimoption *, int opt_flags);
3331static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3332static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3333static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3334static int istermoption(struct vimoption *);
3335static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3336static char_u *get_varp(struct vimoption *);
3337static void option_value2string(struct vimoption *, int opt_flags);
3338static void check_winopt(winopt_T *wop);
3339static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003340#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003341static void langmap_init(void);
3342static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003344static void paste_option_changed(void);
3345static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003347static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003349static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3350static int check_opt_strings(char_u *val, char **values, int);
3351static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003352#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003353static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003354#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003355
3356/*
3357 * Initialize the options, first part.
3358 *
3359 * Called only once from main(), just after creating the first buffer.
3360 */
3361 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003362set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003363{
3364 char_u *p;
3365 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003366 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003367
3368#ifdef FEAT_LANGMAP
3369 langmap_init();
3370#endif
3371
3372 /* Be Vi compatible by default */
3373 p_cp = TRUE;
3374
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003375 /* Use POSIX compatibility when $VIM_POSIX is set. */
3376 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003377 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003378 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003379 set_string_default("shm", (char_u *)"A");
3380 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003381
Bram Moolenaar071d4272004-06-13 20:20:40 +00003382 /*
3383 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003384 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003386 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003387#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003388 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003389# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003390 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003391# endif
3392#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003393 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003394 set_string_default("sh", p);
3395
3396#ifdef FEAT_WILDIGN
3397 /*
3398 * Set the default for 'backupskip' to include environment variables for
3399 * temp files.
3400 */
3401 {
3402# ifdef UNIX
3403 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3404# else
3405 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3406# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003407 int len;
3408 garray_T ga;
3409 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003410
3411 ga_init2(&ga, 1, 100);
3412 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3413 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003414 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415# ifdef UNIX
3416 if (*names[n] == NUL)
3417 p = (char_u *)"/tmp";
3418 else
3419# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003420 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003421 if (p != NULL && *p != NUL)
3422 {
3423 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003424 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003425 if (ga_grow(&ga, len) == OK)
3426 {
3427 if (ga.ga_len > 0)
3428 STRCAT(ga.ga_data, ",");
3429 STRCAT(ga.ga_data, p);
3430 add_pathsep(ga.ga_data);
3431 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003432 ga.ga_len += len;
3433 }
3434 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003435 if (mustfree)
3436 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003437 }
3438 if (ga.ga_data != NULL)
3439 {
3440 set_string_default("bsk", ga.ga_data);
3441 vim_free(ga.ga_data);
3442 }
3443 }
3444#endif
3445
3446 /*
3447 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3448 */
3449 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003450 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003451 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003452#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3453 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3454#endif
3455 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003456#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003457 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003458 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003459#else
3460# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003461 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003462 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003463# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003464 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003465# endif
3466#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003468 opt_idx = findoption((char_u *)"maxmem");
3469 if (opt_idx >= 0)
3470 {
3471#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003472 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3473 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003474#endif
3475 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3476 }
3477 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003478 }
3479
Bram Moolenaar071d4272004-06-13 20:20:40 +00003480#ifdef FEAT_SEARCHPATH
3481 {
3482 char_u *cdpath;
3483 char_u *buf;
3484 int i;
3485 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003486 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003487
3488 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003489 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003490 if (cdpath != NULL)
3491 {
3492 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3493 if (buf != NULL)
3494 {
3495 buf[0] = ','; /* start with ",", current dir first */
3496 j = 1;
3497 for (i = 0; cdpath[i] != NUL; ++i)
3498 {
3499 if (vim_ispathlistsep(cdpath[i]))
3500 buf[j++] = ',';
3501 else
3502 {
3503 if (cdpath[i] == ' ' || cdpath[i] == ',')
3504 buf[j++] = '\\';
3505 buf[j++] = cdpath[i];
3506 }
3507 }
3508 buf[j] = NUL;
3509 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003510 if (opt_idx >= 0)
3511 {
3512 options[opt_idx].def_val[VI_DEFAULT] = buf;
3513 options[opt_idx].flags |= P_DEF_ALLOCED;
3514 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003515 else
3516 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003517 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003518 if (mustfree)
3519 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003520 }
3521 }
3522#endif
3523
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003524#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003525 /* Set print encoding on platforms that don't default to latin1 */
3526 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003527# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003528 (char_u *)"cp1252"
3529# else
3530# ifdef VMS
3531 (char_u *)"dec-mcs"
3532# else
3533# ifdef EBCDIC
3534 (char_u *)"ebcdic-uk"
3535# else
3536# ifdef MAC
3537 (char_u *)"mac-roman"
3538# else /* HPUX */
3539 (char_u *)"hp-roman8"
3540# endif
3541# endif
3542# endif
3543# endif
3544 );
3545#endif
3546
3547#ifdef FEAT_POSTSCRIPT
3548 /* 'printexpr' must be allocated to be able to evaluate it. */
3549 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003550# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003551 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003552# else
3553# ifdef VMS
3554 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3555
3556# else
3557 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3558# endif
3559# endif
3560 );
3561#endif
3562
3563 /*
3564 * Set all the options (except the terminal options) to their default
3565 * value. Also set the global value for local options.
3566 */
3567 set_options_default(0);
3568
3569#ifdef FEAT_GUI
3570 if (found_reverse_arg)
3571 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3572#endif
3573
3574 curbuf->b_p_initialized = TRUE;
3575 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003576 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003577 check_buf_options(curbuf);
3578 check_win_options(curwin);
3579 check_options();
3580
3581 /* Must be before option_expand(), because that one needs vim_isIDc() */
3582 didset_options();
3583
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003584#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003585 /* Use the current chartab for the generic chartab. This is not in
3586 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003587 init_spell_chartab();
3588#endif
3589
Bram Moolenaar071d4272004-06-13 20:20:40 +00003590 /*
3591 * Expand environment variables and things like "~" for the defaults.
3592 * If option_expand() returns non-NULL the variable is expanded. This can
3593 * only happen for non-indirect options.
3594 * Also set the default to the expanded value, so ":set" does not list
3595 * them.
3596 * Don't set the P_ALLOCED flag, because we don't want to free the
3597 * default.
3598 */
3599 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3600 {
3601 if ((options[opt_idx].flags & P_GETTEXT)
3602 && options[opt_idx].var != NULL)
3603 p = (char_u *)_(*(char **)options[opt_idx].var);
3604 else
3605 p = option_expand(opt_idx, NULL);
3606 if (p != NULL && (p = vim_strsave(p)) != NULL)
3607 {
3608 *(char_u **)options[opt_idx].var = p;
3609 /* VIMEXP
3610 * Defaults for all expanded options are currently the same for Vi
3611 * and Vim. When this changes, add some code here! Also need to
3612 * split P_DEF_ALLOCED in two.
3613 */
3614 if (options[opt_idx].flags & P_DEF_ALLOCED)
3615 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3616 options[opt_idx].def_val[VI_DEFAULT] = p;
3617 options[opt_idx].flags |= P_DEF_ALLOCED;
3618 }
3619 }
3620
Bram Moolenaar071d4272004-06-13 20:20:40 +00003621 save_file_ff(curbuf); /* Buffer is unchanged */
3622
Bram Moolenaar071d4272004-06-13 20:20:40 +00003623#if defined(FEAT_ARABIC)
3624 /* Detect use of mlterm.
3625 * Mlterm is a terminal emulator akin to xterm that has some special
3626 * abilities (bidi namely).
3627 * NOTE: mlterm's author is being asked to 'set' a variable
3628 * instead of an environment variable due to inheritance.
3629 */
3630 if (mch_getenv((char_u *)"MLTERM") != NULL)
3631 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3632#endif
3633
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003634 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003635
3636#ifdef FEAT_MBYTE
3637# if defined(WIN3264) && defined(FEAT_GETTEXT)
3638 /*
3639 * If $LANG isn't set, try to get a good value for it. This makes the
3640 * right language be used automatically. Don't do this for English.
3641 */
3642 if (mch_getenv((char_u *)"LANG") == NULL)
3643 {
3644 char buf[20];
3645
3646 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3647 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3648 * only the first two. */
3649 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3650 (LPTSTR)buf, 20);
3651 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3652 {
3653 /* There are a few exceptions (probably more) */
3654 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3655 STRCPY(buf, "zh_TW");
3656 else if (STRNICMP(buf, "chs", 3) == 0
3657 || STRNICMP(buf, "zhc", 3) == 0)
3658 STRCPY(buf, "zh_CN");
3659 else if (STRNICMP(buf, "jp", 2) == 0)
3660 STRCPY(buf, "ja");
3661 else
3662 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003663 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664 }
3665 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003666# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003667# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003668 /* Moved to os_mac_conv.c to avoid dependency problems. */
3669 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003670# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003671# endif
3672
3673 /* enc_locale() will try to find the encoding of the current locale. */
3674 p = enc_locale();
3675 if (p != NULL)
3676 {
3677 char_u *save_enc;
3678
3679 /* Try setting 'encoding' and check if the value is valid.
3680 * If not, go back to the default "latin1". */
3681 save_enc = p_enc;
3682 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003683 if (STRCMP(p_enc, "gb18030") == 0)
3684 {
3685 /* We don't support "gb18030", but "cp936" is a good substitute
3686 * for practical purposes, thus use that. It's not an alias to
3687 * still support conversion between gb18030 and utf-8. */
3688 p_enc = vim_strsave((char_u *)"cp936");
3689 vim_free(p);
3690 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003691 if (mb_init() == NULL)
3692 {
3693 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003694 if (opt_idx >= 0)
3695 {
3696 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3697 options[opt_idx].flags |= P_DEF_ALLOCED;
3698 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003699
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003700#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003701 if (STRCMP(p_enc, "latin1") == 0
3702# ifdef FEAT_MBYTE
3703 || enc_utf8
3704# endif
3705 )
3706 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003707 /* Adjust the default for 'isprint' and 'iskeyword' to match
3708 * latin1. Also set the defaults for when 'nocompatible' is
3709 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003710 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003711 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003712 set_string_option_direct((char_u *)"isk", -1,
3713 ISK_LATIN1, OPT_FREE, SID_NONE);
3714 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003715 if (opt_idx >= 0)
3716 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003717 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003718 if (opt_idx >= 0)
3719 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003720 (void)init_chartab();
3721 }
3722#endif
3723
Bram Moolenaar071d4272004-06-13 20:20:40 +00003724# if defined(WIN3264) && !defined(FEAT_GUI)
3725 /* Win32 console: When GetACP() returns a different value from
3726 * GetConsoleCP() set 'termencoding'. */
3727 if (GetACP() != GetConsoleCP())
3728 {
3729 char buf[50];
3730
3731 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3732 p_tenc = vim_strsave((char_u *)buf);
3733 if (p_tenc != NULL)
3734 {
3735 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003736 if (opt_idx >= 0)
3737 {
3738 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3739 options[opt_idx].flags |= P_DEF_ALLOCED;
3740 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003741 convert_setup(&input_conv, p_tenc, p_enc);
3742 convert_setup(&output_conv, p_enc, p_tenc);
3743 }
3744 else
3745 p_tenc = empty_option;
3746 }
3747# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003748# if defined(WIN3264) && defined(FEAT_MBYTE)
3749 /* $HOME may have characters in active code page. */
3750 init_homedir();
3751# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003752 }
3753 else
3754 {
3755 vim_free(p_enc);
3756 p_enc = save_enc;
3757 }
3758 }
3759#endif
3760
3761#ifdef FEAT_MULTI_LANG
3762 /* Set the default for 'helplang'. */
3763 set_helplang_default(get_mess_lang());
3764#endif
3765}
3766
3767/*
3768 * Set an option to its default value.
3769 * This does not take care of side effects!
3770 */
3771 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003772set_option_default(
3773 int opt_idx,
3774 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3775 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003776{
3777 char_u *varp; /* pointer to variable for current option */
3778 int dvi; /* index in def_val[] */
3779 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003780 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003781 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3782
3783 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3784 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003785 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003786 {
3787 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3788 if (flags & P_STRING)
3789 {
3790 /* Use set_string_option_direct() for local options to handle
3791 * freeing and allocating the value. */
3792 if (options[opt_idx].indir != PV_NONE)
3793 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003794 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795 else
3796 {
3797 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3798 free_string_option(*(char_u **)(varp));
3799 *(char_u **)varp = options[opt_idx].def_val[dvi];
3800 options[opt_idx].flags &= ~P_ALLOCED;
3801 }
3802 }
3803 else if (flags & P_NUM)
3804 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003805 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003806 win_comp_scroll(curwin);
3807 else
3808 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003809 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003810 /* May also set global value for local option. */
3811 if (both)
3812 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3813 *(long *)varp;
3814 }
3815 }
3816 else /* P_BOOL */
3817 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003818 /* the cast to long is required for Manx C, long_i is needed for
3819 * MSVC */
3820 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003821#ifdef UNIX
3822 /* 'modeline' defaults to off for root */
3823 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3824 *(int *)varp = FALSE;
3825#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003826 /* May also set global value for local option. */
3827 if (both)
3828 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3829 *(int *)varp;
3830 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003831
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003832 /* The default value is not insecure. */
3833 flagsp = insecure_flag(opt_idx, opt_flags);
3834 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003835 }
3836
3837#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003838 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003839#endif
3840}
3841
3842/*
3843 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003844 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003845 */
3846 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003847set_options_default(
3848 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003849{
3850 int i;
3851#ifdef FEAT_WINDOWS
3852 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003853 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003854#endif
3855
3856 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003857 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003858#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003859 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003860 || (TRUE
3861# if defined(FEAT_MBYTE)
3862 && options[i].var != (char_u *)&p_enc
3863# endif
3864# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003865 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003866 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003867# endif
3868 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003869#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003870 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003871 set_option_default(i, opt_flags, p_cp);
3872
3873#ifdef FEAT_WINDOWS
3874 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003875 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876 win_comp_scroll(wp);
3877#else
3878 win_comp_scroll(curwin);
3879#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003880#ifdef FEAT_CINDENT
3881 parse_cino(curbuf);
3882#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003883}
3884
3885/*
3886 * Set the Vi-default value of a string option.
3887 * Used for 'sh', 'backupskip' and 'term'.
3888 */
3889 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003890set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003891{
3892 char_u *p;
3893 int opt_idx;
3894
3895 p = vim_strsave(val);
3896 if (p != NULL) /* we don't want a NULL */
3897 {
3898 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003899 if (opt_idx >= 0)
3900 {
3901 if (options[opt_idx].flags & P_DEF_ALLOCED)
3902 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3903 options[opt_idx].def_val[VI_DEFAULT] = p;
3904 options[opt_idx].flags |= P_DEF_ALLOCED;
3905 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906 }
3907}
3908
3909/*
3910 * Set the Vi-default value of a number option.
3911 * Used for 'lines' and 'columns'.
3912 */
3913 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003914set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003915{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003916 int opt_idx;
3917
3918 opt_idx = findoption((char_u *)name);
3919 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003920 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003921}
3922
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003923#if defined(EXITFREE) || defined(PROTO)
3924/*
3925 * Free all options.
3926 */
3927 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003928free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003929{
3930 int i;
3931
3932 for (i = 0; !istermoption(&options[i]); i++)
3933 {
3934 if (options[i].indir == PV_NONE)
3935 {
3936 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003937 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003938 free_string_option(*(char_u **)options[i].var);
3939 if (options[i].flags & P_DEF_ALLOCED)
3940 free_string_option(options[i].def_val[VI_DEFAULT]);
3941 }
3942 else if (options[i].var != VAR_WIN
3943 && (options[i].flags & P_STRING))
3944 /* buffer-local option: free global value */
3945 free_string_option(*(char_u **)options[i].var);
3946 }
3947}
3948#endif
3949
3950
Bram Moolenaar071d4272004-06-13 20:20:40 +00003951/*
3952 * Initialize the options, part two: After getting Rows and Columns and
3953 * setting 'term'.
3954 */
3955 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003956set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003957{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003958 int idx;
3959
Bram Moolenaar071d4272004-06-13 20:20:40 +00003960 /*
3961 * 'scroll' defaults to half the window height. Note that this default is
3962 * wrong when the window height changes.
3963 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003964 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003965 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003966 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003967 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 comp_col();
3969
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003970 /*
3971 * 'window' is only for backwards compatibility with Vi.
3972 * Default is Rows - 1.
3973 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003974 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003975 p_window = Rows - 1;
3976 set_number_default("window", Rows - 1);
3977
Bram Moolenaarf740b292006-02-16 22:11:02 +00003978 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003979#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003980 /*
3981 * If 'background' wasn't set by the user, try guessing the value,
3982 * depending on the terminal name. Only need to check for terminals
3983 * with a dark background, that can handle color.
3984 */
3985 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003986 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3987 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003988 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003989 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003990 /* don't mark it as set, when starting the GUI it may be
3991 * changed again */
3992 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003993 }
3994#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003995
3996#ifdef CURSOR_SHAPE
3997 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3998#endif
3999#ifdef FEAT_MOUSESHAPE
4000 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
4001#endif
4002#ifdef FEAT_PRINTER
4003 (void)parse_printoptions(); /* parse 'printoptions' default value */
4004#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004005}
4006
4007/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00004008 * Return "dark" or "light" depending on the kind of terminal.
4009 * This is just guessing! Recognized are:
4010 * "linux" Linux console
4011 * "screen.linux" Linux console with screen
4012 * "cygwin" Cygwin shell
4013 * "putty" Putty program
4014 * We also check the COLORFGBG environment variable, which is set by
4015 * rxvt and derivatives. This variable contains either two or three
4016 * values separated by semicolons; we want the last value in either
4017 * case. If this value is 0-6 or 8, our background is dark.
4018 */
4019 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004020term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004021{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004022#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004023 /* DOS console nearly always black */
4024 return (char_u *)"dark";
4025#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004026 char_u *p;
4027
Bram Moolenaarf740b292006-02-16 22:11:02 +00004028 if (STRCMP(T_NAME, "linux") == 0
4029 || STRCMP(T_NAME, "screen.linux") == 0
4030 || STRCMP(T_NAME, "cygwin") == 0
4031 || STRCMP(T_NAME, "putty") == 0
4032 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4033 && (p = vim_strrchr(p, ';')) != NULL
4034 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4035 && p[2] == NUL))
4036 return (char_u *)"dark";
4037 return (char_u *)"light";
4038#endif
4039}
4040
4041/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004042 * Initialize the options, part three: After reading the .vimrc
4043 */
4044 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004045set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004046{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004047#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004048/*
4049 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4050 * This is done after other initializations, where 'shell' might have been
4051 * set, but only if they have not been set before.
4052 */
4053 char_u *p;
4054 int idx_srr;
4055 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004056# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004057 int idx_sp;
4058 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004059# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004060
4061 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004062 if (idx_srr < 0)
4063 do_srr = FALSE;
4064 else
4065 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004066# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004067 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004068 if (idx_sp < 0)
4069 do_sp = FALSE;
4070 else
4071 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004072# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004073 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004074 if (p != NULL)
4075 {
4076 /*
4077 * Default for p_sp is "| tee", for p_srr is ">".
4078 * For known shells it is changed here to include stderr.
4079 */
4080 if ( fnamecmp(p, "csh") == 0
4081 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004082# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004083 || fnamecmp(p, "csh.exe") == 0
4084 || fnamecmp(p, "tcsh.exe") == 0
4085# endif
4086 )
4087 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004088# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004089 if (do_sp)
4090 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004091# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004093# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004094 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004095# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004096 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4097 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004098# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099 if (do_srr)
4100 {
4101 p_srr = (char_u *)">&";
4102 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4103 }
4104 }
4105 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004106 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004107 if ( fnamecmp(p, "sh") == 0
4108 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004109 || fnamecmp(p, "mksh") == 0
4110 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004111 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004112 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004113 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004114 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004115# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004116 || fnamecmp(p, "cmd") == 0
4117 || fnamecmp(p, "sh.exe") == 0
4118 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004119 || fnamecmp(p, "mksh.exe") == 0
4120 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004122 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004123 || fnamecmp(p, "bash.exe") == 0
4124 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004125# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004126 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004128# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129 if (do_sp)
4130 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004131# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004132 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004133# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004135# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4137 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004138# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004139 if (do_srr)
4140 {
4141 p_srr = (char_u *)">%s 2>&1";
4142 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4143 }
4144 }
4145 vim_free(p);
4146 }
4147#endif
4148
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004149#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004150 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004151 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4152 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004153 * This is done after other initializations, where 'shell' might have been
4154 * set, but only if they have not been set before. Default for p_shcf is
4155 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004156 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004157 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004158 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004159 {
4160 int idx3;
4161
4162 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004163 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004164 {
4165 p_shcf = (char_u *)"-c";
4166 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4167 }
4168
Bram Moolenaar071d4272004-06-13 20:20:40 +00004169 /* Somehow Win32 requires the quotes around the redirection too */
4170 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004171 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172 {
4173 p_sxq = (char_u *)"\"";
4174 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4175 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004177 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4178 {
4179 int idx3;
4180
4181 /*
4182 * cmd.exe on Windows will strip the first and last double quote given
4183 * on the command line, e.g. most of the time things like:
4184 * cmd /c "my path/to/echo" "my args to echo"
4185 * become:
4186 * my path/to/echo" "my args to echo
4187 * when executed.
4188 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004189 * To avoid this, set shellxquote to surround the command in
4190 * parenthesis. This appears to make most commands work, without
4191 * breaking commands that worked previously, such as
4192 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004193 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004194 idx3 = findoption((char_u *)"sxq");
4195 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4196 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004197 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004198 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4199 }
4200
Bram Moolenaara64ba222012-02-12 23:23:31 +01004201 idx3 = findoption((char_u *)"shcf");
4202 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4203 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004204 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004205 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4206 }
4207 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004208#endif
4209
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004210 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004211 {
4212 int idx_ffs = findoption((char_u *)"ffs");
4213
4214 /* Apply the first entry of 'fileformats' to the initial buffer. */
4215 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4216 set_fileformat(default_fileformat(), OPT_LOCAL);
4217 }
4218
Bram Moolenaar071d4272004-06-13 20:20:40 +00004219#ifdef FEAT_TITLE
4220 set_title_defaults();
4221#endif
4222}
4223
4224#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4225/*
4226 * When 'helplang' is still at its default value, set it to "lang".
4227 * Only the first two characters of "lang" are used.
4228 */
4229 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004230set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004231{
4232 int idx;
4233
4234 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4235 return;
4236 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004237 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004238 {
4239 if (options[idx].flags & P_ALLOCED)
4240 free_string_option(p_hlg);
4241 p_hlg = vim_strsave(lang);
4242 if (p_hlg == NULL)
4243 p_hlg = empty_option;
4244 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004245 {
4246 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4247 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4248 {
4249 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4250 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4251 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004252 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004253 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004254 options[idx].flags |= P_ALLOCED;
4255 }
4256}
4257#endif
4258
4259#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004260static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004261
4262 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004263gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004264{
4265 if (gui_get_lightness(gui.back_pixel) < 127)
4266 return (char_u *)"dark";
4267 return (char_u *)"light";
4268}
4269
4270/*
4271 * Option initializations that can only be done after opening the GUI window.
4272 */
4273 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004274init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004275{
4276 /* Set the 'background' option according to the lightness of the
4277 * background color, unless the user has set it already. */
4278 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4279 {
4280 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4281 highlight_changed();
4282 }
4283}
4284#endif
4285
4286#ifdef FEAT_TITLE
4287/*
4288 * 'title' and 'icon' only default to true if they have not been set or reset
4289 * in .vimrc and we can read the old value.
4290 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4291 * they can be reset. This reduces startup time when using X on a remote
4292 * machine.
4293 */
4294 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004295set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004296{
4297 int idx1;
4298 long val;
4299
4300 /*
4301 * If GUI is (going to be) used, we can always set the window title and
4302 * icon name. Saves a bit of time, because the X11 display server does
4303 * not need to be contacted.
4304 */
4305 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004306 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004307 {
4308#ifdef FEAT_GUI
4309 if (gui.starting || gui.in_use)
4310 val = TRUE;
4311 else
4312#endif
4313 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004314 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004315 p_title = val;
4316 }
4317 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004318 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004319 {
4320#ifdef FEAT_GUI
4321 if (gui.starting || gui.in_use)
4322 val = TRUE;
4323 else
4324#endif
4325 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004326 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004327 p_icon = val;
4328 }
4329}
4330#endif
4331
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004332#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4333 static void
4334trigger_optionsset_string(
4335 int opt_idx,
4336 int opt_flags,
4337 char_u *oldval,
4338 char_u *newval)
4339{
4340 if (oldval != NULL && newval != NULL)
4341 {
4342 char_u buf_type[7];
4343
4344 sprintf((char *)buf_type, "%s",
4345 (opt_flags & OPT_LOCAL) ? "local" : "global");
4346 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4347 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4348 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4349 apply_autocmds(EVENT_OPTIONSET,
4350 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4351 reset_v_option_vars();
4352 }
4353 vim_free(oldval);
4354 vim_free(newval);
4355}
4356#endif
4357
Bram Moolenaar071d4272004-06-13 20:20:40 +00004358/*
4359 * Parse 'arg' for option settings.
4360 *
4361 * 'arg' may be IObuff, but only when no errors can be present and option
4362 * does not need to be expanded with option_expand().
4363 * "opt_flags":
4364 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004365 * OPT_GLOBAL for ":setglobal"
4366 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004367 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004368 * OPT_WINONLY to only set window-local options
4369 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004370 *
4371 * returns FAIL if an error is detected, OK otherwise
4372 */
4373 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004374do_set(
4375 char_u *arg, /* option string (may be written to!) */
4376 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004377{
4378 int opt_idx;
4379 char_u *errmsg;
4380 char_u errbuf[80];
4381 char_u *startarg;
4382 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4383 int nextchar; /* next non-white char after option name */
4384 int afterchar; /* character just after option name */
4385 int len;
4386 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004387 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004388 int key;
4389 long_u flags; /* flags for current option */
4390 char_u *varp = NULL; /* pointer to variable for current option */
4391 int did_show = FALSE; /* already showed one value */
4392 int adding; /* "opt+=arg" */
4393 int prepending; /* "opt^=arg" */
4394 int removing; /* "opt-=arg" */
4395 int cp_val = 0;
4396 char_u key_name[2];
4397
4398 if (*arg == NUL)
4399 {
4400 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004401 did_show = TRUE;
4402 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004403 }
4404
4405 while (*arg != NUL) /* loop to process all options */
4406 {
4407 errmsg = NULL;
4408 startarg = arg; /* remember for error message */
4409
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004410 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4411 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004412 {
4413 /*
4414 * ":set all" show all options.
4415 * ":set all&" set all options to their default value.
4416 */
4417 arg += 3;
4418 if (*arg == '&')
4419 {
4420 ++arg;
4421 /* Only for :set command set global value of local options. */
4422 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004423 didset_options();
4424 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004425 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004426 }
4427 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004428 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004429 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004430 did_show = TRUE;
4431 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004432 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004433 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004434 {
4435 showoptions(2, opt_flags);
4436 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004437 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004438 arg += 7;
4439 }
4440 else
4441 {
4442 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004443 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004444 {
4445 prefix = 0;
4446 arg += 2;
4447 }
4448 else if (STRNCMP(arg, "inv", 3) == 0)
4449 {
4450 prefix = 2;
4451 arg += 3;
4452 }
4453
4454 /* find end of name */
4455 key = 0;
4456 if (*arg == '<')
4457 {
4458 nextchar = 0;
4459 opt_idx = -1;
4460 /* look out for <t_>;> */
4461 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4462 len = 5;
4463 else
4464 {
4465 len = 1;
4466 while (arg[len] != NUL && arg[len] != '>')
4467 ++len;
4468 }
4469 if (arg[len] != '>')
4470 {
4471 errmsg = e_invarg;
4472 goto skip;
4473 }
4474 arg[len] = NUL; /* put NUL after name */
4475 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4476 opt_idx = findoption(arg + 1);
4477 arg[len++] = '>'; /* restore '>' */
4478 if (opt_idx == -1)
4479 key = find_key_option(arg + 1);
4480 }
4481 else
4482 {
4483 len = 0;
4484 /*
4485 * The two characters after "t_" may not be alphanumeric.
4486 */
4487 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4488 len = 4;
4489 else
4490 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4491 ++len;
4492 nextchar = arg[len];
4493 arg[len] = NUL; /* put NUL after name */
4494 opt_idx = findoption(arg);
4495 arg[len] = nextchar; /* restore nextchar */
4496 if (opt_idx == -1)
4497 key = find_key_option(arg);
4498 }
4499
4500 /* remember character after option name */
4501 afterchar = arg[len];
4502
4503 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004504 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004505 ++len;
4506
4507 adding = FALSE;
4508 prepending = FALSE;
4509 removing = FALSE;
4510 if (arg[len] != NUL && arg[len + 1] == '=')
4511 {
4512 if (arg[len] == '+')
4513 {
4514 adding = TRUE; /* "+=" */
4515 ++len;
4516 }
4517 else if (arg[len] == '^')
4518 {
4519 prepending = TRUE; /* "^=" */
4520 ++len;
4521 }
4522 else if (arg[len] == '-')
4523 {
4524 removing = TRUE; /* "-=" */
4525 ++len;
4526 }
4527 }
4528 nextchar = arg[len];
4529
4530 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4531 {
4532 errmsg = (char_u *)N_("E518: Unknown option");
4533 goto skip;
4534 }
4535
4536 if (opt_idx >= 0)
4537 {
4538 if (options[opt_idx].var == NULL) /* hidden option: skip */
4539 {
4540 /* Only give an error message when requesting the value of
4541 * a hidden option, ignore setting it. */
4542 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4543 && (!(options[opt_idx].flags & P_BOOL)
4544 || nextchar == '?'))
4545 errmsg = (char_u *)N_("E519: Option not supported");
4546 goto skip;
4547 }
4548
4549 flags = options[opt_idx].flags;
4550 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4551 }
4552 else
4553 {
4554 flags = P_STRING;
4555 if (key < 0)
4556 {
4557 key_name[0] = KEY2TERMCAP0(key);
4558 key_name[1] = KEY2TERMCAP1(key);
4559 }
4560 else
4561 {
4562 key_name[0] = KS_KEY;
4563 key_name[1] = (key & 0xff);
4564 }
4565 }
4566
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004567 /* Skip all options that are not window-local (used when showing
4568 * an already loaded buffer in a window). */
4569 if ((opt_flags & OPT_WINONLY)
4570 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4571 goto skip;
4572
Bram Moolenaara3227e22006-03-08 21:32:40 +00004573 /* Skip all options that are window-local (used for :vimgrep). */
4574 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4575 && options[opt_idx].var == VAR_WIN)
4576 goto skip;
4577
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004578 /* Disallow changing some options from modelines. */
4579 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004580 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004581 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004582 {
4583 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4584 goto skip;
4585 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004586#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004587 /* In diff mode some options are overruled. This avoids that
4588 * 'foldmethod' becomes "marker" instead of "diff" and that
4589 * "wrap" gets set. */
4590 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004591 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004592 && (
4593#ifdef FEAT_FOLDING
4594 options[opt_idx].indir == PV_FDM ||
4595#endif
4596 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004597 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004598#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004599 }
4600
4601#ifdef HAVE_SANDBOX
4602 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004603 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004604 {
4605 errmsg = (char_u *)_(e_sandbox);
4606 goto skip;
4607 }
4608#endif
4609
4610 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4611 {
4612 arg += len;
4613 cp_val = p_cp;
4614 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4615 {
4616 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4617 {
4618 cp_val = FALSE;
4619 arg += 3;
4620 }
4621 else /* "opt&vi": set to Vi default */
4622 {
4623 cp_val = TRUE;
4624 arg += 2;
4625 }
4626 }
4627 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004628 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004629 {
4630 errmsg = e_trailing;
4631 goto skip;
4632 }
4633 }
4634
4635 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004636 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4637 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004638 */
4639 if (nextchar == '?'
4640 || (prefix == 1
4641 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4642 && !(flags & P_BOOL)))
4643 {
4644 /*
4645 * print value
4646 */
4647 if (did_show)
4648 msg_putchar('\n'); /* cursor below last one */
4649 else
4650 {
4651 gotocmdline(TRUE); /* cursor at status line */
4652 did_show = TRUE; /* remember that we did a line */
4653 }
4654 if (opt_idx >= 0)
4655 {
4656 showoneopt(&options[opt_idx], opt_flags);
4657#ifdef FEAT_EVAL
4658 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004659 {
4660 /* Mention where the option was last set. */
4661 if (varp == options[opt_idx].var)
4662 last_set_msg(options[opt_idx].scriptID);
4663 else if ((int)options[opt_idx].indir & PV_WIN)
4664 last_set_msg(curwin->w_p_scriptID[
4665 (int)options[opt_idx].indir & PV_MASK]);
4666 else if ((int)options[opt_idx].indir & PV_BUF)
4667 last_set_msg(curbuf->b_p_scriptID[
4668 (int)options[opt_idx].indir & PV_MASK]);
4669 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004670#endif
4671 }
4672 else
4673 {
4674 char_u *p;
4675
4676 p = find_termcode(key_name);
4677 if (p == NULL)
4678 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004679 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004680 goto skip;
4681 }
4682 else
4683 (void)show_one_termcode(key_name, p, TRUE);
4684 }
4685 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004686 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004687 errmsg = e_trailing;
4688 }
4689 else
4690 {
4691 if (flags & P_BOOL) /* boolean */
4692 {
4693 if (nextchar == '=' || nextchar == ':')
4694 {
4695 errmsg = e_invarg;
4696 goto skip;
4697 }
4698
4699 /*
4700 * ":set opt!": invert
4701 * ":set opt&": reset to default value
4702 * ":set opt<": reset to global value
4703 */
4704 if (nextchar == '!')
4705 value = *(int *)(varp) ^ 1;
4706 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004707 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004708 ((flags & P_VI_DEF) || cp_val)
4709 ? VI_DEFAULT : VIM_DEFAULT];
4710 else if (nextchar == '<')
4711 {
4712 /* For 'autoread' -1 means to use global value. */
4713 if ((int *)varp == &curbuf->b_p_ar
4714 && opt_flags == OPT_LOCAL)
4715 value = -1;
4716 else
4717 value = *(int *)get_varp_scope(&(options[opt_idx]),
4718 OPT_GLOBAL);
4719 }
4720 else
4721 {
4722 /*
4723 * ":set invopt": invert
4724 * ":set opt" or ":set noopt": set or reset
4725 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004726 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004727 {
4728 errmsg = e_trailing;
4729 goto skip;
4730 }
4731 if (prefix == 2) /* inv */
4732 value = *(int *)(varp) ^ 1;
4733 else
4734 value = prefix;
4735 }
4736
4737 errmsg = set_bool_option(opt_idx, varp, (int)value,
4738 opt_flags);
4739 }
4740 else /* numeric or string */
4741 {
4742 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4743 || prefix != 1)
4744 {
4745 errmsg = e_invarg;
4746 goto skip;
4747 }
4748
4749 if (flags & P_NUM) /* numeric */
4750 {
4751 /*
4752 * Different ways to set a number option:
4753 * & set to default value
4754 * < set to global value
4755 * <xx> accept special key codes for 'wildchar'
4756 * c accept any non-digit for 'wildchar'
4757 * [-]0-9 set number
4758 * other error
4759 */
4760 ++arg;
4761 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004762 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004763 ((flags & P_VI_DEF) || cp_val)
4764 ? VI_DEFAULT : VIM_DEFAULT];
4765 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004766 {
4767 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4768 * use the global value. */
4769 if ((long *)varp == &curbuf->b_p_ul
4770 && opt_flags == OPT_LOCAL)
4771 value = NO_LOCAL_UNDOLEVEL;
4772 else
4773 value = *(long *)get_varp_scope(
4774 &(options[opt_idx]), OPT_GLOBAL);
4775 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004776 else if (((long *)varp == &p_wc
4777 || (long *)varp == &p_wcm)
4778 && (*arg == '<'
4779 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004780 || (*arg != NUL
4781 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004782 && !VIM_ISDIGIT(*arg))))
4783 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02004784 value = string_to_key(arg, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004785 if (value == 0 && (long *)varp != &p_wcm)
4786 {
4787 errmsg = e_invarg;
4788 goto skip;
4789 }
4790 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004791 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4792 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004793 /* Allow negative (for 'undolevels'), octal and
4794 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004795 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4796 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004797 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004798 {
4799 errmsg = e_invarg;
4800 goto skip;
4801 }
4802 }
4803 else
4804 {
4805 errmsg = (char_u *)N_("E521: Number required after =");
4806 goto skip;
4807 }
4808
4809 if (adding)
4810 value = *(long *)varp + value;
4811 if (prepending)
4812 value = *(long *)varp * value;
4813 if (removing)
4814 value = *(long *)varp - value;
4815 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004816 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004817 }
4818 else if (opt_idx >= 0) /* string */
4819 {
4820 char_u *save_arg = NULL;
4821 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004822 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004823 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004824 char_u *origval = NULL;
4825#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4826 char_u *saved_origval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004827 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004828#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004829 unsigned newlen;
4830 int comma;
4831 int bs;
4832 int new_value_alloced; /* new string option
4833 was allocated */
4834
4835 /* When using ":set opt=val" for a global option
4836 * with a local value the local value will be
4837 * reset, use the global value here. */
4838 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004839 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004840 varp = options[opt_idx].var;
4841
4842 /* The old value is kept until we are sure that the
4843 * new value is valid. */
4844 oldval = *(char_u **)varp;
4845 if (nextchar == '&') /* set to default val */
4846 {
4847 newval = options[opt_idx].def_val[
4848 ((flags & P_VI_DEF) || cp_val)
4849 ? VI_DEFAULT : VIM_DEFAULT];
4850 if ((char_u **)varp == &p_bg)
4851 {
4852 /* guess the value of 'background' */
4853#ifdef FEAT_GUI
4854 if (gui.in_use)
4855 newval = gui_bg_default();
4856 else
4857#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004858 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004859 }
4860
4861 /* expand environment variables and ~ (since the
4862 * default value was already expanded, only
4863 * required when an environment variable was set
4864 * later */
4865 if (newval == NULL)
4866 newval = empty_option;
4867 else
4868 {
4869 s = option_expand(opt_idx, newval);
4870 if (s == NULL)
4871 s = newval;
4872 newval = vim_strsave(s);
4873 }
4874 new_value_alloced = TRUE;
4875 }
4876 else if (nextchar == '<') /* set to global val */
4877 {
4878 newval = vim_strsave(*(char_u **)get_varp_scope(
4879 &(options[opt_idx]), OPT_GLOBAL));
4880 new_value_alloced = TRUE;
4881 }
4882 else
4883 {
4884 ++arg; /* jump to after the '=' or ':' */
4885
4886 /*
4887 * Set 'keywordprg' to ":help" if an empty
4888 * value was passed to :set by the user.
4889 * Misuse errbuf[] for the resulting string.
4890 */
4891 if (varp == (char_u *)&p_kp
4892 && (*arg == NUL || *arg == ' '))
4893 {
4894 STRCPY(errbuf, ":help");
4895 save_arg = arg;
4896 arg = errbuf;
4897 }
4898 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004899 * Convert 'backspace' number to string, for
4900 * adding, prepending and removing string.
4901 */
4902 else if (varp == (char_u *)&p_bs
4903 && VIM_ISDIGIT(**(char_u **)varp))
4904 {
4905 i = getdigits((char_u **)varp);
4906 switch (i)
4907 {
4908 case 0:
4909 *(char_u **)varp = empty_option;
4910 break;
4911 case 1:
4912 *(char_u **)varp = vim_strsave(
4913 (char_u *)"indent,eol");
4914 break;
4915 case 2:
4916 *(char_u **)varp = vim_strsave(
4917 (char_u *)"indent,eol,start");
4918 break;
4919 }
4920 vim_free(oldval);
4921 oldval = *(char_u **)varp;
4922 }
4923 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004924 * Convert 'whichwrap' number to string, for
4925 * backwards compatibility with Vim 3.0.
4926 * Misuse errbuf[] for the resulting string.
4927 */
4928 else if (varp == (char_u *)&p_ww
4929 && VIM_ISDIGIT(*arg))
4930 {
4931 *errbuf = NUL;
4932 i = getdigits(&arg);
4933 if (i & 1)
4934 STRCAT(errbuf, "b,");
4935 if (i & 2)
4936 STRCAT(errbuf, "s,");
4937 if (i & 4)
4938 STRCAT(errbuf, "h,l,");
4939 if (i & 8)
4940 STRCAT(errbuf, "<,>,");
4941 if (i & 16)
4942 STRCAT(errbuf, "[,],");
4943 if (*errbuf != NUL) /* remove trailing , */
4944 errbuf[STRLEN(errbuf) - 1] = NUL;
4945 save_arg = arg;
4946 arg = errbuf;
4947 }
4948 /*
4949 * Remove '>' before 'dir' and 'bdir', for
4950 * backwards compatibility with version 3.0
4951 */
4952 else if ( *arg == '>'
4953 && (varp == (char_u *)&p_dir
4954 || varp == (char_u *)&p_bdir))
4955 {
4956 ++arg;
4957 }
4958
4959 /* When setting the local value of a global
4960 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004961 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004962 && (opt_flags & OPT_LOCAL))
4963 origval = *(char_u **)get_varp(
4964 &options[opt_idx]);
4965 else
4966 origval = oldval;
4967
4968 /*
4969 * Copy the new string into allocated memory.
4970 * Can't use set_string_option_direct(), because
4971 * we need to remove the backslashes.
4972 */
4973 /* get a bit too much */
4974 newlen = (unsigned)STRLEN(arg) + 1;
4975 if (adding || prepending || removing)
4976 newlen += (unsigned)STRLEN(origval) + 1;
4977 newval = alloc(newlen);
4978 if (newval == NULL) /* out of mem, don't change */
4979 break;
4980 s = newval;
4981
4982 /*
4983 * Copy the string, skip over escaped chars.
4984 * For MS-DOS and WIN32 backslashes before normal
4985 * file name characters are not removed, and keep
4986 * backslash at start, for "\\machine\path", but
4987 * do remove it for "\\\\machine\\path".
4988 * The reverse is found in ExpandOldSetting().
4989 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004990 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004991 {
4992 if (*arg == '\\' && arg[1] != NUL
4993#ifdef BACKSLASH_IN_FILENAME
4994 && !((flags & P_EXPAND)
4995 && vim_isfilec(arg[1])
4996 && (arg[1] != '\\'
4997 || (s == newval
4998 && arg[2] != '\\')))
4999#endif
5000 )
5001 ++arg; /* remove backslash */
5002#ifdef FEAT_MBYTE
5003 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00005004 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005005 {
5006 /* copy multibyte char */
5007 mch_memmove(s, arg, (size_t)i);
5008 arg += i;
5009 s += i;
5010 }
5011 else
5012#endif
5013 *s++ = *arg++;
5014 }
5015 *s = NUL;
5016
5017 /*
5018 * Expand environment variables and ~.
5019 * Don't do it when adding without inserting a
5020 * comma.
5021 */
5022 if (!(adding || prepending || removing)
5023 || (flags & P_COMMA))
5024 {
5025 s = option_expand(opt_idx, newval);
5026 if (s != NULL)
5027 {
5028 vim_free(newval);
5029 newlen = (unsigned)STRLEN(s) + 1;
5030 if (adding || prepending || removing)
5031 newlen += (unsigned)STRLEN(origval) + 1;
5032 newval = alloc(newlen);
5033 if (newval == NULL)
5034 break;
5035 STRCPY(newval, s);
5036 }
5037 }
5038
5039 /* locate newval[] in origval[] when removing it
5040 * and when adding to avoid duplicates */
5041 i = 0; /* init for GCC */
5042 if (removing || (flags & P_NODUP))
5043 {
5044 i = (int)STRLEN(newval);
5045 bs = 0;
5046 for (s = origval; *s; ++s)
5047 {
5048 if ((!(flags & P_COMMA)
5049 || s == origval
5050 || (s[-1] == ',' && !(bs & 1)))
5051 && STRNCMP(s, newval, i) == 0
5052 && (!(flags & P_COMMA)
5053 || s[i] == ','
5054 || s[i] == NUL))
5055 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005056 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005057 * even number of backslashes or a single
5058 * backslash preceded by a comma before it
5059 * is recognized as a separator */
5060 if ((s > origval + 1
5061 && s[-1] == '\\'
5062 && s[-2] != ',')
5063 || (s == origval + 1
5064 && s[-1] == '\\'))
5065
Bram Moolenaar071d4272004-06-13 20:20:40 +00005066 ++bs;
5067 else
5068 bs = 0;
5069 }
5070
5071 /* do not add if already there */
5072 if ((adding || prepending) && *s)
5073 {
5074 prepending = FALSE;
5075 adding = FALSE;
5076 STRCPY(newval, origval);
5077 }
5078 }
5079
5080 /* concatenate the two strings; add a ',' if
5081 * needed */
5082 if (adding || prepending)
5083 {
5084 comma = ((flags & P_COMMA) && *origval != NUL
5085 && *newval != NUL);
5086 if (adding)
5087 {
5088 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005089 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005090 if (comma && i > 1
5091 && (flags & P_ONECOMMA) == P_ONECOMMA
5092 && origval[i - 1] == ','
5093 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005094 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005095 mch_memmove(newval + i + comma, newval,
5096 STRLEN(newval) + 1);
5097 mch_memmove(newval, origval, (size_t)i);
5098 }
5099 else
5100 {
5101 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005102 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005103 }
5104 if (comma)
5105 newval[i] = ',';
5106 }
5107
5108 /* Remove newval[] from origval[]. (Note: "i" has
5109 * been set above and is used here). */
5110 if (removing)
5111 {
5112 STRCPY(newval, origval);
5113 if (*s)
5114 {
5115 /* may need to remove a comma */
5116 if (flags & P_COMMA)
5117 {
5118 if (s == origval)
5119 {
5120 /* include comma after string */
5121 if (s[i] == ',')
5122 ++i;
5123 }
5124 else
5125 {
5126 /* include comma before string */
5127 --s;
5128 ++i;
5129 }
5130 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005131 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005132 }
5133 }
5134
5135 if (flags & P_FLAGLIST)
5136 {
5137 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005138 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005139 {
5140 /* if options have P_FLAGLIST and
5141 * P_ONECOMMA such as 'whichwrap' */
5142 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005143 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005144 if (*s != ',' && *(s + 1) == ','
5145 && vim_strchr(s + 2, *s) != NULL)
5146 {
5147 /* Remove the duplicated value and
5148 * the next comma. */
5149 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005150 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005151 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005152 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005153 else
5154 {
5155 if ((!(flags & P_COMMA) || *s != ',')
5156 && vim_strchr(s + 1, *s) != NULL)
5157 {
5158 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005159 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005160 }
5161 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005162 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005163 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005164 }
5165
5166 if (save_arg != NULL) /* number for 'whichwrap' */
5167 arg = save_arg;
5168 new_value_alloced = TRUE;
5169 }
5170
5171 /* Set the new value. */
5172 *(char_u **)(varp) = newval;
5173
Bram Moolenaar53744302015-07-17 17:38:22 +02005174#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005175 if (!starting
5176# ifdef FEAT_CRYPT
5177 && options[opt_idx].indir != PV_KEY
5178# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005179 && origval != NULL && newval != NULL)
5180 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005181 /* origval may be freed by
5182 * did_set_string_option(), make a copy. */
5183 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005184 /* newval (and varp) may become invalid if the
5185 * buffer is closed by autocommands. */
5186 saved_newval = vim_strsave(newval);
5187 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005188#endif
5189
Bram Moolenaar071d4272004-06-13 20:20:40 +00005190 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005191 * ":set" on local options. Note: when setting 'syntax'
5192 * or 'filetype' autocommands may be triggered that can
5193 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005194 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5195 new_value_alloced, oldval, errbuf, opt_flags);
5196
5197 /* If error detected, print the error message. */
5198 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01005199 {
5200#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5201 vim_free(saved_origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005202 vim_free(saved_newval);
Bram Moolenaara9884962015-12-13 15:08:56 +01005203#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005204 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01005205 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005206#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005207 trigger_optionsset_string(opt_idx, opt_flags,
5208 saved_origval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005209#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005210 }
5211 else /* key code option */
5212 {
5213 char_u *p;
5214
5215 if (nextchar == '&')
5216 {
5217 if (add_termcap_entry(key_name, TRUE) == FAIL)
5218 errmsg = (char_u *)N_("E522: Not found in termcap");
5219 }
5220 else
5221 {
5222 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005223 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005224 if (*p == '\\' && p[1] != NUL)
5225 ++p;
5226 nextchar = *p;
5227 *p = NUL;
5228 add_termcode(key_name, arg, FALSE);
5229 *p = nextchar;
5230 }
5231 if (full_screen)
5232 ttest(FALSE);
5233 redraw_all_later(CLEAR);
5234 }
5235 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005236
Bram Moolenaar071d4272004-06-13 20:20:40 +00005237 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005238 did_set_option(opt_idx, opt_flags,
5239 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005240 }
5241
5242skip:
5243 /*
5244 * Advance to next argument.
5245 * - skip until a blank found, taking care of backslashes
5246 * - skip blanks
5247 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5248 */
5249 for (i = 0; i < 2 ; ++i)
5250 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005251 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005252 if (*arg++ == '\\' && *arg != NUL)
5253 ++arg;
5254 arg = skipwhite(arg);
5255 if (*arg != '=')
5256 break;
5257 }
5258 }
5259
5260 if (errmsg != NULL)
5261 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005262 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005263 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005264 if (i + (arg - startarg) < IOSIZE)
5265 {
5266 /* append the argument with the error */
5267 STRCAT(IObuff, ": ");
5268 mch_memmove(IObuff + i, startarg, (arg - startarg));
5269 IObuff[i + (arg - startarg)] = NUL;
5270 }
5271 /* make sure all characters are printable */
5272 trans_characters(IObuff, IOSIZE);
5273
5274 ++no_wait_return; /* wait_return done later */
5275 emsg(IObuff); /* show error highlighted */
5276 --no_wait_return;
5277
5278 return FAIL;
5279 }
5280
5281 arg = skipwhite(arg);
5282 }
5283
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005284theend:
5285 if (silent_mode && did_show)
5286 {
5287 /* After displaying option values in silent mode. */
5288 silent_mode = FALSE;
5289 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5290 msg_putchar('\n');
5291 cursor_on(); /* msg_start() switches it off */
5292 out_flush();
5293 silent_mode = TRUE;
5294 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5295 }
5296
Bram Moolenaar071d4272004-06-13 20:20:40 +00005297 return OK;
5298}
5299
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005300/*
5301 * Call this when an option has been given a new value through a user command.
5302 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5303 */
5304 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005305did_set_option(
5306 int opt_idx,
5307 int opt_flags, /* possibly with OPT_MODELINE */
5308 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005309{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005310 long_u *p;
5311
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005312 options[opt_idx].flags |= P_WAS_SET;
5313
5314 /* When an option is set in the sandbox, from a modeline or in secure mode
5315 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005316 * flag. */
5317 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005318 if (secure
5319#ifdef HAVE_SANDBOX
5320 || sandbox != 0
5321#endif
5322 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005323 *p = *p | P_INSECURE;
5324 else if (new_value)
5325 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005326}
5327
Bram Moolenaar071d4272004-06-13 20:20:40 +00005328 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005329illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005330{
5331 if (errbuf == NULL)
5332 return (char_u *)"";
5333 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005334 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005335 return errbuf;
5336}
5337
5338/*
5339 * Convert a key name or string into a key value.
5340 * Used for 'wildchar' and 'cedit' options.
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005341 * When "multi_byte" is TRUE allow for multi-byte characters.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005342 */
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005343 int
5344string_to_key(char_u *arg, int multi_byte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005345{
5346 if (*arg == '<')
5347 return find_key_option(arg + 1);
5348 if (*arg == '^')
5349 return Ctrl_chr(arg[1]);
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005350 if (multi_byte)
5351 return PTR2CHAR(arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005352 return *arg;
5353}
5354
5355#ifdef FEAT_CMDWIN
5356/*
5357 * Check value of 'cedit' and set cedit_key.
5358 * Returns NULL if value is OK, error message otherwise.
5359 */
5360 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005361check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005362{
5363 int n;
5364
5365 if (*p_cedit == NUL)
5366 cedit_key = -1;
5367 else
5368 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005369 n = string_to_key(p_cedit, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005370 if (vim_isprintc(n))
5371 return e_invarg;
5372 cedit_key = n;
5373 }
5374 return NULL;
5375}
5376#endif
5377
5378#ifdef FEAT_TITLE
5379/*
5380 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5381 * maketitle() to create and display it.
5382 * When switching the title or icon off, call mch_restore_title() to get
5383 * the old value back.
5384 */
5385 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005386did_set_title(
5387 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005388{
5389 if (starting != NO_SCREEN
5390#ifdef FEAT_GUI
5391 && !gui.starting
5392#endif
5393 )
5394 {
5395 maketitle();
5396 if (icon)
5397 {
5398 if (!p_icon)
5399 mch_restore_title(2);
5400 }
5401 else
5402 {
5403 if (!p_title)
5404 mch_restore_title(1);
5405 }
5406 }
5407}
5408#endif
5409
5410/*
5411 * set_options_bin - called when 'bin' changes value.
5412 */
5413 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005414set_options_bin(
5415 int oldval,
5416 int newval,
5417 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005418{
5419 /*
5420 * The option values that are changed when 'bin' changes are
5421 * copied when 'bin is set and restored when 'bin' is reset.
5422 */
5423 if (newval)
5424 {
5425 if (!oldval) /* switched on */
5426 {
5427 if (!(opt_flags & OPT_GLOBAL))
5428 {
5429 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5430 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5431 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5432 curbuf->b_p_et_nobin = curbuf->b_p_et;
5433 }
5434 if (!(opt_flags & OPT_LOCAL))
5435 {
5436 p_tw_nobin = p_tw;
5437 p_wm_nobin = p_wm;
5438 p_ml_nobin = p_ml;
5439 p_et_nobin = p_et;
5440 }
5441 }
5442
5443 if (!(opt_flags & OPT_GLOBAL))
5444 {
5445 curbuf->b_p_tw = 0; /* no automatic line wrap */
5446 curbuf->b_p_wm = 0; /* no automatic line wrap */
5447 curbuf->b_p_ml = 0; /* no modelines */
5448 curbuf->b_p_et = 0; /* no expandtab */
5449 }
5450 if (!(opt_flags & OPT_LOCAL))
5451 {
5452 p_tw = 0;
5453 p_wm = 0;
5454 p_ml = FALSE;
5455 p_et = FALSE;
5456 p_bin = TRUE; /* needed when called for the "-b" argument */
5457 }
5458 }
5459 else if (oldval) /* switched off */
5460 {
5461 if (!(opt_flags & OPT_GLOBAL))
5462 {
5463 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5464 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5465 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5466 curbuf->b_p_et = curbuf->b_p_et_nobin;
5467 }
5468 if (!(opt_flags & OPT_LOCAL))
5469 {
5470 p_tw = p_tw_nobin;
5471 p_wm = p_wm_nobin;
5472 p_ml = p_ml_nobin;
5473 p_et = p_et_nobin;
5474 }
5475 }
5476}
5477
5478#ifdef FEAT_VIMINFO
5479/*
5480 * Find the parameter represented by the given character (eg ', :, ", or /),
5481 * and return its associated value in the 'viminfo' string.
5482 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005483 * If the parameter is not specified in the string or there is no following
5484 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005485 */
5486 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005487get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005488{
5489 char_u *p;
5490
5491 p = find_viminfo_parameter(type);
5492 if (p != NULL && VIM_ISDIGIT(*p))
5493 return atoi((char *)p);
5494 return -1;
5495}
5496
5497/*
5498 * Find the parameter represented by the given character (eg ''', ':', '"', or
5499 * '/') in the 'viminfo' option and return a pointer to the string after it.
5500 * Return NULL if the parameter is not specified in the string.
5501 */
5502 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005503find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005504{
5505 char_u *p;
5506
5507 for (p = p_viminfo; *p; ++p)
5508 {
5509 if (*p == type)
5510 return p + 1;
5511 if (*p == 'n') /* 'n' is always the last one */
5512 break;
5513 p = vim_strchr(p, ','); /* skip until next ',' */
5514 if (p == NULL) /* hit the end without finding parameter */
5515 break;
5516 }
5517 return NULL;
5518}
5519#endif
5520
5521/*
5522 * Expand environment variables for some string options.
5523 * These string options cannot be indirect!
5524 * If "val" is NULL expand the current value of the option.
5525 * Return pointer to NameBuff, or NULL when not expanded.
5526 */
5527 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005528option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005529{
5530 /* if option doesn't need expansion nothing to do */
5531 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5532 return NULL;
5533
5534 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5535 * expand_env() would truncate the string. */
5536 if (val != NULL && STRLEN(val) > MAXPATHL)
5537 return NULL;
5538
5539 if (val == NULL)
5540 val = *(char_u **)options[opt_idx].var;
5541
5542 /*
5543 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5544 * Escape spaces when expanding 'tags', they are used to separate file
5545 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005546 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005547 */
5548 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005549 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005550#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005551 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5552#endif
5553 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005554 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5555 return NULL;
5556
5557 return NameBuff;
5558}
5559
5560/*
5561 * After setting various option values: recompute variables that depend on
5562 * option values.
5563 */
5564 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005565didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005566{
5567 /* initialize the table for 'iskeyword' et.al. */
5568 (void)init_chartab();
5569
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005570#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005571 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005572#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005573 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005574 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005575#ifdef FEAT_SESSION
5576 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5577 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5578#endif
5579#ifdef FEAT_FOLDING
5580 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5581#endif
5582 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005583 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005584#ifdef FEAT_VIRTUALEDIT
5585 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5586#endif
5587#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5588 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5589#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005590#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005591 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005592 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005593 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005594 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005595#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005596#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5597 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5598#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005599#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005600 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5601#endif
5602#ifdef FEAT_CMDWIN
5603 /* set cedit_key */
5604 (void)check_cedit();
5605#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005606#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005607 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005608#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005609#ifdef FEAT_LINEBREAK
5610 /* initialize the table for 'breakat'. */
5611 fill_breakat_flags();
5612#endif
5613
5614}
5615
5616/*
5617 * More side effects of setting options.
5618 */
5619 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005620didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005621{
5622 /* Initialize the highlight_attr[] table. */
5623 (void)highlight_changed();
5624
5625 /* Parse default for 'wildmode' */
5626 check_opt_wim();
5627
5628 (void)set_chars_option(&p_lcs);
5629#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5630 /* Parse default for 'fillchars'. */
5631 (void)set_chars_option(&p_fcs);
5632#endif
5633
5634#ifdef FEAT_CLIPBOARD
5635 /* Parse default for 'clipboard' */
5636 (void)check_clipboard_option();
5637#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005638}
5639
5640/*
5641 * Check for string options that are NULL (normally only termcap options).
5642 */
5643 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005644check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005645{
5646 int opt_idx;
5647
5648 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5649 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5650 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5651}
5652
5653/*
5654 * Check string options in a buffer for NULL value.
5655 */
5656 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005657check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005658{
Bram Moolenaar071d4272004-06-13 20:20:40 +00005659 check_string_option(&buf->b_p_bh);
5660 check_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005661#ifdef FEAT_MBYTE
5662 check_string_option(&buf->b_p_fenc);
5663#endif
5664 check_string_option(&buf->b_p_ff);
5665#ifdef FEAT_FIND_ID
5666 check_string_option(&buf->b_p_def);
5667 check_string_option(&buf->b_p_inc);
5668# ifdef FEAT_EVAL
5669 check_string_option(&buf->b_p_inex);
5670# endif
5671#endif
5672#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5673 check_string_option(&buf->b_p_inde);
5674 check_string_option(&buf->b_p_indk);
5675#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005676#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5677 check_string_option(&buf->b_p_bexpr);
5678#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005679#if defined(FEAT_CRYPT)
5680 check_string_option(&buf->b_p_cm);
5681#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005682 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005683#if defined(FEAT_EVAL)
5684 check_string_option(&buf->b_p_fex);
5685#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005686#ifdef FEAT_CRYPT
5687 check_string_option(&buf->b_p_key);
5688#endif
5689 check_string_option(&buf->b_p_kp);
5690 check_string_option(&buf->b_p_mps);
5691 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005692 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005693 check_string_option(&buf->b_p_isk);
5694#ifdef FEAT_COMMENTS
5695 check_string_option(&buf->b_p_com);
5696#endif
5697#ifdef FEAT_FOLDING
5698 check_string_option(&buf->b_p_cms);
5699#endif
5700 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005701#ifdef FEAT_TEXTOBJ
5702 check_string_option(&buf->b_p_qe);
5703#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005704#ifdef FEAT_SYN_HL
5705 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005706 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005707#endif
5708#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005709 check_string_option(&buf->b_s.b_p_spc);
5710 check_string_option(&buf->b_s.b_p_spf);
5711 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005712#endif
5713#ifdef FEAT_SEARCHPATH
5714 check_string_option(&buf->b_p_sua);
5715#endif
5716#ifdef FEAT_CINDENT
5717 check_string_option(&buf->b_p_cink);
5718 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005719 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005720#endif
5721#ifdef FEAT_AUTOCMD
5722 check_string_option(&buf->b_p_ft);
5723#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005724#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5725 check_string_option(&buf->b_p_cinw);
5726#endif
5727#ifdef FEAT_INS_EXPAND
5728 check_string_option(&buf->b_p_cpt);
5729#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005730#ifdef FEAT_COMPL_FUNC
5731 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005732 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005733#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005734#ifdef FEAT_KEYMAP
5735 check_string_option(&buf->b_p_keymap);
5736#endif
5737#ifdef FEAT_QUICKFIX
5738 check_string_option(&buf->b_p_gp);
5739 check_string_option(&buf->b_p_mp);
5740 check_string_option(&buf->b_p_efm);
5741#endif
5742 check_string_option(&buf->b_p_ep);
5743 check_string_option(&buf->b_p_path);
5744 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005745 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005746#ifdef FEAT_INS_EXPAND
5747 check_string_option(&buf->b_p_dict);
5748 check_string_option(&buf->b_p_tsr);
5749#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005750#ifdef FEAT_LISP
5751 check_string_option(&buf->b_p_lw);
5752#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005753 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005754#ifdef FEAT_MBYTE
5755 check_string_option(&buf->b_p_menc);
5756#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005757}
5758
5759/*
5760 * Free the string allocated for an option.
5761 * Checks for the string being empty_option. This may happen if we're out of
5762 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5763 * check_options().
5764 * Does NOT check for P_ALLOCED flag!
5765 */
5766 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005767free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005768{
5769 if (p != empty_option)
5770 vim_free(p);
5771}
5772
5773 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005774clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005775{
5776 if (*pp != empty_option)
5777 vim_free(*pp);
5778 *pp = empty_option;
5779}
5780
5781 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005782check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005783{
5784 if (*pp == NULL)
5785 *pp = empty_option;
5786}
5787
5788/*
5789 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5790 */
5791 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005792set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005793{
5794 int opt_idx;
5795
5796 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5797 if (options[opt_idx].var == (char_u *)p)
5798 {
5799 options[opt_idx].flags |= P_ALLOCED;
5800 return;
5801 }
5802 return; /* cannot happen: didn't find it! */
5803}
5804
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005805#if defined(FEAT_EVAL) || defined(PROTO)
5806/*
5807 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5808 * Return FALSE when it wasn't.
5809 * Return -1 for an unknown option.
5810 */
5811 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005812was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005813{
5814 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005815 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005816
5817 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005818 {
5819 flagp = insecure_flag(idx, opt_flags);
5820 return (*flagp & P_INSECURE) != 0;
5821 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005822 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005823 return -1;
5824}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005825
5826/*
5827 * Get a pointer to the flags used for the P_INSECURE flag of option
5828 * "opt_idx". For some local options a local flags field is used.
5829 */
5830 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005831insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005832{
5833 if (opt_flags & OPT_LOCAL)
5834 switch ((int)options[opt_idx].indir)
5835 {
5836#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005837 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005838#endif
5839#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005840# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005841 case PV_FDE: return &curwin->w_p_fde_flags;
5842 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005843# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005844# ifdef FEAT_BEVAL
5845 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5846# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005847# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005848 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005849# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005850 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005851# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005852 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005853# endif
5854#endif
5855 }
5856
5857 /* Nothing special, return global flags field. */
5858 return &options[opt_idx].flags;
5859}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005860#endif
5861
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005862#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005863static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005864
5865/*
5866 * Redraw the window title and/or tab page text later.
5867 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005868static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005869{
5870 need_maketitle = TRUE;
5871# ifdef FEAT_WINDOWS
5872 redraw_tabline = TRUE;
5873# endif
5874}
5875#endif
5876
Bram Moolenaar071d4272004-06-13 20:20:40 +00005877/*
5878 * Set a string option to a new value (without checking the effect).
5879 * The string is copied into allocated memory.
5880 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005881 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005882 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005883 */
5884 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005885set_string_option_direct(
5886 char_u *name,
5887 int opt_idx,
5888 char_u *val,
5889 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5890 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005891{
5892 char_u *s;
5893 char_u **varp;
5894 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005895 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005896
Bram Moolenaar89d40322006-08-29 15:30:07 +00005897 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005898 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005899 idx = findoption(name);
5900 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005901 {
5902 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005903 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005904 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005905 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005906 }
5907
Bram Moolenaar89d40322006-08-29 15:30:07 +00005908 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005909 return;
5910
5911 s = vim_strsave(val);
5912 if (s != NULL)
5913 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005914 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005915 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005916 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005917 free_string_option(*varp);
5918 *varp = s;
5919
5920 /* For buffer/window local option may also set the global value. */
5921 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005922 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005923
Bram Moolenaar89d40322006-08-29 15:30:07 +00005924 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005925
5926 /* When setting both values of a global option with a local value,
5927 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005928 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005929 {
5930 free_string_option(*varp);
5931 *varp = empty_option;
5932 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005933# ifdef FEAT_EVAL
5934 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005935 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005936 set_sid == 0 ? current_SID : set_sid);
5937# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005938 }
5939}
5940
5941/*
5942 * Set global value for string option when it's a local option.
5943 */
5944 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005945set_string_option_global(
5946 int opt_idx, /* option index */
5947 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005948{
5949 char_u **p, *s;
5950
5951 /* the global value is always allocated */
5952 if (options[opt_idx].var == VAR_WIN)
5953 p = (char_u **)GLOBAL_WO(varp);
5954 else
5955 p = (char_u **)options[opt_idx].var;
5956 if (options[opt_idx].indir != PV_NONE
5957 && p != varp
5958 && (s = vim_strsave(*varp)) != NULL)
5959 {
5960 free_string_option(*p);
5961 *p = s;
5962 }
5963}
5964
5965/*
5966 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005967 *
5968 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005969 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005970 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005971set_string_option(
5972 int opt_idx,
5973 char_u *value,
5974 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005975{
5976 char_u *s;
5977 char_u **varp;
5978 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005979#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5980 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005981 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005982#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005983 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005984
5985 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005986 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005987
5988 s = vim_strsave(value);
5989 if (s != NULL)
5990 {
5991 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5992 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005993 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005994 ? OPT_GLOBAL : OPT_LOCAL)
5995 : opt_flags);
5996 oldval = *varp;
5997 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005998
5999#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02006000 if (!starting
6001# ifdef FEAT_CRYPT
6002 && options[opt_idx].indir != PV_KEY
6003# endif
6004 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006005 {
Bram Moolenaar53744302015-07-17 17:38:22 +02006006 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006007 saved_newval = vim_strsave(s);
6008 }
Bram Moolenaar53744302015-07-17 17:38:22 +02006009#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006010 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
6011 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00006012 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02006013
Bram Moolenaar53744302015-07-17 17:38:22 +02006014#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006015 /* call autocommand after handling side effects */
6016 trigger_optionsset_string(opt_idx, opt_flags,
6017 saved_oldval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02006018#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006019 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006020 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006021}
6022
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006023#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006024/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006025 * Return TRUE if "val" is a valid 'filetype' name.
6026 * Also used for 'syntax' and 'keymap'.
6027 */
6028 static int
6029valid_filetype(char_u *val)
6030{
6031 char_u *s;
6032
6033 for (s = val; *s != NUL; ++s)
6034 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6035 return FALSE;
6036 return TRUE;
6037}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006038#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006039
6040/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006041 * Handle string options that need some action to perform when changed.
6042 * Returns NULL for success, or an error message for an error.
6043 */
6044 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006045did_set_string_option(
6046 int opt_idx, /* index in options[] table */
6047 char_u **varp, /* pointer to the option variable */
6048 int new_value_alloced, /* new value was allocated */
6049 char_u *oldval, /* previous value of the option */
6050 char_u *errbuf, /* buffer for errors, or NULL */
6051 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006052{
6053 char_u *errmsg = NULL;
6054 char_u *s, *p;
6055 int did_chartab = FALSE;
6056 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006057 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006058#ifdef FEAT_GUI
6059 /* set when changing an option that only requires a redraw in the GUI */
6060 int redraw_gui_only = FALSE;
6061#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006062#ifdef FEAT_AUTOCMD
6063 int ft_changed = FALSE;
6064#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006065
6066 /* Get the global option to compare with, otherwise we would have to check
6067 * two values for all local options. */
6068 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6069
6070 /* Disallow changing some options from secure mode */
6071 if ((secure
6072#ifdef HAVE_SANDBOX
6073 || sandbox != 0
6074#endif
6075 ) && (options[opt_idx].flags & P_SECURE))
6076 {
6077 errmsg = e_secure;
6078 }
6079
Bram Moolenaar7554da42016-11-25 22:04:13 +01006080 /* Check for a "normal" directory or file name in some options. Disallow a
6081 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006082 * are often illegal in a file name. Be more permissive if "secure" is off.
6083 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006084 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006085 && vim_strpbrk(*varp, (char_u *)(secure
6086 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006087 || ((options[opt_idx].flags & P_NDNAME)
6088 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006089 {
6090 errmsg = e_invarg;
6091 }
6092
Bram Moolenaar071d4272004-06-13 20:20:40 +00006093 /* 'term' */
6094 else if (varp == &T_NAME)
6095 {
6096 if (T_NAME[0] == NUL)
6097 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6098#ifdef FEAT_GUI
6099 if (gui.in_use)
6100 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6101 else if (term_is_gui(T_NAME))
6102 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6103#endif
6104 else if (set_termname(T_NAME) == FAIL)
6105 errmsg = (char_u *)N_("E522: Not found in termcap");
6106 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006107 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006108 /* Screen colors may have changed. */
6109 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006110
6111 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6112 * P_ALLOCED flag on 'term'. */
6113 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006114 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006115 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006116 }
6117
6118 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006119 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006120 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006121 char_u *bkc = p_bkc;
6122 unsigned int *flags = &bkc_flags;
6123
6124 if (opt_flags & OPT_LOCAL)
6125 {
6126 bkc = curbuf->b_p_bkc;
6127 flags = &curbuf->b_bkc_flags;
6128 }
6129
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006130 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6131 /* make the local value empty: use the global value */
6132 *flags = 0;
6133 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006134 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006135 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6136 errmsg = e_invarg;
6137 if ((((int)*flags & BKC_AUTO) != 0)
6138 + (((int)*flags & BKC_YES) != 0)
6139 + (((int)*flags & BKC_NO) != 0) != 1)
6140 {
6141 /* Must have exactly one of "auto", "yes" and "no". */
6142 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6143 errmsg = e_invarg;
6144 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006145 }
6146 }
6147
6148 /* 'backupext' and 'patchmode' */
6149 else if (varp == &p_bex || varp == &p_pm)
6150 {
6151 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6152 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6153 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6154 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006155#ifdef FEAT_LINEBREAK
6156 /* 'breakindentopt' */
6157 else if (varp == &curwin->w_p_briopt)
6158 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006159 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006160 errmsg = e_invarg;
6161 }
6162#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006163
6164 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006165 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006166 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006167 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006168 */
6169 else if ( varp == &p_isi
6170 || varp == &(curbuf->b_p_isk)
6171 || varp == &p_isp
6172 || varp == &p_isf)
6173 {
6174 if (init_chartab() == FAIL)
6175 {
6176 did_chartab = TRUE; /* need to restore it below */
6177 errmsg = e_invarg; /* error in value */
6178 }
6179 }
6180
6181 /* 'helpfile' */
6182 else if (varp == &p_hf)
6183 {
6184 /* May compute new values for $VIM and $VIMRUNTIME */
6185 if (didset_vim)
6186 {
6187 vim_setenv((char_u *)"VIM", (char_u *)"");
6188 didset_vim = FALSE;
6189 }
6190 if (didset_vimruntime)
6191 {
6192 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6193 didset_vimruntime = FALSE;
6194 }
6195 }
6196
Bram Moolenaar1a384422010-07-14 19:53:30 +02006197#ifdef FEAT_SYN_HL
6198 /* 'colorcolumn' */
6199 else if (varp == &curwin->w_p_cc)
6200 errmsg = check_colorcolumn(curwin);
6201#endif
6202
Bram Moolenaar071d4272004-06-13 20:20:40 +00006203#ifdef FEAT_MULTI_LANG
6204 /* 'helplang' */
6205 else if (varp == &p_hlg)
6206 {
6207 /* Check for "", "ab", "ab,cd", etc. */
6208 for (s = p_hlg; *s != NUL; s += 3)
6209 {
6210 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6211 {
6212 errmsg = e_invarg;
6213 break;
6214 }
6215 if (s[2] == NUL)
6216 break;
6217 }
6218 }
6219#endif
6220
6221 /* 'highlight' */
6222 else if (varp == &p_hl)
6223 {
6224 if (highlight_changed() == FAIL)
6225 errmsg = e_invarg; /* invalid flags */
6226 }
6227
6228 /* 'nrformats' */
6229 else if (gvarp == &p_nf)
6230 {
6231 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6232 errmsg = e_invarg;
6233 }
6234
6235#ifdef FEAT_SESSION
6236 /* 'sessionoptions' */
6237 else if (varp == &p_ssop)
6238 {
6239 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6240 errmsg = e_invarg;
6241 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6242 {
6243 /* Don't allow both "sesdir" and "curdir". */
6244 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6245 errmsg = e_invarg;
6246 }
6247 }
6248 /* 'viewoptions' */
6249 else if (varp == &p_vop)
6250 {
6251 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6252 errmsg = e_invarg;
6253 }
6254#endif
6255
6256 /* 'scrollopt' */
6257#ifdef FEAT_SCROLLBIND
6258 else if (varp == &p_sbo)
6259 {
6260 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6261 errmsg = e_invarg;
6262 }
6263#endif
6264
6265 /* 'ambiwidth' */
6266#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006267 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006268 {
6269 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6270 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006271 else if (set_chars_option(&p_lcs) != NULL)
6272 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6273# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6274 else if (set_chars_option(&p_fcs) != NULL)
6275 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6276# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006277 }
6278#endif
6279
6280 /* 'background' */
6281 else if (varp == &p_bg)
6282 {
6283 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6284 {
6285#ifdef FEAT_EVAL
6286 int dark = (*p_bg == 'd');
6287#endif
6288
6289 init_highlight(FALSE, FALSE);
6290
6291#ifdef FEAT_EVAL
6292 if (dark != (*p_bg == 'd')
6293 && get_var_value((char_u *)"g:colors_name") != NULL)
6294 {
6295 /* The color scheme must have set 'background' back to another
6296 * value, that's not what we want here. Disable the color
6297 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006298 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006299 free_string_option(p_bg);
6300 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6301 check_string_option(&p_bg);
6302 init_highlight(FALSE, FALSE);
6303 }
6304#endif
6305 }
6306 else
6307 errmsg = e_invarg;
6308 }
6309
6310 /* 'wildmode' */
6311 else if (varp == &p_wim)
6312 {
6313 if (check_opt_wim() == FAIL)
6314 errmsg = e_invarg;
6315 }
6316
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006317#ifdef FEAT_CMDL_COMPL
6318 /* 'wildoptions' */
6319 else if (varp == &p_wop)
6320 {
6321 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6322 errmsg = e_invarg;
6323 }
6324#endif
6325
Bram Moolenaar071d4272004-06-13 20:20:40 +00006326#ifdef FEAT_WAK
6327 /* 'winaltkeys' */
6328 else if (varp == &p_wak)
6329 {
6330 if (*p_wak == NUL
6331 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6332 errmsg = e_invarg;
6333# ifdef FEAT_MENU
6334# ifdef FEAT_GUI_MOTIF
6335 else if (gui.in_use)
6336 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6337# else
6338# ifdef FEAT_GUI_GTK
6339 else if (gui.in_use)
6340 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6341# endif
6342# endif
6343# endif
6344 }
6345#endif
6346
6347#ifdef FEAT_AUTOCMD
6348 /* 'eventignore' */
6349 else if (varp == &p_ei)
6350 {
6351 if (check_ei() == FAIL)
6352 errmsg = e_invarg;
6353 }
6354#endif
6355
6356#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006357 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6358 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6359 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006360 {
6361 if (gvarp == &p_fenc)
6362 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006363 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006364 errmsg = e_modifiable;
6365 else if (vim_strchr(*varp, ',') != NULL)
6366 /* No comma allowed in 'fileencoding'; catches confusing it
6367 * with 'fileencodings'. */
6368 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006369 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006370 {
6371# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006372 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006373 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006374# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006375 /* Add 'fileencoding' to the swap file. */
6376 ml_setflags(curbuf);
6377 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006378 }
6379 if (errmsg == NULL)
6380 {
6381 /* canonize the value, so that STRCMP() can be used on it */
6382 p = enc_canonize(*varp);
6383 if (p != NULL)
6384 {
6385 vim_free(*varp);
6386 *varp = p;
6387 }
6388 if (varp == &p_enc)
6389 {
6390 errmsg = mb_init();
6391# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006392 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006393# endif
6394 }
6395 }
6396
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006397# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006398 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6399 {
6400 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6401 if (STRCMP(p_tenc, "utf-8") != 0)
6402 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6403 }
6404# endif
6405
6406 if (errmsg == NULL)
6407 {
6408# ifdef FEAT_KEYMAP
6409 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6410 * (with another encoding). */
6411 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6412 (void)keymap_init();
6413# endif
6414
6415 /* When 'termencoding' is not empty and 'encoding' changes or when
6416 * 'termencoding' changes, need to setup for keyboard input and
6417 * display output conversion. */
6418 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6419 {
6420 convert_setup(&input_conv, p_tenc, p_enc);
6421 convert_setup(&output_conv, p_enc, p_tenc);
6422 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006423
6424# if defined(WIN3264) && defined(FEAT_MBYTE)
6425 /* $HOME may have characters in active code page. */
6426 if (varp == &p_enc)
6427 init_homedir();
6428# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006429 }
6430 }
6431#endif
6432
6433#if defined(FEAT_POSTSCRIPT)
6434 else if (varp == &p_penc)
6435 {
6436 /* Canonize printencoding if VIM standard one */
6437 p = enc_canonize(p_penc);
6438 if (p != NULL)
6439 {
6440 vim_free(p_penc);
6441 p_penc = p;
6442 }
6443 else
6444 {
6445 /* Ensure lower case and '-' for '_' */
6446 for (s = p_penc; *s != NUL; s++)
6447 {
6448 if (*s == '_')
6449 *s = '-';
6450 else
6451 *s = TOLOWER_ASC(*s);
6452 }
6453 }
6454 }
6455#endif
6456
Bram Moolenaar9372a112005-12-06 19:59:18 +00006457#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006458 else if (varp == &p_imak)
6459 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006460 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006461 errmsg = e_invarg;
6462 }
6463#endif
6464
6465#ifdef FEAT_KEYMAP
6466 else if (varp == &curbuf->b_p_keymap)
6467 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006468 if (!valid_filetype(*varp))
6469 errmsg = e_invarg;
6470 else
6471 /* load or unload key mapping tables */
6472 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006473
Bram Moolenaarfab06232009-03-04 03:13:35 +00006474 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006475 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006476 if (*curbuf->b_p_keymap != NUL)
6477 {
6478 /* Installed a new keymap, switch on using it. */
6479 curbuf->b_p_iminsert = B_IMODE_LMAP;
6480 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6481 curbuf->b_p_imsearch = B_IMODE_LMAP;
6482 }
6483 else
6484 {
6485 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6486 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6487 curbuf->b_p_iminsert = B_IMODE_NONE;
6488 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6489 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6490 }
6491 if ((opt_flags & OPT_LOCAL) == 0)
6492 {
6493 set_iminsert_global();
6494 set_imsearch_global();
6495 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006496# ifdef FEAT_WINDOWS
6497 status_redraw_curbuf();
6498# endif
6499 }
6500 }
6501#endif
6502
6503 /* 'fileformat' */
6504 else if (gvarp == &p_ff)
6505 {
6506 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6507 errmsg = e_modifiable;
6508 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6509 errmsg = e_invarg;
6510 else
6511 {
6512 /* may also change 'textmode' */
6513 if (get_fileformat(curbuf) == EOL_DOS)
6514 curbuf->b_p_tx = TRUE;
6515 else
6516 curbuf->b_p_tx = FALSE;
6517#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006518 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006519#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006520 /* update flag in swap file */
6521 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006522 /* Redraw needed when switching to/from "mac": a CR in the text
6523 * will be displayed differently. */
6524 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6525 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006526 }
6527 }
6528
6529 /* 'fileformats' */
6530 else if (varp == &p_ffs)
6531 {
6532 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6533 errmsg = e_invarg;
6534 else
6535 {
6536 /* also change 'textauto' */
6537 if (*p_ffs == NUL)
6538 p_ta = FALSE;
6539 else
6540 p_ta = TRUE;
6541 }
6542 }
6543
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006544#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006545 /* 'cryptkey' */
6546 else if (gvarp == &p_key)
6547 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006548# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006549 /* Make sure the ":set" command doesn't show the new value in the
6550 * history. */
6551 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006552# endif
6553 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6554 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006555 ml_set_crypt_key(curbuf, oldval,
6556 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006557 }
6558
6559 else if (gvarp == &p_cm)
6560 {
6561 if (opt_flags & OPT_LOCAL)
6562 p = curbuf->b_p_cm;
6563 else
6564 p = p_cm;
6565 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6566 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006567 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006568 errmsg = e_invarg;
6569 else
6570 {
6571 /* When setting the global value to empty, make it "zip". */
6572 if (*p_cm == NUL)
6573 {
6574 if (new_value_alloced)
6575 free_string_option(p_cm);
6576 p_cm = vim_strsave((char_u *)"zip");
6577 new_value_alloced = TRUE;
6578 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006579 /* When using ":set cm=name" the local value is going to be empty.
6580 * Do that here, otherwise the crypt functions will still use the
6581 * local value. */
6582 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6583 {
6584 free_string_option(curbuf->b_p_cm);
6585 curbuf->b_p_cm = empty_option;
6586 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006587
6588 /* Need to update the swapfile when the effective method changed.
6589 * Set "s" to the effective old value, "p" to the effective new
6590 * method and compare. */
6591 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6592 s = p_cm; /* was previously using the global value */
6593 else
6594 s = oldval;
6595 if (*curbuf->b_p_cm == NUL)
6596 p = p_cm; /* is now using the global value */
6597 else
6598 p = curbuf->b_p_cm;
6599 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006600 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006601
6602 /* If the global value changes need to update the swapfile for all
6603 * buffers using that value. */
6604 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6605 {
6606 buf_T *buf;
6607
Bram Moolenaar29323592016-07-24 22:04:11 +02006608 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006609 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006610 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006611 }
6612 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006613 }
6614#endif
6615
6616 /* 'matchpairs' */
6617 else if (gvarp == &p_mps)
6618 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006619#ifdef FEAT_MBYTE
6620 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006621 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006622 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006623 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006624 int x2 = -1;
6625 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006626
6627 if (*p != NUL)
6628 p += mb_ptr2len(p);
6629 if (*p != NUL)
6630 x2 = *p++;
6631 if (*p != NUL)
6632 {
6633 x3 = mb_ptr2char(p);
6634 p += mb_ptr2len(p);
6635 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006636 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006637 {
6638 errmsg = e_invarg;
6639 break;
6640 }
6641 if (*p == NUL)
6642 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006643 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006644 }
6645 else
6646#endif
6647 {
6648 /* Check for "x:y,x:y" */
6649 for (p = *varp; *p != NUL; p += 4)
6650 {
6651 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6652 {
6653 errmsg = e_invarg;
6654 break;
6655 }
6656 if (p[3] == NUL)
6657 break;
6658 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006659 }
6660 }
6661
6662#ifdef FEAT_COMMENTS
6663 /* 'comments' */
6664 else if (gvarp == &p_com)
6665 {
6666 for (s = *varp; *s; )
6667 {
6668 while (*s && *s != ':')
6669 {
6670 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6671 && !VIM_ISDIGIT(*s) && *s != '-')
6672 {
6673 errmsg = illegal_char(errbuf, *s);
6674 break;
6675 }
6676 ++s;
6677 }
6678 if (*s++ == NUL)
6679 errmsg = (char_u *)N_("E524: Missing colon");
6680 else if (*s == ',' || *s == NUL)
6681 errmsg = (char_u *)N_("E525: Zero length string");
6682 if (errmsg != NULL)
6683 break;
6684 while (*s && *s != ',')
6685 {
6686 if (*s == '\\' && s[1] != NUL)
6687 ++s;
6688 ++s;
6689 }
6690 s = skip_to_option_part(s);
6691 }
6692 }
6693#endif
6694
6695 /* 'listchars' */
6696 else if (varp == &p_lcs)
6697 {
6698 errmsg = set_chars_option(varp);
6699 }
6700
6701#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6702 /* 'fillchars' */
6703 else if (varp == &p_fcs)
6704 {
6705 errmsg = set_chars_option(varp);
6706 }
6707#endif
6708
6709#ifdef FEAT_CMDWIN
6710 /* 'cedit' */
6711 else if (varp == &p_cedit)
6712 {
6713 errmsg = check_cedit();
6714 }
6715#endif
6716
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006717 /* 'verbosefile' */
6718 else if (varp == &p_vfile)
6719 {
6720 verbose_stop();
6721 if (*p_vfile != NUL && verbose_open() == FAIL)
6722 errmsg = e_invarg;
6723 }
6724
Bram Moolenaar071d4272004-06-13 20:20:40 +00006725#ifdef FEAT_VIMINFO
6726 /* 'viminfo' */
6727 else if (varp == &p_viminfo)
6728 {
6729 for (s = p_viminfo; *s;)
6730 {
6731 /* Check it's a valid character */
6732 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6733 {
6734 errmsg = illegal_char(errbuf, *s);
6735 break;
6736 }
6737 if (*s == 'n') /* name is always last one */
6738 {
6739 break;
6740 }
6741 else if (*s == 'r') /* skip until next ',' */
6742 {
6743 while (*++s && *s != ',')
6744 ;
6745 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006746 else if (*s == '%')
6747 {
6748 /* optional number */
6749 while (vim_isdigit(*++s))
6750 ;
6751 }
6752 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006753 ++s; /* no extra chars */
6754 else /* must have a number */
6755 {
6756 while (vim_isdigit(*++s))
6757 ;
6758
6759 if (!VIM_ISDIGIT(*(s - 1)))
6760 {
6761 if (errbuf != NULL)
6762 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006763 sprintf((char *)errbuf,
6764 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006765 transchar_byte(*(s - 1)));
6766 errmsg = errbuf;
6767 }
6768 else
6769 errmsg = (char_u *)"";
6770 break;
6771 }
6772 }
6773 if (*s == ',')
6774 ++s;
6775 else if (*s)
6776 {
6777 if (errbuf != NULL)
6778 errmsg = (char_u *)N_("E527: Missing comma");
6779 else
6780 errmsg = (char_u *)"";
6781 break;
6782 }
6783 }
6784 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6785 errmsg = (char_u *)N_("E528: Must specify a ' value");
6786 }
6787#endif /* FEAT_VIMINFO */
6788
6789 /* terminal options */
6790 else if (istermoption(&options[opt_idx]) && full_screen)
6791 {
6792 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6793 if (varp == &T_CCO)
6794 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006795 int colors = atoi((char *)T_CCO);
6796
6797 /* Only reinitialize colors if t_Co value has really changed to
6798 * avoid expensive reload of colorscheme if t_Co is set to the
6799 * same value multiple times. */
6800 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006801 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006802 t_colors = colors;
6803 if (t_colors <= 1)
6804 {
6805 if (new_value_alloced)
6806 vim_free(T_CCO);
6807 T_CCO = empty_option;
6808 }
6809 /* We now have a different color setup, initialize it again. */
6810 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006811 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006812 }
6813 ttest(FALSE);
6814 if (varp == &T_ME)
6815 {
6816 out_str(T_ME);
6817 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006818#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006819 /* Since t_me has been set, this probably means that the user
6820 * wants to use this as default colors. Need to reset default
6821 * background/foreground colors. */
6822 mch_set_normal_colors();
6823#endif
6824 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006825 if (varp == &T_BE && termcap_active)
6826 {
6827 if (*T_BE == NUL)
6828 /* When clearing t_BE we assume the user no longer wants
6829 * bracketed paste, thus disable it by writing t_BD. */
6830 out_str(T_BD);
6831 else
6832 out_str(T_BE);
6833 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006834 }
6835
6836#ifdef FEAT_LINEBREAK
6837 /* 'showbreak' */
6838 else if (varp == &p_sbr)
6839 {
6840 for (s = p_sbr; *s; )
6841 {
6842 if (ptr2cells(s) != 1)
6843 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006844 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006845 }
6846 }
6847#endif
6848
6849#ifdef FEAT_GUI
6850 /* 'guifont' */
6851 else if (varp == &p_guifont)
6852 {
6853 if (gui.in_use)
6854 {
6855 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006856# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006857 /*
6858 * Put up a font dialog and let the user select a new value.
6859 * If this is cancelled go back to the old value but don't
6860 * give an error message.
6861 */
6862 if (STRCMP(p, "*") == 0)
6863 {
6864 p = gui_mch_font_dialog(oldval);
6865
6866 if (new_value_alloced)
6867 free_string_option(p_guifont);
6868
6869 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6870 new_value_alloced = TRUE;
6871 }
6872# endif
6873 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6874 {
6875# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6876 if (STRCMP(p_guifont, "*") == 0)
6877 {
6878 /* Dialog was cancelled: Keep the old value without giving
6879 * an error message. */
6880 if (new_value_alloced)
6881 free_string_option(p_guifont);
6882 p_guifont = vim_strsave(oldval);
6883 new_value_alloced = TRUE;
6884 }
6885 else
6886# endif
6887 errmsg = (char_u *)N_("E596: Invalid font(s)");
6888 }
6889 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006890 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006891 }
6892# ifdef FEAT_XFONTSET
6893 else if (varp == &p_guifontset)
6894 {
6895 if (STRCMP(p_guifontset, "*") == 0)
6896 errmsg = (char_u *)N_("E597: can't select fontset");
6897 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6898 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006899 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006900 }
6901# endif
6902# ifdef FEAT_MBYTE
6903 else if (varp == &p_guifontwide)
6904 {
6905 if (STRCMP(p_guifontwide, "*") == 0)
6906 errmsg = (char_u *)N_("E533: can't select wide font");
6907 else if (gui_get_wide_font() == FAIL)
6908 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006909 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006910 }
6911# endif
6912#endif
6913
6914#ifdef CURSOR_SHAPE
6915 /* 'guicursor' */
6916 else if (varp == &p_guicursor)
6917 errmsg = parse_shape_opt(SHAPE_CURSOR);
6918#endif
6919
6920#ifdef FEAT_MOUSESHAPE
6921 /* 'mouseshape' */
6922 else if (varp == &p_mouseshape)
6923 {
6924 errmsg = parse_shape_opt(SHAPE_MOUSE);
6925 update_mouseshape(-1);
6926 }
6927#endif
6928
6929#ifdef FEAT_PRINTER
6930 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006931 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006932# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006933 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006934 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006935# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006936#endif
6937
6938#ifdef FEAT_LANGMAP
6939 /* 'langmap' */
6940 else if (varp == &p_langmap)
6941 langmap_set();
6942#endif
6943
6944#ifdef FEAT_LINEBREAK
6945 /* 'breakat' */
6946 else if (varp == &p_breakat)
6947 fill_breakat_flags();
6948#endif
6949
6950#ifdef FEAT_TITLE
6951 /* 'titlestring' and 'iconstring' */
6952 else if (varp == &p_titlestring || varp == &p_iconstring)
6953 {
6954# ifdef FEAT_STL_OPT
6955 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6956
6957 /* NULL => statusline syntax */
6958 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6959 stl_syntax |= flagval;
6960 else
6961 stl_syntax &= ~flagval;
6962# endif
6963 did_set_title(varp == &p_iconstring);
6964
6965 }
6966#endif
6967
6968#ifdef FEAT_GUI
6969 /* 'guioptions' */
6970 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006971 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006972 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006973 redraw_gui_only = TRUE;
6974 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006975#endif
6976
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006977#if defined(FEAT_GUI_TABLINE)
6978 /* 'guitablabel' */
6979 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006980 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006981 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006982 redraw_gui_only = TRUE;
6983 }
6984 /* 'guitabtooltip' */
6985 else if (varp == &p_gtt)
6986 {
6987 redraw_gui_only = TRUE;
6988 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006989#endif
6990
Bram Moolenaar071d4272004-06-13 20:20:40 +00006991#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6992 /* 'ttymouse' */
6993 else if (varp == &p_ttym)
6994 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006995 /* Switch the mouse off before changing the escape sequences used for
6996 * that. */
6997 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006998 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6999 errmsg = e_invarg;
7000 else
7001 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00007002 if (termcap_active)
7003 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007004 }
7005#endif
7006
Bram Moolenaar071d4272004-06-13 20:20:40 +00007007 /* 'selection' */
7008 else if (varp == &p_sel)
7009 {
7010 if (*p_sel == NUL
7011 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
7012 errmsg = e_invarg;
7013 }
7014
7015 /* 'selectmode' */
7016 else if (varp == &p_slm)
7017 {
7018 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
7019 errmsg = e_invarg;
7020 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007021
7022#ifdef FEAT_BROWSE
7023 /* 'browsedir' */
7024 else if (varp == &p_bsdir)
7025 {
7026 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7027 && !mch_isdir(p_bsdir))
7028 errmsg = e_invarg;
7029 }
7030#endif
7031
Bram Moolenaar071d4272004-06-13 20:20:40 +00007032 /* 'keymodel' */
7033 else if (varp == &p_km)
7034 {
7035 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7036 errmsg = e_invarg;
7037 else
7038 {
7039 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7040 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7041 }
7042 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007043
7044 /* 'mousemodel' */
7045 else if (varp == &p_mousem)
7046 {
7047 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7048 errmsg = e_invarg;
7049#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7050 else if (*p_mousem != *oldval)
7051 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7052 * to create or delete the popup menus. */
7053 gui_motif_update_mousemodel(root_menu);
7054#endif
7055 }
7056
7057 /* 'switchbuf' */
7058 else if (varp == &p_swb)
7059 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007060 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007061 errmsg = e_invarg;
7062 }
7063
7064 /* 'debug' */
7065 else if (varp == &p_debug)
7066 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007067 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007068 errmsg = e_invarg;
7069 }
7070
7071 /* 'display' */
7072 else if (varp == &p_dy)
7073 {
7074 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7075 errmsg = e_invarg;
7076 else
7077 (void)init_chartab();
7078
7079 }
7080
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007081#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007082 /* 'eadirection' */
7083 else if (varp == &p_ead)
7084 {
7085 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7086 errmsg = e_invarg;
7087 }
7088#endif
7089
7090#ifdef FEAT_CLIPBOARD
7091 /* 'clipboard' */
7092 else if (varp == &p_cb)
7093 errmsg = check_clipboard_option();
7094#endif
7095
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007096#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007097 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7098 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007099 else if (varp == &(curwin->w_s->b_p_spl)
7100 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007101 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007102 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007103 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007104 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007105 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007106 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007107 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007108 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007109 /* 'spellsuggest' */
7110 else if (varp == &p_sps)
7111 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007112 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007113 errmsg = e_invarg;
7114 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007115 /* 'mkspellmem' */
7116 else if (varp == &p_msm)
7117 {
7118 if (spell_check_msm() != OK)
7119 errmsg = e_invarg;
7120 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007121#endif
7122
Bram Moolenaar071d4272004-06-13 20:20:40 +00007123 /* When 'bufhidden' is set, check for valid value. */
7124 else if (gvarp == &p_bh)
7125 {
7126 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7127 errmsg = e_invarg;
7128 }
7129
7130 /* When 'buftype' is set, check for valid value. */
7131 else if (gvarp == &p_bt)
7132 {
7133 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7134 errmsg = e_invarg;
7135 else
7136 {
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007137#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007138 if (curwin->w_status_height)
7139 {
7140 curwin->w_redr_status = TRUE;
7141 redraw_later(VALID);
7142 }
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007143#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007144 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007145#ifdef FEAT_TITLE
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007146 redraw_titles();
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007147#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007148 }
7149 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007150
7151#ifdef FEAT_STL_OPT
7152 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007153 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007154 {
7155 int wid;
7156
7157 if (varp == &p_ruf) /* reset ru_wid first */
7158 ru_wid = 0;
7159 s = *varp;
7160 if (varp == &p_ruf && *s == '%')
7161 {
7162 /* set ru_wid if 'ruf' starts with "%99(" */
7163 if (*++s == '-') /* ignore a '-' */
7164 s++;
7165 wid = getdigits(&s);
7166 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7167 ru_wid = wid;
7168 else
7169 errmsg = check_stl_option(p_ruf);
7170 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007171 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007172 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007173 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007174 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007175 comp_col();
7176 }
7177#endif
7178
7179#ifdef FEAT_INS_EXPAND
7180 /* check if it is a valid value for 'complete' -- Acevedo */
7181 else if (gvarp == &p_cpt)
7182 {
7183 for (s = *varp; *s;)
7184 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007185 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007186 s++;
7187 if (!*s)
7188 break;
7189 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7190 {
7191 errmsg = illegal_char(errbuf, *s);
7192 break;
7193 }
7194 if (*++s != NUL && *s != ',' && *s != ' ')
7195 {
7196 if (s[-1] == 'k' || s[-1] == 's')
7197 {
7198 /* skip optional filename after 'k' and 's' */
7199 while (*s && *s != ',' && *s != ' ')
7200 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007201 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007202 ++s;
7203 ++s;
7204 }
7205 }
7206 else
7207 {
7208 if (errbuf != NULL)
7209 {
7210 sprintf((char *)errbuf,
7211 _("E535: Illegal character after <%c>"),
7212 *--s);
7213 errmsg = errbuf;
7214 }
7215 else
7216 errmsg = (char_u *)"";
7217 break;
7218 }
7219 }
7220 }
7221 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007222
7223 /* 'completeopt' */
7224 else if (varp == &p_cot)
7225 {
7226 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7227 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007228 else
7229 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007230 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007231#endif /* FEAT_INS_EXPAND */
7232
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007233#ifdef FEAT_SIGNS
7234 /* 'signcolumn' */
7235 else if (varp == &curwin->w_p_scl)
7236 {
7237 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7238 errmsg = e_invarg;
7239 }
7240#endif
7241
Bram Moolenaar071d4272004-06-13 20:20:40 +00007242
7243#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007244 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007245 else if (varp == &p_toolbar)
7246 {
7247 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7248 &toolbar_flags, TRUE) != OK)
7249 errmsg = e_invarg;
7250 else
7251 {
7252 out_flush();
7253 gui_mch_show_toolbar((toolbar_flags &
7254 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7255 }
7256 }
7257#endif
7258
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007259#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007260 /* 'toolbariconsize': GTK+ 2 only */
7261 else if (varp == &p_tbis)
7262 {
7263 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7264 errmsg = e_invarg;
7265 else
7266 {
7267 out_flush();
7268 gui_mch_show_toolbar((toolbar_flags &
7269 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7270 }
7271 }
7272#endif
7273
7274 /* 'pastetoggle': translate key codes like in a mapping */
7275 else if (varp == &p_pt)
7276 {
7277 if (*p_pt)
7278 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007279 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007280 if (p != NULL)
7281 {
7282 if (new_value_alloced)
7283 free_string_option(p_pt);
7284 p_pt = p;
7285 new_value_alloced = TRUE;
7286 }
7287 }
7288 }
7289
7290 /* 'backspace' */
7291 else if (varp == &p_bs)
7292 {
7293 if (VIM_ISDIGIT(*p_bs))
7294 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007295 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007296 errmsg = e_invarg;
7297 }
7298 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7299 errmsg = e_invarg;
7300 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007301 else if (varp == &p_bo)
7302 {
7303 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7304 errmsg = e_invarg;
7305 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007306
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007307 /* 'tagcase' */
7308 else if (gvarp == &p_tc)
7309 {
7310 unsigned int *flags;
7311
7312 if (opt_flags & OPT_LOCAL)
7313 {
7314 p = curbuf->b_p_tc;
7315 flags = &curbuf->b_tc_flags;
7316 }
7317 else
7318 {
7319 p = p_tc;
7320 flags = &tc_flags;
7321 }
7322
7323 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7324 /* make the local value empty: use the global value */
7325 *flags = 0;
7326 else if (*p == NUL
7327 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7328 errmsg = e_invarg;
7329 }
7330
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007331#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007332 /* 'casemap' */
7333 else if (varp == &p_cmp)
7334 {
7335 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7336 errmsg = e_invarg;
7337 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007338#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007339
7340#ifdef FEAT_DIFF
7341 /* 'diffopt' */
7342 else if (varp == &p_dip)
7343 {
7344 if (diffopt_changed() == FAIL)
7345 errmsg = e_invarg;
7346 }
7347#endif
7348
7349#ifdef FEAT_FOLDING
7350 /* 'foldmethod' */
7351 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7352 {
7353 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7354 || *curwin->w_p_fdm == NUL)
7355 errmsg = e_invarg;
7356 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007357 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007358 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007359 if (foldmethodIsDiff(curwin))
7360 newFoldLevel();
7361 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007362 }
7363# ifdef FEAT_EVAL
7364 /* 'foldexpr' */
7365 else if (varp == &curwin->w_p_fde)
7366 {
7367 if (foldmethodIsExpr(curwin))
7368 foldUpdateAll(curwin);
7369 }
7370# endif
7371 /* 'foldmarker' */
7372 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7373 {
7374 p = vim_strchr(*varp, ',');
7375 if (p == NULL)
7376 errmsg = (char_u *)N_("E536: comma required");
7377 else if (p == *varp || p[1] == NUL)
7378 errmsg = e_invarg;
7379 else if (foldmethodIsMarker(curwin))
7380 foldUpdateAll(curwin);
7381 }
7382 /* 'commentstring' */
7383 else if (gvarp == &p_cms)
7384 {
7385 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7386 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7387 }
7388 /* 'foldopen' */
7389 else if (varp == &p_fdo)
7390 {
7391 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7392 errmsg = e_invarg;
7393 }
7394 /* 'foldclose' */
7395 else if (varp == &p_fcl)
7396 {
7397 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7398 errmsg = e_invarg;
7399 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007400 /* 'foldignore' */
7401 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7402 {
7403 if (foldmethodIsIndent(curwin))
7404 foldUpdateAll(curwin);
7405 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007406#endif
7407
7408#ifdef FEAT_VIRTUALEDIT
7409 /* 'virtualedit' */
7410 else if (varp == &p_ve)
7411 {
7412 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7413 errmsg = e_invarg;
7414 else if (STRCMP(p_ve, oldval) != 0)
7415 {
7416 /* Recompute cursor position in case the new 've' setting
7417 * changes something. */
7418 validate_virtcol();
7419 coladvance(curwin->w_virtcol);
7420 }
7421 }
7422#endif
7423
7424#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7425 else if (varp == &p_csqf)
7426 {
7427 if (p_csqf != NULL)
7428 {
7429 p = p_csqf;
7430 while (*p != NUL)
7431 {
7432 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7433 || p[1] == NUL
7434 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7435 || (p[2] != NUL && p[2] != ','))
7436 {
7437 errmsg = e_invarg;
7438 break;
7439 }
7440 else if (p[2] == NUL)
7441 break;
7442 else
7443 p += 3;
7444 }
7445 }
7446 }
7447#endif
7448
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007449#ifdef FEAT_CINDENT
7450 /* 'cinoptions' */
7451 else if (gvarp == &p_cino)
7452 {
7453 /* TODO: recognize errors */
7454 parse_cino(curbuf);
7455 }
7456#endif
7457
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007458#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007459 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007460 else if (varp == &p_rop && gui.in_use)
7461 {
7462 if (!gui_mch_set_rendering_options(p_rop))
7463 errmsg = e_invarg;
7464 }
7465#endif
7466
Bram Moolenaard0b51382016-11-04 15:23:45 +01007467#ifdef FEAT_AUTOCMD
7468 else if (gvarp == &p_ft)
7469 {
7470 if (!valid_filetype(*varp))
7471 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007472 else
7473 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007474 }
7475#endif
7476
7477#ifdef FEAT_SYN_HL
7478 else if (gvarp == &p_syn)
7479 {
7480 if (!valid_filetype(*varp))
7481 errmsg = e_invarg;
7482 }
7483#endif
7484
Bram Moolenaar825680f2017-07-22 17:04:02 +02007485#ifdef FEAT_TERMINAL
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007486 /* 'termkey' */
Bram Moolenaarc4f43bc2017-07-24 20:03:01 +02007487 else if (varp == &curwin->w_p_tk)
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007488 {
7489 if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
7490 errmsg = e_invarg;
7491 }
Bram Moolenaar825680f2017-07-22 17:04:02 +02007492 /* 'termsize' */
7493 else if (varp == &curwin->w_p_tms)
7494 {
7495 if (*curwin->w_p_tms != NUL)
7496 {
7497 p = skipdigits(curwin->w_p_tms);
7498 if (p == curwin->w_p_tms || *p != 'x' || *skipdigits(p + 1) != NUL)
7499 errmsg = e_invarg;
7500 }
7501 }
7502#endif
7503
Bram Moolenaar071d4272004-06-13 20:20:40 +00007504 /* Options that are a list of flags. */
7505 else
7506 {
7507 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007508 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007509 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007510 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007511 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007512 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007513 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007514 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007515 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007516#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007517 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007518 p = (char_u *)COCU_ALL;
7519#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007520 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007521 {
7522#ifdef FEAT_MOUSE
7523 p = (char_u *)MOUSE_ALL;
7524#else
7525 if (*p_mouse != NUL)
7526 errmsg = (char_u *)N_("E538: No mouse support");
7527#endif
7528 }
7529#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007530 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007531 p = (char_u *)GO_ALL;
7532#endif
7533 if (p != NULL)
7534 {
7535 for (s = *varp; *s; ++s)
7536 if (vim_strchr(p, *s) == NULL)
7537 {
7538 errmsg = illegal_char(errbuf, *s);
7539 break;
7540 }
7541 }
7542 }
7543
7544 /*
7545 * If error detected, restore the previous value.
7546 */
7547 if (errmsg != NULL)
7548 {
7549 if (new_value_alloced)
7550 free_string_option(*varp);
7551 *varp = oldval;
7552 /*
7553 * When resetting some values, need to act on it.
7554 */
7555 if (did_chartab)
7556 (void)init_chartab();
7557 if (varp == &p_hl)
7558 (void)highlight_changed();
7559 }
7560 else
7561 {
7562#ifdef FEAT_EVAL
7563 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007564 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007565#endif
7566 /*
7567 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007568 * Use "free_oldval", because recursiveness may change the flags under
7569 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007570 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007571 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007572 free_string_option(oldval);
7573 if (new_value_alloced)
7574 options[opt_idx].flags |= P_ALLOCED;
7575 else
7576 options[opt_idx].flags &= ~P_ALLOCED;
7577
7578 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007579 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007580 {
7581 /* global option with local value set to use global value; free
7582 * the local value and make it empty */
7583 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7584 free_string_option(*(char_u **)p);
7585 *(char_u **)p = empty_option;
7586 }
7587
7588 /* May set global value for local option. */
7589 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7590 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007591
7592#ifdef FEAT_AUTOCMD
7593 /*
7594 * Trigger the autocommand only after setting the flags.
7595 */
7596# ifdef FEAT_SYN_HL
7597 /* When 'syntax' is set, load the syntax of that name */
7598 if (varp == &(curbuf->b_p_syn))
7599 {
7600 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7601 curbuf->b_fname, TRUE, curbuf);
7602 }
7603# endif
7604 else if (varp == &(curbuf->b_p_ft))
7605 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007606 /* 'filetype' is set, trigger the FileType autocommand.
7607 * Skip this when called from a modeline and the filetype was
7608 * already set to this value. */
7609 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7610 {
7611 did_filetype = TRUE;
7612 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007613 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar163095f2017-07-09 15:41:53 +02007614 /* Just in case the old "curbuf" is now invalid. */
7615 if (varp != &(curbuf->b_p_ft))
7616 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007617 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007618 }
7619#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007620#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007621 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007622 {
7623 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007624 char_u *q = curwin->w_s->b_p_spl;
7625
7626 /* Skip the first name if it is "cjk". */
7627 if (STRNCMP(q, "cjk,", 4) == 0)
7628 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007629
7630 /*
7631 * Source the spell/LANG.vim in 'runtimepath'.
7632 * They could set 'spellcapcheck' depending on the language.
7633 * Use the first name in 'spelllang' up to '_region' or
7634 * '.encoding'.
7635 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007636 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007637 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7638 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007639 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007640 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007641 }
7642#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007643 }
7644
7645#ifdef FEAT_MOUSE
7646 if (varp == &p_mouse)
7647 {
7648# ifdef FEAT_MOUSE_TTY
7649 if (*p_mouse == NUL)
7650 mch_setmouse(FALSE); /* switch mouse off */
7651 else
7652# endif
7653 setmouse(); /* in case 'mouse' changed */
7654 }
7655#endif
7656
Bram Moolenaar913077c2012-03-28 19:59:04 +02007657 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007658 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007659 curwin->w_set_curswant = TRUE;
7660
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007661#ifdef FEAT_GUI
7662 /* check redraw when it's not a GUI option or the GUI is active. */
7663 if (!redraw_gui_only || gui.in_use)
7664#endif
7665 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007666
7667 return errmsg;
7668}
7669
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007670#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007671/*
7672 * Simple int comparison function for use with qsort()
7673 */
7674 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007675int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007676{
7677 return *(const int *)a - *(const int *)b;
7678}
7679
7680/*
7681 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7682 * Returns error message, NULL if it's OK.
7683 */
7684 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007685check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007686{
7687 char_u *s;
7688 int col;
7689 int count = 0;
7690 int color_cols[256];
7691 int i;
7692 int j = 0;
7693
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007694 if (wp->w_buffer == NULL)
7695 return NULL; /* buffer was closed */
7696
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007697 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007698 {
7699 if (*s == '-' || *s == '+')
7700 {
7701 /* -N and +N: add to 'textwidth' */
7702 col = (*s == '-') ? -1 : 1;
7703 ++s;
7704 if (!VIM_ISDIGIT(*s))
7705 return e_invarg;
7706 col = col * getdigits(&s);
7707 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007708 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007709 col += wp->w_buffer->b_p_tw;
7710 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007711 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007712 }
7713 else if (VIM_ISDIGIT(*s))
7714 col = getdigits(&s);
7715 else
7716 return e_invarg;
7717 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007718skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007719 if (*s == NUL)
7720 break;
7721 if (*s != ',')
7722 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007723 if (*++s == NUL)
7724 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007725 }
7726
7727 vim_free(wp->w_p_cc_cols);
7728 if (count == 0)
7729 wp->w_p_cc_cols = NULL;
7730 else
7731 {
7732 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7733 if (wp->w_p_cc_cols != NULL)
7734 {
7735 /* sort the columns for faster usage on screen redraw inside
7736 * win_line() */
7737 qsort(color_cols, count, sizeof(int), int_cmp);
7738
7739 for (i = 0; i < count; ++i)
7740 /* skip duplicates */
7741 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7742 wp->w_p_cc_cols[j++] = color_cols[i];
7743 wp->w_p_cc_cols[j] = -1; /* end marker */
7744 }
7745 }
7746
7747 return NULL; /* no error */
7748}
7749#endif
7750
Bram Moolenaar071d4272004-06-13 20:20:40 +00007751/*
7752 * Handle setting 'listchars' or 'fillchars'.
7753 * Returns error message, NULL if it's OK.
7754 */
7755 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007756set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007757{
7758 int round, i, len, entries;
7759 char_u *p, *s;
7760 int c1, c2 = 0;
7761 struct charstab
7762 {
7763 int *cp;
7764 char *name;
7765 };
7766#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7767 static struct charstab filltab[] =
7768 {
7769 {&fill_stl, "stl"},
7770 {&fill_stlnc, "stlnc"},
7771 {&fill_vert, "vert"},
7772 {&fill_fold, "fold"},
7773 {&fill_diff, "diff"},
7774 };
7775#endif
7776 static struct charstab lcstab[] =
7777 {
7778 {&lcs_eol, "eol"},
7779 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007780 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007781 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007782 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007783 {&lcs_tab2, "tab"},
7784 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007785#ifdef FEAT_CONCEAL
7786 {&lcs_conceal, "conceal"},
7787#else
7788 {NULL, "conceal"},
7789#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007790 };
7791 struct charstab *tab;
7792
7793#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7794 if (varp == &p_lcs)
7795#endif
7796 {
7797 tab = lcstab;
7798 entries = sizeof(lcstab) / sizeof(struct charstab);
7799 }
7800#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7801 else
7802 {
7803 tab = filltab;
7804 entries = sizeof(filltab) / sizeof(struct charstab);
7805 }
7806#endif
7807
7808 /* first round: check for valid value, second round: assign values */
7809 for (round = 0; round <= 1; ++round)
7810 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007811 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007812 {
7813 /* After checking that the value is valid: set defaults: space for
7814 * 'fillchars', NUL for 'listchars' */
7815 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007816 if (tab[i].cp != NULL)
7817 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818 if (varp == &p_lcs)
7819 lcs_tab1 = NUL;
7820#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7821 else
7822 fill_diff = '-';
7823#endif
7824 }
7825 p = *varp;
7826 while (*p)
7827 {
7828 for (i = 0; i < entries; ++i)
7829 {
7830 len = (int)STRLEN(tab[i].name);
7831 if (STRNCMP(p, tab[i].name, len) == 0
7832 && p[len] == ':'
7833 && p[len + 1] != NUL)
7834 {
7835 s = p + len + 1;
7836#ifdef FEAT_MBYTE
7837 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007838 if (mb_char2cells(c1) > 1)
7839 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007840#else
7841 c1 = *s++;
7842#endif
7843 if (tab[i].cp == &lcs_tab2)
7844 {
7845 if (*s == NUL)
7846 continue;
7847#ifdef FEAT_MBYTE
7848 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007849 if (mb_char2cells(c2) > 1)
7850 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007851#else
7852 c2 = *s++;
7853#endif
7854 }
7855 if (*s == ',' || *s == NUL)
7856 {
7857 if (round)
7858 {
7859 if (tab[i].cp == &lcs_tab2)
7860 {
7861 lcs_tab1 = c1;
7862 lcs_tab2 = c2;
7863 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007864 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007865 *(tab[i].cp) = c1;
7866
7867 }
7868 p = s;
7869 break;
7870 }
7871 }
7872 }
7873
7874 if (i == entries)
7875 return e_invarg;
7876 if (*p == ',')
7877 ++p;
7878 }
7879 }
7880
7881 return NULL; /* no error */
7882}
7883
7884#ifdef FEAT_STL_OPT
7885/*
7886 * Check validity of options with the 'statusline' format.
7887 * Return error message or NULL.
7888 */
7889 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007890check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007891{
7892 int itemcnt = 0;
7893 int groupdepth = 0;
7894 static char_u errbuf[80];
7895
7896 while (*s && itemcnt < STL_MAX_ITEM)
7897 {
7898 /* Check for valid keys after % sequences */
7899 while (*s && *s != '%')
7900 s++;
7901 if (!*s)
7902 break;
7903 s++;
7904 if (*s != '%' && *s != ')')
7905 ++itemcnt;
7906 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7907 {
7908 s++;
7909 continue;
7910 }
7911 if (*s == ')')
7912 {
7913 s++;
7914 if (--groupdepth < 0)
7915 break;
7916 continue;
7917 }
7918 if (*s == '-')
7919 s++;
7920 while (VIM_ISDIGIT(*s))
7921 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007922 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007923 continue;
7924 if (*s == '.')
7925 {
7926 s++;
7927 while (*s && VIM_ISDIGIT(*s))
7928 s++;
7929 }
7930 if (*s == '(')
7931 {
7932 groupdepth++;
7933 continue;
7934 }
7935 if (vim_strchr(STL_ALL, *s) == NULL)
7936 {
7937 return illegal_char(errbuf, *s);
7938 }
7939 if (*s == '{')
7940 {
7941 s++;
7942 while (*s != '}' && *s)
7943 s++;
7944 if (*s != '}')
7945 return (char_u *)N_("E540: Unclosed expression sequence");
7946 }
7947 }
7948 if (itemcnt >= STL_MAX_ITEM)
7949 return (char_u *)N_("E541: too many items");
7950 if (groupdepth != 0)
7951 return (char_u *)N_("E542: unbalanced groups");
7952 return NULL;
7953}
7954#endif
7955
7956#ifdef FEAT_CLIPBOARD
7957/*
7958 * Extract the items in the 'clipboard' option and set global values.
7959 */
7960 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007961check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007962{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007963 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007964 int new_autoselect_star = FALSE;
7965 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007966 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007967 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007968 regprog_T *new_exclude_prog = NULL;
7969 char_u *errmsg = NULL;
7970 char_u *p;
7971
7972 for (p = p_cb; *p != NUL; )
7973 {
7974 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7975 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007976 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007977 p += 7;
7978 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007979 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007980 && (p[11] == ',' || p[11] == NUL))
7981 {
7982 new_unnamed |= CLIP_UNNAMED_PLUS;
7983 p += 11;
7984 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007985 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007986 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007987 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007988 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007989 p += 10;
7990 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007991 else if (STRNCMP(p, "autoselectplus", 14) == 0
7992 && (p[14] == ',' || p[14] == NUL))
7993 {
7994 new_autoselect_plus = TRUE;
7995 p += 14;
7996 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007997 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007998 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007999 {
8000 new_autoselectml = TRUE;
8001 p += 12;
8002 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008003 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
8004 {
8005 new_html = TRUE;
8006 p += 4;
8007 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008008 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
8009 {
8010 p += 8;
8011 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
8012 if (new_exclude_prog == NULL)
8013 errmsg = e_invarg;
8014 break;
8015 }
8016 else
8017 {
8018 errmsg = e_invarg;
8019 break;
8020 }
8021 if (*p == ',')
8022 ++p;
8023 }
8024 if (errmsg == NULL)
8025 {
8026 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02008027 clip_autoselect_star = new_autoselect_star;
8028 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008029 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008030 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02008031 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008032 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02008033#ifdef FEAT_GUI_GTK
8034 if (gui.in_use)
8035 {
8036 gui_gtk_set_selection_targets();
8037 gui_gtk_set_dnd_targets();
8038 }
8039#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008040 }
8041 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008042 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008043
8044 return errmsg;
8045}
8046#endif
8047
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008048#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008049 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008050did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008051{
8052 char_u *errmsg = NULL;
8053 win_T *wp;
8054 int l;
8055
8056 if (is_spellfile)
8057 {
8058 l = (int)STRLEN(curwin->w_s->b_p_spf);
8059 if (l > 0 && (l < 4
8060 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8061 errmsg = e_invarg;
8062 }
8063
8064 if (errmsg == NULL)
8065 {
8066 FOR_ALL_WINDOWS(wp)
8067 if (wp->w_buffer == curbuf && wp->w_p_spell)
8068 {
8069 errmsg = did_set_spelllang(wp);
8070# ifdef FEAT_WINDOWS
8071 break;
8072# endif
8073 }
8074 }
8075 return errmsg;
8076}
8077
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008078/*
8079 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8080 * Return error message when failed, NULL when OK.
8081 */
8082 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008083compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008084{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008085 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008086 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008087
Bram Moolenaar860cae12010-06-05 23:22:07 +02008088 if (*synblock->b_p_spc == NUL)
8089 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008090 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008091 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008092 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008093 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008094 if (re != NULL)
8095 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008096 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008097 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008098 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008099 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008100 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008101 return e_invarg;
8102 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008103 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008104 }
8105
Bram Moolenaar473de612013-06-08 18:19:48 +02008106 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008107 return NULL;
8108}
8109#endif
8110
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008111#if defined(FEAT_EVAL) || defined(PROTO)
8112/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008113 * Set the scriptID for an option, taking care of setting the buffer- or
8114 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008115 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008116 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008117set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008118{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008119 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8120 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008121
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008122 /* Remember where the option was set. For local options need to do that
8123 * in the buffer or window structure. */
8124 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008125 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008126 if (both || (opt_flags & OPT_LOCAL))
8127 {
8128 if (indir & PV_BUF)
8129 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8130 else if (indir & PV_WIN)
8131 curwin->w_p_scriptID[indir & PV_MASK] = id;
8132 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008133}
8134#endif
8135
Bram Moolenaar071d4272004-06-13 20:20:40 +00008136/*
8137 * Set the value of a boolean option, and take care of side effects.
8138 * Returns NULL for success, or an error message for an error.
8139 */
8140 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008141set_bool_option(
8142 int opt_idx, /* index in options[] table */
8143 char_u *varp, /* pointer to the option variable */
8144 int value, /* new value */
8145 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008146{
8147 int old_value = *(int *)varp;
8148
Bram Moolenaar071d4272004-06-13 20:20:40 +00008149 /* Disallow changing some options from secure mode */
8150 if ((secure
8151#ifdef HAVE_SANDBOX
8152 || sandbox != 0
8153#endif
8154 ) && (options[opt_idx].flags & P_SECURE))
8155 return e_secure;
8156
8157 *(int *)varp = value; /* set the new value */
8158#ifdef FEAT_EVAL
8159 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008160 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008161#endif
8162
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008163#ifdef FEAT_GUI
8164 need_mouse_correct = TRUE;
8165#endif
8166
Bram Moolenaar071d4272004-06-13 20:20:40 +00008167 /* May set global value for local option. */
8168 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8169 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8170
8171 /*
8172 * Handle side effects of changing a bool option.
8173 */
8174
8175 /* 'compatible' */
8176 if ((int *)varp == &p_cp)
8177 {
8178 compatible_set();
8179 }
8180
Bram Moolenaar920694c2016-08-21 17:45:02 +02008181#ifdef FEAT_LANGMAP
8182 if ((int *)varp == &p_lrm)
8183 /* 'langremap' -> !'langnoremap' */
8184 p_lnr = !p_lrm;
8185 else if ((int *)varp == &p_lnr)
8186 /* 'langnoremap' -> !'langremap' */
8187 p_lrm = !p_lnr;
8188#endif
8189
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008190#ifdef FEAT_PERSISTENT_UNDO
8191 /* 'undofile' */
8192 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8193 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008194 /* Only take action when the option was set. When reset we do not
8195 * delete the undo file, the option may be set again without making
8196 * any changes in between. */
8197 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008198 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008199 char_u hash[UNDO_HASH_SIZE];
8200 buf_T *save_curbuf = curbuf;
8201
Bram Moolenaar29323592016-07-24 22:04:11 +02008202 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008203 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008204 /* When 'undofile' is set globally: for every buffer, otherwise
8205 * only for the current buffer: Try to read in the undofile,
8206 * if one exists, the buffer wasn't changed and the buffer was
8207 * loaded */
8208 if ((curbuf == save_curbuf
8209 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8210 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8211 {
8212 u_compute_hash(hash);
8213 u_read_undo(NULL, hash, curbuf->b_fname);
8214 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008215 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008216 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008217 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008218 }
8219#endif
8220
Bram Moolenaar071d4272004-06-13 20:20:40 +00008221 else if ((int *)varp == &curbuf->b_p_ro)
8222 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008223 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008224 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8225 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008226
8227 /* when 'readonly' is set may give W10 again */
8228 if (curbuf->b_p_ro)
8229 curbuf->b_did_warn = FALSE;
8230
Bram Moolenaar071d4272004-06-13 20:20:40 +00008231#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008232 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008233#endif
8234 }
8235
Bram Moolenaar9c449722010-07-20 18:44:27 +02008236#ifdef FEAT_GUI
8237 else if ((int *)varp == &p_mh)
8238 {
8239 if (!p_mh)
8240 gui_mch_mousehide(FALSE);
8241 }
8242#endif
8243
Bram Moolenaara539df02010-08-01 14:35:05 +02008244 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008245 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008246 {
Bram Moolenaar423802d2017-07-30 16:52:24 +02008247# ifdef FEAT_TERMINAL
8248 /* Cannot set 'modifiable' when in Terminal mode. */
Bram Moolenaar6d819742017-08-06 14:57:49 +02008249 if (term_in_normal_mode()
Bram Moolenaar20e6cd02017-08-01 20:25:22 +02008250 || (bt_terminal(curbuf) && !term_is_finished(curbuf)))
Bram Moolenaar423802d2017-07-30 16:52:24 +02008251 {
8252 curbuf->b_p_ma = FALSE;
8253 return (char_u *)N_("E946: Cannot make a terminal with running job modifiable");
8254 }
8255# endif
8256# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008257 redraw_titles();
Bram Moolenaar423802d2017-07-30 16:52:24 +02008258# endif
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008259 }
Bram Moolenaar423802d2017-07-30 16:52:24 +02008260#ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00008261 /* when 'endofline' is changed, redraw the window title */
8262 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008263 {
8264 redraw_titles();
8265 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008266 /* when 'fixeol' is changed, redraw the window title */
8267 else if ((int *)varp == &curbuf->b_p_fixeol)
8268 {
8269 redraw_titles();
8270 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008271# ifdef FEAT_MBYTE
8272 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008273 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008274 {
8275 redraw_titles();
8276 }
8277# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008278#endif
8279
8280 /* when 'bin' is set also set some other options */
8281 else if ((int *)varp == &curbuf->b_p_bin)
8282 {
8283 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8284#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008285 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008286#endif
8287 }
8288
8289#ifdef FEAT_AUTOCMD
8290 /* when 'buflisted' changes, trigger autocommands */
8291 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8292 {
8293 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8294 NULL, NULL, TRUE, curbuf);
8295 }
8296#endif
8297
8298 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8299 else if ((int *)varp == &curbuf->b_p_swf)
8300 {
8301 if (curbuf->b_p_swf && p_uc)
8302 ml_open_file(curbuf); /* create the swap file */
8303 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008304 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8305 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008306 mf_close_file(curbuf, TRUE); /* remove the swap file */
8307 }
8308
8309 /* when 'terse' is set change 'shortmess' */
8310 else if ((int *)varp == &p_terse)
8311 {
8312 char_u *p;
8313
8314 p = vim_strchr(p_shm, SHM_SEARCH);
8315
8316 /* insert 's' in p_shm */
8317 if (p_terse && p == NULL)
8318 {
8319 STRCPY(IObuff, p_shm);
8320 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008321 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008322 }
8323 /* remove 's' from p_shm */
8324 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008325 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008326 }
8327
8328 /* when 'paste' is set or reset also change other options */
8329 else if ((int *)varp == &p_paste)
8330 {
8331 paste_option_changed();
8332 }
8333
8334 /* when 'insertmode' is set from an autocommand need to do work here */
8335 else if ((int *)varp == &p_im)
8336 {
8337 if (p_im)
8338 {
8339 if ((State & INSERT) == 0)
8340 need_start_insertmode = TRUE;
8341 stop_insert_mode = FALSE;
8342 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008343 /* only reset if it was set previously */
8344 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008345 {
8346 need_start_insertmode = FALSE;
8347 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008348 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008349 clear_cmdline = TRUE; /* remove "(insert)" */
8350 restart_edit = 0;
8351 }
8352 }
8353
8354 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8355 else if ((int *)varp == &p_ic && p_hls)
8356 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008357 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358 }
8359
8360#ifdef FEAT_SEARCH_EXTRA
8361 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8362 else if ((int *)varp == &p_hls)
8363 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008364 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008365 }
8366#endif
8367
8368#ifdef FEAT_SCROLLBIND
8369 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8370 * at the end of normal_cmd() */
8371 else if ((int *)varp == &curwin->w_p_scb)
8372 {
8373 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008374 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008375 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008376 curwin->w_scbind_pos = curwin->w_topline;
8377 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008378 }
8379#endif
8380
8381#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8382 /* There can be only one window with 'previewwindow' set. */
8383 else if ((int *)varp == &curwin->w_p_pvw)
8384 {
8385 if (curwin->w_p_pvw)
8386 {
8387 win_T *win;
8388
Bram Moolenaar29323592016-07-24 22:04:11 +02008389 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008390 if (win->w_p_pvw && win != curwin)
8391 {
8392 curwin->w_p_pvw = FALSE;
8393 return (char_u *)N_("E590: A preview window already exists");
8394 }
8395 }
8396 }
8397#endif
8398
8399 /* when 'textmode' is set or reset also change 'fileformat' */
8400 else if ((int *)varp == &curbuf->b_p_tx)
8401 {
8402 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8403 }
8404
8405 /* when 'textauto' is set or reset also change 'fileformats' */
8406 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008407 set_string_option_direct((char_u *)"ffs", -1,
8408 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008409 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008410
8411 /*
8412 * When 'lisp' option changes include/exclude '-' in
8413 * keyword characters.
8414 */
8415#ifdef FEAT_LISP
8416 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8417 {
8418 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8419 }
8420#endif
8421
8422#ifdef FEAT_TITLE
8423 /* when 'title' changed, may need to change the title; same for 'icon' */
8424 else if ((int *)varp == &p_title)
8425 {
8426 did_set_title(FALSE);
8427 }
8428
8429 else if ((int *)varp == &p_icon)
8430 {
8431 did_set_title(TRUE);
8432 }
8433#endif
8434
8435 else if ((int *)varp == &curbuf->b_changed)
8436 {
8437 if (!value)
8438 save_file_ff(curbuf); /* Buffer is unchanged */
8439#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008440 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008441#endif
8442#ifdef FEAT_AUTOCMD
8443 modified_was_set = value;
8444#endif
8445 }
8446
8447#ifdef BACKSLASH_IN_FILENAME
8448 else if ((int *)varp == &p_ssl)
8449 {
8450 if (p_ssl)
8451 {
8452 psepc = '/';
8453 psepcN = '\\';
8454 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008455 }
8456 else
8457 {
8458 psepc = '\\';
8459 psepcN = '/';
8460 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008461 }
8462
8463 /* need to adjust the file name arguments and buffer names. */
8464 buflist_slash_adjust();
8465 alist_slash_adjust();
8466# ifdef FEAT_EVAL
8467 scriptnames_slash_adjust();
8468# endif
8469 }
8470#endif
8471
8472 /* If 'wrap' is set, set w_leftcol to zero. */
8473 else if ((int *)varp == &curwin->w_p_wrap)
8474 {
8475 if (curwin->w_p_wrap)
8476 curwin->w_leftcol = 0;
8477 }
8478
8479#ifdef FEAT_WINDOWS
8480 else if ((int *)varp == &p_ea)
8481 {
8482 if (p_ea && !old_value)
8483 win_equal(curwin, FALSE, 0);
8484 }
8485#endif
8486
8487 else if ((int *)varp == &p_wiv)
8488 {
8489 /*
8490 * When 'weirdinvert' changed, set/reset 't_xs'.
8491 * Then set 'weirdinvert' according to value of 't_xs'.
8492 */
8493 if (p_wiv && !old_value)
8494 T_XS = (char_u *)"y";
8495 else if (!p_wiv && old_value)
8496 T_XS = empty_option;
8497 p_wiv = (*T_XS != NUL);
8498 }
8499
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008500#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008501 else if ((int *)varp == &p_beval)
8502 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008503 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008504 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008505 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008506 gui_mch_disable_beval_area(balloonEval);
8507 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008508#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008509
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008510#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008511 else if ((int *)varp == &p_acd)
8512 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008513 /* Change directories when the 'acd' option is set now. */
8514 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008515 }
8516#endif
8517
8518#ifdef FEAT_DIFF
8519 /* 'diff' */
8520 else if ((int *)varp == &curwin->w_p_diff)
8521 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008522 /* May add or remove the buffer from the list of diff buffers. */
8523 diff_buf_adjust(curwin);
8524# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008525 if (foldmethodIsDiff(curwin))
8526 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008527# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008528 }
8529#endif
8530
8531#ifdef USE_IM_CONTROL
8532 /* 'imdisable' */
8533 else if ((int *)varp == &p_imdisable)
8534 {
8535 /* Only de-activate it here, it will be enabled when changing mode. */
8536 if (p_imdisable)
8537 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008538 else if (State & INSERT)
8539 /* When the option is set from an autocommand, it may need to take
8540 * effect right away. */
8541 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008542 }
8543#endif
8544
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008545#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008546 /* 'spell' */
8547 else if ((int *)varp == &curwin->w_p_spell)
8548 {
8549 if (curwin->w_p_spell)
8550 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008551 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008552 if (errmsg != NULL)
8553 EMSG(_(errmsg));
8554 }
8555 }
8556#endif
8557
Bram Moolenaar071d4272004-06-13 20:20:40 +00008558#ifdef FEAT_FKMAP
8559 else if ((int *)varp == &p_altkeymap)
8560 {
8561 if (old_value != p_altkeymap)
8562 {
8563 if (!p_altkeymap)
8564 {
8565 p_hkmap = p_fkmap;
8566 p_fkmap = 0;
8567 }
8568 else
8569 {
8570 p_fkmap = p_hkmap;
8571 p_hkmap = 0;
8572 }
8573 (void)init_chartab();
8574 }
8575 }
8576
8577 /*
8578 * In case some second language keymapping options have changed, check
8579 * and correct the setting in a consistent way.
8580 */
8581
8582 /*
8583 * If hkmap or fkmap are set, reset Arabic keymapping.
8584 */
8585 if ((p_hkmap || p_fkmap) && p_altkeymap)
8586 {
8587 p_altkeymap = p_fkmap;
8588# ifdef FEAT_ARABIC
8589 curwin->w_p_arab = FALSE;
8590# endif
8591 (void)init_chartab();
8592 }
8593
8594 /*
8595 * If hkmap set, reset Farsi keymapping.
8596 */
8597 if (p_hkmap && p_altkeymap)
8598 {
8599 p_altkeymap = 0;
8600 p_fkmap = 0;
8601# ifdef FEAT_ARABIC
8602 curwin->w_p_arab = FALSE;
8603# endif
8604 (void)init_chartab();
8605 }
8606
8607 /*
8608 * If fkmap set, reset Hebrew keymapping.
8609 */
8610 if (p_fkmap && !p_altkeymap)
8611 {
8612 p_altkeymap = 1;
8613 p_hkmap = 0;
8614# ifdef FEAT_ARABIC
8615 curwin->w_p_arab = FALSE;
8616# endif
8617 (void)init_chartab();
8618 }
8619#endif
8620
8621#ifdef FEAT_ARABIC
8622 if ((int *)varp == &curwin->w_p_arab)
8623 {
8624 if (curwin->w_p_arab)
8625 {
8626 /*
8627 * 'arabic' is set, handle various sub-settings.
8628 */
8629 if (!p_tbidi)
8630 {
8631 /* set rightleft mode */
8632 if (!curwin->w_p_rl)
8633 {
8634 curwin->w_p_rl = TRUE;
8635 changed_window_setting();
8636 }
8637
8638 /* Enable Arabic shaping (major part of what Arabic requires) */
8639 if (!p_arshape)
8640 {
8641 p_arshape = TRUE;
8642 redraw_later_clear();
8643 }
8644 }
8645
8646 /* Arabic requires a utf-8 encoding, inform the user if its not
8647 * set. */
8648 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008649 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008650 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8651
Bram Moolenaar8820b482017-03-16 17:23:31 +01008652 msg_source(HL_ATTR(HLF_W));
8653 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008654#ifdef FEAT_EVAL
8655 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8656#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008657 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008658
8659# ifdef FEAT_MBYTE
8660 /* set 'delcombine' */
8661 p_deco = TRUE;
8662# endif
8663
8664# ifdef FEAT_KEYMAP
8665 /* Force-set the necessary keymap for arabic */
8666 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8667 OPT_LOCAL);
8668# endif
8669# ifdef FEAT_FKMAP
8670 p_altkeymap = 0;
8671 p_hkmap = 0;
8672 p_fkmap = 0;
8673 (void)init_chartab();
8674# endif
8675 }
8676 else
8677 {
8678 /*
8679 * 'arabic' is reset, handle various sub-settings.
8680 */
8681 if (!p_tbidi)
8682 {
8683 /* reset rightleft mode */
8684 if (curwin->w_p_rl)
8685 {
8686 curwin->w_p_rl = FALSE;
8687 changed_window_setting();
8688 }
8689
8690 /* 'arabicshape' isn't reset, it is a global option and
8691 * another window may still need it "on". */
8692 }
8693
8694 /* 'delcombine' isn't reset, it is a global option and another
8695 * window may still want it "on". */
8696
8697# ifdef FEAT_KEYMAP
8698 /* Revert to the default keymap */
8699 curbuf->b_p_iminsert = B_IMODE_NONE;
8700 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8701# endif
8702 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008703 }
8704
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008705#endif
8706
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008707#ifdef FEAT_TERMGUICOLORS
8708 /* 'termguicolors' */
8709 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008710 {
8711# ifdef FEAT_GUI
8712 if (!gui.in_use && !gui.starting)
8713# endif
8714 highlight_gui_started();
8715 }
8716#endif
8717
Bram Moolenaar071d4272004-06-13 20:20:40 +00008718 /*
8719 * End of handling side effects for bool options.
8720 */
8721
Bram Moolenaar53744302015-07-17 17:38:22 +02008722 /* after handling side effects, call autocommand */
8723
Bram Moolenaar071d4272004-06-13 20:20:40 +00008724 options[opt_idx].flags |= P_WAS_SET;
8725
Bram Moolenaar53744302015-07-17 17:38:22 +02008726#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8727 if (!starting)
8728 {
8729 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008730 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8731 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8732 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008733 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8734 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8735 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8736 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8737 reset_v_option_vars();
8738 }
8739#endif
8740
Bram Moolenaar071d4272004-06-13 20:20:40 +00008741 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008742 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008743 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008744 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008745 check_redraw(options[opt_idx].flags);
8746
8747 return NULL;
8748}
8749
8750/*
8751 * Set the value of a number option, and take care of side effects.
8752 * Returns NULL for success, or an error message for an error.
8753 */
8754 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008755set_num_option(
8756 int opt_idx, /* index in options[] table */
8757 char_u *varp, /* pointer to the option variable */
8758 long value, /* new value */
8759 char_u *errbuf, /* buffer for error messages */
8760 size_t errbuflen, /* length of "errbuf" */
8761 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008762 OPT_MODELINE */
8763{
8764 char_u *errmsg = NULL;
8765 long old_value = *(long *)varp;
8766 long old_Rows = Rows; /* remember old Rows */
8767 long old_Columns = Columns; /* remember old Columns */
8768 long *pp = (long *)varp;
8769
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008770 /* Disallow changing some options from secure mode. */
8771 if ((secure
8772#ifdef HAVE_SANDBOX
8773 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008774#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008775 ) && (options[opt_idx].flags & P_SECURE))
8776 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008777
8778 *pp = value;
8779#ifdef FEAT_EVAL
8780 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008781 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008782#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008783#ifdef FEAT_GUI
8784 need_mouse_correct = TRUE;
8785#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008786
Bram Moolenaar14f24742012-08-08 18:01:05 +02008787 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008788 {
8789 errmsg = e_positive;
8790 curbuf->b_p_sw = curbuf->b_p_ts;
8791 }
8792
8793 /*
8794 * Number options that need some action when changed
8795 */
8796#ifdef FEAT_WINDOWS
8797 if (pp == &p_wh || pp == &p_hh)
8798 {
8799 if (p_wh < 1)
8800 {
8801 errmsg = e_positive;
8802 p_wh = 1;
8803 }
8804 if (p_wmh > p_wh)
8805 {
8806 errmsg = e_winheight;
8807 p_wh = p_wmh;
8808 }
8809 if (p_hh < 0)
8810 {
8811 errmsg = e_positive;
8812 p_hh = 0;
8813 }
8814
8815 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008816 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008817 {
8818 if (pp == &p_wh && curwin->w_height < p_wh)
8819 win_setheight((int)p_wh);
8820 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8821 win_setheight((int)p_hh);
8822 }
8823 }
8824
8825 /* 'winminheight' */
8826 else if (pp == &p_wmh)
8827 {
8828 if (p_wmh < 0)
8829 {
8830 errmsg = e_positive;
8831 p_wmh = 0;
8832 }
8833 if (p_wmh > p_wh)
8834 {
8835 errmsg = e_winheight;
8836 p_wmh = p_wh;
8837 }
8838 win_setminheight();
8839 }
8840
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008841# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008842 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008843 {
8844 if (p_wiw < 1)
8845 {
8846 errmsg = e_positive;
8847 p_wiw = 1;
8848 }
8849 if (p_wmw > p_wiw)
8850 {
8851 errmsg = e_winwidth;
8852 p_wiw = p_wmw;
8853 }
8854
8855 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008856 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008857 win_setwidth((int)p_wiw);
8858 }
8859
8860 /* 'winminwidth' */
8861 else if (pp == &p_wmw)
8862 {
8863 if (p_wmw < 0)
8864 {
8865 errmsg = e_positive;
8866 p_wmw = 0;
8867 }
8868 if (p_wmw > p_wiw)
8869 {
8870 errmsg = e_winwidth;
8871 p_wmw = p_wiw;
8872 }
8873 win_setminheight();
8874 }
8875# endif
8876
8877#endif
8878
8879#ifdef FEAT_WINDOWS
8880 /* (re)set last window status line */
8881 else if (pp == &p_ls)
8882 {
8883 last_status(FALSE);
8884 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008885
8886 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008887 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008888 {
8889 shell_new_rows(); /* recompute window positions and heights */
8890 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008891#endif
8892
8893#ifdef FEAT_GUI
8894 else if (pp == &p_linespace)
8895 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008896 /* Recompute gui.char_height and resize the Vim window to keep the
8897 * same number of lines. */
8898 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008899 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008900 }
8901#endif
8902
8903#ifdef FEAT_FOLDING
8904 /* 'foldlevel' */
8905 else if (pp == &curwin->w_p_fdl)
8906 {
8907 if (curwin->w_p_fdl < 0)
8908 curwin->w_p_fdl = 0;
8909 newFoldLevel();
8910 }
8911
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008912 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008913 else if (pp == &curwin->w_p_fml)
8914 {
8915 foldUpdateAll(curwin);
8916 }
8917
8918 /* 'foldnestmax' */
8919 else if (pp == &curwin->w_p_fdn)
8920 {
8921 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8922 foldUpdateAll(curwin);
8923 }
8924
8925 /* 'foldcolumn' */
8926 else if (pp == &curwin->w_p_fdc)
8927 {
8928 if (curwin->w_p_fdc < 0)
8929 {
8930 errmsg = e_positive;
8931 curwin->w_p_fdc = 0;
8932 }
8933 else if (curwin->w_p_fdc > 12)
8934 {
8935 errmsg = e_invarg;
8936 curwin->w_p_fdc = 12;
8937 }
8938 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008939#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008940
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008941#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008942 /* 'shiftwidth' or 'tabstop' */
8943 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8944 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008945# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008946 if (foldmethodIsIndent(curwin))
8947 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008948# endif
8949# ifdef FEAT_CINDENT
8950 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8951 * parse 'cinoptions'. */
8952 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8953 parse_cino(curbuf);
8954# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008955 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008956#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008957
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008958#ifdef FEAT_MBYTE
8959 /* 'maxcombine' */
8960 else if (pp == &p_mco)
8961 {
8962 if (p_mco > MAX_MCO)
8963 p_mco = MAX_MCO;
8964 else if (p_mco < 0)
8965 p_mco = 0;
8966 screenclear(); /* will re-allocate the screen */
8967 }
8968#endif
8969
Bram Moolenaar071d4272004-06-13 20:20:40 +00008970 else if (pp == &curbuf->b_p_iminsert)
8971 {
8972 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8973 {
8974 errmsg = e_invarg;
8975 curbuf->b_p_iminsert = B_IMODE_NONE;
8976 }
8977 p_iminsert = curbuf->b_p_iminsert;
8978 if (termcap_active) /* don't do this in the alternate screen */
8979 showmode();
8980#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8981 /* Show/unshow value of 'keymap' in status lines. */
8982 status_redraw_curbuf();
8983#endif
8984 }
8985
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008986 else if (pp == &p_window)
8987 {
8988 if (p_window < 1)
8989 p_window = 1;
8990 else if (p_window >= Rows)
8991 p_window = Rows - 1;
8992 }
8993
Bram Moolenaar071d4272004-06-13 20:20:40 +00008994 else if (pp == &curbuf->b_p_imsearch)
8995 {
8996 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8997 {
8998 errmsg = e_invarg;
8999 curbuf->b_p_imsearch = B_IMODE_NONE;
9000 }
9001 p_imsearch = curbuf->b_p_imsearch;
9002 }
9003
9004#ifdef FEAT_TITLE
9005 /* if 'titlelen' has changed, redraw the title */
9006 else if (pp == &p_titlelen)
9007 {
9008 if (p_titlelen < 0)
9009 {
9010 errmsg = e_positive;
9011 p_titlelen = 85;
9012 }
9013 if (starting != NO_SCREEN && old_value != p_titlelen)
9014 need_maketitle = TRUE;
9015 }
9016#endif
9017
9018 /* if p_ch changed value, change the command line height */
9019 else if (pp == &p_ch)
9020 {
9021 if (p_ch < 1)
9022 {
9023 errmsg = e_positive;
9024 p_ch = 1;
9025 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00009026 if (p_ch > Rows - min_rows() + 1)
9027 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009028
9029 /* Only compute the new window layout when startup has been
9030 * completed. Otherwise the frame sizes may be wrong. */
9031 if (p_ch != old_value && full_screen
9032#ifdef FEAT_GUI
9033 && !gui.starting
9034#endif
9035 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00009036 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009037 }
9038
9039 /* when 'updatecount' changes from zero to non-zero, open swap files */
9040 else if (pp == &p_uc)
9041 {
9042 if (p_uc < 0)
9043 {
9044 errmsg = e_positive;
9045 p_uc = 100;
9046 }
9047 if (p_uc && !old_value)
9048 ml_open_files();
9049 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02009050#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009051 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009052 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009053 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009054 {
9055 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009056 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009057 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009058 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009059 {
9060 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009061 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009062 }
9063 }
9064#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009065#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009066 else if (pp == &p_mzq)
9067 mzvim_reset_timer();
9068#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009069
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009070#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9071 /* 'pyxversion' */
9072 else if (pp == &p_pyx)
9073 {
9074 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9075 errmsg = e_invarg;
9076 }
9077#endif
9078
Bram Moolenaar071d4272004-06-13 20:20:40 +00009079 /* sync undo before 'undolevels' changes */
9080 else if (pp == &p_ul)
9081 {
9082 /* use the old value, otherwise u_sync() may not work properly */
9083 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009084 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009085 p_ul = value;
9086 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009087 else if (pp == &curbuf->b_p_ul)
9088 {
9089 /* use the old value, otherwise u_sync() may not work properly */
9090 curbuf->b_p_ul = old_value;
9091 u_sync(TRUE);
9092 curbuf->b_p_ul = value;
9093 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009094
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009095#ifdef FEAT_LINEBREAK
9096 /* 'numberwidth' must be positive */
9097 else if (pp == &curwin->w_p_nuw)
9098 {
9099 if (curwin->w_p_nuw < 1)
9100 {
9101 errmsg = e_positive;
9102 curwin->w_p_nuw = 1;
9103 }
9104 if (curwin->w_p_nuw > 10)
9105 {
9106 errmsg = e_invarg;
9107 curwin->w_p_nuw = 10;
9108 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009109 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009110 }
9111#endif
9112
Bram Moolenaar1a384422010-07-14 19:53:30 +02009113 else if (pp == &curbuf->b_p_tw)
9114 {
9115 if (curbuf->b_p_tw < 0)
9116 {
9117 errmsg = e_positive;
9118 curbuf->b_p_tw = 0;
9119 }
9120#ifdef FEAT_SYN_HL
9121# ifdef FEAT_WINDOWS
9122 {
9123 win_T *wp;
9124 tabpage_T *tp;
9125
9126 FOR_ALL_TAB_WINDOWS(tp, wp)
9127 check_colorcolumn(wp);
9128 }
9129# else
9130 check_colorcolumn(curwin);
9131# endif
9132#endif
9133 }
9134
Bram Moolenaar071d4272004-06-13 20:20:40 +00009135 /*
9136 * Check the bounds for numeric options here
9137 */
9138 if (Rows < min_rows() && full_screen)
9139 {
9140 if (errbuf != NULL)
9141 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009142 vim_snprintf((char *)errbuf, errbuflen,
9143 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009144 errmsg = errbuf;
9145 }
9146 Rows = min_rows();
9147 }
9148 if (Columns < MIN_COLUMNS && full_screen)
9149 {
9150 if (errbuf != NULL)
9151 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009152 vim_snprintf((char *)errbuf, errbuflen,
9153 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009154 errmsg = errbuf;
9155 }
9156 Columns = MIN_COLUMNS;
9157 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009158 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009159
Bram Moolenaar071d4272004-06-13 20:20:40 +00009160 /*
9161 * If the screen (shell) height has been changed, assume it is the
9162 * physical screenheight.
9163 */
9164 if (old_Rows != Rows || old_Columns != Columns)
9165 {
9166 /* Changing the screen size is not allowed while updating the screen. */
9167 if (updating_screen)
9168 *pp = old_value;
9169 else if (full_screen
9170#ifdef FEAT_GUI
9171 && !gui.starting
9172#endif
9173 )
9174 set_shellsize((int)Columns, (int)Rows, TRUE);
9175 else
9176 {
9177 /* Postpone the resizing; check the size and cmdline position for
9178 * messages. */
9179 check_shellsize();
9180 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9181 cmdline_row = Rows - p_ch;
9182 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009183 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009184 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009185 }
9186
Bram Moolenaar071d4272004-06-13 20:20:40 +00009187 if (curbuf->b_p_ts <= 0)
9188 {
9189 errmsg = e_positive;
9190 curbuf->b_p_ts = 8;
9191 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009192 if (p_tm < 0)
9193 {
9194 errmsg = e_positive;
9195 p_tm = 0;
9196 }
9197 if ((curwin->w_p_scr <= 0
9198 || (curwin->w_p_scr > curwin->w_height
9199 && curwin->w_height > 0))
9200 && full_screen)
9201 {
9202 if (pp == &(curwin->w_p_scr))
9203 {
9204 if (curwin->w_p_scr != 0)
9205 errmsg = e_scroll;
9206 win_comp_scroll(curwin);
9207 }
9208 /* If 'scroll' became invalid because of a side effect silently adjust
9209 * it. */
9210 else if (curwin->w_p_scr <= 0)
9211 curwin->w_p_scr = 1;
9212 else /* curwin->w_p_scr > curwin->w_height */
9213 curwin->w_p_scr = curwin->w_height;
9214 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009215 if (p_hi < 0)
9216 {
9217 errmsg = e_positive;
9218 p_hi = 0;
9219 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009220 else if (p_hi > 10000)
9221 {
9222 errmsg = e_invarg;
9223 p_hi = 10000;
9224 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009225 if (p_re < 0 || p_re > 2)
9226 {
9227 errmsg = e_invarg;
9228 p_re = 0;
9229 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009230 if (p_report < 0)
9231 {
9232 errmsg = e_positive;
9233 p_report = 1;
9234 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009235 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009236 {
9237 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9238 p_sj = Rows / 2;
9239 else
9240 {
9241 errmsg = e_scroll;
9242 p_sj = 1;
9243 }
9244 }
9245 if (p_so < 0 && full_screen)
9246 {
9247 errmsg = e_scroll;
9248 p_so = 0;
9249 }
9250 if (p_siso < 0 && full_screen)
9251 {
9252 errmsg = e_positive;
9253 p_siso = 0;
9254 }
9255#ifdef FEAT_CMDWIN
9256 if (p_cwh < 1)
9257 {
9258 errmsg = e_positive;
9259 p_cwh = 1;
9260 }
9261#endif
9262 if (p_ut < 0)
9263 {
9264 errmsg = e_positive;
9265 p_ut = 2000;
9266 }
9267 if (p_ss < 0)
9268 {
9269 errmsg = e_positive;
9270 p_ss = 0;
9271 }
9272
9273 /* May set global value for local option. */
9274 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9275 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9276
9277 options[opt_idx].flags |= P_WAS_SET;
9278
Bram Moolenaar53744302015-07-17 17:38:22 +02009279#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9280 if (!starting && errmsg == NULL)
9281 {
9282 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009283 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9284 vim_snprintf((char *)buf_new, 10, "%ld", value);
9285 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009286 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9287 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9288 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9289 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9290 reset_v_option_vars();
9291 }
9292#endif
9293
Bram Moolenaar071d4272004-06-13 20:20:40 +00009294 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009295 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009296 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009297 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009298 check_redraw(options[opt_idx].flags);
9299
9300 return errmsg;
9301}
9302
9303/*
9304 * Called after an option changed: check if something needs to be redrawn.
9305 */
9306 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009307check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009308{
9309 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009310 int doclear = (flags & P_RCLR) == P_RCLR;
9311 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009312
9313#ifdef FEAT_WINDOWS
9314 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9315 status_redraw_all();
9316#endif
9317
9318 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9319 changed_window_setting();
9320 if (flags & P_RBUF)
9321 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009322 if (flags & P_RWINONLY)
9323 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009324 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009325 redraw_all_later(CLEAR);
9326 else if (all)
9327 redraw_all_later(NOT_VALID);
9328}
9329
9330/*
9331 * Find index for option 'arg'.
9332 * Return -1 if not found.
9333 */
9334 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009335findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009336{
9337 int opt_idx;
9338 char *s, *p;
9339 static short quick_tab[27] = {0, 0}; /* quick access table */
9340 int is_term_opt;
9341
9342 /*
9343 * For first call: Initialize the quick-access table.
9344 * It contains the index for the first option that starts with a certain
9345 * letter. There are 26 letters, plus the first "t_" option.
9346 */
9347 if (quick_tab[1] == 0)
9348 {
9349 p = options[0].fullname;
9350 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9351 {
9352 if (s[0] != p[0])
9353 {
9354 if (s[0] == 't' && s[1] == '_')
9355 quick_tab[26] = opt_idx;
9356 else
9357 quick_tab[CharOrdLow(s[0])] = opt_idx;
9358 }
9359 p = s;
9360 }
9361 }
9362
9363 /*
9364 * Check for name starting with an illegal character.
9365 */
9366#ifdef EBCDIC
9367 if (!islower(arg[0]))
9368#else
9369 if (arg[0] < 'a' || arg[0] > 'z')
9370#endif
9371 return -1;
9372
9373 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9374 if (is_term_opt)
9375 opt_idx = quick_tab[26];
9376 else
9377 opt_idx = quick_tab[CharOrdLow(arg[0])];
9378 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9379 {
9380 if (STRCMP(arg, s) == 0) /* match full name */
9381 break;
9382 }
9383 if (s == NULL && !is_term_opt)
9384 {
9385 opt_idx = quick_tab[CharOrdLow(arg[0])];
9386 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9387 {
9388 s = options[opt_idx].shortname;
9389 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9390 break;
9391 s = NULL;
9392 }
9393 }
9394 if (s == NULL)
9395 opt_idx = -1;
9396 return opt_idx;
9397}
9398
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009399#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009400/*
9401 * Get the value for an option.
9402 *
9403 * Returns:
9404 * Number or Toggle option: 1, *numval gets value.
9405 * String option: 0, *stringval gets allocated string.
9406 * Hidden Number or Toggle option: -1.
9407 * hidden String option: -2.
9408 * unknown option: -3.
9409 */
9410 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009411get_option_value(
9412 char_u *name,
9413 long *numval,
9414 char_u **stringval, /* NULL when only checking existence */
9415 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009416{
9417 int opt_idx;
9418 char_u *varp;
9419
9420 opt_idx = findoption(name);
9421 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009422 {
9423 int key;
9424
9425 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9426 && (key = find_key_option(name)) != 0)
9427 {
9428 char_u key_name[2];
9429 char_u *p;
9430
9431 if (key < 0)
9432 {
9433 key_name[0] = KEY2TERMCAP0(key);
9434 key_name[1] = KEY2TERMCAP1(key);
9435 }
9436 else
9437 {
9438 key_name[0] = KS_KEY;
9439 key_name[1] = (key & 0xff);
9440 }
9441 p = find_termcode(key_name);
9442 if (p != NULL)
9443 {
9444 if (stringval != NULL)
9445 *stringval = vim_strsave(p);
9446 return 0;
9447 }
9448 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009449 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009450 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009451
9452 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9453
9454 if (options[opt_idx].flags & P_STRING)
9455 {
9456 if (varp == NULL) /* hidden option */
9457 return -2;
9458 if (stringval != NULL)
9459 {
9460#ifdef FEAT_CRYPT
9461 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009462 if ((char_u **)varp == &curbuf->b_p_key
9463 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009464 *stringval = vim_strsave((char_u *)"*****");
9465 else
9466#endif
9467 *stringval = vim_strsave(*(char_u **)(varp));
9468 }
9469 return 0;
9470 }
9471
9472 if (varp == NULL) /* hidden option */
9473 return -1;
9474 if (options[opt_idx].flags & P_NUM)
9475 *numval = *(long *)varp;
9476 else
9477 {
9478 /* Special case: 'modified' is b_changed, but we also want to consider
9479 * it set when 'ff' or 'fenc' changed. */
9480 if ((int *)varp == &curbuf->b_changed)
9481 *numval = curbufIsChanged();
9482 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009483 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009484 }
9485 return 1;
9486}
9487#endif
9488
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009489#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009490/*
9491 * Returns the option attributes and its value. Unlike the above function it
9492 * will return either global value or local value of the option depending on
9493 * what was requested, but it will never return global value if it was
9494 * requested to return local one and vice versa. Neither it will return
9495 * buffer-local value if it was requested to return window-local one.
9496 *
9497 * Pretends that option is absent if it is not present in the requested scope
9498 * (i.e. has no global, window-local or buffer-local value depending on
9499 * opt_type). Uses
9500 *
9501 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009502 * 0 hidden or unknown option, also option that does not have requested
9503 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009504 * see SOPT_* in vim.h for other flags
9505 *
9506 * Possible opt_type values: see SREQ_* in vim.h
9507 */
9508 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009509get_option_value_strict(
9510 char_u *name,
9511 long *numval,
9512 char_u **stringval, /* NULL when only obtaining attributes */
9513 int opt_type,
9514 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009515{
9516 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009517 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009518 struct vimoption *p;
9519 int r = 0;
9520
9521 opt_idx = findoption(name);
9522 if (opt_idx < 0)
9523 return 0;
9524
9525 p = &(options[opt_idx]);
9526
9527 /* Hidden option */
9528 if (p->var == NULL)
9529 return 0;
9530
9531 if (p->flags & P_BOOL)
9532 r |= SOPT_BOOL;
9533 else if (p->flags & P_NUM)
9534 r |= SOPT_NUM;
9535 else if (p->flags & P_STRING)
9536 r |= SOPT_STRING;
9537
9538 if (p->indir == PV_NONE)
9539 {
9540 if (opt_type == SREQ_GLOBAL)
9541 r |= SOPT_GLOBAL;
9542 else
9543 return 0; /* Did not request global-only option */
9544 }
9545 else
9546 {
9547 if (p->indir & PV_BOTH)
9548 r |= SOPT_GLOBAL;
9549 else if (opt_type == SREQ_GLOBAL)
9550 return 0; /* Requested global option */
9551
9552 if (p->indir & PV_WIN)
9553 {
9554 if (opt_type == SREQ_BUF)
9555 return 0; /* Did not request window-local option */
9556 else
9557 r |= SOPT_WIN;
9558 }
9559 else if (p->indir & PV_BUF)
9560 {
9561 if (opt_type == SREQ_WIN)
9562 return 0; /* Did not request buffer-local option */
9563 else
9564 r |= SOPT_BUF;
9565 }
9566 }
9567
9568 if (stringval == NULL)
9569 return r;
9570
9571 if (opt_type == SREQ_GLOBAL)
9572 varp = p->var;
9573 else
9574 {
9575 if (opt_type == SREQ_BUF)
9576 {
9577 /* Special case: 'modified' is b_changed, but we also want to
9578 * consider it set when 'ff' or 'fenc' changed. */
9579 if (p->indir == PV_MOD)
9580 {
9581 *numval = bufIsChanged((buf_T *) from);
9582 varp = NULL;
9583 }
9584#ifdef FEAT_CRYPT
9585 else if (p->indir == PV_KEY)
9586 {
9587 /* never return the value of the crypt key */
9588 *stringval = NULL;
9589 varp = NULL;
9590 }
9591#endif
9592 else
9593 {
9594 aco_save_T aco;
9595 aucmd_prepbuf(&aco, (buf_T *) from);
9596 varp = get_varp(p);
9597 aucmd_restbuf(&aco);
9598 }
9599 }
9600 else if (opt_type == SREQ_WIN)
9601 {
9602 win_T *save_curwin;
9603 save_curwin = curwin;
9604 curwin = (win_T *) from;
9605 curbuf = curwin->w_buffer;
9606 varp = get_varp(p);
9607 curwin = save_curwin;
9608 curbuf = curwin->w_buffer;
9609 }
9610 if (varp == p->var)
9611 return (r | SOPT_UNSET);
9612 }
9613
9614 if (varp != NULL)
9615 {
9616 if (p->flags & P_STRING)
9617 *stringval = vim_strsave(*(char_u **)(varp));
9618 else if (p->flags & P_NUM)
9619 *numval = *(long *) varp;
9620 else
9621 *numval = *(int *)varp;
9622 }
9623
9624 return r;
9625}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009626
9627/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009628 * Iterate over options. First argument is a pointer to a pointer to a
9629 * structure inside options[] array, second is option type like in the above
9630 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009631 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009632 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009633 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009634 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009635 * first argument to NULL.
9636 *
9637 * Returns full option name for current option on each call.
9638 */
9639 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009640option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009641{
9642 struct vimoption *ret = NULL;
9643 do
9644 {
9645 if (*option == NULL)
9646 *option = (void *) options;
9647 else if (((struct vimoption *) (*option))->fullname == NULL)
9648 {
9649 *option = NULL;
9650 return NULL;
9651 }
9652 else
9653 *option = (void *) (((struct vimoption *) (*option)) + 1);
9654
9655 ret = ((struct vimoption *) (*option));
9656
9657 /* Hidden option */
9658 if (ret->var == NULL)
9659 {
9660 ret = NULL;
9661 continue;
9662 }
9663
9664 switch (opt_type)
9665 {
9666 case SREQ_GLOBAL:
9667 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9668 ret = NULL;
9669 break;
9670 case SREQ_BUF:
9671 if (!(ret->indir & PV_BUF))
9672 ret = NULL;
9673 break;
9674 case SREQ_WIN:
9675 if (!(ret->indir & PV_WIN))
9676 ret = NULL;
9677 break;
9678 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009679 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009680 return NULL;
9681 }
9682 }
9683 while (ret == NULL);
9684
9685 return (char_u *)ret->fullname;
9686}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009687#endif
9688
Bram Moolenaar071d4272004-06-13 20:20:40 +00009689/*
9690 * Set the value of option "name".
9691 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009692 *
9693 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009694 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009695 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009696set_option_value(
9697 char_u *name,
9698 long number,
9699 char_u *string,
9700 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009701{
9702 int opt_idx;
9703 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009704 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009705
9706 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009707 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009708 {
9709 int key;
9710
9711 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9712 && (key = find_key_option(name)) != 0)
9713 {
9714 char_u key_name[2];
9715
9716 if (key < 0)
9717 {
9718 key_name[0] = KEY2TERMCAP0(key);
9719 key_name[1] = KEY2TERMCAP1(key);
9720 }
9721 else
9722 {
9723 key_name[0] = KS_KEY;
9724 key_name[1] = (key & 0xff);
9725 }
9726 add_termcode(key_name, string, FALSE);
9727 if (full_screen)
9728 ttest(FALSE);
9729 redraw_all_later(CLEAR);
9730 return NULL;
9731 }
9732
Bram Moolenaar071d4272004-06-13 20:20:40 +00009733 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009734 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009735 else
9736 {
9737 flags = options[opt_idx].flags;
9738#ifdef HAVE_SANDBOX
9739 /* Disallow changing some options in the sandbox */
9740 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009741 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009742 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009743 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009744 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009745#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009746 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009747 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009748 else
9749 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009750 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009751 if (varp != NULL) /* hidden option is not changed */
9752 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009753 if (number == 0 && string != NULL)
9754 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009755 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009756
9757 /* Either we are given a string or we are setting option
9758 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009759 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009760 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009761 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009762 {
9763 /* There's another character after zeros or the string
9764 * is empty. In both cases, we are trying to set a
9765 * num option using a string. */
9766 EMSG3(_("E521: Number required: &%s = '%s'"),
9767 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009768 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009769
9770 }
9771 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009772 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009773 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009774 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009775 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009776 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009777 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009778 }
9779 }
9780 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009781 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009782}
9783
9784/*
9785 * Get the terminal code for a terminal option.
9786 * Returns NULL when not found.
9787 */
9788 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009789get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009790{
9791 int opt_idx;
9792 char_u *varp;
9793
9794 if (tname[0] != 't' || tname[1] != '_' ||
9795 tname[2] == NUL || tname[3] == NUL)
9796 return NULL;
9797 if ((opt_idx = findoption(tname)) >= 0)
9798 {
9799 varp = get_varp(&(options[opt_idx]));
9800 if (varp != NULL)
9801 varp = *(char_u **)(varp);
9802 return varp;
9803 }
9804 return find_termcode(tname + 2);
9805}
9806
9807 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009808get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009809{
9810 int i;
9811
9812 i = findoption((char_u *)"hl");
9813 if (i >= 0)
9814 return options[i].def_val[VI_DEFAULT];
9815 return (char_u *)NULL;
9816}
9817
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009818#if defined(FEAT_MBYTE) || defined(PROTO)
9819 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009820get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009821{
9822 int i;
9823
9824 i = findoption((char_u *)"enc");
9825 if (i >= 0)
9826 return options[i].def_val[VI_DEFAULT];
9827 return (char_u *)NULL;
9828}
9829#endif
9830
Bram Moolenaar071d4272004-06-13 20:20:40 +00009831/*
9832 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9833 */
9834 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009835find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009836{
9837 int key;
9838 int modifiers;
9839
9840 /*
9841 * Don't use get_special_key_code() for t_xx, we don't want it to call
9842 * add_termcap_entry().
9843 */
9844 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9845 key = TERMCAP2KEY(arg[2], arg[3]);
9846 else
9847 {
9848 --arg; /* put arg at the '<' */
9849 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009850 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009851 if (modifiers) /* can't handle modifiers here */
9852 key = 0;
9853 }
9854 return key;
9855}
9856
9857/*
9858 * if 'all' == 0: show changed options
9859 * if 'all' == 1: show all normal options
9860 * if 'all' == 2: show all terminal options
9861 */
9862 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009863showoptions(
9864 int all,
9865 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009866{
9867 struct vimoption *p;
9868 int col;
9869 int isterm;
9870 char_u *varp;
9871 struct vimoption **items;
9872 int item_count;
9873 int run;
9874 int row, rows;
9875 int cols;
9876 int i;
9877 int len;
9878
9879#define INC 20
9880#define GAP 3
9881
9882 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9883 PARAM_COUNT));
9884 if (items == NULL)
9885 return;
9886
9887 /* Highlight title */
9888 if (all == 2)
9889 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9890 else if (opt_flags & OPT_GLOBAL)
9891 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9892 else if (opt_flags & OPT_LOCAL)
9893 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9894 else
9895 MSG_PUTS_TITLE(_("\n--- Options ---"));
9896
9897 /*
9898 * do the loop two times:
9899 * 1. display the short items
9900 * 2. display the long items (only strings and numbers)
9901 */
9902 for (run = 1; run <= 2 && !got_int; ++run)
9903 {
9904 /*
9905 * collect the items in items[]
9906 */
9907 item_count = 0;
9908 for (p = &options[0]; p->fullname != NULL; p++)
9909 {
9910 varp = NULL;
9911 isterm = istermoption(p);
9912 if (opt_flags != 0)
9913 {
9914 if (p->indir != PV_NONE && !isterm)
9915 varp = get_varp_scope(p, opt_flags);
9916 }
9917 else
9918 varp = get_varp(p);
9919 if (varp != NULL
9920 && ((all == 2 && isterm)
9921 || (all == 1 && !isterm)
9922 || (all == 0 && !optval_default(p, varp))))
9923 {
9924 if (p->flags & P_BOOL)
9925 len = 1; /* a toggle option fits always */
9926 else
9927 {
9928 option_value2string(p, opt_flags);
9929 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9930 }
9931 if ((len <= INC - GAP && run == 1) ||
9932 (len > INC - GAP && run == 2))
9933 items[item_count++] = p;
9934 }
9935 }
9936
9937 /*
9938 * display the items
9939 */
9940 if (run == 1)
9941 {
9942 cols = (Columns + GAP - 3) / INC;
9943 if (cols == 0)
9944 cols = 1;
9945 rows = (item_count + cols - 1) / cols;
9946 }
9947 else /* run == 2 */
9948 rows = item_count;
9949 for (row = 0; row < rows && !got_int; ++row)
9950 {
9951 msg_putchar('\n'); /* go to next line */
9952 if (got_int) /* 'q' typed in more */
9953 break;
9954 col = 0;
9955 for (i = row; i < item_count; i += rows)
9956 {
9957 msg_col = col; /* make columns */
9958 showoneopt(items[i], opt_flags);
9959 col += INC;
9960 }
9961 out_flush();
9962 ui_breakcheck();
9963 }
9964 }
9965 vim_free(items);
9966}
9967
9968/*
9969 * Return TRUE if option "p" has its default value.
9970 */
9971 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009972optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009973{
9974 int dvi;
9975
9976 if (varp == NULL)
9977 return TRUE; /* hidden option is always at default */
9978 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9979 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009980 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009981 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009982 /* the cast to long is required for Manx C, long_i is
9983 * needed for MSVC */
9984 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009985 /* P_STRING */
9986 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9987}
9988
9989/*
9990 * showoneopt: show the value of one option
9991 * must not be called with a hidden option!
9992 */
9993 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009994showoneopt(
9995 struct vimoption *p,
9996 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009997{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009998 char_u *varp;
9999 int save_silent = silent_mode;
10000
10001 silent_mode = FALSE;
10002 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010003
10004 varp = get_varp_scope(p, opt_flags);
10005
10006 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
10007 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
10008 ? !curbufIsChanged() : !*(int *)varp))
10009 MSG_PUTS("no");
10010 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
10011 MSG_PUTS("--");
10012 else
10013 MSG_PUTS(" ");
10014 MSG_PUTS(p->fullname);
10015 if (!(p->flags & P_BOOL))
10016 {
10017 msg_putchar('=');
10018 /* put value string in NameBuff */
10019 option_value2string(p, opt_flags);
10020 msg_outtrans(NameBuff);
10021 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010022
10023 silent_mode = save_silent;
10024 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010025}
10026
10027/*
10028 * Write modified options as ":set" commands to a file.
10029 *
10030 * There are three values for "opt_flags":
10031 * OPT_GLOBAL: Write global option values and fresh values of
10032 * buffer-local options (used for start of a session
10033 * file).
10034 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
10035 * curwin (used for a vimrc file).
10036 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
10037 * and local values for window-local options of
10038 * curwin. Local values are also written when at the
10039 * default value, because a modeline or autocommand
10040 * may have set them when doing ":edit file" and the
10041 * user has set them back at the default or fresh
10042 * value.
10043 * When "local_only" is TRUE, don't write fresh
10044 * values, only local values (for ":mkview").
10045 * (fresh value = value used for a new buffer or window for a local option).
10046 *
10047 * Return FAIL on error, OK otherwise.
10048 */
10049 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010050makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010051{
10052 struct vimoption *p;
10053 char_u *varp; /* currently used value */
10054 char_u *varp_fresh; /* local value */
10055 char_u *varp_local = NULL; /* fresh value */
10056 char *cmd;
10057 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010058 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010059
10060 /*
10061 * The options that don't have a default (terminal name, columns, lines)
10062 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010063 * Do the loop over "options[]" twice: once for options with the
10064 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010065 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010066 for (pri = 1; pri >= 0; --pri)
10067 {
10068 for (p = &options[0]; !istermoption(p); p++)
10069 if (!(p->flags & P_NO_MKRC)
10070 && !istermoption(p)
10071 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010072 {
10073 /* skip global option when only doing locals */
10074 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10075 continue;
10076
10077 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10078 * file, they are always buffer-specific. */
10079 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10080 continue;
10081
10082 /* Global values are only written when not at the default value. */
10083 varp = get_varp_scope(p, opt_flags);
10084 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10085 continue;
10086
10087 round = 2;
10088 if (p->indir != PV_NONE)
10089 {
10090 if (p->var == VAR_WIN)
10091 {
10092 /* skip window-local option when only doing globals */
10093 if (!(opt_flags & OPT_LOCAL))
10094 continue;
10095 /* When fresh value of window-local option is not at the
10096 * default, need to write it too. */
10097 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10098 {
10099 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10100 if (!optval_default(p, varp_fresh))
10101 {
10102 round = 1;
10103 varp_local = varp;
10104 varp = varp_fresh;
10105 }
10106 }
10107 }
10108 }
10109
10110 /* Round 1: fresh value for window-local options.
10111 * Round 2: other values */
10112 for ( ; round <= 2; varp = varp_local, ++round)
10113 {
10114 if (round == 1 || (opt_flags & OPT_GLOBAL))
10115 cmd = "set";
10116 else
10117 cmd = "setlocal";
10118
10119 if (p->flags & P_BOOL)
10120 {
10121 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10122 return FAIL;
10123 }
10124 else if (p->flags & P_NUM)
10125 {
10126 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10127 return FAIL;
10128 }
10129 else /* P_STRING */
10130 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010131#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10132 int do_endif = FALSE;
10133
Bram Moolenaar071d4272004-06-13 20:20:40 +000010134 /* Don't set 'syntax' and 'filetype' again if the value is
10135 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010136 if (
10137# if defined(FEAT_SYN_HL)
10138 p->indir == PV_SYN
10139# if defined(FEAT_AUTOCMD)
10140 ||
10141# endif
10142# endif
10143# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010144 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010145# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010146 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010147 {
10148 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10149 *(char_u **)(varp)) < 0
10150 || put_eol(fd) < 0)
10151 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010152 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010153 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010154#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010155 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10156 (p->flags & P_EXPAND) != 0) == FAIL)
10157 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010158#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10159 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010160 {
10161 if (put_line(fd, "endif") == FAIL)
10162 return FAIL;
10163 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010164#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010165 }
10166 }
10167 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010168 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010169 return OK;
10170}
10171
10172#if defined(FEAT_FOLDING) || defined(PROTO)
10173/*
10174 * Generate set commands for the local fold options only. Used when
10175 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10176 */
10177 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010178makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010179{
10180 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10181# ifdef FEAT_EVAL
10182 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10183 == FAIL
10184# endif
10185 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10186 == FAIL
10187 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10188 == FAIL
10189 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10190 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10191 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10192 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10193 )
10194 return FAIL;
10195
10196 return OK;
10197}
10198#endif
10199
10200 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010201put_setstring(
10202 FILE *fd,
10203 char *cmd,
10204 char *name,
10205 char_u **valuep,
10206 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010207{
10208 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010209 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010210
10211 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10212 return FAIL;
10213 if (*valuep != NULL)
10214 {
10215 /* Output 'pastetoggle' as key names. For other
10216 * options some characters have to be escaped with
10217 * CTRL-V or backslash */
10218 if (valuep == &p_pt)
10219 {
10220 s = *valuep;
10221 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010222 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010223 return FAIL;
10224 }
10225 else if (expand)
10226 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010227 buf = alloc(MAXPATHL);
10228 if (buf == NULL)
10229 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010230 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10231 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010232 {
10233 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010234 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010235 }
10236 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237 }
10238 else if (put_escstr(fd, *valuep, 2) == FAIL)
10239 return FAIL;
10240 }
10241 if (put_eol(fd) < 0)
10242 return FAIL;
10243 return OK;
10244}
10245
10246 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010247put_setnum(
10248 FILE *fd,
10249 char *cmd,
10250 char *name,
10251 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010252{
10253 long wc;
10254
10255 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10256 return FAIL;
10257 if (wc_use_keyname((char_u *)valuep, &wc))
10258 {
10259 /* print 'wildchar' and 'wildcharm' as a key name */
10260 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10261 return FAIL;
10262 }
10263 else if (fprintf(fd, "%ld", *valuep) < 0)
10264 return FAIL;
10265 if (put_eol(fd) < 0)
10266 return FAIL;
10267 return OK;
10268}
10269
10270 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010271put_setbool(
10272 FILE *fd,
10273 char *cmd,
10274 char *name,
10275 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010276{
Bram Moolenaar893de922007-10-02 18:40:57 +000010277 if (value < 0) /* global/local option using global value */
10278 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010279 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10280 || put_eol(fd) < 0)
10281 return FAIL;
10282 return OK;
10283}
10284
10285/*
10286 * Clear all the terminal options.
10287 * If the option has been allocated, free the memory.
10288 * Terminal options are never hidden or indirect.
10289 */
10290 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010291clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010292{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010293 /*
10294 * Reset a few things before clearing the old options. This may cause
10295 * outputting a few things that the terminal doesn't understand, but the
10296 * screen will be cleared later, so this is OK.
10297 */
10298#ifdef FEAT_MOUSE_TTY
10299 mch_setmouse(FALSE); /* switch mouse off */
10300#endif
10301#ifdef FEAT_TITLE
10302 mch_restore_title(3); /* restore window titles */
10303#endif
10304#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10305 /* When starting the GUI close the display opened for the clipboard.
10306 * After restoring the title, because that will need the display. */
10307 if (gui.starting)
10308 clear_xterm_clip();
10309#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010310 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010311
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010312 free_termoptions();
10313}
10314
10315 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010316free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010317{
10318 struct vimoption *p;
10319
Bram Moolenaar071d4272004-06-13 20:20:40 +000010320 for (p = &options[0]; p->fullname != NULL; p++)
10321 if (istermoption(p))
10322 {
10323 if (p->flags & P_ALLOCED)
10324 free_string_option(*(char_u **)(p->var));
10325 if (p->flags & P_DEF_ALLOCED)
10326 free_string_option(p->def_val[VI_DEFAULT]);
10327 *(char_u **)(p->var) = empty_option;
10328 p->def_val[VI_DEFAULT] = empty_option;
10329 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10330 }
10331 clear_termcodes();
10332}
10333
10334/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010335 * Free the string for one term option, if it was allocated.
10336 * Set the string to empty_option and clear allocated flag.
10337 * "var" points to the option value.
10338 */
10339 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010340free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010341{
10342 struct vimoption *p;
10343
10344 for (p = &options[0]; p->fullname != NULL; p++)
10345 if (p->var == var)
10346 {
10347 if (p->flags & P_ALLOCED)
10348 free_string_option(*(char_u **)(p->var));
10349 *(char_u **)(p->var) = empty_option;
10350 p->flags &= ~P_ALLOCED;
10351 break;
10352 }
10353}
10354
10355/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010356 * Set the terminal option defaults to the current value.
10357 * Used after setting the terminal name.
10358 */
10359 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010360set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010361{
10362 struct vimoption *p;
10363
10364 for (p = &options[0]; p->fullname != NULL; p++)
10365 {
10366 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10367 {
10368 if (p->flags & P_DEF_ALLOCED)
10369 {
10370 free_string_option(p->def_val[VI_DEFAULT]);
10371 p->flags &= ~P_DEF_ALLOCED;
10372 }
10373 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10374 if (p->flags & P_ALLOCED)
10375 {
10376 p->flags |= P_DEF_ALLOCED;
10377 p->flags &= ~P_ALLOCED; /* don't free the value now */
10378 }
10379 }
10380 }
10381}
10382
10383/*
10384 * return TRUE if 'p' starts with 't_'
10385 */
10386 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010387istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010388{
10389 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10390}
10391
10392/*
10393 * Compute columns for ruler and shown command. 'sc_col' is also used to
10394 * decide what the maximum length of a message on the status line can be.
10395 * If there is a status line for the last window, 'sc_col' is independent
10396 * of 'ru_col'.
10397 */
10398
10399#define COL_RULER 17 /* columns needed by standard ruler */
10400
10401 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010402comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010403{
10404#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010405 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010406
10407 sc_col = 0;
10408 ru_col = 0;
10409 if (p_ru)
10410 {
10411#ifdef FEAT_STL_OPT
10412 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10413#else
10414 ru_col = COL_RULER + 1;
10415#endif
10416 /* no last status line, adjust sc_col */
10417 if (!last_has_status)
10418 sc_col = ru_col;
10419 }
10420 if (p_sc)
10421 {
10422 sc_col += SHOWCMD_COLS;
10423 if (!p_ru || last_has_status) /* no need for separating space */
10424 ++sc_col;
10425 }
10426 sc_col = Columns - sc_col;
10427 ru_col = Columns - ru_col;
10428 if (sc_col <= 0) /* screen too narrow, will become a mess */
10429 sc_col = 1;
10430 if (ru_col <= 0)
10431 ru_col = 1;
10432#else
10433 sc_col = Columns;
10434 ru_col = Columns;
10435#endif
10436}
10437
10438/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010439 * Unset local option value, similar to ":set opt<".
10440 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010441 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010442unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010443{
10444 struct vimoption *p;
10445 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010446 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010447
10448 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010449 if (opt_idx < 0)
10450 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010451 p = &(options[opt_idx]);
10452
10453 switch ((int)p->indir)
10454 {
10455 /* global option with local value: use local value if it's been set */
10456 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010457 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010458 break;
10459 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010460 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010461 break;
10462 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010463 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010464 break;
10465 case PV_AR:
10466 buf->b_p_ar = -1;
10467 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010468 case PV_BKC:
10469 clear_string_option(&buf->b_p_bkc);
10470 buf->b_bkc_flags = 0;
10471 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010472 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010473 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010474 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010475 case PV_TC:
10476 clear_string_option(&buf->b_p_tc);
10477 buf->b_tc_flags = 0;
10478 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010479#ifdef FEAT_FIND_ID
10480 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010481 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010482 break;
10483 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010484 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010485 break;
10486#endif
10487#ifdef FEAT_INS_EXPAND
10488 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010489 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010490 break;
10491 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010492 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010493 break;
10494#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010495 case PV_FP:
10496 clear_string_option(&buf->b_p_fp);
10497 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010498#ifdef FEAT_QUICKFIX
10499 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010500 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010501 break;
10502 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010503 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010504 break;
10505 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010506 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010507 break;
10508#endif
10509#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10510 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010511 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010512 break;
10513#endif
10514#if defined(FEAT_CRYPT)
10515 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010516 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010517 break;
10518#endif
10519#ifdef FEAT_STL_OPT
10520 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010521 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010522 break;
10523#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010524 case PV_UL:
10525 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10526 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010527#ifdef FEAT_LISP
10528 case PV_LW:
10529 clear_string_option(&buf->b_p_lw);
10530 break;
10531#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010532#ifdef FEAT_MBYTE
10533 case PV_MENC:
10534 clear_string_option(&buf->b_p_menc);
10535 break;
10536#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010537 }
10538}
10539
10540/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010541 * Get pointer to option variable, depending on local or global scope.
10542 */
10543 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010544get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010545{
10546 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10547 {
10548 if (p->var == VAR_WIN)
10549 return (char_u *)GLOBAL_WO(get_varp(p));
10550 return p->var;
10551 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010552 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010553 {
10554 switch ((int)p->indir)
10555 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010556 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010557#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010558 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10559 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10560 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010561#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010562 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10563 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10564 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010565 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010566 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010567 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010568#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010569 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10570 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010571#endif
10572#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010573 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10574 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010575#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010576#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10577 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10578#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010579#if defined(FEAT_CRYPT)
10580 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10581#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010582#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010583 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010584#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010585 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010586#ifdef FEAT_LISP
10587 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10588#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010589 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010590#ifdef FEAT_MBYTE
10591 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10592#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010593 }
10594 return NULL; /* "cannot happen" */
10595 }
10596 return get_varp(p);
10597}
10598
10599/*
10600 * Get pointer to option variable.
10601 */
10602 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010603get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010604{
10605 /* hidden option, always return NULL */
10606 if (p->var == NULL)
10607 return NULL;
10608
10609 switch ((int)p->indir)
10610 {
10611 case PV_NONE: return p->var;
10612
10613 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010614 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010615 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010616 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010617 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010618 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010619 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010620 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010621 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010622 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010623 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010624 case PV_TC: return *curbuf->b_p_tc != NUL
10625 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010626 case PV_BKC: return *curbuf->b_p_bkc != NUL
10627 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010628#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010629 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010630 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010631 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010632 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10633#endif
10634#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010635 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010636 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010637 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010638 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10639#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010640 case PV_FP: return *curbuf->b_p_fp != NUL
10641 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010642#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010643 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010644 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010645 case PV_GP: return *curbuf->b_p_gp != NUL
10646 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10647 case PV_MP: return *curbuf->b_p_mp != NUL
10648 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010649#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010650#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10651 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10652 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10653#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010654#if defined(FEAT_CRYPT)
10655 case PV_CM: return *curbuf->b_p_cm != NUL
10656 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10657#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010658#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010659 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010660 ? (char_u *)&(curwin->w_p_stl) : p->var;
10661#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010662 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10663 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010664#ifdef FEAT_LISP
10665 case PV_LW: return *curbuf->b_p_lw != NUL
10666 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10667#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010668#ifdef FEAT_MBYTE
10669 case PV_MENC: return *curbuf->b_p_menc != NUL
10670 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010672
10673#ifdef FEAT_ARABIC
10674 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10675#endif
10676 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010677#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010678 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10679#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010680#ifdef FEAT_SYN_HL
10681 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10682 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010683 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010684#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010685#ifdef FEAT_DIFF
10686 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10687#endif
10688#ifdef FEAT_FOLDING
10689 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10690 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10691 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10692 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10693 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10694 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10695 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10696# ifdef FEAT_EVAL
10697 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10698 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10699# endif
10700 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10701#endif
10702 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010703 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010704#ifdef FEAT_LINEBREAK
10705 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10706#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010707#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010708 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010709 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10710#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010711#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10712 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10713#endif
10714#ifdef FEAT_RIGHTLEFT
10715 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10716 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10717#endif
10718 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10719 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10720#ifdef FEAT_LINEBREAK
10721 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010722 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10723 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010724#endif
10725#ifdef FEAT_SCROLLBIND
10726 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10727#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010728#ifdef FEAT_CURSORBIND
10729 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10730#endif
10731#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010732 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10733 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10734#endif
10735#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +020010736 case PV_TK: return (char_u *)&(curwin->w_p_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010737 case PV_TMS: return (char_u *)&(curwin->w_p_tms);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010738#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010739
10740 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10741 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10742#ifdef FEAT_MBYTE
10743 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10744#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010745 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10746 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010747 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10748 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10749#ifdef FEAT_CINDENT
10750 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10751 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10752 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10753#endif
10754#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10755 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10756#endif
10757#ifdef FEAT_COMMENTS
10758 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10759#endif
10760#ifdef FEAT_FOLDING
10761 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10762#endif
10763#ifdef FEAT_INS_EXPAND
10764 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10765#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010766#ifdef FEAT_COMPL_FUNC
10767 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010768 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010769#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010770 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010771 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010772 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10773#ifdef FEAT_MBYTE
10774 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10775#endif
10776 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10777#ifdef FEAT_AUTOCMD
10778 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10779#endif
10780 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010781 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010782 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10783 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10784 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10785 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10786#ifdef FEAT_FIND_ID
10787# ifdef FEAT_EVAL
10788 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10789# endif
10790#endif
10791#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10792 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10793 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10794#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010795#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010796 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10797#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010798#ifdef FEAT_CRYPT
10799 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10800#endif
10801#ifdef FEAT_LISP
10802 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10803#endif
10804 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10805 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10806 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10807 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10808 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010809 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010810#ifdef FEAT_TEXTOBJ
10811 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10812#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010813 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10814#ifdef FEAT_SMARTINDENT
10815 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10816#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010817 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010818 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10819#ifdef FEAT_SEARCHPATH
10820 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10821#endif
10822 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10823#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010824 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010825 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10826#endif
10827#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010828 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10829 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10830 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010831#endif
10832 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10833 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10834 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10835 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010836#ifdef FEAT_PERSISTENT_UNDO
10837 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10838#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010839 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10840#ifdef FEAT_KEYMAP
10841 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10842#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010843#ifdef FEAT_SIGNS
10844 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10845#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010846 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010847 }
10848 /* always return a valid pointer to avoid a crash! */
10849 return (char_u *)&(curbuf->b_p_wm);
10850}
10851
10852/*
10853 * Get the value of 'equalprg', either the buffer-local one or the global one.
10854 */
10855 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010856get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010857{
10858 if (*curbuf->b_p_ep == NUL)
10859 return p_ep;
10860 return curbuf->b_p_ep;
10861}
10862
10863#if defined(FEAT_WINDOWS) || defined(PROTO)
10864/*
10865 * Copy options from one window to another.
10866 * Used when splitting a window.
10867 */
10868 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010869win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010870{
10871 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10872 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10873# ifdef FEAT_RIGHTLEFT
10874# ifdef FEAT_FKMAP
10875 /* Is this right? */
10876 wp_to->w_farsi = wp_from->w_farsi;
10877# endif
10878# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010879#if defined(FEAT_LINEBREAK)
10880 briopt_check(wp_to);
10881#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010882}
10883#endif
10884
10885/*
10886 * Copy the options from one winopt_T to another.
10887 * Doesn't free the old option values in "to", use clear_winopt() for that.
10888 * The 'scroll' option is not copied, because it depends on the window height.
10889 * The 'previewwindow' option is reset, there can be only one preview window.
10890 */
10891 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010892copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010893{
10894#ifdef FEAT_ARABIC
10895 to->wo_arab = from->wo_arab;
10896#endif
10897 to->wo_list = from->wo_list;
10898 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010899 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010900#ifdef FEAT_LINEBREAK
10901 to->wo_nuw = from->wo_nuw;
10902#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010903#ifdef FEAT_RIGHTLEFT
10904 to->wo_rl = from->wo_rl;
10905 to->wo_rlc = vim_strsave(from->wo_rlc);
10906#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010907#ifdef FEAT_STL_OPT
10908 to->wo_stl = vim_strsave(from->wo_stl);
10909#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010910 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010911#ifdef FEAT_DIFF
10912 to->wo_wrap_save = from->wo_wrap_save;
10913#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010914#ifdef FEAT_LINEBREAK
10915 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010916 to->wo_bri = from->wo_bri;
10917 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010918#endif
10919#ifdef FEAT_SCROLLBIND
10920 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010921 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010922#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010923#ifdef FEAT_CURSORBIND
10924 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010925 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010926#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010927#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010928 to->wo_spell = from->wo_spell;
10929#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010930#ifdef FEAT_SYN_HL
10931 to->wo_cuc = from->wo_cuc;
10932 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010933 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010934#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010935#ifdef FEAT_DIFF
10936 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010937 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010938#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010939#ifdef FEAT_CONCEAL
10940 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010941 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010942#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010943#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010944 to->wo_tk = vim_strsave(from->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010945 to->wo_tms = vim_strsave(from->wo_tms);
10946#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010947#ifdef FEAT_FOLDING
10948 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010949 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010950 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010951 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010952 to->wo_fdi = vim_strsave(from->wo_fdi);
10953 to->wo_fml = from->wo_fml;
10954 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010955 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010956 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010957 to->wo_fdm_save = from->wo_diff_saved
10958 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010959 to->wo_fdn = from->wo_fdn;
10960# ifdef FEAT_EVAL
10961 to->wo_fde = vim_strsave(from->wo_fde);
10962 to->wo_fdt = vim_strsave(from->wo_fdt);
10963# endif
10964 to->wo_fmr = vim_strsave(from->wo_fmr);
10965#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010966#ifdef FEAT_SIGNS
10967 to->wo_scl = vim_strsave(from->wo_scl);
10968#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010969 check_winopt(to); /* don't want NULL pointers */
10970}
10971
10972/*
10973 * Check string options in a window for a NULL value.
10974 */
10975 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010976check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010977{
10978 check_winopt(&win->w_onebuf_opt);
10979 check_winopt(&win->w_allbuf_opt);
10980}
10981
10982/*
10983 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10984 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010985 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010986check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010987{
10988#ifdef FEAT_FOLDING
10989 check_string_option(&wop->wo_fdi);
10990 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010991 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010992# ifdef FEAT_EVAL
10993 check_string_option(&wop->wo_fde);
10994 check_string_option(&wop->wo_fdt);
10995# endif
10996 check_string_option(&wop->wo_fmr);
10997#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010998#ifdef FEAT_SIGNS
10999 check_string_option(&wop->wo_scl);
11000#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011001#ifdef FEAT_RIGHTLEFT
11002 check_string_option(&wop->wo_rlc);
11003#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011004#ifdef FEAT_STL_OPT
11005 check_string_option(&wop->wo_stl);
11006#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011007#ifdef FEAT_SYN_HL
11008 check_string_option(&wop->wo_cc);
11009#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011010#ifdef FEAT_CONCEAL
11011 check_string_option(&wop->wo_cocu);
11012#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011013#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011014 check_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011015 check_string_option(&wop->wo_tms);
11016#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011017#ifdef FEAT_LINEBREAK
11018 check_string_option(&wop->wo_briopt);
11019#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011020}
11021
11022/*
11023 * Free the allocated memory inside a winopt_T.
11024 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011025 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011026clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011027{
11028#ifdef FEAT_FOLDING
11029 clear_string_option(&wop->wo_fdi);
11030 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011031 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011032# ifdef FEAT_EVAL
11033 clear_string_option(&wop->wo_fde);
11034 clear_string_option(&wop->wo_fdt);
11035# endif
11036 clear_string_option(&wop->wo_fmr);
11037#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011038#ifdef FEAT_SIGNS
11039 clear_string_option(&wop->wo_scl);
11040#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011041#ifdef FEAT_LINEBREAK
11042 clear_string_option(&wop->wo_briopt);
11043#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011044#ifdef FEAT_RIGHTLEFT
11045 clear_string_option(&wop->wo_rlc);
11046#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011047#ifdef FEAT_STL_OPT
11048 clear_string_option(&wop->wo_stl);
11049#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011050#ifdef FEAT_SYN_HL
11051 clear_string_option(&wop->wo_cc);
11052#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011053#ifdef FEAT_CONCEAL
11054 clear_string_option(&wop->wo_cocu);
11055#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011056#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011057 clear_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011058 clear_string_option(&wop->wo_tms);
11059#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011060}
11061
11062/*
11063 * Copy global option values to local options for one buffer.
11064 * Used when creating a new buffer and sometimes when entering a buffer.
11065 * flags:
11066 * BCO_ENTER We will enter the buf buffer.
11067 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11068 * appropriate.
11069 * BCO_NOHELP Don't copy the values to a help buffer.
11070 */
11071 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011072buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011073{
11074 int should_copy = TRUE;
11075 char_u *save_p_isk = NULL; /* init for GCC */
11076 int dont_do_help;
11077 int did_isk = FALSE;
11078
11079 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011080 * Skip this when the option defaults have not been set yet. Happens when
11081 * main() allocates the first buffer.
11082 */
11083 if (p_cpo != NULL)
11084 {
11085 /*
11086 * Always copy when entering and 'cpo' contains 'S'.
11087 * Don't copy when already initialized.
11088 * Don't copy when 'cpo' contains 's' and not entering.
11089 * 'S' BCO_ENTER initialized 's' should_copy
11090 * yes yes X X TRUE
11091 * yes no yes X FALSE
11092 * no X yes X FALSE
11093 * X no no yes FALSE
11094 * X no no no TRUE
11095 * no yes no X TRUE
11096 */
11097 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11098 && (buf->b_p_initialized
11099 || (!(flags & BCO_ENTER)
11100 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11101 should_copy = FALSE;
11102
11103 if (should_copy || (flags & BCO_ALWAYS))
11104 {
11105 /* Don't copy the options specific to a help buffer when
11106 * BCO_NOHELP is given or the options were initialized already
11107 * (jumping back to a help file with CTRL-T or CTRL-O) */
11108 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11109 || buf->b_p_initialized;
11110 if (dont_do_help) /* don't free b_p_isk */
11111 {
11112 save_p_isk = buf->b_p_isk;
11113 buf->b_p_isk = NULL;
11114 }
11115 /*
11116 * Always free the allocated strings.
11117 * If not already initialized, set 'readonly' and copy 'fileformat'.
11118 */
11119 if (!buf->b_p_initialized)
11120 {
11121 free_buf_options(buf, TRUE);
11122 buf->b_p_ro = FALSE; /* don't copy readonly */
11123 buf->b_p_tx = p_tx;
11124#ifdef FEAT_MBYTE
11125 buf->b_p_fenc = vim_strsave(p_fenc);
11126#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011127 switch (*p_ffs)
11128 {
11129 case 'm':
11130 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11131 case 'd':
11132 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11133 case 'u':
11134 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11135 default:
11136 buf->b_p_ff = vim_strsave(p_ff);
11137 }
11138 if (buf->b_p_ff != NULL)
11139 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011140 buf->b_p_bh = empty_option;
11141 buf->b_p_bt = empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011142 }
11143 else
11144 free_buf_options(buf, FALSE);
11145
11146 buf->b_p_ai = p_ai;
11147 buf->b_p_ai_nopaste = p_ai_nopaste;
11148 buf->b_p_sw = p_sw;
11149 buf->b_p_tw = p_tw;
11150 buf->b_p_tw_nopaste = p_tw_nopaste;
11151 buf->b_p_tw_nobin = p_tw_nobin;
11152 buf->b_p_wm = p_wm;
11153 buf->b_p_wm_nopaste = p_wm_nopaste;
11154 buf->b_p_wm_nobin = p_wm_nobin;
11155 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011156#ifdef FEAT_MBYTE
11157 buf->b_p_bomb = p_bomb;
11158#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011159 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011160 buf->b_p_et = p_et;
11161 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011162 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011163 buf->b_p_ml = p_ml;
11164 buf->b_p_ml_nobin = p_ml_nobin;
11165 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011166 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011167#ifdef FEAT_INS_EXPAND
11168 buf->b_p_cpt = vim_strsave(p_cpt);
11169#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011170#ifdef FEAT_COMPL_FUNC
11171 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011172 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011173#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011174 buf->b_p_sts = p_sts;
11175 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011176 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011177#ifdef FEAT_COMMENTS
11178 buf->b_p_com = vim_strsave(p_com);
11179#endif
11180#ifdef FEAT_FOLDING
11181 buf->b_p_cms = vim_strsave(p_cms);
11182#endif
11183 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011184 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011185 buf->b_p_nf = vim_strsave(p_nf);
11186 buf->b_p_mps = vim_strsave(p_mps);
11187#ifdef FEAT_SMARTINDENT
11188 buf->b_p_si = p_si;
11189#endif
11190 buf->b_p_ci = p_ci;
11191#ifdef FEAT_CINDENT
11192 buf->b_p_cin = p_cin;
11193 buf->b_p_cink = vim_strsave(p_cink);
11194 buf->b_p_cino = vim_strsave(p_cino);
11195#endif
11196#ifdef FEAT_AUTOCMD
11197 /* Don't copy 'filetype', it must be detected */
11198 buf->b_p_ft = empty_option;
11199#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011200 buf->b_p_pi = p_pi;
11201#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11202 buf->b_p_cinw = vim_strsave(p_cinw);
11203#endif
11204#ifdef FEAT_LISP
11205 buf->b_p_lisp = p_lisp;
11206#endif
11207#ifdef FEAT_SYN_HL
11208 /* Don't copy 'syntax', it must be set */
11209 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011210 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011211 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011212#endif
11213#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011214 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011215 (void)compile_cap_prog(&buf->b_s);
11216 buf->b_s.b_p_spf = vim_strsave(p_spf);
11217 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011218#endif
11219#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11220 buf->b_p_inde = vim_strsave(p_inde);
11221 buf->b_p_indk = vim_strsave(p_indk);
11222#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011223 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011224#if defined(FEAT_EVAL)
11225 buf->b_p_fex = vim_strsave(p_fex);
11226#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011227#ifdef FEAT_CRYPT
11228 buf->b_p_key = vim_strsave(p_key);
11229#endif
11230#ifdef FEAT_SEARCHPATH
11231 buf->b_p_sua = vim_strsave(p_sua);
11232#endif
11233#ifdef FEAT_KEYMAP
11234 buf->b_p_keymap = vim_strsave(p_keymap);
11235 buf->b_kmap_state |= KEYMAP_INIT;
11236#endif
11237 /* This isn't really an option, but copying the langmap and IME
11238 * state from the current buffer is better than resetting it. */
11239 buf->b_p_iminsert = p_iminsert;
11240 buf->b_p_imsearch = p_imsearch;
11241
11242 /* options that are normally global but also have a local value
11243 * are not copied, start using the global value */
11244 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011245 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011246 buf->b_p_bkc = empty_option;
11247 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011248#ifdef FEAT_QUICKFIX
11249 buf->b_p_gp = empty_option;
11250 buf->b_p_mp = empty_option;
11251 buf->b_p_efm = empty_option;
11252#endif
11253 buf->b_p_ep = empty_option;
11254 buf->b_p_kp = empty_option;
11255 buf->b_p_path = empty_option;
11256 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011257 buf->b_p_tc = empty_option;
11258 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011259#ifdef FEAT_FIND_ID
11260 buf->b_p_def = empty_option;
11261 buf->b_p_inc = empty_option;
11262# ifdef FEAT_EVAL
11263 buf->b_p_inex = vim_strsave(p_inex);
11264# endif
11265#endif
11266#ifdef FEAT_INS_EXPAND
11267 buf->b_p_dict = empty_option;
11268 buf->b_p_tsr = empty_option;
11269#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011270#ifdef FEAT_TEXTOBJ
11271 buf->b_p_qe = vim_strsave(p_qe);
11272#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011273#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11274 buf->b_p_bexpr = empty_option;
11275#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011276#if defined(FEAT_CRYPT)
11277 buf->b_p_cm = empty_option;
11278#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011279#ifdef FEAT_PERSISTENT_UNDO
11280 buf->b_p_udf = p_udf;
11281#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011282#ifdef FEAT_LISP
11283 buf->b_p_lw = empty_option;
11284#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011285#ifdef FEAT_MBYTE
11286 buf->b_p_menc = empty_option;
11287#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011288
11289 /*
11290 * Don't copy the options set by ex_help(), use the saved values,
11291 * when going from a help buffer to a non-help buffer.
11292 * Don't touch these at all when BCO_NOHELP is used and going from
11293 * or to a help buffer.
11294 */
11295 if (dont_do_help)
11296 buf->b_p_isk = save_p_isk;
11297 else
11298 {
11299 buf->b_p_isk = vim_strsave(p_isk);
11300 did_isk = TRUE;
11301 buf->b_p_ts = p_ts;
11302 buf->b_help = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011303 if (buf->b_p_bt[0] == 'h')
11304 clear_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011305 buf->b_p_ma = p_ma;
11306 }
11307 }
11308
11309 /*
11310 * When the options should be copied (ignoring BCO_ALWAYS), set the
11311 * flag that indicates that the options have been initialized.
11312 */
11313 if (should_copy)
11314 buf->b_p_initialized = TRUE;
11315 }
11316
11317 check_buf_options(buf); /* make sure we don't have NULLs */
11318 if (did_isk)
11319 (void)buf_init_chartab(buf, FALSE);
11320}
11321
11322/*
11323 * Reset the 'modifiable' option and its default value.
11324 */
11325 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011326reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011327{
11328 int opt_idx;
11329
11330 curbuf->b_p_ma = FALSE;
11331 p_ma = FALSE;
11332 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011333 if (opt_idx >= 0)
11334 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011335}
11336
11337/*
11338 * Set the global value for 'iminsert' to the local value.
11339 */
11340 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011341set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011342{
11343 p_iminsert = curbuf->b_p_iminsert;
11344}
11345
11346/*
11347 * Set the global value for 'imsearch' to the local value.
11348 */
11349 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011350set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011351{
11352 p_imsearch = curbuf->b_p_imsearch;
11353}
11354
11355#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11356static int expand_option_idx = -1;
11357static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11358static int expand_option_flags = 0;
11359
11360 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011361set_context_in_set_cmd(
11362 expand_T *xp,
11363 char_u *arg,
11364 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011365{
11366 int nextchar;
11367 long_u flags = 0; /* init for GCC */
11368 int opt_idx = 0; /* init for GCC */
11369 char_u *p;
11370 char_u *s;
11371 int is_term_option = FALSE;
11372 int key;
11373
11374 expand_option_flags = opt_flags;
11375
11376 xp->xp_context = EXPAND_SETTINGS;
11377 if (*arg == NUL)
11378 {
11379 xp->xp_pattern = arg;
11380 return;
11381 }
11382 p = arg + STRLEN(arg) - 1;
11383 if (*p == ' ' && *(p - 1) != '\\')
11384 {
11385 xp->xp_pattern = p + 1;
11386 return;
11387 }
11388 while (p > arg)
11389 {
11390 s = p;
11391 /* count number of backslashes before ' ' or ',' */
11392 if (*p == ' ' || *p == ',')
11393 {
11394 while (s > arg && *(s - 1) == '\\')
11395 --s;
11396 }
11397 /* break at a space with an even number of backslashes */
11398 if (*p == ' ' && ((p - s) & 1) == 0)
11399 {
11400 ++p;
11401 break;
11402 }
11403 --p;
11404 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011405 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011406 {
11407 xp->xp_context = EXPAND_BOOL_SETTINGS;
11408 p += 2;
11409 }
11410 if (STRNCMP(p, "inv", 3) == 0)
11411 {
11412 xp->xp_context = EXPAND_BOOL_SETTINGS;
11413 p += 3;
11414 }
11415 xp->xp_pattern = arg = p;
11416 if (*arg == '<')
11417 {
11418 while (*p != '>')
11419 if (*p++ == NUL) /* expand terminal option name */
11420 return;
11421 key = get_special_key_code(arg + 1);
11422 if (key == 0) /* unknown name */
11423 {
11424 xp->xp_context = EXPAND_NOTHING;
11425 return;
11426 }
11427 nextchar = *++p;
11428 is_term_option = TRUE;
11429 expand_option_name[2] = KEY2TERMCAP0(key);
11430 expand_option_name[3] = KEY2TERMCAP1(key);
11431 }
11432 else
11433 {
11434 if (p[0] == 't' && p[1] == '_')
11435 {
11436 p += 2;
11437 if (*p != NUL)
11438 ++p;
11439 if (*p == NUL)
11440 return; /* expand option name */
11441 nextchar = *++p;
11442 is_term_option = TRUE;
11443 expand_option_name[2] = p[-2];
11444 expand_option_name[3] = p[-1];
11445 }
11446 else
11447 {
11448 /* Allow * wildcard */
11449 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11450 p++;
11451 if (*p == NUL)
11452 return;
11453 nextchar = *p;
11454 *p = NUL;
11455 opt_idx = findoption(arg);
11456 *p = nextchar;
11457 if (opt_idx == -1 || options[opt_idx].var == NULL)
11458 {
11459 xp->xp_context = EXPAND_NOTHING;
11460 return;
11461 }
11462 flags = options[opt_idx].flags;
11463 if (flags & P_BOOL)
11464 {
11465 xp->xp_context = EXPAND_NOTHING;
11466 return;
11467 }
11468 }
11469 }
11470 /* handle "-=" and "+=" */
11471 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11472 {
11473 ++p;
11474 nextchar = '=';
11475 }
11476 if ((nextchar != '=' && nextchar != ':')
11477 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11478 {
11479 xp->xp_context = EXPAND_UNSUCCESSFUL;
11480 return;
11481 }
11482 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11483 {
11484 xp->xp_context = EXPAND_OLD_SETTING;
11485 if (is_term_option)
11486 expand_option_idx = -1;
11487 else
11488 expand_option_idx = opt_idx;
11489 xp->xp_pattern = p + 1;
11490 return;
11491 }
11492 xp->xp_context = EXPAND_NOTHING;
11493 if (is_term_option || (flags & P_NUM))
11494 return;
11495
11496 xp->xp_pattern = p + 1;
11497
11498 if (flags & P_EXPAND)
11499 {
11500 p = options[opt_idx].var;
11501 if (p == (char_u *)&p_bdir
11502 || p == (char_u *)&p_dir
11503 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011504 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011505 || p == (char_u *)&p_rtp
11506#ifdef FEAT_SEARCHPATH
11507 || p == (char_u *)&p_cdpath
11508#endif
11509#ifdef FEAT_SESSION
11510 || p == (char_u *)&p_vdir
11511#endif
11512 )
11513 {
11514 xp->xp_context = EXPAND_DIRECTORIES;
11515 if (p == (char_u *)&p_path
11516#ifdef FEAT_SEARCHPATH
11517 || p == (char_u *)&p_cdpath
11518#endif
11519 )
11520 xp->xp_backslash = XP_BS_THREE;
11521 else
11522 xp->xp_backslash = XP_BS_ONE;
11523 }
11524 else
11525 {
11526 xp->xp_context = EXPAND_FILES;
11527 /* for 'tags' need three backslashes for a space */
11528 if (p == (char_u *)&p_tags)
11529 xp->xp_backslash = XP_BS_THREE;
11530 else
11531 xp->xp_backslash = XP_BS_ONE;
11532 }
11533 }
11534
11535 /* For an option that is a list of file names, find the start of the
11536 * last file name. */
11537 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11538 {
11539 /* count number of backslashes before ' ' or ',' */
11540 if (*p == ' ' || *p == ',')
11541 {
11542 s = p;
11543 while (s > xp->xp_pattern && *(s - 1) == '\\')
11544 --s;
11545 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11546 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11547 {
11548 xp->xp_pattern = p + 1;
11549 break;
11550 }
11551 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011552
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011553#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011554 /* for 'spellsuggest' start at "file:" */
11555 if (options[opt_idx].var == (char_u *)&p_sps
11556 && STRNCMP(p, "file:", 5) == 0)
11557 {
11558 xp->xp_pattern = p + 5;
11559 break;
11560 }
11561#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011562 }
11563
11564 return;
11565}
11566
11567 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011568ExpandSettings(
11569 expand_T *xp,
11570 regmatch_T *regmatch,
11571 int *num_file,
11572 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011573{
11574 int num_normal = 0; /* Nr of matching non-term-code settings */
11575 int num_term = 0; /* Nr of matching terminal code settings */
11576 int opt_idx;
11577 int match;
11578 int count = 0;
11579 char_u *str;
11580 int loop;
11581 int is_term_opt;
11582 char_u name_buf[MAX_KEY_NAME_LEN];
11583 static char *(names[]) = {"all", "termcap"};
11584 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11585
11586 /* do this loop twice:
11587 * loop == 0: count the number of matching options
11588 * loop == 1: copy the matching options into allocated memory
11589 */
11590 for (loop = 0; loop <= 1; ++loop)
11591 {
11592 regmatch->rm_ic = ic;
11593 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11594 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011595 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11596 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011597 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11598 {
11599 if (loop == 0)
11600 num_normal++;
11601 else
11602 (*file)[count++] = vim_strsave((char_u *)names[match]);
11603 }
11604 }
11605 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11606 opt_idx++)
11607 {
11608 if (options[opt_idx].var == NULL)
11609 continue;
11610 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11611 && !(options[opt_idx].flags & P_BOOL))
11612 continue;
11613 is_term_opt = istermoption(&options[opt_idx]);
11614 if (is_term_opt && num_normal > 0)
11615 continue;
11616 match = FALSE;
11617 if (vim_regexec(regmatch, str, (colnr_T)0)
11618 || (options[opt_idx].shortname != NULL
11619 && vim_regexec(regmatch,
11620 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11621 match = TRUE;
11622 else if (is_term_opt)
11623 {
11624 name_buf[0] = '<';
11625 name_buf[1] = 't';
11626 name_buf[2] = '_';
11627 name_buf[3] = str[2];
11628 name_buf[4] = str[3];
11629 name_buf[5] = '>';
11630 name_buf[6] = NUL;
11631 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11632 {
11633 match = TRUE;
11634 str = name_buf;
11635 }
11636 }
11637 if (match)
11638 {
11639 if (loop == 0)
11640 {
11641 if (is_term_opt)
11642 num_term++;
11643 else
11644 num_normal++;
11645 }
11646 else
11647 (*file)[count++] = vim_strsave(str);
11648 }
11649 }
11650 /*
11651 * Check terminal key codes, these are not in the option table
11652 */
11653 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11654 {
11655 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11656 {
11657 if (!isprint(str[0]) || !isprint(str[1]))
11658 continue;
11659
11660 name_buf[0] = 't';
11661 name_buf[1] = '_';
11662 name_buf[2] = str[0];
11663 name_buf[3] = str[1];
11664 name_buf[4] = NUL;
11665
11666 match = FALSE;
11667 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11668 match = TRUE;
11669 else
11670 {
11671 name_buf[0] = '<';
11672 name_buf[1] = 't';
11673 name_buf[2] = '_';
11674 name_buf[3] = str[0];
11675 name_buf[4] = str[1];
11676 name_buf[5] = '>';
11677 name_buf[6] = NUL;
11678
11679 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11680 match = TRUE;
11681 }
11682 if (match)
11683 {
11684 if (loop == 0)
11685 num_term++;
11686 else
11687 (*file)[count++] = vim_strsave(name_buf);
11688 }
11689 }
11690
11691 /*
11692 * Check special key names.
11693 */
11694 regmatch->rm_ic = TRUE; /* ignore case here */
11695 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11696 {
11697 name_buf[0] = '<';
11698 STRCPY(name_buf + 1, str);
11699 STRCAT(name_buf, ">");
11700
11701 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11702 {
11703 if (loop == 0)
11704 num_term++;
11705 else
11706 (*file)[count++] = vim_strsave(name_buf);
11707 }
11708 }
11709 }
11710 if (loop == 0)
11711 {
11712 if (num_normal > 0)
11713 *num_file = num_normal;
11714 else if (num_term > 0)
11715 *num_file = num_term;
11716 else
11717 return OK;
11718 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11719 if (*file == NULL)
11720 {
11721 *file = (char_u **)"";
11722 return FAIL;
11723 }
11724 }
11725 }
11726 return OK;
11727}
11728
11729 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011730ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011731{
11732 char_u *var = NULL; /* init for GCC */
11733 char_u *buf;
11734
11735 *num_file = 0;
11736 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11737 if (*file == NULL)
11738 return FAIL;
11739
11740 /*
11741 * For a terminal key code expand_option_idx is < 0.
11742 */
11743 if (expand_option_idx < 0)
11744 {
11745 var = find_termcode(expand_option_name + 2);
11746 if (var == NULL)
11747 expand_option_idx = findoption(expand_option_name);
11748 }
11749
11750 if (expand_option_idx >= 0)
11751 {
11752 /* put string of option value in NameBuff */
11753 option_value2string(&options[expand_option_idx], expand_option_flags);
11754 var = NameBuff;
11755 }
11756 else if (var == NULL)
11757 var = (char_u *)"";
11758
11759 /* A backslash is required before some characters. This is the reverse of
11760 * what happens in do_set(). */
11761 buf = vim_strsave_escaped(var, escape_chars);
11762
11763 if (buf == NULL)
11764 {
11765 vim_free(*file);
11766 *file = NULL;
11767 return FAIL;
11768 }
11769
11770#ifdef BACKSLASH_IN_FILENAME
11771 /* For MS-Windows et al. we don't double backslashes at the start and
11772 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011773 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011774 if (var[0] == '\\' && var[1] == '\\'
11775 && expand_option_idx >= 0
11776 && (options[expand_option_idx].flags & P_EXPAND)
11777 && vim_isfilec(var[2])
11778 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011779 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011780#endif
11781
11782 *file[0] = buf;
11783 *num_file = 1;
11784 return OK;
11785}
11786#endif
11787
11788/*
11789 * Get the value for the numeric or string option *opp in a nice format into
11790 * NameBuff[]. Must not be called with a hidden option!
11791 */
11792 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011793option_value2string(
11794 struct vimoption *opp,
11795 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011796{
11797 char_u *varp;
11798
11799 varp = get_varp_scope(opp, opt_flags);
11800
11801 if (opp->flags & P_NUM)
11802 {
11803 long wc = 0;
11804
11805 if (wc_use_keyname(varp, &wc))
11806 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11807 else if (wc != 0)
11808 STRCPY(NameBuff, transchar((int)wc));
11809 else
11810 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11811 }
11812 else /* P_STRING */
11813 {
11814 varp = *(char_u **)(varp);
11815 if (varp == NULL) /* just in case */
11816 NameBuff[0] = NUL;
11817#ifdef FEAT_CRYPT
11818 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011819 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011820 STRCPY(NameBuff, "*****");
11821#endif
11822 else if (opp->flags & P_EXPAND)
11823 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11824 /* Translate 'pastetoggle' into special key names */
11825 else if ((char_u **)opp->var == &p_pt)
11826 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11827 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011828 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011829 }
11830}
11831
11832/*
11833 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11834 * printed as a keyname.
11835 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11836 */
11837 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011838wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011839{
11840 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11841 {
11842 *wcp = *(long *)varp;
11843 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11844 return TRUE;
11845 }
11846 return FALSE;
11847}
11848
Bram Moolenaar01615492015-02-03 13:00:38 +010011849#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011850/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011851 * Any character has an equivalent 'langmap' character. This is used for
11852 * keyboards that have a special language mode that sends characters above
11853 * 128 (although other characters can be translated too). The "to" field is a
11854 * Vim command character. This avoids having to switch the keyboard back to
11855 * ASCII mode when leaving Insert mode.
11856 *
11857 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11858 * commands.
11859 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11860 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11861 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011862 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011863# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011864/*
11865 * With multi-byte support use growarray for 'langmap' chars >= 256
11866 */
11867typedef struct
11868{
11869 int from;
11870 int to;
11871} langmap_entry_T;
11872
11873static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011874static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011875
11876/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011877 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11878 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011879 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011880 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011881langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011882{
11883 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011884 int a = 0;
11885 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011886
11887 /* Do a binary search for an existing entry. */
11888 while (a != b)
11889 {
11890 int i = (a + b) / 2;
11891 int d = entries[i].from - from;
11892
11893 if (d == 0)
11894 {
11895 entries[i].to = to;
11896 return;
11897 }
11898 if (d < 0)
11899 a = i + 1;
11900 else
11901 b = i;
11902 }
11903
11904 if (ga_grow(&langmap_mapga, 1) != OK)
11905 return; /* out of memory */
11906
11907 /* insert new entry at position "a" */
11908 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11909 mch_memmove(entries + 1, entries,
11910 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11911 ++langmap_mapga.ga_len;
11912 entries[0].from = from;
11913 entries[0].to = to;
11914}
11915
11916/*
11917 * Apply 'langmap' to multi-byte character "c" and return the result.
11918 */
11919 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011920langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011921{
11922 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11923 int a = 0;
11924 int b = langmap_mapga.ga_len;
11925
11926 while (a != b)
11927 {
11928 int i = (a + b) / 2;
11929 int d = entries[i].from - c;
11930
11931 if (d == 0)
11932 return entries[i].to; /* found matching entry */
11933 if (d < 0)
11934 a = i + 1;
11935 else
11936 b = i;
11937 }
11938 return c; /* no entry found, return "c" unmodified */
11939}
11940# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011941
11942 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011943langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011944{
11945 int i;
11946
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011947 for (i = 0; i < 256; i++)
11948 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11949# ifdef FEAT_MBYTE
11950 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11951# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011952}
11953
11954/*
11955 * Called when langmap option is set; the language map can be
11956 * changed at any time!
11957 */
11958 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011959langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011960{
11961 char_u *p;
11962 char_u *p2;
11963 int from, to;
11964
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011965#ifdef FEAT_MBYTE
11966 ga_clear(&langmap_mapga); /* clear the previous map first */
11967#endif
11968 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011969
11970 for (p = p_langmap; p[0] != NUL; )
11971 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011972 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011973 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011974 {
11975 if (p2[0] == '\\' && p2[1] != NUL)
11976 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011977 }
11978 if (p2[0] == ';')
11979 ++p2; /* abcd;ABCD form, p2 points to A */
11980 else
11981 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11982 while (p[0])
11983 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011984 if (p[0] == ',')
11985 {
11986 ++p;
11987 break;
11988 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011989 if (p[0] == '\\' && p[1] != NUL)
11990 ++p;
11991#ifdef FEAT_MBYTE
11992 from = (*mb_ptr2char)(p);
11993#else
11994 from = p[0];
11995#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011996 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011997 if (p2 == NULL)
11998 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011999 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012000 if (p[0] != ',')
12001 {
12002 if (p[0] == '\\')
12003 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012004#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012005 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012006#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012007 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012008#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012009 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012010 }
12011 else
12012 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020012013 if (p2[0] != ',')
12014 {
12015 if (p2[0] == '\\')
12016 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012017#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012018 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012019#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012020 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012021#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012022 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012023 }
12024 if (to == NUL)
12025 {
12026 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
12027 transchar(from));
12028 return;
12029 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012030
12031#ifdef FEAT_MBYTE
12032 if (from >= 256)
12033 langmap_set_entry(from, to);
12034 else
12035#endif
12036 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012037
12038 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012039 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012040 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012041 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012042 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012043 if (*p == ';')
12044 {
12045 p = p2;
12046 if (p[0] != NUL)
12047 {
12048 if (p[0] != ',')
12049 {
12050 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12051 return;
12052 }
12053 ++p;
12054 }
12055 break;
12056 }
12057 }
12058 }
12059 }
12060}
12061#endif
12062
12063/*
12064 * Return TRUE if format option 'x' is in effect.
12065 * Take care of no formatting when 'paste' is set.
12066 */
12067 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012068has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012069{
12070 if (p_paste)
12071 return FALSE;
12072 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12073}
12074
12075/*
12076 * Return TRUE if "x" is present in 'shortmess' option, or
12077 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12078 */
12079 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012080shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012081{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012082 return p_shm != NULL &&
12083 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012084 || (vim_strchr(p_shm, 'a') != NULL
12085 && vim_strchr((char_u *)SHM_A, x) != NULL));
12086}
12087
12088/*
12089 * paste_option_changed() - Called after p_paste was set or reset.
12090 */
12091 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012092paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012093{
12094 static int old_p_paste = FALSE;
12095 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012096 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012097#ifdef FEAT_CMDL_INFO
12098 static int save_ru = 0;
12099#endif
12100#ifdef FEAT_RIGHTLEFT
12101 static int save_ri = 0;
12102 static int save_hkmap = 0;
12103#endif
12104 buf_T *buf;
12105
12106 if (p_paste)
12107 {
12108 /*
12109 * Paste switched from off to on.
12110 * Save the current values, so they can be restored later.
12111 */
12112 if (!old_p_paste)
12113 {
12114 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012115 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012116 {
12117 buf->b_p_tw_nopaste = buf->b_p_tw;
12118 buf->b_p_wm_nopaste = buf->b_p_wm;
12119 buf->b_p_sts_nopaste = buf->b_p_sts;
12120 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012121 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012122 }
12123
12124 /* save global options */
12125 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012126 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012127#ifdef FEAT_CMDL_INFO
12128 save_ru = p_ru;
12129#endif
12130#ifdef FEAT_RIGHTLEFT
12131 save_ri = p_ri;
12132 save_hkmap = p_hkmap;
12133#endif
12134 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012135 p_ai_nopaste = p_ai;
12136 p_et_nopaste = p_et;
12137 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012138 p_tw_nopaste = p_tw;
12139 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012140 }
12141
12142 /*
12143 * Always set the option values, also when 'paste' is set when it is
12144 * already on.
12145 */
12146 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012147 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012148 {
12149 buf->b_p_tw = 0; /* textwidth is 0 */
12150 buf->b_p_wm = 0; /* wrapmargin is 0 */
12151 buf->b_p_sts = 0; /* softtabstop is 0 */
12152 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012153 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012154 }
12155
12156 /* set global options */
12157 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012158 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012159#ifdef FEAT_CMDL_INFO
12160# ifdef FEAT_WINDOWS
12161 if (p_ru)
12162 status_redraw_all(); /* redraw to remove the ruler */
12163# endif
12164 p_ru = 0; /* no ruler */
12165#endif
12166#ifdef FEAT_RIGHTLEFT
12167 p_ri = 0; /* no reverse insert */
12168 p_hkmap = 0; /* no Hebrew keyboard */
12169#endif
12170 /* set global values for local buffer options */
12171 p_tw = 0;
12172 p_wm = 0;
12173 p_sts = 0;
12174 p_ai = 0;
12175 }
12176
12177 /*
12178 * Paste switched from on to off: Restore saved values.
12179 */
12180 else if (old_p_paste)
12181 {
12182 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012183 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012184 {
12185 buf->b_p_tw = buf->b_p_tw_nopaste;
12186 buf->b_p_wm = buf->b_p_wm_nopaste;
12187 buf->b_p_sts = buf->b_p_sts_nopaste;
12188 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012189 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012190 }
12191
12192 /* restore global options */
12193 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012194 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012195#ifdef FEAT_CMDL_INFO
12196# ifdef FEAT_WINDOWS
12197 if (p_ru != save_ru)
12198 status_redraw_all(); /* redraw to draw the ruler */
12199# endif
12200 p_ru = save_ru;
12201#endif
12202#ifdef FEAT_RIGHTLEFT
12203 p_ri = save_ri;
12204 p_hkmap = save_hkmap;
12205#endif
12206 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012207 p_ai = p_ai_nopaste;
12208 p_et = p_et_nopaste;
12209 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012210 p_tw = p_tw_nopaste;
12211 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012212 }
12213
12214 old_p_paste = p_paste;
12215}
12216
12217/*
12218 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12219 *
12220 * Reset 'compatible' and set the values for options that didn't get set yet
12221 * to the Vim defaults.
12222 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012223 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012224 */
12225 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012226vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012227{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012228 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012229 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012230 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012231
12232 if (!option_was_set((char_u *)"cp"))
12233 {
12234 p_cp = FALSE;
12235 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12236 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12237 set_option_default(opt_idx, OPT_FREE, FALSE);
12238 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012239 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012240 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012241
12242 if (fname != NULL)
12243 {
12244 p = vim_getenv(envname, &dofree);
12245 if (p == NULL)
12246 {
12247 /* Set $MYVIMRC to the first vimrc file found. */
12248 p = FullName_save(fname, FALSE);
12249 if (p != NULL)
12250 {
12251 vim_setenv(envname, p);
12252 vim_free(p);
12253 }
12254 }
12255 else if (dofree)
12256 vim_free(p);
12257 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012258}
12259
12260/*
12261 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12262 */
12263 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012264change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012265{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012266 int opt_idx;
12267
Bram Moolenaar071d4272004-06-13 20:20:40 +000012268 if (p_cp != on)
12269 {
12270 p_cp = on;
12271 compatible_set();
12272 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012273 opt_idx = findoption((char_u *)"cp");
12274 if (opt_idx >= 0)
12275 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012276}
12277
12278/*
12279 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012280 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012281 */
12282 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012283option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012284{
12285 int idx;
12286
12287 idx = findoption(name);
12288 if (idx < 0) /* unknown option */
12289 return FALSE;
12290 if (options[idx].flags & P_WAS_SET)
12291 return TRUE;
12292 return FALSE;
12293}
12294
12295/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012296 * Reset the flag indicating option "name" was set.
12297 */
12298 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012299reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012300{
12301 int idx = findoption(name);
12302
12303 if (idx >= 0)
12304 options[idx].flags &= ~P_WAS_SET;
12305}
12306
12307/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012308 * compatible_set() - Called when 'compatible' has been set or unset.
12309 *
12310 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12311 * flag) to a Vi compatible value.
12312 * When 'compatible' is unset: Set all options that have a different default
12313 * for Vim (without the P_VI_DEF flag) to that default.
12314 */
12315 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012316compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012317{
12318 int opt_idx;
12319
12320 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12321 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12322 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12323 set_option_default(opt_idx, OPT_FREE, p_cp);
12324 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012325 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012326}
12327
12328#ifdef FEAT_LINEBREAK
12329
12330# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12331 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012332 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012333# endif
12334
12335/*
12336 * fill_breakat_flags() -- called when 'breakat' changes value.
12337 */
12338 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012339fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012340{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012341 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012342 int i;
12343
12344 for (i = 0; i < 256; i++)
12345 breakat_flags[i] = FALSE;
12346
12347 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012348 for (p = p_breakat; *p; p++)
12349 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012350}
12351
12352# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012353 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012354# endif
12355
12356#endif
12357
12358/*
12359 * Check an option that can be a range of string values.
12360 *
12361 * Return OK for correct value, FAIL otherwise.
12362 * Empty is always OK.
12363 */
12364 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012365check_opt_strings(
12366 char_u *val,
12367 char **values,
12368 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012369{
12370 return opt_strings_flags(val, values, NULL, list);
12371}
12372
12373/*
12374 * Handle an option that can be a range of string values.
12375 * Set a flag in "*flagp" for each string present.
12376 *
12377 * Return OK for correct value, FAIL otherwise.
12378 * Empty is always OK.
12379 */
12380 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012381opt_strings_flags(
12382 char_u *val, /* new value */
12383 char **values, /* array of valid string values */
12384 unsigned *flagp,
12385 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012386{
12387 int i;
12388 int len;
12389 unsigned new_flags = 0;
12390
12391 while (*val)
12392 {
12393 for (i = 0; ; ++i)
12394 {
12395 if (values[i] == NULL) /* val not found in values[] */
12396 return FAIL;
12397
12398 len = (int)STRLEN(values[i]);
12399 if (STRNCMP(values[i], val, len) == 0
12400 && ((list && val[len] == ',') || val[len] == NUL))
12401 {
12402 val += len + (val[len] == ',');
12403 new_flags |= (1 << i);
12404 break; /* check next item in val list */
12405 }
12406 }
12407 }
12408 if (flagp != NULL)
12409 *flagp = new_flags;
12410
12411 return OK;
12412}
12413
12414/*
12415 * Read the 'wildmode' option, fill wim_flags[].
12416 */
12417 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012418check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012419{
12420 char_u new_wim_flags[4];
12421 char_u *p;
12422 int i;
12423 int idx = 0;
12424
12425 for (i = 0; i < 4; ++i)
12426 new_wim_flags[i] = 0;
12427
12428 for (p = p_wim; *p; ++p)
12429 {
12430 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12431 ;
12432 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12433 return FAIL;
12434 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12435 new_wim_flags[idx] |= WIM_LONGEST;
12436 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12437 new_wim_flags[idx] |= WIM_FULL;
12438 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12439 new_wim_flags[idx] |= WIM_LIST;
12440 else
12441 return FAIL;
12442 p += i;
12443 if (*p == NUL)
12444 break;
12445 if (*p == ',')
12446 {
12447 if (idx == 3)
12448 return FAIL;
12449 ++idx;
12450 }
12451 }
12452
12453 /* fill remaining entries with last flag */
12454 while (idx < 3)
12455 {
12456 new_wim_flags[idx + 1] = new_wim_flags[idx];
12457 ++idx;
12458 }
12459
12460 /* only when there are no errors, wim_flags[] is changed */
12461 for (i = 0; i < 4; ++i)
12462 wim_flags[i] = new_wim_flags[i];
12463 return OK;
12464}
12465
12466/*
12467 * Check if backspacing over something is allowed.
12468 */
12469 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012470can_bs(
12471 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012472{
12473 switch (*p_bs)
12474 {
12475 case '2': return TRUE;
12476 case '1': return (what != BS_START);
12477 case '0': return FALSE;
12478 }
12479 return vim_strchr(p_bs, what) != NULL;
12480}
12481
12482/*
12483 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12484 * the file must be considered changed when the value is different.
12485 */
12486 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012487save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012488{
12489 buf->b_start_ffc = *buf->b_p_ff;
12490 buf->b_start_eol = buf->b_p_eol;
12491#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012492 buf->b_start_bomb = buf->b_p_bomb;
12493
Bram Moolenaar071d4272004-06-13 20:20:40 +000012494 /* Only use free/alloc when necessary, they take time. */
12495 if (buf->b_start_fenc == NULL
12496 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12497 {
12498 vim_free(buf->b_start_fenc);
12499 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12500 }
12501#endif
12502}
12503
12504/*
12505 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12506 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012507 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12508 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012509 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012510 * When "ignore_empty" is true don't consider a new, empty buffer to be
12511 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012512 */
12513 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012514file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012515{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012516 /* In a buffer that was never loaded the options are not valid. */
12517 if (buf->b_flags & BF_NEVERLOADED)
12518 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012519 if (ignore_empty
12520 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012521 && buf->b_ml.ml_line_count == 1
12522 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12523 return FALSE;
12524 if (buf->b_start_ffc != *buf->b_p_ff)
12525 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012526 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012527 return TRUE;
12528#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012529 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12530 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012531 if (buf->b_start_fenc == NULL)
12532 return (*buf->b_p_fenc != NUL);
12533 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12534#else
12535 return FALSE;
12536#endif
12537}
12538
12539/*
12540 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12541 */
12542 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012543check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012544{
12545 return check_opt_strings(p, p_ff_values, FALSE);
12546}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012547
12548/*
12549 * Return the effective shiftwidth value for current buffer, using the
12550 * 'tabstop' value when 'shiftwidth' is zero.
12551 */
12552 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012553get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012554{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012555 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012556}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012557
12558/*
12559 * Return the effective softtabstop value for the current buffer, using the
12560 * 'tabstop' value when 'softtabstop' is negative.
12561 */
12562 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012563get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012564{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012565 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012566}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012567
12568/*
12569 * Check matchpairs option for "*initc".
12570 * If there is a match set "*initc" to the matching character and "*findc" to
12571 * the opposite character. Set "*backwards" to the direction.
12572 * When "switchit" is TRUE swap the direction.
12573 */
12574 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012575find_mps_values(
12576 int *initc,
12577 int *findc,
12578 int *backwards,
12579 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012580{
12581 char_u *ptr;
12582
12583 ptr = curbuf->b_p_mps;
12584 while (*ptr != NUL)
12585 {
12586#ifdef FEAT_MBYTE
12587 if (has_mbyte)
12588 {
12589 char_u *prev;
12590
12591 if (mb_ptr2char(ptr) == *initc)
12592 {
12593 if (switchit)
12594 {
12595 *findc = *initc;
12596 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12597 *backwards = TRUE;
12598 }
12599 else
12600 {
12601 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12602 *backwards = FALSE;
12603 }
12604 return;
12605 }
12606 prev = ptr;
12607 ptr += mb_ptr2len(ptr) + 1;
12608 if (mb_ptr2char(ptr) == *initc)
12609 {
12610 if (switchit)
12611 {
12612 *findc = *initc;
12613 *initc = mb_ptr2char(prev);
12614 *backwards = FALSE;
12615 }
12616 else
12617 {
12618 *findc = mb_ptr2char(prev);
12619 *backwards = TRUE;
12620 }
12621 return;
12622 }
12623 ptr += mb_ptr2len(ptr);
12624 }
12625 else
12626#endif
12627 {
12628 if (*ptr == *initc)
12629 {
12630 if (switchit)
12631 {
12632 *backwards = TRUE;
12633 *findc = *initc;
12634 *initc = ptr[2];
12635 }
12636 else
12637 {
12638 *backwards = FALSE;
12639 *findc = ptr[2];
12640 }
12641 return;
12642 }
12643 ptr += 2;
12644 if (*ptr == *initc)
12645 {
12646 if (switchit)
12647 {
12648 *backwards = FALSE;
12649 *findc = *initc;
12650 *initc = ptr[-2];
12651 }
12652 else
12653 {
12654 *backwards = TRUE;
12655 *findc = ptr[-2];
12656 }
12657 return;
12658 }
12659 ++ptr;
12660 }
12661 if (*ptr == ',')
12662 ++ptr;
12663 }
12664}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012665
12666#if defined(FEAT_LINEBREAK) || defined(PROTO)
12667/*
12668 * This is called when 'breakindentopt' is changed and when a window is
12669 * initialized.
12670 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012671 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012672briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012673{
12674 char_u *p;
12675 int bri_shift = 0;
12676 long bri_min = 20;
12677 int bri_sbr = FALSE;
12678
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012679 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012680 while (*p != NUL)
12681 {
12682 if (STRNCMP(p, "shift:", 6) == 0
12683 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12684 {
12685 p += 6;
12686 bri_shift = getdigits(&p);
12687 }
12688 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12689 {
12690 p += 4;
12691 bri_min = getdigits(&p);
12692 }
12693 else if (STRNCMP(p, "sbr", 3) == 0)
12694 {
12695 p += 3;
12696 bri_sbr = TRUE;
12697 }
12698 if (*p != ',' && *p != NUL)
12699 return FAIL;
12700 if (*p == ',')
12701 ++p;
12702 }
12703
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012704 wp->w_p_brishift = bri_shift;
12705 wp->w_p_brimin = bri_min;
12706 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012707
12708 return OK;
12709}
12710#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012711
12712/*
12713 * Get the local or global value of 'backupcopy'.
12714 */
12715 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012716get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012717{
12718 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12719}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012720
12721#if defined(FEAT_SIGNS) || defined(PROTO)
12722/*
12723 * Return TRUE when window "wp" has a column to draw signs in.
12724 */
12725 int
12726signcolumn_on(win_T *wp)
12727{
12728 if (*wp->w_p_scl == 'n')
12729 return FALSE;
12730 if (*wp->w_p_scl == 'y')
12731 return TRUE;
12732 return (wp->w_buffer->b_signlist != NULL
12733# ifdef FEAT_NETBEANS_INTG
12734 || wp->w_buffer->b_has_sign_column
12735# endif
12736 );
12737}
12738#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012739
12740#if defined(FEAT_EVAL) || defined(PROTO)
12741/*
12742 * Get window or buffer local options.
12743 */
12744 dict_T *
12745get_winbuf_options(int bufopt)
12746{
12747 dict_T *d;
12748 int opt_idx;
12749
12750 d = dict_alloc();
12751 if (d == NULL)
12752 return NULL;
12753
12754 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12755 {
12756 struct vimoption *opt = &options[opt_idx];
12757
12758 if ((bufopt && (opt->indir & PV_BUF))
12759 || (!bufopt && (opt->indir & PV_WIN)))
12760 {
12761 char_u *varp = get_varp(opt);
12762
12763 if (varp != NULL)
12764 {
12765 if (opt->flags & P_STRING)
12766 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012767 else if (opt->flags & P_NUM)
12768 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012769 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012770 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012771 }
12772 }
12773 }
12774
12775 return d;
12776}
12777#endif