blob: 90a11bce3a897a3aaadd1c9e79445caa20311176 [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 Moolenaar071d4272004-06-13 20:20:40 +00003197 p_term("t_RI", T_CRI)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003198 p_term("t_RS", T_CRS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003199 p_term("t_RV", T_CRV)
3200 p_term("t_Sb", T_CSB)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003201 p_term("t_SC", T_CSC)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003203 p_term("t_Sf", T_CSF)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003204 p_term("t_SH", T_CSH)
Bram Moolenaare5401222015-06-25 19:16:56 +02003205 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003207 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209 p_term("t_te", T_TE)
3210 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003211 p_term("t_ts", T_TS)
3212 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003213 p_term("t_ue", T_UE)
3214 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003215 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216 p_term("t_vb", T_VB)
3217 p_term("t_ve", T_VE)
3218 p_term("t_vi", T_VI)
Bram Moolenaarce1c3272017-08-20 15:05:15 +02003219 p_term("t_VS", T_CVS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003220 p_term("t_vs", T_VS)
3221 p_term("t_WP", T_CWP)
3222 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003223 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003224 p_term("t_xs", T_XS)
3225 p_term("t_ZH", T_CZH)
3226 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003227 p_term("t_8f", T_8F)
3228 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003229
3230/* terminal key codes are not in here */
3231
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003232 /* end marker */
3233 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003234};
3235
3236#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3237
3238#ifdef FEAT_MBYTE
3239static char *(p_ambw_values[]) = {"single", "double", NULL};
3240#endif
3241static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003242static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003243static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003244#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003245static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003246#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003247#ifdef FEAT_CMDL_COMPL
3248static char *(p_wop_values[]) = {"tagfile", NULL};
3249#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003250#ifdef FEAT_WAK
3251static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3252#endif
3253static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003254static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3255static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003256static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257#ifdef FEAT_BROWSE
3258static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3259#endif
3260#ifdef FEAT_SCROLLBIND
3261static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3262#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003263static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003264#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003265static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3266#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003267#ifdef FEAT_AUTOCMD
3268static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL};
3269#else
3270static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003271#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003272static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003273static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3274#ifdef FEAT_FOLDING
3275static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003276# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003277 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003278# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003279 NULL};
3280static char *(p_fcl_values[]) = {"all", NULL};
3281#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003282#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003283static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003284#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003285#ifdef FEAT_SIGNS
3286static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3287#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003288
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003289static void set_option_default(int, int opt_flags, int compatible);
3290static void set_options_default(int opt_flags);
3291static char_u *term_bg_default(void);
3292static void did_set_option(int opt_idx, int opt_flags, int new_value);
3293static char_u *illegal_char(char_u *, int);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003294#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003295static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003296#endif
3297#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003298static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003299#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003300static char_u *option_expand(int opt_idx, char_u *val);
3301static void didset_options(void);
3302static void didset_options2(void);
3303static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003304#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003305static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003306#else
3307# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3308#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003309static void set_string_option_global(int opt_idx, char_u **varp);
3310static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3311static 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);
3312static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003313#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003314static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003315#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003316#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003317static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003319#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003320static char_u *did_set_spell_option(int is_spellfile);
3321static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003322#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003323#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003324static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003325#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003326static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3327static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3328static void check_redraw(long_u flags);
3329static int findoption(char_u *);
3330static int find_key_option(char_u *);
3331static void showoptions(int all, int opt_flags);
3332static int optval_default(struct vimoption *, char_u *varp);
3333static void showoneopt(struct vimoption *, int opt_flags);
3334static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3335static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3336static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3337static int istermoption(struct vimoption *);
3338static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3339static char_u *get_varp(struct vimoption *);
3340static void option_value2string(struct vimoption *, int opt_flags);
3341static void check_winopt(winopt_T *wop);
3342static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003344static void langmap_init(void);
3345static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003347static void paste_option_changed(void);
3348static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003349#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003350static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003351#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003352static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3353static int check_opt_strings(char_u *val, char **values, int);
3354static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003355#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003356static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003357#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358
3359/*
3360 * Initialize the options, first part.
3361 *
3362 * Called only once from main(), just after creating the first buffer.
3363 */
3364 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003365set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003366{
3367 char_u *p;
3368 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003369 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370
3371#ifdef FEAT_LANGMAP
3372 langmap_init();
3373#endif
3374
3375 /* Be Vi compatible by default */
3376 p_cp = TRUE;
3377
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003378 /* Use POSIX compatibility when $VIM_POSIX is set. */
3379 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003380 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003381 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003382 set_string_default("shm", (char_u *)"A");
3383 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003384
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385 /*
3386 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003387 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003388 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003389 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003390#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003391 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003392# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003393 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003394# endif
3395#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003396 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003397 set_string_default("sh", p);
3398
3399#ifdef FEAT_WILDIGN
3400 /*
3401 * Set the default for 'backupskip' to include environment variables for
3402 * temp files.
3403 */
3404 {
3405# ifdef UNIX
3406 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3407# else
3408 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3409# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003410 int len;
3411 garray_T ga;
3412 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003413
3414 ga_init2(&ga, 1, 100);
3415 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3416 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003417 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003418# ifdef UNIX
3419 if (*names[n] == NUL)
3420 p = (char_u *)"/tmp";
3421 else
3422# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003423 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424 if (p != NULL && *p != NUL)
3425 {
3426 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003427 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428 if (ga_grow(&ga, len) == OK)
3429 {
3430 if (ga.ga_len > 0)
3431 STRCAT(ga.ga_data, ",");
3432 STRCAT(ga.ga_data, p);
3433 add_pathsep(ga.ga_data);
3434 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003435 ga.ga_len += len;
3436 }
3437 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003438 if (mustfree)
3439 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003440 }
3441 if (ga.ga_data != NULL)
3442 {
3443 set_string_default("bsk", ga.ga_data);
3444 vim_free(ga.ga_data);
3445 }
3446 }
3447#endif
3448
3449 /*
3450 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3451 */
3452 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003453 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003454 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003455#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3456 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3457#endif
3458 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003459#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003460 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003461 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003462#else
3463# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003464 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003465 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003466# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003467 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003468# endif
3469#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003470 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003471 opt_idx = findoption((char_u *)"maxmem");
3472 if (opt_idx >= 0)
3473 {
3474#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003475 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3476 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003477#endif
3478 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3479 }
3480 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003481 }
3482
Bram Moolenaar071d4272004-06-13 20:20:40 +00003483#ifdef FEAT_SEARCHPATH
3484 {
3485 char_u *cdpath;
3486 char_u *buf;
3487 int i;
3488 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003489 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003490
3491 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003492 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003493 if (cdpath != NULL)
3494 {
3495 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3496 if (buf != NULL)
3497 {
3498 buf[0] = ','; /* start with ",", current dir first */
3499 j = 1;
3500 for (i = 0; cdpath[i] != NUL; ++i)
3501 {
3502 if (vim_ispathlistsep(cdpath[i]))
3503 buf[j++] = ',';
3504 else
3505 {
3506 if (cdpath[i] == ' ' || cdpath[i] == ',')
3507 buf[j++] = '\\';
3508 buf[j++] = cdpath[i];
3509 }
3510 }
3511 buf[j] = NUL;
3512 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003513 if (opt_idx >= 0)
3514 {
3515 options[opt_idx].def_val[VI_DEFAULT] = buf;
3516 options[opt_idx].flags |= P_DEF_ALLOCED;
3517 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003518 else
3519 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003520 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003521 if (mustfree)
3522 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003523 }
3524 }
3525#endif
3526
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003527#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003528 /* Set print encoding on platforms that don't default to latin1 */
3529 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003530# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003531 (char_u *)"cp1252"
3532# else
3533# ifdef VMS
3534 (char_u *)"dec-mcs"
3535# else
3536# ifdef EBCDIC
3537 (char_u *)"ebcdic-uk"
3538# else
3539# ifdef MAC
3540 (char_u *)"mac-roman"
3541# else /* HPUX */
3542 (char_u *)"hp-roman8"
3543# endif
3544# endif
3545# endif
3546# endif
3547 );
3548#endif
3549
3550#ifdef FEAT_POSTSCRIPT
3551 /* 'printexpr' must be allocated to be able to evaluate it. */
3552 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003553# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003554 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003555# else
3556# ifdef VMS
3557 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3558
3559# else
3560 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3561# endif
3562# endif
3563 );
3564#endif
3565
3566 /*
3567 * Set all the options (except the terminal options) to their default
3568 * value. Also set the global value for local options.
3569 */
3570 set_options_default(0);
3571
3572#ifdef FEAT_GUI
3573 if (found_reverse_arg)
3574 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3575#endif
3576
3577 curbuf->b_p_initialized = TRUE;
3578 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003579 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003580 check_buf_options(curbuf);
3581 check_win_options(curwin);
3582 check_options();
3583
3584 /* Must be before option_expand(), because that one needs vim_isIDc() */
3585 didset_options();
3586
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003587#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003588 /* Use the current chartab for the generic chartab. This is not in
3589 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003590 init_spell_chartab();
3591#endif
3592
Bram Moolenaar071d4272004-06-13 20:20:40 +00003593 /*
3594 * Expand environment variables and things like "~" for the defaults.
3595 * If option_expand() returns non-NULL the variable is expanded. This can
3596 * only happen for non-indirect options.
3597 * Also set the default to the expanded value, so ":set" does not list
3598 * them.
3599 * Don't set the P_ALLOCED flag, because we don't want to free the
3600 * default.
3601 */
3602 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3603 {
3604 if ((options[opt_idx].flags & P_GETTEXT)
3605 && options[opt_idx].var != NULL)
3606 p = (char_u *)_(*(char **)options[opt_idx].var);
3607 else
3608 p = option_expand(opt_idx, NULL);
3609 if (p != NULL && (p = vim_strsave(p)) != NULL)
3610 {
3611 *(char_u **)options[opt_idx].var = p;
3612 /* VIMEXP
3613 * Defaults for all expanded options are currently the same for Vi
3614 * and Vim. When this changes, add some code here! Also need to
3615 * split P_DEF_ALLOCED in two.
3616 */
3617 if (options[opt_idx].flags & P_DEF_ALLOCED)
3618 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3619 options[opt_idx].def_val[VI_DEFAULT] = p;
3620 options[opt_idx].flags |= P_DEF_ALLOCED;
3621 }
3622 }
3623
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624 save_file_ff(curbuf); /* Buffer is unchanged */
3625
Bram Moolenaar071d4272004-06-13 20:20:40 +00003626#if defined(FEAT_ARABIC)
3627 /* Detect use of mlterm.
3628 * Mlterm is a terminal emulator akin to xterm that has some special
3629 * abilities (bidi namely).
3630 * NOTE: mlterm's author is being asked to 'set' a variable
3631 * instead of an environment variable due to inheritance.
3632 */
3633 if (mch_getenv((char_u *)"MLTERM") != NULL)
3634 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3635#endif
3636
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003637 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638
3639#ifdef FEAT_MBYTE
3640# if defined(WIN3264) && defined(FEAT_GETTEXT)
3641 /*
3642 * If $LANG isn't set, try to get a good value for it. This makes the
3643 * right language be used automatically. Don't do this for English.
3644 */
3645 if (mch_getenv((char_u *)"LANG") == NULL)
3646 {
3647 char buf[20];
3648
3649 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3650 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3651 * only the first two. */
3652 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3653 (LPTSTR)buf, 20);
3654 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3655 {
3656 /* There are a few exceptions (probably more) */
3657 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3658 STRCPY(buf, "zh_TW");
3659 else if (STRNICMP(buf, "chs", 3) == 0
3660 || STRNICMP(buf, "zhc", 3) == 0)
3661 STRCPY(buf, "zh_CN");
3662 else if (STRNICMP(buf, "jp", 2) == 0)
3663 STRCPY(buf, "ja");
3664 else
3665 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003666 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003667 }
3668 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003669# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003670# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003671 /* Moved to os_mac_conv.c to avoid dependency problems. */
3672 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003673# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674# endif
3675
3676 /* enc_locale() will try to find the encoding of the current locale. */
3677 p = enc_locale();
3678 if (p != NULL)
3679 {
3680 char_u *save_enc;
3681
3682 /* Try setting 'encoding' and check if the value is valid.
3683 * If not, go back to the default "latin1". */
3684 save_enc = p_enc;
3685 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003686 if (STRCMP(p_enc, "gb18030") == 0)
3687 {
3688 /* We don't support "gb18030", but "cp936" is a good substitute
3689 * for practical purposes, thus use that. It's not an alias to
3690 * still support conversion between gb18030 and utf-8. */
3691 p_enc = vim_strsave((char_u *)"cp936");
3692 vim_free(p);
3693 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003694 if (mb_init() == NULL)
3695 {
3696 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003697 if (opt_idx >= 0)
3698 {
3699 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3700 options[opt_idx].flags |= P_DEF_ALLOCED;
3701 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003702
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003703#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003704 if (STRCMP(p_enc, "latin1") == 0
3705# ifdef FEAT_MBYTE
3706 || enc_utf8
3707# endif
3708 )
3709 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003710 /* Adjust the default for 'isprint' and 'iskeyword' to match
3711 * latin1. Also set the defaults for when 'nocompatible' is
3712 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003713 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003714 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003715 set_string_option_direct((char_u *)"isk", -1,
3716 ISK_LATIN1, OPT_FREE, SID_NONE);
3717 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003718 if (opt_idx >= 0)
3719 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003720 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003721 if (opt_idx >= 0)
3722 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003723 (void)init_chartab();
3724 }
3725#endif
3726
Bram Moolenaar071d4272004-06-13 20:20:40 +00003727# if defined(WIN3264) && !defined(FEAT_GUI)
3728 /* Win32 console: When GetACP() returns a different value from
3729 * GetConsoleCP() set 'termencoding'. */
3730 if (GetACP() != GetConsoleCP())
3731 {
3732 char buf[50];
3733
3734 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3735 p_tenc = vim_strsave((char_u *)buf);
3736 if (p_tenc != NULL)
3737 {
3738 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003739 if (opt_idx >= 0)
3740 {
3741 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3742 options[opt_idx].flags |= P_DEF_ALLOCED;
3743 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003744 convert_setup(&input_conv, p_tenc, p_enc);
3745 convert_setup(&output_conv, p_enc, p_tenc);
3746 }
3747 else
3748 p_tenc = empty_option;
3749 }
3750# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003751# if defined(WIN3264) && defined(FEAT_MBYTE)
3752 /* $HOME may have characters in active code page. */
3753 init_homedir();
3754# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003755 }
3756 else
3757 {
3758 vim_free(p_enc);
3759 p_enc = save_enc;
3760 }
3761 }
3762#endif
3763
3764#ifdef FEAT_MULTI_LANG
3765 /* Set the default for 'helplang'. */
3766 set_helplang_default(get_mess_lang());
3767#endif
3768}
3769
3770/*
3771 * Set an option to its default value.
3772 * This does not take care of side effects!
3773 */
3774 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003775set_option_default(
3776 int opt_idx,
3777 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3778 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003779{
3780 char_u *varp; /* pointer to variable for current option */
3781 int dvi; /* index in def_val[] */
3782 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003783 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003784 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3785
3786 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3787 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003788 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003789 {
3790 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3791 if (flags & P_STRING)
3792 {
3793 /* Use set_string_option_direct() for local options to handle
3794 * freeing and allocating the value. */
3795 if (options[opt_idx].indir != PV_NONE)
3796 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003797 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003798 else
3799 {
3800 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3801 free_string_option(*(char_u **)(varp));
3802 *(char_u **)varp = options[opt_idx].def_val[dvi];
3803 options[opt_idx].flags &= ~P_ALLOCED;
3804 }
3805 }
3806 else if (flags & P_NUM)
3807 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003808 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003809 win_comp_scroll(curwin);
3810 else
3811 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003812 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003813 /* May also set global value for local option. */
3814 if (both)
3815 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3816 *(long *)varp;
3817 }
3818 }
3819 else /* P_BOOL */
3820 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003821 /* the cast to long is required for Manx C, long_i is needed for
3822 * MSVC */
3823 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003824#ifdef UNIX
3825 /* 'modeline' defaults to off for root */
3826 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3827 *(int *)varp = FALSE;
3828#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003829 /* May also set global value for local option. */
3830 if (both)
3831 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3832 *(int *)varp;
3833 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003834
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003835 /* The default value is not insecure. */
3836 flagsp = insecure_flag(opt_idx, opt_flags);
3837 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003838 }
3839
3840#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003841 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003842#endif
3843}
3844
3845/*
3846 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003847 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003848 */
3849 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003850set_options_default(
3851 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003852{
3853 int i;
3854#ifdef FEAT_WINDOWS
3855 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003856 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003857#endif
3858
3859 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003860 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003861#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003862 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003863 || (TRUE
3864# if defined(FEAT_MBYTE)
3865 && options[i].var != (char_u *)&p_enc
3866# endif
3867# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003868 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003869 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003870# endif
3871 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003872#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003873 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003874 set_option_default(i, opt_flags, p_cp);
3875
3876#ifdef FEAT_WINDOWS
3877 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003878 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879 win_comp_scroll(wp);
3880#else
3881 win_comp_scroll(curwin);
3882#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003883#ifdef FEAT_CINDENT
3884 parse_cino(curbuf);
3885#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003886}
3887
3888/*
3889 * Set the Vi-default value of a string option.
3890 * Used for 'sh', 'backupskip' and 'term'.
3891 */
3892 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003893set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003894{
3895 char_u *p;
3896 int opt_idx;
3897
3898 p = vim_strsave(val);
3899 if (p != NULL) /* we don't want a NULL */
3900 {
3901 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003902 if (opt_idx >= 0)
3903 {
3904 if (options[opt_idx].flags & P_DEF_ALLOCED)
3905 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3906 options[opt_idx].def_val[VI_DEFAULT] = p;
3907 options[opt_idx].flags |= P_DEF_ALLOCED;
3908 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003909 }
3910}
3911
3912/*
3913 * Set the Vi-default value of a number option.
3914 * Used for 'lines' and 'columns'.
3915 */
3916 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003917set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003918{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003919 int opt_idx;
3920
3921 opt_idx = findoption((char_u *)name);
3922 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003923 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003924}
3925
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003926#if defined(EXITFREE) || defined(PROTO)
3927/*
3928 * Free all options.
3929 */
3930 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003931free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003932{
3933 int i;
3934
3935 for (i = 0; !istermoption(&options[i]); i++)
3936 {
3937 if (options[i].indir == PV_NONE)
3938 {
3939 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003940 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003941 free_string_option(*(char_u **)options[i].var);
3942 if (options[i].flags & P_DEF_ALLOCED)
3943 free_string_option(options[i].def_val[VI_DEFAULT]);
3944 }
3945 else if (options[i].var != VAR_WIN
3946 && (options[i].flags & P_STRING))
3947 /* buffer-local option: free global value */
3948 free_string_option(*(char_u **)options[i].var);
3949 }
3950}
3951#endif
3952
3953
Bram Moolenaar071d4272004-06-13 20:20:40 +00003954/*
3955 * Initialize the options, part two: After getting Rows and Columns and
3956 * setting 'term'.
3957 */
3958 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003959set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003960{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003961 int idx;
3962
Bram Moolenaar071d4272004-06-13 20:20:40 +00003963 /*
3964 * 'scroll' defaults to half the window height. Note that this default is
3965 * wrong when the window height changes.
3966 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003967 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003968 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003969 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003970 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003971 comp_col();
3972
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003973 /*
3974 * 'window' is only for backwards compatibility with Vi.
3975 * Default is Rows - 1.
3976 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003977 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003978 p_window = Rows - 1;
3979 set_number_default("window", Rows - 1);
3980
Bram Moolenaarf740b292006-02-16 22:11:02 +00003981 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003982#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003983 /*
3984 * If 'background' wasn't set by the user, try guessing the value,
3985 * depending on the terminal name. Only need to check for terminals
3986 * with a dark background, that can handle color.
3987 */
3988 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003989 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3990 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003991 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003992 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003993 /* don't mark it as set, when starting the GUI it may be
3994 * changed again */
3995 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996 }
3997#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003998
3999#ifdef CURSOR_SHAPE
4000 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
4001#endif
4002#ifdef FEAT_MOUSESHAPE
4003 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
4004#endif
4005#ifdef FEAT_PRINTER
4006 (void)parse_printoptions(); /* parse 'printoptions' default value */
4007#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004008}
4009
4010/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00004011 * Return "dark" or "light" depending on the kind of terminal.
4012 * This is just guessing! Recognized are:
4013 * "linux" Linux console
4014 * "screen.linux" Linux console with screen
4015 * "cygwin" Cygwin shell
4016 * "putty" Putty program
4017 * We also check the COLORFGBG environment variable, which is set by
4018 * rxvt and derivatives. This variable contains either two or three
4019 * values separated by semicolons; we want the last value in either
4020 * case. If this value is 0-6 or 8, our background is dark.
4021 */
4022 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004023term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004024{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004025#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004026 /* DOS console nearly always black */
4027 return (char_u *)"dark";
4028#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004029 char_u *p;
4030
Bram Moolenaarf740b292006-02-16 22:11:02 +00004031 if (STRCMP(T_NAME, "linux") == 0
4032 || STRCMP(T_NAME, "screen.linux") == 0
4033 || STRCMP(T_NAME, "cygwin") == 0
4034 || STRCMP(T_NAME, "putty") == 0
4035 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4036 && (p = vim_strrchr(p, ';')) != NULL
4037 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4038 && p[2] == NUL))
4039 return (char_u *)"dark";
4040 return (char_u *)"light";
4041#endif
4042}
4043
4044/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045 * Initialize the options, part three: After reading the .vimrc
4046 */
4047 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004048set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004049{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004050#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004051/*
4052 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4053 * This is done after other initializations, where 'shell' might have been
4054 * set, but only if they have not been set before.
4055 */
4056 char_u *p;
4057 int idx_srr;
4058 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004059# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004060 int idx_sp;
4061 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004062# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004063
4064 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004065 if (idx_srr < 0)
4066 do_srr = FALSE;
4067 else
4068 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004069# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004070 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004071 if (idx_sp < 0)
4072 do_sp = FALSE;
4073 else
4074 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004075# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004076 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004077 if (p != NULL)
4078 {
4079 /*
4080 * Default for p_sp is "| tee", for p_srr is ">".
4081 * For known shells it is changed here to include stderr.
4082 */
4083 if ( fnamecmp(p, "csh") == 0
4084 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004085# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004086 || fnamecmp(p, "csh.exe") == 0
4087 || fnamecmp(p, "tcsh.exe") == 0
4088# endif
4089 )
4090 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004091# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092 if (do_sp)
4093 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004094# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004095 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004096# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004097 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004098# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4100 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004101# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102 if (do_srr)
4103 {
4104 p_srr = (char_u *)">&";
4105 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4106 }
4107 }
4108 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004109 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004110 if ( fnamecmp(p, "sh") == 0
4111 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004112 || fnamecmp(p, "mksh") == 0
4113 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004114 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004115 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004116 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004117 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004118# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119 || fnamecmp(p, "cmd") == 0
4120 || fnamecmp(p, "sh.exe") == 0
4121 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004122 || fnamecmp(p, "mksh.exe") == 0
4123 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004125 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004126 || fnamecmp(p, "bash.exe") == 0
4127 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004128# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004129 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004130 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004131# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004132 if (do_sp)
4133 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004134# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004135 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004136# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004137 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004138# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004139 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4140 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004141# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004142 if (do_srr)
4143 {
4144 p_srr = (char_u *)">%s 2>&1";
4145 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4146 }
4147 }
4148 vim_free(p);
4149 }
4150#endif
4151
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004152#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004153 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004154 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4155 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004156 * This is done after other initializations, where 'shell' might have been
4157 * set, but only if they have not been set before. Default for p_shcf is
4158 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004159 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004160 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004161 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004162 {
4163 int idx3;
4164
4165 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004166 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167 {
4168 p_shcf = (char_u *)"-c";
4169 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4170 }
4171
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172 /* Somehow Win32 requires the quotes around the redirection too */
4173 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004174 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004175 {
4176 p_sxq = (char_u *)"\"";
4177 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4178 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004179 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004180 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4181 {
4182 int idx3;
4183
4184 /*
4185 * cmd.exe on Windows will strip the first and last double quote given
4186 * on the command line, e.g. most of the time things like:
4187 * cmd /c "my path/to/echo" "my args to echo"
4188 * become:
4189 * my path/to/echo" "my args to echo
4190 * when executed.
4191 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004192 * To avoid this, set shellxquote to surround the command in
4193 * parenthesis. This appears to make most commands work, without
4194 * breaking commands that worked previously, such as
4195 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004196 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004197 idx3 = findoption((char_u *)"sxq");
4198 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4199 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004200 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004201 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4202 }
4203
Bram Moolenaara64ba222012-02-12 23:23:31 +01004204 idx3 = findoption((char_u *)"shcf");
4205 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4206 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004207 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004208 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4209 }
4210 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004211#endif
4212
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004213 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004214 {
4215 int idx_ffs = findoption((char_u *)"ffs");
4216
4217 /* Apply the first entry of 'fileformats' to the initial buffer. */
4218 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4219 set_fileformat(default_fileformat(), OPT_LOCAL);
4220 }
4221
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222#ifdef FEAT_TITLE
4223 set_title_defaults();
4224#endif
4225}
4226
4227#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4228/*
4229 * When 'helplang' is still at its default value, set it to "lang".
4230 * Only the first two characters of "lang" are used.
4231 */
4232 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004233set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004234{
4235 int idx;
4236
4237 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4238 return;
4239 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004240 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004241 {
4242 if (options[idx].flags & P_ALLOCED)
4243 free_string_option(p_hlg);
4244 p_hlg = vim_strsave(lang);
4245 if (p_hlg == NULL)
4246 p_hlg = empty_option;
4247 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004248 {
4249 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4250 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4251 {
4252 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4253 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4254 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004255 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004256 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004257 options[idx].flags |= P_ALLOCED;
4258 }
4259}
4260#endif
4261
4262#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004263static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004264
4265 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004266gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004267{
4268 if (gui_get_lightness(gui.back_pixel) < 127)
4269 return (char_u *)"dark";
4270 return (char_u *)"light";
4271}
4272
4273/*
4274 * Option initializations that can only be done after opening the GUI window.
4275 */
4276 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004277init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004278{
4279 /* Set the 'background' option according to the lightness of the
4280 * background color, unless the user has set it already. */
4281 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4282 {
4283 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4284 highlight_changed();
4285 }
4286}
4287#endif
4288
4289#ifdef FEAT_TITLE
4290/*
4291 * 'title' and 'icon' only default to true if they have not been set or reset
4292 * in .vimrc and we can read the old value.
4293 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4294 * they can be reset. This reduces startup time when using X on a remote
4295 * machine.
4296 */
4297 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004298set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004299{
4300 int idx1;
4301 long val;
4302
4303 /*
4304 * If GUI is (going to be) used, we can always set the window title and
4305 * icon name. Saves a bit of time, because the X11 display server does
4306 * not need to be contacted.
4307 */
4308 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004309 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004310 {
4311#ifdef FEAT_GUI
4312 if (gui.starting || gui.in_use)
4313 val = TRUE;
4314 else
4315#endif
4316 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004317 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004318 p_title = val;
4319 }
4320 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004321 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004322 {
4323#ifdef FEAT_GUI
4324 if (gui.starting || gui.in_use)
4325 val = TRUE;
4326 else
4327#endif
4328 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004329 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004330 p_icon = val;
4331 }
4332}
4333#endif
4334
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004335#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4336 static void
4337trigger_optionsset_string(
4338 int opt_idx,
4339 int opt_flags,
4340 char_u *oldval,
4341 char_u *newval)
4342{
4343 if (oldval != NULL && newval != NULL)
4344 {
4345 char_u buf_type[7];
4346
4347 sprintf((char *)buf_type, "%s",
4348 (opt_flags & OPT_LOCAL) ? "local" : "global");
4349 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4350 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4351 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4352 apply_autocmds(EVENT_OPTIONSET,
4353 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4354 reset_v_option_vars();
4355 }
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004356}
4357#endif
4358
Bram Moolenaar071d4272004-06-13 20:20:40 +00004359/*
4360 * Parse 'arg' for option settings.
4361 *
4362 * 'arg' may be IObuff, but only when no errors can be present and option
4363 * does not need to be expanded with option_expand().
4364 * "opt_flags":
4365 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004366 * OPT_GLOBAL for ":setglobal"
4367 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004368 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004369 * OPT_WINONLY to only set window-local options
4370 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004371 *
4372 * returns FAIL if an error is detected, OK otherwise
4373 */
4374 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004375do_set(
4376 char_u *arg, /* option string (may be written to!) */
4377 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004378{
4379 int opt_idx;
4380 char_u *errmsg;
4381 char_u errbuf[80];
4382 char_u *startarg;
4383 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4384 int nextchar; /* next non-white char after option name */
4385 int afterchar; /* character just after option name */
4386 int len;
4387 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004388 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004389 int key;
4390 long_u flags; /* flags for current option */
4391 char_u *varp = NULL; /* pointer to variable for current option */
4392 int did_show = FALSE; /* already showed one value */
4393 int adding; /* "opt+=arg" */
4394 int prepending; /* "opt^=arg" */
4395 int removing; /* "opt-=arg" */
4396 int cp_val = 0;
4397 char_u key_name[2];
4398
4399 if (*arg == NUL)
4400 {
4401 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004402 did_show = TRUE;
4403 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004404 }
4405
4406 while (*arg != NUL) /* loop to process all options */
4407 {
4408 errmsg = NULL;
4409 startarg = arg; /* remember for error message */
4410
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004411 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4412 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004413 {
4414 /*
4415 * ":set all" show all options.
4416 * ":set all&" set all options to their default value.
4417 */
4418 arg += 3;
4419 if (*arg == '&')
4420 {
4421 ++arg;
4422 /* Only for :set command set global value of local options. */
4423 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004424 didset_options();
4425 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004426 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004427 }
4428 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004429 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004430 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004431 did_show = TRUE;
4432 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004433 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004434 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004435 {
4436 showoptions(2, opt_flags);
4437 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004438 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004439 arg += 7;
4440 }
4441 else
4442 {
4443 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004444 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004445 {
4446 prefix = 0;
4447 arg += 2;
4448 }
4449 else if (STRNCMP(arg, "inv", 3) == 0)
4450 {
4451 prefix = 2;
4452 arg += 3;
4453 }
4454
4455 /* find end of name */
4456 key = 0;
4457 if (*arg == '<')
4458 {
4459 nextchar = 0;
4460 opt_idx = -1;
4461 /* look out for <t_>;> */
4462 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4463 len = 5;
4464 else
4465 {
4466 len = 1;
4467 while (arg[len] != NUL && arg[len] != '>')
4468 ++len;
4469 }
4470 if (arg[len] != '>')
4471 {
4472 errmsg = e_invarg;
4473 goto skip;
4474 }
4475 arg[len] = NUL; /* put NUL after name */
4476 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4477 opt_idx = findoption(arg + 1);
4478 arg[len++] = '>'; /* restore '>' */
4479 if (opt_idx == -1)
4480 key = find_key_option(arg + 1);
4481 }
4482 else
4483 {
4484 len = 0;
4485 /*
4486 * The two characters after "t_" may not be alphanumeric.
4487 */
4488 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4489 len = 4;
4490 else
4491 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4492 ++len;
4493 nextchar = arg[len];
4494 arg[len] = NUL; /* put NUL after name */
4495 opt_idx = findoption(arg);
4496 arg[len] = nextchar; /* restore nextchar */
4497 if (opt_idx == -1)
4498 key = find_key_option(arg);
4499 }
4500
4501 /* remember character after option name */
4502 afterchar = arg[len];
4503
4504 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004505 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004506 ++len;
4507
4508 adding = FALSE;
4509 prepending = FALSE;
4510 removing = FALSE;
4511 if (arg[len] != NUL && arg[len + 1] == '=')
4512 {
4513 if (arg[len] == '+')
4514 {
4515 adding = TRUE; /* "+=" */
4516 ++len;
4517 }
4518 else if (arg[len] == '^')
4519 {
4520 prepending = TRUE; /* "^=" */
4521 ++len;
4522 }
4523 else if (arg[len] == '-')
4524 {
4525 removing = TRUE; /* "-=" */
4526 ++len;
4527 }
4528 }
4529 nextchar = arg[len];
4530
4531 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4532 {
4533 errmsg = (char_u *)N_("E518: Unknown option");
4534 goto skip;
4535 }
4536
4537 if (opt_idx >= 0)
4538 {
4539 if (options[opt_idx].var == NULL) /* hidden option: skip */
4540 {
4541 /* Only give an error message when requesting the value of
4542 * a hidden option, ignore setting it. */
4543 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4544 && (!(options[opt_idx].flags & P_BOOL)
4545 || nextchar == '?'))
4546 errmsg = (char_u *)N_("E519: Option not supported");
4547 goto skip;
4548 }
4549
4550 flags = options[opt_idx].flags;
4551 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4552 }
4553 else
4554 {
4555 flags = P_STRING;
4556 if (key < 0)
4557 {
4558 key_name[0] = KEY2TERMCAP0(key);
4559 key_name[1] = KEY2TERMCAP1(key);
4560 }
4561 else
4562 {
4563 key_name[0] = KS_KEY;
4564 key_name[1] = (key & 0xff);
4565 }
4566 }
4567
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004568 /* Skip all options that are not window-local (used when showing
4569 * an already loaded buffer in a window). */
4570 if ((opt_flags & OPT_WINONLY)
4571 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4572 goto skip;
4573
Bram Moolenaara3227e22006-03-08 21:32:40 +00004574 /* Skip all options that are window-local (used for :vimgrep). */
4575 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4576 && options[opt_idx].var == VAR_WIN)
4577 goto skip;
4578
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004579 /* Disallow changing some options from modelines. */
4580 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004581 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004582 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004583 {
4584 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4585 goto skip;
4586 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004587#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004588 /* In diff mode some options are overruled. This avoids that
4589 * 'foldmethod' becomes "marker" instead of "diff" and that
4590 * "wrap" gets set. */
4591 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004592 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004593 && (
4594#ifdef FEAT_FOLDING
4595 options[opt_idx].indir == PV_FDM ||
4596#endif
4597 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004598 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004599#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004600 }
4601
4602#ifdef HAVE_SANDBOX
4603 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004604 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004605 {
4606 errmsg = (char_u *)_(e_sandbox);
4607 goto skip;
4608 }
4609#endif
4610
4611 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4612 {
4613 arg += len;
4614 cp_val = p_cp;
4615 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4616 {
4617 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4618 {
4619 cp_val = FALSE;
4620 arg += 3;
4621 }
4622 else /* "opt&vi": set to Vi default */
4623 {
4624 cp_val = TRUE;
4625 arg += 2;
4626 }
4627 }
4628 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004629 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004630 {
4631 errmsg = e_trailing;
4632 goto skip;
4633 }
4634 }
4635
4636 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004637 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4638 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004639 */
4640 if (nextchar == '?'
4641 || (prefix == 1
4642 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4643 && !(flags & P_BOOL)))
4644 {
4645 /*
4646 * print value
4647 */
4648 if (did_show)
4649 msg_putchar('\n'); /* cursor below last one */
4650 else
4651 {
4652 gotocmdline(TRUE); /* cursor at status line */
4653 did_show = TRUE; /* remember that we did a line */
4654 }
4655 if (opt_idx >= 0)
4656 {
4657 showoneopt(&options[opt_idx], opt_flags);
4658#ifdef FEAT_EVAL
4659 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004660 {
4661 /* Mention where the option was last set. */
4662 if (varp == options[opt_idx].var)
4663 last_set_msg(options[opt_idx].scriptID);
4664 else if ((int)options[opt_idx].indir & PV_WIN)
4665 last_set_msg(curwin->w_p_scriptID[
4666 (int)options[opt_idx].indir & PV_MASK]);
4667 else if ((int)options[opt_idx].indir & PV_BUF)
4668 last_set_msg(curbuf->b_p_scriptID[
4669 (int)options[opt_idx].indir & PV_MASK]);
4670 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004671#endif
4672 }
4673 else
4674 {
4675 char_u *p;
4676
4677 p = find_termcode(key_name);
4678 if (p == NULL)
4679 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004680 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004681 goto skip;
4682 }
4683 else
4684 (void)show_one_termcode(key_name, p, TRUE);
4685 }
4686 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004687 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004688 errmsg = e_trailing;
4689 }
4690 else
4691 {
4692 if (flags & P_BOOL) /* boolean */
4693 {
4694 if (nextchar == '=' || nextchar == ':')
4695 {
4696 errmsg = e_invarg;
4697 goto skip;
4698 }
4699
4700 /*
4701 * ":set opt!": invert
4702 * ":set opt&": reset to default value
4703 * ":set opt<": reset to global value
4704 */
4705 if (nextchar == '!')
4706 value = *(int *)(varp) ^ 1;
4707 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004708 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004709 ((flags & P_VI_DEF) || cp_val)
4710 ? VI_DEFAULT : VIM_DEFAULT];
4711 else if (nextchar == '<')
4712 {
4713 /* For 'autoread' -1 means to use global value. */
4714 if ((int *)varp == &curbuf->b_p_ar
4715 && opt_flags == OPT_LOCAL)
4716 value = -1;
4717 else
4718 value = *(int *)get_varp_scope(&(options[opt_idx]),
4719 OPT_GLOBAL);
4720 }
4721 else
4722 {
4723 /*
4724 * ":set invopt": invert
4725 * ":set opt" or ":set noopt": set or reset
4726 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004727 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004728 {
4729 errmsg = e_trailing;
4730 goto skip;
4731 }
4732 if (prefix == 2) /* inv */
4733 value = *(int *)(varp) ^ 1;
4734 else
4735 value = prefix;
4736 }
4737
4738 errmsg = set_bool_option(opt_idx, varp, (int)value,
4739 opt_flags);
4740 }
4741 else /* numeric or string */
4742 {
4743 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4744 || prefix != 1)
4745 {
4746 errmsg = e_invarg;
4747 goto skip;
4748 }
4749
4750 if (flags & P_NUM) /* numeric */
4751 {
4752 /*
4753 * Different ways to set a number option:
4754 * & set to default value
4755 * < set to global value
4756 * <xx> accept special key codes for 'wildchar'
4757 * c accept any non-digit for 'wildchar'
4758 * [-]0-9 set number
4759 * other error
4760 */
4761 ++arg;
4762 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004763 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004764 ((flags & P_VI_DEF) || cp_val)
4765 ? VI_DEFAULT : VIM_DEFAULT];
4766 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004767 {
4768 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4769 * use the global value. */
4770 if ((long *)varp == &curbuf->b_p_ul
4771 && opt_flags == OPT_LOCAL)
4772 value = NO_LOCAL_UNDOLEVEL;
4773 else
4774 value = *(long *)get_varp_scope(
4775 &(options[opt_idx]), OPT_GLOBAL);
4776 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004777 else if (((long *)varp == &p_wc
4778 || (long *)varp == &p_wcm)
4779 && (*arg == '<'
4780 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004781 || (*arg != NUL
4782 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004783 && !VIM_ISDIGIT(*arg))))
4784 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02004785 value = string_to_key(arg, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004786 if (value == 0 && (long *)varp != &p_wcm)
4787 {
4788 errmsg = e_invarg;
4789 goto skip;
4790 }
4791 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004792 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4793 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004794 /* Allow negative (for 'undolevels'), octal and
4795 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004796 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4797 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004798 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004799 {
4800 errmsg = e_invarg;
4801 goto skip;
4802 }
4803 }
4804 else
4805 {
4806 errmsg = (char_u *)N_("E521: Number required after =");
4807 goto skip;
4808 }
4809
4810 if (adding)
4811 value = *(long *)varp + value;
4812 if (prepending)
4813 value = *(long *)varp * value;
4814 if (removing)
4815 value = *(long *)varp - value;
4816 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004817 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004818 }
4819 else if (opt_idx >= 0) /* string */
4820 {
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004821 char_u *save_arg = NULL;
4822 char_u *s = NULL;
4823 char_u *oldval = NULL; /* previous value if *varp */
4824 char_u *newval;
4825 char_u *origval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004826#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004827 char_u *saved_origval = NULL;
4828 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004829#endif
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004830 unsigned newlen;
4831 int comma;
4832 int bs;
4833 int new_value_alloced; /* new string option
Bram Moolenaar071d4272004-06-13 20:20:40 +00004834 was allocated */
4835
4836 /* When using ":set opt=val" for a global option
4837 * with a local value the local value will be
4838 * reset, use the global value here. */
4839 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004840 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004841 varp = options[opt_idx].var;
4842
4843 /* The old value is kept until we are sure that the
4844 * new value is valid. */
4845 oldval = *(char_u **)varp;
Bram Moolenaar8efa0262017-08-20 15:47:20 +02004846
4847 /* When setting the local value of a global
4848 * option, the old value may be the global value. */
4849 if (((int)options[opt_idx].indir & PV_BOTH)
4850 && (opt_flags & OPT_LOCAL))
4851 origval = *(char_u **)get_varp(
4852 &options[opt_idx]);
4853 else
4854 origval = oldval;
4855
Bram Moolenaar071d4272004-06-13 20:20:40 +00004856 if (nextchar == '&') /* set to default val */
4857 {
4858 newval = options[opt_idx].def_val[
4859 ((flags & P_VI_DEF) || cp_val)
4860 ? VI_DEFAULT : VIM_DEFAULT];
4861 if ((char_u **)varp == &p_bg)
4862 {
4863 /* guess the value of 'background' */
4864#ifdef FEAT_GUI
4865 if (gui.in_use)
4866 newval = gui_bg_default();
4867 else
4868#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004869 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004870 }
4871
4872 /* expand environment variables and ~ (since the
4873 * default value was already expanded, only
4874 * required when an environment variable was set
4875 * later */
4876 if (newval == NULL)
4877 newval = empty_option;
4878 else
4879 {
4880 s = option_expand(opt_idx, newval);
4881 if (s == NULL)
4882 s = newval;
4883 newval = vim_strsave(s);
4884 }
4885 new_value_alloced = TRUE;
4886 }
4887 else if (nextchar == '<') /* set to global val */
4888 {
4889 newval = vim_strsave(*(char_u **)get_varp_scope(
4890 &(options[opt_idx]), OPT_GLOBAL));
4891 new_value_alloced = TRUE;
4892 }
4893 else
4894 {
4895 ++arg; /* jump to after the '=' or ':' */
4896
4897 /*
4898 * Set 'keywordprg' to ":help" if an empty
4899 * value was passed to :set by the user.
4900 * Misuse errbuf[] for the resulting string.
4901 */
4902 if (varp == (char_u *)&p_kp
4903 && (*arg == NUL || *arg == ' '))
4904 {
4905 STRCPY(errbuf, ":help");
4906 save_arg = arg;
4907 arg = errbuf;
4908 }
4909 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004910 * Convert 'backspace' number to string, for
4911 * adding, prepending and removing string.
4912 */
4913 else if (varp == (char_u *)&p_bs
4914 && VIM_ISDIGIT(**(char_u **)varp))
4915 {
4916 i = getdigits((char_u **)varp);
4917 switch (i)
4918 {
4919 case 0:
4920 *(char_u **)varp = empty_option;
4921 break;
4922 case 1:
4923 *(char_u **)varp = vim_strsave(
4924 (char_u *)"indent,eol");
4925 break;
4926 case 2:
4927 *(char_u **)varp = vim_strsave(
4928 (char_u *)"indent,eol,start");
4929 break;
4930 }
4931 vim_free(oldval);
Bram Moolenaaredbc0d42017-08-20 16:11:51 +02004932 if (origval == oldval)
4933 origval = *(char_u **)varp;
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004934 oldval = *(char_u **)varp;
4935 }
4936 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004937 * Convert 'whichwrap' number to string, for
4938 * backwards compatibility with Vim 3.0.
4939 * Misuse errbuf[] for the resulting string.
4940 */
4941 else if (varp == (char_u *)&p_ww
4942 && VIM_ISDIGIT(*arg))
4943 {
4944 *errbuf = NUL;
4945 i = getdigits(&arg);
4946 if (i & 1)
4947 STRCAT(errbuf, "b,");
4948 if (i & 2)
4949 STRCAT(errbuf, "s,");
4950 if (i & 4)
4951 STRCAT(errbuf, "h,l,");
4952 if (i & 8)
4953 STRCAT(errbuf, "<,>,");
4954 if (i & 16)
4955 STRCAT(errbuf, "[,],");
4956 if (*errbuf != NUL) /* remove trailing , */
4957 errbuf[STRLEN(errbuf) - 1] = NUL;
4958 save_arg = arg;
4959 arg = errbuf;
4960 }
4961 /*
4962 * Remove '>' before 'dir' and 'bdir', for
4963 * backwards compatibility with version 3.0
4964 */
4965 else if ( *arg == '>'
4966 && (varp == (char_u *)&p_dir
4967 || varp == (char_u *)&p_bdir))
4968 {
4969 ++arg;
4970 }
4971
Bram Moolenaar071d4272004-06-13 20:20:40 +00004972 /*
4973 * Copy the new string into allocated memory.
4974 * Can't use set_string_option_direct(), because
4975 * we need to remove the backslashes.
4976 */
4977 /* get a bit too much */
4978 newlen = (unsigned)STRLEN(arg) + 1;
4979 if (adding || prepending || removing)
4980 newlen += (unsigned)STRLEN(origval) + 1;
4981 newval = alloc(newlen);
4982 if (newval == NULL) /* out of mem, don't change */
4983 break;
4984 s = newval;
4985
4986 /*
4987 * Copy the string, skip over escaped chars.
4988 * For MS-DOS and WIN32 backslashes before normal
4989 * file name characters are not removed, and keep
4990 * backslash at start, for "\\machine\path", but
4991 * do remove it for "\\\\machine\\path".
4992 * The reverse is found in ExpandOldSetting().
4993 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004994 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004995 {
4996 if (*arg == '\\' && arg[1] != NUL
4997#ifdef BACKSLASH_IN_FILENAME
4998 && !((flags & P_EXPAND)
4999 && vim_isfilec(arg[1])
5000 && (arg[1] != '\\'
5001 || (s == newval
5002 && arg[2] != '\\')))
5003#endif
5004 )
5005 ++arg; /* remove backslash */
5006#ifdef FEAT_MBYTE
5007 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00005008 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005009 {
5010 /* copy multibyte char */
5011 mch_memmove(s, arg, (size_t)i);
5012 arg += i;
5013 s += i;
5014 }
5015 else
5016#endif
5017 *s++ = *arg++;
5018 }
5019 *s = NUL;
5020
5021 /*
5022 * Expand environment variables and ~.
5023 * Don't do it when adding without inserting a
5024 * comma.
5025 */
5026 if (!(adding || prepending || removing)
5027 || (flags & P_COMMA))
5028 {
5029 s = option_expand(opt_idx, newval);
5030 if (s != NULL)
5031 {
5032 vim_free(newval);
5033 newlen = (unsigned)STRLEN(s) + 1;
5034 if (adding || prepending || removing)
5035 newlen += (unsigned)STRLEN(origval) + 1;
5036 newval = alloc(newlen);
5037 if (newval == NULL)
5038 break;
5039 STRCPY(newval, s);
5040 }
5041 }
5042
5043 /* locate newval[] in origval[] when removing it
5044 * and when adding to avoid duplicates */
5045 i = 0; /* init for GCC */
5046 if (removing || (flags & P_NODUP))
5047 {
5048 i = (int)STRLEN(newval);
5049 bs = 0;
5050 for (s = origval; *s; ++s)
5051 {
5052 if ((!(flags & P_COMMA)
5053 || s == origval
5054 || (s[-1] == ',' && !(bs & 1)))
5055 && STRNCMP(s, newval, i) == 0
5056 && (!(flags & P_COMMA)
5057 || s[i] == ','
5058 || s[i] == NUL))
5059 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005060 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005061 * even number of backslashes or a single
5062 * backslash preceded by a comma before it
5063 * is recognized as a separator */
5064 if ((s > origval + 1
5065 && s[-1] == '\\'
5066 && s[-2] != ',')
5067 || (s == origval + 1
5068 && s[-1] == '\\'))
5069
Bram Moolenaar071d4272004-06-13 20:20:40 +00005070 ++bs;
5071 else
5072 bs = 0;
5073 }
5074
5075 /* do not add if already there */
5076 if ((adding || prepending) && *s)
5077 {
5078 prepending = FALSE;
5079 adding = FALSE;
5080 STRCPY(newval, origval);
5081 }
5082 }
5083
5084 /* concatenate the two strings; add a ',' if
5085 * needed */
5086 if (adding || prepending)
5087 {
5088 comma = ((flags & P_COMMA) && *origval != NUL
5089 && *newval != NUL);
5090 if (adding)
5091 {
5092 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005093 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005094 if (comma && i > 1
5095 && (flags & P_ONECOMMA) == P_ONECOMMA
5096 && origval[i - 1] == ','
5097 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005098 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005099 mch_memmove(newval + i + comma, newval,
5100 STRLEN(newval) + 1);
5101 mch_memmove(newval, origval, (size_t)i);
5102 }
5103 else
5104 {
5105 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005106 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005107 }
5108 if (comma)
5109 newval[i] = ',';
5110 }
5111
5112 /* Remove newval[] from origval[]. (Note: "i" has
5113 * been set above and is used here). */
5114 if (removing)
5115 {
5116 STRCPY(newval, origval);
5117 if (*s)
5118 {
5119 /* may need to remove a comma */
5120 if (flags & P_COMMA)
5121 {
5122 if (s == origval)
5123 {
5124 /* include comma after string */
5125 if (s[i] == ',')
5126 ++i;
5127 }
5128 else
5129 {
5130 /* include comma before string */
5131 --s;
5132 ++i;
5133 }
5134 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005135 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005136 }
5137 }
5138
5139 if (flags & P_FLAGLIST)
5140 {
5141 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005142 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005143 {
5144 /* if options have P_FLAGLIST and
5145 * P_ONECOMMA such as 'whichwrap' */
5146 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005147 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005148 if (*s != ',' && *(s + 1) == ','
5149 && vim_strchr(s + 2, *s) != NULL)
5150 {
5151 /* Remove the duplicated value and
5152 * the next comma. */
5153 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005154 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005155 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005156 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005157 else
5158 {
5159 if ((!(flags & P_COMMA) || *s != ',')
5160 && vim_strchr(s + 1, *s) != NULL)
5161 {
5162 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005163 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005164 }
5165 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005166 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005167 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005168 }
5169
5170 if (save_arg != NULL) /* number for 'whichwrap' */
5171 arg = save_arg;
5172 new_value_alloced = TRUE;
5173 }
5174
Bram Moolenaar8efa0262017-08-20 15:47:20 +02005175 /*
5176 * Set the new value.
5177 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005178 *(char_u **)(varp) = newval;
5179
Bram Moolenaar53744302015-07-17 17:38:22 +02005180#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005181 if (!starting
5182# ifdef FEAT_CRYPT
5183 && options[opt_idx].indir != PV_KEY
5184# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005185 && origval != NULL && newval != NULL)
5186 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005187 /* origval may be freed by
5188 * did_set_string_option(), make a copy. */
5189 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005190 /* newval (and varp) may become invalid if the
5191 * buffer is closed by autocommands. */
5192 saved_newval = vim_strsave(newval);
5193 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005194#endif
5195
Bram Moolenaar071d4272004-06-13 20:20:40 +00005196 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005197 * ":set" on local options. Note: when setting 'syntax'
5198 * or 'filetype' autocommands may be triggered that can
5199 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005200 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5201 new_value_alloced, oldval, errbuf, opt_flags);
5202
Bram Moolenaar8efa0262017-08-20 15:47:20 +02005203#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5204 if (errmsg == NULL)
5205 trigger_optionsset_string(opt_idx, opt_flags,
5206 saved_origval, saved_newval);
5207 vim_free(saved_origval);
5208 vim_free(saved_newval);
5209#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005210 /* If error detected, print the error message. */
5211 if (errmsg != NULL)
5212 goto skip;
5213 }
5214 else /* key code option */
5215 {
5216 char_u *p;
5217
5218 if (nextchar == '&')
5219 {
5220 if (add_termcap_entry(key_name, TRUE) == FAIL)
5221 errmsg = (char_u *)N_("E522: Not found in termcap");
5222 }
5223 else
5224 {
5225 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005226 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005227 if (*p == '\\' && p[1] != NUL)
5228 ++p;
5229 nextchar = *p;
5230 *p = NUL;
5231 add_termcode(key_name, arg, FALSE);
5232 *p = nextchar;
5233 }
5234 if (full_screen)
5235 ttest(FALSE);
5236 redraw_all_later(CLEAR);
5237 }
5238 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005239
Bram Moolenaar071d4272004-06-13 20:20:40 +00005240 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005241 did_set_option(opt_idx, opt_flags,
5242 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005243 }
5244
5245skip:
5246 /*
5247 * Advance to next argument.
5248 * - skip until a blank found, taking care of backslashes
5249 * - skip blanks
5250 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5251 */
5252 for (i = 0; i < 2 ; ++i)
5253 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005254 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005255 if (*arg++ == '\\' && *arg != NUL)
5256 ++arg;
5257 arg = skipwhite(arg);
5258 if (*arg != '=')
5259 break;
5260 }
5261 }
5262
5263 if (errmsg != NULL)
5264 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005265 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005266 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005267 if (i + (arg - startarg) < IOSIZE)
5268 {
5269 /* append the argument with the error */
5270 STRCAT(IObuff, ": ");
5271 mch_memmove(IObuff + i, startarg, (arg - startarg));
5272 IObuff[i + (arg - startarg)] = NUL;
5273 }
5274 /* make sure all characters are printable */
5275 trans_characters(IObuff, IOSIZE);
5276
5277 ++no_wait_return; /* wait_return done later */
5278 emsg(IObuff); /* show error highlighted */
5279 --no_wait_return;
5280
5281 return FAIL;
5282 }
5283
5284 arg = skipwhite(arg);
5285 }
5286
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005287theend:
5288 if (silent_mode && did_show)
5289 {
5290 /* After displaying option values in silent mode. */
5291 silent_mode = FALSE;
5292 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5293 msg_putchar('\n');
5294 cursor_on(); /* msg_start() switches it off */
5295 out_flush();
5296 silent_mode = TRUE;
5297 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5298 }
5299
Bram Moolenaar071d4272004-06-13 20:20:40 +00005300 return OK;
5301}
5302
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005303/*
5304 * Call this when an option has been given a new value through a user command.
5305 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5306 */
5307 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005308did_set_option(
5309 int opt_idx,
5310 int opt_flags, /* possibly with OPT_MODELINE */
5311 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005312{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005313 long_u *p;
5314
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005315 options[opt_idx].flags |= P_WAS_SET;
5316
5317 /* When an option is set in the sandbox, from a modeline or in secure mode
5318 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005319 * flag. */
5320 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005321 if (secure
5322#ifdef HAVE_SANDBOX
5323 || sandbox != 0
5324#endif
5325 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005326 *p = *p | P_INSECURE;
5327 else if (new_value)
5328 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005329}
5330
Bram Moolenaar071d4272004-06-13 20:20:40 +00005331 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005332illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005333{
5334 if (errbuf == NULL)
5335 return (char_u *)"";
5336 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005337 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005338 return errbuf;
5339}
5340
5341/*
5342 * Convert a key name or string into a key value.
5343 * Used for 'wildchar' and 'cedit' options.
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005344 * When "multi_byte" is TRUE allow for multi-byte characters.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005345 */
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005346 int
5347string_to_key(char_u *arg, int multi_byte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005348{
5349 if (*arg == '<')
5350 return find_key_option(arg + 1);
5351 if (*arg == '^')
5352 return Ctrl_chr(arg[1]);
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005353 if (multi_byte)
5354 return PTR2CHAR(arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005355 return *arg;
5356}
5357
5358#ifdef FEAT_CMDWIN
5359/*
5360 * Check value of 'cedit' and set cedit_key.
5361 * Returns NULL if value is OK, error message otherwise.
5362 */
5363 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005364check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005365{
5366 int n;
5367
5368 if (*p_cedit == NUL)
5369 cedit_key = -1;
5370 else
5371 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005372 n = string_to_key(p_cedit, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005373 if (vim_isprintc(n))
5374 return e_invarg;
5375 cedit_key = n;
5376 }
5377 return NULL;
5378}
5379#endif
5380
5381#ifdef FEAT_TITLE
5382/*
5383 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5384 * maketitle() to create and display it.
5385 * When switching the title or icon off, call mch_restore_title() to get
5386 * the old value back.
5387 */
5388 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005389did_set_title(
5390 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005391{
5392 if (starting != NO_SCREEN
5393#ifdef FEAT_GUI
5394 && !gui.starting
5395#endif
5396 )
5397 {
5398 maketitle();
5399 if (icon)
5400 {
5401 if (!p_icon)
5402 mch_restore_title(2);
5403 }
5404 else
5405 {
5406 if (!p_title)
5407 mch_restore_title(1);
5408 }
5409 }
5410}
5411#endif
5412
5413/*
5414 * set_options_bin - called when 'bin' changes value.
5415 */
5416 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005417set_options_bin(
5418 int oldval,
5419 int newval,
5420 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005421{
5422 /*
5423 * The option values that are changed when 'bin' changes are
5424 * copied when 'bin is set and restored when 'bin' is reset.
5425 */
5426 if (newval)
5427 {
5428 if (!oldval) /* switched on */
5429 {
5430 if (!(opt_flags & OPT_GLOBAL))
5431 {
5432 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5433 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5434 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5435 curbuf->b_p_et_nobin = curbuf->b_p_et;
5436 }
5437 if (!(opt_flags & OPT_LOCAL))
5438 {
5439 p_tw_nobin = p_tw;
5440 p_wm_nobin = p_wm;
5441 p_ml_nobin = p_ml;
5442 p_et_nobin = p_et;
5443 }
5444 }
5445
5446 if (!(opt_flags & OPT_GLOBAL))
5447 {
5448 curbuf->b_p_tw = 0; /* no automatic line wrap */
5449 curbuf->b_p_wm = 0; /* no automatic line wrap */
5450 curbuf->b_p_ml = 0; /* no modelines */
5451 curbuf->b_p_et = 0; /* no expandtab */
5452 }
5453 if (!(opt_flags & OPT_LOCAL))
5454 {
5455 p_tw = 0;
5456 p_wm = 0;
5457 p_ml = FALSE;
5458 p_et = FALSE;
5459 p_bin = TRUE; /* needed when called for the "-b" argument */
5460 }
5461 }
5462 else if (oldval) /* switched off */
5463 {
5464 if (!(opt_flags & OPT_GLOBAL))
5465 {
5466 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5467 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5468 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5469 curbuf->b_p_et = curbuf->b_p_et_nobin;
5470 }
5471 if (!(opt_flags & OPT_LOCAL))
5472 {
5473 p_tw = p_tw_nobin;
5474 p_wm = p_wm_nobin;
5475 p_ml = p_ml_nobin;
5476 p_et = p_et_nobin;
5477 }
5478 }
5479}
5480
5481#ifdef FEAT_VIMINFO
5482/*
5483 * Find the parameter represented by the given character (eg ', :, ", or /),
5484 * and return its associated value in the 'viminfo' string.
5485 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005486 * If the parameter is not specified in the string or there is no following
5487 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005488 */
5489 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005490get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005491{
5492 char_u *p;
5493
5494 p = find_viminfo_parameter(type);
5495 if (p != NULL && VIM_ISDIGIT(*p))
5496 return atoi((char *)p);
5497 return -1;
5498}
5499
5500/*
5501 * Find the parameter represented by the given character (eg ''', ':', '"', or
5502 * '/') in the 'viminfo' option and return a pointer to the string after it.
5503 * Return NULL if the parameter is not specified in the string.
5504 */
5505 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005506find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005507{
5508 char_u *p;
5509
5510 for (p = p_viminfo; *p; ++p)
5511 {
5512 if (*p == type)
5513 return p + 1;
5514 if (*p == 'n') /* 'n' is always the last one */
5515 break;
5516 p = vim_strchr(p, ','); /* skip until next ',' */
5517 if (p == NULL) /* hit the end without finding parameter */
5518 break;
5519 }
5520 return NULL;
5521}
5522#endif
5523
5524/*
5525 * Expand environment variables for some string options.
5526 * These string options cannot be indirect!
5527 * If "val" is NULL expand the current value of the option.
5528 * Return pointer to NameBuff, or NULL when not expanded.
5529 */
5530 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005531option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005532{
5533 /* if option doesn't need expansion nothing to do */
5534 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5535 return NULL;
5536
5537 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5538 * expand_env() would truncate the string. */
5539 if (val != NULL && STRLEN(val) > MAXPATHL)
5540 return NULL;
5541
5542 if (val == NULL)
5543 val = *(char_u **)options[opt_idx].var;
5544
5545 /*
5546 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5547 * Escape spaces when expanding 'tags', they are used to separate file
5548 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005549 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005550 */
5551 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005552 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005553#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005554 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5555#endif
5556 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005557 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5558 return NULL;
5559
5560 return NameBuff;
5561}
5562
5563/*
5564 * After setting various option values: recompute variables that depend on
5565 * option values.
5566 */
5567 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005568didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005569{
5570 /* initialize the table for 'iskeyword' et.al. */
5571 (void)init_chartab();
5572
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005573#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005574 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005575#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005576 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005577 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005578#ifdef FEAT_SESSION
5579 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5580 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5581#endif
5582#ifdef FEAT_FOLDING
5583 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5584#endif
5585 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005586 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005587#ifdef FEAT_VIRTUALEDIT
5588 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5589#endif
5590#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5591 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5592#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005593#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005594 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005595 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005596 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005597 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005598#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005599#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5600 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5601#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005602#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005603 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5604#endif
5605#ifdef FEAT_CMDWIN
5606 /* set cedit_key */
5607 (void)check_cedit();
5608#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005609#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005610 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005611#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005612#ifdef FEAT_LINEBREAK
5613 /* initialize the table for 'breakat'. */
5614 fill_breakat_flags();
5615#endif
5616
5617}
5618
5619/*
5620 * More side effects of setting options.
5621 */
5622 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005623didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005624{
5625 /* Initialize the highlight_attr[] table. */
5626 (void)highlight_changed();
5627
5628 /* Parse default for 'wildmode' */
5629 check_opt_wim();
5630
5631 (void)set_chars_option(&p_lcs);
5632#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5633 /* Parse default for 'fillchars'. */
5634 (void)set_chars_option(&p_fcs);
5635#endif
5636
5637#ifdef FEAT_CLIPBOARD
5638 /* Parse default for 'clipboard' */
5639 (void)check_clipboard_option();
5640#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005641}
5642
5643/*
5644 * Check for string options that are NULL (normally only termcap options).
5645 */
5646 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005647check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005648{
5649 int opt_idx;
5650
5651 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5652 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5653 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5654}
5655
5656/*
5657 * Check string options in a buffer for NULL value.
5658 */
5659 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005660check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005661{
Bram Moolenaar071d4272004-06-13 20:20:40 +00005662 check_string_option(&buf->b_p_bh);
5663 check_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005664#ifdef FEAT_MBYTE
5665 check_string_option(&buf->b_p_fenc);
5666#endif
5667 check_string_option(&buf->b_p_ff);
5668#ifdef FEAT_FIND_ID
5669 check_string_option(&buf->b_p_def);
5670 check_string_option(&buf->b_p_inc);
5671# ifdef FEAT_EVAL
5672 check_string_option(&buf->b_p_inex);
5673# endif
5674#endif
5675#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5676 check_string_option(&buf->b_p_inde);
5677 check_string_option(&buf->b_p_indk);
5678#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005679#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5680 check_string_option(&buf->b_p_bexpr);
5681#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005682#if defined(FEAT_CRYPT)
5683 check_string_option(&buf->b_p_cm);
5684#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005685 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005686#if defined(FEAT_EVAL)
5687 check_string_option(&buf->b_p_fex);
5688#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005689#ifdef FEAT_CRYPT
5690 check_string_option(&buf->b_p_key);
5691#endif
5692 check_string_option(&buf->b_p_kp);
5693 check_string_option(&buf->b_p_mps);
5694 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005695 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005696 check_string_option(&buf->b_p_isk);
5697#ifdef FEAT_COMMENTS
5698 check_string_option(&buf->b_p_com);
5699#endif
5700#ifdef FEAT_FOLDING
5701 check_string_option(&buf->b_p_cms);
5702#endif
5703 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005704#ifdef FEAT_TEXTOBJ
5705 check_string_option(&buf->b_p_qe);
5706#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005707#ifdef FEAT_SYN_HL
5708 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005709 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005710#endif
5711#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005712 check_string_option(&buf->b_s.b_p_spc);
5713 check_string_option(&buf->b_s.b_p_spf);
5714 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005715#endif
5716#ifdef FEAT_SEARCHPATH
5717 check_string_option(&buf->b_p_sua);
5718#endif
5719#ifdef FEAT_CINDENT
5720 check_string_option(&buf->b_p_cink);
5721 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005722 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005723#endif
5724#ifdef FEAT_AUTOCMD
5725 check_string_option(&buf->b_p_ft);
5726#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005727#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5728 check_string_option(&buf->b_p_cinw);
5729#endif
5730#ifdef FEAT_INS_EXPAND
5731 check_string_option(&buf->b_p_cpt);
5732#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005733#ifdef FEAT_COMPL_FUNC
5734 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005735 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005736#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005737#ifdef FEAT_KEYMAP
5738 check_string_option(&buf->b_p_keymap);
5739#endif
5740#ifdef FEAT_QUICKFIX
5741 check_string_option(&buf->b_p_gp);
5742 check_string_option(&buf->b_p_mp);
5743 check_string_option(&buf->b_p_efm);
5744#endif
5745 check_string_option(&buf->b_p_ep);
5746 check_string_option(&buf->b_p_path);
5747 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005748 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005749#ifdef FEAT_INS_EXPAND
5750 check_string_option(&buf->b_p_dict);
5751 check_string_option(&buf->b_p_tsr);
5752#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005753#ifdef FEAT_LISP
5754 check_string_option(&buf->b_p_lw);
5755#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005756 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005757#ifdef FEAT_MBYTE
5758 check_string_option(&buf->b_p_menc);
5759#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005760}
5761
5762/*
5763 * Free the string allocated for an option.
5764 * Checks for the string being empty_option. This may happen if we're out of
5765 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5766 * check_options().
5767 * Does NOT check for P_ALLOCED flag!
5768 */
5769 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005770free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005771{
5772 if (p != empty_option)
5773 vim_free(p);
5774}
5775
5776 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005777clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005778{
5779 if (*pp != empty_option)
5780 vim_free(*pp);
5781 *pp = empty_option;
5782}
5783
5784 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005785check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005786{
5787 if (*pp == NULL)
5788 *pp = empty_option;
5789}
5790
5791/*
5792 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5793 */
5794 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005795set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005796{
5797 int opt_idx;
5798
5799 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5800 if (options[opt_idx].var == (char_u *)p)
5801 {
5802 options[opt_idx].flags |= P_ALLOCED;
5803 return;
5804 }
5805 return; /* cannot happen: didn't find it! */
5806}
5807
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005808#if defined(FEAT_EVAL) || defined(PROTO)
5809/*
5810 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5811 * Return FALSE when it wasn't.
5812 * Return -1 for an unknown option.
5813 */
5814 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005815was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005816{
5817 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005818 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005819
5820 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005821 {
5822 flagp = insecure_flag(idx, opt_flags);
5823 return (*flagp & P_INSECURE) != 0;
5824 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005825 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005826 return -1;
5827}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005828
5829/*
5830 * Get a pointer to the flags used for the P_INSECURE flag of option
5831 * "opt_idx". For some local options a local flags field is used.
5832 */
5833 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005834insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005835{
5836 if (opt_flags & OPT_LOCAL)
5837 switch ((int)options[opt_idx].indir)
5838 {
5839#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005840 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005841#endif
5842#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005843# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005844 case PV_FDE: return &curwin->w_p_fde_flags;
5845 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005846# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005847# ifdef FEAT_BEVAL
5848 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5849# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005850# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005851 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005852# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005853 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005854# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005855 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005856# endif
5857#endif
5858 }
5859
5860 /* Nothing special, return global flags field. */
5861 return &options[opt_idx].flags;
5862}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005863#endif
5864
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005865#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005866static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005867
5868/*
5869 * Redraw the window title and/or tab page text later.
5870 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005871static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005872{
5873 need_maketitle = TRUE;
5874# ifdef FEAT_WINDOWS
5875 redraw_tabline = TRUE;
5876# endif
5877}
5878#endif
5879
Bram Moolenaar071d4272004-06-13 20:20:40 +00005880/*
5881 * Set a string option to a new value (without checking the effect).
5882 * The string is copied into allocated memory.
5883 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005884 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005885 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005886 */
5887 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005888set_string_option_direct(
5889 char_u *name,
5890 int opt_idx,
5891 char_u *val,
5892 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5893 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005894{
5895 char_u *s;
5896 char_u **varp;
5897 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005898 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005899
Bram Moolenaar89d40322006-08-29 15:30:07 +00005900 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005901 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005902 idx = findoption(name);
5903 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005904 {
5905 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005906 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005907 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005908 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005909 }
5910
Bram Moolenaar89d40322006-08-29 15:30:07 +00005911 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005912 return;
5913
5914 s = vim_strsave(val);
5915 if (s != NULL)
5916 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005917 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005918 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005919 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005920 free_string_option(*varp);
5921 *varp = s;
5922
5923 /* For buffer/window local option may also set the global value. */
5924 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005925 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005926
Bram Moolenaar89d40322006-08-29 15:30:07 +00005927 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005928
5929 /* When setting both values of a global option with a local value,
5930 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005931 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005932 {
5933 free_string_option(*varp);
5934 *varp = empty_option;
5935 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005936# ifdef FEAT_EVAL
5937 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005938 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005939 set_sid == 0 ? current_SID : set_sid);
5940# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005941 }
5942}
5943
5944/*
5945 * Set global value for string option when it's a local option.
5946 */
5947 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005948set_string_option_global(
5949 int opt_idx, /* option index */
5950 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005951{
5952 char_u **p, *s;
5953
5954 /* the global value is always allocated */
5955 if (options[opt_idx].var == VAR_WIN)
5956 p = (char_u **)GLOBAL_WO(varp);
5957 else
5958 p = (char_u **)options[opt_idx].var;
5959 if (options[opt_idx].indir != PV_NONE
5960 && p != varp
5961 && (s = vim_strsave(*varp)) != NULL)
5962 {
5963 free_string_option(*p);
5964 *p = s;
5965 }
5966}
5967
5968/*
5969 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005970 *
5971 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005972 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005973 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005974set_string_option(
5975 int opt_idx,
5976 char_u *value,
5977 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005978{
5979 char_u *s;
5980 char_u **varp;
5981 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005982#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5983 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005984 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005985#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005986 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005987
5988 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005989 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005990
5991 s = vim_strsave(value);
5992 if (s != NULL)
5993 {
5994 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5995 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005996 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005997 ? OPT_GLOBAL : OPT_LOCAL)
5998 : opt_flags);
5999 oldval = *varp;
6000 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02006001
6002#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02006003 if (!starting
6004# ifdef FEAT_CRYPT
6005 && options[opt_idx].indir != PV_KEY
6006# endif
6007 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006008 {
Bram Moolenaar53744302015-07-17 17:38:22 +02006009 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006010 saved_newval = vim_strsave(s);
6011 }
Bram Moolenaar53744302015-07-17 17:38:22 +02006012#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006013 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
6014 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00006015 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02006016
Bram Moolenaar53744302015-07-17 17:38:22 +02006017#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006018 /* call autocommand after handling side effects */
Bram Moolenaar8efa0262017-08-20 15:47:20 +02006019 if (r == NULL)
6020 trigger_optionsset_string(opt_idx, opt_flags,
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006021 saved_oldval, saved_newval);
Bram Moolenaar8efa0262017-08-20 15:47:20 +02006022 vim_free(saved_oldval);
6023 vim_free(saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02006024#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006025 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006026 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006027}
6028
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006029#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006030/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006031 * Return TRUE if "val" is a valid 'filetype' name.
6032 * Also used for 'syntax' and 'keymap'.
6033 */
6034 static int
6035valid_filetype(char_u *val)
6036{
6037 char_u *s;
6038
6039 for (s = val; *s != NUL; ++s)
6040 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6041 return FALSE;
6042 return TRUE;
6043}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006044#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006045
6046/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006047 * Handle string options that need some action to perform when changed.
6048 * Returns NULL for success, or an error message for an error.
6049 */
6050 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006051did_set_string_option(
6052 int opt_idx, /* index in options[] table */
6053 char_u **varp, /* pointer to the option variable */
6054 int new_value_alloced, /* new value was allocated */
6055 char_u *oldval, /* previous value of the option */
6056 char_u *errbuf, /* buffer for errors, or NULL */
6057 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006058{
6059 char_u *errmsg = NULL;
6060 char_u *s, *p;
6061 int did_chartab = FALSE;
6062 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006063 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006064#ifdef FEAT_GUI
6065 /* set when changing an option that only requires a redraw in the GUI */
6066 int redraw_gui_only = FALSE;
6067#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006068#ifdef FEAT_AUTOCMD
6069 int ft_changed = FALSE;
6070#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006071
6072 /* Get the global option to compare with, otherwise we would have to check
6073 * two values for all local options. */
6074 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6075
6076 /* Disallow changing some options from secure mode */
6077 if ((secure
6078#ifdef HAVE_SANDBOX
6079 || sandbox != 0
6080#endif
6081 ) && (options[opt_idx].flags & P_SECURE))
6082 {
6083 errmsg = e_secure;
6084 }
6085
Bram Moolenaar7554da42016-11-25 22:04:13 +01006086 /* Check for a "normal" directory or file name in some options. Disallow a
6087 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006088 * are often illegal in a file name. Be more permissive if "secure" is off.
6089 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006090 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006091 && vim_strpbrk(*varp, (char_u *)(secure
6092 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006093 || ((options[opt_idx].flags & P_NDNAME)
6094 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006095 {
6096 errmsg = e_invarg;
6097 }
6098
Bram Moolenaar071d4272004-06-13 20:20:40 +00006099 /* 'term' */
6100 else if (varp == &T_NAME)
6101 {
6102 if (T_NAME[0] == NUL)
6103 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6104#ifdef FEAT_GUI
6105 if (gui.in_use)
6106 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6107 else if (term_is_gui(T_NAME))
6108 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6109#endif
6110 else if (set_termname(T_NAME) == FAIL)
6111 errmsg = (char_u *)N_("E522: Not found in termcap");
6112 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006113 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006114 /* Screen colors may have changed. */
6115 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006116
6117 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6118 * P_ALLOCED flag on 'term'. */
6119 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006120 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006121 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006122 }
6123
6124 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006125 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006126 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006127 char_u *bkc = p_bkc;
6128 unsigned int *flags = &bkc_flags;
6129
6130 if (opt_flags & OPT_LOCAL)
6131 {
6132 bkc = curbuf->b_p_bkc;
6133 flags = &curbuf->b_bkc_flags;
6134 }
6135
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006136 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6137 /* make the local value empty: use the global value */
6138 *flags = 0;
6139 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006140 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006141 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6142 errmsg = e_invarg;
6143 if ((((int)*flags & BKC_AUTO) != 0)
6144 + (((int)*flags & BKC_YES) != 0)
6145 + (((int)*flags & BKC_NO) != 0) != 1)
6146 {
6147 /* Must have exactly one of "auto", "yes" and "no". */
6148 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6149 errmsg = e_invarg;
6150 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006151 }
6152 }
6153
6154 /* 'backupext' and 'patchmode' */
6155 else if (varp == &p_bex || varp == &p_pm)
6156 {
6157 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6158 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6159 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6160 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006161#ifdef FEAT_LINEBREAK
6162 /* 'breakindentopt' */
6163 else if (varp == &curwin->w_p_briopt)
6164 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006165 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006166 errmsg = e_invarg;
6167 }
6168#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006169
6170 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006171 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006172 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006173 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006174 */
6175 else if ( varp == &p_isi
6176 || varp == &(curbuf->b_p_isk)
6177 || varp == &p_isp
6178 || varp == &p_isf)
6179 {
6180 if (init_chartab() == FAIL)
6181 {
6182 did_chartab = TRUE; /* need to restore it below */
6183 errmsg = e_invarg; /* error in value */
6184 }
6185 }
6186
6187 /* 'helpfile' */
6188 else if (varp == &p_hf)
6189 {
6190 /* May compute new values for $VIM and $VIMRUNTIME */
6191 if (didset_vim)
6192 {
6193 vim_setenv((char_u *)"VIM", (char_u *)"");
6194 didset_vim = FALSE;
6195 }
6196 if (didset_vimruntime)
6197 {
6198 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6199 didset_vimruntime = FALSE;
6200 }
6201 }
6202
Bram Moolenaar1a384422010-07-14 19:53:30 +02006203#ifdef FEAT_SYN_HL
6204 /* 'colorcolumn' */
6205 else if (varp == &curwin->w_p_cc)
6206 errmsg = check_colorcolumn(curwin);
6207#endif
6208
Bram Moolenaar071d4272004-06-13 20:20:40 +00006209#ifdef FEAT_MULTI_LANG
6210 /* 'helplang' */
6211 else if (varp == &p_hlg)
6212 {
6213 /* Check for "", "ab", "ab,cd", etc. */
6214 for (s = p_hlg; *s != NUL; s += 3)
6215 {
6216 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6217 {
6218 errmsg = e_invarg;
6219 break;
6220 }
6221 if (s[2] == NUL)
6222 break;
6223 }
6224 }
6225#endif
6226
6227 /* 'highlight' */
6228 else if (varp == &p_hl)
6229 {
6230 if (highlight_changed() == FAIL)
6231 errmsg = e_invarg; /* invalid flags */
6232 }
6233
6234 /* 'nrformats' */
6235 else if (gvarp == &p_nf)
6236 {
6237 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6238 errmsg = e_invarg;
6239 }
6240
6241#ifdef FEAT_SESSION
6242 /* 'sessionoptions' */
6243 else if (varp == &p_ssop)
6244 {
6245 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6246 errmsg = e_invarg;
6247 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6248 {
6249 /* Don't allow both "sesdir" and "curdir". */
6250 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6251 errmsg = e_invarg;
6252 }
6253 }
6254 /* 'viewoptions' */
6255 else if (varp == &p_vop)
6256 {
6257 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6258 errmsg = e_invarg;
6259 }
6260#endif
6261
6262 /* 'scrollopt' */
6263#ifdef FEAT_SCROLLBIND
6264 else if (varp == &p_sbo)
6265 {
6266 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6267 errmsg = e_invarg;
6268 }
6269#endif
6270
6271 /* 'ambiwidth' */
6272#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006273 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006274 {
6275 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6276 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006277 else if (set_chars_option(&p_lcs) != NULL)
6278 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6279# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6280 else if (set_chars_option(&p_fcs) != NULL)
6281 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6282# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006283 }
6284#endif
6285
6286 /* 'background' */
6287 else if (varp == &p_bg)
6288 {
6289 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6290 {
6291#ifdef FEAT_EVAL
6292 int dark = (*p_bg == 'd');
6293#endif
6294
6295 init_highlight(FALSE, FALSE);
6296
6297#ifdef FEAT_EVAL
6298 if (dark != (*p_bg == 'd')
6299 && get_var_value((char_u *)"g:colors_name") != NULL)
6300 {
6301 /* The color scheme must have set 'background' back to another
6302 * value, that's not what we want here. Disable the color
6303 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006304 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006305 free_string_option(p_bg);
6306 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6307 check_string_option(&p_bg);
6308 init_highlight(FALSE, FALSE);
6309 }
6310#endif
6311 }
6312 else
6313 errmsg = e_invarg;
6314 }
6315
6316 /* 'wildmode' */
6317 else if (varp == &p_wim)
6318 {
6319 if (check_opt_wim() == FAIL)
6320 errmsg = e_invarg;
6321 }
6322
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006323#ifdef FEAT_CMDL_COMPL
6324 /* 'wildoptions' */
6325 else if (varp == &p_wop)
6326 {
6327 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6328 errmsg = e_invarg;
6329 }
6330#endif
6331
Bram Moolenaar071d4272004-06-13 20:20:40 +00006332#ifdef FEAT_WAK
6333 /* 'winaltkeys' */
6334 else if (varp == &p_wak)
6335 {
6336 if (*p_wak == NUL
6337 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6338 errmsg = e_invarg;
6339# ifdef FEAT_MENU
6340# ifdef FEAT_GUI_MOTIF
6341 else if (gui.in_use)
6342 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6343# else
6344# ifdef FEAT_GUI_GTK
6345 else if (gui.in_use)
6346 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6347# endif
6348# endif
6349# endif
6350 }
6351#endif
6352
6353#ifdef FEAT_AUTOCMD
6354 /* 'eventignore' */
6355 else if (varp == &p_ei)
6356 {
6357 if (check_ei() == FAIL)
6358 errmsg = e_invarg;
6359 }
6360#endif
6361
6362#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006363 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6364 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6365 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006366 {
6367 if (gvarp == &p_fenc)
6368 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006369 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006370 errmsg = e_modifiable;
6371 else if (vim_strchr(*varp, ',') != NULL)
6372 /* No comma allowed in 'fileencoding'; catches confusing it
6373 * with 'fileencodings'. */
6374 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006375 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006376 {
6377# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006378 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006379 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006380# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006381 /* Add 'fileencoding' to the swap file. */
6382 ml_setflags(curbuf);
6383 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006384 }
6385 if (errmsg == NULL)
6386 {
6387 /* canonize the value, so that STRCMP() can be used on it */
6388 p = enc_canonize(*varp);
6389 if (p != NULL)
6390 {
6391 vim_free(*varp);
6392 *varp = p;
6393 }
6394 if (varp == &p_enc)
6395 {
6396 errmsg = mb_init();
6397# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006398 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006399# endif
6400 }
6401 }
6402
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006403# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006404 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6405 {
6406 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6407 if (STRCMP(p_tenc, "utf-8") != 0)
6408 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6409 }
6410# endif
6411
6412 if (errmsg == NULL)
6413 {
6414# ifdef FEAT_KEYMAP
6415 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6416 * (with another encoding). */
6417 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6418 (void)keymap_init();
6419# endif
6420
6421 /* When 'termencoding' is not empty and 'encoding' changes or when
6422 * 'termencoding' changes, need to setup for keyboard input and
6423 * display output conversion. */
6424 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6425 {
6426 convert_setup(&input_conv, p_tenc, p_enc);
6427 convert_setup(&output_conv, p_enc, p_tenc);
6428 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006429
6430# if defined(WIN3264) && defined(FEAT_MBYTE)
6431 /* $HOME may have characters in active code page. */
6432 if (varp == &p_enc)
6433 init_homedir();
6434# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006435 }
6436 }
6437#endif
6438
6439#if defined(FEAT_POSTSCRIPT)
6440 else if (varp == &p_penc)
6441 {
6442 /* Canonize printencoding if VIM standard one */
6443 p = enc_canonize(p_penc);
6444 if (p != NULL)
6445 {
6446 vim_free(p_penc);
6447 p_penc = p;
6448 }
6449 else
6450 {
6451 /* Ensure lower case and '-' for '_' */
6452 for (s = p_penc; *s != NUL; s++)
6453 {
6454 if (*s == '_')
6455 *s = '-';
6456 else
6457 *s = TOLOWER_ASC(*s);
6458 }
6459 }
6460 }
6461#endif
6462
Bram Moolenaar9372a112005-12-06 19:59:18 +00006463#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006464 else if (varp == &p_imak)
6465 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006466 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006467 errmsg = e_invarg;
6468 }
6469#endif
6470
6471#ifdef FEAT_KEYMAP
6472 else if (varp == &curbuf->b_p_keymap)
6473 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006474 if (!valid_filetype(*varp))
6475 errmsg = e_invarg;
6476 else
6477 /* load or unload key mapping tables */
6478 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006479
Bram Moolenaarfab06232009-03-04 03:13:35 +00006480 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006481 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006482 if (*curbuf->b_p_keymap != NUL)
6483 {
6484 /* Installed a new keymap, switch on using it. */
6485 curbuf->b_p_iminsert = B_IMODE_LMAP;
6486 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6487 curbuf->b_p_imsearch = B_IMODE_LMAP;
6488 }
6489 else
6490 {
6491 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6492 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6493 curbuf->b_p_iminsert = B_IMODE_NONE;
6494 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6495 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6496 }
6497 if ((opt_flags & OPT_LOCAL) == 0)
6498 {
6499 set_iminsert_global();
6500 set_imsearch_global();
6501 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006502# ifdef FEAT_WINDOWS
6503 status_redraw_curbuf();
6504# endif
6505 }
6506 }
6507#endif
6508
6509 /* 'fileformat' */
6510 else if (gvarp == &p_ff)
6511 {
6512 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6513 errmsg = e_modifiable;
6514 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6515 errmsg = e_invarg;
6516 else
6517 {
6518 /* may also change 'textmode' */
6519 if (get_fileformat(curbuf) == EOL_DOS)
6520 curbuf->b_p_tx = TRUE;
6521 else
6522 curbuf->b_p_tx = FALSE;
6523#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006524 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006525#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006526 /* update flag in swap file */
6527 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006528 /* Redraw needed when switching to/from "mac": a CR in the text
6529 * will be displayed differently. */
6530 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6531 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006532 }
6533 }
6534
6535 /* 'fileformats' */
6536 else if (varp == &p_ffs)
6537 {
6538 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6539 errmsg = e_invarg;
6540 else
6541 {
6542 /* also change 'textauto' */
6543 if (*p_ffs == NUL)
6544 p_ta = FALSE;
6545 else
6546 p_ta = TRUE;
6547 }
6548 }
6549
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006550#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006551 /* 'cryptkey' */
6552 else if (gvarp == &p_key)
6553 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006554# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006555 /* Make sure the ":set" command doesn't show the new value in the
6556 * history. */
6557 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006558# endif
6559 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6560 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006561 ml_set_crypt_key(curbuf, oldval,
6562 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006563 }
6564
6565 else if (gvarp == &p_cm)
6566 {
6567 if (opt_flags & OPT_LOCAL)
6568 p = curbuf->b_p_cm;
6569 else
6570 p = p_cm;
6571 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6572 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006573 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006574 errmsg = e_invarg;
6575 else
6576 {
6577 /* When setting the global value to empty, make it "zip". */
6578 if (*p_cm == NUL)
6579 {
6580 if (new_value_alloced)
6581 free_string_option(p_cm);
6582 p_cm = vim_strsave((char_u *)"zip");
6583 new_value_alloced = TRUE;
6584 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006585 /* When using ":set cm=name" the local value is going to be empty.
6586 * Do that here, otherwise the crypt functions will still use the
6587 * local value. */
6588 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6589 {
6590 free_string_option(curbuf->b_p_cm);
6591 curbuf->b_p_cm = empty_option;
6592 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006593
6594 /* Need to update the swapfile when the effective method changed.
6595 * Set "s" to the effective old value, "p" to the effective new
6596 * method and compare. */
6597 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6598 s = p_cm; /* was previously using the global value */
6599 else
6600 s = oldval;
6601 if (*curbuf->b_p_cm == NUL)
6602 p = p_cm; /* is now using the global value */
6603 else
6604 p = curbuf->b_p_cm;
6605 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006606 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006607
6608 /* If the global value changes need to update the swapfile for all
6609 * buffers using that value. */
6610 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6611 {
6612 buf_T *buf;
6613
Bram Moolenaar29323592016-07-24 22:04:11 +02006614 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006615 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006616 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006617 }
6618 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006619 }
6620#endif
6621
6622 /* 'matchpairs' */
6623 else if (gvarp == &p_mps)
6624 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006625#ifdef FEAT_MBYTE
6626 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006627 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006628 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006629 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006630 int x2 = -1;
6631 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006632
6633 if (*p != NUL)
6634 p += mb_ptr2len(p);
6635 if (*p != NUL)
6636 x2 = *p++;
6637 if (*p != NUL)
6638 {
6639 x3 = mb_ptr2char(p);
6640 p += mb_ptr2len(p);
6641 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006642 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006643 {
6644 errmsg = e_invarg;
6645 break;
6646 }
6647 if (*p == NUL)
6648 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006649 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006650 }
6651 else
6652#endif
6653 {
6654 /* Check for "x:y,x:y" */
6655 for (p = *varp; *p != NUL; p += 4)
6656 {
6657 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6658 {
6659 errmsg = e_invarg;
6660 break;
6661 }
6662 if (p[3] == NUL)
6663 break;
6664 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006665 }
6666 }
6667
6668#ifdef FEAT_COMMENTS
6669 /* 'comments' */
6670 else if (gvarp == &p_com)
6671 {
6672 for (s = *varp; *s; )
6673 {
6674 while (*s && *s != ':')
6675 {
6676 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6677 && !VIM_ISDIGIT(*s) && *s != '-')
6678 {
6679 errmsg = illegal_char(errbuf, *s);
6680 break;
6681 }
6682 ++s;
6683 }
6684 if (*s++ == NUL)
6685 errmsg = (char_u *)N_("E524: Missing colon");
6686 else if (*s == ',' || *s == NUL)
6687 errmsg = (char_u *)N_("E525: Zero length string");
6688 if (errmsg != NULL)
6689 break;
6690 while (*s && *s != ',')
6691 {
6692 if (*s == '\\' && s[1] != NUL)
6693 ++s;
6694 ++s;
6695 }
6696 s = skip_to_option_part(s);
6697 }
6698 }
6699#endif
6700
6701 /* 'listchars' */
6702 else if (varp == &p_lcs)
6703 {
6704 errmsg = set_chars_option(varp);
6705 }
6706
6707#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6708 /* 'fillchars' */
6709 else if (varp == &p_fcs)
6710 {
6711 errmsg = set_chars_option(varp);
6712 }
6713#endif
6714
6715#ifdef FEAT_CMDWIN
6716 /* 'cedit' */
6717 else if (varp == &p_cedit)
6718 {
6719 errmsg = check_cedit();
6720 }
6721#endif
6722
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006723 /* 'verbosefile' */
6724 else if (varp == &p_vfile)
6725 {
6726 verbose_stop();
6727 if (*p_vfile != NUL && verbose_open() == FAIL)
6728 errmsg = e_invarg;
6729 }
6730
Bram Moolenaar071d4272004-06-13 20:20:40 +00006731#ifdef FEAT_VIMINFO
6732 /* 'viminfo' */
6733 else if (varp == &p_viminfo)
6734 {
6735 for (s = p_viminfo; *s;)
6736 {
6737 /* Check it's a valid character */
6738 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6739 {
6740 errmsg = illegal_char(errbuf, *s);
6741 break;
6742 }
6743 if (*s == 'n') /* name is always last one */
6744 {
6745 break;
6746 }
6747 else if (*s == 'r') /* skip until next ',' */
6748 {
6749 while (*++s && *s != ',')
6750 ;
6751 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006752 else if (*s == '%')
6753 {
6754 /* optional number */
6755 while (vim_isdigit(*++s))
6756 ;
6757 }
6758 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006759 ++s; /* no extra chars */
6760 else /* must have a number */
6761 {
6762 while (vim_isdigit(*++s))
6763 ;
6764
6765 if (!VIM_ISDIGIT(*(s - 1)))
6766 {
6767 if (errbuf != NULL)
6768 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006769 sprintf((char *)errbuf,
6770 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006771 transchar_byte(*(s - 1)));
6772 errmsg = errbuf;
6773 }
6774 else
6775 errmsg = (char_u *)"";
6776 break;
6777 }
6778 }
6779 if (*s == ',')
6780 ++s;
6781 else if (*s)
6782 {
6783 if (errbuf != NULL)
6784 errmsg = (char_u *)N_("E527: Missing comma");
6785 else
6786 errmsg = (char_u *)"";
6787 break;
6788 }
6789 }
6790 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6791 errmsg = (char_u *)N_("E528: Must specify a ' value");
6792 }
6793#endif /* FEAT_VIMINFO */
6794
6795 /* terminal options */
6796 else if (istermoption(&options[opt_idx]) && full_screen)
6797 {
6798 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6799 if (varp == &T_CCO)
6800 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006801 int colors = atoi((char *)T_CCO);
6802
6803 /* Only reinitialize colors if t_Co value has really changed to
6804 * avoid expensive reload of colorscheme if t_Co is set to the
6805 * same value multiple times. */
6806 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006807 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006808 t_colors = colors;
6809 if (t_colors <= 1)
6810 {
6811 if (new_value_alloced)
6812 vim_free(T_CCO);
6813 T_CCO = empty_option;
6814 }
6815 /* We now have a different color setup, initialize it again. */
6816 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006817 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006818 }
6819 ttest(FALSE);
6820 if (varp == &T_ME)
6821 {
6822 out_str(T_ME);
6823 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006824#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006825 /* Since t_me has been set, this probably means that the user
6826 * wants to use this as default colors. Need to reset default
6827 * background/foreground colors. */
6828 mch_set_normal_colors();
6829#endif
6830 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006831 if (varp == &T_BE && termcap_active)
6832 {
6833 if (*T_BE == NUL)
6834 /* When clearing t_BE we assume the user no longer wants
6835 * bracketed paste, thus disable it by writing t_BD. */
6836 out_str(T_BD);
6837 else
6838 out_str(T_BE);
6839 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006840 }
6841
6842#ifdef FEAT_LINEBREAK
6843 /* 'showbreak' */
6844 else if (varp == &p_sbr)
6845 {
6846 for (s = p_sbr; *s; )
6847 {
6848 if (ptr2cells(s) != 1)
6849 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006850 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006851 }
6852 }
6853#endif
6854
6855#ifdef FEAT_GUI
6856 /* 'guifont' */
6857 else if (varp == &p_guifont)
6858 {
6859 if (gui.in_use)
6860 {
6861 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006862# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006863 /*
6864 * Put up a font dialog and let the user select a new value.
6865 * If this is cancelled go back to the old value but don't
6866 * give an error message.
6867 */
6868 if (STRCMP(p, "*") == 0)
6869 {
6870 p = gui_mch_font_dialog(oldval);
6871
6872 if (new_value_alloced)
6873 free_string_option(p_guifont);
6874
6875 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6876 new_value_alloced = TRUE;
6877 }
6878# endif
6879 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6880 {
6881# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6882 if (STRCMP(p_guifont, "*") == 0)
6883 {
6884 /* Dialog was cancelled: Keep the old value without giving
6885 * an error message. */
6886 if (new_value_alloced)
6887 free_string_option(p_guifont);
6888 p_guifont = vim_strsave(oldval);
6889 new_value_alloced = TRUE;
6890 }
6891 else
6892# endif
6893 errmsg = (char_u *)N_("E596: Invalid font(s)");
6894 }
6895 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006896 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006897 }
6898# ifdef FEAT_XFONTSET
6899 else if (varp == &p_guifontset)
6900 {
6901 if (STRCMP(p_guifontset, "*") == 0)
6902 errmsg = (char_u *)N_("E597: can't select fontset");
6903 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6904 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006905 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006906 }
6907# endif
6908# ifdef FEAT_MBYTE
6909 else if (varp == &p_guifontwide)
6910 {
6911 if (STRCMP(p_guifontwide, "*") == 0)
6912 errmsg = (char_u *)N_("E533: can't select wide font");
6913 else if (gui_get_wide_font() == FAIL)
6914 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006915 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006916 }
6917# endif
6918#endif
6919
6920#ifdef CURSOR_SHAPE
6921 /* 'guicursor' */
6922 else if (varp == &p_guicursor)
6923 errmsg = parse_shape_opt(SHAPE_CURSOR);
6924#endif
6925
6926#ifdef FEAT_MOUSESHAPE
6927 /* 'mouseshape' */
6928 else if (varp == &p_mouseshape)
6929 {
6930 errmsg = parse_shape_opt(SHAPE_MOUSE);
6931 update_mouseshape(-1);
6932 }
6933#endif
6934
6935#ifdef FEAT_PRINTER
6936 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006937 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006938# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006939 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006940 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006941# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006942#endif
6943
6944#ifdef FEAT_LANGMAP
6945 /* 'langmap' */
6946 else if (varp == &p_langmap)
6947 langmap_set();
6948#endif
6949
6950#ifdef FEAT_LINEBREAK
6951 /* 'breakat' */
6952 else if (varp == &p_breakat)
6953 fill_breakat_flags();
6954#endif
6955
6956#ifdef FEAT_TITLE
6957 /* 'titlestring' and 'iconstring' */
6958 else if (varp == &p_titlestring || varp == &p_iconstring)
6959 {
6960# ifdef FEAT_STL_OPT
6961 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6962
6963 /* NULL => statusline syntax */
6964 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6965 stl_syntax |= flagval;
6966 else
6967 stl_syntax &= ~flagval;
6968# endif
6969 did_set_title(varp == &p_iconstring);
6970
6971 }
6972#endif
6973
6974#ifdef FEAT_GUI
6975 /* 'guioptions' */
6976 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006977 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006978 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006979 redraw_gui_only = TRUE;
6980 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006981#endif
6982
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006983#if defined(FEAT_GUI_TABLINE)
6984 /* 'guitablabel' */
6985 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006986 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006987 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006988 redraw_gui_only = TRUE;
6989 }
6990 /* 'guitabtooltip' */
6991 else if (varp == &p_gtt)
6992 {
6993 redraw_gui_only = TRUE;
6994 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006995#endif
6996
Bram Moolenaar071d4272004-06-13 20:20:40 +00006997#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6998 /* 'ttymouse' */
6999 else if (varp == &p_ttym)
7000 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007001 /* Switch the mouse off before changing the escape sequences used for
7002 * that. */
7003 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007004 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
7005 errmsg = e_invarg;
7006 else
7007 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00007008 if (termcap_active)
7009 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007010 }
7011#endif
7012
Bram Moolenaar071d4272004-06-13 20:20:40 +00007013 /* 'selection' */
7014 else if (varp == &p_sel)
7015 {
7016 if (*p_sel == NUL
7017 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
7018 errmsg = e_invarg;
7019 }
7020
7021 /* 'selectmode' */
7022 else if (varp == &p_slm)
7023 {
7024 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
7025 errmsg = e_invarg;
7026 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007027
7028#ifdef FEAT_BROWSE
7029 /* 'browsedir' */
7030 else if (varp == &p_bsdir)
7031 {
7032 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7033 && !mch_isdir(p_bsdir))
7034 errmsg = e_invarg;
7035 }
7036#endif
7037
Bram Moolenaar071d4272004-06-13 20:20:40 +00007038 /* 'keymodel' */
7039 else if (varp == &p_km)
7040 {
7041 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7042 errmsg = e_invarg;
7043 else
7044 {
7045 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7046 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7047 }
7048 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007049
7050 /* 'mousemodel' */
7051 else if (varp == &p_mousem)
7052 {
7053 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7054 errmsg = e_invarg;
7055#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7056 else if (*p_mousem != *oldval)
7057 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7058 * to create or delete the popup menus. */
7059 gui_motif_update_mousemodel(root_menu);
7060#endif
7061 }
7062
7063 /* 'switchbuf' */
7064 else if (varp == &p_swb)
7065 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007066 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007067 errmsg = e_invarg;
7068 }
7069
7070 /* 'debug' */
7071 else if (varp == &p_debug)
7072 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007073 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007074 errmsg = e_invarg;
7075 }
7076
7077 /* 'display' */
7078 else if (varp == &p_dy)
7079 {
7080 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7081 errmsg = e_invarg;
7082 else
7083 (void)init_chartab();
7084
7085 }
7086
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007087#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007088 /* 'eadirection' */
7089 else if (varp == &p_ead)
7090 {
7091 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7092 errmsg = e_invarg;
7093 }
7094#endif
7095
7096#ifdef FEAT_CLIPBOARD
7097 /* 'clipboard' */
7098 else if (varp == &p_cb)
7099 errmsg = check_clipboard_option();
7100#endif
7101
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007102#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007103 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7104 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007105 else if (varp == &(curwin->w_s->b_p_spl)
7106 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007107 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007108 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007109 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007110 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007111 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007112 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007113 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007114 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007115 /* 'spellsuggest' */
7116 else if (varp == &p_sps)
7117 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007118 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007119 errmsg = e_invarg;
7120 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007121 /* 'mkspellmem' */
7122 else if (varp == &p_msm)
7123 {
7124 if (spell_check_msm() != OK)
7125 errmsg = e_invarg;
7126 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007127#endif
7128
Bram Moolenaar071d4272004-06-13 20:20:40 +00007129 /* When 'bufhidden' is set, check for valid value. */
7130 else if (gvarp == &p_bh)
7131 {
7132 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7133 errmsg = e_invarg;
7134 }
7135
7136 /* When 'buftype' is set, check for valid value. */
7137 else if (gvarp == &p_bt)
7138 {
7139 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7140 errmsg = e_invarg;
7141 else
7142 {
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007143#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007144 if (curwin->w_status_height)
7145 {
7146 curwin->w_redr_status = TRUE;
7147 redraw_later(VALID);
7148 }
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007149#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007150 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007151#ifdef FEAT_TITLE
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007152 redraw_titles();
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007153#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007154 }
7155 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007156
7157#ifdef FEAT_STL_OPT
7158 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007159 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007160 {
7161 int wid;
7162
7163 if (varp == &p_ruf) /* reset ru_wid first */
7164 ru_wid = 0;
7165 s = *varp;
7166 if (varp == &p_ruf && *s == '%')
7167 {
7168 /* set ru_wid if 'ruf' starts with "%99(" */
7169 if (*++s == '-') /* ignore a '-' */
7170 s++;
7171 wid = getdigits(&s);
7172 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7173 ru_wid = wid;
7174 else
7175 errmsg = check_stl_option(p_ruf);
7176 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007177 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007178 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007179 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007180 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007181 comp_col();
7182 }
7183#endif
7184
7185#ifdef FEAT_INS_EXPAND
7186 /* check if it is a valid value for 'complete' -- Acevedo */
7187 else if (gvarp == &p_cpt)
7188 {
7189 for (s = *varp; *s;)
7190 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007191 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007192 s++;
7193 if (!*s)
7194 break;
7195 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7196 {
7197 errmsg = illegal_char(errbuf, *s);
7198 break;
7199 }
7200 if (*++s != NUL && *s != ',' && *s != ' ')
7201 {
7202 if (s[-1] == 'k' || s[-1] == 's')
7203 {
7204 /* skip optional filename after 'k' and 's' */
7205 while (*s && *s != ',' && *s != ' ')
7206 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007207 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007208 ++s;
7209 ++s;
7210 }
7211 }
7212 else
7213 {
7214 if (errbuf != NULL)
7215 {
7216 sprintf((char *)errbuf,
7217 _("E535: Illegal character after <%c>"),
7218 *--s);
7219 errmsg = errbuf;
7220 }
7221 else
7222 errmsg = (char_u *)"";
7223 break;
7224 }
7225 }
7226 }
7227 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007228
7229 /* 'completeopt' */
7230 else if (varp == &p_cot)
7231 {
7232 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7233 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007234 else
7235 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007236 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007237#endif /* FEAT_INS_EXPAND */
7238
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007239#ifdef FEAT_SIGNS
7240 /* 'signcolumn' */
7241 else if (varp == &curwin->w_p_scl)
7242 {
7243 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7244 errmsg = e_invarg;
7245 }
7246#endif
7247
Bram Moolenaar071d4272004-06-13 20:20:40 +00007248
7249#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007250 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007251 else if (varp == &p_toolbar)
7252 {
7253 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7254 &toolbar_flags, TRUE) != OK)
7255 errmsg = e_invarg;
7256 else
7257 {
7258 out_flush();
7259 gui_mch_show_toolbar((toolbar_flags &
7260 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7261 }
7262 }
7263#endif
7264
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007265#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007266 /* 'toolbariconsize': GTK+ 2 only */
7267 else if (varp == &p_tbis)
7268 {
7269 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7270 errmsg = e_invarg;
7271 else
7272 {
7273 out_flush();
7274 gui_mch_show_toolbar((toolbar_flags &
7275 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7276 }
7277 }
7278#endif
7279
7280 /* 'pastetoggle': translate key codes like in a mapping */
7281 else if (varp == &p_pt)
7282 {
7283 if (*p_pt)
7284 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007285 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007286 if (p != NULL)
7287 {
7288 if (new_value_alloced)
7289 free_string_option(p_pt);
7290 p_pt = p;
7291 new_value_alloced = TRUE;
7292 }
7293 }
7294 }
7295
7296 /* 'backspace' */
7297 else if (varp == &p_bs)
7298 {
7299 if (VIM_ISDIGIT(*p_bs))
7300 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007301 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007302 errmsg = e_invarg;
7303 }
7304 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7305 errmsg = e_invarg;
7306 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007307 else if (varp == &p_bo)
7308 {
7309 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7310 errmsg = e_invarg;
7311 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007312
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007313 /* 'tagcase' */
7314 else if (gvarp == &p_tc)
7315 {
7316 unsigned int *flags;
7317
7318 if (opt_flags & OPT_LOCAL)
7319 {
7320 p = curbuf->b_p_tc;
7321 flags = &curbuf->b_tc_flags;
7322 }
7323 else
7324 {
7325 p = p_tc;
7326 flags = &tc_flags;
7327 }
7328
7329 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7330 /* make the local value empty: use the global value */
7331 *flags = 0;
7332 else if (*p == NUL
7333 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7334 errmsg = e_invarg;
7335 }
7336
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007337#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007338 /* 'casemap' */
7339 else if (varp == &p_cmp)
7340 {
7341 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7342 errmsg = e_invarg;
7343 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007344#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007345
7346#ifdef FEAT_DIFF
7347 /* 'diffopt' */
7348 else if (varp == &p_dip)
7349 {
7350 if (diffopt_changed() == FAIL)
7351 errmsg = e_invarg;
7352 }
7353#endif
7354
7355#ifdef FEAT_FOLDING
7356 /* 'foldmethod' */
7357 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7358 {
7359 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7360 || *curwin->w_p_fdm == NUL)
7361 errmsg = e_invarg;
7362 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007363 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007364 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007365 if (foldmethodIsDiff(curwin))
7366 newFoldLevel();
7367 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007368 }
7369# ifdef FEAT_EVAL
7370 /* 'foldexpr' */
7371 else if (varp == &curwin->w_p_fde)
7372 {
7373 if (foldmethodIsExpr(curwin))
7374 foldUpdateAll(curwin);
7375 }
7376# endif
7377 /* 'foldmarker' */
7378 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7379 {
7380 p = vim_strchr(*varp, ',');
7381 if (p == NULL)
7382 errmsg = (char_u *)N_("E536: comma required");
7383 else if (p == *varp || p[1] == NUL)
7384 errmsg = e_invarg;
7385 else if (foldmethodIsMarker(curwin))
7386 foldUpdateAll(curwin);
7387 }
7388 /* 'commentstring' */
7389 else if (gvarp == &p_cms)
7390 {
7391 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7392 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7393 }
7394 /* 'foldopen' */
7395 else if (varp == &p_fdo)
7396 {
7397 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7398 errmsg = e_invarg;
7399 }
7400 /* 'foldclose' */
7401 else if (varp == &p_fcl)
7402 {
7403 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7404 errmsg = e_invarg;
7405 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007406 /* 'foldignore' */
7407 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7408 {
7409 if (foldmethodIsIndent(curwin))
7410 foldUpdateAll(curwin);
7411 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007412#endif
7413
7414#ifdef FEAT_VIRTUALEDIT
7415 /* 'virtualedit' */
7416 else if (varp == &p_ve)
7417 {
7418 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7419 errmsg = e_invarg;
7420 else if (STRCMP(p_ve, oldval) != 0)
7421 {
7422 /* Recompute cursor position in case the new 've' setting
7423 * changes something. */
7424 validate_virtcol();
7425 coladvance(curwin->w_virtcol);
7426 }
7427 }
7428#endif
7429
7430#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7431 else if (varp == &p_csqf)
7432 {
7433 if (p_csqf != NULL)
7434 {
7435 p = p_csqf;
7436 while (*p != NUL)
7437 {
7438 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7439 || p[1] == NUL
7440 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7441 || (p[2] != NUL && p[2] != ','))
7442 {
7443 errmsg = e_invarg;
7444 break;
7445 }
7446 else if (p[2] == NUL)
7447 break;
7448 else
7449 p += 3;
7450 }
7451 }
7452 }
7453#endif
7454
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007455#ifdef FEAT_CINDENT
7456 /* 'cinoptions' */
7457 else if (gvarp == &p_cino)
7458 {
7459 /* TODO: recognize errors */
7460 parse_cino(curbuf);
7461 }
7462#endif
7463
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007464#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007465 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007466 else if (varp == &p_rop && gui.in_use)
7467 {
7468 if (!gui_mch_set_rendering_options(p_rop))
7469 errmsg = e_invarg;
7470 }
7471#endif
7472
Bram Moolenaard0b51382016-11-04 15:23:45 +01007473#ifdef FEAT_AUTOCMD
7474 else if (gvarp == &p_ft)
7475 {
7476 if (!valid_filetype(*varp))
7477 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007478 else
7479 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007480 }
7481#endif
7482
7483#ifdef FEAT_SYN_HL
7484 else if (gvarp == &p_syn)
7485 {
7486 if (!valid_filetype(*varp))
7487 errmsg = e_invarg;
7488 }
7489#endif
7490
Bram Moolenaar825680f2017-07-22 17:04:02 +02007491#ifdef FEAT_TERMINAL
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007492 /* 'termkey' */
Bram Moolenaarc4f43bc2017-07-24 20:03:01 +02007493 else if (varp == &curwin->w_p_tk)
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007494 {
7495 if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
7496 errmsg = e_invarg;
7497 }
Bram Moolenaar825680f2017-07-22 17:04:02 +02007498 /* 'termsize' */
7499 else if (varp == &curwin->w_p_tms)
7500 {
7501 if (*curwin->w_p_tms != NUL)
7502 {
7503 p = skipdigits(curwin->w_p_tms);
7504 if (p == curwin->w_p_tms || *p != 'x' || *skipdigits(p + 1) != NUL)
7505 errmsg = e_invarg;
7506 }
7507 }
7508#endif
7509
Bram Moolenaar071d4272004-06-13 20:20:40 +00007510 /* Options that are a list of flags. */
7511 else
7512 {
7513 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007514 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007515 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007516 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007517 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007518 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007519 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007520 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007521 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007522#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007523 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007524 p = (char_u *)COCU_ALL;
7525#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007526 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007527 {
7528#ifdef FEAT_MOUSE
7529 p = (char_u *)MOUSE_ALL;
7530#else
7531 if (*p_mouse != NUL)
7532 errmsg = (char_u *)N_("E538: No mouse support");
7533#endif
7534 }
7535#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007536 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007537 p = (char_u *)GO_ALL;
7538#endif
7539 if (p != NULL)
7540 {
7541 for (s = *varp; *s; ++s)
7542 if (vim_strchr(p, *s) == NULL)
7543 {
7544 errmsg = illegal_char(errbuf, *s);
7545 break;
7546 }
7547 }
7548 }
7549
7550 /*
7551 * If error detected, restore the previous value.
7552 */
7553 if (errmsg != NULL)
7554 {
7555 if (new_value_alloced)
7556 free_string_option(*varp);
7557 *varp = oldval;
7558 /*
7559 * When resetting some values, need to act on it.
7560 */
7561 if (did_chartab)
7562 (void)init_chartab();
7563 if (varp == &p_hl)
7564 (void)highlight_changed();
7565 }
7566 else
7567 {
7568#ifdef FEAT_EVAL
7569 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007570 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007571#endif
7572 /*
7573 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007574 * Use "free_oldval", because recursiveness may change the flags under
7575 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007576 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007577 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007578 free_string_option(oldval);
7579 if (new_value_alloced)
7580 options[opt_idx].flags |= P_ALLOCED;
7581 else
7582 options[opt_idx].flags &= ~P_ALLOCED;
7583
7584 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007585 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007586 {
7587 /* global option with local value set to use global value; free
7588 * the local value and make it empty */
7589 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7590 free_string_option(*(char_u **)p);
7591 *(char_u **)p = empty_option;
7592 }
7593
7594 /* May set global value for local option. */
7595 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7596 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007597
7598#ifdef FEAT_AUTOCMD
7599 /*
7600 * Trigger the autocommand only after setting the flags.
7601 */
7602# ifdef FEAT_SYN_HL
7603 /* When 'syntax' is set, load the syntax of that name */
7604 if (varp == &(curbuf->b_p_syn))
7605 {
7606 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7607 curbuf->b_fname, TRUE, curbuf);
7608 }
7609# endif
7610 else if (varp == &(curbuf->b_p_ft))
7611 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007612 /* 'filetype' is set, trigger the FileType autocommand.
7613 * Skip this when called from a modeline and the filetype was
7614 * already set to this value. */
7615 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7616 {
7617 did_filetype = TRUE;
7618 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007619 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar163095f2017-07-09 15:41:53 +02007620 /* Just in case the old "curbuf" is now invalid. */
7621 if (varp != &(curbuf->b_p_ft))
7622 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007623 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007624 }
7625#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007626#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007627 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007628 {
7629 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007630 char_u *q = curwin->w_s->b_p_spl;
7631
7632 /* Skip the first name if it is "cjk". */
7633 if (STRNCMP(q, "cjk,", 4) == 0)
7634 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007635
7636 /*
7637 * Source the spell/LANG.vim in 'runtimepath'.
7638 * They could set 'spellcapcheck' depending on the language.
7639 * Use the first name in 'spelllang' up to '_region' or
7640 * '.encoding'.
7641 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007642 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007643 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7644 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007645 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007646 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007647 }
7648#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007649 }
7650
7651#ifdef FEAT_MOUSE
7652 if (varp == &p_mouse)
7653 {
7654# ifdef FEAT_MOUSE_TTY
7655 if (*p_mouse == NUL)
7656 mch_setmouse(FALSE); /* switch mouse off */
7657 else
7658# endif
7659 setmouse(); /* in case 'mouse' changed */
7660 }
7661#endif
7662
Bram Moolenaar913077c2012-03-28 19:59:04 +02007663 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007664 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007665 curwin->w_set_curswant = TRUE;
7666
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007667#ifdef FEAT_GUI
7668 /* check redraw when it's not a GUI option or the GUI is active. */
7669 if (!redraw_gui_only || gui.in_use)
7670#endif
7671 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007672
7673 return errmsg;
7674}
7675
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007676#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007677/*
7678 * Simple int comparison function for use with qsort()
7679 */
7680 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007681int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007682{
7683 return *(const int *)a - *(const int *)b;
7684}
7685
7686/*
7687 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7688 * Returns error message, NULL if it's OK.
7689 */
7690 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007691check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007692{
7693 char_u *s;
7694 int col;
7695 int count = 0;
7696 int color_cols[256];
7697 int i;
7698 int j = 0;
7699
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007700 if (wp->w_buffer == NULL)
7701 return NULL; /* buffer was closed */
7702
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007703 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007704 {
7705 if (*s == '-' || *s == '+')
7706 {
7707 /* -N and +N: add to 'textwidth' */
7708 col = (*s == '-') ? -1 : 1;
7709 ++s;
7710 if (!VIM_ISDIGIT(*s))
7711 return e_invarg;
7712 col = col * getdigits(&s);
7713 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007714 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007715 col += wp->w_buffer->b_p_tw;
7716 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007717 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007718 }
7719 else if (VIM_ISDIGIT(*s))
7720 col = getdigits(&s);
7721 else
7722 return e_invarg;
7723 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007724skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007725 if (*s == NUL)
7726 break;
7727 if (*s != ',')
7728 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007729 if (*++s == NUL)
7730 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007731 }
7732
7733 vim_free(wp->w_p_cc_cols);
7734 if (count == 0)
7735 wp->w_p_cc_cols = NULL;
7736 else
7737 {
7738 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7739 if (wp->w_p_cc_cols != NULL)
7740 {
7741 /* sort the columns for faster usage on screen redraw inside
7742 * win_line() */
7743 qsort(color_cols, count, sizeof(int), int_cmp);
7744
7745 for (i = 0; i < count; ++i)
7746 /* skip duplicates */
7747 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7748 wp->w_p_cc_cols[j++] = color_cols[i];
7749 wp->w_p_cc_cols[j] = -1; /* end marker */
7750 }
7751 }
7752
7753 return NULL; /* no error */
7754}
7755#endif
7756
Bram Moolenaar071d4272004-06-13 20:20:40 +00007757/*
7758 * Handle setting 'listchars' or 'fillchars'.
7759 * Returns error message, NULL if it's OK.
7760 */
7761 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007762set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007763{
7764 int round, i, len, entries;
7765 char_u *p, *s;
7766 int c1, c2 = 0;
7767 struct charstab
7768 {
7769 int *cp;
7770 char *name;
7771 };
7772#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7773 static struct charstab filltab[] =
7774 {
7775 {&fill_stl, "stl"},
7776 {&fill_stlnc, "stlnc"},
7777 {&fill_vert, "vert"},
7778 {&fill_fold, "fold"},
7779 {&fill_diff, "diff"},
7780 };
7781#endif
7782 static struct charstab lcstab[] =
7783 {
7784 {&lcs_eol, "eol"},
7785 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007786 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007787 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007788 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007789 {&lcs_tab2, "tab"},
7790 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007791#ifdef FEAT_CONCEAL
7792 {&lcs_conceal, "conceal"},
7793#else
7794 {NULL, "conceal"},
7795#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007796 };
7797 struct charstab *tab;
7798
7799#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7800 if (varp == &p_lcs)
7801#endif
7802 {
7803 tab = lcstab;
7804 entries = sizeof(lcstab) / sizeof(struct charstab);
7805 }
7806#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7807 else
7808 {
7809 tab = filltab;
7810 entries = sizeof(filltab) / sizeof(struct charstab);
7811 }
7812#endif
7813
7814 /* first round: check for valid value, second round: assign values */
7815 for (round = 0; round <= 1; ++round)
7816 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007817 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818 {
7819 /* After checking that the value is valid: set defaults: space for
7820 * 'fillchars', NUL for 'listchars' */
7821 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007822 if (tab[i].cp != NULL)
7823 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007824 if (varp == &p_lcs)
7825 lcs_tab1 = NUL;
7826#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7827 else
7828 fill_diff = '-';
7829#endif
7830 }
7831 p = *varp;
7832 while (*p)
7833 {
7834 for (i = 0; i < entries; ++i)
7835 {
7836 len = (int)STRLEN(tab[i].name);
7837 if (STRNCMP(p, tab[i].name, len) == 0
7838 && p[len] == ':'
7839 && p[len + 1] != NUL)
7840 {
7841 s = p + len + 1;
7842#ifdef FEAT_MBYTE
7843 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007844 if (mb_char2cells(c1) > 1)
7845 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007846#else
7847 c1 = *s++;
7848#endif
7849 if (tab[i].cp == &lcs_tab2)
7850 {
7851 if (*s == NUL)
7852 continue;
7853#ifdef FEAT_MBYTE
7854 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007855 if (mb_char2cells(c2) > 1)
7856 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007857#else
7858 c2 = *s++;
7859#endif
7860 }
7861 if (*s == ',' || *s == NUL)
7862 {
7863 if (round)
7864 {
7865 if (tab[i].cp == &lcs_tab2)
7866 {
7867 lcs_tab1 = c1;
7868 lcs_tab2 = c2;
7869 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007870 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007871 *(tab[i].cp) = c1;
7872
7873 }
7874 p = s;
7875 break;
7876 }
7877 }
7878 }
7879
7880 if (i == entries)
7881 return e_invarg;
7882 if (*p == ',')
7883 ++p;
7884 }
7885 }
7886
7887 return NULL; /* no error */
7888}
7889
7890#ifdef FEAT_STL_OPT
7891/*
7892 * Check validity of options with the 'statusline' format.
7893 * Return error message or NULL.
7894 */
7895 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007896check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007897{
7898 int itemcnt = 0;
7899 int groupdepth = 0;
7900 static char_u errbuf[80];
7901
7902 while (*s && itemcnt < STL_MAX_ITEM)
7903 {
7904 /* Check for valid keys after % sequences */
7905 while (*s && *s != '%')
7906 s++;
7907 if (!*s)
7908 break;
7909 s++;
7910 if (*s != '%' && *s != ')')
7911 ++itemcnt;
7912 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7913 {
7914 s++;
7915 continue;
7916 }
7917 if (*s == ')')
7918 {
7919 s++;
7920 if (--groupdepth < 0)
7921 break;
7922 continue;
7923 }
7924 if (*s == '-')
7925 s++;
7926 while (VIM_ISDIGIT(*s))
7927 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007928 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007929 continue;
7930 if (*s == '.')
7931 {
7932 s++;
7933 while (*s && VIM_ISDIGIT(*s))
7934 s++;
7935 }
7936 if (*s == '(')
7937 {
7938 groupdepth++;
7939 continue;
7940 }
7941 if (vim_strchr(STL_ALL, *s) == NULL)
7942 {
7943 return illegal_char(errbuf, *s);
7944 }
7945 if (*s == '{')
7946 {
7947 s++;
7948 while (*s != '}' && *s)
7949 s++;
7950 if (*s != '}')
7951 return (char_u *)N_("E540: Unclosed expression sequence");
7952 }
7953 }
7954 if (itemcnt >= STL_MAX_ITEM)
7955 return (char_u *)N_("E541: too many items");
7956 if (groupdepth != 0)
7957 return (char_u *)N_("E542: unbalanced groups");
7958 return NULL;
7959}
7960#endif
7961
7962#ifdef FEAT_CLIPBOARD
7963/*
7964 * Extract the items in the 'clipboard' option and set global values.
7965 */
7966 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007967check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007968{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007969 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007970 int new_autoselect_star = FALSE;
7971 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007972 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007973 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007974 regprog_T *new_exclude_prog = NULL;
7975 char_u *errmsg = NULL;
7976 char_u *p;
7977
7978 for (p = p_cb; *p != NUL; )
7979 {
7980 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7981 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007982 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007983 p += 7;
7984 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007985 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007986 && (p[11] == ',' || p[11] == NUL))
7987 {
7988 new_unnamed |= CLIP_UNNAMED_PLUS;
7989 p += 11;
7990 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007991 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007992 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007993 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007994 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007995 p += 10;
7996 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007997 else if (STRNCMP(p, "autoselectplus", 14) == 0
7998 && (p[14] == ',' || p[14] == NUL))
7999 {
8000 new_autoselect_plus = TRUE;
8001 p += 14;
8002 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008003 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02008004 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00008005 {
8006 new_autoselectml = TRUE;
8007 p += 12;
8008 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008009 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
8010 {
8011 new_html = TRUE;
8012 p += 4;
8013 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008014 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
8015 {
8016 p += 8;
8017 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
8018 if (new_exclude_prog == NULL)
8019 errmsg = e_invarg;
8020 break;
8021 }
8022 else
8023 {
8024 errmsg = e_invarg;
8025 break;
8026 }
8027 if (*p == ',')
8028 ++p;
8029 }
8030 if (errmsg == NULL)
8031 {
8032 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02008033 clip_autoselect_star = new_autoselect_star;
8034 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008035 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008036 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02008037 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008038 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02008039#ifdef FEAT_GUI_GTK
8040 if (gui.in_use)
8041 {
8042 gui_gtk_set_selection_targets();
8043 gui_gtk_set_dnd_targets();
8044 }
8045#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008046 }
8047 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008048 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008049
8050 return errmsg;
8051}
8052#endif
8053
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008054#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008055 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008056did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008057{
8058 char_u *errmsg = NULL;
8059 win_T *wp;
8060 int l;
8061
8062 if (is_spellfile)
8063 {
8064 l = (int)STRLEN(curwin->w_s->b_p_spf);
8065 if (l > 0 && (l < 4
8066 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8067 errmsg = e_invarg;
8068 }
8069
8070 if (errmsg == NULL)
8071 {
8072 FOR_ALL_WINDOWS(wp)
8073 if (wp->w_buffer == curbuf && wp->w_p_spell)
8074 {
8075 errmsg = did_set_spelllang(wp);
8076# ifdef FEAT_WINDOWS
8077 break;
8078# endif
8079 }
8080 }
8081 return errmsg;
8082}
8083
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008084/*
8085 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8086 * Return error message when failed, NULL when OK.
8087 */
8088 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008089compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008090{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008091 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008092 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008093
Bram Moolenaar860cae12010-06-05 23:22:07 +02008094 if (*synblock->b_p_spc == NUL)
8095 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008096 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008097 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008098 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008099 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008100 if (re != NULL)
8101 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008102 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008103 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008104 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008105 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008106 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008107 return e_invarg;
8108 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008109 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008110 }
8111
Bram Moolenaar473de612013-06-08 18:19:48 +02008112 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008113 return NULL;
8114}
8115#endif
8116
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008117#if defined(FEAT_EVAL) || defined(PROTO)
8118/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008119 * Set the scriptID for an option, taking care of setting the buffer- or
8120 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008121 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008122 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008123set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008124{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008125 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8126 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008127
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008128 /* Remember where the option was set. For local options need to do that
8129 * in the buffer or window structure. */
8130 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008131 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008132 if (both || (opt_flags & OPT_LOCAL))
8133 {
8134 if (indir & PV_BUF)
8135 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8136 else if (indir & PV_WIN)
8137 curwin->w_p_scriptID[indir & PV_MASK] = id;
8138 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008139}
8140#endif
8141
Bram Moolenaar071d4272004-06-13 20:20:40 +00008142/*
8143 * Set the value of a boolean option, and take care of side effects.
8144 * Returns NULL for success, or an error message for an error.
8145 */
8146 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008147set_bool_option(
8148 int opt_idx, /* index in options[] table */
8149 char_u *varp, /* pointer to the option variable */
8150 int value, /* new value */
8151 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008152{
8153 int old_value = *(int *)varp;
8154
Bram Moolenaar071d4272004-06-13 20:20:40 +00008155 /* Disallow changing some options from secure mode */
8156 if ((secure
8157#ifdef HAVE_SANDBOX
8158 || sandbox != 0
8159#endif
8160 ) && (options[opt_idx].flags & P_SECURE))
8161 return e_secure;
8162
8163 *(int *)varp = value; /* set the new value */
8164#ifdef FEAT_EVAL
8165 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008166 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008167#endif
8168
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008169#ifdef FEAT_GUI
8170 need_mouse_correct = TRUE;
8171#endif
8172
Bram Moolenaar071d4272004-06-13 20:20:40 +00008173 /* May set global value for local option. */
8174 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8175 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8176
8177 /*
8178 * Handle side effects of changing a bool option.
8179 */
8180
8181 /* 'compatible' */
8182 if ((int *)varp == &p_cp)
8183 {
8184 compatible_set();
8185 }
8186
Bram Moolenaar920694c2016-08-21 17:45:02 +02008187#ifdef FEAT_LANGMAP
8188 if ((int *)varp == &p_lrm)
8189 /* 'langremap' -> !'langnoremap' */
8190 p_lnr = !p_lrm;
8191 else if ((int *)varp == &p_lnr)
8192 /* 'langnoremap' -> !'langremap' */
8193 p_lrm = !p_lnr;
8194#endif
8195
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008196#ifdef FEAT_PERSISTENT_UNDO
8197 /* 'undofile' */
8198 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8199 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008200 /* Only take action when the option was set. When reset we do not
8201 * delete the undo file, the option may be set again without making
8202 * any changes in between. */
8203 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008204 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008205 char_u hash[UNDO_HASH_SIZE];
8206 buf_T *save_curbuf = curbuf;
8207
Bram Moolenaar29323592016-07-24 22:04:11 +02008208 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008209 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008210 /* When 'undofile' is set globally: for every buffer, otherwise
8211 * only for the current buffer: Try to read in the undofile,
8212 * if one exists, the buffer wasn't changed and the buffer was
8213 * loaded */
8214 if ((curbuf == save_curbuf
8215 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8216 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8217 {
8218 u_compute_hash(hash);
8219 u_read_undo(NULL, hash, curbuf->b_fname);
8220 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008221 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008222 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008223 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008224 }
8225#endif
8226
Bram Moolenaar071d4272004-06-13 20:20:40 +00008227 else if ((int *)varp == &curbuf->b_p_ro)
8228 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008229 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008230 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8231 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008232
8233 /* when 'readonly' is set may give W10 again */
8234 if (curbuf->b_p_ro)
8235 curbuf->b_did_warn = FALSE;
8236
Bram Moolenaar071d4272004-06-13 20:20:40 +00008237#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008238 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008239#endif
8240 }
8241
Bram Moolenaar9c449722010-07-20 18:44:27 +02008242#ifdef FEAT_GUI
8243 else if ((int *)varp == &p_mh)
8244 {
8245 if (!p_mh)
8246 gui_mch_mousehide(FALSE);
8247 }
8248#endif
8249
Bram Moolenaara539df02010-08-01 14:35:05 +02008250 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008251 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008252 {
Bram Moolenaar423802d2017-07-30 16:52:24 +02008253# ifdef FEAT_TERMINAL
8254 /* Cannot set 'modifiable' when in Terminal mode. */
Bram Moolenaar6d819742017-08-06 14:57:49 +02008255 if (term_in_normal_mode()
Bram Moolenaar20e6cd02017-08-01 20:25:22 +02008256 || (bt_terminal(curbuf) && !term_is_finished(curbuf)))
Bram Moolenaar423802d2017-07-30 16:52:24 +02008257 {
8258 curbuf->b_p_ma = FALSE;
8259 return (char_u *)N_("E946: Cannot make a terminal with running job modifiable");
8260 }
8261# endif
8262# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008263 redraw_titles();
Bram Moolenaar423802d2017-07-30 16:52:24 +02008264# endif
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008265 }
Bram Moolenaar423802d2017-07-30 16:52:24 +02008266#ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00008267 /* when 'endofline' is changed, redraw the window title */
8268 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008269 {
8270 redraw_titles();
8271 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008272 /* when 'fixeol' is changed, redraw the window title */
8273 else if ((int *)varp == &curbuf->b_p_fixeol)
8274 {
8275 redraw_titles();
8276 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008277# ifdef FEAT_MBYTE
8278 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008279 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008280 {
8281 redraw_titles();
8282 }
8283# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008284#endif
8285
8286 /* when 'bin' is set also set some other options */
8287 else if ((int *)varp == &curbuf->b_p_bin)
8288 {
8289 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8290#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008291 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008292#endif
8293 }
8294
8295#ifdef FEAT_AUTOCMD
8296 /* when 'buflisted' changes, trigger autocommands */
8297 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8298 {
8299 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8300 NULL, NULL, TRUE, curbuf);
8301 }
8302#endif
8303
8304 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8305 else if ((int *)varp == &curbuf->b_p_swf)
8306 {
8307 if (curbuf->b_p_swf && p_uc)
8308 ml_open_file(curbuf); /* create the swap file */
8309 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008310 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8311 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008312 mf_close_file(curbuf, TRUE); /* remove the swap file */
8313 }
8314
8315 /* when 'terse' is set change 'shortmess' */
8316 else if ((int *)varp == &p_terse)
8317 {
8318 char_u *p;
8319
8320 p = vim_strchr(p_shm, SHM_SEARCH);
8321
8322 /* insert 's' in p_shm */
8323 if (p_terse && p == NULL)
8324 {
8325 STRCPY(IObuff, p_shm);
8326 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008327 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008328 }
8329 /* remove 's' from p_shm */
8330 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008331 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008332 }
8333
8334 /* when 'paste' is set or reset also change other options */
8335 else if ((int *)varp == &p_paste)
8336 {
8337 paste_option_changed();
8338 }
8339
8340 /* when 'insertmode' is set from an autocommand need to do work here */
8341 else if ((int *)varp == &p_im)
8342 {
8343 if (p_im)
8344 {
8345 if ((State & INSERT) == 0)
8346 need_start_insertmode = TRUE;
8347 stop_insert_mode = FALSE;
8348 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008349 /* only reset if it was set previously */
8350 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008351 {
8352 need_start_insertmode = FALSE;
8353 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008354 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008355 clear_cmdline = TRUE; /* remove "(insert)" */
8356 restart_edit = 0;
8357 }
8358 }
8359
8360 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8361 else if ((int *)varp == &p_ic && p_hls)
8362 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008363 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008364 }
8365
8366#ifdef FEAT_SEARCH_EXTRA
8367 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8368 else if ((int *)varp == &p_hls)
8369 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008370 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008371 }
8372#endif
8373
8374#ifdef FEAT_SCROLLBIND
8375 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8376 * at the end of normal_cmd() */
8377 else if ((int *)varp == &curwin->w_p_scb)
8378 {
8379 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008380 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008381 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008382 curwin->w_scbind_pos = curwin->w_topline;
8383 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008384 }
8385#endif
8386
8387#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8388 /* There can be only one window with 'previewwindow' set. */
8389 else if ((int *)varp == &curwin->w_p_pvw)
8390 {
8391 if (curwin->w_p_pvw)
8392 {
8393 win_T *win;
8394
Bram Moolenaar29323592016-07-24 22:04:11 +02008395 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008396 if (win->w_p_pvw && win != curwin)
8397 {
8398 curwin->w_p_pvw = FALSE;
8399 return (char_u *)N_("E590: A preview window already exists");
8400 }
8401 }
8402 }
8403#endif
8404
8405 /* when 'textmode' is set or reset also change 'fileformat' */
8406 else if ((int *)varp == &curbuf->b_p_tx)
8407 {
8408 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8409 }
8410
8411 /* when 'textauto' is set or reset also change 'fileformats' */
8412 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008413 set_string_option_direct((char_u *)"ffs", -1,
8414 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008415 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008416
8417 /*
8418 * When 'lisp' option changes include/exclude '-' in
8419 * keyword characters.
8420 */
8421#ifdef FEAT_LISP
8422 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8423 {
8424 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8425 }
8426#endif
8427
8428#ifdef FEAT_TITLE
8429 /* when 'title' changed, may need to change the title; same for 'icon' */
8430 else if ((int *)varp == &p_title)
8431 {
8432 did_set_title(FALSE);
8433 }
8434
8435 else if ((int *)varp == &p_icon)
8436 {
8437 did_set_title(TRUE);
8438 }
8439#endif
8440
8441 else if ((int *)varp == &curbuf->b_changed)
8442 {
8443 if (!value)
8444 save_file_ff(curbuf); /* Buffer is unchanged */
8445#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008446 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008447#endif
8448#ifdef FEAT_AUTOCMD
8449 modified_was_set = value;
8450#endif
8451 }
8452
8453#ifdef BACKSLASH_IN_FILENAME
8454 else if ((int *)varp == &p_ssl)
8455 {
8456 if (p_ssl)
8457 {
8458 psepc = '/';
8459 psepcN = '\\';
8460 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008461 }
8462 else
8463 {
8464 psepc = '\\';
8465 psepcN = '/';
8466 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008467 }
8468
8469 /* need to adjust the file name arguments and buffer names. */
8470 buflist_slash_adjust();
8471 alist_slash_adjust();
8472# ifdef FEAT_EVAL
8473 scriptnames_slash_adjust();
8474# endif
8475 }
8476#endif
8477
8478 /* If 'wrap' is set, set w_leftcol to zero. */
8479 else if ((int *)varp == &curwin->w_p_wrap)
8480 {
8481 if (curwin->w_p_wrap)
8482 curwin->w_leftcol = 0;
8483 }
8484
8485#ifdef FEAT_WINDOWS
8486 else if ((int *)varp == &p_ea)
8487 {
8488 if (p_ea && !old_value)
8489 win_equal(curwin, FALSE, 0);
8490 }
8491#endif
8492
8493 else if ((int *)varp == &p_wiv)
8494 {
8495 /*
8496 * When 'weirdinvert' changed, set/reset 't_xs'.
8497 * Then set 'weirdinvert' according to value of 't_xs'.
8498 */
8499 if (p_wiv && !old_value)
8500 T_XS = (char_u *)"y";
8501 else if (!p_wiv && old_value)
8502 T_XS = empty_option;
8503 p_wiv = (*T_XS != NUL);
8504 }
8505
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008506#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008507 else if ((int *)varp == &p_beval)
8508 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008509 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008510 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008511 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008512 gui_mch_disable_beval_area(balloonEval);
8513 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008514#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008515
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008516#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008517 else if ((int *)varp == &p_acd)
8518 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008519 /* Change directories when the 'acd' option is set now. */
8520 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008521 }
8522#endif
8523
8524#ifdef FEAT_DIFF
8525 /* 'diff' */
8526 else if ((int *)varp == &curwin->w_p_diff)
8527 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008528 /* May add or remove the buffer from the list of diff buffers. */
8529 diff_buf_adjust(curwin);
8530# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008531 if (foldmethodIsDiff(curwin))
8532 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008533# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008534 }
8535#endif
8536
8537#ifdef USE_IM_CONTROL
8538 /* 'imdisable' */
8539 else if ((int *)varp == &p_imdisable)
8540 {
8541 /* Only de-activate it here, it will be enabled when changing mode. */
8542 if (p_imdisable)
8543 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008544 else if (State & INSERT)
8545 /* When the option is set from an autocommand, it may need to take
8546 * effect right away. */
8547 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008548 }
8549#endif
8550
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008551#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008552 /* 'spell' */
8553 else if ((int *)varp == &curwin->w_p_spell)
8554 {
8555 if (curwin->w_p_spell)
8556 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008557 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008558 if (errmsg != NULL)
8559 EMSG(_(errmsg));
8560 }
8561 }
8562#endif
8563
Bram Moolenaar071d4272004-06-13 20:20:40 +00008564#ifdef FEAT_FKMAP
8565 else if ((int *)varp == &p_altkeymap)
8566 {
8567 if (old_value != p_altkeymap)
8568 {
8569 if (!p_altkeymap)
8570 {
8571 p_hkmap = p_fkmap;
8572 p_fkmap = 0;
8573 }
8574 else
8575 {
8576 p_fkmap = p_hkmap;
8577 p_hkmap = 0;
8578 }
8579 (void)init_chartab();
8580 }
8581 }
8582
8583 /*
8584 * In case some second language keymapping options have changed, check
8585 * and correct the setting in a consistent way.
8586 */
8587
8588 /*
8589 * If hkmap or fkmap are set, reset Arabic keymapping.
8590 */
8591 if ((p_hkmap || p_fkmap) && p_altkeymap)
8592 {
8593 p_altkeymap = p_fkmap;
8594# ifdef FEAT_ARABIC
8595 curwin->w_p_arab = FALSE;
8596# endif
8597 (void)init_chartab();
8598 }
8599
8600 /*
8601 * If hkmap set, reset Farsi keymapping.
8602 */
8603 if (p_hkmap && p_altkeymap)
8604 {
8605 p_altkeymap = 0;
8606 p_fkmap = 0;
8607# ifdef FEAT_ARABIC
8608 curwin->w_p_arab = FALSE;
8609# endif
8610 (void)init_chartab();
8611 }
8612
8613 /*
8614 * If fkmap set, reset Hebrew keymapping.
8615 */
8616 if (p_fkmap && !p_altkeymap)
8617 {
8618 p_altkeymap = 1;
8619 p_hkmap = 0;
8620# ifdef FEAT_ARABIC
8621 curwin->w_p_arab = FALSE;
8622# endif
8623 (void)init_chartab();
8624 }
8625#endif
8626
8627#ifdef FEAT_ARABIC
8628 if ((int *)varp == &curwin->w_p_arab)
8629 {
8630 if (curwin->w_p_arab)
8631 {
8632 /*
8633 * 'arabic' is set, handle various sub-settings.
8634 */
8635 if (!p_tbidi)
8636 {
8637 /* set rightleft mode */
8638 if (!curwin->w_p_rl)
8639 {
8640 curwin->w_p_rl = TRUE;
8641 changed_window_setting();
8642 }
8643
8644 /* Enable Arabic shaping (major part of what Arabic requires) */
8645 if (!p_arshape)
8646 {
8647 p_arshape = TRUE;
8648 redraw_later_clear();
8649 }
8650 }
8651
8652 /* Arabic requires a utf-8 encoding, inform the user if its not
8653 * set. */
8654 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008655 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008656 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8657
Bram Moolenaar8820b482017-03-16 17:23:31 +01008658 msg_source(HL_ATTR(HLF_W));
8659 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008660#ifdef FEAT_EVAL
8661 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8662#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008663 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008664
8665# ifdef FEAT_MBYTE
8666 /* set 'delcombine' */
8667 p_deco = TRUE;
8668# endif
8669
8670# ifdef FEAT_KEYMAP
8671 /* Force-set the necessary keymap for arabic */
8672 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8673 OPT_LOCAL);
8674# endif
8675# ifdef FEAT_FKMAP
8676 p_altkeymap = 0;
8677 p_hkmap = 0;
8678 p_fkmap = 0;
8679 (void)init_chartab();
8680# endif
8681 }
8682 else
8683 {
8684 /*
8685 * 'arabic' is reset, handle various sub-settings.
8686 */
8687 if (!p_tbidi)
8688 {
8689 /* reset rightleft mode */
8690 if (curwin->w_p_rl)
8691 {
8692 curwin->w_p_rl = FALSE;
8693 changed_window_setting();
8694 }
8695
8696 /* 'arabicshape' isn't reset, it is a global option and
8697 * another window may still need it "on". */
8698 }
8699
8700 /* 'delcombine' isn't reset, it is a global option and another
8701 * window may still want it "on". */
8702
8703# ifdef FEAT_KEYMAP
8704 /* Revert to the default keymap */
8705 curbuf->b_p_iminsert = B_IMODE_NONE;
8706 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8707# endif
8708 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008709 }
8710
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008711#endif
8712
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008713#ifdef FEAT_TERMGUICOLORS
8714 /* 'termguicolors' */
8715 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008716 {
8717# ifdef FEAT_GUI
8718 if (!gui.in_use && !gui.starting)
8719# endif
8720 highlight_gui_started();
8721 }
8722#endif
8723
Bram Moolenaar071d4272004-06-13 20:20:40 +00008724 /*
8725 * End of handling side effects for bool options.
8726 */
8727
Bram Moolenaar53744302015-07-17 17:38:22 +02008728 /* after handling side effects, call autocommand */
8729
Bram Moolenaar071d4272004-06-13 20:20:40 +00008730 options[opt_idx].flags |= P_WAS_SET;
8731
Bram Moolenaar53744302015-07-17 17:38:22 +02008732#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8733 if (!starting)
8734 {
8735 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008736 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8737 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8738 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008739 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8740 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8741 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8742 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8743 reset_v_option_vars();
8744 }
8745#endif
8746
Bram Moolenaar071d4272004-06-13 20:20:40 +00008747 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008748 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008749 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008750 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008751 check_redraw(options[opt_idx].flags);
8752
8753 return NULL;
8754}
8755
8756/*
8757 * Set the value of a number option, and take care of side effects.
8758 * Returns NULL for success, or an error message for an error.
8759 */
8760 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008761set_num_option(
8762 int opt_idx, /* index in options[] table */
8763 char_u *varp, /* pointer to the option variable */
8764 long value, /* new value */
8765 char_u *errbuf, /* buffer for error messages */
8766 size_t errbuflen, /* length of "errbuf" */
8767 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008768 OPT_MODELINE */
8769{
8770 char_u *errmsg = NULL;
8771 long old_value = *(long *)varp;
8772 long old_Rows = Rows; /* remember old Rows */
8773 long old_Columns = Columns; /* remember old Columns */
8774 long *pp = (long *)varp;
8775
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008776 /* Disallow changing some options from secure mode. */
8777 if ((secure
8778#ifdef HAVE_SANDBOX
8779 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008780#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008781 ) && (options[opt_idx].flags & P_SECURE))
8782 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008783
8784 *pp = value;
8785#ifdef FEAT_EVAL
8786 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008787 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008788#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008789#ifdef FEAT_GUI
8790 need_mouse_correct = TRUE;
8791#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008792
Bram Moolenaar14f24742012-08-08 18:01:05 +02008793 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008794 {
8795 errmsg = e_positive;
8796 curbuf->b_p_sw = curbuf->b_p_ts;
8797 }
8798
8799 /*
8800 * Number options that need some action when changed
8801 */
8802#ifdef FEAT_WINDOWS
8803 if (pp == &p_wh || pp == &p_hh)
8804 {
8805 if (p_wh < 1)
8806 {
8807 errmsg = e_positive;
8808 p_wh = 1;
8809 }
8810 if (p_wmh > p_wh)
8811 {
8812 errmsg = e_winheight;
8813 p_wh = p_wmh;
8814 }
8815 if (p_hh < 0)
8816 {
8817 errmsg = e_positive;
8818 p_hh = 0;
8819 }
8820
8821 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008822 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008823 {
8824 if (pp == &p_wh && curwin->w_height < p_wh)
8825 win_setheight((int)p_wh);
8826 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8827 win_setheight((int)p_hh);
8828 }
8829 }
8830
8831 /* 'winminheight' */
8832 else if (pp == &p_wmh)
8833 {
8834 if (p_wmh < 0)
8835 {
8836 errmsg = e_positive;
8837 p_wmh = 0;
8838 }
8839 if (p_wmh > p_wh)
8840 {
8841 errmsg = e_winheight;
8842 p_wmh = p_wh;
8843 }
8844 win_setminheight();
8845 }
8846
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008847# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008848 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008849 {
8850 if (p_wiw < 1)
8851 {
8852 errmsg = e_positive;
8853 p_wiw = 1;
8854 }
8855 if (p_wmw > p_wiw)
8856 {
8857 errmsg = e_winwidth;
8858 p_wiw = p_wmw;
8859 }
8860
8861 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008862 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008863 win_setwidth((int)p_wiw);
8864 }
8865
8866 /* 'winminwidth' */
8867 else if (pp == &p_wmw)
8868 {
8869 if (p_wmw < 0)
8870 {
8871 errmsg = e_positive;
8872 p_wmw = 0;
8873 }
8874 if (p_wmw > p_wiw)
8875 {
8876 errmsg = e_winwidth;
8877 p_wmw = p_wiw;
8878 }
8879 win_setminheight();
8880 }
8881# endif
8882
8883#endif
8884
8885#ifdef FEAT_WINDOWS
8886 /* (re)set last window status line */
8887 else if (pp == &p_ls)
8888 {
8889 last_status(FALSE);
8890 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008891
8892 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008893 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008894 {
8895 shell_new_rows(); /* recompute window positions and heights */
8896 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008897#endif
8898
8899#ifdef FEAT_GUI
8900 else if (pp == &p_linespace)
8901 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008902 /* Recompute gui.char_height and resize the Vim window to keep the
8903 * same number of lines. */
8904 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008905 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008906 }
8907#endif
8908
8909#ifdef FEAT_FOLDING
8910 /* 'foldlevel' */
8911 else if (pp == &curwin->w_p_fdl)
8912 {
8913 if (curwin->w_p_fdl < 0)
8914 curwin->w_p_fdl = 0;
8915 newFoldLevel();
8916 }
8917
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008918 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008919 else if (pp == &curwin->w_p_fml)
8920 {
8921 foldUpdateAll(curwin);
8922 }
8923
8924 /* 'foldnestmax' */
8925 else if (pp == &curwin->w_p_fdn)
8926 {
8927 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8928 foldUpdateAll(curwin);
8929 }
8930
8931 /* 'foldcolumn' */
8932 else if (pp == &curwin->w_p_fdc)
8933 {
8934 if (curwin->w_p_fdc < 0)
8935 {
8936 errmsg = e_positive;
8937 curwin->w_p_fdc = 0;
8938 }
8939 else if (curwin->w_p_fdc > 12)
8940 {
8941 errmsg = e_invarg;
8942 curwin->w_p_fdc = 12;
8943 }
8944 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008945#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008946
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008947#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008948 /* 'shiftwidth' or 'tabstop' */
8949 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8950 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008951# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008952 if (foldmethodIsIndent(curwin))
8953 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008954# endif
8955# ifdef FEAT_CINDENT
8956 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8957 * parse 'cinoptions'. */
8958 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8959 parse_cino(curbuf);
8960# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008961 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008962#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008963
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008964#ifdef FEAT_MBYTE
8965 /* 'maxcombine' */
8966 else if (pp == &p_mco)
8967 {
8968 if (p_mco > MAX_MCO)
8969 p_mco = MAX_MCO;
8970 else if (p_mco < 0)
8971 p_mco = 0;
8972 screenclear(); /* will re-allocate the screen */
8973 }
8974#endif
8975
Bram Moolenaar071d4272004-06-13 20:20:40 +00008976 else if (pp == &curbuf->b_p_iminsert)
8977 {
8978 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8979 {
8980 errmsg = e_invarg;
8981 curbuf->b_p_iminsert = B_IMODE_NONE;
8982 }
8983 p_iminsert = curbuf->b_p_iminsert;
8984 if (termcap_active) /* don't do this in the alternate screen */
8985 showmode();
8986#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8987 /* Show/unshow value of 'keymap' in status lines. */
8988 status_redraw_curbuf();
8989#endif
8990 }
8991
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008992 else if (pp == &p_window)
8993 {
8994 if (p_window < 1)
8995 p_window = 1;
8996 else if (p_window >= Rows)
8997 p_window = Rows - 1;
8998 }
8999
Bram Moolenaar071d4272004-06-13 20:20:40 +00009000 else if (pp == &curbuf->b_p_imsearch)
9001 {
9002 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
9003 {
9004 errmsg = e_invarg;
9005 curbuf->b_p_imsearch = B_IMODE_NONE;
9006 }
9007 p_imsearch = curbuf->b_p_imsearch;
9008 }
9009
9010#ifdef FEAT_TITLE
9011 /* if 'titlelen' has changed, redraw the title */
9012 else if (pp == &p_titlelen)
9013 {
9014 if (p_titlelen < 0)
9015 {
9016 errmsg = e_positive;
9017 p_titlelen = 85;
9018 }
9019 if (starting != NO_SCREEN && old_value != p_titlelen)
9020 need_maketitle = TRUE;
9021 }
9022#endif
9023
9024 /* if p_ch changed value, change the command line height */
9025 else if (pp == &p_ch)
9026 {
9027 if (p_ch < 1)
9028 {
9029 errmsg = e_positive;
9030 p_ch = 1;
9031 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00009032 if (p_ch > Rows - min_rows() + 1)
9033 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009034
9035 /* Only compute the new window layout when startup has been
9036 * completed. Otherwise the frame sizes may be wrong. */
9037 if (p_ch != old_value && full_screen
9038#ifdef FEAT_GUI
9039 && !gui.starting
9040#endif
9041 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00009042 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009043 }
9044
9045 /* when 'updatecount' changes from zero to non-zero, open swap files */
9046 else if (pp == &p_uc)
9047 {
9048 if (p_uc < 0)
9049 {
9050 errmsg = e_positive;
9051 p_uc = 100;
9052 }
9053 if (p_uc && !old_value)
9054 ml_open_files();
9055 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02009056#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009057 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009058 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009059 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009060 {
9061 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009062 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009063 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009064 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009065 {
9066 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009067 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009068 }
9069 }
9070#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009071#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009072 else if (pp == &p_mzq)
9073 mzvim_reset_timer();
9074#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009075
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009076#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9077 /* 'pyxversion' */
9078 else if (pp == &p_pyx)
9079 {
9080 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9081 errmsg = e_invarg;
9082 }
9083#endif
9084
Bram Moolenaar071d4272004-06-13 20:20:40 +00009085 /* sync undo before 'undolevels' changes */
9086 else if (pp == &p_ul)
9087 {
9088 /* use the old value, otherwise u_sync() may not work properly */
9089 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009090 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009091 p_ul = value;
9092 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009093 else if (pp == &curbuf->b_p_ul)
9094 {
9095 /* use the old value, otherwise u_sync() may not work properly */
9096 curbuf->b_p_ul = old_value;
9097 u_sync(TRUE);
9098 curbuf->b_p_ul = value;
9099 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009100
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009101#ifdef FEAT_LINEBREAK
9102 /* 'numberwidth' must be positive */
9103 else if (pp == &curwin->w_p_nuw)
9104 {
9105 if (curwin->w_p_nuw < 1)
9106 {
9107 errmsg = e_positive;
9108 curwin->w_p_nuw = 1;
9109 }
9110 if (curwin->w_p_nuw > 10)
9111 {
9112 errmsg = e_invarg;
9113 curwin->w_p_nuw = 10;
9114 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009115 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009116 }
9117#endif
9118
Bram Moolenaar1a384422010-07-14 19:53:30 +02009119 else if (pp == &curbuf->b_p_tw)
9120 {
9121 if (curbuf->b_p_tw < 0)
9122 {
9123 errmsg = e_positive;
9124 curbuf->b_p_tw = 0;
9125 }
9126#ifdef FEAT_SYN_HL
9127# ifdef FEAT_WINDOWS
9128 {
9129 win_T *wp;
9130 tabpage_T *tp;
9131
9132 FOR_ALL_TAB_WINDOWS(tp, wp)
9133 check_colorcolumn(wp);
9134 }
9135# else
9136 check_colorcolumn(curwin);
9137# endif
9138#endif
9139 }
9140
Bram Moolenaar071d4272004-06-13 20:20:40 +00009141 /*
9142 * Check the bounds for numeric options here
9143 */
9144 if (Rows < min_rows() && full_screen)
9145 {
9146 if (errbuf != NULL)
9147 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009148 vim_snprintf((char *)errbuf, errbuflen,
9149 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009150 errmsg = errbuf;
9151 }
9152 Rows = min_rows();
9153 }
9154 if (Columns < MIN_COLUMNS && full_screen)
9155 {
9156 if (errbuf != NULL)
9157 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009158 vim_snprintf((char *)errbuf, errbuflen,
9159 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009160 errmsg = errbuf;
9161 }
9162 Columns = MIN_COLUMNS;
9163 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009164 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009165
Bram Moolenaar071d4272004-06-13 20:20:40 +00009166 /*
9167 * If the screen (shell) height has been changed, assume it is the
9168 * physical screenheight.
9169 */
9170 if (old_Rows != Rows || old_Columns != Columns)
9171 {
9172 /* Changing the screen size is not allowed while updating the screen. */
9173 if (updating_screen)
9174 *pp = old_value;
9175 else if (full_screen
9176#ifdef FEAT_GUI
9177 && !gui.starting
9178#endif
9179 )
9180 set_shellsize((int)Columns, (int)Rows, TRUE);
9181 else
9182 {
9183 /* Postpone the resizing; check the size and cmdline position for
9184 * messages. */
9185 check_shellsize();
9186 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9187 cmdline_row = Rows - p_ch;
9188 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009189 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009190 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009191 }
9192
Bram Moolenaar071d4272004-06-13 20:20:40 +00009193 if (curbuf->b_p_ts <= 0)
9194 {
9195 errmsg = e_positive;
9196 curbuf->b_p_ts = 8;
9197 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009198 if (p_tm < 0)
9199 {
9200 errmsg = e_positive;
9201 p_tm = 0;
9202 }
9203 if ((curwin->w_p_scr <= 0
9204 || (curwin->w_p_scr > curwin->w_height
9205 && curwin->w_height > 0))
9206 && full_screen)
9207 {
9208 if (pp == &(curwin->w_p_scr))
9209 {
9210 if (curwin->w_p_scr != 0)
9211 errmsg = e_scroll;
9212 win_comp_scroll(curwin);
9213 }
9214 /* If 'scroll' became invalid because of a side effect silently adjust
9215 * it. */
9216 else if (curwin->w_p_scr <= 0)
9217 curwin->w_p_scr = 1;
9218 else /* curwin->w_p_scr > curwin->w_height */
9219 curwin->w_p_scr = curwin->w_height;
9220 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009221 if (p_hi < 0)
9222 {
9223 errmsg = e_positive;
9224 p_hi = 0;
9225 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009226 else if (p_hi > 10000)
9227 {
9228 errmsg = e_invarg;
9229 p_hi = 10000;
9230 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009231 if (p_re < 0 || p_re > 2)
9232 {
9233 errmsg = e_invarg;
9234 p_re = 0;
9235 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009236 if (p_report < 0)
9237 {
9238 errmsg = e_positive;
9239 p_report = 1;
9240 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009241 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009242 {
9243 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9244 p_sj = Rows / 2;
9245 else
9246 {
9247 errmsg = e_scroll;
9248 p_sj = 1;
9249 }
9250 }
9251 if (p_so < 0 && full_screen)
9252 {
9253 errmsg = e_scroll;
9254 p_so = 0;
9255 }
9256 if (p_siso < 0 && full_screen)
9257 {
9258 errmsg = e_positive;
9259 p_siso = 0;
9260 }
9261#ifdef FEAT_CMDWIN
9262 if (p_cwh < 1)
9263 {
9264 errmsg = e_positive;
9265 p_cwh = 1;
9266 }
9267#endif
9268 if (p_ut < 0)
9269 {
9270 errmsg = e_positive;
9271 p_ut = 2000;
9272 }
9273 if (p_ss < 0)
9274 {
9275 errmsg = e_positive;
9276 p_ss = 0;
9277 }
9278
9279 /* May set global value for local option. */
9280 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9281 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9282
9283 options[opt_idx].flags |= P_WAS_SET;
9284
Bram Moolenaar53744302015-07-17 17:38:22 +02009285#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9286 if (!starting && errmsg == NULL)
9287 {
9288 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009289 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9290 vim_snprintf((char *)buf_new, 10, "%ld", value);
9291 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009292 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9293 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9294 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9295 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9296 reset_v_option_vars();
9297 }
9298#endif
9299
Bram Moolenaar071d4272004-06-13 20:20:40 +00009300 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009301 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009302 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009303 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009304 check_redraw(options[opt_idx].flags);
9305
9306 return errmsg;
9307}
9308
9309/*
9310 * Called after an option changed: check if something needs to be redrawn.
9311 */
9312 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009313check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009314{
9315 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009316 int doclear = (flags & P_RCLR) == P_RCLR;
9317 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009318
9319#ifdef FEAT_WINDOWS
9320 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9321 status_redraw_all();
9322#endif
9323
9324 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9325 changed_window_setting();
9326 if (flags & P_RBUF)
9327 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009328 if (flags & P_RWINONLY)
9329 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009330 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009331 redraw_all_later(CLEAR);
9332 else if (all)
9333 redraw_all_later(NOT_VALID);
9334}
9335
9336/*
9337 * Find index for option 'arg'.
9338 * Return -1 if not found.
9339 */
9340 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009341findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009342{
9343 int opt_idx;
9344 char *s, *p;
9345 static short quick_tab[27] = {0, 0}; /* quick access table */
9346 int is_term_opt;
9347
9348 /*
9349 * For first call: Initialize the quick-access table.
9350 * It contains the index for the first option that starts with a certain
9351 * letter. There are 26 letters, plus the first "t_" option.
9352 */
9353 if (quick_tab[1] == 0)
9354 {
9355 p = options[0].fullname;
9356 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9357 {
9358 if (s[0] != p[0])
9359 {
9360 if (s[0] == 't' && s[1] == '_')
9361 quick_tab[26] = opt_idx;
9362 else
9363 quick_tab[CharOrdLow(s[0])] = opt_idx;
9364 }
9365 p = s;
9366 }
9367 }
9368
9369 /*
9370 * Check for name starting with an illegal character.
9371 */
9372#ifdef EBCDIC
9373 if (!islower(arg[0]))
9374#else
9375 if (arg[0] < 'a' || arg[0] > 'z')
9376#endif
9377 return -1;
9378
9379 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9380 if (is_term_opt)
9381 opt_idx = quick_tab[26];
9382 else
9383 opt_idx = quick_tab[CharOrdLow(arg[0])];
9384 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9385 {
9386 if (STRCMP(arg, s) == 0) /* match full name */
9387 break;
9388 }
9389 if (s == NULL && !is_term_opt)
9390 {
9391 opt_idx = quick_tab[CharOrdLow(arg[0])];
9392 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9393 {
9394 s = options[opt_idx].shortname;
9395 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9396 break;
9397 s = NULL;
9398 }
9399 }
9400 if (s == NULL)
9401 opt_idx = -1;
9402 return opt_idx;
9403}
9404
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009405#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009406/*
9407 * Get the value for an option.
9408 *
9409 * Returns:
9410 * Number or Toggle option: 1, *numval gets value.
9411 * String option: 0, *stringval gets allocated string.
9412 * Hidden Number or Toggle option: -1.
9413 * hidden String option: -2.
9414 * unknown option: -3.
9415 */
9416 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009417get_option_value(
9418 char_u *name,
9419 long *numval,
9420 char_u **stringval, /* NULL when only checking existence */
9421 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009422{
9423 int opt_idx;
9424 char_u *varp;
9425
9426 opt_idx = findoption(name);
9427 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009428 {
9429 int key;
9430
9431 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9432 && (key = find_key_option(name)) != 0)
9433 {
9434 char_u key_name[2];
9435 char_u *p;
9436
9437 if (key < 0)
9438 {
9439 key_name[0] = KEY2TERMCAP0(key);
9440 key_name[1] = KEY2TERMCAP1(key);
9441 }
9442 else
9443 {
9444 key_name[0] = KS_KEY;
9445 key_name[1] = (key & 0xff);
9446 }
9447 p = find_termcode(key_name);
9448 if (p != NULL)
9449 {
9450 if (stringval != NULL)
9451 *stringval = vim_strsave(p);
9452 return 0;
9453 }
9454 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009455 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009456 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009457
9458 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9459
9460 if (options[opt_idx].flags & P_STRING)
9461 {
9462 if (varp == NULL) /* hidden option */
9463 return -2;
9464 if (stringval != NULL)
9465 {
9466#ifdef FEAT_CRYPT
9467 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009468 if ((char_u **)varp == &curbuf->b_p_key
9469 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009470 *stringval = vim_strsave((char_u *)"*****");
9471 else
9472#endif
9473 *stringval = vim_strsave(*(char_u **)(varp));
9474 }
9475 return 0;
9476 }
9477
9478 if (varp == NULL) /* hidden option */
9479 return -1;
9480 if (options[opt_idx].flags & P_NUM)
9481 *numval = *(long *)varp;
9482 else
9483 {
9484 /* Special case: 'modified' is b_changed, but we also want to consider
9485 * it set when 'ff' or 'fenc' changed. */
9486 if ((int *)varp == &curbuf->b_changed)
9487 *numval = curbufIsChanged();
9488 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009489 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009490 }
9491 return 1;
9492}
9493#endif
9494
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009495#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009496/*
9497 * Returns the option attributes and its value. Unlike the above function it
9498 * will return either global value or local value of the option depending on
9499 * what was requested, but it will never return global value if it was
9500 * requested to return local one and vice versa. Neither it will return
9501 * buffer-local value if it was requested to return window-local one.
9502 *
9503 * Pretends that option is absent if it is not present in the requested scope
9504 * (i.e. has no global, window-local or buffer-local value depending on
9505 * opt_type). Uses
9506 *
9507 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009508 * 0 hidden or unknown option, also option that does not have requested
9509 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009510 * see SOPT_* in vim.h for other flags
9511 *
9512 * Possible opt_type values: see SREQ_* in vim.h
9513 */
9514 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009515get_option_value_strict(
9516 char_u *name,
9517 long *numval,
9518 char_u **stringval, /* NULL when only obtaining attributes */
9519 int opt_type,
9520 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009521{
9522 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009523 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009524 struct vimoption *p;
9525 int r = 0;
9526
9527 opt_idx = findoption(name);
9528 if (opt_idx < 0)
9529 return 0;
9530
9531 p = &(options[opt_idx]);
9532
9533 /* Hidden option */
9534 if (p->var == NULL)
9535 return 0;
9536
9537 if (p->flags & P_BOOL)
9538 r |= SOPT_BOOL;
9539 else if (p->flags & P_NUM)
9540 r |= SOPT_NUM;
9541 else if (p->flags & P_STRING)
9542 r |= SOPT_STRING;
9543
9544 if (p->indir == PV_NONE)
9545 {
9546 if (opt_type == SREQ_GLOBAL)
9547 r |= SOPT_GLOBAL;
9548 else
9549 return 0; /* Did not request global-only option */
9550 }
9551 else
9552 {
9553 if (p->indir & PV_BOTH)
9554 r |= SOPT_GLOBAL;
9555 else if (opt_type == SREQ_GLOBAL)
9556 return 0; /* Requested global option */
9557
9558 if (p->indir & PV_WIN)
9559 {
9560 if (opt_type == SREQ_BUF)
9561 return 0; /* Did not request window-local option */
9562 else
9563 r |= SOPT_WIN;
9564 }
9565 else if (p->indir & PV_BUF)
9566 {
9567 if (opt_type == SREQ_WIN)
9568 return 0; /* Did not request buffer-local option */
9569 else
9570 r |= SOPT_BUF;
9571 }
9572 }
9573
9574 if (stringval == NULL)
9575 return r;
9576
9577 if (opt_type == SREQ_GLOBAL)
9578 varp = p->var;
9579 else
9580 {
9581 if (opt_type == SREQ_BUF)
9582 {
9583 /* Special case: 'modified' is b_changed, but we also want to
9584 * consider it set when 'ff' or 'fenc' changed. */
9585 if (p->indir == PV_MOD)
9586 {
9587 *numval = bufIsChanged((buf_T *) from);
9588 varp = NULL;
9589 }
9590#ifdef FEAT_CRYPT
9591 else if (p->indir == PV_KEY)
9592 {
9593 /* never return the value of the crypt key */
9594 *stringval = NULL;
9595 varp = NULL;
9596 }
9597#endif
9598 else
9599 {
9600 aco_save_T aco;
9601 aucmd_prepbuf(&aco, (buf_T *) from);
9602 varp = get_varp(p);
9603 aucmd_restbuf(&aco);
9604 }
9605 }
9606 else if (opt_type == SREQ_WIN)
9607 {
9608 win_T *save_curwin;
9609 save_curwin = curwin;
9610 curwin = (win_T *) from;
9611 curbuf = curwin->w_buffer;
9612 varp = get_varp(p);
9613 curwin = save_curwin;
9614 curbuf = curwin->w_buffer;
9615 }
9616 if (varp == p->var)
9617 return (r | SOPT_UNSET);
9618 }
9619
9620 if (varp != NULL)
9621 {
9622 if (p->flags & P_STRING)
9623 *stringval = vim_strsave(*(char_u **)(varp));
9624 else if (p->flags & P_NUM)
9625 *numval = *(long *) varp;
9626 else
9627 *numval = *(int *)varp;
9628 }
9629
9630 return r;
9631}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009632
9633/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009634 * Iterate over options. First argument is a pointer to a pointer to a
9635 * structure inside options[] array, second is option type like in the above
9636 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009637 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009638 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009639 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009640 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009641 * first argument to NULL.
9642 *
9643 * Returns full option name for current option on each call.
9644 */
9645 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009646option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009647{
9648 struct vimoption *ret = NULL;
9649 do
9650 {
9651 if (*option == NULL)
9652 *option = (void *) options;
9653 else if (((struct vimoption *) (*option))->fullname == NULL)
9654 {
9655 *option = NULL;
9656 return NULL;
9657 }
9658 else
9659 *option = (void *) (((struct vimoption *) (*option)) + 1);
9660
9661 ret = ((struct vimoption *) (*option));
9662
9663 /* Hidden option */
9664 if (ret->var == NULL)
9665 {
9666 ret = NULL;
9667 continue;
9668 }
9669
9670 switch (opt_type)
9671 {
9672 case SREQ_GLOBAL:
9673 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9674 ret = NULL;
9675 break;
9676 case SREQ_BUF:
9677 if (!(ret->indir & PV_BUF))
9678 ret = NULL;
9679 break;
9680 case SREQ_WIN:
9681 if (!(ret->indir & PV_WIN))
9682 ret = NULL;
9683 break;
9684 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009685 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009686 return NULL;
9687 }
9688 }
9689 while (ret == NULL);
9690
9691 return (char_u *)ret->fullname;
9692}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009693#endif
9694
Bram Moolenaar071d4272004-06-13 20:20:40 +00009695/*
9696 * Set the value of option "name".
9697 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009698 *
9699 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009700 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009701 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009702set_option_value(
9703 char_u *name,
9704 long number,
9705 char_u *string,
9706 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009707{
9708 int opt_idx;
9709 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009710 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009711
9712 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009713 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009714 {
9715 int key;
9716
9717 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9718 && (key = find_key_option(name)) != 0)
9719 {
9720 char_u key_name[2];
9721
9722 if (key < 0)
9723 {
9724 key_name[0] = KEY2TERMCAP0(key);
9725 key_name[1] = KEY2TERMCAP1(key);
9726 }
9727 else
9728 {
9729 key_name[0] = KS_KEY;
9730 key_name[1] = (key & 0xff);
9731 }
9732 add_termcode(key_name, string, FALSE);
9733 if (full_screen)
9734 ttest(FALSE);
9735 redraw_all_later(CLEAR);
9736 return NULL;
9737 }
9738
Bram Moolenaar071d4272004-06-13 20:20:40 +00009739 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009740 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009741 else
9742 {
9743 flags = options[opt_idx].flags;
9744#ifdef HAVE_SANDBOX
9745 /* Disallow changing some options in the sandbox */
9746 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009747 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009748 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009749 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009750 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009751#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009752 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009753 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009754 else
9755 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009756 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009757 if (varp != NULL) /* hidden option is not changed */
9758 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009759 if (number == 0 && string != NULL)
9760 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009761 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009762
9763 /* Either we are given a string or we are setting option
9764 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009765 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009766 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009767 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009768 {
9769 /* There's another character after zeros or the string
9770 * is empty. In both cases, we are trying to set a
9771 * num option using a string. */
9772 EMSG3(_("E521: Number required: &%s = '%s'"),
9773 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009774 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009775
9776 }
9777 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009778 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009779 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009780 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009781 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009782 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009783 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009784 }
9785 }
9786 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009787 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009788}
9789
9790/*
9791 * Get the terminal code for a terminal option.
9792 * Returns NULL when not found.
9793 */
9794 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009795get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009796{
9797 int opt_idx;
9798 char_u *varp;
9799
9800 if (tname[0] != 't' || tname[1] != '_' ||
9801 tname[2] == NUL || tname[3] == NUL)
9802 return NULL;
9803 if ((opt_idx = findoption(tname)) >= 0)
9804 {
9805 varp = get_varp(&(options[opt_idx]));
9806 if (varp != NULL)
9807 varp = *(char_u **)(varp);
9808 return varp;
9809 }
9810 return find_termcode(tname + 2);
9811}
9812
9813 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009814get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009815{
9816 int i;
9817
9818 i = findoption((char_u *)"hl");
9819 if (i >= 0)
9820 return options[i].def_val[VI_DEFAULT];
9821 return (char_u *)NULL;
9822}
9823
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009824#if defined(FEAT_MBYTE) || defined(PROTO)
9825 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009826get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009827{
9828 int i;
9829
9830 i = findoption((char_u *)"enc");
9831 if (i >= 0)
9832 return options[i].def_val[VI_DEFAULT];
9833 return (char_u *)NULL;
9834}
9835#endif
9836
Bram Moolenaar071d4272004-06-13 20:20:40 +00009837/*
9838 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9839 */
9840 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009841find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009842{
9843 int key;
9844 int modifiers;
9845
9846 /*
9847 * Don't use get_special_key_code() for t_xx, we don't want it to call
9848 * add_termcap_entry().
9849 */
9850 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9851 key = TERMCAP2KEY(arg[2], arg[3]);
9852 else
9853 {
9854 --arg; /* put arg at the '<' */
9855 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009856 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009857 if (modifiers) /* can't handle modifiers here */
9858 key = 0;
9859 }
9860 return key;
9861}
9862
9863/*
9864 * if 'all' == 0: show changed options
9865 * if 'all' == 1: show all normal options
9866 * if 'all' == 2: show all terminal options
9867 */
9868 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009869showoptions(
9870 int all,
9871 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009872{
9873 struct vimoption *p;
9874 int col;
9875 int isterm;
9876 char_u *varp;
9877 struct vimoption **items;
9878 int item_count;
9879 int run;
9880 int row, rows;
9881 int cols;
9882 int i;
9883 int len;
9884
9885#define INC 20
9886#define GAP 3
9887
9888 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9889 PARAM_COUNT));
9890 if (items == NULL)
9891 return;
9892
9893 /* Highlight title */
9894 if (all == 2)
9895 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9896 else if (opt_flags & OPT_GLOBAL)
9897 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9898 else if (opt_flags & OPT_LOCAL)
9899 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9900 else
9901 MSG_PUTS_TITLE(_("\n--- Options ---"));
9902
9903 /*
9904 * do the loop two times:
9905 * 1. display the short items
9906 * 2. display the long items (only strings and numbers)
9907 */
9908 for (run = 1; run <= 2 && !got_int; ++run)
9909 {
9910 /*
9911 * collect the items in items[]
9912 */
9913 item_count = 0;
9914 for (p = &options[0]; p->fullname != NULL; p++)
9915 {
9916 varp = NULL;
9917 isterm = istermoption(p);
9918 if (opt_flags != 0)
9919 {
9920 if (p->indir != PV_NONE && !isterm)
9921 varp = get_varp_scope(p, opt_flags);
9922 }
9923 else
9924 varp = get_varp(p);
9925 if (varp != NULL
9926 && ((all == 2 && isterm)
9927 || (all == 1 && !isterm)
9928 || (all == 0 && !optval_default(p, varp))))
9929 {
9930 if (p->flags & P_BOOL)
9931 len = 1; /* a toggle option fits always */
9932 else
9933 {
9934 option_value2string(p, opt_flags);
9935 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9936 }
9937 if ((len <= INC - GAP && run == 1) ||
9938 (len > INC - GAP && run == 2))
9939 items[item_count++] = p;
9940 }
9941 }
9942
9943 /*
9944 * display the items
9945 */
9946 if (run == 1)
9947 {
9948 cols = (Columns + GAP - 3) / INC;
9949 if (cols == 0)
9950 cols = 1;
9951 rows = (item_count + cols - 1) / cols;
9952 }
9953 else /* run == 2 */
9954 rows = item_count;
9955 for (row = 0; row < rows && !got_int; ++row)
9956 {
9957 msg_putchar('\n'); /* go to next line */
9958 if (got_int) /* 'q' typed in more */
9959 break;
9960 col = 0;
9961 for (i = row; i < item_count; i += rows)
9962 {
9963 msg_col = col; /* make columns */
9964 showoneopt(items[i], opt_flags);
9965 col += INC;
9966 }
9967 out_flush();
9968 ui_breakcheck();
9969 }
9970 }
9971 vim_free(items);
9972}
9973
9974/*
9975 * Return TRUE if option "p" has its default value.
9976 */
9977 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009978optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009979{
9980 int dvi;
9981
9982 if (varp == NULL)
9983 return TRUE; /* hidden option is always at default */
9984 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9985 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009986 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009987 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009988 /* the cast to long is required for Manx C, long_i is
9989 * needed for MSVC */
9990 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009991 /* P_STRING */
9992 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9993}
9994
9995/*
9996 * showoneopt: show the value of one option
9997 * must not be called with a hidden option!
9998 */
9999 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010000showoneopt(
10001 struct vimoption *p,
10002 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010003{
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010004 char_u *varp;
10005 int save_silent = silent_mode;
10006
10007 silent_mode = FALSE;
10008 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010009
10010 varp = get_varp_scope(p, opt_flags);
10011
10012 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
10013 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
10014 ? !curbufIsChanged() : !*(int *)varp))
10015 MSG_PUTS("no");
10016 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
10017 MSG_PUTS("--");
10018 else
10019 MSG_PUTS(" ");
10020 MSG_PUTS(p->fullname);
10021 if (!(p->flags & P_BOOL))
10022 {
10023 msg_putchar('=');
10024 /* put value string in NameBuff */
10025 option_value2string(p, opt_flags);
10026 msg_outtrans(NameBuff);
10027 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010028
10029 silent_mode = save_silent;
10030 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010031}
10032
10033/*
10034 * Write modified options as ":set" commands to a file.
10035 *
10036 * There are three values for "opt_flags":
10037 * OPT_GLOBAL: Write global option values and fresh values of
10038 * buffer-local options (used for start of a session
10039 * file).
10040 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
10041 * curwin (used for a vimrc file).
10042 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
10043 * and local values for window-local options of
10044 * curwin. Local values are also written when at the
10045 * default value, because a modeline or autocommand
10046 * may have set them when doing ":edit file" and the
10047 * user has set them back at the default or fresh
10048 * value.
10049 * When "local_only" is TRUE, don't write fresh
10050 * values, only local values (for ":mkview").
10051 * (fresh value = value used for a new buffer or window for a local option).
10052 *
10053 * Return FAIL on error, OK otherwise.
10054 */
10055 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010056makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010057{
10058 struct vimoption *p;
10059 char_u *varp; /* currently used value */
10060 char_u *varp_fresh; /* local value */
10061 char_u *varp_local = NULL; /* fresh value */
10062 char *cmd;
10063 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010064 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010065
10066 /*
10067 * The options that don't have a default (terminal name, columns, lines)
10068 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010069 * Do the loop over "options[]" twice: once for options with the
10070 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010071 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010072 for (pri = 1; pri >= 0; --pri)
10073 {
10074 for (p = &options[0]; !istermoption(p); p++)
10075 if (!(p->flags & P_NO_MKRC)
10076 && !istermoption(p)
10077 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010078 {
10079 /* skip global option when only doing locals */
10080 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10081 continue;
10082
10083 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10084 * file, they are always buffer-specific. */
10085 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10086 continue;
10087
10088 /* Global values are only written when not at the default value. */
10089 varp = get_varp_scope(p, opt_flags);
10090 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10091 continue;
10092
10093 round = 2;
10094 if (p->indir != PV_NONE)
10095 {
10096 if (p->var == VAR_WIN)
10097 {
10098 /* skip window-local option when only doing globals */
10099 if (!(opt_flags & OPT_LOCAL))
10100 continue;
10101 /* When fresh value of window-local option is not at the
10102 * default, need to write it too. */
10103 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10104 {
10105 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10106 if (!optval_default(p, varp_fresh))
10107 {
10108 round = 1;
10109 varp_local = varp;
10110 varp = varp_fresh;
10111 }
10112 }
10113 }
10114 }
10115
10116 /* Round 1: fresh value for window-local options.
10117 * Round 2: other values */
10118 for ( ; round <= 2; varp = varp_local, ++round)
10119 {
10120 if (round == 1 || (opt_flags & OPT_GLOBAL))
10121 cmd = "set";
10122 else
10123 cmd = "setlocal";
10124
10125 if (p->flags & P_BOOL)
10126 {
10127 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10128 return FAIL;
10129 }
10130 else if (p->flags & P_NUM)
10131 {
10132 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10133 return FAIL;
10134 }
10135 else /* P_STRING */
10136 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010137#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10138 int do_endif = FALSE;
10139
Bram Moolenaar071d4272004-06-13 20:20:40 +000010140 /* Don't set 'syntax' and 'filetype' again if the value is
10141 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010142 if (
10143# if defined(FEAT_SYN_HL)
10144 p->indir == PV_SYN
10145# if defined(FEAT_AUTOCMD)
10146 ||
10147# endif
10148# endif
10149# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010150 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010151# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010152 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010153 {
10154 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10155 *(char_u **)(varp)) < 0
10156 || put_eol(fd) < 0)
10157 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010158 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010159 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010160#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010161 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10162 (p->flags & P_EXPAND) != 0) == FAIL)
10163 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010164#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10165 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010166 {
10167 if (put_line(fd, "endif") == FAIL)
10168 return FAIL;
10169 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010170#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010171 }
10172 }
10173 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010174 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010175 return OK;
10176}
10177
10178#if defined(FEAT_FOLDING) || defined(PROTO)
10179/*
10180 * Generate set commands for the local fold options only. Used when
10181 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10182 */
10183 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010184makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010185{
10186 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10187# ifdef FEAT_EVAL
10188 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10189 == FAIL
10190# endif
10191 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10192 == FAIL
10193 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10194 == FAIL
10195 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10196 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10197 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10198 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10199 )
10200 return FAIL;
10201
10202 return OK;
10203}
10204#endif
10205
10206 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010207put_setstring(
10208 FILE *fd,
10209 char *cmd,
10210 char *name,
10211 char_u **valuep,
10212 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010213{
10214 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010215 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010216
10217 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10218 return FAIL;
10219 if (*valuep != NULL)
10220 {
10221 /* Output 'pastetoggle' as key names. For other
10222 * options some characters have to be escaped with
10223 * CTRL-V or backslash */
10224 if (valuep == &p_pt)
10225 {
10226 s = *valuep;
10227 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010228 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010229 return FAIL;
10230 }
10231 else if (expand)
10232 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010233 buf = alloc(MAXPATHL);
10234 if (buf == NULL)
10235 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010236 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10237 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010238 {
10239 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010240 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010241 }
10242 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010243 }
10244 else if (put_escstr(fd, *valuep, 2) == FAIL)
10245 return FAIL;
10246 }
10247 if (put_eol(fd) < 0)
10248 return FAIL;
10249 return OK;
10250}
10251
10252 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010253put_setnum(
10254 FILE *fd,
10255 char *cmd,
10256 char *name,
10257 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010258{
10259 long wc;
10260
10261 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10262 return FAIL;
10263 if (wc_use_keyname((char_u *)valuep, &wc))
10264 {
10265 /* print 'wildchar' and 'wildcharm' as a key name */
10266 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10267 return FAIL;
10268 }
10269 else if (fprintf(fd, "%ld", *valuep) < 0)
10270 return FAIL;
10271 if (put_eol(fd) < 0)
10272 return FAIL;
10273 return OK;
10274}
10275
10276 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010277put_setbool(
10278 FILE *fd,
10279 char *cmd,
10280 char *name,
10281 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010282{
Bram Moolenaar893de922007-10-02 18:40:57 +000010283 if (value < 0) /* global/local option using global value */
10284 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010285 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10286 || put_eol(fd) < 0)
10287 return FAIL;
10288 return OK;
10289}
10290
10291/*
10292 * Clear all the terminal options.
10293 * If the option has been allocated, free the memory.
10294 * Terminal options are never hidden or indirect.
10295 */
10296 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010297clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010298{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010299 /*
10300 * Reset a few things before clearing the old options. This may cause
10301 * outputting a few things that the terminal doesn't understand, but the
10302 * screen will be cleared later, so this is OK.
10303 */
10304#ifdef FEAT_MOUSE_TTY
10305 mch_setmouse(FALSE); /* switch mouse off */
10306#endif
10307#ifdef FEAT_TITLE
10308 mch_restore_title(3); /* restore window titles */
10309#endif
10310#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10311 /* When starting the GUI close the display opened for the clipboard.
10312 * After restoring the title, because that will need the display. */
10313 if (gui.starting)
10314 clear_xterm_clip();
10315#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010316 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010317
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010318 free_termoptions();
10319}
10320
10321 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010322free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010323{
10324 struct vimoption *p;
10325
Bram Moolenaar071d4272004-06-13 20:20:40 +000010326 for (p = &options[0]; p->fullname != NULL; p++)
10327 if (istermoption(p))
10328 {
10329 if (p->flags & P_ALLOCED)
10330 free_string_option(*(char_u **)(p->var));
10331 if (p->flags & P_DEF_ALLOCED)
10332 free_string_option(p->def_val[VI_DEFAULT]);
10333 *(char_u **)(p->var) = empty_option;
10334 p->def_val[VI_DEFAULT] = empty_option;
10335 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10336 }
10337 clear_termcodes();
10338}
10339
10340/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010341 * Free the string for one term option, if it was allocated.
10342 * Set the string to empty_option and clear allocated flag.
10343 * "var" points to the option value.
10344 */
10345 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010346free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010347{
10348 struct vimoption *p;
10349
10350 for (p = &options[0]; p->fullname != NULL; p++)
10351 if (p->var == var)
10352 {
10353 if (p->flags & P_ALLOCED)
10354 free_string_option(*(char_u **)(p->var));
10355 *(char_u **)(p->var) = empty_option;
10356 p->flags &= ~P_ALLOCED;
10357 break;
10358 }
10359}
10360
10361/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010362 * Set the terminal option defaults to the current value.
10363 * Used after setting the terminal name.
10364 */
10365 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010366set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010367{
10368 struct vimoption *p;
10369
10370 for (p = &options[0]; p->fullname != NULL; p++)
10371 {
10372 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10373 {
10374 if (p->flags & P_DEF_ALLOCED)
10375 {
10376 free_string_option(p->def_val[VI_DEFAULT]);
10377 p->flags &= ~P_DEF_ALLOCED;
10378 }
10379 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10380 if (p->flags & P_ALLOCED)
10381 {
10382 p->flags |= P_DEF_ALLOCED;
10383 p->flags &= ~P_ALLOCED; /* don't free the value now */
10384 }
10385 }
10386 }
10387}
10388
10389/*
10390 * return TRUE if 'p' starts with 't_'
10391 */
10392 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010393istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010394{
10395 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10396}
10397
10398/*
10399 * Compute columns for ruler and shown command. 'sc_col' is also used to
10400 * decide what the maximum length of a message on the status line can be.
10401 * If there is a status line for the last window, 'sc_col' is independent
10402 * of 'ru_col'.
10403 */
10404
10405#define COL_RULER 17 /* columns needed by standard ruler */
10406
10407 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010408comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010409{
10410#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010411 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010412
10413 sc_col = 0;
10414 ru_col = 0;
10415 if (p_ru)
10416 {
10417#ifdef FEAT_STL_OPT
10418 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10419#else
10420 ru_col = COL_RULER + 1;
10421#endif
10422 /* no last status line, adjust sc_col */
10423 if (!last_has_status)
10424 sc_col = ru_col;
10425 }
10426 if (p_sc)
10427 {
10428 sc_col += SHOWCMD_COLS;
10429 if (!p_ru || last_has_status) /* no need for separating space */
10430 ++sc_col;
10431 }
10432 sc_col = Columns - sc_col;
10433 ru_col = Columns - ru_col;
10434 if (sc_col <= 0) /* screen too narrow, will become a mess */
10435 sc_col = 1;
10436 if (ru_col <= 0)
10437 ru_col = 1;
10438#else
10439 sc_col = Columns;
10440 ru_col = Columns;
10441#endif
10442}
10443
10444/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010445 * Unset local option value, similar to ":set opt<".
10446 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010447 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010448unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010449{
10450 struct vimoption *p;
10451 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010452 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010453
10454 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010455 if (opt_idx < 0)
10456 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010457 p = &(options[opt_idx]);
10458
10459 switch ((int)p->indir)
10460 {
10461 /* global option with local value: use local value if it's been set */
10462 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010463 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010464 break;
10465 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010466 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010467 break;
10468 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010469 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010470 break;
10471 case PV_AR:
10472 buf->b_p_ar = -1;
10473 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010474 case PV_BKC:
10475 clear_string_option(&buf->b_p_bkc);
10476 buf->b_bkc_flags = 0;
10477 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010478 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010479 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010480 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010481 case PV_TC:
10482 clear_string_option(&buf->b_p_tc);
10483 buf->b_tc_flags = 0;
10484 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010485#ifdef FEAT_FIND_ID
10486 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010487 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010488 break;
10489 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010490 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010491 break;
10492#endif
10493#ifdef FEAT_INS_EXPAND
10494 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010495 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010496 break;
10497 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010498 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010499 break;
10500#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010501 case PV_FP:
10502 clear_string_option(&buf->b_p_fp);
10503 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010504#ifdef FEAT_QUICKFIX
10505 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010506 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010507 break;
10508 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010509 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010510 break;
10511 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010512 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010513 break;
10514#endif
10515#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10516 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010517 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010518 break;
10519#endif
10520#if defined(FEAT_CRYPT)
10521 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010522 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010523 break;
10524#endif
10525#ifdef FEAT_STL_OPT
10526 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010527 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010528 break;
10529#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010530 case PV_UL:
10531 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10532 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010533#ifdef FEAT_LISP
10534 case PV_LW:
10535 clear_string_option(&buf->b_p_lw);
10536 break;
10537#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010538#ifdef FEAT_MBYTE
10539 case PV_MENC:
10540 clear_string_option(&buf->b_p_menc);
10541 break;
10542#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010543 }
10544}
10545
10546/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010547 * Get pointer to option variable, depending on local or global scope.
10548 */
10549 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010550get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010551{
10552 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10553 {
10554 if (p->var == VAR_WIN)
10555 return (char_u *)GLOBAL_WO(get_varp(p));
10556 return p->var;
10557 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010558 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010559 {
10560 switch ((int)p->indir)
10561 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010562 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010563#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010564 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10565 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10566 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010567#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010568 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10569 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10570 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010571 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010572 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010573 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010574#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010575 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10576 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010577#endif
10578#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010579 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10580 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010581#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010582#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10583 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10584#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010585#if defined(FEAT_CRYPT)
10586 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10587#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010588#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010589 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010590#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010591 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010592#ifdef FEAT_LISP
10593 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10594#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010595 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010596#ifdef FEAT_MBYTE
10597 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10598#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010599 }
10600 return NULL; /* "cannot happen" */
10601 }
10602 return get_varp(p);
10603}
10604
10605/*
10606 * Get pointer to option variable.
10607 */
10608 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010609get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010610{
10611 /* hidden option, always return NULL */
10612 if (p->var == NULL)
10613 return NULL;
10614
10615 switch ((int)p->indir)
10616 {
10617 case PV_NONE: return p->var;
10618
10619 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010620 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010621 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010622 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010623 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010624 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010625 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010626 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010627 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010628 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010629 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010630 case PV_TC: return *curbuf->b_p_tc != NUL
10631 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010632 case PV_BKC: return *curbuf->b_p_bkc != NUL
10633 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010634#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010635 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010636 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010637 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010638 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10639#endif
10640#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010641 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010642 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010643 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010644 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10645#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010646 case PV_FP: return *curbuf->b_p_fp != NUL
10647 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010648#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010649 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010650 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010651 case PV_GP: return *curbuf->b_p_gp != NUL
10652 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10653 case PV_MP: return *curbuf->b_p_mp != NUL
10654 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010655#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010656#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10657 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10658 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10659#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010660#if defined(FEAT_CRYPT)
10661 case PV_CM: return *curbuf->b_p_cm != NUL
10662 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10663#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010664#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010665 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010666 ? (char_u *)&(curwin->w_p_stl) : p->var;
10667#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010668 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10669 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010670#ifdef FEAT_LISP
10671 case PV_LW: return *curbuf->b_p_lw != NUL
10672 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10673#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010674#ifdef FEAT_MBYTE
10675 case PV_MENC: return *curbuf->b_p_menc != NUL
10676 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10677#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010678
10679#ifdef FEAT_ARABIC
10680 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10681#endif
10682 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010683#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010684 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10685#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010686#ifdef FEAT_SYN_HL
10687 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10688 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010689 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010690#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010691#ifdef FEAT_DIFF
10692 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10693#endif
10694#ifdef FEAT_FOLDING
10695 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10696 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10697 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10698 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10699 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10700 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10701 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10702# ifdef FEAT_EVAL
10703 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10704 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10705# endif
10706 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10707#endif
10708 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010709 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010710#ifdef FEAT_LINEBREAK
10711 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10712#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010713#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010714 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010715 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10716#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010717#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10718 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10719#endif
10720#ifdef FEAT_RIGHTLEFT
10721 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10722 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10723#endif
10724 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10725 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10726#ifdef FEAT_LINEBREAK
10727 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010728 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10729 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010730#endif
10731#ifdef FEAT_SCROLLBIND
10732 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10733#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010734#ifdef FEAT_CURSORBIND
10735 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10736#endif
10737#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010738 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10739 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10740#endif
10741#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +020010742 case PV_TK: return (char_u *)&(curwin->w_p_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010743 case PV_TMS: return (char_u *)&(curwin->w_p_tms);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010744#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010745
10746 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10747 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10748#ifdef FEAT_MBYTE
10749 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10750#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010751 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10752 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010753 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10754 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10755#ifdef FEAT_CINDENT
10756 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10757 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10758 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10759#endif
10760#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10761 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10762#endif
10763#ifdef FEAT_COMMENTS
10764 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10765#endif
10766#ifdef FEAT_FOLDING
10767 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10768#endif
10769#ifdef FEAT_INS_EXPAND
10770 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10771#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010772#ifdef FEAT_COMPL_FUNC
10773 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010774 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010775#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010776 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010777 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010778 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10779#ifdef FEAT_MBYTE
10780 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10781#endif
10782 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10783#ifdef FEAT_AUTOCMD
10784 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10785#endif
10786 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010787 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010788 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10789 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10790 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10791 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10792#ifdef FEAT_FIND_ID
10793# ifdef FEAT_EVAL
10794 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10795# endif
10796#endif
10797#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10798 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10799 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10800#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010801#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010802 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10803#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010804#ifdef FEAT_CRYPT
10805 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10806#endif
10807#ifdef FEAT_LISP
10808 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10809#endif
10810 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10811 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10812 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10813 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10814 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010815 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010816#ifdef FEAT_TEXTOBJ
10817 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10818#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010819 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10820#ifdef FEAT_SMARTINDENT
10821 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10822#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010823 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10825#ifdef FEAT_SEARCHPATH
10826 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10827#endif
10828 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10829#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010830 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010831 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10832#endif
10833#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010834 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10835 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10836 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010837#endif
10838 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10839 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10840 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10841 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010842#ifdef FEAT_PERSISTENT_UNDO
10843 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10844#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010845 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10846#ifdef FEAT_KEYMAP
10847 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10848#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010849#ifdef FEAT_SIGNS
10850 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10851#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010852 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010853 }
10854 /* always return a valid pointer to avoid a crash! */
10855 return (char_u *)&(curbuf->b_p_wm);
10856}
10857
10858/*
10859 * Get the value of 'equalprg', either the buffer-local one or the global one.
10860 */
10861 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010862get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010863{
10864 if (*curbuf->b_p_ep == NUL)
10865 return p_ep;
10866 return curbuf->b_p_ep;
10867}
10868
10869#if defined(FEAT_WINDOWS) || defined(PROTO)
10870/*
10871 * Copy options from one window to another.
10872 * Used when splitting a window.
10873 */
10874 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010875win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010876{
10877 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10878 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10879# ifdef FEAT_RIGHTLEFT
10880# ifdef FEAT_FKMAP
10881 /* Is this right? */
10882 wp_to->w_farsi = wp_from->w_farsi;
10883# endif
10884# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010885#if defined(FEAT_LINEBREAK)
10886 briopt_check(wp_to);
10887#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010888}
10889#endif
10890
10891/*
10892 * Copy the options from one winopt_T to another.
10893 * Doesn't free the old option values in "to", use clear_winopt() for that.
10894 * The 'scroll' option is not copied, because it depends on the window height.
10895 * The 'previewwindow' option is reset, there can be only one preview window.
10896 */
10897 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010898copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010899{
10900#ifdef FEAT_ARABIC
10901 to->wo_arab = from->wo_arab;
10902#endif
10903 to->wo_list = from->wo_list;
10904 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010905 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010906#ifdef FEAT_LINEBREAK
10907 to->wo_nuw = from->wo_nuw;
10908#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010909#ifdef FEAT_RIGHTLEFT
10910 to->wo_rl = from->wo_rl;
10911 to->wo_rlc = vim_strsave(from->wo_rlc);
10912#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010913#ifdef FEAT_STL_OPT
10914 to->wo_stl = vim_strsave(from->wo_stl);
10915#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010916 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010917#ifdef FEAT_DIFF
10918 to->wo_wrap_save = from->wo_wrap_save;
10919#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010920#ifdef FEAT_LINEBREAK
10921 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010922 to->wo_bri = from->wo_bri;
10923 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010924#endif
10925#ifdef FEAT_SCROLLBIND
10926 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010927 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010928#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010929#ifdef FEAT_CURSORBIND
10930 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010931 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010932#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010933#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010934 to->wo_spell = from->wo_spell;
10935#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010936#ifdef FEAT_SYN_HL
10937 to->wo_cuc = from->wo_cuc;
10938 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010939 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010940#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010941#ifdef FEAT_DIFF
10942 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010943 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010944#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010945#ifdef FEAT_CONCEAL
10946 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010947 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010948#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010949#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010950 to->wo_tk = vim_strsave(from->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010951 to->wo_tms = vim_strsave(from->wo_tms);
10952#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010953#ifdef FEAT_FOLDING
10954 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010955 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010956 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010957 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010958 to->wo_fdi = vim_strsave(from->wo_fdi);
10959 to->wo_fml = from->wo_fml;
10960 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010961 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010962 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010963 to->wo_fdm_save = from->wo_diff_saved
10964 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010965 to->wo_fdn = from->wo_fdn;
10966# ifdef FEAT_EVAL
10967 to->wo_fde = vim_strsave(from->wo_fde);
10968 to->wo_fdt = vim_strsave(from->wo_fdt);
10969# endif
10970 to->wo_fmr = vim_strsave(from->wo_fmr);
10971#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010972#ifdef FEAT_SIGNS
10973 to->wo_scl = vim_strsave(from->wo_scl);
10974#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010975 check_winopt(to); /* don't want NULL pointers */
10976}
10977
10978/*
10979 * Check string options in a window for a NULL value.
10980 */
10981 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010982check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010983{
10984 check_winopt(&win->w_onebuf_opt);
10985 check_winopt(&win->w_allbuf_opt);
10986}
10987
10988/*
10989 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10990 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010991 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010992check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010993{
10994#ifdef FEAT_FOLDING
10995 check_string_option(&wop->wo_fdi);
10996 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010997 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010998# ifdef FEAT_EVAL
10999 check_string_option(&wop->wo_fde);
11000 check_string_option(&wop->wo_fdt);
11001# endif
11002 check_string_option(&wop->wo_fmr);
11003#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011004#ifdef FEAT_SIGNS
11005 check_string_option(&wop->wo_scl);
11006#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011007#ifdef FEAT_RIGHTLEFT
11008 check_string_option(&wop->wo_rlc);
11009#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011010#ifdef FEAT_STL_OPT
11011 check_string_option(&wop->wo_stl);
11012#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011013#ifdef FEAT_SYN_HL
11014 check_string_option(&wop->wo_cc);
11015#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011016#ifdef FEAT_CONCEAL
11017 check_string_option(&wop->wo_cocu);
11018#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011019#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011020 check_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011021 check_string_option(&wop->wo_tms);
11022#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011023#ifdef FEAT_LINEBREAK
11024 check_string_option(&wop->wo_briopt);
11025#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011026}
11027
11028/*
11029 * Free the allocated memory inside a winopt_T.
11030 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011031 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011032clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011033{
11034#ifdef FEAT_FOLDING
11035 clear_string_option(&wop->wo_fdi);
11036 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011037 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011038# ifdef FEAT_EVAL
11039 clear_string_option(&wop->wo_fde);
11040 clear_string_option(&wop->wo_fdt);
11041# endif
11042 clear_string_option(&wop->wo_fmr);
11043#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011044#ifdef FEAT_SIGNS
11045 clear_string_option(&wop->wo_scl);
11046#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011047#ifdef FEAT_LINEBREAK
11048 clear_string_option(&wop->wo_briopt);
11049#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011050#ifdef FEAT_RIGHTLEFT
11051 clear_string_option(&wop->wo_rlc);
11052#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011053#ifdef FEAT_STL_OPT
11054 clear_string_option(&wop->wo_stl);
11055#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011056#ifdef FEAT_SYN_HL
11057 clear_string_option(&wop->wo_cc);
11058#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011059#ifdef FEAT_CONCEAL
11060 clear_string_option(&wop->wo_cocu);
11061#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011062#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011063 clear_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011064 clear_string_option(&wop->wo_tms);
11065#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011066}
11067
11068/*
11069 * Copy global option values to local options for one buffer.
11070 * Used when creating a new buffer and sometimes when entering a buffer.
11071 * flags:
11072 * BCO_ENTER We will enter the buf buffer.
11073 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11074 * appropriate.
11075 * BCO_NOHELP Don't copy the values to a help buffer.
11076 */
11077 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011078buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011079{
11080 int should_copy = TRUE;
11081 char_u *save_p_isk = NULL; /* init for GCC */
11082 int dont_do_help;
11083 int did_isk = FALSE;
11084
11085 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011086 * Skip this when the option defaults have not been set yet. Happens when
11087 * main() allocates the first buffer.
11088 */
11089 if (p_cpo != NULL)
11090 {
11091 /*
11092 * Always copy when entering and 'cpo' contains 'S'.
11093 * Don't copy when already initialized.
11094 * Don't copy when 'cpo' contains 's' and not entering.
11095 * 'S' BCO_ENTER initialized 's' should_copy
11096 * yes yes X X TRUE
11097 * yes no yes X FALSE
11098 * no X yes X FALSE
11099 * X no no yes FALSE
11100 * X no no no TRUE
11101 * no yes no X TRUE
11102 */
11103 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11104 && (buf->b_p_initialized
11105 || (!(flags & BCO_ENTER)
11106 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11107 should_copy = FALSE;
11108
11109 if (should_copy || (flags & BCO_ALWAYS))
11110 {
11111 /* Don't copy the options specific to a help buffer when
11112 * BCO_NOHELP is given or the options were initialized already
11113 * (jumping back to a help file with CTRL-T or CTRL-O) */
11114 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11115 || buf->b_p_initialized;
11116 if (dont_do_help) /* don't free b_p_isk */
11117 {
11118 save_p_isk = buf->b_p_isk;
11119 buf->b_p_isk = NULL;
11120 }
11121 /*
11122 * Always free the allocated strings.
11123 * If not already initialized, set 'readonly' and copy 'fileformat'.
11124 */
11125 if (!buf->b_p_initialized)
11126 {
11127 free_buf_options(buf, TRUE);
11128 buf->b_p_ro = FALSE; /* don't copy readonly */
11129 buf->b_p_tx = p_tx;
11130#ifdef FEAT_MBYTE
11131 buf->b_p_fenc = vim_strsave(p_fenc);
11132#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011133 switch (*p_ffs)
11134 {
11135 case 'm':
11136 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11137 case 'd':
11138 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11139 case 'u':
11140 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11141 default:
11142 buf->b_p_ff = vim_strsave(p_ff);
11143 }
11144 if (buf->b_p_ff != NULL)
11145 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011146 buf->b_p_bh = empty_option;
11147 buf->b_p_bt = empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011148 }
11149 else
11150 free_buf_options(buf, FALSE);
11151
11152 buf->b_p_ai = p_ai;
11153 buf->b_p_ai_nopaste = p_ai_nopaste;
11154 buf->b_p_sw = p_sw;
11155 buf->b_p_tw = p_tw;
11156 buf->b_p_tw_nopaste = p_tw_nopaste;
11157 buf->b_p_tw_nobin = p_tw_nobin;
11158 buf->b_p_wm = p_wm;
11159 buf->b_p_wm_nopaste = p_wm_nopaste;
11160 buf->b_p_wm_nobin = p_wm_nobin;
11161 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011162#ifdef FEAT_MBYTE
11163 buf->b_p_bomb = p_bomb;
11164#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011165 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011166 buf->b_p_et = p_et;
11167 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011168 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011169 buf->b_p_ml = p_ml;
11170 buf->b_p_ml_nobin = p_ml_nobin;
11171 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011172 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011173#ifdef FEAT_INS_EXPAND
11174 buf->b_p_cpt = vim_strsave(p_cpt);
11175#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011176#ifdef FEAT_COMPL_FUNC
11177 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011178 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011179#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011180 buf->b_p_sts = p_sts;
11181 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011182 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011183#ifdef FEAT_COMMENTS
11184 buf->b_p_com = vim_strsave(p_com);
11185#endif
11186#ifdef FEAT_FOLDING
11187 buf->b_p_cms = vim_strsave(p_cms);
11188#endif
11189 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011190 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011191 buf->b_p_nf = vim_strsave(p_nf);
11192 buf->b_p_mps = vim_strsave(p_mps);
11193#ifdef FEAT_SMARTINDENT
11194 buf->b_p_si = p_si;
11195#endif
11196 buf->b_p_ci = p_ci;
11197#ifdef FEAT_CINDENT
11198 buf->b_p_cin = p_cin;
11199 buf->b_p_cink = vim_strsave(p_cink);
11200 buf->b_p_cino = vim_strsave(p_cino);
11201#endif
11202#ifdef FEAT_AUTOCMD
11203 /* Don't copy 'filetype', it must be detected */
11204 buf->b_p_ft = empty_option;
11205#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011206 buf->b_p_pi = p_pi;
11207#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11208 buf->b_p_cinw = vim_strsave(p_cinw);
11209#endif
11210#ifdef FEAT_LISP
11211 buf->b_p_lisp = p_lisp;
11212#endif
11213#ifdef FEAT_SYN_HL
11214 /* Don't copy 'syntax', it must be set */
11215 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011216 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011217 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011218#endif
11219#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011220 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011221 (void)compile_cap_prog(&buf->b_s);
11222 buf->b_s.b_p_spf = vim_strsave(p_spf);
11223 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011224#endif
11225#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11226 buf->b_p_inde = vim_strsave(p_inde);
11227 buf->b_p_indk = vim_strsave(p_indk);
11228#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011229 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011230#if defined(FEAT_EVAL)
11231 buf->b_p_fex = vim_strsave(p_fex);
11232#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011233#ifdef FEAT_CRYPT
11234 buf->b_p_key = vim_strsave(p_key);
11235#endif
11236#ifdef FEAT_SEARCHPATH
11237 buf->b_p_sua = vim_strsave(p_sua);
11238#endif
11239#ifdef FEAT_KEYMAP
11240 buf->b_p_keymap = vim_strsave(p_keymap);
11241 buf->b_kmap_state |= KEYMAP_INIT;
11242#endif
11243 /* This isn't really an option, but copying the langmap and IME
11244 * state from the current buffer is better than resetting it. */
11245 buf->b_p_iminsert = p_iminsert;
11246 buf->b_p_imsearch = p_imsearch;
11247
11248 /* options that are normally global but also have a local value
11249 * are not copied, start using the global value */
11250 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011251 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011252 buf->b_p_bkc = empty_option;
11253 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011254#ifdef FEAT_QUICKFIX
11255 buf->b_p_gp = empty_option;
11256 buf->b_p_mp = empty_option;
11257 buf->b_p_efm = empty_option;
11258#endif
11259 buf->b_p_ep = empty_option;
11260 buf->b_p_kp = empty_option;
11261 buf->b_p_path = empty_option;
11262 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011263 buf->b_p_tc = empty_option;
11264 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011265#ifdef FEAT_FIND_ID
11266 buf->b_p_def = empty_option;
11267 buf->b_p_inc = empty_option;
11268# ifdef FEAT_EVAL
11269 buf->b_p_inex = vim_strsave(p_inex);
11270# endif
11271#endif
11272#ifdef FEAT_INS_EXPAND
11273 buf->b_p_dict = empty_option;
11274 buf->b_p_tsr = empty_option;
11275#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011276#ifdef FEAT_TEXTOBJ
11277 buf->b_p_qe = vim_strsave(p_qe);
11278#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011279#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11280 buf->b_p_bexpr = empty_option;
11281#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011282#if defined(FEAT_CRYPT)
11283 buf->b_p_cm = empty_option;
11284#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011285#ifdef FEAT_PERSISTENT_UNDO
11286 buf->b_p_udf = p_udf;
11287#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011288#ifdef FEAT_LISP
11289 buf->b_p_lw = empty_option;
11290#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011291#ifdef FEAT_MBYTE
11292 buf->b_p_menc = empty_option;
11293#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011294
11295 /*
11296 * Don't copy the options set by ex_help(), use the saved values,
11297 * when going from a help buffer to a non-help buffer.
11298 * Don't touch these at all when BCO_NOHELP is used and going from
11299 * or to a help buffer.
11300 */
11301 if (dont_do_help)
11302 buf->b_p_isk = save_p_isk;
11303 else
11304 {
11305 buf->b_p_isk = vim_strsave(p_isk);
11306 did_isk = TRUE;
11307 buf->b_p_ts = p_ts;
11308 buf->b_help = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011309 if (buf->b_p_bt[0] == 'h')
11310 clear_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011311 buf->b_p_ma = p_ma;
11312 }
11313 }
11314
11315 /*
11316 * When the options should be copied (ignoring BCO_ALWAYS), set the
11317 * flag that indicates that the options have been initialized.
11318 */
11319 if (should_copy)
11320 buf->b_p_initialized = TRUE;
11321 }
11322
11323 check_buf_options(buf); /* make sure we don't have NULLs */
11324 if (did_isk)
11325 (void)buf_init_chartab(buf, FALSE);
11326}
11327
11328/*
11329 * Reset the 'modifiable' option and its default value.
11330 */
11331 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011332reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011333{
11334 int opt_idx;
11335
11336 curbuf->b_p_ma = FALSE;
11337 p_ma = FALSE;
11338 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011339 if (opt_idx >= 0)
11340 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011341}
11342
11343/*
11344 * Set the global value for 'iminsert' to the local value.
11345 */
11346 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011347set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011348{
11349 p_iminsert = curbuf->b_p_iminsert;
11350}
11351
11352/*
11353 * Set the global value for 'imsearch' to the local value.
11354 */
11355 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011356set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011357{
11358 p_imsearch = curbuf->b_p_imsearch;
11359}
11360
11361#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11362static int expand_option_idx = -1;
11363static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11364static int expand_option_flags = 0;
11365
11366 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011367set_context_in_set_cmd(
11368 expand_T *xp,
11369 char_u *arg,
11370 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011371{
11372 int nextchar;
11373 long_u flags = 0; /* init for GCC */
11374 int opt_idx = 0; /* init for GCC */
11375 char_u *p;
11376 char_u *s;
11377 int is_term_option = FALSE;
11378 int key;
11379
11380 expand_option_flags = opt_flags;
11381
11382 xp->xp_context = EXPAND_SETTINGS;
11383 if (*arg == NUL)
11384 {
11385 xp->xp_pattern = arg;
11386 return;
11387 }
11388 p = arg + STRLEN(arg) - 1;
11389 if (*p == ' ' && *(p - 1) != '\\')
11390 {
11391 xp->xp_pattern = p + 1;
11392 return;
11393 }
11394 while (p > arg)
11395 {
11396 s = p;
11397 /* count number of backslashes before ' ' or ',' */
11398 if (*p == ' ' || *p == ',')
11399 {
11400 while (s > arg && *(s - 1) == '\\')
11401 --s;
11402 }
11403 /* break at a space with an even number of backslashes */
11404 if (*p == ' ' && ((p - s) & 1) == 0)
11405 {
11406 ++p;
11407 break;
11408 }
11409 --p;
11410 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011411 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011412 {
11413 xp->xp_context = EXPAND_BOOL_SETTINGS;
11414 p += 2;
11415 }
11416 if (STRNCMP(p, "inv", 3) == 0)
11417 {
11418 xp->xp_context = EXPAND_BOOL_SETTINGS;
11419 p += 3;
11420 }
11421 xp->xp_pattern = arg = p;
11422 if (*arg == '<')
11423 {
11424 while (*p != '>')
11425 if (*p++ == NUL) /* expand terminal option name */
11426 return;
11427 key = get_special_key_code(arg + 1);
11428 if (key == 0) /* unknown name */
11429 {
11430 xp->xp_context = EXPAND_NOTHING;
11431 return;
11432 }
11433 nextchar = *++p;
11434 is_term_option = TRUE;
11435 expand_option_name[2] = KEY2TERMCAP0(key);
11436 expand_option_name[3] = KEY2TERMCAP1(key);
11437 }
11438 else
11439 {
11440 if (p[0] == 't' && p[1] == '_')
11441 {
11442 p += 2;
11443 if (*p != NUL)
11444 ++p;
11445 if (*p == NUL)
11446 return; /* expand option name */
11447 nextchar = *++p;
11448 is_term_option = TRUE;
11449 expand_option_name[2] = p[-2];
11450 expand_option_name[3] = p[-1];
11451 }
11452 else
11453 {
11454 /* Allow * wildcard */
11455 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11456 p++;
11457 if (*p == NUL)
11458 return;
11459 nextchar = *p;
11460 *p = NUL;
11461 opt_idx = findoption(arg);
11462 *p = nextchar;
11463 if (opt_idx == -1 || options[opt_idx].var == NULL)
11464 {
11465 xp->xp_context = EXPAND_NOTHING;
11466 return;
11467 }
11468 flags = options[opt_idx].flags;
11469 if (flags & P_BOOL)
11470 {
11471 xp->xp_context = EXPAND_NOTHING;
11472 return;
11473 }
11474 }
11475 }
11476 /* handle "-=" and "+=" */
11477 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11478 {
11479 ++p;
11480 nextchar = '=';
11481 }
11482 if ((nextchar != '=' && nextchar != ':')
11483 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11484 {
11485 xp->xp_context = EXPAND_UNSUCCESSFUL;
11486 return;
11487 }
11488 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11489 {
11490 xp->xp_context = EXPAND_OLD_SETTING;
11491 if (is_term_option)
11492 expand_option_idx = -1;
11493 else
11494 expand_option_idx = opt_idx;
11495 xp->xp_pattern = p + 1;
11496 return;
11497 }
11498 xp->xp_context = EXPAND_NOTHING;
11499 if (is_term_option || (flags & P_NUM))
11500 return;
11501
11502 xp->xp_pattern = p + 1;
11503
11504 if (flags & P_EXPAND)
11505 {
11506 p = options[opt_idx].var;
11507 if (p == (char_u *)&p_bdir
11508 || p == (char_u *)&p_dir
11509 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011510 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011511 || p == (char_u *)&p_rtp
11512#ifdef FEAT_SEARCHPATH
11513 || p == (char_u *)&p_cdpath
11514#endif
11515#ifdef FEAT_SESSION
11516 || p == (char_u *)&p_vdir
11517#endif
11518 )
11519 {
11520 xp->xp_context = EXPAND_DIRECTORIES;
11521 if (p == (char_u *)&p_path
11522#ifdef FEAT_SEARCHPATH
11523 || p == (char_u *)&p_cdpath
11524#endif
11525 )
11526 xp->xp_backslash = XP_BS_THREE;
11527 else
11528 xp->xp_backslash = XP_BS_ONE;
11529 }
11530 else
11531 {
11532 xp->xp_context = EXPAND_FILES;
11533 /* for 'tags' need three backslashes for a space */
11534 if (p == (char_u *)&p_tags)
11535 xp->xp_backslash = XP_BS_THREE;
11536 else
11537 xp->xp_backslash = XP_BS_ONE;
11538 }
11539 }
11540
11541 /* For an option that is a list of file names, find the start of the
11542 * last file name. */
11543 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11544 {
11545 /* count number of backslashes before ' ' or ',' */
11546 if (*p == ' ' || *p == ',')
11547 {
11548 s = p;
11549 while (s > xp->xp_pattern && *(s - 1) == '\\')
11550 --s;
11551 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11552 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11553 {
11554 xp->xp_pattern = p + 1;
11555 break;
11556 }
11557 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011558
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011559#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011560 /* for 'spellsuggest' start at "file:" */
11561 if (options[opt_idx].var == (char_u *)&p_sps
11562 && STRNCMP(p, "file:", 5) == 0)
11563 {
11564 xp->xp_pattern = p + 5;
11565 break;
11566 }
11567#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011568 }
11569
11570 return;
11571}
11572
11573 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011574ExpandSettings(
11575 expand_T *xp,
11576 regmatch_T *regmatch,
11577 int *num_file,
11578 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011579{
11580 int num_normal = 0; /* Nr of matching non-term-code settings */
11581 int num_term = 0; /* Nr of matching terminal code settings */
11582 int opt_idx;
11583 int match;
11584 int count = 0;
11585 char_u *str;
11586 int loop;
11587 int is_term_opt;
11588 char_u name_buf[MAX_KEY_NAME_LEN];
11589 static char *(names[]) = {"all", "termcap"};
11590 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11591
11592 /* do this loop twice:
11593 * loop == 0: count the number of matching options
11594 * loop == 1: copy the matching options into allocated memory
11595 */
11596 for (loop = 0; loop <= 1; ++loop)
11597 {
11598 regmatch->rm_ic = ic;
11599 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11600 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011601 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11602 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011603 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11604 {
11605 if (loop == 0)
11606 num_normal++;
11607 else
11608 (*file)[count++] = vim_strsave((char_u *)names[match]);
11609 }
11610 }
11611 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11612 opt_idx++)
11613 {
11614 if (options[opt_idx].var == NULL)
11615 continue;
11616 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11617 && !(options[opt_idx].flags & P_BOOL))
11618 continue;
11619 is_term_opt = istermoption(&options[opt_idx]);
11620 if (is_term_opt && num_normal > 0)
11621 continue;
11622 match = FALSE;
11623 if (vim_regexec(regmatch, str, (colnr_T)0)
11624 || (options[opt_idx].shortname != NULL
11625 && vim_regexec(regmatch,
11626 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11627 match = TRUE;
11628 else if (is_term_opt)
11629 {
11630 name_buf[0] = '<';
11631 name_buf[1] = 't';
11632 name_buf[2] = '_';
11633 name_buf[3] = str[2];
11634 name_buf[4] = str[3];
11635 name_buf[5] = '>';
11636 name_buf[6] = NUL;
11637 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11638 {
11639 match = TRUE;
11640 str = name_buf;
11641 }
11642 }
11643 if (match)
11644 {
11645 if (loop == 0)
11646 {
11647 if (is_term_opt)
11648 num_term++;
11649 else
11650 num_normal++;
11651 }
11652 else
11653 (*file)[count++] = vim_strsave(str);
11654 }
11655 }
11656 /*
11657 * Check terminal key codes, these are not in the option table
11658 */
11659 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11660 {
11661 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11662 {
11663 if (!isprint(str[0]) || !isprint(str[1]))
11664 continue;
11665
11666 name_buf[0] = 't';
11667 name_buf[1] = '_';
11668 name_buf[2] = str[0];
11669 name_buf[3] = str[1];
11670 name_buf[4] = NUL;
11671
11672 match = FALSE;
11673 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11674 match = TRUE;
11675 else
11676 {
11677 name_buf[0] = '<';
11678 name_buf[1] = 't';
11679 name_buf[2] = '_';
11680 name_buf[3] = str[0];
11681 name_buf[4] = str[1];
11682 name_buf[5] = '>';
11683 name_buf[6] = NUL;
11684
11685 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11686 match = TRUE;
11687 }
11688 if (match)
11689 {
11690 if (loop == 0)
11691 num_term++;
11692 else
11693 (*file)[count++] = vim_strsave(name_buf);
11694 }
11695 }
11696
11697 /*
11698 * Check special key names.
11699 */
11700 regmatch->rm_ic = TRUE; /* ignore case here */
11701 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11702 {
11703 name_buf[0] = '<';
11704 STRCPY(name_buf + 1, str);
11705 STRCAT(name_buf, ">");
11706
11707 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11708 {
11709 if (loop == 0)
11710 num_term++;
11711 else
11712 (*file)[count++] = vim_strsave(name_buf);
11713 }
11714 }
11715 }
11716 if (loop == 0)
11717 {
11718 if (num_normal > 0)
11719 *num_file = num_normal;
11720 else if (num_term > 0)
11721 *num_file = num_term;
11722 else
11723 return OK;
11724 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11725 if (*file == NULL)
11726 {
11727 *file = (char_u **)"";
11728 return FAIL;
11729 }
11730 }
11731 }
11732 return OK;
11733}
11734
11735 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011736ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011737{
11738 char_u *var = NULL; /* init for GCC */
11739 char_u *buf;
11740
11741 *num_file = 0;
11742 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11743 if (*file == NULL)
11744 return FAIL;
11745
11746 /*
11747 * For a terminal key code expand_option_idx is < 0.
11748 */
11749 if (expand_option_idx < 0)
11750 {
11751 var = find_termcode(expand_option_name + 2);
11752 if (var == NULL)
11753 expand_option_idx = findoption(expand_option_name);
11754 }
11755
11756 if (expand_option_idx >= 0)
11757 {
11758 /* put string of option value in NameBuff */
11759 option_value2string(&options[expand_option_idx], expand_option_flags);
11760 var = NameBuff;
11761 }
11762 else if (var == NULL)
11763 var = (char_u *)"";
11764
11765 /* A backslash is required before some characters. This is the reverse of
11766 * what happens in do_set(). */
11767 buf = vim_strsave_escaped(var, escape_chars);
11768
11769 if (buf == NULL)
11770 {
11771 vim_free(*file);
11772 *file = NULL;
11773 return FAIL;
11774 }
11775
11776#ifdef BACKSLASH_IN_FILENAME
11777 /* For MS-Windows et al. we don't double backslashes at the start and
11778 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011779 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011780 if (var[0] == '\\' && var[1] == '\\'
11781 && expand_option_idx >= 0
11782 && (options[expand_option_idx].flags & P_EXPAND)
11783 && vim_isfilec(var[2])
11784 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011785 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011786#endif
11787
11788 *file[0] = buf;
11789 *num_file = 1;
11790 return OK;
11791}
11792#endif
11793
11794/*
11795 * Get the value for the numeric or string option *opp in a nice format into
11796 * NameBuff[]. Must not be called with a hidden option!
11797 */
11798 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011799option_value2string(
11800 struct vimoption *opp,
11801 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011802{
11803 char_u *varp;
11804
11805 varp = get_varp_scope(opp, opt_flags);
11806
11807 if (opp->flags & P_NUM)
11808 {
11809 long wc = 0;
11810
11811 if (wc_use_keyname(varp, &wc))
11812 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11813 else if (wc != 0)
11814 STRCPY(NameBuff, transchar((int)wc));
11815 else
11816 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11817 }
11818 else /* P_STRING */
11819 {
11820 varp = *(char_u **)(varp);
11821 if (varp == NULL) /* just in case */
11822 NameBuff[0] = NUL;
11823#ifdef FEAT_CRYPT
11824 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011825 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011826 STRCPY(NameBuff, "*****");
11827#endif
11828 else if (opp->flags & P_EXPAND)
11829 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11830 /* Translate 'pastetoggle' into special key names */
11831 else if ((char_u **)opp->var == &p_pt)
11832 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11833 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011834 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011835 }
11836}
11837
11838/*
11839 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11840 * printed as a keyname.
11841 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11842 */
11843 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011844wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011845{
11846 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11847 {
11848 *wcp = *(long *)varp;
11849 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11850 return TRUE;
11851 }
11852 return FALSE;
11853}
11854
Bram Moolenaar01615492015-02-03 13:00:38 +010011855#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011856/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011857 * Any character has an equivalent 'langmap' character. This is used for
11858 * keyboards that have a special language mode that sends characters above
11859 * 128 (although other characters can be translated too). The "to" field is a
11860 * Vim command character. This avoids having to switch the keyboard back to
11861 * ASCII mode when leaving Insert mode.
11862 *
11863 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11864 * commands.
11865 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11866 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11867 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011868 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011869# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011870/*
11871 * With multi-byte support use growarray for 'langmap' chars >= 256
11872 */
11873typedef struct
11874{
11875 int from;
11876 int to;
11877} langmap_entry_T;
11878
11879static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011880static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011881
11882/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011883 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11884 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011885 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011886 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011887langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011888{
11889 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011890 int a = 0;
11891 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011892
11893 /* Do a binary search for an existing entry. */
11894 while (a != b)
11895 {
11896 int i = (a + b) / 2;
11897 int d = entries[i].from - from;
11898
11899 if (d == 0)
11900 {
11901 entries[i].to = to;
11902 return;
11903 }
11904 if (d < 0)
11905 a = i + 1;
11906 else
11907 b = i;
11908 }
11909
11910 if (ga_grow(&langmap_mapga, 1) != OK)
11911 return; /* out of memory */
11912
11913 /* insert new entry at position "a" */
11914 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11915 mch_memmove(entries + 1, entries,
11916 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11917 ++langmap_mapga.ga_len;
11918 entries[0].from = from;
11919 entries[0].to = to;
11920}
11921
11922/*
11923 * Apply 'langmap' to multi-byte character "c" and return the result.
11924 */
11925 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011926langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011927{
11928 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11929 int a = 0;
11930 int b = langmap_mapga.ga_len;
11931
11932 while (a != b)
11933 {
11934 int i = (a + b) / 2;
11935 int d = entries[i].from - c;
11936
11937 if (d == 0)
11938 return entries[i].to; /* found matching entry */
11939 if (d < 0)
11940 a = i + 1;
11941 else
11942 b = i;
11943 }
11944 return c; /* no entry found, return "c" unmodified */
11945}
11946# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011947
11948 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011949langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011950{
11951 int i;
11952
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011953 for (i = 0; i < 256; i++)
11954 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11955# ifdef FEAT_MBYTE
11956 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11957# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011958}
11959
11960/*
11961 * Called when langmap option is set; the language map can be
11962 * changed at any time!
11963 */
11964 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011965langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011966{
11967 char_u *p;
11968 char_u *p2;
11969 int from, to;
11970
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011971#ifdef FEAT_MBYTE
11972 ga_clear(&langmap_mapga); /* clear the previous map first */
11973#endif
11974 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011975
11976 for (p = p_langmap; p[0] != NUL; )
11977 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011978 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011979 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011980 {
11981 if (p2[0] == '\\' && p2[1] != NUL)
11982 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011983 }
11984 if (p2[0] == ';')
11985 ++p2; /* abcd;ABCD form, p2 points to A */
11986 else
11987 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11988 while (p[0])
11989 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011990 if (p[0] == ',')
11991 {
11992 ++p;
11993 break;
11994 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011995 if (p[0] == '\\' && p[1] != NUL)
11996 ++p;
11997#ifdef FEAT_MBYTE
11998 from = (*mb_ptr2char)(p);
11999#else
12000 from = p[0];
12001#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012002 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012003 if (p2 == NULL)
12004 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012005 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012006 if (p[0] != ',')
12007 {
12008 if (p[0] == '\\')
12009 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012010#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012011 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012012#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012013 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012014#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012015 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012016 }
12017 else
12018 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020012019 if (p2[0] != ',')
12020 {
12021 if (p2[0] == '\\')
12022 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012023#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012024 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012025#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012026 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012027#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012028 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012029 }
12030 if (to == NUL)
12031 {
12032 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
12033 transchar(from));
12034 return;
12035 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012036
12037#ifdef FEAT_MBYTE
12038 if (from >= 256)
12039 langmap_set_entry(from, to);
12040 else
12041#endif
12042 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012043
12044 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012045 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012046 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012047 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012048 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012049 if (*p == ';')
12050 {
12051 p = p2;
12052 if (p[0] != NUL)
12053 {
12054 if (p[0] != ',')
12055 {
12056 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12057 return;
12058 }
12059 ++p;
12060 }
12061 break;
12062 }
12063 }
12064 }
12065 }
12066}
12067#endif
12068
12069/*
12070 * Return TRUE if format option 'x' is in effect.
12071 * Take care of no formatting when 'paste' is set.
12072 */
12073 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012074has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012075{
12076 if (p_paste)
12077 return FALSE;
12078 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12079}
12080
12081/*
12082 * Return TRUE if "x" is present in 'shortmess' option, or
12083 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12084 */
12085 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012086shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012087{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012088 return p_shm != NULL &&
12089 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012090 || (vim_strchr(p_shm, 'a') != NULL
12091 && vim_strchr((char_u *)SHM_A, x) != NULL));
12092}
12093
12094/*
12095 * paste_option_changed() - Called after p_paste was set or reset.
12096 */
12097 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012098paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012099{
12100 static int old_p_paste = FALSE;
12101 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012102 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012103#ifdef FEAT_CMDL_INFO
12104 static int save_ru = 0;
12105#endif
12106#ifdef FEAT_RIGHTLEFT
12107 static int save_ri = 0;
12108 static int save_hkmap = 0;
12109#endif
12110 buf_T *buf;
12111
12112 if (p_paste)
12113 {
12114 /*
12115 * Paste switched from off to on.
12116 * Save the current values, so they can be restored later.
12117 */
12118 if (!old_p_paste)
12119 {
12120 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012121 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012122 {
12123 buf->b_p_tw_nopaste = buf->b_p_tw;
12124 buf->b_p_wm_nopaste = buf->b_p_wm;
12125 buf->b_p_sts_nopaste = buf->b_p_sts;
12126 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012127 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012128 }
12129
12130 /* save global options */
12131 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012132 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012133#ifdef FEAT_CMDL_INFO
12134 save_ru = p_ru;
12135#endif
12136#ifdef FEAT_RIGHTLEFT
12137 save_ri = p_ri;
12138 save_hkmap = p_hkmap;
12139#endif
12140 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012141 p_ai_nopaste = p_ai;
12142 p_et_nopaste = p_et;
12143 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012144 p_tw_nopaste = p_tw;
12145 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012146 }
12147
12148 /*
12149 * Always set the option values, also when 'paste' is set when it is
12150 * already on.
12151 */
12152 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012153 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012154 {
12155 buf->b_p_tw = 0; /* textwidth is 0 */
12156 buf->b_p_wm = 0; /* wrapmargin is 0 */
12157 buf->b_p_sts = 0; /* softtabstop is 0 */
12158 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012159 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012160 }
12161
12162 /* set global options */
12163 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012164 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012165#ifdef FEAT_CMDL_INFO
12166# ifdef FEAT_WINDOWS
12167 if (p_ru)
12168 status_redraw_all(); /* redraw to remove the ruler */
12169# endif
12170 p_ru = 0; /* no ruler */
12171#endif
12172#ifdef FEAT_RIGHTLEFT
12173 p_ri = 0; /* no reverse insert */
12174 p_hkmap = 0; /* no Hebrew keyboard */
12175#endif
12176 /* set global values for local buffer options */
12177 p_tw = 0;
12178 p_wm = 0;
12179 p_sts = 0;
12180 p_ai = 0;
12181 }
12182
12183 /*
12184 * Paste switched from on to off: Restore saved values.
12185 */
12186 else if (old_p_paste)
12187 {
12188 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012189 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012190 {
12191 buf->b_p_tw = buf->b_p_tw_nopaste;
12192 buf->b_p_wm = buf->b_p_wm_nopaste;
12193 buf->b_p_sts = buf->b_p_sts_nopaste;
12194 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012195 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012196 }
12197
12198 /* restore global options */
12199 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012200 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012201#ifdef FEAT_CMDL_INFO
12202# ifdef FEAT_WINDOWS
12203 if (p_ru != save_ru)
12204 status_redraw_all(); /* redraw to draw the ruler */
12205# endif
12206 p_ru = save_ru;
12207#endif
12208#ifdef FEAT_RIGHTLEFT
12209 p_ri = save_ri;
12210 p_hkmap = save_hkmap;
12211#endif
12212 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012213 p_ai = p_ai_nopaste;
12214 p_et = p_et_nopaste;
12215 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012216 p_tw = p_tw_nopaste;
12217 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012218 }
12219
12220 old_p_paste = p_paste;
12221}
12222
12223/*
12224 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12225 *
12226 * Reset 'compatible' and set the values for options that didn't get set yet
12227 * to the Vim defaults.
12228 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012229 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012230 */
12231 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012232vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012233{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012234 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012235 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012236 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012237
12238 if (!option_was_set((char_u *)"cp"))
12239 {
12240 p_cp = FALSE;
12241 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12242 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12243 set_option_default(opt_idx, OPT_FREE, FALSE);
12244 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012245 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012246 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012247
12248 if (fname != NULL)
12249 {
12250 p = vim_getenv(envname, &dofree);
12251 if (p == NULL)
12252 {
12253 /* Set $MYVIMRC to the first vimrc file found. */
12254 p = FullName_save(fname, FALSE);
12255 if (p != NULL)
12256 {
12257 vim_setenv(envname, p);
12258 vim_free(p);
12259 }
12260 }
12261 else if (dofree)
12262 vim_free(p);
12263 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012264}
12265
12266/*
12267 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12268 */
12269 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012270change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012271{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012272 int opt_idx;
12273
Bram Moolenaar071d4272004-06-13 20:20:40 +000012274 if (p_cp != on)
12275 {
12276 p_cp = on;
12277 compatible_set();
12278 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012279 opt_idx = findoption((char_u *)"cp");
12280 if (opt_idx >= 0)
12281 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012282}
12283
12284/*
12285 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012286 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012287 */
12288 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012289option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012290{
12291 int idx;
12292
12293 idx = findoption(name);
12294 if (idx < 0) /* unknown option */
12295 return FALSE;
12296 if (options[idx].flags & P_WAS_SET)
12297 return TRUE;
12298 return FALSE;
12299}
12300
12301/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012302 * Reset the flag indicating option "name" was set.
12303 */
12304 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012305reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012306{
12307 int idx = findoption(name);
12308
12309 if (idx >= 0)
12310 options[idx].flags &= ~P_WAS_SET;
12311}
12312
12313/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012314 * compatible_set() - Called when 'compatible' has been set or unset.
12315 *
12316 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12317 * flag) to a Vi compatible value.
12318 * When 'compatible' is unset: Set all options that have a different default
12319 * for Vim (without the P_VI_DEF flag) to that default.
12320 */
12321 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012322compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012323{
12324 int opt_idx;
12325
12326 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12327 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12328 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12329 set_option_default(opt_idx, OPT_FREE, p_cp);
12330 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012331 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012332}
12333
12334#ifdef FEAT_LINEBREAK
12335
12336# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12337 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012338 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012339# endif
12340
12341/*
12342 * fill_breakat_flags() -- called when 'breakat' changes value.
12343 */
12344 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012345fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012346{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012347 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012348 int i;
12349
12350 for (i = 0; i < 256; i++)
12351 breakat_flags[i] = FALSE;
12352
12353 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012354 for (p = p_breakat; *p; p++)
12355 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012356}
12357
12358# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012359 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012360# endif
12361
12362#endif
12363
12364/*
12365 * Check an option that can be a range of string values.
12366 *
12367 * Return OK for correct value, FAIL otherwise.
12368 * Empty is always OK.
12369 */
12370 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012371check_opt_strings(
12372 char_u *val,
12373 char **values,
12374 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012375{
12376 return opt_strings_flags(val, values, NULL, list);
12377}
12378
12379/*
12380 * Handle an option that can be a range of string values.
12381 * Set a flag in "*flagp" for each string present.
12382 *
12383 * Return OK for correct value, FAIL otherwise.
12384 * Empty is always OK.
12385 */
12386 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012387opt_strings_flags(
12388 char_u *val, /* new value */
12389 char **values, /* array of valid string values */
12390 unsigned *flagp,
12391 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012392{
12393 int i;
12394 int len;
12395 unsigned new_flags = 0;
12396
12397 while (*val)
12398 {
12399 for (i = 0; ; ++i)
12400 {
12401 if (values[i] == NULL) /* val not found in values[] */
12402 return FAIL;
12403
12404 len = (int)STRLEN(values[i]);
12405 if (STRNCMP(values[i], val, len) == 0
12406 && ((list && val[len] == ',') || val[len] == NUL))
12407 {
12408 val += len + (val[len] == ',');
12409 new_flags |= (1 << i);
12410 break; /* check next item in val list */
12411 }
12412 }
12413 }
12414 if (flagp != NULL)
12415 *flagp = new_flags;
12416
12417 return OK;
12418}
12419
12420/*
12421 * Read the 'wildmode' option, fill wim_flags[].
12422 */
12423 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012424check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012425{
12426 char_u new_wim_flags[4];
12427 char_u *p;
12428 int i;
12429 int idx = 0;
12430
12431 for (i = 0; i < 4; ++i)
12432 new_wim_flags[i] = 0;
12433
12434 for (p = p_wim; *p; ++p)
12435 {
12436 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12437 ;
12438 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12439 return FAIL;
12440 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12441 new_wim_flags[idx] |= WIM_LONGEST;
12442 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12443 new_wim_flags[idx] |= WIM_FULL;
12444 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12445 new_wim_flags[idx] |= WIM_LIST;
12446 else
12447 return FAIL;
12448 p += i;
12449 if (*p == NUL)
12450 break;
12451 if (*p == ',')
12452 {
12453 if (idx == 3)
12454 return FAIL;
12455 ++idx;
12456 }
12457 }
12458
12459 /* fill remaining entries with last flag */
12460 while (idx < 3)
12461 {
12462 new_wim_flags[idx + 1] = new_wim_flags[idx];
12463 ++idx;
12464 }
12465
12466 /* only when there are no errors, wim_flags[] is changed */
12467 for (i = 0; i < 4; ++i)
12468 wim_flags[i] = new_wim_flags[i];
12469 return OK;
12470}
12471
12472/*
12473 * Check if backspacing over something is allowed.
12474 */
12475 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012476can_bs(
12477 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012478{
12479 switch (*p_bs)
12480 {
12481 case '2': return TRUE;
12482 case '1': return (what != BS_START);
12483 case '0': return FALSE;
12484 }
12485 return vim_strchr(p_bs, what) != NULL;
12486}
12487
12488/*
12489 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12490 * the file must be considered changed when the value is different.
12491 */
12492 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012493save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012494{
12495 buf->b_start_ffc = *buf->b_p_ff;
12496 buf->b_start_eol = buf->b_p_eol;
12497#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012498 buf->b_start_bomb = buf->b_p_bomb;
12499
Bram Moolenaar071d4272004-06-13 20:20:40 +000012500 /* Only use free/alloc when necessary, they take time. */
12501 if (buf->b_start_fenc == NULL
12502 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12503 {
12504 vim_free(buf->b_start_fenc);
12505 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12506 }
12507#endif
12508}
12509
12510/*
12511 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12512 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012513 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12514 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012515 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012516 * When "ignore_empty" is true don't consider a new, empty buffer to be
12517 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012518 */
12519 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012520file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012521{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012522 /* In a buffer that was never loaded the options are not valid. */
12523 if (buf->b_flags & BF_NEVERLOADED)
12524 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012525 if (ignore_empty
12526 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012527 && buf->b_ml.ml_line_count == 1
12528 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12529 return FALSE;
12530 if (buf->b_start_ffc != *buf->b_p_ff)
12531 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012532 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012533 return TRUE;
12534#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012535 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12536 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012537 if (buf->b_start_fenc == NULL)
12538 return (*buf->b_p_fenc != NUL);
12539 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12540#else
12541 return FALSE;
12542#endif
12543}
12544
12545/*
12546 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12547 */
12548 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012549check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012550{
12551 return check_opt_strings(p, p_ff_values, FALSE);
12552}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012553
12554/*
12555 * Return the effective shiftwidth value for current buffer, using the
12556 * 'tabstop' value when 'shiftwidth' is zero.
12557 */
12558 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012559get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012560{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012561 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012562}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012563
12564/*
12565 * Return the effective softtabstop value for the current buffer, using the
12566 * 'tabstop' value when 'softtabstop' is negative.
12567 */
12568 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012569get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012570{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012571 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012572}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012573
12574/*
12575 * Check matchpairs option for "*initc".
12576 * If there is a match set "*initc" to the matching character and "*findc" to
12577 * the opposite character. Set "*backwards" to the direction.
12578 * When "switchit" is TRUE swap the direction.
12579 */
12580 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012581find_mps_values(
12582 int *initc,
12583 int *findc,
12584 int *backwards,
12585 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012586{
12587 char_u *ptr;
12588
12589 ptr = curbuf->b_p_mps;
12590 while (*ptr != NUL)
12591 {
12592#ifdef FEAT_MBYTE
12593 if (has_mbyte)
12594 {
12595 char_u *prev;
12596
12597 if (mb_ptr2char(ptr) == *initc)
12598 {
12599 if (switchit)
12600 {
12601 *findc = *initc;
12602 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12603 *backwards = TRUE;
12604 }
12605 else
12606 {
12607 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12608 *backwards = FALSE;
12609 }
12610 return;
12611 }
12612 prev = ptr;
12613 ptr += mb_ptr2len(ptr) + 1;
12614 if (mb_ptr2char(ptr) == *initc)
12615 {
12616 if (switchit)
12617 {
12618 *findc = *initc;
12619 *initc = mb_ptr2char(prev);
12620 *backwards = FALSE;
12621 }
12622 else
12623 {
12624 *findc = mb_ptr2char(prev);
12625 *backwards = TRUE;
12626 }
12627 return;
12628 }
12629 ptr += mb_ptr2len(ptr);
12630 }
12631 else
12632#endif
12633 {
12634 if (*ptr == *initc)
12635 {
12636 if (switchit)
12637 {
12638 *backwards = TRUE;
12639 *findc = *initc;
12640 *initc = ptr[2];
12641 }
12642 else
12643 {
12644 *backwards = FALSE;
12645 *findc = ptr[2];
12646 }
12647 return;
12648 }
12649 ptr += 2;
12650 if (*ptr == *initc)
12651 {
12652 if (switchit)
12653 {
12654 *backwards = FALSE;
12655 *findc = *initc;
12656 *initc = ptr[-2];
12657 }
12658 else
12659 {
12660 *backwards = TRUE;
12661 *findc = ptr[-2];
12662 }
12663 return;
12664 }
12665 ++ptr;
12666 }
12667 if (*ptr == ',')
12668 ++ptr;
12669 }
12670}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012671
12672#if defined(FEAT_LINEBREAK) || defined(PROTO)
12673/*
12674 * This is called when 'breakindentopt' is changed and when a window is
12675 * initialized.
12676 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012677 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012678briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012679{
12680 char_u *p;
12681 int bri_shift = 0;
12682 long bri_min = 20;
12683 int bri_sbr = FALSE;
12684
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012685 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012686 while (*p != NUL)
12687 {
12688 if (STRNCMP(p, "shift:", 6) == 0
12689 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12690 {
12691 p += 6;
12692 bri_shift = getdigits(&p);
12693 }
12694 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12695 {
12696 p += 4;
12697 bri_min = getdigits(&p);
12698 }
12699 else if (STRNCMP(p, "sbr", 3) == 0)
12700 {
12701 p += 3;
12702 bri_sbr = TRUE;
12703 }
12704 if (*p != ',' && *p != NUL)
12705 return FAIL;
12706 if (*p == ',')
12707 ++p;
12708 }
12709
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012710 wp->w_p_brishift = bri_shift;
12711 wp->w_p_brimin = bri_min;
12712 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012713
12714 return OK;
12715}
12716#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012717
12718/*
12719 * Get the local or global value of 'backupcopy'.
12720 */
12721 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012722get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012723{
12724 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12725}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012726
12727#if defined(FEAT_SIGNS) || defined(PROTO)
12728/*
12729 * Return TRUE when window "wp" has a column to draw signs in.
12730 */
12731 int
12732signcolumn_on(win_T *wp)
12733{
12734 if (*wp->w_p_scl == 'n')
12735 return FALSE;
12736 if (*wp->w_p_scl == 'y')
12737 return TRUE;
12738 return (wp->w_buffer->b_signlist != NULL
12739# ifdef FEAT_NETBEANS_INTG
12740 || wp->w_buffer->b_has_sign_column
12741# endif
12742 );
12743}
12744#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012745
12746#if defined(FEAT_EVAL) || defined(PROTO)
12747/*
12748 * Get window or buffer local options.
12749 */
12750 dict_T *
12751get_winbuf_options(int bufopt)
12752{
12753 dict_T *d;
12754 int opt_idx;
12755
12756 d = dict_alloc();
12757 if (d == NULL)
12758 return NULL;
12759
12760 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12761 {
12762 struct vimoption *opt = &options[opt_idx];
12763
12764 if ((bufopt && (opt->indir & PV_BUF))
12765 || (!bufopt && (opt->indir & PV_WIN)))
12766 {
12767 char_u *varp = get_varp(opt);
12768
12769 if (varp != NULL)
12770 {
12771 if (opt->flags & P_STRING)
12772 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012773 else if (opt->flags & P_NUM)
12774 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012775 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012776 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012777 }
12778 }
12779 }
12780
12781 return d;
12782}
12783#endif