blob: 5b50913e18f11eb014ba87bb5ab055ca55d32b2f [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,
Bram Moolenaar0903d562017-08-26 22:30:15 +02002199 /* untranslated to avoid problems when 'encoding'
2200 * is changed */
2201 {(char_u *)"%<%f%h%m%=Page %N", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202#else
2203 (char_u *)NULL, PV_NONE,
2204 {(char_u *)NULL, (char_u *)0L}
2205#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002206 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002207 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2208#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2209 (char_u *)&p_pmcs, PV_NONE,
2210 {(char_u *)"", (char_u *)0L}
2211#else
2212 (char_u *)NULL, PV_NONE,
2213 {(char_u *)NULL, (char_u *)0L}
2214#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002215 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002216 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2217#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2218 (char_u *)&p_pmfn, PV_NONE,
2219 {(char_u *)"", (char_u *)0L}
2220#else
2221 (char_u *)NULL, PV_NONE,
2222 {(char_u *)NULL, (char_u *)0L}
2223#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002224 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002225 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002226#ifdef FEAT_PRINTER
2227 (char_u *)&p_popt, PV_NONE,
2228 {(char_u *)"", (char_u *)0L}
2229#else
2230 (char_u *)NULL, PV_NONE,
2231 {(char_u *)NULL, (char_u *)0L}
2232#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002233 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002234 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002235 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002236 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002237 {"pumheight", "ph", P_NUM|P_VI_DEF,
2238#ifdef FEAT_INS_EXPAND
2239 (char_u *)&p_ph, PV_NONE,
2240#else
2241 (char_u *)NULL, PV_NONE,
2242#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002243 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002244 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002245#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002246 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002247 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002248#else
2249 (char_u *)NULL, PV_NONE,
2250 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002251#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002252 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002253 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002254#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002255 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002256 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002257#else
2258 (char_u *)NULL, PV_NONE,
2259 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002260#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002261 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002262 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2263#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2264 (char_u *)&p_pyx, PV_NONE,
2265#else
2266 (char_u *)NULL, PV_NONE,
2267#endif
2268 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2269 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002270 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2271#ifdef FEAT_TEXTOBJ
2272 (char_u *)&p_qe, PV_QE,
2273 {(char_u *)"\\", (char_u *)0L}
2274#else
2275 (char_u *)NULL, PV_NONE,
2276 {(char_u *)NULL, (char_u *)0L}
2277#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002278 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002279 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2280 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002281 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282 {"redraw", NULL, P_BOOL|P_VI_DEF,
2283 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002284 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002285 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2286#ifdef FEAT_RELTIME
2287 (char_u *)&p_rdt, PV_NONE,
2288#else
2289 (char_u *)NULL, PV_NONE,
2290#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002291 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002292 {"regexpengine", "re", P_NUM|P_VI_DEF,
2293 (char_u *)&p_re, PV_NONE,
2294 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002295 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2296 (char_u *)VAR_WIN, PV_RNU,
2297 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 {"remap", NULL, P_BOOL|P_VI_DEF,
2299 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002300 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002301 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002302#ifdef FEAT_RENDER_OPTIONS
2303 (char_u *)&p_rop, PV_NONE,
2304 {(char_u *)"", (char_u *)0L}
2305#else
2306 (char_u *)NULL, PV_NONE,
2307 {(char_u *)NULL, (char_u *)0L}
2308#endif
2309 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002310 {"report", NULL, P_NUM|P_VI_DEF,
2311 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002312 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002313 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2314#ifdef WIN3264
2315 (char_u *)&p_rs, PV_NONE,
2316#else
2317 (char_u *)NULL, PV_NONE,
2318#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002319 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2321#ifdef FEAT_RIGHTLEFT
2322 (char_u *)&p_ri, PV_NONE,
2323#else
2324 (char_u *)NULL, PV_NONE,
2325#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002326 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2328#ifdef FEAT_RIGHTLEFT
2329 (char_u *)VAR_WIN, PV_RL,
2330#else
2331 (char_u *)NULL, PV_NONE,
2332#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002333 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2335#ifdef FEAT_RIGHTLEFT
2336 (char_u *)VAR_WIN, PV_RLC,
2337 {(char_u *)"search", (char_u *)NULL}
2338#else
2339 (char_u *)NULL, PV_NONE,
2340 {(char_u *)NULL, (char_u *)0L}
2341#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002342 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002343 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002344#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002345 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002346 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002347#else
2348 (char_u *)NULL, PV_NONE,
2349 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002350#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002351 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2353#ifdef FEAT_CMDL_INFO
2354 (char_u *)&p_ru, PV_NONE,
2355#else
2356 (char_u *)NULL, PV_NONE,
2357#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002358 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2360#ifdef FEAT_STL_OPT
2361 (char_u *)&p_ruf, PV_NONE,
2362#else
2363 (char_u *)NULL, PV_NONE,
2364#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002365 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002366 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2367 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002368 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2370 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2372 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002373 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2375#ifdef FEAT_SCROLLBIND
2376 (char_u *)VAR_WIN, PV_SCBIND,
2377#else
2378 (char_u *)NULL, PV_NONE,
2379#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002380 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2382 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002383 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002384 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2385 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002386 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002387 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388#ifdef FEAT_SCROLLBIND
2389 (char_u *)&p_sbo, PV_NONE,
2390 {(char_u *)"ver,jump", (char_u *)0L}
2391#else
2392 (char_u *)NULL, PV_NONE,
2393 {(char_u *)0L, (char_u *)0L}
2394#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002395 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002396 {"sections", "sect", P_STRING|P_VI_DEF,
2397 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002398 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2399 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002400 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2401 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002402 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002403 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002405 {(char_u *)"inclusive", (char_u *)0L}
2406 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002407 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002409 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002410 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002411#ifdef FEAT_SESSION
2412 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002413 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414 (char_u *)0L}
2415#else
2416 (char_u *)NULL, PV_NONE,
2417 {(char_u *)0L, (char_u *)0L}
2418#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002419 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2421 (char_u *)&p_sh, PV_NONE,
2422 {
2423#ifdef VMS
2424 (char_u *)"-",
2425#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002426# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002427 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002428# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002429 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002430# endif
2431#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002432 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2434 (char_u *)&p_shcf, PV_NONE,
2435 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002436#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 (char_u *)"/c",
2438#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002440#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2443#ifdef FEAT_QUICKFIX
2444 (char_u *)&p_sp, PV_NONE,
2445 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002446#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448#else
2449 (char_u *)">",
2450#endif
2451 (char_u *)0L}
2452#else
2453 (char_u *)NULL, PV_NONE,
2454 {(char_u *)0L, (char_u *)0L}
2455#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002456 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002457 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2458 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002459 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002460 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2461 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002462 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002463 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2464#ifdef BACKSLASH_IN_FILENAME
2465 (char_u *)&p_ssl, PV_NONE,
2466#else
2467 (char_u *)NULL, PV_NONE,
2468#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002469 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002470 {"shelltemp", "stmp", P_BOOL,
2471 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002472 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002473 {"shelltype", "st", P_NUM|P_VI_DEF,
2474#ifdef AMIGA
2475 (char_u *)&p_st, PV_NONE,
2476#else
2477 (char_u *)NULL, PV_NONE,
2478#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002479 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002480 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2481 (char_u *)&p_sxq, PV_NONE,
2482 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002483#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 (char_u *)"\"",
2485#else
2486 (char_u *)"",
2487#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002488 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002489 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2490 (char_u *)&p_sxe, PV_NONE,
2491 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002492#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002493 (char_u *)"\"&|<>()@^",
2494#else
2495 (char_u *)"",
2496#endif
2497 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002498 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2499 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002500 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2502 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002503 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2505 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002506 {(char_u *)"", (char_u *)"filnxtToO"}
2507 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002510 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002511 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2512#ifdef FEAT_LINEBREAK
2513 (char_u *)&p_sbr, PV_NONE,
2514#else
2515 (char_u *)NULL, PV_NONE,
2516#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002517 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002518 {"showcmd", "sc", P_BOOL|P_VIM,
2519#ifdef FEAT_CMDL_INFO
2520 (char_u *)&p_sc, PV_NONE,
2521#else
2522 (char_u *)NULL, PV_NONE,
2523#endif
2524 {(char_u *)FALSE,
2525#ifdef UNIX
2526 (char_u *)FALSE
2527#else
2528 (char_u *)TRUE
2529#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002530 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2532 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002533 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002534 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2535 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002536 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 {"showmode", "smd", P_BOOL|P_VIM,
2538 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002539 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002540 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2541#ifdef FEAT_WINDOWS
2542 (char_u *)&p_stal, PV_NONE,
2543#else
2544 (char_u *)NULL, PV_NONE,
2545#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002546 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002547 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2548 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002549 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002550 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2551 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002552 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002553 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2554#ifdef FEAT_SIGNS
2555 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002556 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002557#else
2558 (char_u *)NULL, PV_NONE,
2559 {(char_u *)NULL, (char_u *)0L}
2560#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002561 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002562 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2563 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002564 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002565 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2566 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2569#ifdef FEAT_SMARTINDENT
2570 (char_u *)&p_si, PV_SI,
2571#else
2572 (char_u *)NULL, PV_NONE,
2573#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002574 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002575 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2576 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002578 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2579 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002580 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002581 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2582 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002584 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002585#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002586 (char_u *)VAR_WIN, PV_SPELL,
2587#else
2588 (char_u *)NULL, PV_NONE,
2589#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002590 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002591 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002592#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002593 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002594 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002595#else
2596 (char_u *)NULL, PV_NONE,
2597 {(char_u *)0L, (char_u *)0L}
2598#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002599 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002600 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2601 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002602#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002603 (char_u *)&p_spf, PV_SPF,
2604 {(char_u *)"", (char_u *)0L}
2605#else
2606 (char_u *)NULL, PV_NONE,
2607 {(char_u *)0L, (char_u *)0L}
2608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002609 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002610 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2611 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002612#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002613 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002614 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002615#else
2616 (char_u *)NULL, PV_NONE,
2617 {(char_u *)0L, (char_u *)0L}
2618#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002619 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002620 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002621#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002622 (char_u *)&p_sps, PV_NONE,
2623 {(char_u *)"best", (char_u *)0L}
2624#else
2625 (char_u *)NULL, PV_NONE,
2626 {(char_u *)0L, (char_u *)0L}
2627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002628 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002629 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2630#ifdef FEAT_WINDOWS
2631 (char_u *)&p_sb, PV_NONE,
2632#else
2633 (char_u *)NULL, PV_NONE,
2634#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002635 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002637#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638 (char_u *)&p_spr, PV_NONE,
2639#else
2640 (char_u *)NULL, PV_NONE,
2641#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002642 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2644 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002645 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002646 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2647#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002648 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002649#else
2650 (char_u *)NULL, PV_NONE,
2651#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002652 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002653 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654 (char_u *)&p_su, PV_NONE,
2655 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002656 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002657 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002658#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002659 (char_u *)&p_sua, PV_SUA,
2660 {(char_u *)"", (char_u *)0L}
2661#else
2662 (char_u *)NULL, PV_NONE,
2663 {(char_u *)0L, (char_u *)0L}
2664#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002665 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2667 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002668 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002669 {"swapsync", "sws", P_STRING|P_VI_DEF,
2670 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002671 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002672 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002674 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002675 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2676#ifdef FEAT_SYN_HL
2677 (char_u *)&p_smc, PV_SMC,
2678 {(char_u *)3000L, (char_u *)0L}
2679#else
2680 (char_u *)NULL, PV_NONE,
2681 {(char_u *)0L, (char_u *)0L}
2682#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002683 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002684 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002685#ifdef FEAT_SYN_HL
2686 (char_u *)&p_syn, PV_SYN,
2687 {(char_u *)"", (char_u *)0L}
2688#else
2689 (char_u *)NULL, PV_NONE,
2690 {(char_u *)0L, (char_u *)0L}
2691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002692 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002693 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2694#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002695 (char_u *)&p_tal, PV_NONE,
2696#else
2697 (char_u *)NULL, PV_NONE,
2698#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002699 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002700 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2701#ifdef FEAT_WINDOWS
2702 (char_u *)&p_tpm, PV_NONE,
2703#else
2704 (char_u *)NULL, PV_NONE,
2705#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002706 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002707 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2708 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002709 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002710 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2711 (char_u *)&p_tbs, PV_NONE,
2712#ifdef VMS /* binary searching doesn't appear to work on VMS */
2713 {(char_u *)0L, (char_u *)0L}
2714#else
2715 {(char_u *)TRUE, (char_u *)0L}
2716#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002717 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002718 {"tagcase", "tc", P_STRING|P_VIM,
2719 (char_u *)&p_tc, PV_TC,
2720 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002721 {"taglength", "tl", P_NUM|P_VI_DEF,
2722 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002723 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724 {"tagrelative", "tr", P_BOOL|P_VIM,
2725 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002726 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002727 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002728 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002729 {
2730#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2731 (char_u *)"./tags,./TAGS,tags,TAGS",
2732#else
2733 (char_u *)"./tags,tags",
2734#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002735 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002736 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2737 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002738 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002739 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002740#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002741 (char_u *)&p_tcldll, PV_NONE,
2742 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002743#else
2744 (char_u *)NULL, PV_NONE,
2745 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002746#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002747 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002748 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2749 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002750 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002751 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2752#ifdef FEAT_ARABIC
2753 (char_u *)&p_tbidi, PV_NONE,
2754#else
2755 (char_u *)NULL, PV_NONE,
2756#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002757 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002758 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2759#ifdef FEAT_MBYTE
2760 (char_u *)&p_tenc, PV_NONE,
2761 {(char_u *)"", (char_u *)0L}
2762#else
2763 (char_u *)NULL, PV_NONE,
2764 {(char_u *)0L, (char_u *)0L}
2765#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002766 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002767 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2768#ifdef FEAT_TERMGUICOLORS
2769 (char_u *)&p_tgc, PV_NONE,
2770 {(char_u *)FALSE, (char_u *)FALSE}
2771#else
2772 (char_u*)NULL, PV_NONE,
2773 {(char_u *)FALSE, (char_u *)FALSE}
2774#endif
2775 SCRIPTID_INIT},
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002776 {"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2777#ifdef FEAT_TERMINAL
2778 (char_u *)VAR_WIN, PV_TK,
Bram Moolenaar1f28b4c2017-07-28 13:48:34 +02002779 {(char_u *)"", (char_u *)NULL}
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002780#else
2781 (char_u *)NULL, PV_NONE,
2782 {(char_u *)NULL, (char_u *)0L}
2783#endif
2784 SCRIPTID_INIT},
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002785 {"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2786#ifdef FEAT_TERMINAL
2787 (char_u *)VAR_WIN, PV_TMS,
2788 {(char_u *)"", (char_u *)NULL}
2789#else
2790 (char_u *)NULL, PV_NONE,
2791 {(char_u *)NULL, (char_u *)0L}
2792#endif
2793 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002794 {"terse", NULL, P_BOOL|P_VI_DEF,
2795 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002796 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797 {"textauto", "ta", P_BOOL|P_VIM,
2798 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002799 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2800 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002801 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2802 (char_u *)&p_tx, PV_TX,
2803 {
2804#ifdef USE_CRNL
2805 (char_u *)TRUE,
2806#else
2807 (char_u *)FALSE,
2808#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002809 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002810 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002812 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002813 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002815 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816#else
2817 (char_u *)NULL, PV_NONE,
2818#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2821 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823 {"timeout", "to", P_BOOL|P_VI_DEF,
2824 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002825 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002826 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2827 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002828 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002829 {"title", NULL, P_BOOL|P_VI_DEF,
2830#ifdef FEAT_TITLE
2831 (char_u *)&p_title, PV_NONE,
2832#else
2833 (char_u *)NULL, PV_NONE,
2834#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002835 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002836 {"titlelen", NULL, P_NUM|P_VI_DEF,
2837#ifdef FEAT_TITLE
2838 (char_u *)&p_titlelen, PV_NONE,
2839#else
2840 (char_u *)NULL, PV_NONE,
2841#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002842 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002843 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002844#ifdef FEAT_TITLE
2845 (char_u *)&p_titleold, PV_NONE,
2846 {(char_u *)N_("Thanks for flying Vim"),
2847 (char_u *)0L}
2848#else
2849 (char_u *)NULL, PV_NONE,
2850 {(char_u *)0L, (char_u *)0L}
2851#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002852 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002853 {"titlestring", NULL, P_STRING|P_VI_DEF,
2854#ifdef FEAT_TITLE
2855 (char_u *)&p_titlestring, PV_NONE,
2856#else
2857 (char_u *)NULL, PV_NONE,
2858#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002859 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002860 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002861#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002863 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002864#else
2865 (char_u *)NULL, PV_NONE,
2866 {(char_u *)0L, (char_u *)0L}
2867#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002868 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002869 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002870#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002872 {(char_u *)"small", (char_u *)0L}
2873#else
2874 (char_u *)NULL, PV_NONE,
2875 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002876#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002877 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2879 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002880 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002881 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2882 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002883 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002884 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2885 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002886 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002887 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2888 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002889 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002890 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2891#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2892 (char_u *)&p_ttym, PV_NONE,
2893#else
2894 (char_u *)NULL, PV_NONE,
2895#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002896 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002897 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2898 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002899 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002900 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2901 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002902 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002903 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2904 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002905#ifdef FEAT_PERSISTENT_UNDO
2906 (char_u *)&p_udir, PV_NONE,
2907 {(char_u *)".", (char_u *)0L}
2908#else
2909 (char_u *)NULL, PV_NONE,
2910 {(char_u *)0L, (char_u *)0L}
2911#endif
2912 SCRIPTID_INIT},
2913 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2914#ifdef FEAT_PERSISTENT_UNDO
2915 (char_u *)&p_udf, PV_UDF,
2916#else
2917 (char_u *)NULL, PV_NONE,
2918#endif
2919 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002920 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002921 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002923#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002924 (char_u *)1000L,
2925#else
2926 (char_u *)100L,
2927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002928 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002929 {"undoreload", "ur", P_NUM|P_VI_DEF,
2930 (char_u *)&p_ur, PV_NONE,
2931 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002932 {"updatecount", "uc", P_NUM|P_VI_DEF,
2933 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002934 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002935 {"updatetime", "ut", P_NUM|P_VI_DEF,
2936 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002937 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002938 {"verbose", "vbs", P_NUM|P_VI_DEF,
2939 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002940 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002941 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2942 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002943 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2945#ifdef FEAT_SESSION
2946 (char_u *)&p_vdir, PV_NONE,
2947 {(char_u *)DFLT_VDIR, (char_u *)0L}
2948#else
2949 (char_u *)NULL, PV_NONE,
2950 {(char_u *)0L, (char_u *)0L}
2951#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002952 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002953 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002954#ifdef FEAT_SESSION
2955 (char_u *)&p_vop, PV_NONE,
2956 {(char_u *)"folds,options,cursor", (char_u *)0L}
2957#else
2958 (char_u *)NULL, PV_NONE,
2959 {(char_u *)0L, (char_u *)0L}
2960#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002961 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002962 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002963#ifdef FEAT_VIMINFO
2964 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002965#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002966 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002967#else
2968# ifdef AMIGA
2969 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002970 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002972 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002973# endif
2974#endif
2975#else
2976 (char_u *)NULL, PV_NONE,
2977 {(char_u *)0L, (char_u *)0L}
2978#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002979 SCRIPTID_INIT},
Bram Moolenaarc4da1132017-07-15 19:39:43 +02002980 {"viminfofile", "vif", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE|P_VI_DEF,
2981#ifdef FEAT_VIMINFO
2982 (char_u *)&p_viminfofile, PV_NONE,
2983 {(char_u *)"", (char_u *)0L}
2984#else
2985 (char_u *)NULL, PV_NONE,
2986 {(char_u *)0L, (char_u *)0L}
2987#endif
2988 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002989 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2990 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991#ifdef FEAT_VIRTUALEDIT
2992 (char_u *)&p_ve, PV_NONE,
2993 {(char_u *)"", (char_u *)""}
2994#else
2995 (char_u *)NULL, PV_NONE,
2996 {(char_u *)0L, (char_u *)0L}
2997#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002998 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 {"visualbell", "vb", P_BOOL|P_VI_DEF,
3000 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003001 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003002 {"w300", NULL, P_NUM|P_VI_DEF,
3003 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003004 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003005 {"w1200", NULL, P_NUM|P_VI_DEF,
3006 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003007 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008 {"w9600", NULL, P_NUM|P_VI_DEF,
3009 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003010 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011 {"warn", NULL, P_BOOL|P_VI_DEF,
3012 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003013 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003014 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
3015 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003016 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003017 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003019 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003020 {"wildchar", "wc", P_NUM|P_VIM,
3021 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003022 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3023 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003024 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003025 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003026 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003027 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003028#ifdef FEAT_WILDIGN
3029 (char_u *)&p_wig, PV_NONE,
3030#else
3031 (char_u *)NULL, PV_NONE,
3032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003033 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003034 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3035 (char_u *)&p_wic, PV_NONE,
3036 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003037 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3038#ifdef FEAT_WILDMENU
3039 (char_u *)&p_wmnu, PV_NONE,
3040#else
3041 (char_u *)NULL, PV_NONE,
3042#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003043 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003044 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003046 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003047 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3048#ifdef FEAT_CMDL_COMPL
3049 (char_u *)&p_wop, PV_NONE,
3050 {(char_u *)"", (char_u *)0L}
3051#else
3052 (char_u *)NULL, PV_NONE,
3053 {(char_u *)NULL, (char_u *)0L}
3054#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003055 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003056 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3057#ifdef FEAT_WAK
3058 (char_u *)&p_wak, PV_NONE,
3059 {(char_u *)"menu", (char_u *)0L}
3060#else
3061 (char_u *)NULL, PV_NONE,
3062 {(char_u *)NULL, (char_u *)0L}
3063#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003064 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003065 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003066 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003067 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003068 {"winheight", "wh", P_NUM|P_VI_DEF,
3069#ifdef FEAT_WINDOWS
3070 (char_u *)&p_wh, PV_NONE,
3071#else
3072 (char_u *)NULL, PV_NONE,
3073#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003074 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003075 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003076#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003077 (char_u *)VAR_WIN, PV_WFH,
3078#else
3079 (char_u *)NULL, PV_NONE,
3080#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003081 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003082 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003083#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003084 (char_u *)VAR_WIN, PV_WFW,
3085#else
3086 (char_u *)NULL, PV_NONE,
3087#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003089 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3090#ifdef FEAT_WINDOWS
3091 (char_u *)&p_wmh, PV_NONE,
3092#else
3093 (char_u *)NULL, PV_NONE,
3094#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003095 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003097#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003098 (char_u *)&p_wmw, PV_NONE,
3099#else
3100 (char_u *)NULL, PV_NONE,
3101#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003102 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9e13aa72017-08-16 23:14:08 +02003103 {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar84ed4ad2017-08-17 11:33:42 +02003104#if defined(WIN3264) && defined(FEAT_TERMINAL)
Bram Moolenaar9e13aa72017-08-16 23:14:08 +02003105 (char_u *)&p_winptydll, PV_NONE, {
3106# ifdef _WIN64
3107 (char_u *)"winpty64.dll",
3108# else
3109 (char_u *)"winpty32.dll",
3110# endif
3111 (char_u *)0L}
3112#else
3113 (char_u *)NULL, PV_NONE,
3114 {(char_u *)0L, (char_u *)0L}
3115#endif
3116 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003118#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003119 (char_u *)&p_wiw, PV_NONE,
3120#else
3121 (char_u *)NULL, PV_NONE,
3122#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003123 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003124 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3125 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003126 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003127 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3128 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003129 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3131 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003132 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133 {"write", NULL, P_BOOL|P_VI_DEF,
3134 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003135 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136 {"writeany", "wa", P_BOOL|P_VI_DEF,
3137 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003138 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003139 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3140 (char_u *)&p_wb, PV_NONE,
3141 {
3142#ifdef FEAT_WRITEBACKUP
3143 (char_u *)TRUE,
3144#else
3145 (char_u *)FALSE,
3146#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003147 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148 {"writedelay", "wd", P_NUM|P_VI_DEF,
3149 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003150 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151
3152/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003153#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003154 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003155 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156
3157 p_term("t_AB", T_CAB)
3158 p_term("t_AF", T_CAF)
3159 p_term("t_AL", T_CAL)
3160 p_term("t_al", T_AL)
3161 p_term("t_bc", T_BC)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003162 p_term("t_BE", T_BE)
3163 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003164 p_term("t_cd", T_CD)
3165 p_term("t_ce", T_CE)
3166 p_term("t_cl", T_CL)
3167 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003168 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003169 p_term("t_Co", T_CCO)
3170 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003171 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003173#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003174 p_term("t_CV", T_CSV)
3175#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003176 p_term("t_da", T_DA)
3177 p_term("t_db", T_DB)
3178 p_term("t_DL", T_CDL)
3179 p_term("t_dl", T_DL)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003180 p_term("t_EC", T_CEC)
Bram Moolenaare5401222015-06-25 19:16:56 +02003181 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003182 p_term("t_fs", T_FS)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003183 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003184 p_term("t_IE", T_CIE)
3185 p_term("t_IS", T_CIS)
3186 p_term("t_ke", T_KE)
3187 p_term("t_ks", T_KS)
3188 p_term("t_le", T_LE)
3189 p_term("t_mb", T_MB)
3190 p_term("t_md", T_MD)
3191 p_term("t_me", T_ME)
3192 p_term("t_mr", T_MR)
3193 p_term("t_ms", T_MS)
3194 p_term("t_nd", T_ND)
3195 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003196 p_term("t_RB", T_RBG)
Bram Moolenaar4db25542017-08-28 22:43:05 +02003197 p_term("t_RC", T_CRC)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003198 p_term("t_RI", T_CRI)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003199 p_term("t_RS", T_CRS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200 p_term("t_RV", T_CRV)
3201 p_term("t_Sb", T_CSB)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003202 p_term("t_SC", T_CSC)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003204 p_term("t_Sf", T_CSF)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003205 p_term("t_SH", T_CSH)
Bram Moolenaare5401222015-06-25 19:16:56 +02003206 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003208 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003210 p_term("t_te", T_TE)
3211 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003212 p_term("t_ts", T_TS)
3213 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003214 p_term("t_ue", T_UE)
3215 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003216 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003217 p_term("t_vb", T_VB)
3218 p_term("t_ve", T_VE)
3219 p_term("t_vi", T_VI)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003220 p_term("t_VS", T_CVS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003221 p_term("t_vs", T_VS)
3222 p_term("t_WP", T_CWP)
3223 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003224 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003225 p_term("t_xs", T_XS)
3226 p_term("t_ZH", T_CZH)
3227 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003228 p_term("t_8f", T_8F)
3229 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003230
3231/* terminal key codes are not in here */
3232
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003233 /* end marker */
3234 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003235};
3236
3237#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3238
3239#ifdef FEAT_MBYTE
3240static char *(p_ambw_values[]) = {"single", "double", NULL};
3241#endif
3242static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003243static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003245#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003246static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003247#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003248#ifdef FEAT_CMDL_COMPL
3249static char *(p_wop_values[]) = {"tagfile", NULL};
3250#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251#ifdef FEAT_WAK
3252static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3253#endif
3254static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3256static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003258#ifdef FEAT_BROWSE
3259static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3260#endif
3261#ifdef FEAT_SCROLLBIND
3262static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3263#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003264static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003265#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003266static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3267#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003268#ifdef FEAT_AUTOCMD
3269static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL};
3270#else
3271static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003272#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003273static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3275#ifdef FEAT_FOLDING
3276static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003277# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003279# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003280 NULL};
3281static char *(p_fcl_values[]) = {"all", NULL};
3282#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003283#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003284static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003285#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003286#ifdef FEAT_SIGNS
3287static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3288#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003289
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003290static void set_option_default(int, int opt_flags, int compatible);
3291static void set_options_default(int opt_flags);
3292static char_u *term_bg_default(void);
3293static void did_set_option(int opt_idx, int opt_flags, int new_value);
3294static char_u *illegal_char(char_u *, int);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003295#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003296static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003297#endif
3298#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003299static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003301static char_u *option_expand(int opt_idx, char_u *val);
3302static void didset_options(void);
3303static void didset_options2(void);
3304static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003305#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003306static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003307#else
3308# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3309#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003310static void set_string_option_global(int opt_idx, char_u **varp);
3311static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3312static 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);
3313static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003314#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003315static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003316#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003317#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003318static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003319#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003320#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003321static char_u *did_set_spell_option(int is_spellfile);
3322static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003323#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003324#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003325static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003326#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003327static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3328static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3329static void check_redraw(long_u flags);
3330static int findoption(char_u *);
3331static int find_key_option(char_u *);
3332static void showoptions(int all, int opt_flags);
3333static int optval_default(struct vimoption *, char_u *varp);
3334static void showoneopt(struct vimoption *, int opt_flags);
3335static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3336static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3337static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3338static int istermoption(struct vimoption *);
3339static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3340static char_u *get_varp(struct vimoption *);
3341static void option_value2string(struct vimoption *, int opt_flags);
3342static void check_winopt(winopt_T *wop);
3343static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003344#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003345static void langmap_init(void);
3346static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003347#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003348static void paste_option_changed(void);
3349static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003350#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003351static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003352#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003353static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3354static int check_opt_strings(char_u *val, char **values, int);
3355static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003356#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003357static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003358#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003359
3360/*
3361 * Initialize the options, first part.
3362 *
3363 * Called only once from main(), just after creating the first buffer.
3364 */
3365 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003366set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003367{
3368 char_u *p;
3369 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003370 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003371
3372#ifdef FEAT_LANGMAP
3373 langmap_init();
3374#endif
3375
3376 /* Be Vi compatible by default */
3377 p_cp = TRUE;
3378
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003379 /* Use POSIX compatibility when $VIM_POSIX is set. */
3380 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003381 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003382 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003383 set_string_default("shm", (char_u *)"A");
3384 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003385
Bram Moolenaar071d4272004-06-13 20:20:40 +00003386 /*
3387 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003388 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003389 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003390 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003391#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003392 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003393# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003394 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395# endif
3396#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003397 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003398 set_string_default("sh", p);
3399
3400#ifdef FEAT_WILDIGN
3401 /*
3402 * Set the default for 'backupskip' to include environment variables for
3403 * temp files.
3404 */
3405 {
3406# ifdef UNIX
3407 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3408# else
3409 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3410# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003411 int len;
3412 garray_T ga;
3413 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003414
3415 ga_init2(&ga, 1, 100);
3416 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3417 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003418 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003419# ifdef UNIX
3420 if (*names[n] == NUL)
3421 p = (char_u *)"/tmp";
3422 else
3423# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003424 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003425 if (p != NULL && *p != NUL)
3426 {
3427 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003428 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003429 if (ga_grow(&ga, len) == OK)
3430 {
3431 if (ga.ga_len > 0)
3432 STRCAT(ga.ga_data, ",");
3433 STRCAT(ga.ga_data, p);
3434 add_pathsep(ga.ga_data);
3435 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003436 ga.ga_len += len;
3437 }
3438 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003439 if (mustfree)
3440 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003441 }
3442 if (ga.ga_data != NULL)
3443 {
3444 set_string_default("bsk", ga.ga_data);
3445 vim_free(ga.ga_data);
3446 }
3447 }
3448#endif
3449
3450 /*
3451 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3452 */
3453 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003454 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003456#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3457 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3458#endif
3459 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003460#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003461 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003462 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003463#else
3464# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003465 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003466 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003468 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003469# endif
3470#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003471 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003472 opt_idx = findoption((char_u *)"maxmem");
3473 if (opt_idx >= 0)
3474 {
3475#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003476 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3477 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003478#endif
3479 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3480 }
3481 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482 }
3483
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484#ifdef FEAT_SEARCHPATH
3485 {
3486 char_u *cdpath;
3487 char_u *buf;
3488 int i;
3489 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003490 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003491
3492 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003493 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003494 if (cdpath != NULL)
3495 {
3496 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3497 if (buf != NULL)
3498 {
3499 buf[0] = ','; /* start with ",", current dir first */
3500 j = 1;
3501 for (i = 0; cdpath[i] != NUL; ++i)
3502 {
3503 if (vim_ispathlistsep(cdpath[i]))
3504 buf[j++] = ',';
3505 else
3506 {
3507 if (cdpath[i] == ' ' || cdpath[i] == ',')
3508 buf[j++] = '\\';
3509 buf[j++] = cdpath[i];
3510 }
3511 }
3512 buf[j] = NUL;
3513 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003514 if (opt_idx >= 0)
3515 {
3516 options[opt_idx].def_val[VI_DEFAULT] = buf;
3517 options[opt_idx].flags |= P_DEF_ALLOCED;
3518 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003519 else
3520 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003521 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003522 if (mustfree)
3523 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003524 }
3525 }
3526#endif
3527
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003528#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003529 /* Set print encoding on platforms that don't default to latin1 */
3530 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003531# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003532 (char_u *)"cp1252"
3533# else
3534# ifdef VMS
3535 (char_u *)"dec-mcs"
3536# else
3537# ifdef EBCDIC
3538 (char_u *)"ebcdic-uk"
3539# else
3540# ifdef MAC
3541 (char_u *)"mac-roman"
3542# else /* HPUX */
3543 (char_u *)"hp-roman8"
3544# endif
3545# endif
3546# endif
3547# endif
3548 );
3549#endif
3550
3551#ifdef FEAT_POSTSCRIPT
3552 /* 'printexpr' must be allocated to be able to evaluate it. */
3553 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003554# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003555 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003556# else
3557# ifdef VMS
3558 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3559
3560# else
3561 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3562# endif
3563# endif
3564 );
3565#endif
3566
3567 /*
3568 * Set all the options (except the terminal options) to their default
3569 * value. Also set the global value for local options.
3570 */
3571 set_options_default(0);
3572
3573#ifdef FEAT_GUI
3574 if (found_reverse_arg)
3575 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3576#endif
3577
3578 curbuf->b_p_initialized = TRUE;
3579 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003580 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003581 check_buf_options(curbuf);
3582 check_win_options(curwin);
3583 check_options();
3584
3585 /* Must be before option_expand(), because that one needs vim_isIDc() */
3586 didset_options();
3587
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003588#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003589 /* Use the current chartab for the generic chartab. This is not in
3590 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003591 init_spell_chartab();
3592#endif
3593
Bram Moolenaar071d4272004-06-13 20:20:40 +00003594 /*
3595 * Expand environment variables and things like "~" for the defaults.
3596 * If option_expand() returns non-NULL the variable is expanded. This can
3597 * only happen for non-indirect options.
3598 * Also set the default to the expanded value, so ":set" does not list
3599 * them.
3600 * Don't set the P_ALLOCED flag, because we don't want to free the
3601 * default.
3602 */
3603 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3604 {
3605 if ((options[opt_idx].flags & P_GETTEXT)
3606 && options[opt_idx].var != NULL)
3607 p = (char_u *)_(*(char **)options[opt_idx].var);
3608 else
3609 p = option_expand(opt_idx, NULL);
3610 if (p != NULL && (p = vim_strsave(p)) != NULL)
3611 {
3612 *(char_u **)options[opt_idx].var = p;
3613 /* VIMEXP
3614 * Defaults for all expanded options are currently the same for Vi
3615 * and Vim. When this changes, add some code here! Also need to
3616 * split P_DEF_ALLOCED in two.
3617 */
3618 if (options[opt_idx].flags & P_DEF_ALLOCED)
3619 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3620 options[opt_idx].def_val[VI_DEFAULT] = p;
3621 options[opt_idx].flags |= P_DEF_ALLOCED;
3622 }
3623 }
3624
Bram Moolenaar071d4272004-06-13 20:20:40 +00003625 save_file_ff(curbuf); /* Buffer is unchanged */
3626
Bram Moolenaar071d4272004-06-13 20:20:40 +00003627#if defined(FEAT_ARABIC)
3628 /* Detect use of mlterm.
3629 * Mlterm is a terminal emulator akin to xterm that has some special
3630 * abilities (bidi namely).
3631 * NOTE: mlterm's author is being asked to 'set' a variable
3632 * instead of an environment variable due to inheritance.
3633 */
3634 if (mch_getenv((char_u *)"MLTERM") != NULL)
3635 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3636#endif
3637
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003638 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003639
3640#ifdef FEAT_MBYTE
3641# if defined(WIN3264) && defined(FEAT_GETTEXT)
3642 /*
3643 * If $LANG isn't set, try to get a good value for it. This makes the
3644 * right language be used automatically. Don't do this for English.
3645 */
3646 if (mch_getenv((char_u *)"LANG") == NULL)
3647 {
3648 char buf[20];
3649
3650 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3651 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3652 * only the first two. */
3653 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3654 (LPTSTR)buf, 20);
3655 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3656 {
3657 /* There are a few exceptions (probably more) */
3658 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3659 STRCPY(buf, "zh_TW");
3660 else if (STRNICMP(buf, "chs", 3) == 0
3661 || STRNICMP(buf, "zhc", 3) == 0)
3662 STRCPY(buf, "zh_CN");
3663 else if (STRNICMP(buf, "jp", 2) == 0)
3664 STRCPY(buf, "ja");
3665 else
3666 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003667 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668 }
3669 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003670# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003671# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003672 /* Moved to os_mac_conv.c to avoid dependency problems. */
3673 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003674# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003675# endif
3676
3677 /* enc_locale() will try to find the encoding of the current locale. */
3678 p = enc_locale();
3679 if (p != NULL)
3680 {
3681 char_u *save_enc;
3682
3683 /* Try setting 'encoding' and check if the value is valid.
3684 * If not, go back to the default "latin1". */
3685 save_enc = p_enc;
3686 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003687 if (STRCMP(p_enc, "gb18030") == 0)
3688 {
3689 /* We don't support "gb18030", but "cp936" is a good substitute
3690 * for practical purposes, thus use that. It's not an alias to
3691 * still support conversion between gb18030 and utf-8. */
3692 p_enc = vim_strsave((char_u *)"cp936");
3693 vim_free(p);
3694 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003695 if (mb_init() == NULL)
3696 {
3697 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003698 if (opt_idx >= 0)
3699 {
3700 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3701 options[opt_idx].flags |= P_DEF_ALLOCED;
3702 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003703
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003704#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003705 if (STRCMP(p_enc, "latin1") == 0
3706# ifdef FEAT_MBYTE
3707 || enc_utf8
3708# endif
3709 )
3710 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003711 /* Adjust the default for 'isprint' and 'iskeyword' to match
3712 * latin1. Also set the defaults for when 'nocompatible' is
3713 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003714 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003715 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003716 set_string_option_direct((char_u *)"isk", -1,
3717 ISK_LATIN1, OPT_FREE, SID_NONE);
3718 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003719 if (opt_idx >= 0)
3720 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003721 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003722 if (opt_idx >= 0)
3723 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003724 (void)init_chartab();
3725 }
3726#endif
3727
Bram Moolenaar071d4272004-06-13 20:20:40 +00003728# if defined(WIN3264) && !defined(FEAT_GUI)
3729 /* Win32 console: When GetACP() returns a different value from
3730 * GetConsoleCP() set 'termencoding'. */
3731 if (GetACP() != GetConsoleCP())
3732 {
3733 char buf[50];
3734
3735 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3736 p_tenc = vim_strsave((char_u *)buf);
3737 if (p_tenc != NULL)
3738 {
3739 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003740 if (opt_idx >= 0)
3741 {
3742 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3743 options[opt_idx].flags |= P_DEF_ALLOCED;
3744 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003745 convert_setup(&input_conv, p_tenc, p_enc);
3746 convert_setup(&output_conv, p_enc, p_tenc);
3747 }
3748 else
3749 p_tenc = empty_option;
3750 }
3751# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003752# if defined(WIN3264) && defined(FEAT_MBYTE)
3753 /* $HOME may have characters in active code page. */
3754 init_homedir();
3755# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003756 }
3757 else
3758 {
3759 vim_free(p_enc);
3760 p_enc = save_enc;
3761 }
3762 }
3763#endif
3764
3765#ifdef FEAT_MULTI_LANG
3766 /* Set the default for 'helplang'. */
3767 set_helplang_default(get_mess_lang());
3768#endif
3769}
3770
3771/*
3772 * Set an option to its default value.
3773 * This does not take care of side effects!
3774 */
3775 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003776set_option_default(
3777 int opt_idx,
3778 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3779 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003780{
3781 char_u *varp; /* pointer to variable for current option */
3782 int dvi; /* index in def_val[] */
3783 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003784 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003785 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3786
3787 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3788 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003789 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003790 {
3791 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3792 if (flags & P_STRING)
3793 {
3794 /* Use set_string_option_direct() for local options to handle
3795 * freeing and allocating the value. */
3796 if (options[opt_idx].indir != PV_NONE)
3797 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003798 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003799 else
3800 {
3801 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3802 free_string_option(*(char_u **)(varp));
3803 *(char_u **)varp = options[opt_idx].def_val[dvi];
3804 options[opt_idx].flags &= ~P_ALLOCED;
3805 }
3806 }
3807 else if (flags & P_NUM)
3808 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003809 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003810 win_comp_scroll(curwin);
3811 else
3812 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003813 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003814 /* May also set global value for local option. */
3815 if (both)
3816 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3817 *(long *)varp;
3818 }
3819 }
3820 else /* P_BOOL */
3821 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003822 /* the cast to long is required for Manx C, long_i is needed for
3823 * MSVC */
3824 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003825#ifdef UNIX
3826 /* 'modeline' defaults to off for root */
3827 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3828 *(int *)varp = FALSE;
3829#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003830 /* May also set global value for local option. */
3831 if (both)
3832 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3833 *(int *)varp;
3834 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003835
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003836 /* The default value is not insecure. */
3837 flagsp = insecure_flag(opt_idx, opt_flags);
3838 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003839 }
3840
3841#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003842 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003843#endif
3844}
3845
3846/*
3847 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003848 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003849 */
3850 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003851set_options_default(
3852 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003853{
3854 int i;
3855#ifdef FEAT_WINDOWS
3856 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003857 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003858#endif
3859
3860 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003861 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003862#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003863 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003864 || (TRUE
3865# if defined(FEAT_MBYTE)
3866 && options[i].var != (char_u *)&p_enc
3867# endif
3868# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003869 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003870 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003871# endif
3872 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003873#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003874 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003875 set_option_default(i, opt_flags, p_cp);
3876
3877#ifdef FEAT_WINDOWS
3878 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003879 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003880 win_comp_scroll(wp);
3881#else
3882 win_comp_scroll(curwin);
3883#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003884#ifdef FEAT_CINDENT
3885 parse_cino(curbuf);
3886#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003887}
3888
3889/*
3890 * Set the Vi-default value of a string option.
3891 * Used for 'sh', 'backupskip' and 'term'.
3892 */
3893 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003894set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003895{
3896 char_u *p;
3897 int opt_idx;
3898
3899 p = vim_strsave(val);
3900 if (p != NULL) /* we don't want a NULL */
3901 {
3902 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003903 if (opt_idx >= 0)
3904 {
3905 if (options[opt_idx].flags & P_DEF_ALLOCED)
3906 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3907 options[opt_idx].def_val[VI_DEFAULT] = p;
3908 options[opt_idx].flags |= P_DEF_ALLOCED;
3909 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003910 }
3911}
3912
3913/*
3914 * Set the Vi-default value of a number option.
3915 * Used for 'lines' and 'columns'.
3916 */
3917 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003918set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003919{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003920 int opt_idx;
3921
3922 opt_idx = findoption((char_u *)name);
3923 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003924 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925}
3926
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003927#if defined(EXITFREE) || defined(PROTO)
3928/*
3929 * Free all options.
3930 */
3931 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003932free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003933{
3934 int i;
3935
3936 for (i = 0; !istermoption(&options[i]); i++)
3937 {
3938 if (options[i].indir == PV_NONE)
3939 {
3940 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003941 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003942 free_string_option(*(char_u **)options[i].var);
3943 if (options[i].flags & P_DEF_ALLOCED)
3944 free_string_option(options[i].def_val[VI_DEFAULT]);
3945 }
3946 else if (options[i].var != VAR_WIN
3947 && (options[i].flags & P_STRING))
3948 /* buffer-local option: free global value */
3949 free_string_option(*(char_u **)options[i].var);
3950 }
3951}
3952#endif
3953
3954
Bram Moolenaar071d4272004-06-13 20:20:40 +00003955/*
3956 * Initialize the options, part two: After getting Rows and Columns and
3957 * setting 'term'.
3958 */
3959 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003960set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003961{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003962 int idx;
3963
Bram Moolenaar071d4272004-06-13 20:20:40 +00003964 /*
3965 * 'scroll' defaults to half the window height. Note that this default is
3966 * wrong when the window height changes.
3967 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003968 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003969 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003970 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003971 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003972 comp_col();
3973
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003974 /*
3975 * 'window' is only for backwards compatibility with Vi.
3976 * Default is Rows - 1.
3977 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003978 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003979 p_window = Rows - 1;
3980 set_number_default("window", Rows - 1);
3981
Bram Moolenaarf740b292006-02-16 22:11:02 +00003982 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003983#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003984 /*
3985 * If 'background' wasn't set by the user, try guessing the value,
3986 * depending on the terminal name. Only need to check for terminals
3987 * with a dark background, that can handle color.
3988 */
3989 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003990 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3991 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003992 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003993 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003994 /* don't mark it as set, when starting the GUI it may be
3995 * changed again */
3996 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003997 }
3998#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003999
4000#ifdef CURSOR_SHAPE
4001 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
4002#endif
4003#ifdef FEAT_MOUSESHAPE
4004 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
4005#endif
4006#ifdef FEAT_PRINTER
4007 (void)parse_printoptions(); /* parse 'printoptions' default value */
4008#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004009}
4010
4011/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00004012 * Return "dark" or "light" depending on the kind of terminal.
4013 * This is just guessing! Recognized are:
4014 * "linux" Linux console
4015 * "screen.linux" Linux console with screen
4016 * "cygwin" Cygwin shell
4017 * "putty" Putty program
4018 * We also check the COLORFGBG environment variable, which is set by
4019 * rxvt and derivatives. This variable contains either two or three
4020 * values separated by semicolons; we want the last value in either
4021 * case. If this value is 0-6 or 8, our background is dark.
4022 */
4023 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004024term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004025{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004026#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004027 /* DOS console nearly always black */
4028 return (char_u *)"dark";
4029#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004030 char_u *p;
4031
Bram Moolenaarf740b292006-02-16 22:11:02 +00004032 if (STRCMP(T_NAME, "linux") == 0
4033 || STRCMP(T_NAME, "screen.linux") == 0
4034 || STRCMP(T_NAME, "cygwin") == 0
4035 || STRCMP(T_NAME, "putty") == 0
4036 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4037 && (p = vim_strrchr(p, ';')) != NULL
4038 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4039 && p[2] == NUL))
4040 return (char_u *)"dark";
4041 return (char_u *)"light";
4042#endif
4043}
4044
4045/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004046 * Initialize the options, part three: After reading the .vimrc
4047 */
4048 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004049set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004050{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004051#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004052/*
4053 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4054 * This is done after other initializations, where 'shell' might have been
4055 * set, but only if they have not been set before.
4056 */
4057 char_u *p;
4058 int idx_srr;
4059 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004060# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061 int idx_sp;
4062 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004063# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064
4065 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004066 if (idx_srr < 0)
4067 do_srr = FALSE;
4068 else
4069 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004070# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004072 if (idx_sp < 0)
4073 do_sp = FALSE;
4074 else
4075 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004076# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004077 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004078 if (p != NULL)
4079 {
4080 /*
4081 * Default for p_sp is "| tee", for p_srr is ">".
4082 * For known shells it is changed here to include stderr.
4083 */
4084 if ( fnamecmp(p, "csh") == 0
4085 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004086# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087 || fnamecmp(p, "csh.exe") == 0
4088 || fnamecmp(p, "tcsh.exe") == 0
4089# endif
4090 )
4091 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004092# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004093 if (do_sp)
4094 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004095# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004096 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004097# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004099# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4101 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004102# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004103 if (do_srr)
4104 {
4105 p_srr = (char_u *)">&";
4106 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4107 }
4108 }
4109 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004110 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004111 if ( fnamecmp(p, "sh") == 0
4112 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004113 || fnamecmp(p, "mksh") == 0
4114 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004115 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004116 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004118 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004119# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004120 || fnamecmp(p, "cmd") == 0
4121 || fnamecmp(p, "sh.exe") == 0
4122 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004123 || fnamecmp(p, "mksh.exe") == 0
4124 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004125 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004126 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127 || fnamecmp(p, "bash.exe") == 0
4128 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004130 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004132# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004133 if (do_sp)
4134 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004135# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004137# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004138 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004139# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4141 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004142# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004143 if (do_srr)
4144 {
4145 p_srr = (char_u *)">%s 2>&1";
4146 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4147 }
4148 }
4149 vim_free(p);
4150 }
4151#endif
4152
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004153#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004155 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4156 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004157 * This is done after other initializations, where 'shell' might have been
4158 * set, but only if they have not been set before. Default for p_shcf is
4159 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004160 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004161 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004162 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004163 {
4164 int idx3;
4165
4166 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004167 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004168 {
4169 p_shcf = (char_u *)"-c";
4170 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4171 }
4172
Bram Moolenaar071d4272004-06-13 20:20:40 +00004173 /* Somehow Win32 requires the quotes around the redirection too */
4174 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004175 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004176 {
4177 p_sxq = (char_u *)"\"";
4178 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4179 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004180 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004181 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4182 {
4183 int idx3;
4184
4185 /*
4186 * cmd.exe on Windows will strip the first and last double quote given
4187 * on the command line, e.g. most of the time things like:
4188 * cmd /c "my path/to/echo" "my args to echo"
4189 * become:
4190 * my path/to/echo" "my args to echo
4191 * when executed.
4192 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004193 * To avoid this, set shellxquote to surround the command in
4194 * parenthesis. This appears to make most commands work, without
4195 * breaking commands that worked previously, such as
4196 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004197 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004198 idx3 = findoption((char_u *)"sxq");
4199 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4200 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004201 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004202 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4203 }
4204
Bram Moolenaara64ba222012-02-12 23:23:31 +01004205 idx3 = findoption((char_u *)"shcf");
4206 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4207 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004208 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004209 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4210 }
4211 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212#endif
4213
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004214 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004215 {
4216 int idx_ffs = findoption((char_u *)"ffs");
4217
4218 /* Apply the first entry of 'fileformats' to the initial buffer. */
4219 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4220 set_fileformat(default_fileformat(), OPT_LOCAL);
4221 }
4222
Bram Moolenaar071d4272004-06-13 20:20:40 +00004223#ifdef FEAT_TITLE
4224 set_title_defaults();
4225#endif
4226}
4227
4228#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4229/*
4230 * When 'helplang' is still at its default value, set it to "lang".
4231 * Only the first two characters of "lang" are used.
4232 */
4233 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004234set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004235{
4236 int idx;
4237
4238 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4239 return;
4240 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004241 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004242 {
4243 if (options[idx].flags & P_ALLOCED)
4244 free_string_option(p_hlg);
4245 p_hlg = vim_strsave(lang);
4246 if (p_hlg == NULL)
4247 p_hlg = empty_option;
4248 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004249 {
4250 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4251 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4252 {
4253 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4254 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4255 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004256 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004257 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004258 options[idx].flags |= P_ALLOCED;
4259 }
4260}
4261#endif
4262
4263#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004264static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004265
4266 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004267gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004268{
4269 if (gui_get_lightness(gui.back_pixel) < 127)
4270 return (char_u *)"dark";
4271 return (char_u *)"light";
4272}
4273
4274/*
4275 * Option initializations that can only be done after opening the GUI window.
4276 */
4277 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004278init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004279{
4280 /* Set the 'background' option according to the lightness of the
4281 * background color, unless the user has set it already. */
4282 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4283 {
4284 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4285 highlight_changed();
4286 }
4287}
4288#endif
4289
4290#ifdef FEAT_TITLE
4291/*
4292 * 'title' and 'icon' only default to true if they have not been set or reset
4293 * in .vimrc and we can read the old value.
4294 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4295 * they can be reset. This reduces startup time when using X on a remote
4296 * machine.
4297 */
4298 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004299set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004300{
4301 int idx1;
4302 long val;
4303
4304 /*
4305 * If GUI is (going to be) used, we can always set the window title and
4306 * icon name. Saves a bit of time, because the X11 display server does
4307 * not need to be contacted.
4308 */
4309 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004310 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004311 {
4312#ifdef FEAT_GUI
4313 if (gui.starting || gui.in_use)
4314 val = TRUE;
4315 else
4316#endif
4317 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004318 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004319 p_title = val;
4320 }
4321 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004322 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004323 {
4324#ifdef FEAT_GUI
4325 if (gui.starting || gui.in_use)
4326 val = TRUE;
4327 else
4328#endif
4329 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004330 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004331 p_icon = val;
4332 }
4333}
4334#endif
4335
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004336#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4337 static void
4338trigger_optionsset_string(
4339 int opt_idx,
4340 int opt_flags,
4341 char_u *oldval,
4342 char_u *newval)
4343{
4344 if (oldval != NULL && newval != NULL)
4345 {
4346 char_u buf_type[7];
4347
4348 sprintf((char *)buf_type, "%s",
4349 (opt_flags & OPT_LOCAL) ? "local" : "global");
4350 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4351 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4352 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4353 apply_autocmds(EVENT_OPTIONSET,
4354 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4355 reset_v_option_vars();
4356 }
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004357}
4358#endif
4359
Bram Moolenaar071d4272004-06-13 20:20:40 +00004360/*
4361 * Parse 'arg' for option settings.
4362 *
4363 * 'arg' may be IObuff, but only when no errors can be present and option
4364 * does not need to be expanded with option_expand().
4365 * "opt_flags":
4366 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004367 * OPT_GLOBAL for ":setglobal"
4368 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004369 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004370 * OPT_WINONLY to only set window-local options
4371 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372 *
4373 * returns FAIL if an error is detected, OK otherwise
4374 */
4375 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004376do_set(
4377 char_u *arg, /* option string (may be written to!) */
4378 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004379{
4380 int opt_idx;
4381 char_u *errmsg;
4382 char_u errbuf[80];
4383 char_u *startarg;
4384 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4385 int nextchar; /* next non-white char after option name */
4386 int afterchar; /* character just after option name */
4387 int len;
4388 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004389 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004390 int key;
4391 long_u flags; /* flags for current option */
4392 char_u *varp = NULL; /* pointer to variable for current option */
4393 int did_show = FALSE; /* already showed one value */
4394 int adding; /* "opt+=arg" */
4395 int prepending; /* "opt^=arg" */
4396 int removing; /* "opt-=arg" */
4397 int cp_val = 0;
4398 char_u key_name[2];
4399
4400 if (*arg == NUL)
4401 {
4402 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004403 did_show = TRUE;
4404 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004405 }
4406
4407 while (*arg != NUL) /* loop to process all options */
4408 {
4409 errmsg = NULL;
4410 startarg = arg; /* remember for error message */
4411
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004412 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4413 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004414 {
4415 /*
4416 * ":set all" show all options.
4417 * ":set all&" set all options to their default value.
4418 */
4419 arg += 3;
4420 if (*arg == '&')
4421 {
4422 ++arg;
4423 /* Only for :set command set global value of local options. */
4424 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004425 didset_options();
4426 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004427 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004428 }
4429 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004430 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004431 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004432 did_show = TRUE;
4433 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004434 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004435 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004436 {
4437 showoptions(2, opt_flags);
4438 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004439 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004440 arg += 7;
4441 }
4442 else
4443 {
4444 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004445 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004446 {
4447 prefix = 0;
4448 arg += 2;
4449 }
4450 else if (STRNCMP(arg, "inv", 3) == 0)
4451 {
4452 prefix = 2;
4453 arg += 3;
4454 }
4455
4456 /* find end of name */
4457 key = 0;
4458 if (*arg == '<')
4459 {
4460 nextchar = 0;
4461 opt_idx = -1;
4462 /* look out for <t_>;> */
4463 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4464 len = 5;
4465 else
4466 {
4467 len = 1;
4468 while (arg[len] != NUL && arg[len] != '>')
4469 ++len;
4470 }
4471 if (arg[len] != '>')
4472 {
4473 errmsg = e_invarg;
4474 goto skip;
4475 }
4476 arg[len] = NUL; /* put NUL after name */
4477 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4478 opt_idx = findoption(arg + 1);
4479 arg[len++] = '>'; /* restore '>' */
4480 if (opt_idx == -1)
4481 key = find_key_option(arg + 1);
4482 }
4483 else
4484 {
4485 len = 0;
4486 /*
4487 * The two characters after "t_" may not be alphanumeric.
4488 */
4489 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4490 len = 4;
4491 else
4492 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4493 ++len;
4494 nextchar = arg[len];
4495 arg[len] = NUL; /* put NUL after name */
4496 opt_idx = findoption(arg);
4497 arg[len] = nextchar; /* restore nextchar */
4498 if (opt_idx == -1)
4499 key = find_key_option(arg);
4500 }
4501
4502 /* remember character after option name */
4503 afterchar = arg[len];
4504
4505 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004506 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004507 ++len;
4508
4509 adding = FALSE;
4510 prepending = FALSE;
4511 removing = FALSE;
4512 if (arg[len] != NUL && arg[len + 1] == '=')
4513 {
4514 if (arg[len] == '+')
4515 {
4516 adding = TRUE; /* "+=" */
4517 ++len;
4518 }
4519 else if (arg[len] == '^')
4520 {
4521 prepending = TRUE; /* "^=" */
4522 ++len;
4523 }
4524 else if (arg[len] == '-')
4525 {
4526 removing = TRUE; /* "-=" */
4527 ++len;
4528 }
4529 }
4530 nextchar = arg[len];
4531
4532 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4533 {
4534 errmsg = (char_u *)N_("E518: Unknown option");
4535 goto skip;
4536 }
4537
4538 if (opt_idx >= 0)
4539 {
4540 if (options[opt_idx].var == NULL) /* hidden option: skip */
4541 {
4542 /* Only give an error message when requesting the value of
4543 * a hidden option, ignore setting it. */
4544 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4545 && (!(options[opt_idx].flags & P_BOOL)
4546 || nextchar == '?'))
4547 errmsg = (char_u *)N_("E519: Option not supported");
4548 goto skip;
4549 }
4550
4551 flags = options[opt_idx].flags;
4552 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4553 }
4554 else
4555 {
4556 flags = P_STRING;
4557 if (key < 0)
4558 {
4559 key_name[0] = KEY2TERMCAP0(key);
4560 key_name[1] = KEY2TERMCAP1(key);
4561 }
4562 else
4563 {
4564 key_name[0] = KS_KEY;
4565 key_name[1] = (key & 0xff);
4566 }
4567 }
4568
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004569 /* Skip all options that are not window-local (used when showing
4570 * an already loaded buffer in a window). */
4571 if ((opt_flags & OPT_WINONLY)
4572 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4573 goto skip;
4574
Bram Moolenaara3227e22006-03-08 21:32:40 +00004575 /* Skip all options that are window-local (used for :vimgrep). */
4576 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4577 && options[opt_idx].var == VAR_WIN)
4578 goto skip;
4579
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004580 /* Disallow changing some options from modelines. */
4581 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004582 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004583 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004584 {
4585 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4586 goto skip;
4587 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004588#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004589 /* In diff mode some options are overruled. This avoids that
4590 * 'foldmethod' becomes "marker" instead of "diff" and that
4591 * "wrap" gets set. */
4592 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004593 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004594 && (
4595#ifdef FEAT_FOLDING
4596 options[opt_idx].indir == PV_FDM ||
4597#endif
4598 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004599 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004600#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004601 }
4602
4603#ifdef HAVE_SANDBOX
4604 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004605 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004606 {
4607 errmsg = (char_u *)_(e_sandbox);
4608 goto skip;
4609 }
4610#endif
4611
4612 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4613 {
4614 arg += len;
4615 cp_val = p_cp;
4616 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4617 {
4618 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4619 {
4620 cp_val = FALSE;
4621 arg += 3;
4622 }
4623 else /* "opt&vi": set to Vi default */
4624 {
4625 cp_val = TRUE;
4626 arg += 2;
4627 }
4628 }
4629 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004630 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004631 {
4632 errmsg = e_trailing;
4633 goto skip;
4634 }
4635 }
4636
4637 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004638 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4639 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004640 */
4641 if (nextchar == '?'
4642 || (prefix == 1
4643 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4644 && !(flags & P_BOOL)))
4645 {
4646 /*
4647 * print value
4648 */
4649 if (did_show)
4650 msg_putchar('\n'); /* cursor below last one */
4651 else
4652 {
4653 gotocmdline(TRUE); /* cursor at status line */
4654 did_show = TRUE; /* remember that we did a line */
4655 }
4656 if (opt_idx >= 0)
4657 {
4658 showoneopt(&options[opt_idx], opt_flags);
4659#ifdef FEAT_EVAL
4660 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004661 {
4662 /* Mention where the option was last set. */
4663 if (varp == options[opt_idx].var)
4664 last_set_msg(options[opt_idx].scriptID);
4665 else if ((int)options[opt_idx].indir & PV_WIN)
4666 last_set_msg(curwin->w_p_scriptID[
4667 (int)options[opt_idx].indir & PV_MASK]);
4668 else if ((int)options[opt_idx].indir & PV_BUF)
4669 last_set_msg(curbuf->b_p_scriptID[
4670 (int)options[opt_idx].indir & PV_MASK]);
4671 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004672#endif
4673 }
4674 else
4675 {
4676 char_u *p;
4677
4678 p = find_termcode(key_name);
4679 if (p == NULL)
4680 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004681 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004682 goto skip;
4683 }
4684 else
4685 (void)show_one_termcode(key_name, p, TRUE);
4686 }
4687 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004688 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004689 errmsg = e_trailing;
4690 }
4691 else
4692 {
4693 if (flags & P_BOOL) /* boolean */
4694 {
4695 if (nextchar == '=' || nextchar == ':')
4696 {
4697 errmsg = e_invarg;
4698 goto skip;
4699 }
4700
4701 /*
4702 * ":set opt!": invert
4703 * ":set opt&": reset to default value
4704 * ":set opt<": reset to global value
4705 */
4706 if (nextchar == '!')
4707 value = *(int *)(varp) ^ 1;
4708 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004709 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004710 ((flags & P_VI_DEF) || cp_val)
4711 ? VI_DEFAULT : VIM_DEFAULT];
4712 else if (nextchar == '<')
4713 {
4714 /* For 'autoread' -1 means to use global value. */
4715 if ((int *)varp == &curbuf->b_p_ar
4716 && opt_flags == OPT_LOCAL)
4717 value = -1;
4718 else
4719 value = *(int *)get_varp_scope(&(options[opt_idx]),
4720 OPT_GLOBAL);
4721 }
4722 else
4723 {
4724 /*
4725 * ":set invopt": invert
4726 * ":set opt" or ":set noopt": set or reset
4727 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004728 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004729 {
4730 errmsg = e_trailing;
4731 goto skip;
4732 }
4733 if (prefix == 2) /* inv */
4734 value = *(int *)(varp) ^ 1;
4735 else
4736 value = prefix;
4737 }
4738
4739 errmsg = set_bool_option(opt_idx, varp, (int)value,
4740 opt_flags);
4741 }
4742 else /* numeric or string */
4743 {
4744 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4745 || prefix != 1)
4746 {
4747 errmsg = e_invarg;
4748 goto skip;
4749 }
4750
4751 if (flags & P_NUM) /* numeric */
4752 {
4753 /*
4754 * Different ways to set a number option:
4755 * & set to default value
4756 * < set to global value
4757 * <xx> accept special key codes for 'wildchar'
4758 * c accept any non-digit for 'wildchar'
4759 * [-]0-9 set number
4760 * other error
4761 */
4762 ++arg;
4763 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004764 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004765 ((flags & P_VI_DEF) || cp_val)
4766 ? VI_DEFAULT : VIM_DEFAULT];
4767 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004768 {
4769 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4770 * use the global value. */
4771 if ((long *)varp == &curbuf->b_p_ul
4772 && opt_flags == OPT_LOCAL)
4773 value = NO_LOCAL_UNDOLEVEL;
4774 else
4775 value = *(long *)get_varp_scope(
4776 &(options[opt_idx]), OPT_GLOBAL);
4777 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004778 else if (((long *)varp == &p_wc
4779 || (long *)varp == &p_wcm)
4780 && (*arg == '<'
4781 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004782 || (*arg != NUL
4783 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004784 && !VIM_ISDIGIT(*arg))))
4785 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02004786 value = string_to_key(arg, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004787 if (value == 0 && (long *)varp != &p_wcm)
4788 {
4789 errmsg = e_invarg;
4790 goto skip;
4791 }
4792 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004793 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4794 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004795 /* Allow negative (for 'undolevels'), octal and
4796 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004797 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4798 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004799 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004800 {
4801 errmsg = e_invarg;
4802 goto skip;
4803 }
4804 }
4805 else
4806 {
4807 errmsg = (char_u *)N_("E521: Number required after =");
4808 goto skip;
4809 }
4810
4811 if (adding)
4812 value = *(long *)varp + value;
4813 if (prepending)
4814 value = *(long *)varp * value;
4815 if (removing)
4816 value = *(long *)varp - value;
4817 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004818 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004819 }
4820 else if (opt_idx >= 0) /* string */
4821 {
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004822 char_u *save_arg = NULL;
4823 char_u *s = NULL;
4824 char_u *oldval = NULL; /* previous value if *varp */
4825 char_u *newval;
4826 char_u *origval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004827#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004828 char_u *saved_origval = NULL;
4829 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004830#endif
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004831 unsigned newlen;
4832 int comma;
4833 int bs;
4834 int new_value_alloced; /* new string option
Bram Moolenaar071d4272004-06-13 20:20:40 +00004835 was allocated */
4836
4837 /* When using ":set opt=val" for a global option
4838 * with a local value the local value will be
4839 * reset, use the global value here. */
4840 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004841 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004842 varp = options[opt_idx].var;
4843
4844 /* The old value is kept until we are sure that the
4845 * new value is valid. */
4846 oldval = *(char_u **)varp;
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004847
4848 /* When setting the local value of a global
4849 * option, the old value may be the global value. */
4850 if (((int)options[opt_idx].indir & PV_BOTH)
4851 && (opt_flags & OPT_LOCAL))
4852 origval = *(char_u **)get_varp(
4853 &options[opt_idx]);
4854 else
4855 origval = oldval;
4856
Bram Moolenaar071d4272004-06-13 20:20:40 +00004857 if (nextchar == '&') /* set to default val */
4858 {
4859 newval = options[opt_idx].def_val[
4860 ((flags & P_VI_DEF) || cp_val)
4861 ? VI_DEFAULT : VIM_DEFAULT];
4862 if ((char_u **)varp == &p_bg)
4863 {
4864 /* guess the value of 'background' */
4865#ifdef FEAT_GUI
4866 if (gui.in_use)
4867 newval = gui_bg_default();
4868 else
4869#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004870 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004871 }
4872
4873 /* expand environment variables and ~ (since the
4874 * default value was already expanded, only
4875 * required when an environment variable was set
4876 * later */
4877 if (newval == NULL)
4878 newval = empty_option;
4879 else
4880 {
4881 s = option_expand(opt_idx, newval);
4882 if (s == NULL)
4883 s = newval;
4884 newval = vim_strsave(s);
4885 }
4886 new_value_alloced = TRUE;
4887 }
4888 else if (nextchar == '<') /* set to global val */
4889 {
4890 newval = vim_strsave(*(char_u **)get_varp_scope(
4891 &(options[opt_idx]), OPT_GLOBAL));
4892 new_value_alloced = TRUE;
4893 }
4894 else
4895 {
4896 ++arg; /* jump to after the '=' or ':' */
4897
4898 /*
4899 * Set 'keywordprg' to ":help" if an empty
4900 * value was passed to :set by the user.
4901 * Misuse errbuf[] for the resulting string.
4902 */
4903 if (varp == (char_u *)&p_kp
4904 && (*arg == NUL || *arg == ' '))
4905 {
4906 STRCPY(errbuf, ":help");
4907 save_arg = arg;
4908 arg = errbuf;
4909 }
4910 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004911 * Convert 'backspace' number to string, for
4912 * adding, prepending and removing string.
4913 */
4914 else if (varp == (char_u *)&p_bs
4915 && VIM_ISDIGIT(**(char_u **)varp))
4916 {
4917 i = getdigits((char_u **)varp);
4918 switch (i)
4919 {
4920 case 0:
4921 *(char_u **)varp = empty_option;
4922 break;
4923 case 1:
4924 *(char_u **)varp = vim_strsave(
4925 (char_u *)"indent,eol");
4926 break;
4927 case 2:
4928 *(char_u **)varp = vim_strsave(
4929 (char_u *)"indent,eol,start");
4930 break;
4931 }
4932 vim_free(oldval);
Bram Moolenaaredbc0d42017-08-20 16:11:51 +02004933 if (origval == oldval)
4934 origval = *(char_u **)varp;
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004935 oldval = *(char_u **)varp;
4936 }
4937 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004938 * Convert 'whichwrap' number to string, for
4939 * backwards compatibility with Vim 3.0.
4940 * Misuse errbuf[] for the resulting string.
4941 */
4942 else if (varp == (char_u *)&p_ww
4943 && VIM_ISDIGIT(*arg))
4944 {
4945 *errbuf = NUL;
4946 i = getdigits(&arg);
4947 if (i & 1)
4948 STRCAT(errbuf, "b,");
4949 if (i & 2)
4950 STRCAT(errbuf, "s,");
4951 if (i & 4)
4952 STRCAT(errbuf, "h,l,");
4953 if (i & 8)
4954 STRCAT(errbuf, "<,>,");
4955 if (i & 16)
4956 STRCAT(errbuf, "[,],");
4957 if (*errbuf != NUL) /* remove trailing , */
4958 errbuf[STRLEN(errbuf) - 1] = NUL;
4959 save_arg = arg;
4960 arg = errbuf;
4961 }
4962 /*
4963 * Remove '>' before 'dir' and 'bdir', for
4964 * backwards compatibility with version 3.0
4965 */
4966 else if ( *arg == '>'
4967 && (varp == (char_u *)&p_dir
4968 || varp == (char_u *)&p_bdir))
4969 {
4970 ++arg;
4971 }
4972
Bram Moolenaar071d4272004-06-13 20:20:40 +00004973 /*
4974 * Copy the new string into allocated memory.
4975 * Can't use set_string_option_direct(), because
4976 * we need to remove the backslashes.
4977 */
4978 /* get a bit too much */
4979 newlen = (unsigned)STRLEN(arg) + 1;
4980 if (adding || prepending || removing)
4981 newlen += (unsigned)STRLEN(origval) + 1;
4982 newval = alloc(newlen);
4983 if (newval == NULL) /* out of mem, don't change */
4984 break;
4985 s = newval;
4986
4987 /*
4988 * Copy the string, skip over escaped chars.
4989 * For MS-DOS and WIN32 backslashes before normal
4990 * file name characters are not removed, and keep
4991 * backslash at start, for "\\machine\path", but
4992 * do remove it for "\\\\machine\\path".
4993 * The reverse is found in ExpandOldSetting().
4994 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004995 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004996 {
4997 if (*arg == '\\' && arg[1] != NUL
4998#ifdef BACKSLASH_IN_FILENAME
4999 && !((flags & P_EXPAND)
5000 && vim_isfilec(arg[1])
5001 && (arg[1] != '\\'
5002 || (s == newval
5003 && arg[2] != '\\')))
5004#endif
5005 )
5006 ++arg; /* remove backslash */
5007#ifdef FEAT_MBYTE
5008 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00005009 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005010 {
5011 /* copy multibyte char */
5012 mch_memmove(s, arg, (size_t)i);
5013 arg += i;
5014 s += i;
5015 }
5016 else
5017#endif
5018 *s++ = *arg++;
5019 }
5020 *s = NUL;
5021
5022 /*
5023 * Expand environment variables and ~.
5024 * Don't do it when adding without inserting a
5025 * comma.
5026 */
5027 if (!(adding || prepending || removing)
5028 || (flags & P_COMMA))
5029 {
5030 s = option_expand(opt_idx, newval);
5031 if (s != NULL)
5032 {
5033 vim_free(newval);
5034 newlen = (unsigned)STRLEN(s) + 1;
5035 if (adding || prepending || removing)
5036 newlen += (unsigned)STRLEN(origval) + 1;
5037 newval = alloc(newlen);
5038 if (newval == NULL)
5039 break;
5040 STRCPY(newval, s);
5041 }
5042 }
5043
5044 /* locate newval[] in origval[] when removing it
5045 * and when adding to avoid duplicates */
5046 i = 0; /* init for GCC */
5047 if (removing || (flags & P_NODUP))
5048 {
5049 i = (int)STRLEN(newval);
5050 bs = 0;
5051 for (s = origval; *s; ++s)
5052 {
5053 if ((!(flags & P_COMMA)
5054 || s == origval
5055 || (s[-1] == ',' && !(bs & 1)))
5056 && STRNCMP(s, newval, i) == 0
5057 && (!(flags & P_COMMA)
5058 || s[i] == ','
5059 || s[i] == NUL))
5060 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005061 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005062 * even number of backslashes or a single
5063 * backslash preceded by a comma before it
5064 * is recognized as a separator */
5065 if ((s > origval + 1
5066 && s[-1] == '\\'
5067 && s[-2] != ',')
5068 || (s == origval + 1
5069 && s[-1] == '\\'))
5070
Bram Moolenaar071d4272004-06-13 20:20:40 +00005071 ++bs;
5072 else
5073 bs = 0;
5074 }
5075
5076 /* do not add if already there */
5077 if ((adding || prepending) && *s)
5078 {
5079 prepending = FALSE;
5080 adding = FALSE;
5081 STRCPY(newval, origval);
5082 }
5083 }
5084
5085 /* concatenate the two strings; add a ',' if
5086 * needed */
5087 if (adding || prepending)
5088 {
5089 comma = ((flags & P_COMMA) && *origval != NUL
5090 && *newval != NUL);
5091 if (adding)
5092 {
5093 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005094 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005095 if (comma && i > 1
5096 && (flags & P_ONECOMMA) == P_ONECOMMA
5097 && origval[i - 1] == ','
5098 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005099 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005100 mch_memmove(newval + i + comma, newval,
5101 STRLEN(newval) + 1);
5102 mch_memmove(newval, origval, (size_t)i);
5103 }
5104 else
5105 {
5106 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005107 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005108 }
5109 if (comma)
5110 newval[i] = ',';
5111 }
5112
5113 /* Remove newval[] from origval[]. (Note: "i" has
5114 * been set above and is used here). */
5115 if (removing)
5116 {
5117 STRCPY(newval, origval);
5118 if (*s)
5119 {
5120 /* may need to remove a comma */
5121 if (flags & P_COMMA)
5122 {
5123 if (s == origval)
5124 {
5125 /* include comma after string */
5126 if (s[i] == ',')
5127 ++i;
5128 }
5129 else
5130 {
5131 /* include comma before string */
5132 --s;
5133 ++i;
5134 }
5135 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005136 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005137 }
5138 }
5139
5140 if (flags & P_FLAGLIST)
5141 {
5142 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005143 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005144 {
5145 /* if options have P_FLAGLIST and
5146 * P_ONECOMMA such as 'whichwrap' */
5147 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005148 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005149 if (*s != ',' && *(s + 1) == ','
5150 && vim_strchr(s + 2, *s) != NULL)
5151 {
5152 /* Remove the duplicated value and
5153 * the next comma. */
5154 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005155 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005156 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005157 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005158 else
5159 {
5160 if ((!(flags & P_COMMA) || *s != ',')
5161 && vim_strchr(s + 1, *s) != NULL)
5162 {
5163 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005164 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005165 }
5166 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005167 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005168 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005169 }
5170
5171 if (save_arg != NULL) /* number for 'whichwrap' */
5172 arg = save_arg;
5173 new_value_alloced = TRUE;
5174 }
5175
Bram Moolenaar8efa0262017-08-20 15:47:20 +02005176 /*
5177 * Set the new value.
5178 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005179 *(char_u **)(varp) = newval;
5180
Bram Moolenaar53744302015-07-17 17:38:22 +02005181#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005182 if (!starting
5183# ifdef FEAT_CRYPT
5184 && options[opt_idx].indir != PV_KEY
5185# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005186 && origval != NULL && newval != NULL)
5187 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005188 /* origval may be freed by
5189 * did_set_string_option(), make a copy. */
5190 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005191 /* newval (and varp) may become invalid if the
5192 * buffer is closed by autocommands. */
5193 saved_newval = vim_strsave(newval);
5194 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005195#endif
5196
Bram Moolenaar071d4272004-06-13 20:20:40 +00005197 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005198 * ":set" on local options. Note: when setting 'syntax'
5199 * or 'filetype' autocommands may be triggered that can
5200 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005201 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5202 new_value_alloced, oldval, errbuf, opt_flags);
5203
Bram Moolenaar8efa0262017-08-20 15:47:20 +02005204#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5205 if (errmsg == NULL)
5206 trigger_optionsset_string(opt_idx, opt_flags,
5207 saved_origval, saved_newval);
5208 vim_free(saved_origval);
5209 vim_free(saved_newval);
5210#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005211 /* If error detected, print the error message. */
5212 if (errmsg != NULL)
5213 goto skip;
5214 }
5215 else /* key code option */
5216 {
5217 char_u *p;
5218
5219 if (nextchar == '&')
5220 {
5221 if (add_termcap_entry(key_name, TRUE) == FAIL)
5222 errmsg = (char_u *)N_("E522: Not found in termcap");
5223 }
5224 else
5225 {
5226 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005227 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005228 if (*p == '\\' && p[1] != NUL)
5229 ++p;
5230 nextchar = *p;
5231 *p = NUL;
5232 add_termcode(key_name, arg, FALSE);
5233 *p = nextchar;
5234 }
5235 if (full_screen)
5236 ttest(FALSE);
5237 redraw_all_later(CLEAR);
5238 }
5239 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005240
Bram Moolenaar071d4272004-06-13 20:20:40 +00005241 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005242 did_set_option(opt_idx, opt_flags,
5243 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005244 }
5245
5246skip:
5247 /*
5248 * Advance to next argument.
5249 * - skip until a blank found, taking care of backslashes
5250 * - skip blanks
5251 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5252 */
5253 for (i = 0; i < 2 ; ++i)
5254 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005255 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005256 if (*arg++ == '\\' && *arg != NUL)
5257 ++arg;
5258 arg = skipwhite(arg);
5259 if (*arg != '=')
5260 break;
5261 }
5262 }
5263
5264 if (errmsg != NULL)
5265 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005266 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005267 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005268 if (i + (arg - startarg) < IOSIZE)
5269 {
5270 /* append the argument with the error */
5271 STRCAT(IObuff, ": ");
5272 mch_memmove(IObuff + i, startarg, (arg - startarg));
5273 IObuff[i + (arg - startarg)] = NUL;
5274 }
5275 /* make sure all characters are printable */
5276 trans_characters(IObuff, IOSIZE);
5277
5278 ++no_wait_return; /* wait_return done later */
5279 emsg(IObuff); /* show error highlighted */
5280 --no_wait_return;
5281
5282 return FAIL;
5283 }
5284
5285 arg = skipwhite(arg);
5286 }
5287
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005288theend:
5289 if (silent_mode && did_show)
5290 {
5291 /* After displaying option values in silent mode. */
5292 silent_mode = FALSE;
5293 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5294 msg_putchar('\n');
5295 cursor_on(); /* msg_start() switches it off */
5296 out_flush();
5297 silent_mode = TRUE;
5298 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5299 }
5300
Bram Moolenaar071d4272004-06-13 20:20:40 +00005301 return OK;
5302}
5303
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005304/*
5305 * Call this when an option has been given a new value through a user command.
5306 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5307 */
5308 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005309did_set_option(
5310 int opt_idx,
5311 int opt_flags, /* possibly with OPT_MODELINE */
5312 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005313{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005314 long_u *p;
5315
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005316 options[opt_idx].flags |= P_WAS_SET;
5317
5318 /* When an option is set in the sandbox, from a modeline or in secure mode
5319 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005320 * flag. */
5321 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005322 if (secure
5323#ifdef HAVE_SANDBOX
5324 || sandbox != 0
5325#endif
5326 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005327 *p = *p | P_INSECURE;
5328 else if (new_value)
5329 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005330}
5331
Bram Moolenaar071d4272004-06-13 20:20:40 +00005332 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005333illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005334{
5335 if (errbuf == NULL)
5336 return (char_u *)"";
5337 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005338 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005339 return errbuf;
5340}
5341
5342/*
5343 * Convert a key name or string into a key value.
5344 * Used for 'wildchar' and 'cedit' options.
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005345 * When "multi_byte" is TRUE allow for multi-byte characters.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005346 */
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005347 int
5348string_to_key(char_u *arg, int multi_byte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005349{
5350 if (*arg == '<')
5351 return find_key_option(arg + 1);
5352 if (*arg == '^')
5353 return Ctrl_chr(arg[1]);
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005354 if (multi_byte)
5355 return PTR2CHAR(arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005356 return *arg;
5357}
5358
5359#ifdef FEAT_CMDWIN
5360/*
5361 * Check value of 'cedit' and set cedit_key.
5362 * Returns NULL if value is OK, error message otherwise.
5363 */
5364 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005365check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005366{
5367 int n;
5368
5369 if (*p_cedit == NUL)
5370 cedit_key = -1;
5371 else
5372 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005373 n = string_to_key(p_cedit, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005374 if (vim_isprintc(n))
5375 return e_invarg;
5376 cedit_key = n;
5377 }
5378 return NULL;
5379}
5380#endif
5381
5382#ifdef FEAT_TITLE
5383/*
5384 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5385 * maketitle() to create and display it.
5386 * When switching the title or icon off, call mch_restore_title() to get
5387 * the old value back.
5388 */
5389 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005390did_set_title(
5391 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005392{
5393 if (starting != NO_SCREEN
5394#ifdef FEAT_GUI
5395 && !gui.starting
5396#endif
5397 )
5398 {
5399 maketitle();
5400 if (icon)
5401 {
5402 if (!p_icon)
5403 mch_restore_title(2);
5404 }
5405 else
5406 {
5407 if (!p_title)
5408 mch_restore_title(1);
5409 }
5410 }
5411}
5412#endif
5413
5414/*
5415 * set_options_bin - called when 'bin' changes value.
5416 */
5417 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005418set_options_bin(
5419 int oldval,
5420 int newval,
5421 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005422{
5423 /*
5424 * The option values that are changed when 'bin' changes are
5425 * copied when 'bin is set and restored when 'bin' is reset.
5426 */
5427 if (newval)
5428 {
5429 if (!oldval) /* switched on */
5430 {
5431 if (!(opt_flags & OPT_GLOBAL))
5432 {
5433 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5434 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5435 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5436 curbuf->b_p_et_nobin = curbuf->b_p_et;
5437 }
5438 if (!(opt_flags & OPT_LOCAL))
5439 {
5440 p_tw_nobin = p_tw;
5441 p_wm_nobin = p_wm;
5442 p_ml_nobin = p_ml;
5443 p_et_nobin = p_et;
5444 }
5445 }
5446
5447 if (!(opt_flags & OPT_GLOBAL))
5448 {
5449 curbuf->b_p_tw = 0; /* no automatic line wrap */
5450 curbuf->b_p_wm = 0; /* no automatic line wrap */
5451 curbuf->b_p_ml = 0; /* no modelines */
5452 curbuf->b_p_et = 0; /* no expandtab */
5453 }
5454 if (!(opt_flags & OPT_LOCAL))
5455 {
5456 p_tw = 0;
5457 p_wm = 0;
5458 p_ml = FALSE;
5459 p_et = FALSE;
5460 p_bin = TRUE; /* needed when called for the "-b" argument */
5461 }
5462 }
5463 else if (oldval) /* switched off */
5464 {
5465 if (!(opt_flags & OPT_GLOBAL))
5466 {
5467 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5468 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5469 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5470 curbuf->b_p_et = curbuf->b_p_et_nobin;
5471 }
5472 if (!(opt_flags & OPT_LOCAL))
5473 {
5474 p_tw = p_tw_nobin;
5475 p_wm = p_wm_nobin;
5476 p_ml = p_ml_nobin;
5477 p_et = p_et_nobin;
5478 }
5479 }
5480}
5481
5482#ifdef FEAT_VIMINFO
5483/*
5484 * Find the parameter represented by the given character (eg ', :, ", or /),
5485 * and return its associated value in the 'viminfo' string.
5486 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005487 * If the parameter is not specified in the string or there is no following
5488 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005489 */
5490 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005491get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005492{
5493 char_u *p;
5494
5495 p = find_viminfo_parameter(type);
5496 if (p != NULL && VIM_ISDIGIT(*p))
5497 return atoi((char *)p);
5498 return -1;
5499}
5500
5501/*
5502 * Find the parameter represented by the given character (eg ''', ':', '"', or
5503 * '/') in the 'viminfo' option and return a pointer to the string after it.
5504 * Return NULL if the parameter is not specified in the string.
5505 */
5506 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005507find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005508{
5509 char_u *p;
5510
5511 for (p = p_viminfo; *p; ++p)
5512 {
5513 if (*p == type)
5514 return p + 1;
5515 if (*p == 'n') /* 'n' is always the last one */
5516 break;
5517 p = vim_strchr(p, ','); /* skip until next ',' */
5518 if (p == NULL) /* hit the end without finding parameter */
5519 break;
5520 }
5521 return NULL;
5522}
5523#endif
5524
5525/*
5526 * Expand environment variables for some string options.
5527 * These string options cannot be indirect!
5528 * If "val" is NULL expand the current value of the option.
5529 * Return pointer to NameBuff, or NULL when not expanded.
5530 */
5531 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005532option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005533{
5534 /* if option doesn't need expansion nothing to do */
5535 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5536 return NULL;
5537
5538 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5539 * expand_env() would truncate the string. */
5540 if (val != NULL && STRLEN(val) > MAXPATHL)
5541 return NULL;
5542
5543 if (val == NULL)
5544 val = *(char_u **)options[opt_idx].var;
5545
5546 /*
5547 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5548 * Escape spaces when expanding 'tags', they are used to separate file
5549 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005550 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005551 */
5552 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005553 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005554#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005555 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5556#endif
5557 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005558 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5559 return NULL;
5560
5561 return NameBuff;
5562}
5563
5564/*
5565 * After setting various option values: recompute variables that depend on
5566 * option values.
5567 */
5568 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005569didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005570{
5571 /* initialize the table for 'iskeyword' et.al. */
5572 (void)init_chartab();
5573
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005574#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005575 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005576#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005577 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005578 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005579#ifdef FEAT_SESSION
5580 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5581 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5582#endif
5583#ifdef FEAT_FOLDING
5584 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5585#endif
5586 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005587 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005588#ifdef FEAT_VIRTUALEDIT
5589 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5590#endif
5591#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5592 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5593#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005594#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005595 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005596 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005597 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005598 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005599#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005600#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5601 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5602#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005603#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005604 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5605#endif
5606#ifdef FEAT_CMDWIN
5607 /* set cedit_key */
5608 (void)check_cedit();
5609#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005610#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005611 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005612#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005613#ifdef FEAT_LINEBREAK
5614 /* initialize the table for 'breakat'. */
5615 fill_breakat_flags();
5616#endif
5617
5618}
5619
5620/*
5621 * More side effects of setting options.
5622 */
5623 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005624didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005625{
5626 /* Initialize the highlight_attr[] table. */
5627 (void)highlight_changed();
5628
5629 /* Parse default for 'wildmode' */
5630 check_opt_wim();
5631
5632 (void)set_chars_option(&p_lcs);
5633#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5634 /* Parse default for 'fillchars'. */
5635 (void)set_chars_option(&p_fcs);
5636#endif
5637
5638#ifdef FEAT_CLIPBOARD
5639 /* Parse default for 'clipboard' */
5640 (void)check_clipboard_option();
5641#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005642}
5643
5644/*
5645 * Check for string options that are NULL (normally only termcap options).
5646 */
5647 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005648check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005649{
5650 int opt_idx;
5651
5652 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5653 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5654 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5655}
5656
5657/*
5658 * Check string options in a buffer for NULL value.
5659 */
5660 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005661check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005662{
Bram Moolenaar071d4272004-06-13 20:20:40 +00005663 check_string_option(&buf->b_p_bh);
5664 check_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005665#ifdef FEAT_MBYTE
5666 check_string_option(&buf->b_p_fenc);
5667#endif
5668 check_string_option(&buf->b_p_ff);
5669#ifdef FEAT_FIND_ID
5670 check_string_option(&buf->b_p_def);
5671 check_string_option(&buf->b_p_inc);
5672# ifdef FEAT_EVAL
5673 check_string_option(&buf->b_p_inex);
5674# endif
5675#endif
5676#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5677 check_string_option(&buf->b_p_inde);
5678 check_string_option(&buf->b_p_indk);
5679#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005680#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5681 check_string_option(&buf->b_p_bexpr);
5682#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005683#if defined(FEAT_CRYPT)
5684 check_string_option(&buf->b_p_cm);
5685#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005686 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005687#if defined(FEAT_EVAL)
5688 check_string_option(&buf->b_p_fex);
5689#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005690#ifdef FEAT_CRYPT
5691 check_string_option(&buf->b_p_key);
5692#endif
5693 check_string_option(&buf->b_p_kp);
5694 check_string_option(&buf->b_p_mps);
5695 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005696 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005697 check_string_option(&buf->b_p_isk);
5698#ifdef FEAT_COMMENTS
5699 check_string_option(&buf->b_p_com);
5700#endif
5701#ifdef FEAT_FOLDING
5702 check_string_option(&buf->b_p_cms);
5703#endif
5704 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005705#ifdef FEAT_TEXTOBJ
5706 check_string_option(&buf->b_p_qe);
5707#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005708#ifdef FEAT_SYN_HL
5709 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005710 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005711#endif
5712#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005713 check_string_option(&buf->b_s.b_p_spc);
5714 check_string_option(&buf->b_s.b_p_spf);
5715 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005716#endif
5717#ifdef FEAT_SEARCHPATH
5718 check_string_option(&buf->b_p_sua);
5719#endif
5720#ifdef FEAT_CINDENT
5721 check_string_option(&buf->b_p_cink);
5722 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005723 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005724#endif
5725#ifdef FEAT_AUTOCMD
5726 check_string_option(&buf->b_p_ft);
5727#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005728#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5729 check_string_option(&buf->b_p_cinw);
5730#endif
5731#ifdef FEAT_INS_EXPAND
5732 check_string_option(&buf->b_p_cpt);
5733#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005734#ifdef FEAT_COMPL_FUNC
5735 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005736 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005737#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005738#ifdef FEAT_KEYMAP
5739 check_string_option(&buf->b_p_keymap);
5740#endif
5741#ifdef FEAT_QUICKFIX
5742 check_string_option(&buf->b_p_gp);
5743 check_string_option(&buf->b_p_mp);
5744 check_string_option(&buf->b_p_efm);
5745#endif
5746 check_string_option(&buf->b_p_ep);
5747 check_string_option(&buf->b_p_path);
5748 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005749 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005750#ifdef FEAT_INS_EXPAND
5751 check_string_option(&buf->b_p_dict);
5752 check_string_option(&buf->b_p_tsr);
5753#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005754#ifdef FEAT_LISP
5755 check_string_option(&buf->b_p_lw);
5756#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005757 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005758#ifdef FEAT_MBYTE
5759 check_string_option(&buf->b_p_menc);
5760#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005761}
5762
5763/*
5764 * Free the string allocated for an option.
5765 * Checks for the string being empty_option. This may happen if we're out of
5766 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5767 * check_options().
5768 * Does NOT check for P_ALLOCED flag!
5769 */
5770 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005771free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005772{
5773 if (p != empty_option)
5774 vim_free(p);
5775}
5776
5777 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005778clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005779{
5780 if (*pp != empty_option)
5781 vim_free(*pp);
5782 *pp = empty_option;
5783}
5784
5785 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005786check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005787{
5788 if (*pp == NULL)
5789 *pp = empty_option;
5790}
5791
5792/*
5793 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5794 */
5795 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005796set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005797{
5798 int opt_idx;
5799
5800 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5801 if (options[opt_idx].var == (char_u *)p)
5802 {
5803 options[opt_idx].flags |= P_ALLOCED;
5804 return;
5805 }
5806 return; /* cannot happen: didn't find it! */
5807}
5808
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005809#if defined(FEAT_EVAL) || defined(PROTO)
5810/*
5811 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5812 * Return FALSE when it wasn't.
5813 * Return -1 for an unknown option.
5814 */
5815 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005816was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005817{
5818 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005819 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005820
5821 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005822 {
5823 flagp = insecure_flag(idx, opt_flags);
5824 return (*flagp & P_INSECURE) != 0;
5825 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005826 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005827 return -1;
5828}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005829
5830/*
5831 * Get a pointer to the flags used for the P_INSECURE flag of option
5832 * "opt_idx". For some local options a local flags field is used.
5833 */
5834 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005835insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005836{
5837 if (opt_flags & OPT_LOCAL)
5838 switch ((int)options[opt_idx].indir)
5839 {
5840#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005841 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005842#endif
5843#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005844# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005845 case PV_FDE: return &curwin->w_p_fde_flags;
5846 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005847# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005848# ifdef FEAT_BEVAL
5849 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5850# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005851# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005852 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005853# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005854 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005855# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005856 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005857# endif
5858#endif
5859 }
5860
5861 /* Nothing special, return global flags field. */
5862 return &options[opt_idx].flags;
5863}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005864#endif
5865
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005866#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005867static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005868
5869/*
5870 * Redraw the window title and/or tab page text later.
5871 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005872static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005873{
5874 need_maketitle = TRUE;
5875# ifdef FEAT_WINDOWS
5876 redraw_tabline = TRUE;
5877# endif
5878}
5879#endif
5880
Bram Moolenaar071d4272004-06-13 20:20:40 +00005881/*
5882 * Set a string option to a new value (without checking the effect).
5883 * The string is copied into allocated memory.
5884 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005885 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005886 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005887 */
5888 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005889set_string_option_direct(
5890 char_u *name,
5891 int opt_idx,
5892 char_u *val,
5893 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5894 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005895{
5896 char_u *s;
5897 char_u **varp;
5898 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005899 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005900
Bram Moolenaar89d40322006-08-29 15:30:07 +00005901 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005902 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005903 idx = findoption(name);
5904 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005905 {
5906 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005907 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005908 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005909 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005910 }
5911
Bram Moolenaar89d40322006-08-29 15:30:07 +00005912 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005913 return;
5914
5915 s = vim_strsave(val);
5916 if (s != NULL)
5917 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005918 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005919 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005920 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005921 free_string_option(*varp);
5922 *varp = s;
5923
5924 /* For buffer/window local option may also set the global value. */
5925 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005926 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005927
Bram Moolenaar89d40322006-08-29 15:30:07 +00005928 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005929
5930 /* When setting both values of a global option with a local value,
5931 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005932 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005933 {
5934 free_string_option(*varp);
5935 *varp = empty_option;
5936 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005937# ifdef FEAT_EVAL
5938 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005939 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005940 set_sid == 0 ? current_SID : set_sid);
5941# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005942 }
5943}
5944
5945/*
5946 * Set global value for string option when it's a local option.
5947 */
5948 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005949set_string_option_global(
5950 int opt_idx, /* option index */
5951 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005952{
5953 char_u **p, *s;
5954
5955 /* the global value is always allocated */
5956 if (options[opt_idx].var == VAR_WIN)
5957 p = (char_u **)GLOBAL_WO(varp);
5958 else
5959 p = (char_u **)options[opt_idx].var;
5960 if (options[opt_idx].indir != PV_NONE
5961 && p != varp
5962 && (s = vim_strsave(*varp)) != NULL)
5963 {
5964 free_string_option(*p);
5965 *p = s;
5966 }
5967}
5968
5969/*
5970 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005971 *
5972 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005973 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005974 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005975set_string_option(
5976 int opt_idx,
5977 char_u *value,
5978 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005979{
5980 char_u *s;
5981 char_u **varp;
5982 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005983#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5984 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005985 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005986#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005987 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005988
5989 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005990 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005991
5992 s = vim_strsave(value);
5993 if (s != NULL)
5994 {
5995 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5996 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005997 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005998 ? OPT_GLOBAL : OPT_LOCAL)
5999 : opt_flags);
6000 oldval = *varp;
6001 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02006002
6003#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02006004 if (!starting
6005# ifdef FEAT_CRYPT
6006 && options[opt_idx].indir != PV_KEY
6007# endif
6008 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006009 {
Bram Moolenaar53744302015-07-17 17:38:22 +02006010 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006011 saved_newval = vim_strsave(s);
6012 }
Bram Moolenaar53744302015-07-17 17:38:22 +02006013#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006014 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
6015 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00006016 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02006017
Bram Moolenaar53744302015-07-17 17:38:22 +02006018#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006019 /* call autocommand after handling side effects */
Bram Moolenaar8efa0262017-08-20 15:47:20 +02006020 if (r == NULL)
6021 trigger_optionsset_string(opt_idx, opt_flags,
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006022 saved_oldval, saved_newval);
Bram Moolenaar8efa0262017-08-20 15:47:20 +02006023 vim_free(saved_oldval);
6024 vim_free(saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02006025#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006026 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006027 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006028}
6029
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006030#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006031/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006032 * Return TRUE if "val" is a valid 'filetype' name.
6033 * Also used for 'syntax' and 'keymap'.
6034 */
6035 static int
6036valid_filetype(char_u *val)
6037{
6038 char_u *s;
6039
6040 for (s = val; *s != NUL; ++s)
6041 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6042 return FALSE;
6043 return TRUE;
6044}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006045#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006046
6047/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006048 * Handle string options that need some action to perform when changed.
6049 * Returns NULL for success, or an error message for an error.
6050 */
6051 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006052did_set_string_option(
6053 int opt_idx, /* index in options[] table */
6054 char_u **varp, /* pointer to the option variable */
6055 int new_value_alloced, /* new value was allocated */
6056 char_u *oldval, /* previous value of the option */
6057 char_u *errbuf, /* buffer for errors, or NULL */
6058 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006059{
6060 char_u *errmsg = NULL;
6061 char_u *s, *p;
6062 int did_chartab = FALSE;
6063 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006064 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006065#ifdef FEAT_GUI
6066 /* set when changing an option that only requires a redraw in the GUI */
6067 int redraw_gui_only = FALSE;
6068#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006069#ifdef FEAT_AUTOCMD
6070 int ft_changed = FALSE;
6071#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006072
6073 /* Get the global option to compare with, otherwise we would have to check
6074 * two values for all local options. */
6075 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6076
6077 /* Disallow changing some options from secure mode */
6078 if ((secure
6079#ifdef HAVE_SANDBOX
6080 || sandbox != 0
6081#endif
6082 ) && (options[opt_idx].flags & P_SECURE))
6083 {
6084 errmsg = e_secure;
6085 }
6086
Bram Moolenaar7554da42016-11-25 22:04:13 +01006087 /* Check for a "normal" directory or file name in some options. Disallow a
6088 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006089 * are often illegal in a file name. Be more permissive if "secure" is off.
6090 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006091 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006092 && vim_strpbrk(*varp, (char_u *)(secure
6093 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006094 || ((options[opt_idx].flags & P_NDNAME)
6095 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006096 {
6097 errmsg = e_invarg;
6098 }
6099
Bram Moolenaar071d4272004-06-13 20:20:40 +00006100 /* 'term' */
6101 else if (varp == &T_NAME)
6102 {
6103 if (T_NAME[0] == NUL)
6104 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6105#ifdef FEAT_GUI
6106 if (gui.in_use)
6107 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6108 else if (term_is_gui(T_NAME))
6109 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6110#endif
6111 else if (set_termname(T_NAME) == FAIL)
6112 errmsg = (char_u *)N_("E522: Not found in termcap");
6113 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006114 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006115 /* Screen colors may have changed. */
6116 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006117
6118 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6119 * P_ALLOCED flag on 'term'. */
6120 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006121 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006122 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006123 }
6124
6125 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006126 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006127 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006128 char_u *bkc = p_bkc;
6129 unsigned int *flags = &bkc_flags;
6130
6131 if (opt_flags & OPT_LOCAL)
6132 {
6133 bkc = curbuf->b_p_bkc;
6134 flags = &curbuf->b_bkc_flags;
6135 }
6136
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006137 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6138 /* make the local value empty: use the global value */
6139 *flags = 0;
6140 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006141 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006142 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6143 errmsg = e_invarg;
6144 if ((((int)*flags & BKC_AUTO) != 0)
6145 + (((int)*flags & BKC_YES) != 0)
6146 + (((int)*flags & BKC_NO) != 0) != 1)
6147 {
6148 /* Must have exactly one of "auto", "yes" and "no". */
6149 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6150 errmsg = e_invarg;
6151 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006152 }
6153 }
6154
6155 /* 'backupext' and 'patchmode' */
6156 else if (varp == &p_bex || varp == &p_pm)
6157 {
6158 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6159 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6160 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6161 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006162#ifdef FEAT_LINEBREAK
6163 /* 'breakindentopt' */
6164 else if (varp == &curwin->w_p_briopt)
6165 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006166 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006167 errmsg = e_invarg;
6168 }
6169#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006170
6171 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006172 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006173 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006174 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006175 */
6176 else if ( varp == &p_isi
6177 || varp == &(curbuf->b_p_isk)
6178 || varp == &p_isp
6179 || varp == &p_isf)
6180 {
6181 if (init_chartab() == FAIL)
6182 {
6183 did_chartab = TRUE; /* need to restore it below */
6184 errmsg = e_invarg; /* error in value */
6185 }
6186 }
6187
6188 /* 'helpfile' */
6189 else if (varp == &p_hf)
6190 {
6191 /* May compute new values for $VIM and $VIMRUNTIME */
6192 if (didset_vim)
6193 {
6194 vim_setenv((char_u *)"VIM", (char_u *)"");
6195 didset_vim = FALSE;
6196 }
6197 if (didset_vimruntime)
6198 {
6199 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6200 didset_vimruntime = FALSE;
6201 }
6202 }
6203
Bram Moolenaar1a384422010-07-14 19:53:30 +02006204#ifdef FEAT_SYN_HL
6205 /* 'colorcolumn' */
6206 else if (varp == &curwin->w_p_cc)
6207 errmsg = check_colorcolumn(curwin);
6208#endif
6209
Bram Moolenaar071d4272004-06-13 20:20:40 +00006210#ifdef FEAT_MULTI_LANG
6211 /* 'helplang' */
6212 else if (varp == &p_hlg)
6213 {
6214 /* Check for "", "ab", "ab,cd", etc. */
6215 for (s = p_hlg; *s != NUL; s += 3)
6216 {
6217 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6218 {
6219 errmsg = e_invarg;
6220 break;
6221 }
6222 if (s[2] == NUL)
6223 break;
6224 }
6225 }
6226#endif
6227
6228 /* 'highlight' */
6229 else if (varp == &p_hl)
6230 {
6231 if (highlight_changed() == FAIL)
6232 errmsg = e_invarg; /* invalid flags */
6233 }
6234
6235 /* 'nrformats' */
6236 else if (gvarp == &p_nf)
6237 {
6238 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6239 errmsg = e_invarg;
6240 }
6241
6242#ifdef FEAT_SESSION
6243 /* 'sessionoptions' */
6244 else if (varp == &p_ssop)
6245 {
6246 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6247 errmsg = e_invarg;
6248 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6249 {
6250 /* Don't allow both "sesdir" and "curdir". */
6251 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6252 errmsg = e_invarg;
6253 }
6254 }
6255 /* 'viewoptions' */
6256 else if (varp == &p_vop)
6257 {
6258 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6259 errmsg = e_invarg;
6260 }
6261#endif
6262
6263 /* 'scrollopt' */
6264#ifdef FEAT_SCROLLBIND
6265 else if (varp == &p_sbo)
6266 {
6267 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6268 errmsg = e_invarg;
6269 }
6270#endif
6271
6272 /* 'ambiwidth' */
6273#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006274 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006275 {
6276 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6277 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006278 else if (set_chars_option(&p_lcs) != NULL)
6279 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6280# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6281 else if (set_chars_option(&p_fcs) != NULL)
6282 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6283# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006284 }
6285#endif
6286
6287 /* 'background' */
6288 else if (varp == &p_bg)
6289 {
6290 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6291 {
6292#ifdef FEAT_EVAL
6293 int dark = (*p_bg == 'd');
6294#endif
6295
6296 init_highlight(FALSE, FALSE);
6297
6298#ifdef FEAT_EVAL
6299 if (dark != (*p_bg == 'd')
6300 && get_var_value((char_u *)"g:colors_name") != NULL)
6301 {
6302 /* The color scheme must have set 'background' back to another
6303 * value, that's not what we want here. Disable the color
6304 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006305 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006306 free_string_option(p_bg);
6307 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6308 check_string_option(&p_bg);
6309 init_highlight(FALSE, FALSE);
6310 }
6311#endif
6312 }
6313 else
6314 errmsg = e_invarg;
6315 }
6316
6317 /* 'wildmode' */
6318 else if (varp == &p_wim)
6319 {
6320 if (check_opt_wim() == FAIL)
6321 errmsg = e_invarg;
6322 }
6323
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006324#ifdef FEAT_CMDL_COMPL
6325 /* 'wildoptions' */
6326 else if (varp == &p_wop)
6327 {
6328 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6329 errmsg = e_invarg;
6330 }
6331#endif
6332
Bram Moolenaar071d4272004-06-13 20:20:40 +00006333#ifdef FEAT_WAK
6334 /* 'winaltkeys' */
6335 else if (varp == &p_wak)
6336 {
6337 if (*p_wak == NUL
6338 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6339 errmsg = e_invarg;
6340# ifdef FEAT_MENU
6341# ifdef FEAT_GUI_MOTIF
6342 else if (gui.in_use)
6343 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6344# else
6345# ifdef FEAT_GUI_GTK
6346 else if (gui.in_use)
6347 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6348# endif
6349# endif
6350# endif
6351 }
6352#endif
6353
6354#ifdef FEAT_AUTOCMD
6355 /* 'eventignore' */
6356 else if (varp == &p_ei)
6357 {
6358 if (check_ei() == FAIL)
6359 errmsg = e_invarg;
6360 }
6361#endif
6362
6363#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006364 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6365 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6366 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006367 {
6368 if (gvarp == &p_fenc)
6369 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006370 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006371 errmsg = e_modifiable;
6372 else if (vim_strchr(*varp, ',') != NULL)
6373 /* No comma allowed in 'fileencoding'; catches confusing it
6374 * with 'fileencodings'. */
6375 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006376 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006377 {
6378# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006379 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006380 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006381# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006382 /* Add 'fileencoding' to the swap file. */
6383 ml_setflags(curbuf);
6384 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006385 }
6386 if (errmsg == NULL)
6387 {
6388 /* canonize the value, so that STRCMP() can be used on it */
6389 p = enc_canonize(*varp);
6390 if (p != NULL)
6391 {
6392 vim_free(*varp);
6393 *varp = p;
6394 }
6395 if (varp == &p_enc)
6396 {
6397 errmsg = mb_init();
6398# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006399 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006400# endif
6401 }
6402 }
6403
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006404# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006405 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6406 {
6407 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6408 if (STRCMP(p_tenc, "utf-8") != 0)
6409 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6410 }
6411# endif
6412
6413 if (errmsg == NULL)
6414 {
6415# ifdef FEAT_KEYMAP
6416 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6417 * (with another encoding). */
6418 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6419 (void)keymap_init();
6420# endif
6421
6422 /* When 'termencoding' is not empty and 'encoding' changes or when
6423 * 'termencoding' changes, need to setup for keyboard input and
6424 * display output conversion. */
6425 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6426 {
6427 convert_setup(&input_conv, p_tenc, p_enc);
6428 convert_setup(&output_conv, p_enc, p_tenc);
6429 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006430
6431# if defined(WIN3264) && defined(FEAT_MBYTE)
6432 /* $HOME may have characters in active code page. */
6433 if (varp == &p_enc)
6434 init_homedir();
6435# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006436 }
6437 }
6438#endif
6439
6440#if defined(FEAT_POSTSCRIPT)
6441 else if (varp == &p_penc)
6442 {
6443 /* Canonize printencoding if VIM standard one */
6444 p = enc_canonize(p_penc);
6445 if (p != NULL)
6446 {
6447 vim_free(p_penc);
6448 p_penc = p;
6449 }
6450 else
6451 {
6452 /* Ensure lower case and '-' for '_' */
6453 for (s = p_penc; *s != NUL; s++)
6454 {
6455 if (*s == '_')
6456 *s = '-';
6457 else
6458 *s = TOLOWER_ASC(*s);
6459 }
6460 }
6461 }
6462#endif
6463
Bram Moolenaar9372a112005-12-06 19:59:18 +00006464#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006465 else if (varp == &p_imak)
6466 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006467 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006468 errmsg = e_invarg;
6469 }
6470#endif
6471
6472#ifdef FEAT_KEYMAP
6473 else if (varp == &curbuf->b_p_keymap)
6474 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006475 if (!valid_filetype(*varp))
6476 errmsg = e_invarg;
6477 else
6478 /* load or unload key mapping tables */
6479 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006480
Bram Moolenaarfab06232009-03-04 03:13:35 +00006481 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006482 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006483 if (*curbuf->b_p_keymap != NUL)
6484 {
6485 /* Installed a new keymap, switch on using it. */
6486 curbuf->b_p_iminsert = B_IMODE_LMAP;
6487 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6488 curbuf->b_p_imsearch = B_IMODE_LMAP;
6489 }
6490 else
6491 {
6492 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6493 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6494 curbuf->b_p_iminsert = B_IMODE_NONE;
6495 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6496 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6497 }
6498 if ((opt_flags & OPT_LOCAL) == 0)
6499 {
6500 set_iminsert_global();
6501 set_imsearch_global();
6502 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006503# ifdef FEAT_WINDOWS
6504 status_redraw_curbuf();
6505# endif
6506 }
6507 }
6508#endif
6509
6510 /* 'fileformat' */
6511 else if (gvarp == &p_ff)
6512 {
6513 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6514 errmsg = e_modifiable;
6515 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6516 errmsg = e_invarg;
6517 else
6518 {
6519 /* may also change 'textmode' */
6520 if (get_fileformat(curbuf) == EOL_DOS)
6521 curbuf->b_p_tx = TRUE;
6522 else
6523 curbuf->b_p_tx = FALSE;
6524#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006525 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006526#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006527 /* update flag in swap file */
6528 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006529 /* Redraw needed when switching to/from "mac": a CR in the text
6530 * will be displayed differently. */
6531 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6532 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006533 }
6534 }
6535
6536 /* 'fileformats' */
6537 else if (varp == &p_ffs)
6538 {
6539 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6540 errmsg = e_invarg;
6541 else
6542 {
6543 /* also change 'textauto' */
6544 if (*p_ffs == NUL)
6545 p_ta = FALSE;
6546 else
6547 p_ta = TRUE;
6548 }
6549 }
6550
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006551#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006552 /* 'cryptkey' */
6553 else if (gvarp == &p_key)
6554 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006555# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006556 /* Make sure the ":set" command doesn't show the new value in the
6557 * history. */
6558 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006559# endif
6560 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6561 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006562 ml_set_crypt_key(curbuf, oldval,
6563 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006564 }
6565
6566 else if (gvarp == &p_cm)
6567 {
6568 if (opt_flags & OPT_LOCAL)
6569 p = curbuf->b_p_cm;
6570 else
6571 p = p_cm;
6572 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6573 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006574 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006575 errmsg = e_invarg;
6576 else
6577 {
6578 /* When setting the global value to empty, make it "zip". */
6579 if (*p_cm == NUL)
6580 {
6581 if (new_value_alloced)
6582 free_string_option(p_cm);
6583 p_cm = vim_strsave((char_u *)"zip");
6584 new_value_alloced = TRUE;
6585 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006586 /* When using ":set cm=name" the local value is going to be empty.
6587 * Do that here, otherwise the crypt functions will still use the
6588 * local value. */
6589 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6590 {
6591 free_string_option(curbuf->b_p_cm);
6592 curbuf->b_p_cm = empty_option;
6593 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006594
6595 /* Need to update the swapfile when the effective method changed.
6596 * Set "s" to the effective old value, "p" to the effective new
6597 * method and compare. */
6598 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6599 s = p_cm; /* was previously using the global value */
6600 else
6601 s = oldval;
6602 if (*curbuf->b_p_cm == NUL)
6603 p = p_cm; /* is now using the global value */
6604 else
6605 p = curbuf->b_p_cm;
6606 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006607 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006608
6609 /* If the global value changes need to update the swapfile for all
6610 * buffers using that value. */
6611 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6612 {
6613 buf_T *buf;
6614
Bram Moolenaar29323592016-07-24 22:04:11 +02006615 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006616 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006617 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006618 }
6619 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006620 }
6621#endif
6622
6623 /* 'matchpairs' */
6624 else if (gvarp == &p_mps)
6625 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006626#ifdef FEAT_MBYTE
6627 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006628 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006629 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006630 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006631 int x2 = -1;
6632 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006633
6634 if (*p != NUL)
6635 p += mb_ptr2len(p);
6636 if (*p != NUL)
6637 x2 = *p++;
6638 if (*p != NUL)
6639 {
6640 x3 = mb_ptr2char(p);
6641 p += mb_ptr2len(p);
6642 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006643 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006644 {
6645 errmsg = e_invarg;
6646 break;
6647 }
6648 if (*p == NUL)
6649 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006650 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006651 }
6652 else
6653#endif
6654 {
6655 /* Check for "x:y,x:y" */
6656 for (p = *varp; *p != NUL; p += 4)
6657 {
6658 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6659 {
6660 errmsg = e_invarg;
6661 break;
6662 }
6663 if (p[3] == NUL)
6664 break;
6665 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006666 }
6667 }
6668
6669#ifdef FEAT_COMMENTS
6670 /* 'comments' */
6671 else if (gvarp == &p_com)
6672 {
6673 for (s = *varp; *s; )
6674 {
6675 while (*s && *s != ':')
6676 {
6677 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6678 && !VIM_ISDIGIT(*s) && *s != '-')
6679 {
6680 errmsg = illegal_char(errbuf, *s);
6681 break;
6682 }
6683 ++s;
6684 }
6685 if (*s++ == NUL)
6686 errmsg = (char_u *)N_("E524: Missing colon");
6687 else if (*s == ',' || *s == NUL)
6688 errmsg = (char_u *)N_("E525: Zero length string");
6689 if (errmsg != NULL)
6690 break;
6691 while (*s && *s != ',')
6692 {
6693 if (*s == '\\' && s[1] != NUL)
6694 ++s;
6695 ++s;
6696 }
6697 s = skip_to_option_part(s);
6698 }
6699 }
6700#endif
6701
6702 /* 'listchars' */
6703 else if (varp == &p_lcs)
6704 {
6705 errmsg = set_chars_option(varp);
6706 }
6707
6708#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6709 /* 'fillchars' */
6710 else if (varp == &p_fcs)
6711 {
6712 errmsg = set_chars_option(varp);
6713 }
6714#endif
6715
6716#ifdef FEAT_CMDWIN
6717 /* 'cedit' */
6718 else if (varp == &p_cedit)
6719 {
6720 errmsg = check_cedit();
6721 }
6722#endif
6723
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006724 /* 'verbosefile' */
6725 else if (varp == &p_vfile)
6726 {
6727 verbose_stop();
6728 if (*p_vfile != NUL && verbose_open() == FAIL)
6729 errmsg = e_invarg;
6730 }
6731
Bram Moolenaar071d4272004-06-13 20:20:40 +00006732#ifdef FEAT_VIMINFO
6733 /* 'viminfo' */
6734 else if (varp == &p_viminfo)
6735 {
6736 for (s = p_viminfo; *s;)
6737 {
6738 /* Check it's a valid character */
6739 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6740 {
6741 errmsg = illegal_char(errbuf, *s);
6742 break;
6743 }
6744 if (*s == 'n') /* name is always last one */
6745 {
6746 break;
6747 }
6748 else if (*s == 'r') /* skip until next ',' */
6749 {
6750 while (*++s && *s != ',')
6751 ;
6752 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006753 else if (*s == '%')
6754 {
6755 /* optional number */
6756 while (vim_isdigit(*++s))
6757 ;
6758 }
6759 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006760 ++s; /* no extra chars */
6761 else /* must have a number */
6762 {
6763 while (vim_isdigit(*++s))
6764 ;
6765
6766 if (!VIM_ISDIGIT(*(s - 1)))
6767 {
6768 if (errbuf != NULL)
6769 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006770 sprintf((char *)errbuf,
6771 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006772 transchar_byte(*(s - 1)));
6773 errmsg = errbuf;
6774 }
6775 else
6776 errmsg = (char_u *)"";
6777 break;
6778 }
6779 }
6780 if (*s == ',')
6781 ++s;
6782 else if (*s)
6783 {
6784 if (errbuf != NULL)
6785 errmsg = (char_u *)N_("E527: Missing comma");
6786 else
6787 errmsg = (char_u *)"";
6788 break;
6789 }
6790 }
6791 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6792 errmsg = (char_u *)N_("E528: Must specify a ' value");
6793 }
6794#endif /* FEAT_VIMINFO */
6795
6796 /* terminal options */
6797 else if (istermoption(&options[opt_idx]) && full_screen)
6798 {
6799 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6800 if (varp == &T_CCO)
6801 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006802 int colors = atoi((char *)T_CCO);
6803
6804 /* Only reinitialize colors if t_Co value has really changed to
6805 * avoid expensive reload of colorscheme if t_Co is set to the
6806 * same value multiple times. */
6807 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006808 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006809 t_colors = colors;
6810 if (t_colors <= 1)
6811 {
6812 if (new_value_alloced)
6813 vim_free(T_CCO);
6814 T_CCO = empty_option;
6815 }
6816 /* We now have a different color setup, initialize it again. */
6817 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006818 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006819 }
6820 ttest(FALSE);
6821 if (varp == &T_ME)
6822 {
6823 out_str(T_ME);
6824 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006825#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006826 /* Since t_me has been set, this probably means that the user
6827 * wants to use this as default colors. Need to reset default
6828 * background/foreground colors. */
6829 mch_set_normal_colors();
6830#endif
6831 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006832 if (varp == &T_BE && termcap_active)
6833 {
6834 if (*T_BE == NUL)
6835 /* When clearing t_BE we assume the user no longer wants
6836 * bracketed paste, thus disable it by writing t_BD. */
6837 out_str(T_BD);
6838 else
6839 out_str(T_BE);
6840 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006841 }
6842
6843#ifdef FEAT_LINEBREAK
6844 /* 'showbreak' */
6845 else if (varp == &p_sbr)
6846 {
6847 for (s = p_sbr; *s; )
6848 {
6849 if (ptr2cells(s) != 1)
6850 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006851 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006852 }
6853 }
6854#endif
6855
6856#ifdef FEAT_GUI
6857 /* 'guifont' */
6858 else if (varp == &p_guifont)
6859 {
6860 if (gui.in_use)
6861 {
6862 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006863# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006864 /*
6865 * Put up a font dialog and let the user select a new value.
6866 * If this is cancelled go back to the old value but don't
6867 * give an error message.
6868 */
6869 if (STRCMP(p, "*") == 0)
6870 {
6871 p = gui_mch_font_dialog(oldval);
6872
6873 if (new_value_alloced)
6874 free_string_option(p_guifont);
6875
6876 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6877 new_value_alloced = TRUE;
6878 }
6879# endif
6880 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6881 {
6882# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6883 if (STRCMP(p_guifont, "*") == 0)
6884 {
6885 /* Dialog was cancelled: Keep the old value without giving
6886 * an error message. */
6887 if (new_value_alloced)
6888 free_string_option(p_guifont);
6889 p_guifont = vim_strsave(oldval);
6890 new_value_alloced = TRUE;
6891 }
6892 else
6893# endif
6894 errmsg = (char_u *)N_("E596: Invalid font(s)");
6895 }
6896 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006897 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006898 }
6899# ifdef FEAT_XFONTSET
6900 else if (varp == &p_guifontset)
6901 {
6902 if (STRCMP(p_guifontset, "*") == 0)
6903 errmsg = (char_u *)N_("E597: can't select fontset");
6904 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6905 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006906 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006907 }
6908# endif
6909# ifdef FEAT_MBYTE
6910 else if (varp == &p_guifontwide)
6911 {
6912 if (STRCMP(p_guifontwide, "*") == 0)
6913 errmsg = (char_u *)N_("E533: can't select wide font");
6914 else if (gui_get_wide_font() == FAIL)
6915 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006916 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006917 }
6918# endif
6919#endif
6920
6921#ifdef CURSOR_SHAPE
6922 /* 'guicursor' */
6923 else if (varp == &p_guicursor)
6924 errmsg = parse_shape_opt(SHAPE_CURSOR);
6925#endif
6926
6927#ifdef FEAT_MOUSESHAPE
6928 /* 'mouseshape' */
6929 else if (varp == &p_mouseshape)
6930 {
6931 errmsg = parse_shape_opt(SHAPE_MOUSE);
6932 update_mouseshape(-1);
6933 }
6934#endif
6935
6936#ifdef FEAT_PRINTER
6937 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006938 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006939# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006940 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006941 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006942# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006943#endif
6944
6945#ifdef FEAT_LANGMAP
6946 /* 'langmap' */
6947 else if (varp == &p_langmap)
6948 langmap_set();
6949#endif
6950
6951#ifdef FEAT_LINEBREAK
6952 /* 'breakat' */
6953 else if (varp == &p_breakat)
6954 fill_breakat_flags();
6955#endif
6956
6957#ifdef FEAT_TITLE
6958 /* 'titlestring' and 'iconstring' */
6959 else if (varp == &p_titlestring || varp == &p_iconstring)
6960 {
6961# ifdef FEAT_STL_OPT
6962 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6963
6964 /* NULL => statusline syntax */
6965 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6966 stl_syntax |= flagval;
6967 else
6968 stl_syntax &= ~flagval;
6969# endif
6970 did_set_title(varp == &p_iconstring);
6971
6972 }
6973#endif
6974
6975#ifdef FEAT_GUI
6976 /* 'guioptions' */
6977 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006978 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006979 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006980 redraw_gui_only = TRUE;
6981 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006982#endif
6983
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006984#if defined(FEAT_GUI_TABLINE)
6985 /* 'guitablabel' */
6986 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006987 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006988 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006989 redraw_gui_only = TRUE;
6990 }
6991 /* 'guitabtooltip' */
6992 else if (varp == &p_gtt)
6993 {
6994 redraw_gui_only = TRUE;
6995 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006996#endif
6997
Bram Moolenaar071d4272004-06-13 20:20:40 +00006998#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6999 /* 'ttymouse' */
7000 else if (varp == &p_ttym)
7001 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007002 /* Switch the mouse off before changing the escape sequences used for
7003 * that. */
7004 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007005 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
7006 errmsg = e_invarg;
7007 else
7008 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00007009 if (termcap_active)
7010 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007011 }
7012#endif
7013
Bram Moolenaar071d4272004-06-13 20:20:40 +00007014 /* 'selection' */
7015 else if (varp == &p_sel)
7016 {
7017 if (*p_sel == NUL
7018 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
7019 errmsg = e_invarg;
7020 }
7021
7022 /* 'selectmode' */
7023 else if (varp == &p_slm)
7024 {
7025 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
7026 errmsg = e_invarg;
7027 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028
7029#ifdef FEAT_BROWSE
7030 /* 'browsedir' */
7031 else if (varp == &p_bsdir)
7032 {
7033 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7034 && !mch_isdir(p_bsdir))
7035 errmsg = e_invarg;
7036 }
7037#endif
7038
Bram Moolenaar071d4272004-06-13 20:20:40 +00007039 /* 'keymodel' */
7040 else if (varp == &p_km)
7041 {
7042 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7043 errmsg = e_invarg;
7044 else
7045 {
7046 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7047 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7048 }
7049 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007050
7051 /* 'mousemodel' */
7052 else if (varp == &p_mousem)
7053 {
7054 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7055 errmsg = e_invarg;
7056#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7057 else if (*p_mousem != *oldval)
7058 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7059 * to create or delete the popup menus. */
7060 gui_motif_update_mousemodel(root_menu);
7061#endif
7062 }
7063
7064 /* 'switchbuf' */
7065 else if (varp == &p_swb)
7066 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007067 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007068 errmsg = e_invarg;
7069 }
7070
7071 /* 'debug' */
7072 else if (varp == &p_debug)
7073 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007074 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007075 errmsg = e_invarg;
7076 }
7077
7078 /* 'display' */
7079 else if (varp == &p_dy)
7080 {
7081 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7082 errmsg = e_invarg;
7083 else
7084 (void)init_chartab();
7085
7086 }
7087
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007088#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007089 /* 'eadirection' */
7090 else if (varp == &p_ead)
7091 {
7092 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7093 errmsg = e_invarg;
7094 }
7095#endif
7096
7097#ifdef FEAT_CLIPBOARD
7098 /* 'clipboard' */
7099 else if (varp == &p_cb)
7100 errmsg = check_clipboard_option();
7101#endif
7102
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007103#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007104 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7105 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007106 else if (varp == &(curwin->w_s->b_p_spl)
7107 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007108 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007109 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007110 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007111 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007112 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007113 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007114 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007115 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007116 /* 'spellsuggest' */
7117 else if (varp == &p_sps)
7118 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007119 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007120 errmsg = e_invarg;
7121 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007122 /* 'mkspellmem' */
7123 else if (varp == &p_msm)
7124 {
7125 if (spell_check_msm() != OK)
7126 errmsg = e_invarg;
7127 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007128#endif
7129
Bram Moolenaar071d4272004-06-13 20:20:40 +00007130 /* When 'bufhidden' is set, check for valid value. */
7131 else if (gvarp == &p_bh)
7132 {
7133 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7134 errmsg = e_invarg;
7135 }
7136
7137 /* When 'buftype' is set, check for valid value. */
7138 else if (gvarp == &p_bt)
7139 {
7140 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7141 errmsg = e_invarg;
7142 else
7143 {
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007144#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007145 if (curwin->w_status_height)
7146 {
7147 curwin->w_redr_status = TRUE;
7148 redraw_later(VALID);
7149 }
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007150#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007151 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007152#ifdef FEAT_TITLE
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007153 redraw_titles();
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007154#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007155 }
7156 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007157
7158#ifdef FEAT_STL_OPT
7159 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007160 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007161 {
7162 int wid;
7163
7164 if (varp == &p_ruf) /* reset ru_wid first */
7165 ru_wid = 0;
7166 s = *varp;
7167 if (varp == &p_ruf && *s == '%')
7168 {
7169 /* set ru_wid if 'ruf' starts with "%99(" */
7170 if (*++s == '-') /* ignore a '-' */
7171 s++;
7172 wid = getdigits(&s);
7173 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7174 ru_wid = wid;
7175 else
7176 errmsg = check_stl_option(p_ruf);
7177 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007178 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007179 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007180 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007181 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007182 comp_col();
7183 }
7184#endif
7185
7186#ifdef FEAT_INS_EXPAND
7187 /* check if it is a valid value for 'complete' -- Acevedo */
7188 else if (gvarp == &p_cpt)
7189 {
7190 for (s = *varp; *s;)
7191 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007192 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007193 s++;
7194 if (!*s)
7195 break;
7196 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7197 {
7198 errmsg = illegal_char(errbuf, *s);
7199 break;
7200 }
7201 if (*++s != NUL && *s != ',' && *s != ' ')
7202 {
7203 if (s[-1] == 'k' || s[-1] == 's')
7204 {
7205 /* skip optional filename after 'k' and 's' */
7206 while (*s && *s != ',' && *s != ' ')
7207 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007208 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007209 ++s;
7210 ++s;
7211 }
7212 }
7213 else
7214 {
7215 if (errbuf != NULL)
7216 {
7217 sprintf((char *)errbuf,
7218 _("E535: Illegal character after <%c>"),
7219 *--s);
7220 errmsg = errbuf;
7221 }
7222 else
7223 errmsg = (char_u *)"";
7224 break;
7225 }
7226 }
7227 }
7228 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007229
7230 /* 'completeopt' */
7231 else if (varp == &p_cot)
7232 {
7233 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7234 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007235 else
7236 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007237 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007238#endif /* FEAT_INS_EXPAND */
7239
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007240#ifdef FEAT_SIGNS
7241 /* 'signcolumn' */
7242 else if (varp == &curwin->w_p_scl)
7243 {
7244 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7245 errmsg = e_invarg;
7246 }
7247#endif
7248
Bram Moolenaar071d4272004-06-13 20:20:40 +00007249
7250#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007251 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007252 else if (varp == &p_toolbar)
7253 {
7254 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7255 &toolbar_flags, TRUE) != OK)
7256 errmsg = e_invarg;
7257 else
7258 {
7259 out_flush();
7260 gui_mch_show_toolbar((toolbar_flags &
7261 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7262 }
7263 }
7264#endif
7265
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007266#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007267 /* 'toolbariconsize': GTK+ 2 only */
7268 else if (varp == &p_tbis)
7269 {
7270 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7271 errmsg = e_invarg;
7272 else
7273 {
7274 out_flush();
7275 gui_mch_show_toolbar((toolbar_flags &
7276 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7277 }
7278 }
7279#endif
7280
7281 /* 'pastetoggle': translate key codes like in a mapping */
7282 else if (varp == &p_pt)
7283 {
7284 if (*p_pt)
7285 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007286 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007287 if (p != NULL)
7288 {
7289 if (new_value_alloced)
7290 free_string_option(p_pt);
7291 p_pt = p;
7292 new_value_alloced = TRUE;
7293 }
7294 }
7295 }
7296
7297 /* 'backspace' */
7298 else if (varp == &p_bs)
7299 {
7300 if (VIM_ISDIGIT(*p_bs))
7301 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007302 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007303 errmsg = e_invarg;
7304 }
7305 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7306 errmsg = e_invarg;
7307 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007308 else if (varp == &p_bo)
7309 {
7310 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7311 errmsg = e_invarg;
7312 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007313
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007314 /* 'tagcase' */
7315 else if (gvarp == &p_tc)
7316 {
7317 unsigned int *flags;
7318
7319 if (opt_flags & OPT_LOCAL)
7320 {
7321 p = curbuf->b_p_tc;
7322 flags = &curbuf->b_tc_flags;
7323 }
7324 else
7325 {
7326 p = p_tc;
7327 flags = &tc_flags;
7328 }
7329
7330 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7331 /* make the local value empty: use the global value */
7332 *flags = 0;
7333 else if (*p == NUL
7334 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7335 errmsg = e_invarg;
7336 }
7337
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007338#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007339 /* 'casemap' */
7340 else if (varp == &p_cmp)
7341 {
7342 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7343 errmsg = e_invarg;
7344 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007345#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007346
7347#ifdef FEAT_DIFF
7348 /* 'diffopt' */
7349 else if (varp == &p_dip)
7350 {
7351 if (diffopt_changed() == FAIL)
7352 errmsg = e_invarg;
7353 }
7354#endif
7355
7356#ifdef FEAT_FOLDING
7357 /* 'foldmethod' */
7358 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7359 {
7360 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7361 || *curwin->w_p_fdm == NUL)
7362 errmsg = e_invarg;
7363 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007364 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007365 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007366 if (foldmethodIsDiff(curwin))
7367 newFoldLevel();
7368 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007369 }
7370# ifdef FEAT_EVAL
7371 /* 'foldexpr' */
7372 else if (varp == &curwin->w_p_fde)
7373 {
7374 if (foldmethodIsExpr(curwin))
7375 foldUpdateAll(curwin);
7376 }
7377# endif
7378 /* 'foldmarker' */
7379 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7380 {
7381 p = vim_strchr(*varp, ',');
7382 if (p == NULL)
7383 errmsg = (char_u *)N_("E536: comma required");
7384 else if (p == *varp || p[1] == NUL)
7385 errmsg = e_invarg;
7386 else if (foldmethodIsMarker(curwin))
7387 foldUpdateAll(curwin);
7388 }
7389 /* 'commentstring' */
7390 else if (gvarp == &p_cms)
7391 {
7392 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7393 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7394 }
7395 /* 'foldopen' */
7396 else if (varp == &p_fdo)
7397 {
7398 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7399 errmsg = e_invarg;
7400 }
7401 /* 'foldclose' */
7402 else if (varp == &p_fcl)
7403 {
7404 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7405 errmsg = e_invarg;
7406 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007407 /* 'foldignore' */
7408 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7409 {
7410 if (foldmethodIsIndent(curwin))
7411 foldUpdateAll(curwin);
7412 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007413#endif
7414
7415#ifdef FEAT_VIRTUALEDIT
7416 /* 'virtualedit' */
7417 else if (varp == &p_ve)
7418 {
7419 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7420 errmsg = e_invarg;
7421 else if (STRCMP(p_ve, oldval) != 0)
7422 {
7423 /* Recompute cursor position in case the new 've' setting
7424 * changes something. */
7425 validate_virtcol();
7426 coladvance(curwin->w_virtcol);
7427 }
7428 }
7429#endif
7430
7431#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7432 else if (varp == &p_csqf)
7433 {
7434 if (p_csqf != NULL)
7435 {
7436 p = p_csqf;
7437 while (*p != NUL)
7438 {
7439 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7440 || p[1] == NUL
7441 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7442 || (p[2] != NUL && p[2] != ','))
7443 {
7444 errmsg = e_invarg;
7445 break;
7446 }
7447 else if (p[2] == NUL)
7448 break;
7449 else
7450 p += 3;
7451 }
7452 }
7453 }
7454#endif
7455
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007456#ifdef FEAT_CINDENT
7457 /* 'cinoptions' */
7458 else if (gvarp == &p_cino)
7459 {
7460 /* TODO: recognize errors */
7461 parse_cino(curbuf);
7462 }
7463#endif
7464
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007465#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007466 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007467 else if (varp == &p_rop && gui.in_use)
7468 {
7469 if (!gui_mch_set_rendering_options(p_rop))
7470 errmsg = e_invarg;
7471 }
7472#endif
7473
Bram Moolenaard0b51382016-11-04 15:23:45 +01007474#ifdef FEAT_AUTOCMD
7475 else if (gvarp == &p_ft)
7476 {
7477 if (!valid_filetype(*varp))
7478 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007479 else
7480 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007481 }
7482#endif
7483
7484#ifdef FEAT_SYN_HL
7485 else if (gvarp == &p_syn)
7486 {
7487 if (!valid_filetype(*varp))
7488 errmsg = e_invarg;
7489 }
7490#endif
7491
Bram Moolenaar825680f2017-07-22 17:04:02 +02007492#ifdef FEAT_TERMINAL
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007493 /* 'termkey' */
Bram Moolenaarc4f43bc2017-07-24 20:03:01 +02007494 else if (varp == &curwin->w_p_tk)
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007495 {
7496 if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
7497 errmsg = e_invarg;
7498 }
Bram Moolenaar825680f2017-07-22 17:04:02 +02007499 /* 'termsize' */
7500 else if (varp == &curwin->w_p_tms)
7501 {
7502 if (*curwin->w_p_tms != NUL)
7503 {
7504 p = skipdigits(curwin->w_p_tms);
7505 if (p == curwin->w_p_tms || *p != 'x' || *skipdigits(p + 1) != NUL)
7506 errmsg = e_invarg;
7507 }
7508 }
7509#endif
7510
Bram Moolenaar071d4272004-06-13 20:20:40 +00007511 /* Options that are a list of flags. */
7512 else
7513 {
7514 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007515 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007516 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007517 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007518 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007519 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007520 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007521 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007522 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007523#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007524 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007525 p = (char_u *)COCU_ALL;
7526#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007527 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007528 {
7529#ifdef FEAT_MOUSE
7530 p = (char_u *)MOUSE_ALL;
7531#else
7532 if (*p_mouse != NUL)
7533 errmsg = (char_u *)N_("E538: No mouse support");
7534#endif
7535 }
7536#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007537 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007538 p = (char_u *)GO_ALL;
7539#endif
7540 if (p != NULL)
7541 {
7542 for (s = *varp; *s; ++s)
7543 if (vim_strchr(p, *s) == NULL)
7544 {
7545 errmsg = illegal_char(errbuf, *s);
7546 break;
7547 }
7548 }
7549 }
7550
7551 /*
7552 * If error detected, restore the previous value.
7553 */
7554 if (errmsg != NULL)
7555 {
7556 if (new_value_alloced)
7557 free_string_option(*varp);
7558 *varp = oldval;
7559 /*
7560 * When resetting some values, need to act on it.
7561 */
7562 if (did_chartab)
7563 (void)init_chartab();
7564 if (varp == &p_hl)
7565 (void)highlight_changed();
7566 }
7567 else
7568 {
7569#ifdef FEAT_EVAL
7570 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007571 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007572#endif
7573 /*
7574 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007575 * Use "free_oldval", because recursiveness may change the flags under
7576 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007577 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007578 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007579 free_string_option(oldval);
7580 if (new_value_alloced)
7581 options[opt_idx].flags |= P_ALLOCED;
7582 else
7583 options[opt_idx].flags &= ~P_ALLOCED;
7584
7585 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007586 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007587 {
7588 /* global option with local value set to use global value; free
7589 * the local value and make it empty */
7590 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7591 free_string_option(*(char_u **)p);
7592 *(char_u **)p = empty_option;
7593 }
7594
7595 /* May set global value for local option. */
7596 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7597 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007598
7599#ifdef FEAT_AUTOCMD
7600 /*
7601 * Trigger the autocommand only after setting the flags.
7602 */
7603# ifdef FEAT_SYN_HL
7604 /* When 'syntax' is set, load the syntax of that name */
7605 if (varp == &(curbuf->b_p_syn))
7606 {
7607 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7608 curbuf->b_fname, TRUE, curbuf);
7609 }
7610# endif
7611 else if (varp == &(curbuf->b_p_ft))
7612 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007613 /* 'filetype' is set, trigger the FileType autocommand.
7614 * Skip this when called from a modeline and the filetype was
7615 * already set to this value. */
7616 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7617 {
7618 did_filetype = TRUE;
7619 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007620 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar163095f2017-07-09 15:41:53 +02007621 /* Just in case the old "curbuf" is now invalid. */
7622 if (varp != &(curbuf->b_p_ft))
7623 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007624 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007625 }
7626#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007627#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007628 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007629 {
7630 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007631 char_u *q = curwin->w_s->b_p_spl;
7632
7633 /* Skip the first name if it is "cjk". */
7634 if (STRNCMP(q, "cjk,", 4) == 0)
7635 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007636
7637 /*
7638 * Source the spell/LANG.vim in 'runtimepath'.
7639 * They could set 'spellcapcheck' depending on the language.
7640 * Use the first name in 'spelllang' up to '_region' or
7641 * '.encoding'.
7642 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007643 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007644 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7645 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007646 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007647 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007648 }
7649#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007650 }
7651
7652#ifdef FEAT_MOUSE
7653 if (varp == &p_mouse)
7654 {
7655# ifdef FEAT_MOUSE_TTY
7656 if (*p_mouse == NUL)
7657 mch_setmouse(FALSE); /* switch mouse off */
7658 else
7659# endif
7660 setmouse(); /* in case 'mouse' changed */
7661 }
7662#endif
7663
Bram Moolenaar913077c2012-03-28 19:59:04 +02007664 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007665 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007666 curwin->w_set_curswant = TRUE;
7667
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007668#ifdef FEAT_GUI
7669 /* check redraw when it's not a GUI option or the GUI is active. */
7670 if (!redraw_gui_only || gui.in_use)
7671#endif
7672 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007673
7674 return errmsg;
7675}
7676
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007677#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007678/*
7679 * Simple int comparison function for use with qsort()
7680 */
7681 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007682int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007683{
7684 return *(const int *)a - *(const int *)b;
7685}
7686
7687/*
7688 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7689 * Returns error message, NULL if it's OK.
7690 */
7691 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007692check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007693{
7694 char_u *s;
7695 int col;
7696 int count = 0;
7697 int color_cols[256];
7698 int i;
7699 int j = 0;
7700
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007701 if (wp->w_buffer == NULL)
7702 return NULL; /* buffer was closed */
7703
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007704 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007705 {
7706 if (*s == '-' || *s == '+')
7707 {
7708 /* -N and +N: add to 'textwidth' */
7709 col = (*s == '-') ? -1 : 1;
7710 ++s;
7711 if (!VIM_ISDIGIT(*s))
7712 return e_invarg;
7713 col = col * getdigits(&s);
7714 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007715 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007716 col += wp->w_buffer->b_p_tw;
7717 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007718 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007719 }
7720 else if (VIM_ISDIGIT(*s))
7721 col = getdigits(&s);
7722 else
7723 return e_invarg;
7724 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007725skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007726 if (*s == NUL)
7727 break;
7728 if (*s != ',')
7729 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007730 if (*++s == NUL)
7731 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007732 }
7733
7734 vim_free(wp->w_p_cc_cols);
7735 if (count == 0)
7736 wp->w_p_cc_cols = NULL;
7737 else
7738 {
7739 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7740 if (wp->w_p_cc_cols != NULL)
7741 {
7742 /* sort the columns for faster usage on screen redraw inside
7743 * win_line() */
7744 qsort(color_cols, count, sizeof(int), int_cmp);
7745
7746 for (i = 0; i < count; ++i)
7747 /* skip duplicates */
7748 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7749 wp->w_p_cc_cols[j++] = color_cols[i];
7750 wp->w_p_cc_cols[j] = -1; /* end marker */
7751 }
7752 }
7753
7754 return NULL; /* no error */
7755}
7756#endif
7757
Bram Moolenaar071d4272004-06-13 20:20:40 +00007758/*
7759 * Handle setting 'listchars' or 'fillchars'.
7760 * Returns error message, NULL if it's OK.
7761 */
7762 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007763set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007764{
7765 int round, i, len, entries;
7766 char_u *p, *s;
7767 int c1, c2 = 0;
7768 struct charstab
7769 {
7770 int *cp;
7771 char *name;
7772 };
7773#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7774 static struct charstab filltab[] =
7775 {
7776 {&fill_stl, "stl"},
7777 {&fill_stlnc, "stlnc"},
7778 {&fill_vert, "vert"},
7779 {&fill_fold, "fold"},
7780 {&fill_diff, "diff"},
7781 };
7782#endif
7783 static struct charstab lcstab[] =
7784 {
7785 {&lcs_eol, "eol"},
7786 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007787 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007788 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007789 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007790 {&lcs_tab2, "tab"},
7791 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007792#ifdef FEAT_CONCEAL
7793 {&lcs_conceal, "conceal"},
7794#else
7795 {NULL, "conceal"},
7796#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007797 };
7798 struct charstab *tab;
7799
7800#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7801 if (varp == &p_lcs)
7802#endif
7803 {
7804 tab = lcstab;
7805 entries = sizeof(lcstab) / sizeof(struct charstab);
7806 }
7807#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7808 else
7809 {
7810 tab = filltab;
7811 entries = sizeof(filltab) / sizeof(struct charstab);
7812 }
7813#endif
7814
7815 /* first round: check for valid value, second round: assign values */
7816 for (round = 0; round <= 1; ++round)
7817 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007818 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007819 {
7820 /* After checking that the value is valid: set defaults: space for
7821 * 'fillchars', NUL for 'listchars' */
7822 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007823 if (tab[i].cp != NULL)
7824 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007825 if (varp == &p_lcs)
7826 lcs_tab1 = NUL;
7827#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7828 else
7829 fill_diff = '-';
7830#endif
7831 }
7832 p = *varp;
7833 while (*p)
7834 {
7835 for (i = 0; i < entries; ++i)
7836 {
7837 len = (int)STRLEN(tab[i].name);
7838 if (STRNCMP(p, tab[i].name, len) == 0
7839 && p[len] == ':'
7840 && p[len + 1] != NUL)
7841 {
7842 s = p + len + 1;
7843#ifdef FEAT_MBYTE
7844 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007845 if (mb_char2cells(c1) > 1)
7846 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007847#else
7848 c1 = *s++;
7849#endif
7850 if (tab[i].cp == &lcs_tab2)
7851 {
7852 if (*s == NUL)
7853 continue;
7854#ifdef FEAT_MBYTE
7855 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007856 if (mb_char2cells(c2) > 1)
7857 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007858#else
7859 c2 = *s++;
7860#endif
7861 }
7862 if (*s == ',' || *s == NUL)
7863 {
7864 if (round)
7865 {
7866 if (tab[i].cp == &lcs_tab2)
7867 {
7868 lcs_tab1 = c1;
7869 lcs_tab2 = c2;
7870 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007871 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007872 *(tab[i].cp) = c1;
7873
7874 }
7875 p = s;
7876 break;
7877 }
7878 }
7879 }
7880
7881 if (i == entries)
7882 return e_invarg;
7883 if (*p == ',')
7884 ++p;
7885 }
7886 }
7887
7888 return NULL; /* no error */
7889}
7890
7891#ifdef FEAT_STL_OPT
7892/*
7893 * Check validity of options with the 'statusline' format.
7894 * Return error message or NULL.
7895 */
7896 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007897check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007898{
7899 int itemcnt = 0;
7900 int groupdepth = 0;
7901 static char_u errbuf[80];
7902
7903 while (*s && itemcnt < STL_MAX_ITEM)
7904 {
7905 /* Check for valid keys after % sequences */
7906 while (*s && *s != '%')
7907 s++;
7908 if (!*s)
7909 break;
7910 s++;
7911 if (*s != '%' && *s != ')')
7912 ++itemcnt;
7913 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7914 {
7915 s++;
7916 continue;
7917 }
7918 if (*s == ')')
7919 {
7920 s++;
7921 if (--groupdepth < 0)
7922 break;
7923 continue;
7924 }
7925 if (*s == '-')
7926 s++;
7927 while (VIM_ISDIGIT(*s))
7928 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007929 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007930 continue;
7931 if (*s == '.')
7932 {
7933 s++;
7934 while (*s && VIM_ISDIGIT(*s))
7935 s++;
7936 }
7937 if (*s == '(')
7938 {
7939 groupdepth++;
7940 continue;
7941 }
7942 if (vim_strchr(STL_ALL, *s) == NULL)
7943 {
7944 return illegal_char(errbuf, *s);
7945 }
7946 if (*s == '{')
7947 {
7948 s++;
7949 while (*s != '}' && *s)
7950 s++;
7951 if (*s != '}')
7952 return (char_u *)N_("E540: Unclosed expression sequence");
7953 }
7954 }
7955 if (itemcnt >= STL_MAX_ITEM)
7956 return (char_u *)N_("E541: too many items");
7957 if (groupdepth != 0)
7958 return (char_u *)N_("E542: unbalanced groups");
7959 return NULL;
7960}
7961#endif
7962
7963#ifdef FEAT_CLIPBOARD
7964/*
7965 * Extract the items in the 'clipboard' option and set global values.
7966 */
7967 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007968check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007969{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007970 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007971 int new_autoselect_star = FALSE;
7972 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007973 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007974 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007975 regprog_T *new_exclude_prog = NULL;
7976 char_u *errmsg = NULL;
7977 char_u *p;
7978
7979 for (p = p_cb; *p != NUL; )
7980 {
7981 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7982 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007983 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007984 p += 7;
7985 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007986 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007987 && (p[11] == ',' || p[11] == NUL))
7988 {
7989 new_unnamed |= CLIP_UNNAMED_PLUS;
7990 p += 11;
7991 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007992 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007993 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007994 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007995 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007996 p += 10;
7997 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007998 else if (STRNCMP(p, "autoselectplus", 14) == 0
7999 && (p[14] == ',' || p[14] == NUL))
8000 {
8001 new_autoselect_plus = TRUE;
8002 p += 14;
8003 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008004 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02008005 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00008006 {
8007 new_autoselectml = TRUE;
8008 p += 12;
8009 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008010 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
8011 {
8012 new_html = TRUE;
8013 p += 4;
8014 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008015 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
8016 {
8017 p += 8;
8018 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
8019 if (new_exclude_prog == NULL)
8020 errmsg = e_invarg;
8021 break;
8022 }
8023 else
8024 {
8025 errmsg = e_invarg;
8026 break;
8027 }
8028 if (*p == ',')
8029 ++p;
8030 }
8031 if (errmsg == NULL)
8032 {
8033 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02008034 clip_autoselect_star = new_autoselect_star;
8035 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008036 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008037 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02008038 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008039 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02008040#ifdef FEAT_GUI_GTK
8041 if (gui.in_use)
8042 {
8043 gui_gtk_set_selection_targets();
8044 gui_gtk_set_dnd_targets();
8045 }
8046#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008047 }
8048 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008049 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008050
8051 return errmsg;
8052}
8053#endif
8054
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008055#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008056 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008057did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008058{
8059 char_u *errmsg = NULL;
8060 win_T *wp;
8061 int l;
8062
8063 if (is_spellfile)
8064 {
8065 l = (int)STRLEN(curwin->w_s->b_p_spf);
8066 if (l > 0 && (l < 4
8067 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8068 errmsg = e_invarg;
8069 }
8070
8071 if (errmsg == NULL)
8072 {
8073 FOR_ALL_WINDOWS(wp)
8074 if (wp->w_buffer == curbuf && wp->w_p_spell)
8075 {
8076 errmsg = did_set_spelllang(wp);
8077# ifdef FEAT_WINDOWS
8078 break;
8079# endif
8080 }
8081 }
8082 return errmsg;
8083}
8084
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008085/*
8086 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8087 * Return error message when failed, NULL when OK.
8088 */
8089 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008090compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008091{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008092 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008093 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008094
Bram Moolenaar860cae12010-06-05 23:22:07 +02008095 if (*synblock->b_p_spc == NUL)
8096 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008097 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008098 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008099 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008100 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008101 if (re != NULL)
8102 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008103 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008104 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008105 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008106 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008107 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008108 return e_invarg;
8109 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008110 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008111 }
8112
Bram Moolenaar473de612013-06-08 18:19:48 +02008113 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008114 return NULL;
8115}
8116#endif
8117
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008118#if defined(FEAT_EVAL) || defined(PROTO)
8119/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008120 * Set the scriptID for an option, taking care of setting the buffer- or
8121 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008122 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008123 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008124set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008125{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008126 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8127 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008128
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008129 /* Remember where the option was set. For local options need to do that
8130 * in the buffer or window structure. */
8131 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008132 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008133 if (both || (opt_flags & OPT_LOCAL))
8134 {
8135 if (indir & PV_BUF)
8136 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8137 else if (indir & PV_WIN)
8138 curwin->w_p_scriptID[indir & PV_MASK] = id;
8139 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008140}
8141#endif
8142
Bram Moolenaar071d4272004-06-13 20:20:40 +00008143/*
8144 * Set the value of a boolean option, and take care of side effects.
8145 * Returns NULL for success, or an error message for an error.
8146 */
8147 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008148set_bool_option(
8149 int opt_idx, /* index in options[] table */
8150 char_u *varp, /* pointer to the option variable */
8151 int value, /* new value */
8152 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008153{
8154 int old_value = *(int *)varp;
8155
Bram Moolenaar071d4272004-06-13 20:20:40 +00008156 /* Disallow changing some options from secure mode */
8157 if ((secure
8158#ifdef HAVE_SANDBOX
8159 || sandbox != 0
8160#endif
8161 ) && (options[opt_idx].flags & P_SECURE))
8162 return e_secure;
8163
8164 *(int *)varp = value; /* set the new value */
8165#ifdef FEAT_EVAL
8166 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008167 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008168#endif
8169
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008170#ifdef FEAT_GUI
8171 need_mouse_correct = TRUE;
8172#endif
8173
Bram Moolenaar071d4272004-06-13 20:20:40 +00008174 /* May set global value for local option. */
8175 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8176 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8177
8178 /*
8179 * Handle side effects of changing a bool option.
8180 */
8181
8182 /* 'compatible' */
8183 if ((int *)varp == &p_cp)
8184 {
8185 compatible_set();
8186 }
8187
Bram Moolenaar920694c2016-08-21 17:45:02 +02008188#ifdef FEAT_LANGMAP
8189 if ((int *)varp == &p_lrm)
8190 /* 'langremap' -> !'langnoremap' */
8191 p_lnr = !p_lrm;
8192 else if ((int *)varp == &p_lnr)
8193 /* 'langnoremap' -> !'langremap' */
8194 p_lrm = !p_lnr;
8195#endif
8196
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008197#ifdef FEAT_PERSISTENT_UNDO
8198 /* 'undofile' */
8199 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8200 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008201 /* Only take action when the option was set. When reset we do not
8202 * delete the undo file, the option may be set again without making
8203 * any changes in between. */
8204 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008205 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008206 char_u hash[UNDO_HASH_SIZE];
8207 buf_T *save_curbuf = curbuf;
8208
Bram Moolenaar29323592016-07-24 22:04:11 +02008209 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008210 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008211 /* When 'undofile' is set globally: for every buffer, otherwise
8212 * only for the current buffer: Try to read in the undofile,
8213 * if one exists, the buffer wasn't changed and the buffer was
8214 * loaded */
8215 if ((curbuf == save_curbuf
8216 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8217 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8218 {
8219 u_compute_hash(hash);
8220 u_read_undo(NULL, hash, curbuf->b_fname);
8221 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008222 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008223 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008224 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008225 }
8226#endif
8227
Bram Moolenaar071d4272004-06-13 20:20:40 +00008228 else if ((int *)varp == &curbuf->b_p_ro)
8229 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008230 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008231 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8232 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008233
8234 /* when 'readonly' is set may give W10 again */
8235 if (curbuf->b_p_ro)
8236 curbuf->b_did_warn = FALSE;
8237
Bram Moolenaar071d4272004-06-13 20:20:40 +00008238#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008239 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008240#endif
8241 }
8242
Bram Moolenaar9c449722010-07-20 18:44:27 +02008243#ifdef FEAT_GUI
8244 else if ((int *)varp == &p_mh)
8245 {
8246 if (!p_mh)
8247 gui_mch_mousehide(FALSE);
8248 }
8249#endif
8250
Bram Moolenaara539df02010-08-01 14:35:05 +02008251 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008252 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008253 {
Bram Moolenaar423802d2017-07-30 16:52:24 +02008254# ifdef FEAT_TERMINAL
8255 /* Cannot set 'modifiable' when in Terminal mode. */
Bram Moolenaar6d819742017-08-06 14:57:49 +02008256 if (term_in_normal_mode()
Bram Moolenaar20e6cd02017-08-01 20:25:22 +02008257 || (bt_terminal(curbuf) && !term_is_finished(curbuf)))
Bram Moolenaar423802d2017-07-30 16:52:24 +02008258 {
8259 curbuf->b_p_ma = FALSE;
8260 return (char_u *)N_("E946: Cannot make a terminal with running job modifiable");
8261 }
8262# endif
8263# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008264 redraw_titles();
Bram Moolenaar423802d2017-07-30 16:52:24 +02008265# endif
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008266 }
Bram Moolenaar423802d2017-07-30 16:52:24 +02008267#ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00008268 /* when 'endofline' is changed, redraw the window title */
8269 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008270 {
8271 redraw_titles();
8272 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008273 /* when 'fixeol' is changed, redraw the window title */
8274 else if ((int *)varp == &curbuf->b_p_fixeol)
8275 {
8276 redraw_titles();
8277 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008278# ifdef FEAT_MBYTE
8279 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008280 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008281 {
8282 redraw_titles();
8283 }
8284# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008285#endif
8286
8287 /* when 'bin' is set also set some other options */
8288 else if ((int *)varp == &curbuf->b_p_bin)
8289 {
8290 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8291#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008292 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008293#endif
8294 }
8295
8296#ifdef FEAT_AUTOCMD
8297 /* when 'buflisted' changes, trigger autocommands */
8298 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8299 {
8300 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8301 NULL, NULL, TRUE, curbuf);
8302 }
8303#endif
8304
8305 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8306 else if ((int *)varp == &curbuf->b_p_swf)
8307 {
8308 if (curbuf->b_p_swf && p_uc)
8309 ml_open_file(curbuf); /* create the swap file */
8310 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008311 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8312 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008313 mf_close_file(curbuf, TRUE); /* remove the swap file */
8314 }
8315
8316 /* when 'terse' is set change 'shortmess' */
8317 else if ((int *)varp == &p_terse)
8318 {
8319 char_u *p;
8320
8321 p = vim_strchr(p_shm, SHM_SEARCH);
8322
8323 /* insert 's' in p_shm */
8324 if (p_terse && p == NULL)
8325 {
8326 STRCPY(IObuff, p_shm);
8327 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008328 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008329 }
8330 /* remove 's' from p_shm */
8331 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008332 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008333 }
8334
8335 /* when 'paste' is set or reset also change other options */
8336 else if ((int *)varp == &p_paste)
8337 {
8338 paste_option_changed();
8339 }
8340
8341 /* when 'insertmode' is set from an autocommand need to do work here */
8342 else if ((int *)varp == &p_im)
8343 {
8344 if (p_im)
8345 {
8346 if ((State & INSERT) == 0)
8347 need_start_insertmode = TRUE;
8348 stop_insert_mode = FALSE;
8349 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008350 /* only reset if it was set previously */
8351 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008352 {
8353 need_start_insertmode = FALSE;
8354 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008355 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008356 clear_cmdline = TRUE; /* remove "(insert)" */
8357 restart_edit = 0;
8358 }
8359 }
8360
8361 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8362 else if ((int *)varp == &p_ic && p_hls)
8363 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008364 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008365 }
8366
8367#ifdef FEAT_SEARCH_EXTRA
8368 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8369 else if ((int *)varp == &p_hls)
8370 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008371 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008372 }
8373#endif
8374
8375#ifdef FEAT_SCROLLBIND
8376 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8377 * at the end of normal_cmd() */
8378 else if ((int *)varp == &curwin->w_p_scb)
8379 {
8380 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008381 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008382 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008383 curwin->w_scbind_pos = curwin->w_topline;
8384 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008385 }
8386#endif
8387
8388#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8389 /* There can be only one window with 'previewwindow' set. */
8390 else if ((int *)varp == &curwin->w_p_pvw)
8391 {
8392 if (curwin->w_p_pvw)
8393 {
8394 win_T *win;
8395
Bram Moolenaar29323592016-07-24 22:04:11 +02008396 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008397 if (win->w_p_pvw && win != curwin)
8398 {
8399 curwin->w_p_pvw = FALSE;
8400 return (char_u *)N_("E590: A preview window already exists");
8401 }
8402 }
8403 }
8404#endif
8405
8406 /* when 'textmode' is set or reset also change 'fileformat' */
8407 else if ((int *)varp == &curbuf->b_p_tx)
8408 {
8409 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8410 }
8411
8412 /* when 'textauto' is set or reset also change 'fileformats' */
8413 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008414 set_string_option_direct((char_u *)"ffs", -1,
8415 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008416 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008417
8418 /*
8419 * When 'lisp' option changes include/exclude '-' in
8420 * keyword characters.
8421 */
8422#ifdef FEAT_LISP
8423 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8424 {
8425 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8426 }
8427#endif
8428
8429#ifdef FEAT_TITLE
8430 /* when 'title' changed, may need to change the title; same for 'icon' */
8431 else if ((int *)varp == &p_title)
8432 {
8433 did_set_title(FALSE);
8434 }
8435
8436 else if ((int *)varp == &p_icon)
8437 {
8438 did_set_title(TRUE);
8439 }
8440#endif
8441
8442 else if ((int *)varp == &curbuf->b_changed)
8443 {
8444 if (!value)
8445 save_file_ff(curbuf); /* Buffer is unchanged */
8446#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008447 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008448#endif
8449#ifdef FEAT_AUTOCMD
8450 modified_was_set = value;
8451#endif
8452 }
8453
8454#ifdef BACKSLASH_IN_FILENAME
8455 else if ((int *)varp == &p_ssl)
8456 {
8457 if (p_ssl)
8458 {
8459 psepc = '/';
8460 psepcN = '\\';
8461 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008462 }
8463 else
8464 {
8465 psepc = '\\';
8466 psepcN = '/';
8467 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008468 }
8469
8470 /* need to adjust the file name arguments and buffer names. */
8471 buflist_slash_adjust();
8472 alist_slash_adjust();
8473# ifdef FEAT_EVAL
8474 scriptnames_slash_adjust();
8475# endif
8476 }
8477#endif
8478
8479 /* If 'wrap' is set, set w_leftcol to zero. */
8480 else if ((int *)varp == &curwin->w_p_wrap)
8481 {
8482 if (curwin->w_p_wrap)
8483 curwin->w_leftcol = 0;
8484 }
8485
8486#ifdef FEAT_WINDOWS
8487 else if ((int *)varp == &p_ea)
8488 {
8489 if (p_ea && !old_value)
8490 win_equal(curwin, FALSE, 0);
8491 }
8492#endif
8493
8494 else if ((int *)varp == &p_wiv)
8495 {
8496 /*
8497 * When 'weirdinvert' changed, set/reset 't_xs'.
8498 * Then set 'weirdinvert' according to value of 't_xs'.
8499 */
8500 if (p_wiv && !old_value)
8501 T_XS = (char_u *)"y";
8502 else if (!p_wiv && old_value)
8503 T_XS = empty_option;
8504 p_wiv = (*T_XS != NUL);
8505 }
8506
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008507#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008508 else if ((int *)varp == &p_beval)
8509 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008510 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008511 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008512 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008513 gui_mch_disable_beval_area(balloonEval);
8514 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008515#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008516
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008517#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008518 else if ((int *)varp == &p_acd)
8519 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008520 /* Change directories when the 'acd' option is set now. */
8521 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008522 }
8523#endif
8524
8525#ifdef FEAT_DIFF
8526 /* 'diff' */
8527 else if ((int *)varp == &curwin->w_p_diff)
8528 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008529 /* May add or remove the buffer from the list of diff buffers. */
8530 diff_buf_adjust(curwin);
8531# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008532 if (foldmethodIsDiff(curwin))
8533 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008534# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008535 }
8536#endif
8537
8538#ifdef USE_IM_CONTROL
8539 /* 'imdisable' */
8540 else if ((int *)varp == &p_imdisable)
8541 {
8542 /* Only de-activate it here, it will be enabled when changing mode. */
8543 if (p_imdisable)
8544 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008545 else if (State & INSERT)
8546 /* When the option is set from an autocommand, it may need to take
8547 * effect right away. */
8548 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008549 }
8550#endif
8551
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008552#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008553 /* 'spell' */
8554 else if ((int *)varp == &curwin->w_p_spell)
8555 {
8556 if (curwin->w_p_spell)
8557 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008558 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008559 if (errmsg != NULL)
8560 EMSG(_(errmsg));
8561 }
8562 }
8563#endif
8564
Bram Moolenaar071d4272004-06-13 20:20:40 +00008565#ifdef FEAT_FKMAP
8566 else if ((int *)varp == &p_altkeymap)
8567 {
8568 if (old_value != p_altkeymap)
8569 {
8570 if (!p_altkeymap)
8571 {
8572 p_hkmap = p_fkmap;
8573 p_fkmap = 0;
8574 }
8575 else
8576 {
8577 p_fkmap = p_hkmap;
8578 p_hkmap = 0;
8579 }
8580 (void)init_chartab();
8581 }
8582 }
8583
8584 /*
8585 * In case some second language keymapping options have changed, check
8586 * and correct the setting in a consistent way.
8587 */
8588
8589 /*
8590 * If hkmap or fkmap are set, reset Arabic keymapping.
8591 */
8592 if ((p_hkmap || p_fkmap) && p_altkeymap)
8593 {
8594 p_altkeymap = p_fkmap;
8595# ifdef FEAT_ARABIC
8596 curwin->w_p_arab = FALSE;
8597# endif
8598 (void)init_chartab();
8599 }
8600
8601 /*
8602 * If hkmap set, reset Farsi keymapping.
8603 */
8604 if (p_hkmap && p_altkeymap)
8605 {
8606 p_altkeymap = 0;
8607 p_fkmap = 0;
8608# ifdef FEAT_ARABIC
8609 curwin->w_p_arab = FALSE;
8610# endif
8611 (void)init_chartab();
8612 }
8613
8614 /*
8615 * If fkmap set, reset Hebrew keymapping.
8616 */
8617 if (p_fkmap && !p_altkeymap)
8618 {
8619 p_altkeymap = 1;
8620 p_hkmap = 0;
8621# ifdef FEAT_ARABIC
8622 curwin->w_p_arab = FALSE;
8623# endif
8624 (void)init_chartab();
8625 }
8626#endif
8627
8628#ifdef FEAT_ARABIC
8629 if ((int *)varp == &curwin->w_p_arab)
8630 {
8631 if (curwin->w_p_arab)
8632 {
8633 /*
8634 * 'arabic' is set, handle various sub-settings.
8635 */
8636 if (!p_tbidi)
8637 {
8638 /* set rightleft mode */
8639 if (!curwin->w_p_rl)
8640 {
8641 curwin->w_p_rl = TRUE;
8642 changed_window_setting();
8643 }
8644
8645 /* Enable Arabic shaping (major part of what Arabic requires) */
8646 if (!p_arshape)
8647 {
8648 p_arshape = TRUE;
8649 redraw_later_clear();
8650 }
8651 }
8652
8653 /* Arabic requires a utf-8 encoding, inform the user if its not
8654 * set. */
8655 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008656 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008657 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8658
Bram Moolenaar8820b482017-03-16 17:23:31 +01008659 msg_source(HL_ATTR(HLF_W));
8660 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008661#ifdef FEAT_EVAL
8662 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8663#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008664 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008665
8666# ifdef FEAT_MBYTE
8667 /* set 'delcombine' */
8668 p_deco = TRUE;
8669# endif
8670
8671# ifdef FEAT_KEYMAP
8672 /* Force-set the necessary keymap for arabic */
8673 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8674 OPT_LOCAL);
8675# endif
8676# ifdef FEAT_FKMAP
8677 p_altkeymap = 0;
8678 p_hkmap = 0;
8679 p_fkmap = 0;
8680 (void)init_chartab();
8681# endif
8682 }
8683 else
8684 {
8685 /*
8686 * 'arabic' is reset, handle various sub-settings.
8687 */
8688 if (!p_tbidi)
8689 {
8690 /* reset rightleft mode */
8691 if (curwin->w_p_rl)
8692 {
8693 curwin->w_p_rl = FALSE;
8694 changed_window_setting();
8695 }
8696
8697 /* 'arabicshape' isn't reset, it is a global option and
8698 * another window may still need it "on". */
8699 }
8700
8701 /* 'delcombine' isn't reset, it is a global option and another
8702 * window may still want it "on". */
8703
8704# ifdef FEAT_KEYMAP
8705 /* Revert to the default keymap */
8706 curbuf->b_p_iminsert = B_IMODE_NONE;
8707 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8708# endif
8709 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008710 }
8711
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008712#endif
8713
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008714#ifdef FEAT_TERMGUICOLORS
8715 /* 'termguicolors' */
8716 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008717 {
8718# ifdef FEAT_GUI
8719 if (!gui.in_use && !gui.starting)
8720# endif
8721 highlight_gui_started();
8722 }
8723#endif
8724
Bram Moolenaar071d4272004-06-13 20:20:40 +00008725 /*
8726 * End of handling side effects for bool options.
8727 */
8728
Bram Moolenaar53744302015-07-17 17:38:22 +02008729 /* after handling side effects, call autocommand */
8730
Bram Moolenaar071d4272004-06-13 20:20:40 +00008731 options[opt_idx].flags |= P_WAS_SET;
8732
Bram Moolenaar53744302015-07-17 17:38:22 +02008733#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8734 if (!starting)
8735 {
8736 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008737 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8738 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8739 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008740 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8741 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8742 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8743 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8744 reset_v_option_vars();
8745 }
8746#endif
8747
Bram Moolenaar071d4272004-06-13 20:20:40 +00008748 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008749 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008750 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008751 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008752 check_redraw(options[opt_idx].flags);
8753
8754 return NULL;
8755}
8756
8757/*
8758 * Set the value of a number option, and take care of side effects.
8759 * Returns NULL for success, or an error message for an error.
8760 */
8761 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008762set_num_option(
8763 int opt_idx, /* index in options[] table */
8764 char_u *varp, /* pointer to the option variable */
8765 long value, /* new value */
8766 char_u *errbuf, /* buffer for error messages */
8767 size_t errbuflen, /* length of "errbuf" */
8768 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008769 OPT_MODELINE */
8770{
8771 char_u *errmsg = NULL;
8772 long old_value = *(long *)varp;
8773 long old_Rows = Rows; /* remember old Rows */
8774 long old_Columns = Columns; /* remember old Columns */
8775 long *pp = (long *)varp;
8776
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008777 /* Disallow changing some options from secure mode. */
8778 if ((secure
8779#ifdef HAVE_SANDBOX
8780 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008781#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008782 ) && (options[opt_idx].flags & P_SECURE))
8783 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008784
8785 *pp = value;
8786#ifdef FEAT_EVAL
8787 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008788 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008789#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008790#ifdef FEAT_GUI
8791 need_mouse_correct = TRUE;
8792#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008793
Bram Moolenaar14f24742012-08-08 18:01:05 +02008794 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008795 {
8796 errmsg = e_positive;
8797 curbuf->b_p_sw = curbuf->b_p_ts;
8798 }
8799
8800 /*
8801 * Number options that need some action when changed
8802 */
8803#ifdef FEAT_WINDOWS
8804 if (pp == &p_wh || pp == &p_hh)
8805 {
8806 if (p_wh < 1)
8807 {
8808 errmsg = e_positive;
8809 p_wh = 1;
8810 }
8811 if (p_wmh > p_wh)
8812 {
8813 errmsg = e_winheight;
8814 p_wh = p_wmh;
8815 }
8816 if (p_hh < 0)
8817 {
8818 errmsg = e_positive;
8819 p_hh = 0;
8820 }
8821
8822 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008823 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008824 {
8825 if (pp == &p_wh && curwin->w_height < p_wh)
8826 win_setheight((int)p_wh);
8827 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8828 win_setheight((int)p_hh);
8829 }
8830 }
8831
8832 /* 'winminheight' */
8833 else if (pp == &p_wmh)
8834 {
8835 if (p_wmh < 0)
8836 {
8837 errmsg = e_positive;
8838 p_wmh = 0;
8839 }
8840 if (p_wmh > p_wh)
8841 {
8842 errmsg = e_winheight;
8843 p_wmh = p_wh;
8844 }
8845 win_setminheight();
8846 }
8847
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008848# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008849 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008850 {
8851 if (p_wiw < 1)
8852 {
8853 errmsg = e_positive;
8854 p_wiw = 1;
8855 }
8856 if (p_wmw > p_wiw)
8857 {
8858 errmsg = e_winwidth;
8859 p_wiw = p_wmw;
8860 }
8861
8862 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008863 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008864 win_setwidth((int)p_wiw);
8865 }
8866
8867 /* 'winminwidth' */
8868 else if (pp == &p_wmw)
8869 {
8870 if (p_wmw < 0)
8871 {
8872 errmsg = e_positive;
8873 p_wmw = 0;
8874 }
8875 if (p_wmw > p_wiw)
8876 {
8877 errmsg = e_winwidth;
8878 p_wmw = p_wiw;
8879 }
8880 win_setminheight();
8881 }
8882# endif
8883
8884#endif
8885
8886#ifdef FEAT_WINDOWS
8887 /* (re)set last window status line */
8888 else if (pp == &p_ls)
8889 {
8890 last_status(FALSE);
8891 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008892
8893 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008894 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008895 {
8896 shell_new_rows(); /* recompute window positions and heights */
8897 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008898#endif
8899
8900#ifdef FEAT_GUI
8901 else if (pp == &p_linespace)
8902 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008903 /* Recompute gui.char_height and resize the Vim window to keep the
8904 * same number of lines. */
8905 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008906 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008907 }
8908#endif
8909
8910#ifdef FEAT_FOLDING
8911 /* 'foldlevel' */
8912 else if (pp == &curwin->w_p_fdl)
8913 {
8914 if (curwin->w_p_fdl < 0)
8915 curwin->w_p_fdl = 0;
8916 newFoldLevel();
8917 }
8918
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008919 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008920 else if (pp == &curwin->w_p_fml)
8921 {
8922 foldUpdateAll(curwin);
8923 }
8924
8925 /* 'foldnestmax' */
8926 else if (pp == &curwin->w_p_fdn)
8927 {
8928 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8929 foldUpdateAll(curwin);
8930 }
8931
8932 /* 'foldcolumn' */
8933 else if (pp == &curwin->w_p_fdc)
8934 {
8935 if (curwin->w_p_fdc < 0)
8936 {
8937 errmsg = e_positive;
8938 curwin->w_p_fdc = 0;
8939 }
8940 else if (curwin->w_p_fdc > 12)
8941 {
8942 errmsg = e_invarg;
8943 curwin->w_p_fdc = 12;
8944 }
8945 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008946#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008947
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008948#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008949 /* 'shiftwidth' or 'tabstop' */
8950 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8951 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008952# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008953 if (foldmethodIsIndent(curwin))
8954 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008955# endif
8956# ifdef FEAT_CINDENT
8957 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8958 * parse 'cinoptions'. */
8959 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8960 parse_cino(curbuf);
8961# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008962 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008963#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008964
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008965#ifdef FEAT_MBYTE
8966 /* 'maxcombine' */
8967 else if (pp == &p_mco)
8968 {
8969 if (p_mco > MAX_MCO)
8970 p_mco = MAX_MCO;
8971 else if (p_mco < 0)
8972 p_mco = 0;
8973 screenclear(); /* will re-allocate the screen */
8974 }
8975#endif
8976
Bram Moolenaar071d4272004-06-13 20:20:40 +00008977 else if (pp == &curbuf->b_p_iminsert)
8978 {
8979 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8980 {
8981 errmsg = e_invarg;
8982 curbuf->b_p_iminsert = B_IMODE_NONE;
8983 }
8984 p_iminsert = curbuf->b_p_iminsert;
8985 if (termcap_active) /* don't do this in the alternate screen */
8986 showmode();
8987#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8988 /* Show/unshow value of 'keymap' in status lines. */
8989 status_redraw_curbuf();
8990#endif
8991 }
8992
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008993 else if (pp == &p_window)
8994 {
8995 if (p_window < 1)
8996 p_window = 1;
8997 else if (p_window >= Rows)
8998 p_window = Rows - 1;
8999 }
9000
Bram Moolenaar071d4272004-06-13 20:20:40 +00009001 else if (pp == &curbuf->b_p_imsearch)
9002 {
9003 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
9004 {
9005 errmsg = e_invarg;
9006 curbuf->b_p_imsearch = B_IMODE_NONE;
9007 }
9008 p_imsearch = curbuf->b_p_imsearch;
9009 }
9010
9011#ifdef FEAT_TITLE
9012 /* if 'titlelen' has changed, redraw the title */
9013 else if (pp == &p_titlelen)
9014 {
9015 if (p_titlelen < 0)
9016 {
9017 errmsg = e_positive;
9018 p_titlelen = 85;
9019 }
9020 if (starting != NO_SCREEN && old_value != p_titlelen)
9021 need_maketitle = TRUE;
9022 }
9023#endif
9024
9025 /* if p_ch changed value, change the command line height */
9026 else if (pp == &p_ch)
9027 {
9028 if (p_ch < 1)
9029 {
9030 errmsg = e_positive;
9031 p_ch = 1;
9032 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00009033 if (p_ch > Rows - min_rows() + 1)
9034 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009035
9036 /* Only compute the new window layout when startup has been
9037 * completed. Otherwise the frame sizes may be wrong. */
9038 if (p_ch != old_value && full_screen
9039#ifdef FEAT_GUI
9040 && !gui.starting
9041#endif
9042 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00009043 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009044 }
9045
9046 /* when 'updatecount' changes from zero to non-zero, open swap files */
9047 else if (pp == &p_uc)
9048 {
9049 if (p_uc < 0)
9050 {
9051 errmsg = e_positive;
9052 p_uc = 100;
9053 }
9054 if (p_uc && !old_value)
9055 ml_open_files();
9056 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02009057#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009058 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009059 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009060 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009061 {
9062 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009063 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009064 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009065 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009066 {
9067 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009068 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009069 }
9070 }
9071#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009072#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009073 else if (pp == &p_mzq)
9074 mzvim_reset_timer();
9075#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009076
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009077#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9078 /* 'pyxversion' */
9079 else if (pp == &p_pyx)
9080 {
9081 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9082 errmsg = e_invarg;
9083 }
9084#endif
9085
Bram Moolenaar071d4272004-06-13 20:20:40 +00009086 /* sync undo before 'undolevels' changes */
9087 else if (pp == &p_ul)
9088 {
9089 /* use the old value, otherwise u_sync() may not work properly */
9090 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009091 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009092 p_ul = value;
9093 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009094 else if (pp == &curbuf->b_p_ul)
9095 {
9096 /* use the old value, otherwise u_sync() may not work properly */
9097 curbuf->b_p_ul = old_value;
9098 u_sync(TRUE);
9099 curbuf->b_p_ul = value;
9100 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009101
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009102#ifdef FEAT_LINEBREAK
9103 /* 'numberwidth' must be positive */
9104 else if (pp == &curwin->w_p_nuw)
9105 {
9106 if (curwin->w_p_nuw < 1)
9107 {
9108 errmsg = e_positive;
9109 curwin->w_p_nuw = 1;
9110 }
9111 if (curwin->w_p_nuw > 10)
9112 {
9113 errmsg = e_invarg;
9114 curwin->w_p_nuw = 10;
9115 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009116 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009117 }
9118#endif
9119
Bram Moolenaar1a384422010-07-14 19:53:30 +02009120 else if (pp == &curbuf->b_p_tw)
9121 {
9122 if (curbuf->b_p_tw < 0)
9123 {
9124 errmsg = e_positive;
9125 curbuf->b_p_tw = 0;
9126 }
9127#ifdef FEAT_SYN_HL
9128# ifdef FEAT_WINDOWS
9129 {
9130 win_T *wp;
9131 tabpage_T *tp;
9132
9133 FOR_ALL_TAB_WINDOWS(tp, wp)
9134 check_colorcolumn(wp);
9135 }
9136# else
9137 check_colorcolumn(curwin);
9138# endif
9139#endif
9140 }
9141
Bram Moolenaar071d4272004-06-13 20:20:40 +00009142 /*
9143 * Check the bounds for numeric options here
9144 */
9145 if (Rows < min_rows() && full_screen)
9146 {
9147 if (errbuf != NULL)
9148 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009149 vim_snprintf((char *)errbuf, errbuflen,
9150 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009151 errmsg = errbuf;
9152 }
9153 Rows = min_rows();
9154 }
9155 if (Columns < MIN_COLUMNS && full_screen)
9156 {
9157 if (errbuf != NULL)
9158 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009159 vim_snprintf((char *)errbuf, errbuflen,
9160 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009161 errmsg = errbuf;
9162 }
9163 Columns = MIN_COLUMNS;
9164 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009165 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009166
Bram Moolenaar071d4272004-06-13 20:20:40 +00009167 /*
9168 * If the screen (shell) height has been changed, assume it is the
9169 * physical screenheight.
9170 */
9171 if (old_Rows != Rows || old_Columns != Columns)
9172 {
9173 /* Changing the screen size is not allowed while updating the screen. */
9174 if (updating_screen)
9175 *pp = old_value;
9176 else if (full_screen
9177#ifdef FEAT_GUI
9178 && !gui.starting
9179#endif
9180 )
9181 set_shellsize((int)Columns, (int)Rows, TRUE);
9182 else
9183 {
9184 /* Postpone the resizing; check the size and cmdline position for
9185 * messages. */
9186 check_shellsize();
9187 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9188 cmdline_row = Rows - p_ch;
9189 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009190 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009191 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009192 }
9193
Bram Moolenaar071d4272004-06-13 20:20:40 +00009194 if (curbuf->b_p_ts <= 0)
9195 {
9196 errmsg = e_positive;
9197 curbuf->b_p_ts = 8;
9198 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009199 if (p_tm < 0)
9200 {
9201 errmsg = e_positive;
9202 p_tm = 0;
9203 }
9204 if ((curwin->w_p_scr <= 0
9205 || (curwin->w_p_scr > curwin->w_height
9206 && curwin->w_height > 0))
9207 && full_screen)
9208 {
9209 if (pp == &(curwin->w_p_scr))
9210 {
9211 if (curwin->w_p_scr != 0)
9212 errmsg = e_scroll;
9213 win_comp_scroll(curwin);
9214 }
9215 /* If 'scroll' became invalid because of a side effect silently adjust
9216 * it. */
9217 else if (curwin->w_p_scr <= 0)
9218 curwin->w_p_scr = 1;
9219 else /* curwin->w_p_scr > curwin->w_height */
9220 curwin->w_p_scr = curwin->w_height;
9221 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009222 if (p_hi < 0)
9223 {
9224 errmsg = e_positive;
9225 p_hi = 0;
9226 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009227 else if (p_hi > 10000)
9228 {
9229 errmsg = e_invarg;
9230 p_hi = 10000;
9231 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009232 if (p_re < 0 || p_re > 2)
9233 {
9234 errmsg = e_invarg;
9235 p_re = 0;
9236 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009237 if (p_report < 0)
9238 {
9239 errmsg = e_positive;
9240 p_report = 1;
9241 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009242 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009243 {
9244 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9245 p_sj = Rows / 2;
9246 else
9247 {
9248 errmsg = e_scroll;
9249 p_sj = 1;
9250 }
9251 }
9252 if (p_so < 0 && full_screen)
9253 {
9254 errmsg = e_scroll;
9255 p_so = 0;
9256 }
9257 if (p_siso < 0 && full_screen)
9258 {
9259 errmsg = e_positive;
9260 p_siso = 0;
9261 }
9262#ifdef FEAT_CMDWIN
9263 if (p_cwh < 1)
9264 {
9265 errmsg = e_positive;
9266 p_cwh = 1;
9267 }
9268#endif
9269 if (p_ut < 0)
9270 {
9271 errmsg = e_positive;
9272 p_ut = 2000;
9273 }
9274 if (p_ss < 0)
9275 {
9276 errmsg = e_positive;
9277 p_ss = 0;
9278 }
9279
9280 /* May set global value for local option. */
9281 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9282 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9283
9284 options[opt_idx].flags |= P_WAS_SET;
9285
Bram Moolenaar53744302015-07-17 17:38:22 +02009286#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9287 if (!starting && errmsg == NULL)
9288 {
9289 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009290 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9291 vim_snprintf((char *)buf_new, 10, "%ld", value);
9292 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009293 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9294 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9295 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9296 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9297 reset_v_option_vars();
9298 }
9299#endif
9300
Bram Moolenaar071d4272004-06-13 20:20:40 +00009301 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009302 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009303 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009304 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009305 check_redraw(options[opt_idx].flags);
9306
9307 return errmsg;
9308}
9309
9310/*
9311 * Called after an option changed: check if something needs to be redrawn.
9312 */
9313 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009314check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009315{
9316 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009317 int doclear = (flags & P_RCLR) == P_RCLR;
9318 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009319
9320#ifdef FEAT_WINDOWS
9321 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9322 status_redraw_all();
9323#endif
9324
9325 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9326 changed_window_setting();
9327 if (flags & P_RBUF)
9328 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009329 if (flags & P_RWINONLY)
9330 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009331 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009332 redraw_all_later(CLEAR);
9333 else if (all)
9334 redraw_all_later(NOT_VALID);
9335}
9336
9337/*
9338 * Find index for option 'arg'.
9339 * Return -1 if not found.
9340 */
9341 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009342findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009343{
9344 int opt_idx;
9345 char *s, *p;
9346 static short quick_tab[27] = {0, 0}; /* quick access table */
9347 int is_term_opt;
9348
9349 /*
9350 * For first call: Initialize the quick-access table.
9351 * It contains the index for the first option that starts with a certain
9352 * letter. There are 26 letters, plus the first "t_" option.
9353 */
9354 if (quick_tab[1] == 0)
9355 {
9356 p = options[0].fullname;
9357 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9358 {
9359 if (s[0] != p[0])
9360 {
9361 if (s[0] == 't' && s[1] == '_')
9362 quick_tab[26] = opt_idx;
9363 else
9364 quick_tab[CharOrdLow(s[0])] = opt_idx;
9365 }
9366 p = s;
9367 }
9368 }
9369
9370 /*
9371 * Check for name starting with an illegal character.
9372 */
9373#ifdef EBCDIC
9374 if (!islower(arg[0]))
9375#else
9376 if (arg[0] < 'a' || arg[0] > 'z')
9377#endif
9378 return -1;
9379
9380 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9381 if (is_term_opt)
9382 opt_idx = quick_tab[26];
9383 else
9384 opt_idx = quick_tab[CharOrdLow(arg[0])];
9385 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9386 {
9387 if (STRCMP(arg, s) == 0) /* match full name */
9388 break;
9389 }
9390 if (s == NULL && !is_term_opt)
9391 {
9392 opt_idx = quick_tab[CharOrdLow(arg[0])];
9393 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9394 {
9395 s = options[opt_idx].shortname;
9396 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9397 break;
9398 s = NULL;
9399 }
9400 }
9401 if (s == NULL)
9402 opt_idx = -1;
9403 return opt_idx;
9404}
9405
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009406#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009407/*
9408 * Get the value for an option.
9409 *
9410 * Returns:
9411 * Number or Toggle option: 1, *numval gets value.
9412 * String option: 0, *stringval gets allocated string.
9413 * Hidden Number or Toggle option: -1.
9414 * hidden String option: -2.
9415 * unknown option: -3.
9416 */
9417 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009418get_option_value(
9419 char_u *name,
9420 long *numval,
9421 char_u **stringval, /* NULL when only checking existence */
9422 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009423{
9424 int opt_idx;
9425 char_u *varp;
9426
9427 opt_idx = findoption(name);
9428 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009429 {
9430 int key;
9431
9432 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9433 && (key = find_key_option(name)) != 0)
9434 {
9435 char_u key_name[2];
9436 char_u *p;
9437
9438 if (key < 0)
9439 {
9440 key_name[0] = KEY2TERMCAP0(key);
9441 key_name[1] = KEY2TERMCAP1(key);
9442 }
9443 else
9444 {
9445 key_name[0] = KS_KEY;
9446 key_name[1] = (key & 0xff);
9447 }
9448 p = find_termcode(key_name);
9449 if (p != NULL)
9450 {
9451 if (stringval != NULL)
9452 *stringval = vim_strsave(p);
9453 return 0;
9454 }
9455 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009456 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009457 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009458
9459 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9460
9461 if (options[opt_idx].flags & P_STRING)
9462 {
9463 if (varp == NULL) /* hidden option */
9464 return -2;
9465 if (stringval != NULL)
9466 {
9467#ifdef FEAT_CRYPT
9468 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009469 if ((char_u **)varp == &curbuf->b_p_key
9470 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009471 *stringval = vim_strsave((char_u *)"*****");
9472 else
9473#endif
9474 *stringval = vim_strsave(*(char_u **)(varp));
9475 }
9476 return 0;
9477 }
9478
9479 if (varp == NULL) /* hidden option */
9480 return -1;
9481 if (options[opt_idx].flags & P_NUM)
9482 *numval = *(long *)varp;
9483 else
9484 {
9485 /* Special case: 'modified' is b_changed, but we also want to consider
9486 * it set when 'ff' or 'fenc' changed. */
9487 if ((int *)varp == &curbuf->b_changed)
9488 *numval = curbufIsChanged();
9489 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009490 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009491 }
9492 return 1;
9493}
9494#endif
9495
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009496#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009497/*
9498 * Returns the option attributes and its value. Unlike the above function it
9499 * will return either global value or local value of the option depending on
9500 * what was requested, but it will never return global value if it was
9501 * requested to return local one and vice versa. Neither it will return
9502 * buffer-local value if it was requested to return window-local one.
9503 *
9504 * Pretends that option is absent if it is not present in the requested scope
9505 * (i.e. has no global, window-local or buffer-local value depending on
9506 * opt_type). Uses
9507 *
9508 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009509 * 0 hidden or unknown option, also option that does not have requested
9510 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009511 * see SOPT_* in vim.h for other flags
9512 *
9513 * Possible opt_type values: see SREQ_* in vim.h
9514 */
9515 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009516get_option_value_strict(
9517 char_u *name,
9518 long *numval,
9519 char_u **stringval, /* NULL when only obtaining attributes */
9520 int opt_type,
9521 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009522{
9523 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009524 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009525 struct vimoption *p;
9526 int r = 0;
9527
9528 opt_idx = findoption(name);
9529 if (opt_idx < 0)
9530 return 0;
9531
9532 p = &(options[opt_idx]);
9533
9534 /* Hidden option */
9535 if (p->var == NULL)
9536 return 0;
9537
9538 if (p->flags & P_BOOL)
9539 r |= SOPT_BOOL;
9540 else if (p->flags & P_NUM)
9541 r |= SOPT_NUM;
9542 else if (p->flags & P_STRING)
9543 r |= SOPT_STRING;
9544
9545 if (p->indir == PV_NONE)
9546 {
9547 if (opt_type == SREQ_GLOBAL)
9548 r |= SOPT_GLOBAL;
9549 else
9550 return 0; /* Did not request global-only option */
9551 }
9552 else
9553 {
9554 if (p->indir & PV_BOTH)
9555 r |= SOPT_GLOBAL;
9556 else if (opt_type == SREQ_GLOBAL)
9557 return 0; /* Requested global option */
9558
9559 if (p->indir & PV_WIN)
9560 {
9561 if (opt_type == SREQ_BUF)
9562 return 0; /* Did not request window-local option */
9563 else
9564 r |= SOPT_WIN;
9565 }
9566 else if (p->indir & PV_BUF)
9567 {
9568 if (opt_type == SREQ_WIN)
9569 return 0; /* Did not request buffer-local option */
9570 else
9571 r |= SOPT_BUF;
9572 }
9573 }
9574
9575 if (stringval == NULL)
9576 return r;
9577
9578 if (opt_type == SREQ_GLOBAL)
9579 varp = p->var;
9580 else
9581 {
9582 if (opt_type == SREQ_BUF)
9583 {
9584 /* Special case: 'modified' is b_changed, but we also want to
9585 * consider it set when 'ff' or 'fenc' changed. */
9586 if (p->indir == PV_MOD)
9587 {
9588 *numval = bufIsChanged((buf_T *) from);
9589 varp = NULL;
9590 }
9591#ifdef FEAT_CRYPT
9592 else if (p->indir == PV_KEY)
9593 {
9594 /* never return the value of the crypt key */
9595 *stringval = NULL;
9596 varp = NULL;
9597 }
9598#endif
9599 else
9600 {
9601 aco_save_T aco;
9602 aucmd_prepbuf(&aco, (buf_T *) from);
9603 varp = get_varp(p);
9604 aucmd_restbuf(&aco);
9605 }
9606 }
9607 else if (opt_type == SREQ_WIN)
9608 {
9609 win_T *save_curwin;
9610 save_curwin = curwin;
9611 curwin = (win_T *) from;
9612 curbuf = curwin->w_buffer;
9613 varp = get_varp(p);
9614 curwin = save_curwin;
9615 curbuf = curwin->w_buffer;
9616 }
9617 if (varp == p->var)
9618 return (r | SOPT_UNSET);
9619 }
9620
9621 if (varp != NULL)
9622 {
9623 if (p->flags & P_STRING)
9624 *stringval = vim_strsave(*(char_u **)(varp));
9625 else if (p->flags & P_NUM)
9626 *numval = *(long *) varp;
9627 else
9628 *numval = *(int *)varp;
9629 }
9630
9631 return r;
9632}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009633
9634/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009635 * Iterate over options. First argument is a pointer to a pointer to a
9636 * structure inside options[] array, second is option type like in the above
9637 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009638 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009639 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009640 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009641 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009642 * first argument to NULL.
9643 *
9644 * Returns full option name for current option on each call.
9645 */
9646 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009647option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009648{
9649 struct vimoption *ret = NULL;
9650 do
9651 {
9652 if (*option == NULL)
9653 *option = (void *) options;
9654 else if (((struct vimoption *) (*option))->fullname == NULL)
9655 {
9656 *option = NULL;
9657 return NULL;
9658 }
9659 else
9660 *option = (void *) (((struct vimoption *) (*option)) + 1);
9661
9662 ret = ((struct vimoption *) (*option));
9663
9664 /* Hidden option */
9665 if (ret->var == NULL)
9666 {
9667 ret = NULL;
9668 continue;
9669 }
9670
9671 switch (opt_type)
9672 {
9673 case SREQ_GLOBAL:
9674 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9675 ret = NULL;
9676 break;
9677 case SREQ_BUF:
9678 if (!(ret->indir & PV_BUF))
9679 ret = NULL;
9680 break;
9681 case SREQ_WIN:
9682 if (!(ret->indir & PV_WIN))
9683 ret = NULL;
9684 break;
9685 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009686 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009687 return NULL;
9688 }
9689 }
9690 while (ret == NULL);
9691
9692 return (char_u *)ret->fullname;
9693}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009694#endif
9695
Bram Moolenaar071d4272004-06-13 20:20:40 +00009696/*
9697 * Set the value of option "name".
9698 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009699 *
9700 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009701 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009702 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009703set_option_value(
9704 char_u *name,
9705 long number,
9706 char_u *string,
9707 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009708{
9709 int opt_idx;
9710 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009711 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009712
9713 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009714 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009715 {
9716 int key;
9717
9718 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9719 && (key = find_key_option(name)) != 0)
9720 {
9721 char_u key_name[2];
9722
9723 if (key < 0)
9724 {
9725 key_name[0] = KEY2TERMCAP0(key);
9726 key_name[1] = KEY2TERMCAP1(key);
9727 }
9728 else
9729 {
9730 key_name[0] = KS_KEY;
9731 key_name[1] = (key & 0xff);
9732 }
9733 add_termcode(key_name, string, FALSE);
9734 if (full_screen)
9735 ttest(FALSE);
9736 redraw_all_later(CLEAR);
9737 return NULL;
9738 }
9739
Bram Moolenaar071d4272004-06-13 20:20:40 +00009740 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009741 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009742 else
9743 {
9744 flags = options[opt_idx].flags;
9745#ifdef HAVE_SANDBOX
9746 /* Disallow changing some options in the sandbox */
9747 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009748 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009749 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009750 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009751 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009752#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009753 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009754 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009755 else
9756 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009757 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009758 if (varp != NULL) /* hidden option is not changed */
9759 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009760 if (number == 0 && string != NULL)
9761 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009762 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009763
9764 /* Either we are given a string or we are setting option
9765 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009766 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009767 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009768 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009769 {
9770 /* There's another character after zeros or the string
9771 * is empty. In both cases, we are trying to set a
9772 * num option using a string. */
9773 EMSG3(_("E521: Number required: &%s = '%s'"),
9774 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009775 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009776
9777 }
9778 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009779 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009780 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009781 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009782 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009783 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009784 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009785 }
9786 }
9787 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009788 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009789}
9790
9791/*
9792 * Get the terminal code for a terminal option.
9793 * Returns NULL when not found.
9794 */
9795 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009796get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009797{
9798 int opt_idx;
9799 char_u *varp;
9800
9801 if (tname[0] != 't' || tname[1] != '_' ||
9802 tname[2] == NUL || tname[3] == NUL)
9803 return NULL;
9804 if ((opt_idx = findoption(tname)) >= 0)
9805 {
9806 varp = get_varp(&(options[opt_idx]));
9807 if (varp != NULL)
9808 varp = *(char_u **)(varp);
9809 return varp;
9810 }
9811 return find_termcode(tname + 2);
9812}
9813
9814 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009815get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009816{
9817 int i;
9818
9819 i = findoption((char_u *)"hl");
9820 if (i >= 0)
9821 return options[i].def_val[VI_DEFAULT];
9822 return (char_u *)NULL;
9823}
9824
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009825#if defined(FEAT_MBYTE) || defined(PROTO)
9826 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009827get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009828{
9829 int i;
9830
9831 i = findoption((char_u *)"enc");
9832 if (i >= 0)
9833 return options[i].def_val[VI_DEFAULT];
9834 return (char_u *)NULL;
9835}
9836#endif
9837
Bram Moolenaar071d4272004-06-13 20:20:40 +00009838/*
9839 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9840 */
9841 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009842find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009843{
9844 int key;
9845 int modifiers;
9846
9847 /*
9848 * Don't use get_special_key_code() for t_xx, we don't want it to call
9849 * add_termcap_entry().
9850 */
9851 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9852 key = TERMCAP2KEY(arg[2], arg[3]);
9853 else
9854 {
9855 --arg; /* put arg at the '<' */
9856 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009857 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009858 if (modifiers) /* can't handle modifiers here */
9859 key = 0;
9860 }
9861 return key;
9862}
9863
9864/*
9865 * if 'all' == 0: show changed options
9866 * if 'all' == 1: show all normal options
9867 * if 'all' == 2: show all terminal options
9868 */
9869 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009870showoptions(
9871 int all,
9872 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009873{
9874 struct vimoption *p;
9875 int col;
9876 int isterm;
9877 char_u *varp;
9878 struct vimoption **items;
9879 int item_count;
9880 int run;
9881 int row, rows;
9882 int cols;
9883 int i;
9884 int len;
9885
9886#define INC 20
9887#define GAP 3
9888
9889 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9890 PARAM_COUNT));
9891 if (items == NULL)
9892 return;
9893
9894 /* Highlight title */
9895 if (all == 2)
9896 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9897 else if (opt_flags & OPT_GLOBAL)
9898 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9899 else if (opt_flags & OPT_LOCAL)
9900 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9901 else
9902 MSG_PUTS_TITLE(_("\n--- Options ---"));
9903
9904 /*
9905 * do the loop two times:
9906 * 1. display the short items
9907 * 2. display the long items (only strings and numbers)
9908 */
9909 for (run = 1; run <= 2 && !got_int; ++run)
9910 {
9911 /*
9912 * collect the items in items[]
9913 */
9914 item_count = 0;
9915 for (p = &options[0]; p->fullname != NULL; p++)
9916 {
9917 varp = NULL;
9918 isterm = istermoption(p);
9919 if (opt_flags != 0)
9920 {
9921 if (p->indir != PV_NONE && !isterm)
9922 varp = get_varp_scope(p, opt_flags);
9923 }
9924 else
9925 varp = get_varp(p);
9926 if (varp != NULL
9927 && ((all == 2 && isterm)
9928 || (all == 1 && !isterm)
9929 || (all == 0 && !optval_default(p, varp))))
9930 {
9931 if (p->flags & P_BOOL)
9932 len = 1; /* a toggle option fits always */
9933 else
9934 {
9935 option_value2string(p, opt_flags);
9936 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9937 }
9938 if ((len <= INC - GAP && run == 1) ||
9939 (len > INC - GAP && run == 2))
9940 items[item_count++] = p;
9941 }
9942 }
9943
9944 /*
9945 * display the items
9946 */
9947 if (run == 1)
9948 {
9949 cols = (Columns + GAP - 3) / INC;
9950 if (cols == 0)
9951 cols = 1;
9952 rows = (item_count + cols - 1) / cols;
9953 }
9954 else /* run == 2 */
9955 rows = item_count;
9956 for (row = 0; row < rows && !got_int; ++row)
9957 {
9958 msg_putchar('\n'); /* go to next line */
9959 if (got_int) /* 'q' typed in more */
9960 break;
9961 col = 0;
9962 for (i = row; i < item_count; i += rows)
9963 {
9964 msg_col = col; /* make columns */
9965 showoneopt(items[i], opt_flags);
9966 col += INC;
9967 }
9968 out_flush();
9969 ui_breakcheck();
9970 }
9971 }
9972 vim_free(items);
9973}
9974
9975/*
9976 * Return TRUE if option "p" has its default value.
9977 */
9978 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009979optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009980{
9981 int dvi;
9982
9983 if (varp == NULL)
9984 return TRUE; /* hidden option is always at default */
9985 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9986 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009987 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009988 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009989 /* the cast to long is required for Manx C, long_i is
9990 * needed for MSVC */
9991 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009992 /* P_STRING */
9993 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9994}
9995
9996/*
9997 * showoneopt: show the value of one option
9998 * must not be called with a hidden option!
9999 */
10000 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010001showoneopt(
10002 struct vimoption *p,
10003 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010004{
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010005 char_u *varp;
10006 int save_silent = silent_mode;
10007
10008 silent_mode = FALSE;
10009 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010010
10011 varp = get_varp_scope(p, opt_flags);
10012
10013 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
10014 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
10015 ? !curbufIsChanged() : !*(int *)varp))
10016 MSG_PUTS("no");
10017 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
10018 MSG_PUTS("--");
10019 else
10020 MSG_PUTS(" ");
10021 MSG_PUTS(p->fullname);
10022 if (!(p->flags & P_BOOL))
10023 {
10024 msg_putchar('=');
10025 /* put value string in NameBuff */
10026 option_value2string(p, opt_flags);
10027 msg_outtrans(NameBuff);
10028 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010029
10030 silent_mode = save_silent;
10031 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010032}
10033
10034/*
10035 * Write modified options as ":set" commands to a file.
10036 *
10037 * There are three values for "opt_flags":
10038 * OPT_GLOBAL: Write global option values and fresh values of
10039 * buffer-local options (used for start of a session
10040 * file).
10041 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
10042 * curwin (used for a vimrc file).
10043 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
10044 * and local values for window-local options of
10045 * curwin. Local values are also written when at the
10046 * default value, because a modeline or autocommand
10047 * may have set them when doing ":edit file" and the
10048 * user has set them back at the default or fresh
10049 * value.
10050 * When "local_only" is TRUE, don't write fresh
10051 * values, only local values (for ":mkview").
10052 * (fresh value = value used for a new buffer or window for a local option).
10053 *
10054 * Return FAIL on error, OK otherwise.
10055 */
10056 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010057makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010058{
10059 struct vimoption *p;
10060 char_u *varp; /* currently used value */
10061 char_u *varp_fresh; /* local value */
10062 char_u *varp_local = NULL; /* fresh value */
10063 char *cmd;
10064 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010065 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010066
10067 /*
10068 * The options that don't have a default (terminal name, columns, lines)
10069 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010070 * Do the loop over "options[]" twice: once for options with the
10071 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010072 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010073 for (pri = 1; pri >= 0; --pri)
10074 {
10075 for (p = &options[0]; !istermoption(p); p++)
10076 if (!(p->flags & P_NO_MKRC)
10077 && !istermoption(p)
10078 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010079 {
10080 /* skip global option when only doing locals */
10081 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10082 continue;
10083
10084 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10085 * file, they are always buffer-specific. */
10086 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10087 continue;
10088
10089 /* Global values are only written when not at the default value. */
10090 varp = get_varp_scope(p, opt_flags);
10091 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10092 continue;
10093
10094 round = 2;
10095 if (p->indir != PV_NONE)
10096 {
10097 if (p->var == VAR_WIN)
10098 {
10099 /* skip window-local option when only doing globals */
10100 if (!(opt_flags & OPT_LOCAL))
10101 continue;
10102 /* When fresh value of window-local option is not at the
10103 * default, need to write it too. */
10104 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10105 {
10106 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10107 if (!optval_default(p, varp_fresh))
10108 {
10109 round = 1;
10110 varp_local = varp;
10111 varp = varp_fresh;
10112 }
10113 }
10114 }
10115 }
10116
10117 /* Round 1: fresh value for window-local options.
10118 * Round 2: other values */
10119 for ( ; round <= 2; varp = varp_local, ++round)
10120 {
10121 if (round == 1 || (opt_flags & OPT_GLOBAL))
10122 cmd = "set";
10123 else
10124 cmd = "setlocal";
10125
10126 if (p->flags & P_BOOL)
10127 {
10128 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10129 return FAIL;
10130 }
10131 else if (p->flags & P_NUM)
10132 {
10133 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10134 return FAIL;
10135 }
10136 else /* P_STRING */
10137 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010138#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10139 int do_endif = FALSE;
10140
Bram Moolenaar071d4272004-06-13 20:20:40 +000010141 /* Don't set 'syntax' and 'filetype' again if the value is
10142 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010143 if (
10144# if defined(FEAT_SYN_HL)
10145 p->indir == PV_SYN
10146# if defined(FEAT_AUTOCMD)
10147 ||
10148# endif
10149# endif
10150# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010151 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010152# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010153 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010154 {
10155 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10156 *(char_u **)(varp)) < 0
10157 || put_eol(fd) < 0)
10158 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010159 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010160 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010161#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010162 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10163 (p->flags & P_EXPAND) != 0) == FAIL)
10164 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010165#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10166 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010167 {
10168 if (put_line(fd, "endif") == FAIL)
10169 return FAIL;
10170 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010171#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010172 }
10173 }
10174 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010175 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010176 return OK;
10177}
10178
10179#if defined(FEAT_FOLDING) || defined(PROTO)
10180/*
10181 * Generate set commands for the local fold options only. Used when
10182 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10183 */
10184 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010185makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010186{
10187 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10188# ifdef FEAT_EVAL
10189 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10190 == FAIL
10191# endif
10192 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10193 == FAIL
10194 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10195 == FAIL
10196 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10197 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10198 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10199 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10200 )
10201 return FAIL;
10202
10203 return OK;
10204}
10205#endif
10206
10207 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010208put_setstring(
10209 FILE *fd,
10210 char *cmd,
10211 char *name,
10212 char_u **valuep,
10213 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010214{
10215 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010216 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010217
10218 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10219 return FAIL;
10220 if (*valuep != NULL)
10221 {
10222 /* Output 'pastetoggle' as key names. For other
10223 * options some characters have to be escaped with
10224 * CTRL-V or backslash */
10225 if (valuep == &p_pt)
10226 {
10227 s = *valuep;
10228 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010229 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010230 return FAIL;
10231 }
10232 else if (expand)
10233 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010234 buf = alloc(MAXPATHL);
10235 if (buf == NULL)
10236 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10238 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010239 {
10240 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010241 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010242 }
10243 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010244 }
10245 else if (put_escstr(fd, *valuep, 2) == FAIL)
10246 return FAIL;
10247 }
10248 if (put_eol(fd) < 0)
10249 return FAIL;
10250 return OK;
10251}
10252
10253 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010254put_setnum(
10255 FILE *fd,
10256 char *cmd,
10257 char *name,
10258 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010259{
10260 long wc;
10261
10262 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10263 return FAIL;
10264 if (wc_use_keyname((char_u *)valuep, &wc))
10265 {
10266 /* print 'wildchar' and 'wildcharm' as a key name */
10267 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10268 return FAIL;
10269 }
10270 else if (fprintf(fd, "%ld", *valuep) < 0)
10271 return FAIL;
10272 if (put_eol(fd) < 0)
10273 return FAIL;
10274 return OK;
10275}
10276
10277 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010278put_setbool(
10279 FILE *fd,
10280 char *cmd,
10281 char *name,
10282 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010283{
Bram Moolenaar893de922007-10-02 18:40:57 +000010284 if (value < 0) /* global/local option using global value */
10285 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010286 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10287 || put_eol(fd) < 0)
10288 return FAIL;
10289 return OK;
10290}
10291
10292/*
10293 * Clear all the terminal options.
10294 * If the option has been allocated, free the memory.
10295 * Terminal options are never hidden or indirect.
10296 */
10297 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010298clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010299{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010300 /*
10301 * Reset a few things before clearing the old options. This may cause
10302 * outputting a few things that the terminal doesn't understand, but the
10303 * screen will be cleared later, so this is OK.
10304 */
10305#ifdef FEAT_MOUSE_TTY
10306 mch_setmouse(FALSE); /* switch mouse off */
10307#endif
10308#ifdef FEAT_TITLE
10309 mch_restore_title(3); /* restore window titles */
10310#endif
10311#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10312 /* When starting the GUI close the display opened for the clipboard.
10313 * After restoring the title, because that will need the display. */
10314 if (gui.starting)
10315 clear_xterm_clip();
10316#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010317 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010318
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010319 free_termoptions();
10320}
10321
10322 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010323free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010324{
10325 struct vimoption *p;
10326
Bram Moolenaar071d4272004-06-13 20:20:40 +000010327 for (p = &options[0]; p->fullname != NULL; p++)
10328 if (istermoption(p))
10329 {
10330 if (p->flags & P_ALLOCED)
10331 free_string_option(*(char_u **)(p->var));
10332 if (p->flags & P_DEF_ALLOCED)
10333 free_string_option(p->def_val[VI_DEFAULT]);
10334 *(char_u **)(p->var) = empty_option;
10335 p->def_val[VI_DEFAULT] = empty_option;
10336 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10337 }
10338 clear_termcodes();
10339}
10340
10341/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010342 * Free the string for one term option, if it was allocated.
10343 * Set the string to empty_option and clear allocated flag.
10344 * "var" points to the option value.
10345 */
10346 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010347free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010348{
10349 struct vimoption *p;
10350
10351 for (p = &options[0]; p->fullname != NULL; p++)
10352 if (p->var == var)
10353 {
10354 if (p->flags & P_ALLOCED)
10355 free_string_option(*(char_u **)(p->var));
10356 *(char_u **)(p->var) = empty_option;
10357 p->flags &= ~P_ALLOCED;
10358 break;
10359 }
10360}
10361
10362/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010363 * Set the terminal option defaults to the current value.
10364 * Used after setting the terminal name.
10365 */
10366 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010367set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010368{
10369 struct vimoption *p;
10370
10371 for (p = &options[0]; p->fullname != NULL; p++)
10372 {
10373 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10374 {
10375 if (p->flags & P_DEF_ALLOCED)
10376 {
10377 free_string_option(p->def_val[VI_DEFAULT]);
10378 p->flags &= ~P_DEF_ALLOCED;
10379 }
10380 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10381 if (p->flags & P_ALLOCED)
10382 {
10383 p->flags |= P_DEF_ALLOCED;
10384 p->flags &= ~P_ALLOCED; /* don't free the value now */
10385 }
10386 }
10387 }
10388}
10389
10390/*
10391 * return TRUE if 'p' starts with 't_'
10392 */
10393 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010394istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010395{
10396 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10397}
10398
10399/*
10400 * Compute columns for ruler and shown command. 'sc_col' is also used to
10401 * decide what the maximum length of a message on the status line can be.
10402 * If there is a status line for the last window, 'sc_col' is independent
10403 * of 'ru_col'.
10404 */
10405
10406#define COL_RULER 17 /* columns needed by standard ruler */
10407
10408 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010409comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010410{
10411#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010412 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010413
10414 sc_col = 0;
10415 ru_col = 0;
10416 if (p_ru)
10417 {
10418#ifdef FEAT_STL_OPT
10419 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10420#else
10421 ru_col = COL_RULER + 1;
10422#endif
10423 /* no last status line, adjust sc_col */
10424 if (!last_has_status)
10425 sc_col = ru_col;
10426 }
10427 if (p_sc)
10428 {
10429 sc_col += SHOWCMD_COLS;
10430 if (!p_ru || last_has_status) /* no need for separating space */
10431 ++sc_col;
10432 }
10433 sc_col = Columns - sc_col;
10434 ru_col = Columns - ru_col;
10435 if (sc_col <= 0) /* screen too narrow, will become a mess */
10436 sc_col = 1;
10437 if (ru_col <= 0)
10438 ru_col = 1;
10439#else
10440 sc_col = Columns;
10441 ru_col = Columns;
10442#endif
10443}
10444
10445/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010446 * Unset local option value, similar to ":set opt<".
10447 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010448 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010449unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010450{
10451 struct vimoption *p;
10452 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010453 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010454
10455 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010456 if (opt_idx < 0)
10457 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010458 p = &(options[opt_idx]);
10459
10460 switch ((int)p->indir)
10461 {
10462 /* global option with local value: use local value if it's been set */
10463 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010464 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010465 break;
10466 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010467 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010468 break;
10469 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010470 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010471 break;
10472 case PV_AR:
10473 buf->b_p_ar = -1;
10474 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010475 case PV_BKC:
10476 clear_string_option(&buf->b_p_bkc);
10477 buf->b_bkc_flags = 0;
10478 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010479 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010480 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010481 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010482 case PV_TC:
10483 clear_string_option(&buf->b_p_tc);
10484 buf->b_tc_flags = 0;
10485 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010486#ifdef FEAT_FIND_ID
10487 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010488 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010489 break;
10490 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010491 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010492 break;
10493#endif
10494#ifdef FEAT_INS_EXPAND
10495 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010496 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010497 break;
10498 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010499 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010500 break;
10501#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010502 case PV_FP:
10503 clear_string_option(&buf->b_p_fp);
10504 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010505#ifdef FEAT_QUICKFIX
10506 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010507 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010508 break;
10509 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010510 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010511 break;
10512 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010513 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010514 break;
10515#endif
10516#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10517 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010518 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010519 break;
10520#endif
10521#if defined(FEAT_CRYPT)
10522 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010523 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010524 break;
10525#endif
10526#ifdef FEAT_STL_OPT
10527 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010528 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010529 break;
10530#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010531 case PV_UL:
10532 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10533 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010534#ifdef FEAT_LISP
10535 case PV_LW:
10536 clear_string_option(&buf->b_p_lw);
10537 break;
10538#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010539#ifdef FEAT_MBYTE
10540 case PV_MENC:
10541 clear_string_option(&buf->b_p_menc);
10542 break;
10543#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010544 }
10545}
10546
10547/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010548 * Get pointer to option variable, depending on local or global scope.
10549 */
10550 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010551get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010552{
10553 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10554 {
10555 if (p->var == VAR_WIN)
10556 return (char_u *)GLOBAL_WO(get_varp(p));
10557 return p->var;
10558 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010559 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010560 {
10561 switch ((int)p->indir)
10562 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010563 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010564#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010565 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10566 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10567 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010568#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010569 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10570 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10571 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010572 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010573 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010574 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010575#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010576 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10577 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010578#endif
10579#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010580 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10581 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010582#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010583#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10584 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10585#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010586#if defined(FEAT_CRYPT)
10587 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10588#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010589#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010590 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010591#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010592 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010593#ifdef FEAT_LISP
10594 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10595#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010596 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010597#ifdef FEAT_MBYTE
10598 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10599#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010600 }
10601 return NULL; /* "cannot happen" */
10602 }
10603 return get_varp(p);
10604}
10605
10606/*
10607 * Get pointer to option variable.
10608 */
10609 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010610get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010611{
10612 /* hidden option, always return NULL */
10613 if (p->var == NULL)
10614 return NULL;
10615
10616 switch ((int)p->indir)
10617 {
10618 case PV_NONE: return p->var;
10619
10620 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010621 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010622 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010623 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010624 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010625 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010626 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010627 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010628 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010629 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010630 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010631 case PV_TC: return *curbuf->b_p_tc != NUL
10632 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010633 case PV_BKC: return *curbuf->b_p_bkc != NUL
10634 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010635#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010636 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010637 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010638 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010639 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10640#endif
10641#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010642 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010643 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010644 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010645 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10646#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010647 case PV_FP: return *curbuf->b_p_fp != NUL
10648 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010649#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010650 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010651 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010652 case PV_GP: return *curbuf->b_p_gp != NUL
10653 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10654 case PV_MP: return *curbuf->b_p_mp != NUL
10655 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010656#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010657#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10658 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10659 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10660#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010661#if defined(FEAT_CRYPT)
10662 case PV_CM: return *curbuf->b_p_cm != NUL
10663 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10664#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010665#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010666 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010667 ? (char_u *)&(curwin->w_p_stl) : p->var;
10668#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010669 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10670 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010671#ifdef FEAT_LISP
10672 case PV_LW: return *curbuf->b_p_lw != NUL
10673 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10674#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010675#ifdef FEAT_MBYTE
10676 case PV_MENC: return *curbuf->b_p_menc != NUL
10677 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10678#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010679
10680#ifdef FEAT_ARABIC
10681 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10682#endif
10683 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010684#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010685 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10686#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010687#ifdef FEAT_SYN_HL
10688 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10689 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010690 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010691#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010692#ifdef FEAT_DIFF
10693 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10694#endif
10695#ifdef FEAT_FOLDING
10696 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10697 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10698 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10699 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10700 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10701 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10702 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10703# ifdef FEAT_EVAL
10704 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10705 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10706# endif
10707 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10708#endif
10709 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010710 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010711#ifdef FEAT_LINEBREAK
10712 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10713#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010714#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010715 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010716 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10717#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010718#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10719 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10720#endif
10721#ifdef FEAT_RIGHTLEFT
10722 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10723 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10724#endif
10725 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10726 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10727#ifdef FEAT_LINEBREAK
10728 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010729 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10730 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010731#endif
10732#ifdef FEAT_SCROLLBIND
10733 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10734#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010735#ifdef FEAT_CURSORBIND
10736 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10737#endif
10738#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010739 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10740 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10741#endif
10742#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +020010743 case PV_TK: return (char_u *)&(curwin->w_p_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010744 case PV_TMS: return (char_u *)&(curwin->w_p_tms);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010745#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010746
10747 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10748 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10749#ifdef FEAT_MBYTE
10750 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10751#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010752 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10753 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010754 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10755 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10756#ifdef FEAT_CINDENT
10757 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10758 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10759 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10760#endif
10761#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10762 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10763#endif
10764#ifdef FEAT_COMMENTS
10765 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10766#endif
10767#ifdef FEAT_FOLDING
10768 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10769#endif
10770#ifdef FEAT_INS_EXPAND
10771 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10772#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010773#ifdef FEAT_COMPL_FUNC
10774 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010775 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010776#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010777 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010778 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010779 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10780#ifdef FEAT_MBYTE
10781 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10782#endif
10783 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10784#ifdef FEAT_AUTOCMD
10785 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10786#endif
10787 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010788 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010789 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10790 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10791 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10792 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10793#ifdef FEAT_FIND_ID
10794# ifdef FEAT_EVAL
10795 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10796# endif
10797#endif
10798#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10799 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10800 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10801#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010802#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010803 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10804#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010805#ifdef FEAT_CRYPT
10806 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10807#endif
10808#ifdef FEAT_LISP
10809 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10810#endif
10811 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10812 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10813 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10814 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10815 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010816 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010817#ifdef FEAT_TEXTOBJ
10818 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10819#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010820 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10821#ifdef FEAT_SMARTINDENT
10822 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10823#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010825 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10826#ifdef FEAT_SEARCHPATH
10827 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10828#endif
10829 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10830#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010831 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010832 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10833#endif
10834#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010835 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10836 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10837 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010838#endif
10839 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10840 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10841 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10842 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010843#ifdef FEAT_PERSISTENT_UNDO
10844 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10845#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010846 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10847#ifdef FEAT_KEYMAP
10848 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10849#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010850#ifdef FEAT_SIGNS
10851 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10852#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010853 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010854 }
10855 /* always return a valid pointer to avoid a crash! */
10856 return (char_u *)&(curbuf->b_p_wm);
10857}
10858
10859/*
10860 * Get the value of 'equalprg', either the buffer-local one or the global one.
10861 */
10862 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010863get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010864{
10865 if (*curbuf->b_p_ep == NUL)
10866 return p_ep;
10867 return curbuf->b_p_ep;
10868}
10869
10870#if defined(FEAT_WINDOWS) || defined(PROTO)
10871/*
10872 * Copy options from one window to another.
10873 * Used when splitting a window.
10874 */
10875 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010876win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010877{
10878 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10879 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10880# ifdef FEAT_RIGHTLEFT
10881# ifdef FEAT_FKMAP
10882 /* Is this right? */
10883 wp_to->w_farsi = wp_from->w_farsi;
10884# endif
10885# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010886#if defined(FEAT_LINEBREAK)
10887 briopt_check(wp_to);
10888#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010889}
10890#endif
10891
10892/*
10893 * Copy the options from one winopt_T to another.
10894 * Doesn't free the old option values in "to", use clear_winopt() for that.
10895 * The 'scroll' option is not copied, because it depends on the window height.
10896 * The 'previewwindow' option is reset, there can be only one preview window.
10897 */
10898 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010899copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010900{
10901#ifdef FEAT_ARABIC
10902 to->wo_arab = from->wo_arab;
10903#endif
10904 to->wo_list = from->wo_list;
10905 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010906 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010907#ifdef FEAT_LINEBREAK
10908 to->wo_nuw = from->wo_nuw;
10909#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010910#ifdef FEAT_RIGHTLEFT
10911 to->wo_rl = from->wo_rl;
10912 to->wo_rlc = vim_strsave(from->wo_rlc);
10913#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010914#ifdef FEAT_STL_OPT
10915 to->wo_stl = vim_strsave(from->wo_stl);
10916#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010917 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010918#ifdef FEAT_DIFF
10919 to->wo_wrap_save = from->wo_wrap_save;
10920#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010921#ifdef FEAT_LINEBREAK
10922 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010923 to->wo_bri = from->wo_bri;
10924 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010925#endif
10926#ifdef FEAT_SCROLLBIND
10927 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010928 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010929#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010930#ifdef FEAT_CURSORBIND
10931 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010932 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010933#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010934#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010935 to->wo_spell = from->wo_spell;
10936#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010937#ifdef FEAT_SYN_HL
10938 to->wo_cuc = from->wo_cuc;
10939 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010940 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010941#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010942#ifdef FEAT_DIFF
10943 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010944 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010945#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010946#ifdef FEAT_CONCEAL
10947 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010948 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010949#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010950#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010951 to->wo_tk = vim_strsave(from->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010952 to->wo_tms = vim_strsave(from->wo_tms);
10953#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010954#ifdef FEAT_FOLDING
10955 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010956 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010957 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010958 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010959 to->wo_fdi = vim_strsave(from->wo_fdi);
10960 to->wo_fml = from->wo_fml;
10961 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010962 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010963 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010964 to->wo_fdm_save = from->wo_diff_saved
10965 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010966 to->wo_fdn = from->wo_fdn;
10967# ifdef FEAT_EVAL
10968 to->wo_fde = vim_strsave(from->wo_fde);
10969 to->wo_fdt = vim_strsave(from->wo_fdt);
10970# endif
10971 to->wo_fmr = vim_strsave(from->wo_fmr);
10972#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010973#ifdef FEAT_SIGNS
10974 to->wo_scl = vim_strsave(from->wo_scl);
10975#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010976 check_winopt(to); /* don't want NULL pointers */
10977}
10978
10979/*
10980 * Check string options in a window for a NULL value.
10981 */
10982 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010983check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010984{
10985 check_winopt(&win->w_onebuf_opt);
10986 check_winopt(&win->w_allbuf_opt);
10987}
10988
10989/*
10990 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10991 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010992 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010993check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010994{
10995#ifdef FEAT_FOLDING
10996 check_string_option(&wop->wo_fdi);
10997 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010998 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010999# ifdef FEAT_EVAL
11000 check_string_option(&wop->wo_fde);
11001 check_string_option(&wop->wo_fdt);
11002# endif
11003 check_string_option(&wop->wo_fmr);
11004#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011005#ifdef FEAT_SIGNS
11006 check_string_option(&wop->wo_scl);
11007#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011008#ifdef FEAT_RIGHTLEFT
11009 check_string_option(&wop->wo_rlc);
11010#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011011#ifdef FEAT_STL_OPT
11012 check_string_option(&wop->wo_stl);
11013#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011014#ifdef FEAT_SYN_HL
11015 check_string_option(&wop->wo_cc);
11016#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011017#ifdef FEAT_CONCEAL
11018 check_string_option(&wop->wo_cocu);
11019#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011020#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011021 check_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011022 check_string_option(&wop->wo_tms);
11023#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011024#ifdef FEAT_LINEBREAK
11025 check_string_option(&wop->wo_briopt);
11026#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011027}
11028
11029/*
11030 * Free the allocated memory inside a winopt_T.
11031 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011032 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011033clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011034{
11035#ifdef FEAT_FOLDING
11036 clear_string_option(&wop->wo_fdi);
11037 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011038 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011039# ifdef FEAT_EVAL
11040 clear_string_option(&wop->wo_fde);
11041 clear_string_option(&wop->wo_fdt);
11042# endif
11043 clear_string_option(&wop->wo_fmr);
11044#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011045#ifdef FEAT_SIGNS
11046 clear_string_option(&wop->wo_scl);
11047#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011048#ifdef FEAT_LINEBREAK
11049 clear_string_option(&wop->wo_briopt);
11050#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011051#ifdef FEAT_RIGHTLEFT
11052 clear_string_option(&wop->wo_rlc);
11053#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011054#ifdef FEAT_STL_OPT
11055 clear_string_option(&wop->wo_stl);
11056#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011057#ifdef FEAT_SYN_HL
11058 clear_string_option(&wop->wo_cc);
11059#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011060#ifdef FEAT_CONCEAL
11061 clear_string_option(&wop->wo_cocu);
11062#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011063#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011064 clear_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011065 clear_string_option(&wop->wo_tms);
11066#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011067}
11068
11069/*
11070 * Copy global option values to local options for one buffer.
11071 * Used when creating a new buffer and sometimes when entering a buffer.
11072 * flags:
11073 * BCO_ENTER We will enter the buf buffer.
11074 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11075 * appropriate.
11076 * BCO_NOHELP Don't copy the values to a help buffer.
11077 */
11078 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011079buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011080{
11081 int should_copy = TRUE;
11082 char_u *save_p_isk = NULL; /* init for GCC */
11083 int dont_do_help;
11084 int did_isk = FALSE;
11085
11086 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011087 * Skip this when the option defaults have not been set yet. Happens when
11088 * main() allocates the first buffer.
11089 */
11090 if (p_cpo != NULL)
11091 {
11092 /*
11093 * Always copy when entering and 'cpo' contains 'S'.
11094 * Don't copy when already initialized.
11095 * Don't copy when 'cpo' contains 's' and not entering.
11096 * 'S' BCO_ENTER initialized 's' should_copy
11097 * yes yes X X TRUE
11098 * yes no yes X FALSE
11099 * no X yes X FALSE
11100 * X no no yes FALSE
11101 * X no no no TRUE
11102 * no yes no X TRUE
11103 */
11104 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11105 && (buf->b_p_initialized
11106 || (!(flags & BCO_ENTER)
11107 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11108 should_copy = FALSE;
11109
11110 if (should_copy || (flags & BCO_ALWAYS))
11111 {
11112 /* Don't copy the options specific to a help buffer when
11113 * BCO_NOHELP is given or the options were initialized already
11114 * (jumping back to a help file with CTRL-T or CTRL-O) */
11115 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11116 || buf->b_p_initialized;
11117 if (dont_do_help) /* don't free b_p_isk */
11118 {
11119 save_p_isk = buf->b_p_isk;
11120 buf->b_p_isk = NULL;
11121 }
11122 /*
11123 * Always free the allocated strings.
11124 * If not already initialized, set 'readonly' and copy 'fileformat'.
11125 */
11126 if (!buf->b_p_initialized)
11127 {
11128 free_buf_options(buf, TRUE);
11129 buf->b_p_ro = FALSE; /* don't copy readonly */
11130 buf->b_p_tx = p_tx;
11131#ifdef FEAT_MBYTE
11132 buf->b_p_fenc = vim_strsave(p_fenc);
11133#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011134 switch (*p_ffs)
11135 {
11136 case 'm':
11137 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11138 case 'd':
11139 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11140 case 'u':
11141 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11142 default:
11143 buf->b_p_ff = vim_strsave(p_ff);
11144 }
11145 if (buf->b_p_ff != NULL)
11146 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011147 buf->b_p_bh = empty_option;
11148 buf->b_p_bt = empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011149 }
11150 else
11151 free_buf_options(buf, FALSE);
11152
11153 buf->b_p_ai = p_ai;
11154 buf->b_p_ai_nopaste = p_ai_nopaste;
11155 buf->b_p_sw = p_sw;
11156 buf->b_p_tw = p_tw;
11157 buf->b_p_tw_nopaste = p_tw_nopaste;
11158 buf->b_p_tw_nobin = p_tw_nobin;
11159 buf->b_p_wm = p_wm;
11160 buf->b_p_wm_nopaste = p_wm_nopaste;
11161 buf->b_p_wm_nobin = p_wm_nobin;
11162 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011163#ifdef FEAT_MBYTE
11164 buf->b_p_bomb = p_bomb;
11165#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011166 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011167 buf->b_p_et = p_et;
11168 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011169 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011170 buf->b_p_ml = p_ml;
11171 buf->b_p_ml_nobin = p_ml_nobin;
11172 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011173 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011174#ifdef FEAT_INS_EXPAND
11175 buf->b_p_cpt = vim_strsave(p_cpt);
11176#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011177#ifdef FEAT_COMPL_FUNC
11178 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011179 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011180#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011181 buf->b_p_sts = p_sts;
11182 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011183 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011184#ifdef FEAT_COMMENTS
11185 buf->b_p_com = vim_strsave(p_com);
11186#endif
11187#ifdef FEAT_FOLDING
11188 buf->b_p_cms = vim_strsave(p_cms);
11189#endif
11190 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011191 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011192 buf->b_p_nf = vim_strsave(p_nf);
11193 buf->b_p_mps = vim_strsave(p_mps);
11194#ifdef FEAT_SMARTINDENT
11195 buf->b_p_si = p_si;
11196#endif
11197 buf->b_p_ci = p_ci;
11198#ifdef FEAT_CINDENT
11199 buf->b_p_cin = p_cin;
11200 buf->b_p_cink = vim_strsave(p_cink);
11201 buf->b_p_cino = vim_strsave(p_cino);
11202#endif
11203#ifdef FEAT_AUTOCMD
11204 /* Don't copy 'filetype', it must be detected */
11205 buf->b_p_ft = empty_option;
11206#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011207 buf->b_p_pi = p_pi;
11208#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11209 buf->b_p_cinw = vim_strsave(p_cinw);
11210#endif
11211#ifdef FEAT_LISP
11212 buf->b_p_lisp = p_lisp;
11213#endif
11214#ifdef FEAT_SYN_HL
11215 /* Don't copy 'syntax', it must be set */
11216 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011217 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011218 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011219#endif
11220#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011221 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011222 (void)compile_cap_prog(&buf->b_s);
11223 buf->b_s.b_p_spf = vim_strsave(p_spf);
11224 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011225#endif
11226#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11227 buf->b_p_inde = vim_strsave(p_inde);
11228 buf->b_p_indk = vim_strsave(p_indk);
11229#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011230 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011231#if defined(FEAT_EVAL)
11232 buf->b_p_fex = vim_strsave(p_fex);
11233#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011234#ifdef FEAT_CRYPT
11235 buf->b_p_key = vim_strsave(p_key);
11236#endif
11237#ifdef FEAT_SEARCHPATH
11238 buf->b_p_sua = vim_strsave(p_sua);
11239#endif
11240#ifdef FEAT_KEYMAP
11241 buf->b_p_keymap = vim_strsave(p_keymap);
11242 buf->b_kmap_state |= KEYMAP_INIT;
11243#endif
11244 /* This isn't really an option, but copying the langmap and IME
11245 * state from the current buffer is better than resetting it. */
11246 buf->b_p_iminsert = p_iminsert;
11247 buf->b_p_imsearch = p_imsearch;
11248
11249 /* options that are normally global but also have a local value
11250 * are not copied, start using the global value */
11251 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011252 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011253 buf->b_p_bkc = empty_option;
11254 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011255#ifdef FEAT_QUICKFIX
11256 buf->b_p_gp = empty_option;
11257 buf->b_p_mp = empty_option;
11258 buf->b_p_efm = empty_option;
11259#endif
11260 buf->b_p_ep = empty_option;
11261 buf->b_p_kp = empty_option;
11262 buf->b_p_path = empty_option;
11263 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011264 buf->b_p_tc = empty_option;
11265 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011266#ifdef FEAT_FIND_ID
11267 buf->b_p_def = empty_option;
11268 buf->b_p_inc = empty_option;
11269# ifdef FEAT_EVAL
11270 buf->b_p_inex = vim_strsave(p_inex);
11271# endif
11272#endif
11273#ifdef FEAT_INS_EXPAND
11274 buf->b_p_dict = empty_option;
11275 buf->b_p_tsr = empty_option;
11276#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011277#ifdef FEAT_TEXTOBJ
11278 buf->b_p_qe = vim_strsave(p_qe);
11279#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011280#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11281 buf->b_p_bexpr = empty_option;
11282#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011283#if defined(FEAT_CRYPT)
11284 buf->b_p_cm = empty_option;
11285#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011286#ifdef FEAT_PERSISTENT_UNDO
11287 buf->b_p_udf = p_udf;
11288#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011289#ifdef FEAT_LISP
11290 buf->b_p_lw = empty_option;
11291#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011292#ifdef FEAT_MBYTE
11293 buf->b_p_menc = empty_option;
11294#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011295
11296 /*
11297 * Don't copy the options set by ex_help(), use the saved values,
11298 * when going from a help buffer to a non-help buffer.
11299 * Don't touch these at all when BCO_NOHELP is used and going from
11300 * or to a help buffer.
11301 */
11302 if (dont_do_help)
11303 buf->b_p_isk = save_p_isk;
11304 else
11305 {
11306 buf->b_p_isk = vim_strsave(p_isk);
11307 did_isk = TRUE;
11308 buf->b_p_ts = p_ts;
11309 buf->b_help = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011310 if (buf->b_p_bt[0] == 'h')
11311 clear_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011312 buf->b_p_ma = p_ma;
11313 }
11314 }
11315
11316 /*
11317 * When the options should be copied (ignoring BCO_ALWAYS), set the
11318 * flag that indicates that the options have been initialized.
11319 */
11320 if (should_copy)
11321 buf->b_p_initialized = TRUE;
11322 }
11323
11324 check_buf_options(buf); /* make sure we don't have NULLs */
11325 if (did_isk)
11326 (void)buf_init_chartab(buf, FALSE);
11327}
11328
11329/*
11330 * Reset the 'modifiable' option and its default value.
11331 */
11332 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011333reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011334{
11335 int opt_idx;
11336
11337 curbuf->b_p_ma = FALSE;
11338 p_ma = FALSE;
11339 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011340 if (opt_idx >= 0)
11341 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011342}
11343
11344/*
11345 * Set the global value for 'iminsert' to the local value.
11346 */
11347 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011348set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011349{
11350 p_iminsert = curbuf->b_p_iminsert;
11351}
11352
11353/*
11354 * Set the global value for 'imsearch' to the local value.
11355 */
11356 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011357set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011358{
11359 p_imsearch = curbuf->b_p_imsearch;
11360}
11361
11362#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11363static int expand_option_idx = -1;
11364static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11365static int expand_option_flags = 0;
11366
11367 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011368set_context_in_set_cmd(
11369 expand_T *xp,
11370 char_u *arg,
11371 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011372{
11373 int nextchar;
11374 long_u flags = 0; /* init for GCC */
11375 int opt_idx = 0; /* init for GCC */
11376 char_u *p;
11377 char_u *s;
11378 int is_term_option = FALSE;
11379 int key;
11380
11381 expand_option_flags = opt_flags;
11382
11383 xp->xp_context = EXPAND_SETTINGS;
11384 if (*arg == NUL)
11385 {
11386 xp->xp_pattern = arg;
11387 return;
11388 }
11389 p = arg + STRLEN(arg) - 1;
11390 if (*p == ' ' && *(p - 1) != '\\')
11391 {
11392 xp->xp_pattern = p + 1;
11393 return;
11394 }
11395 while (p > arg)
11396 {
11397 s = p;
11398 /* count number of backslashes before ' ' or ',' */
11399 if (*p == ' ' || *p == ',')
11400 {
11401 while (s > arg && *(s - 1) == '\\')
11402 --s;
11403 }
11404 /* break at a space with an even number of backslashes */
11405 if (*p == ' ' && ((p - s) & 1) == 0)
11406 {
11407 ++p;
11408 break;
11409 }
11410 --p;
11411 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011412 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011413 {
11414 xp->xp_context = EXPAND_BOOL_SETTINGS;
11415 p += 2;
11416 }
11417 if (STRNCMP(p, "inv", 3) == 0)
11418 {
11419 xp->xp_context = EXPAND_BOOL_SETTINGS;
11420 p += 3;
11421 }
11422 xp->xp_pattern = arg = p;
11423 if (*arg == '<')
11424 {
11425 while (*p != '>')
11426 if (*p++ == NUL) /* expand terminal option name */
11427 return;
11428 key = get_special_key_code(arg + 1);
11429 if (key == 0) /* unknown name */
11430 {
11431 xp->xp_context = EXPAND_NOTHING;
11432 return;
11433 }
11434 nextchar = *++p;
11435 is_term_option = TRUE;
11436 expand_option_name[2] = KEY2TERMCAP0(key);
11437 expand_option_name[3] = KEY2TERMCAP1(key);
11438 }
11439 else
11440 {
11441 if (p[0] == 't' && p[1] == '_')
11442 {
11443 p += 2;
11444 if (*p != NUL)
11445 ++p;
11446 if (*p == NUL)
11447 return; /* expand option name */
11448 nextchar = *++p;
11449 is_term_option = TRUE;
11450 expand_option_name[2] = p[-2];
11451 expand_option_name[3] = p[-1];
11452 }
11453 else
11454 {
11455 /* Allow * wildcard */
11456 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11457 p++;
11458 if (*p == NUL)
11459 return;
11460 nextchar = *p;
11461 *p = NUL;
11462 opt_idx = findoption(arg);
11463 *p = nextchar;
11464 if (opt_idx == -1 || options[opt_idx].var == NULL)
11465 {
11466 xp->xp_context = EXPAND_NOTHING;
11467 return;
11468 }
11469 flags = options[opt_idx].flags;
11470 if (flags & P_BOOL)
11471 {
11472 xp->xp_context = EXPAND_NOTHING;
11473 return;
11474 }
11475 }
11476 }
11477 /* handle "-=" and "+=" */
11478 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11479 {
11480 ++p;
11481 nextchar = '=';
11482 }
11483 if ((nextchar != '=' && nextchar != ':')
11484 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11485 {
11486 xp->xp_context = EXPAND_UNSUCCESSFUL;
11487 return;
11488 }
11489 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11490 {
11491 xp->xp_context = EXPAND_OLD_SETTING;
11492 if (is_term_option)
11493 expand_option_idx = -1;
11494 else
11495 expand_option_idx = opt_idx;
11496 xp->xp_pattern = p + 1;
11497 return;
11498 }
11499 xp->xp_context = EXPAND_NOTHING;
11500 if (is_term_option || (flags & P_NUM))
11501 return;
11502
11503 xp->xp_pattern = p + 1;
11504
11505 if (flags & P_EXPAND)
11506 {
11507 p = options[opt_idx].var;
11508 if (p == (char_u *)&p_bdir
11509 || p == (char_u *)&p_dir
11510 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011511 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011512 || p == (char_u *)&p_rtp
11513#ifdef FEAT_SEARCHPATH
11514 || p == (char_u *)&p_cdpath
11515#endif
11516#ifdef FEAT_SESSION
11517 || p == (char_u *)&p_vdir
11518#endif
11519 )
11520 {
11521 xp->xp_context = EXPAND_DIRECTORIES;
11522 if (p == (char_u *)&p_path
11523#ifdef FEAT_SEARCHPATH
11524 || p == (char_u *)&p_cdpath
11525#endif
11526 )
11527 xp->xp_backslash = XP_BS_THREE;
11528 else
11529 xp->xp_backslash = XP_BS_ONE;
11530 }
11531 else
11532 {
11533 xp->xp_context = EXPAND_FILES;
11534 /* for 'tags' need three backslashes for a space */
11535 if (p == (char_u *)&p_tags)
11536 xp->xp_backslash = XP_BS_THREE;
11537 else
11538 xp->xp_backslash = XP_BS_ONE;
11539 }
11540 }
11541
11542 /* For an option that is a list of file names, find the start of the
11543 * last file name. */
11544 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11545 {
11546 /* count number of backslashes before ' ' or ',' */
11547 if (*p == ' ' || *p == ',')
11548 {
11549 s = p;
11550 while (s > xp->xp_pattern && *(s - 1) == '\\')
11551 --s;
11552 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11553 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11554 {
11555 xp->xp_pattern = p + 1;
11556 break;
11557 }
11558 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011559
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011560#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011561 /* for 'spellsuggest' start at "file:" */
11562 if (options[opt_idx].var == (char_u *)&p_sps
11563 && STRNCMP(p, "file:", 5) == 0)
11564 {
11565 xp->xp_pattern = p + 5;
11566 break;
11567 }
11568#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011569 }
11570
11571 return;
11572}
11573
11574 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011575ExpandSettings(
11576 expand_T *xp,
11577 regmatch_T *regmatch,
11578 int *num_file,
11579 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011580{
11581 int num_normal = 0; /* Nr of matching non-term-code settings */
11582 int num_term = 0; /* Nr of matching terminal code settings */
11583 int opt_idx;
11584 int match;
11585 int count = 0;
11586 char_u *str;
11587 int loop;
11588 int is_term_opt;
11589 char_u name_buf[MAX_KEY_NAME_LEN];
11590 static char *(names[]) = {"all", "termcap"};
11591 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11592
11593 /* do this loop twice:
11594 * loop == 0: count the number of matching options
11595 * loop == 1: copy the matching options into allocated memory
11596 */
11597 for (loop = 0; loop <= 1; ++loop)
11598 {
11599 regmatch->rm_ic = ic;
11600 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11601 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011602 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11603 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011604 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11605 {
11606 if (loop == 0)
11607 num_normal++;
11608 else
11609 (*file)[count++] = vim_strsave((char_u *)names[match]);
11610 }
11611 }
11612 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11613 opt_idx++)
11614 {
11615 if (options[opt_idx].var == NULL)
11616 continue;
11617 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11618 && !(options[opt_idx].flags & P_BOOL))
11619 continue;
11620 is_term_opt = istermoption(&options[opt_idx]);
11621 if (is_term_opt && num_normal > 0)
11622 continue;
11623 match = FALSE;
11624 if (vim_regexec(regmatch, str, (colnr_T)0)
11625 || (options[opt_idx].shortname != NULL
11626 && vim_regexec(regmatch,
11627 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11628 match = TRUE;
11629 else if (is_term_opt)
11630 {
11631 name_buf[0] = '<';
11632 name_buf[1] = 't';
11633 name_buf[2] = '_';
11634 name_buf[3] = str[2];
11635 name_buf[4] = str[3];
11636 name_buf[5] = '>';
11637 name_buf[6] = NUL;
11638 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11639 {
11640 match = TRUE;
11641 str = name_buf;
11642 }
11643 }
11644 if (match)
11645 {
11646 if (loop == 0)
11647 {
11648 if (is_term_opt)
11649 num_term++;
11650 else
11651 num_normal++;
11652 }
11653 else
11654 (*file)[count++] = vim_strsave(str);
11655 }
11656 }
11657 /*
11658 * Check terminal key codes, these are not in the option table
11659 */
11660 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11661 {
11662 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11663 {
11664 if (!isprint(str[0]) || !isprint(str[1]))
11665 continue;
11666
11667 name_buf[0] = 't';
11668 name_buf[1] = '_';
11669 name_buf[2] = str[0];
11670 name_buf[3] = str[1];
11671 name_buf[4] = NUL;
11672
11673 match = FALSE;
11674 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11675 match = TRUE;
11676 else
11677 {
11678 name_buf[0] = '<';
11679 name_buf[1] = 't';
11680 name_buf[2] = '_';
11681 name_buf[3] = str[0];
11682 name_buf[4] = str[1];
11683 name_buf[5] = '>';
11684 name_buf[6] = NUL;
11685
11686 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11687 match = TRUE;
11688 }
11689 if (match)
11690 {
11691 if (loop == 0)
11692 num_term++;
11693 else
11694 (*file)[count++] = vim_strsave(name_buf);
11695 }
11696 }
11697
11698 /*
11699 * Check special key names.
11700 */
11701 regmatch->rm_ic = TRUE; /* ignore case here */
11702 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11703 {
11704 name_buf[0] = '<';
11705 STRCPY(name_buf + 1, str);
11706 STRCAT(name_buf, ">");
11707
11708 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11709 {
11710 if (loop == 0)
11711 num_term++;
11712 else
11713 (*file)[count++] = vim_strsave(name_buf);
11714 }
11715 }
11716 }
11717 if (loop == 0)
11718 {
11719 if (num_normal > 0)
11720 *num_file = num_normal;
11721 else if (num_term > 0)
11722 *num_file = num_term;
11723 else
11724 return OK;
11725 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11726 if (*file == NULL)
11727 {
11728 *file = (char_u **)"";
11729 return FAIL;
11730 }
11731 }
11732 }
11733 return OK;
11734}
11735
11736 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011737ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011738{
11739 char_u *var = NULL; /* init for GCC */
11740 char_u *buf;
11741
11742 *num_file = 0;
11743 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11744 if (*file == NULL)
11745 return FAIL;
11746
11747 /*
11748 * For a terminal key code expand_option_idx is < 0.
11749 */
11750 if (expand_option_idx < 0)
11751 {
11752 var = find_termcode(expand_option_name + 2);
11753 if (var == NULL)
11754 expand_option_idx = findoption(expand_option_name);
11755 }
11756
11757 if (expand_option_idx >= 0)
11758 {
11759 /* put string of option value in NameBuff */
11760 option_value2string(&options[expand_option_idx], expand_option_flags);
11761 var = NameBuff;
11762 }
11763 else if (var == NULL)
11764 var = (char_u *)"";
11765
11766 /* A backslash is required before some characters. This is the reverse of
11767 * what happens in do_set(). */
11768 buf = vim_strsave_escaped(var, escape_chars);
11769
11770 if (buf == NULL)
11771 {
11772 vim_free(*file);
11773 *file = NULL;
11774 return FAIL;
11775 }
11776
11777#ifdef BACKSLASH_IN_FILENAME
11778 /* For MS-Windows et al. we don't double backslashes at the start and
11779 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011780 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011781 if (var[0] == '\\' && var[1] == '\\'
11782 && expand_option_idx >= 0
11783 && (options[expand_option_idx].flags & P_EXPAND)
11784 && vim_isfilec(var[2])
11785 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011786 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011787#endif
11788
11789 *file[0] = buf;
11790 *num_file = 1;
11791 return OK;
11792}
11793#endif
11794
11795/*
11796 * Get the value for the numeric or string option *opp in a nice format into
11797 * NameBuff[]. Must not be called with a hidden option!
11798 */
11799 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011800option_value2string(
11801 struct vimoption *opp,
11802 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011803{
11804 char_u *varp;
11805
11806 varp = get_varp_scope(opp, opt_flags);
11807
11808 if (opp->flags & P_NUM)
11809 {
11810 long wc = 0;
11811
11812 if (wc_use_keyname(varp, &wc))
11813 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11814 else if (wc != 0)
11815 STRCPY(NameBuff, transchar((int)wc));
11816 else
11817 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11818 }
11819 else /* P_STRING */
11820 {
11821 varp = *(char_u **)(varp);
11822 if (varp == NULL) /* just in case */
11823 NameBuff[0] = NUL;
11824#ifdef FEAT_CRYPT
11825 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011826 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011827 STRCPY(NameBuff, "*****");
11828#endif
11829 else if (opp->flags & P_EXPAND)
11830 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11831 /* Translate 'pastetoggle' into special key names */
11832 else if ((char_u **)opp->var == &p_pt)
11833 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11834 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011835 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011836 }
11837}
11838
11839/*
11840 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11841 * printed as a keyname.
11842 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11843 */
11844 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011845wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011846{
11847 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11848 {
11849 *wcp = *(long *)varp;
11850 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11851 return TRUE;
11852 }
11853 return FALSE;
11854}
11855
Bram Moolenaar01615492015-02-03 13:00:38 +010011856#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011857/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011858 * Any character has an equivalent 'langmap' character. This is used for
11859 * keyboards that have a special language mode that sends characters above
11860 * 128 (although other characters can be translated too). The "to" field is a
11861 * Vim command character. This avoids having to switch the keyboard back to
11862 * ASCII mode when leaving Insert mode.
11863 *
11864 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11865 * commands.
11866 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11867 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11868 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011869 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011870# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011871/*
11872 * With multi-byte support use growarray for 'langmap' chars >= 256
11873 */
11874typedef struct
11875{
11876 int from;
11877 int to;
11878} langmap_entry_T;
11879
11880static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011881static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011882
11883/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011884 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11885 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011886 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011887 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011888langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011889{
11890 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011891 int a = 0;
11892 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011893
11894 /* Do a binary search for an existing entry. */
11895 while (a != b)
11896 {
11897 int i = (a + b) / 2;
11898 int d = entries[i].from - from;
11899
11900 if (d == 0)
11901 {
11902 entries[i].to = to;
11903 return;
11904 }
11905 if (d < 0)
11906 a = i + 1;
11907 else
11908 b = i;
11909 }
11910
11911 if (ga_grow(&langmap_mapga, 1) != OK)
11912 return; /* out of memory */
11913
11914 /* insert new entry at position "a" */
11915 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11916 mch_memmove(entries + 1, entries,
11917 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11918 ++langmap_mapga.ga_len;
11919 entries[0].from = from;
11920 entries[0].to = to;
11921}
11922
11923/*
11924 * Apply 'langmap' to multi-byte character "c" and return the result.
11925 */
11926 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011927langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011928{
11929 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11930 int a = 0;
11931 int b = langmap_mapga.ga_len;
11932
11933 while (a != b)
11934 {
11935 int i = (a + b) / 2;
11936 int d = entries[i].from - c;
11937
11938 if (d == 0)
11939 return entries[i].to; /* found matching entry */
11940 if (d < 0)
11941 a = i + 1;
11942 else
11943 b = i;
11944 }
11945 return c; /* no entry found, return "c" unmodified */
11946}
11947# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011948
11949 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011950langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011951{
11952 int i;
11953
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011954 for (i = 0; i < 256; i++)
11955 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11956# ifdef FEAT_MBYTE
11957 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11958# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011959}
11960
11961/*
11962 * Called when langmap option is set; the language map can be
11963 * changed at any time!
11964 */
11965 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011966langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011967{
11968 char_u *p;
11969 char_u *p2;
11970 int from, to;
11971
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011972#ifdef FEAT_MBYTE
11973 ga_clear(&langmap_mapga); /* clear the previous map first */
11974#endif
11975 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011976
11977 for (p = p_langmap; p[0] != NUL; )
11978 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011979 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011980 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011981 {
11982 if (p2[0] == '\\' && p2[1] != NUL)
11983 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011984 }
11985 if (p2[0] == ';')
11986 ++p2; /* abcd;ABCD form, p2 points to A */
11987 else
11988 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11989 while (p[0])
11990 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011991 if (p[0] == ',')
11992 {
11993 ++p;
11994 break;
11995 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011996 if (p[0] == '\\' && p[1] != NUL)
11997 ++p;
11998#ifdef FEAT_MBYTE
11999 from = (*mb_ptr2char)(p);
12000#else
12001 from = p[0];
12002#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012003 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012004 if (p2 == NULL)
12005 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012006 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012007 if (p[0] != ',')
12008 {
12009 if (p[0] == '\\')
12010 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012011#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012012 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012013#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012014 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012015#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012016 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012017 }
12018 else
12019 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020012020 if (p2[0] != ',')
12021 {
12022 if (p2[0] == '\\')
12023 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012024#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012025 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012026#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012027 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012028#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012029 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012030 }
12031 if (to == NUL)
12032 {
12033 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
12034 transchar(from));
12035 return;
12036 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012037
12038#ifdef FEAT_MBYTE
12039 if (from >= 256)
12040 langmap_set_entry(from, to);
12041 else
12042#endif
12043 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012044
12045 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012046 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012047 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012048 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012049 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012050 if (*p == ';')
12051 {
12052 p = p2;
12053 if (p[0] != NUL)
12054 {
12055 if (p[0] != ',')
12056 {
12057 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12058 return;
12059 }
12060 ++p;
12061 }
12062 break;
12063 }
12064 }
12065 }
12066 }
12067}
12068#endif
12069
12070/*
12071 * Return TRUE if format option 'x' is in effect.
12072 * Take care of no formatting when 'paste' is set.
12073 */
12074 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012075has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012076{
12077 if (p_paste)
12078 return FALSE;
12079 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12080}
12081
12082/*
12083 * Return TRUE if "x" is present in 'shortmess' option, or
12084 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12085 */
12086 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012087shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012088{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012089 return p_shm != NULL &&
12090 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012091 || (vim_strchr(p_shm, 'a') != NULL
12092 && vim_strchr((char_u *)SHM_A, x) != NULL));
12093}
12094
12095/*
12096 * paste_option_changed() - Called after p_paste was set or reset.
12097 */
12098 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012099paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012100{
12101 static int old_p_paste = FALSE;
12102 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012103 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012104#ifdef FEAT_CMDL_INFO
12105 static int save_ru = 0;
12106#endif
12107#ifdef FEAT_RIGHTLEFT
12108 static int save_ri = 0;
12109 static int save_hkmap = 0;
12110#endif
12111 buf_T *buf;
12112
12113 if (p_paste)
12114 {
12115 /*
12116 * Paste switched from off to on.
12117 * Save the current values, so they can be restored later.
12118 */
12119 if (!old_p_paste)
12120 {
12121 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012122 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012123 {
12124 buf->b_p_tw_nopaste = buf->b_p_tw;
12125 buf->b_p_wm_nopaste = buf->b_p_wm;
12126 buf->b_p_sts_nopaste = buf->b_p_sts;
12127 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012128 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012129 }
12130
12131 /* save global options */
12132 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012133 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012134#ifdef FEAT_CMDL_INFO
12135 save_ru = p_ru;
12136#endif
12137#ifdef FEAT_RIGHTLEFT
12138 save_ri = p_ri;
12139 save_hkmap = p_hkmap;
12140#endif
12141 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012142 p_ai_nopaste = p_ai;
12143 p_et_nopaste = p_et;
12144 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012145 p_tw_nopaste = p_tw;
12146 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012147 }
12148
12149 /*
12150 * Always set the option values, also when 'paste' is set when it is
12151 * already on.
12152 */
12153 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012154 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012155 {
12156 buf->b_p_tw = 0; /* textwidth is 0 */
12157 buf->b_p_wm = 0; /* wrapmargin is 0 */
12158 buf->b_p_sts = 0; /* softtabstop is 0 */
12159 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012160 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012161 }
12162
12163 /* set global options */
12164 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012165 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012166#ifdef FEAT_CMDL_INFO
12167# ifdef FEAT_WINDOWS
12168 if (p_ru)
12169 status_redraw_all(); /* redraw to remove the ruler */
12170# endif
12171 p_ru = 0; /* no ruler */
12172#endif
12173#ifdef FEAT_RIGHTLEFT
12174 p_ri = 0; /* no reverse insert */
12175 p_hkmap = 0; /* no Hebrew keyboard */
12176#endif
12177 /* set global values for local buffer options */
12178 p_tw = 0;
12179 p_wm = 0;
12180 p_sts = 0;
12181 p_ai = 0;
12182 }
12183
12184 /*
12185 * Paste switched from on to off: Restore saved values.
12186 */
12187 else if (old_p_paste)
12188 {
12189 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012190 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012191 {
12192 buf->b_p_tw = buf->b_p_tw_nopaste;
12193 buf->b_p_wm = buf->b_p_wm_nopaste;
12194 buf->b_p_sts = buf->b_p_sts_nopaste;
12195 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012196 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012197 }
12198
12199 /* restore global options */
12200 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012201 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012202#ifdef FEAT_CMDL_INFO
12203# ifdef FEAT_WINDOWS
12204 if (p_ru != save_ru)
12205 status_redraw_all(); /* redraw to draw the ruler */
12206# endif
12207 p_ru = save_ru;
12208#endif
12209#ifdef FEAT_RIGHTLEFT
12210 p_ri = save_ri;
12211 p_hkmap = save_hkmap;
12212#endif
12213 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012214 p_ai = p_ai_nopaste;
12215 p_et = p_et_nopaste;
12216 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012217 p_tw = p_tw_nopaste;
12218 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012219 }
12220
12221 old_p_paste = p_paste;
12222}
12223
12224/*
12225 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12226 *
12227 * Reset 'compatible' and set the values for options that didn't get set yet
12228 * to the Vim defaults.
12229 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012230 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012231 */
12232 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012233vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012234{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012235 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012236 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012237 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012238
12239 if (!option_was_set((char_u *)"cp"))
12240 {
12241 p_cp = FALSE;
12242 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12243 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12244 set_option_default(opt_idx, OPT_FREE, FALSE);
12245 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012246 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012247 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012248
12249 if (fname != NULL)
12250 {
12251 p = vim_getenv(envname, &dofree);
12252 if (p == NULL)
12253 {
12254 /* Set $MYVIMRC to the first vimrc file found. */
12255 p = FullName_save(fname, FALSE);
12256 if (p != NULL)
12257 {
12258 vim_setenv(envname, p);
12259 vim_free(p);
12260 }
12261 }
12262 else if (dofree)
12263 vim_free(p);
12264 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012265}
12266
12267/*
12268 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12269 */
12270 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012271change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012272{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012273 int opt_idx;
12274
Bram Moolenaar071d4272004-06-13 20:20:40 +000012275 if (p_cp != on)
12276 {
12277 p_cp = on;
12278 compatible_set();
12279 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012280 opt_idx = findoption((char_u *)"cp");
12281 if (opt_idx >= 0)
12282 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012283}
12284
12285/*
12286 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012287 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012288 */
12289 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012290option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012291{
12292 int idx;
12293
12294 idx = findoption(name);
12295 if (idx < 0) /* unknown option */
12296 return FALSE;
12297 if (options[idx].flags & P_WAS_SET)
12298 return TRUE;
12299 return FALSE;
12300}
12301
12302/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012303 * Reset the flag indicating option "name" was set.
12304 */
12305 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012306reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012307{
12308 int idx = findoption(name);
12309
12310 if (idx >= 0)
12311 options[idx].flags &= ~P_WAS_SET;
12312}
12313
12314/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012315 * compatible_set() - Called when 'compatible' has been set or unset.
12316 *
12317 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12318 * flag) to a Vi compatible value.
12319 * When 'compatible' is unset: Set all options that have a different default
12320 * for Vim (without the P_VI_DEF flag) to that default.
12321 */
12322 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012323compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012324{
12325 int opt_idx;
12326
12327 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12328 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12329 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12330 set_option_default(opt_idx, OPT_FREE, p_cp);
12331 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012332 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012333}
12334
12335#ifdef FEAT_LINEBREAK
12336
12337# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12338 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012339 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012340# endif
12341
12342/*
12343 * fill_breakat_flags() -- called when 'breakat' changes value.
12344 */
12345 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012346fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012347{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012348 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012349 int i;
12350
12351 for (i = 0; i < 256; i++)
12352 breakat_flags[i] = FALSE;
12353
12354 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012355 for (p = p_breakat; *p; p++)
12356 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012357}
12358
12359# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012360 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012361# endif
12362
12363#endif
12364
12365/*
12366 * Check an option that can be a range of string values.
12367 *
12368 * Return OK for correct value, FAIL otherwise.
12369 * Empty is always OK.
12370 */
12371 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012372check_opt_strings(
12373 char_u *val,
12374 char **values,
12375 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012376{
12377 return opt_strings_flags(val, values, NULL, list);
12378}
12379
12380/*
12381 * Handle an option that can be a range of string values.
12382 * Set a flag in "*flagp" for each string present.
12383 *
12384 * Return OK for correct value, FAIL otherwise.
12385 * Empty is always OK.
12386 */
12387 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012388opt_strings_flags(
12389 char_u *val, /* new value */
12390 char **values, /* array of valid string values */
12391 unsigned *flagp,
12392 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012393{
12394 int i;
12395 int len;
12396 unsigned new_flags = 0;
12397
12398 while (*val)
12399 {
12400 for (i = 0; ; ++i)
12401 {
12402 if (values[i] == NULL) /* val not found in values[] */
12403 return FAIL;
12404
12405 len = (int)STRLEN(values[i]);
12406 if (STRNCMP(values[i], val, len) == 0
12407 && ((list && val[len] == ',') || val[len] == NUL))
12408 {
12409 val += len + (val[len] == ',');
12410 new_flags |= (1 << i);
12411 break; /* check next item in val list */
12412 }
12413 }
12414 }
12415 if (flagp != NULL)
12416 *flagp = new_flags;
12417
12418 return OK;
12419}
12420
12421/*
12422 * Read the 'wildmode' option, fill wim_flags[].
12423 */
12424 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012425check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012426{
12427 char_u new_wim_flags[4];
12428 char_u *p;
12429 int i;
12430 int idx = 0;
12431
12432 for (i = 0; i < 4; ++i)
12433 new_wim_flags[i] = 0;
12434
12435 for (p = p_wim; *p; ++p)
12436 {
12437 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12438 ;
12439 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12440 return FAIL;
12441 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12442 new_wim_flags[idx] |= WIM_LONGEST;
12443 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12444 new_wim_flags[idx] |= WIM_FULL;
12445 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12446 new_wim_flags[idx] |= WIM_LIST;
12447 else
12448 return FAIL;
12449 p += i;
12450 if (*p == NUL)
12451 break;
12452 if (*p == ',')
12453 {
12454 if (idx == 3)
12455 return FAIL;
12456 ++idx;
12457 }
12458 }
12459
12460 /* fill remaining entries with last flag */
12461 while (idx < 3)
12462 {
12463 new_wim_flags[idx + 1] = new_wim_flags[idx];
12464 ++idx;
12465 }
12466
12467 /* only when there are no errors, wim_flags[] is changed */
12468 for (i = 0; i < 4; ++i)
12469 wim_flags[i] = new_wim_flags[i];
12470 return OK;
12471}
12472
12473/*
12474 * Check if backspacing over something is allowed.
12475 */
12476 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012477can_bs(
12478 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012479{
12480 switch (*p_bs)
12481 {
12482 case '2': return TRUE;
12483 case '1': return (what != BS_START);
12484 case '0': return FALSE;
12485 }
12486 return vim_strchr(p_bs, what) != NULL;
12487}
12488
12489/*
12490 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12491 * the file must be considered changed when the value is different.
12492 */
12493 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012494save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012495{
12496 buf->b_start_ffc = *buf->b_p_ff;
12497 buf->b_start_eol = buf->b_p_eol;
12498#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012499 buf->b_start_bomb = buf->b_p_bomb;
12500
Bram Moolenaar071d4272004-06-13 20:20:40 +000012501 /* Only use free/alloc when necessary, they take time. */
12502 if (buf->b_start_fenc == NULL
12503 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12504 {
12505 vim_free(buf->b_start_fenc);
12506 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12507 }
12508#endif
12509}
12510
12511/*
12512 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12513 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012514 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12515 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012516 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012517 * When "ignore_empty" is true don't consider a new, empty buffer to be
12518 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012519 */
12520 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012521file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012522{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012523 /* In a buffer that was never loaded the options are not valid. */
12524 if (buf->b_flags & BF_NEVERLOADED)
12525 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012526 if (ignore_empty
12527 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012528 && buf->b_ml.ml_line_count == 1
12529 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12530 return FALSE;
12531 if (buf->b_start_ffc != *buf->b_p_ff)
12532 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012533 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012534 return TRUE;
12535#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012536 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12537 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012538 if (buf->b_start_fenc == NULL)
12539 return (*buf->b_p_fenc != NUL);
12540 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12541#else
12542 return FALSE;
12543#endif
12544}
12545
12546/*
12547 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12548 */
12549 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012550check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012551{
12552 return check_opt_strings(p, p_ff_values, FALSE);
12553}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012554
12555/*
12556 * Return the effective shiftwidth value for current buffer, using the
12557 * 'tabstop' value when 'shiftwidth' is zero.
12558 */
12559 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012560get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012561{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012562 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012563}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012564
12565/*
12566 * Return the effective softtabstop value for the current buffer, using the
12567 * 'tabstop' value when 'softtabstop' is negative.
12568 */
12569 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012570get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012571{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012572 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012573}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012574
12575/*
12576 * Check matchpairs option for "*initc".
12577 * If there is a match set "*initc" to the matching character and "*findc" to
12578 * the opposite character. Set "*backwards" to the direction.
12579 * When "switchit" is TRUE swap the direction.
12580 */
12581 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012582find_mps_values(
12583 int *initc,
12584 int *findc,
12585 int *backwards,
12586 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012587{
12588 char_u *ptr;
12589
12590 ptr = curbuf->b_p_mps;
12591 while (*ptr != NUL)
12592 {
12593#ifdef FEAT_MBYTE
12594 if (has_mbyte)
12595 {
12596 char_u *prev;
12597
12598 if (mb_ptr2char(ptr) == *initc)
12599 {
12600 if (switchit)
12601 {
12602 *findc = *initc;
12603 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12604 *backwards = TRUE;
12605 }
12606 else
12607 {
12608 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12609 *backwards = FALSE;
12610 }
12611 return;
12612 }
12613 prev = ptr;
12614 ptr += mb_ptr2len(ptr) + 1;
12615 if (mb_ptr2char(ptr) == *initc)
12616 {
12617 if (switchit)
12618 {
12619 *findc = *initc;
12620 *initc = mb_ptr2char(prev);
12621 *backwards = FALSE;
12622 }
12623 else
12624 {
12625 *findc = mb_ptr2char(prev);
12626 *backwards = TRUE;
12627 }
12628 return;
12629 }
12630 ptr += mb_ptr2len(ptr);
12631 }
12632 else
12633#endif
12634 {
12635 if (*ptr == *initc)
12636 {
12637 if (switchit)
12638 {
12639 *backwards = TRUE;
12640 *findc = *initc;
12641 *initc = ptr[2];
12642 }
12643 else
12644 {
12645 *backwards = FALSE;
12646 *findc = ptr[2];
12647 }
12648 return;
12649 }
12650 ptr += 2;
12651 if (*ptr == *initc)
12652 {
12653 if (switchit)
12654 {
12655 *backwards = FALSE;
12656 *findc = *initc;
12657 *initc = ptr[-2];
12658 }
12659 else
12660 {
12661 *backwards = TRUE;
12662 *findc = ptr[-2];
12663 }
12664 return;
12665 }
12666 ++ptr;
12667 }
12668 if (*ptr == ',')
12669 ++ptr;
12670 }
12671}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012672
12673#if defined(FEAT_LINEBREAK) || defined(PROTO)
12674/*
12675 * This is called when 'breakindentopt' is changed and when a window is
12676 * initialized.
12677 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012678 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012679briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012680{
12681 char_u *p;
12682 int bri_shift = 0;
12683 long bri_min = 20;
12684 int bri_sbr = FALSE;
12685
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012686 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012687 while (*p != NUL)
12688 {
12689 if (STRNCMP(p, "shift:", 6) == 0
12690 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12691 {
12692 p += 6;
12693 bri_shift = getdigits(&p);
12694 }
12695 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12696 {
12697 p += 4;
12698 bri_min = getdigits(&p);
12699 }
12700 else if (STRNCMP(p, "sbr", 3) == 0)
12701 {
12702 p += 3;
12703 bri_sbr = TRUE;
12704 }
12705 if (*p != ',' && *p != NUL)
12706 return FAIL;
12707 if (*p == ',')
12708 ++p;
12709 }
12710
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012711 wp->w_p_brishift = bri_shift;
12712 wp->w_p_brimin = bri_min;
12713 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012714
12715 return OK;
12716}
12717#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012718
12719/*
12720 * Get the local or global value of 'backupcopy'.
12721 */
12722 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012723get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012724{
12725 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12726}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012727
12728#if defined(FEAT_SIGNS) || defined(PROTO)
12729/*
12730 * Return TRUE when window "wp" has a column to draw signs in.
12731 */
12732 int
12733signcolumn_on(win_T *wp)
12734{
12735 if (*wp->w_p_scl == 'n')
12736 return FALSE;
12737 if (*wp->w_p_scl == 'y')
12738 return TRUE;
12739 return (wp->w_buffer->b_signlist != NULL
12740# ifdef FEAT_NETBEANS_INTG
12741 || wp->w_buffer->b_has_sign_column
12742# endif
12743 );
12744}
12745#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012746
12747#if defined(FEAT_EVAL) || defined(PROTO)
12748/*
12749 * Get window or buffer local options.
12750 */
12751 dict_T *
12752get_winbuf_options(int bufopt)
12753{
12754 dict_T *d;
12755 int opt_idx;
12756
12757 d = dict_alloc();
12758 if (d == NULL)
12759 return NULL;
12760
12761 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12762 {
12763 struct vimoption *opt = &options[opt_idx];
12764
12765 if ((bufopt && (opt->indir & PV_BUF))
12766 || (!bufopt && (opt->indir & PV_WIN)))
12767 {
12768 char_u *varp = get_varp(opt);
12769
12770 if (varp != NULL)
12771 {
12772 if (opt->flags & P_STRING)
12773 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012774 else if (opt->flags & P_NUM)
12775 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012776 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012777 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012778 }
12779 }
12780 }
12781
12782 return d;
12783}
12784#endif