blob: 1877b7e47f6e70c2f055afddc6d7e31f06dcedab [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Code to handle user-settable options. This is all pretty much table-
12 * driven. Checklist for adding a new option:
13 * - Put it in the options array below (copy an existing entry).
14 * - For a global option: Add a variable for it in option.h.
15 * - For a buffer or window local option:
16 * - Add a PV_XX entry to the enum below.
17 * - Add a variable to the window or buffer struct in structs.h.
18 * - For a window option, add some code to copy_winopt().
19 * - For a buffer option, add some code to buf_copy_options().
20 * - For a buffer string option, add code to check_buf_options().
21 * - If it's a numeric option, add any necessary bounds checks to do_set().
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL.
23 * - When adding an option with expansion (P_EXPAND), but with a different
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
Bram Moolenaarcea912a2016-10-12 14:20:24 +020025 * - Add documentation! One line in doc/quickref.txt, full description in
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar81bdd6a2017-07-23 22:57:00 +020060#define PV_BH OPT_BUF(BV_BH)
61#define PV_BT OPT_BUF(BV_BT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000063# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +0100110#define PV_FP OPT_BOTH(OPT_BUF(BV_FP))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000111#ifdef FEAT_EVAL
112# define PV_FEX OPT_BUF(BV_FEX)
113#endif
114#define PV_FF OPT_BUF(BV_FF)
115#define PV_FLP OPT_BUF(BV_FLP)
116#define PV_FO OPT_BUF(BV_FO)
117#ifdef FEAT_AUTOCMD
118# define PV_FT OPT_BUF(BV_FT)
119#endif
120#define PV_IMI OPT_BUF(BV_IMI)
121#define PV_IMS OPT_BUF(BV_IMS)
122#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
123# define PV_INDE OPT_BUF(BV_INDE)
124# define PV_INDK OPT_BUF(BV_INDK)
125#endif
126#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
127# define PV_INEX OPT_BUF(BV_INEX)
128#endif
129#define PV_INF OPT_BUF(BV_INF)
130#define PV_ISK OPT_BUF(BV_ISK)
131#ifdef FEAT_CRYPT
132# define PV_KEY OPT_BUF(BV_KEY)
133#endif
134#ifdef FEAT_KEYMAP
135# define PV_KMAP OPT_BUF(BV_KMAP)
136#endif
137#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
138#ifdef FEAT_LISP
139# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100140# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000141#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +0100142#ifdef FEAT_MBYTE
143# define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC))
144#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000145#define PV_MA OPT_BUF(BV_MA)
146#define PV_ML OPT_BUF(BV_ML)
147#define PV_MOD OPT_BUF(BV_MOD)
148#define PV_MPS OPT_BUF(BV_MPS)
149#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000150#ifdef FEAT_COMPL_FUNC
151# define PV_OFU OPT_BUF(BV_OFU)
152#endif
153#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
154#define PV_PI OPT_BUF(BV_PI)
155#ifdef FEAT_TEXTOBJ
156# define PV_QE OPT_BUF(BV_QE)
157#endif
158#define PV_RO OPT_BUF(BV_RO)
159#ifdef FEAT_SMARTINDENT
160# define PV_SI OPT_BUF(BV_SI)
161#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100162#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000163#ifdef FEAT_SYN_HL
164# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000165# define PV_SYN OPT_BUF(BV_SYN)
166#endif
167#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000168# define PV_SPC OPT_BUF(BV_SPC)
169# define PV_SPF OPT_BUF(BV_SPF)
170# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000171#endif
172#define PV_STS OPT_BUF(BV_STS)
173#ifdef FEAT_SEARCHPATH
174# define PV_SUA OPT_BUF(BV_SUA)
175#endif
176#define PV_SW OPT_BUF(BV_SW)
177#define PV_SWF OPT_BUF(BV_SWF)
178#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100179#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000180#define PV_TS OPT_BUF(BV_TS)
181#define PV_TW OPT_BUF(BV_TW)
182#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200183#ifdef FEAT_PERSISTENT_UNDO
184# define PV_UDF OPT_BUF(BV_UDF)
185#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187
188/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000189 * Definition of the PV_ values for window-local options.
190 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000191 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000192#define PV_LIST OPT_WIN(WV_LIST)
193#ifdef FEAT_ARABIC
194# define PV_ARAB OPT_WIN(WV_ARAB)
195#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200196#ifdef FEAT_LINEBREAK
197# define PV_BRI OPT_WIN(WV_BRI)
198# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
199#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000200#ifdef FEAT_DIFF
201# define PV_DIFF OPT_WIN(WV_DIFF)
202#endif
203#ifdef FEAT_FOLDING
204# define PV_FDC OPT_WIN(WV_FDC)
205# define PV_FEN OPT_WIN(WV_FEN)
206# define PV_FDI OPT_WIN(WV_FDI)
207# define PV_FDL OPT_WIN(WV_FDL)
208# define PV_FDM OPT_WIN(WV_FDM)
209# define PV_FML OPT_WIN(WV_FML)
210# define PV_FDN OPT_WIN(WV_FDN)
211# ifdef FEAT_EVAL
212# define PV_FDE OPT_WIN(WV_FDE)
213# define PV_FDT OPT_WIN(WV_FDT)
214# endif
215# define PV_FMR OPT_WIN(WV_FMR)
216#endif
217#ifdef FEAT_LINEBREAK
218# define PV_LBR OPT_WIN(WV_LBR)
219#endif
220#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200221#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000222#ifdef FEAT_LINEBREAK
223# define PV_NUW OPT_WIN(WV_NUW)
224#endif
225#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
226# define PV_PVW OPT_WIN(WV_PVW)
227#endif
228#ifdef FEAT_RIGHTLEFT
229# define PV_RL OPT_WIN(WV_RL)
230# define PV_RLC OPT_WIN(WV_RLC)
231#endif
232#ifdef FEAT_SCROLLBIND
233# define PV_SCBIND OPT_WIN(WV_SCBIND)
234#endif
235#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000237# define PV_SPELL OPT_WIN(WV_SPELL)
238#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#ifdef FEAT_SYN_HL
240# define PV_CUC OPT_WIN(WV_CUC)
241# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200242# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000243#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_STL_OPT
245# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
246#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100247#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#ifdef FEAT_WINDOWS
249# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000250# define PV_WFW OPT_WIN(WV_WFW)
251#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000252#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200253#ifdef FEAT_CURSORBIND
254# define PV_CRBIND OPT_WIN(WV_CRBIND)
255#endif
256#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200257# define PV_COCU OPT_WIN(WV_COCU)
258# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200259#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200260#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +0200261# define PV_TK OPT_WIN(WV_TK)
Bram Moolenaare4f25e42017-07-07 11:54:15 +0200262# define PV_TMS OPT_WIN(WV_TMS)
263#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200264#ifdef FEAT_SIGNS
265# define PV_SCL OPT_WIN(WV_SCL)
266#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000267
268/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269typedef enum
270{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000271 PV_NONE = 0,
272 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000273} idopt_T;
274
275/*
276 * Options local to a window have a value local to a buffer and global to all
277 * buffers. Indicate this by setting "var" to VAR_WIN.
278 */
279#define VAR_WIN ((char_u *)-1)
280
281/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000282 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283 * Only to be used in option.c!
284 */
285static int p_ai;
286static int p_bin;
287#ifdef FEAT_MBYTE
288static int p_bomb;
289#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290static char_u *p_bh;
291static char_u *p_bt;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292static int p_bl;
293static int p_ci;
294#ifdef FEAT_CINDENT
295static int p_cin;
296static char_u *p_cink;
297static char_u *p_cino;
298#endif
299#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
300static char_u *p_cinw;
301#endif
302#ifdef FEAT_COMMENTS
303static char_u *p_com;
304#endif
305#ifdef FEAT_FOLDING
306static char_u *p_cms;
307#endif
308#ifdef FEAT_INS_EXPAND
309static char_u *p_cpt;
310#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000311#ifdef FEAT_COMPL_FUNC
312static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000313static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000314#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200316static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000317static int p_et;
318#ifdef FEAT_MBYTE
319static char_u *p_fenc;
320#endif
321static char_u *p_ff;
322static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000323static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000324#ifdef FEAT_AUTOCMD
325static char_u *p_ft;
326#endif
327static long p_iminsert;
328static long p_imsearch;
329#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
330static char_u *p_inex;
331#endif
332#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
333static char_u *p_inde;
334static char_u *p_indk;
335#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000336#if defined(FEAT_EVAL)
337static char_u *p_fex;
338#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000339static int p_inf;
340static char_u *p_isk;
341#ifdef FEAT_CRYPT
342static char_u *p_key;
343#endif
344#ifdef FEAT_LISP
345static int p_lisp;
346#endif
347static int p_ml;
348static int p_ma;
349static int p_mod;
350static char_u *p_mps;
351static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000352static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000353#ifdef FEAT_TEXTOBJ
354static char_u *p_qe;
355#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356static int p_ro;
357#ifdef FEAT_SMARTINDENT
358static int p_si;
359#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000360static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000361static long p_sts;
362#if defined(FEAT_SEARCHPATH)
363static char_u *p_sua;
364#endif
365static long p_sw;
366static int p_swf;
367#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000368static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000370#endif
371#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000372static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000373static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000374static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000375#endif
376static long p_ts;
377static long p_tw;
378static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200379#ifdef FEAT_PERSISTENT_UNDO
380static int p_udf;
381#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382static long p_wm;
383#ifdef FEAT_KEYMAP
384static char_u *p_keymap;
385#endif
386
387/* Saved values for when 'bin' is set. */
388static int p_et_nobin;
389static int p_ml_nobin;
390static long p_tw_nobin;
391static long p_wm_nobin;
392
393/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200394static int p_ai_nopaste;
395static int p_et_nopaste;
396static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397static long p_tw_nopaste;
398static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000399
400struct vimoption
401{
402 char *fullname; /* full option name */
403 char *shortname; /* permissible abbreviation */
404 long_u flags; /* see below */
405 char_u *var; /* global option: pointer to variable;
406 * window-local option: VAR_WIN;
407 * buffer-local option: global value */
408 idopt_T indir; /* global option: PV_NONE;
409 * local option: indirect option index */
410 char_u *def_val[2]; /* default values for variable (vi and vim) */
411#ifdef FEAT_EVAL
412 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000413# define SCRIPTID_INIT , 0
414#else
415# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416#endif
417};
418
419#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
420#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
421
422/*
423 * Flags
424 */
425#define P_BOOL 0x01 /* the option is boolean */
426#define P_NUM 0x02 /* the option is numeric */
427#define P_STRING 0x04 /* the option is a string */
428#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000429 must use free_string_option() when
430 assigning new value. Not set if default is
431 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
433 never be used for local or hidden options! */
434#define P_NODEFAULT 0x40 /* don't set to default value */
435#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
436 use vim_free() when assigning new value */
437#define P_WAS_SET 0x100 /* option has been set/reset */
438#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
439#define P_VI_DEF 0x400 /* Use Vi default for Vim */
440#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
441
442 /* when option changed, what to display: */
443#define P_RSTAT 0x1000 /* redraw status lines */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100444#define P_RWIN 0x2000 /* redraw current window and recompute text */
445#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000446#define P_RALL 0x6000 /* redraw all windows */
447#define P_RCLR 0x7000 /* clear and redraw all */
448
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200449#define P_COMMA 0x8000 /* comma separated list */
450#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
451 * commas */
452#define P_NODUP 0x20000L /* don't allow duplicate strings */
453#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200455#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
456#define P_GETTEXT 0x100000L /* expand default value with _() */
457#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
458#define P_NFNAME 0x400000L /* only normal file name chars allowed */
459#define P_INSECURE 0x800000L /* option was set from a modeline */
460#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100461 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200462#define P_NO_ML 0x2000000L /* not allowed in modeline */
463#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200464 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100465#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100466#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000467
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000468#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
469
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000470/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
471 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100472#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000473# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000474#else
475# define ISP_LATIN1 (char_u *)"@,161-255"
476#endif
477
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100478/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000479#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100480 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar21020352017-06-13 17:21:04 +0200481 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) \
Bram Moolenaar3633cf52017-07-31 22:29:35 +0200482 || defined(FEAT_CONCEAL) || defined(FEAT_QUICKFIX) \
483 || defined(FEAT_TERMINAL)
Bram Moolenaar05fbfdc2017-08-14 22:35:08 +0200484# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000485#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100486# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000487#endif
488
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +0100489/* Default python version for pyx* commands */
490#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
491# define DEFAULT_PYTHON_VER 0
492#elif defined(FEAT_PYTHON3)
493# define DEFAULT_PYTHON_VER 3
494#elif defined(FEAT_PYTHON)
495# define DEFAULT_PYTHON_VER 2
496#else
497# define DEFAULT_PYTHON_VER 0
498#endif
499
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500/*
501 * options[] is initialized here.
502 * The order of the options MUST be alphabetic for ":set all" and findoption().
503 * All option names MUST start with a lowercase letter (for findoption()).
504 * Exception: "t_" options are at the end.
505 * The options with a NULL variable are 'hidden': a set command for them is
506 * ignored and they are not printed.
507 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100508static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000509{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200510 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000511#ifdef FEAT_RIGHTLEFT
512 (char_u *)&p_aleph, PV_NONE,
513#else
514 (char_u *)NULL, PV_NONE,
515#endif
516 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100517#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518 (char_u *)128L,
519#else
520 (char_u *)224L,
521#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000522 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
524#if defined(FEAT_GUI) && defined(MACOS_X)
525 (char_u *)&p_antialias, PV_NONE,
526 {(char_u *)FALSE, (char_u *)FALSE}
527#else
528 (char_u *)NULL, PV_NONE,
529 {(char_u *)FALSE, (char_u *)FALSE}
530#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000531 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200532 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533#ifdef FEAT_ARABIC
534 (char_u *)VAR_WIN, PV_ARAB,
535#else
536 (char_u *)NULL, PV_NONE,
537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000538 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
540#ifdef FEAT_ARABIC
541 (char_u *)&p_arshape, PV_NONE,
542#else
543 (char_u *)NULL, PV_NONE,
544#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000545 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000546 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
547#ifdef FEAT_RIGHTLEFT
548 (char_u *)&p_ari, PV_NONE,
549#else
550 (char_u *)NULL, PV_NONE,
551#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
554#ifdef FEAT_FKMAP
555 (char_u *)&p_altkeymap, PV_NONE,
556#else
557 (char_u *)NULL, PV_NONE,
558#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
561#if defined(FEAT_MBYTE)
562 (char_u *)&p_ambw, PV_NONE,
563 {(char_u *)"single", (char_u *)0L}
564#else
565 (char_u *)NULL, PV_NONE,
566 {(char_u *)0L, (char_u *)0L}
567#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000568 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569 {"autochdir", "acd", P_BOOL|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100570#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000571 (char_u *)&p_acd, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100572 {(char_u *)FALSE, (char_u *)0L}
573#else
574 (char_u *)NULL, PV_NONE,
575 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +0100577 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578 {"autoindent", "ai", P_BOOL|P_VI_DEF,
579 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000580 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581 {"autoprint", "ap", P_BOOL|P_VI_DEF,
582 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000585 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000586 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000587 {"autowrite", "aw", P_BOOL|P_VI_DEF,
588 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000589 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590 {"autowriteall","awa", P_BOOL|P_VI_DEF,
591 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000592 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
594 (char_u *)&p_bg, PV_NONE,
595 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100596#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597 (char_u *)"dark",
598#else
599 (char_u *)"light",
600#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000601 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200602 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000603 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000604 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000605 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
606 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000607 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200608 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200609 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000610#ifdef UNIX
611 {(char_u *)"yes", (char_u *)"auto"}
612#else
613 {(char_u *)"auto", (char_u *)"auto"}
614#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000615 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200616 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
617 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000618 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000619 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000620 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000621 (char_u *)&p_bex, PV_NONE,
622 {
623#ifdef VMS
624 (char_u *)"_",
625#else
626 (char_u *)"~",
627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000628 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200629 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000630#ifdef FEAT_WILDIGN
631 (char_u *)&p_bsk, PV_NONE,
632 {(char_u *)"", (char_u *)0L}
633#else
634 (char_u *)NULL, PV_NONE,
635 {(char_u *)0L, (char_u *)0L}
636#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000637 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100639#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +0000640 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100641 {(char_u *)600L, (char_u *)0L}
642#else
643 (char_u *)NULL, PV_NONE,
644 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000645#endif
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100646 SCRIPTID_INIT},
647 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
648#ifdef FEAT_BEVAL
649 (char_u *)&p_beval, PV_NONE,
650 {(char_u *)FALSE, (char_u *)0L}
651#else
652 (char_u *)NULL, PV_NONE,
653 {(char_u *)0L, (char_u *)0L}
654#endif
655 SCRIPTID_INIT},
656 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
657#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
658 (char_u *)&p_bexpr, PV_BEXPR,
659 {(char_u *)"", (char_u *)0L}
660#else
661 (char_u *)NULL, PV_NONE,
662 {(char_u *)0L, (char_u *)0L}
663#endif
664 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000665 {"beautify", "bf", P_BOOL|P_VI_DEF,
666 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000667 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200668 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
669 (char_u *)&p_bo, PV_NONE,
670 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
672 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000673 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000674 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000675 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000676 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000677 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
678#ifdef FEAT_MBYTE
679 (char_u *)&p_bomb, PV_BOMB,
680#else
681 (char_u *)NULL, PV_NONE,
682#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000683 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000684 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
685#ifdef FEAT_LINEBREAK
686 (char_u *)&p_breakat, PV_NONE,
687 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
688#else
689 (char_u *)NULL, PV_NONE,
690 {(char_u *)0L, (char_u *)0L}
691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000692 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200693 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
694#ifdef FEAT_LINEBREAK
695 (char_u *)VAR_WIN, PV_BRI,
696 {(char_u *)FALSE, (char_u *)0L}
697#else
698 (char_u *)NULL, PV_NONE,
699 {(char_u *)0L, (char_u *)0L}
700#endif
701 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200702 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
703 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200704#ifdef FEAT_LINEBREAK
705 (char_u *)VAR_WIN, PV_BRIOPT,
706 {(char_u *)"", (char_u *)NULL}
707#else
708 (char_u *)NULL, PV_NONE,
709 {(char_u *)"", (char_u *)NULL}
710#endif
711 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000712 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
713#ifdef FEAT_BROWSE
714 (char_u *)&p_bsdir, PV_NONE,
715 {(char_u *)"last", (char_u *)0L}
716#else
717 (char_u *)NULL, PV_NONE,
718 {(char_u *)0L, (char_u *)0L}
719#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000720 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000721 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000722 (char_u *)&p_bh, PV_BH,
723 {(char_u *)"", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000724 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000725 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
726 (char_u *)&p_bl, PV_BL,
727 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000728 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000729 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000730 (char_u *)&p_bt, PV_BT,
731 {(char_u *)"", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000732 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200733 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000734#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000735 (char_u *)&p_cmp, PV_NONE,
736 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000737#else
738 (char_u *)NULL, PV_NONE,
739 {(char_u *)0L, (char_u *)0L}
740#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000741 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000742 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
743#ifdef FEAT_SEARCHPATH
744 (char_u *)&p_cdpath, PV_NONE,
745 {(char_u *)",,", (char_u *)0L}
746#else
747 (char_u *)NULL, PV_NONE,
748 {(char_u *)0L, (char_u *)0L}
749#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000750 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000751 {"cedit", NULL, P_STRING,
752#ifdef FEAT_CMDWIN
753 (char_u *)&p_cedit, PV_NONE,
754 {(char_u *)"", (char_u *)CTRL_F_STR}
755#else
756 (char_u *)NULL, PV_NONE,
757 {(char_u *)0L, (char_u *)0L}
758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000759 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000760 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
761#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
762 (char_u *)&p_ccv, PV_NONE,
763 {(char_u *)"", (char_u *)0L}
764#else
765 (char_u *)NULL, PV_NONE,
766 {(char_u *)0L, (char_u *)0L}
767#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000768 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000769 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
770#ifdef FEAT_CINDENT
771 (char_u *)&p_cin, PV_CIN,
772#else
773 (char_u *)NULL, PV_NONE,
774#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000775 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200776 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000777#ifdef FEAT_CINDENT
778 (char_u *)&p_cink, PV_CINK,
779 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
780#else
781 (char_u *)NULL, PV_NONE,
782 {(char_u *)0L, (char_u *)0L}
783#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000784 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200785 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000786#ifdef FEAT_CINDENT
787 (char_u *)&p_cino, PV_CINO,
788#else
789 (char_u *)NULL, PV_NONE,
790#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000791 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200792 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000793#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
794 (char_u *)&p_cinw, PV_CINW,
795 {(char_u *)"if,else,while,do,for,switch",
796 (char_u *)0L}
797#else
798 (char_u *)NULL, PV_NONE,
799 {(char_u *)0L, (char_u *)0L}
800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000801 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200802 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000803#ifdef FEAT_CLIPBOARD
804 (char_u *)&p_cb, PV_NONE,
805# ifdef FEAT_XCLIPBOARD
806 {(char_u *)"autoselect,exclude:cons\\|linux",
807 (char_u *)0L}
808# else
809 {(char_u *)"", (char_u *)0L}
810# endif
811#else
812 (char_u *)NULL, PV_NONE,
813 {(char_u *)"", (char_u *)0L}
814#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000815 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000816 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
817 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000818 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000819 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
820#ifdef FEAT_CMDWIN
821 (char_u *)&p_cwh, PV_NONE,
822#else
823 (char_u *)NULL, PV_NONE,
824#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000825 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200826 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200827#ifdef FEAT_SYN_HL
828 (char_u *)VAR_WIN, PV_CC,
829#else
830 (char_u *)NULL, PV_NONE,
831#endif
832 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000833 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
834 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000835 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200836 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
837 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000838#ifdef FEAT_COMMENTS
839 (char_u *)&p_com, PV_COM,
840 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
841 (char_u *)0L}
842#else
843 (char_u *)NULL, PV_NONE,
844 {(char_u *)0L, (char_u *)0L}
845#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000846 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200847 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000848#ifdef FEAT_FOLDING
849 (char_u *)&p_cms, PV_CMS,
850 {(char_u *)"/*%s*/", (char_u *)0L}
851#else
852 (char_u *)NULL, PV_NONE,
853 {(char_u *)0L, (char_u *)0L}
854#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000855 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000856 /* P_PRI_MKRC isn't needed here, optval_default()
857 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000858 {"compatible", "cp", P_BOOL|P_RALL,
859 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000860 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200861 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000862#ifdef FEAT_INS_EXPAND
863 (char_u *)&p_cpt, PV_CPT,
864 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
865#else
866 (char_u *)NULL, PV_NONE,
867 {(char_u *)0L, (char_u *)0L}
868#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000869 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200870 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200871#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200872 (char_u *)VAR_WIN, PV_COCU,
873 {(char_u *)"", (char_u *)NULL}
874#else
875 (char_u *)NULL, PV_NONE,
876 {(char_u *)NULL, (char_u *)0L}
877#endif
878 SCRIPTID_INIT},
879 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
880#ifdef FEAT_CONCEAL
881 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200882#else
883 (char_u *)NULL, PV_NONE,
884#endif
885 {(char_u *)0L, (char_u *)0L}
886 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000887 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
888#ifdef FEAT_COMPL_FUNC
889 (char_u *)&p_cfu, PV_CFU,
890 {(char_u *)"", (char_u *)0L}
891#else
892 (char_u *)NULL, PV_NONE,
893 {(char_u *)0L, (char_u *)0L}
894#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000895 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200896 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000897#ifdef FEAT_INS_EXPAND
898 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000899 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000900#else
901 (char_u *)NULL, PV_NONE,
902 {(char_u *)0L, (char_u *)0L}
903#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000904 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000905 {"confirm", "cf", P_BOOL|P_VI_DEF,
906#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
907 (char_u *)&p_confirm, PV_NONE,
908#else
909 (char_u *)NULL, PV_NONE,
910#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000911 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000912 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000913 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000914 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000915 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
916 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000917 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000918 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
919 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000920 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
921 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200922 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200923#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200924 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200925 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200926#else
927 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200928 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200929#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200930 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000931 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
932#ifdef FEAT_CSCOPE
933 (char_u *)&p_cspc, PV_NONE,
934#else
935 (char_u *)NULL, PV_NONE,
936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000937 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000938 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
939#ifdef FEAT_CSCOPE
940 (char_u *)&p_csprg, PV_NONE,
941 {(char_u *)"cscope", (char_u *)0L}
942#else
943 (char_u *)NULL, PV_NONE,
944 {(char_u *)0L, (char_u *)0L}
945#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000946 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200947 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
949 (char_u *)&p_csqf, PV_NONE,
950 {(char_u *)"", (char_u *)0L}
951#else
952 (char_u *)NULL, PV_NONE,
953 {(char_u *)0L, (char_u *)0L}
954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000955 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200956 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
957#ifdef FEAT_CSCOPE
958 (char_u *)&p_csre, PV_NONE,
959#else
960 (char_u *)NULL, PV_NONE,
961#endif
962 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000963 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
964#ifdef FEAT_CSCOPE
965 (char_u *)&p_cst, PV_NONE,
966#else
967 (char_u *)NULL, PV_NONE,
968#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000969 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000970 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
971#ifdef FEAT_CSCOPE
972 (char_u *)&p_csto, PV_NONE,
973#else
974 (char_u *)NULL, PV_NONE,
975#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000976 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
978#ifdef FEAT_CSCOPE
979 (char_u *)&p_csverbose, PV_NONE,
980#else
981 (char_u *)NULL, PV_NONE,
982#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000983 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200984 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
985#ifdef FEAT_CURSORBIND
986 (char_u *)VAR_WIN, PV_CRBIND,
987#else
988 (char_u *)NULL, PV_NONE,
989#endif
990 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000991 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
992#ifdef FEAT_SYN_HL
993 (char_u *)VAR_WIN, PV_CUC,
994#else
995 (char_u *)NULL, PV_NONE,
996#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000997 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100998 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000999#ifdef FEAT_SYN_HL
1000 (char_u *)VAR_WIN, PV_CUL,
1001#else
1002 (char_u *)NULL, PV_NONE,
1003#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001004 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001005 {"debug", NULL, P_STRING|P_VI_DEF,
1006 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001007 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001008 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001010 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001011 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012#else
1013 (char_u *)NULL, PV_NONE,
1014 {(char_u *)NULL, (char_u *)0L}
1015#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001016 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001017 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1018#ifdef FEAT_MBYTE
1019 (char_u *)&p_deco, PV_NONE,
1020#else
1021 (char_u *)NULL, PV_NONE,
1022#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001023 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001024 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001025#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001026 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001027#else
1028 (char_u *)NULL, PV_NONE,
1029#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001030 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1032#ifdef FEAT_DIFF
1033 (char_u *)VAR_WIN, PV_DIFF,
1034#else
1035 (char_u *)NULL, PV_NONE,
1036#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001037 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001038 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1040 (char_u *)&p_dex, PV_NONE,
1041 {(char_u *)"", (char_u *)0L}
1042#else
1043 (char_u *)NULL, PV_NONE,
1044 {(char_u *)0L, (char_u *)0L}
1045#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001046 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001047 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1048 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049#ifdef FEAT_DIFF
1050 (char_u *)&p_dip, PV_NONE,
1051 {(char_u *)"filler", (char_u *)NULL}
1052#else
1053 (char_u *)NULL, PV_NONE,
1054 {(char_u *)"", (char_u *)NULL}
1055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001056 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001057 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1058#ifdef FEAT_DIGRAPHS
1059 (char_u *)&p_dg, PV_NONE,
1060#else
1061 (char_u *)NULL, PV_NONE,
1062#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001063 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001064 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1065 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001067 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001068 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001070 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001072#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 (char_u *)&p_ead, PV_NONE,
1074 {(char_u *)"both", (char_u *)0L}
1075#else
1076 (char_u *)NULL, PV_NONE,
1077 {(char_u *)NULL, (char_u *)0L}
1078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1081 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001083 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1084#if defined(FEAT_MBYTE)
1085 (char_u *)&p_emoji, PV_NONE,
1086 {(char_u *)TRUE, (char_u *)0L}
1087#else
1088 (char_u *)NULL, PV_NONE,
1089 {(char_u *)0L, (char_u *)0L}
1090#endif
1091 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001092 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001093#ifdef FEAT_MBYTE
1094 (char_u *)&p_enc, PV_NONE,
1095 {(char_u *)ENC_DFLT, (char_u *)0L}
1096#else
1097 (char_u *)NULL, PV_NONE,
1098 {(char_u *)0L, (char_u *)0L}
1099#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001100 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001101 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1102 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1105 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001108 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1111 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001112 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1114#ifdef FEAT_QUICKFIX
1115 (char_u *)&p_ef, PV_NONE,
1116 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1117#else
1118 (char_u *)NULL, PV_NONE,
1119 {(char_u *)NULL, (char_u *)0L}
1120#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001121 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001122 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001123#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001124 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001125 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001126#else
1127 (char_u *)NULL, PV_NONE,
1128 {(char_u *)NULL, (char_u *)0L}
1129#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001130 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131 {"esckeys", "ek", P_BOOL|P_VIM,
1132 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001133 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001134 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001135#ifdef FEAT_AUTOCMD
1136 (char_u *)&p_ei, PV_NONE,
1137#else
1138 (char_u *)NULL, PV_NONE,
1139#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001140 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1142 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001143 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1145 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001146 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001147 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1148 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149#ifdef FEAT_MBYTE
1150 (char_u *)&p_fenc, PV_FENC,
1151 {(char_u *)"", (char_u *)0L}
1152#else
1153 (char_u *)NULL, PV_NONE,
1154 {(char_u *)0L, (char_u *)0L}
1155#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001156 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001157 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158#ifdef FEAT_MBYTE
1159 (char_u *)&p_fencs, PV_NONE,
1160 {(char_u *)"ucs-bom", (char_u *)0L}
1161#else
1162 (char_u *)NULL, PV_NONE,
1163 {(char_u *)0L, (char_u *)0L}
1164#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001165 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001166 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1167 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001169 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001170 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1173 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001174 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1175 (char_u *)&p_fic, PV_NONE,
1176 {
1177#ifdef CASE_INSENSITIVE_FILENAME
1178 (char_u *)TRUE,
1179#else
1180 (char_u *)FALSE,
1181#endif
1182 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001183 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184#ifdef FEAT_AUTOCMD
1185 (char_u *)&p_ft, PV_FT,
1186 {(char_u *)"", (char_u *)0L}
1187#else
1188 (char_u *)NULL, PV_NONE,
1189 {(char_u *)0L, (char_u *)0L}
1190#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001191 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001192 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1194 (char_u *)&p_fcs, PV_NONE,
1195 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1196#else
1197 (char_u *)NULL, PV_NONE,
1198 {(char_u *)"", (char_u *)0L}
1199#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001200 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001201 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1202 (char_u *)&p_fixeol, PV_FIXEOL,
1203 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1205#ifdef FEAT_FKMAP
1206 (char_u *)&p_fkmap, PV_NONE,
1207#else
1208 (char_u *)NULL, PV_NONE,
1209#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001210 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 {"flash", "fl", P_BOOL|P_VI_DEF,
1212 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001213 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001214 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001215#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001217 {(char_u *)"", (char_u *)0L}
1218#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001219 (char_u *)NULL, PV_NONE,
1220 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001221#endif
1222 SCRIPTID_INIT},
1223 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1224#ifdef FEAT_FOLDING
1225 (char_u *)VAR_WIN, PV_FDC,
1226 {(char_u *)FALSE, (char_u *)0L}
1227#else
1228 (char_u *)NULL, PV_NONE,
1229 {(char_u *)NULL, (char_u *)0L}
1230#endif
1231 SCRIPTID_INIT},
1232 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1233#ifdef FEAT_FOLDING
1234 (char_u *)VAR_WIN, PV_FEN,
1235 {(char_u *)TRUE, (char_u *)0L}
1236#else
1237 (char_u *)NULL, PV_NONE,
1238 {(char_u *)NULL, (char_u *)0L}
1239#endif
1240 SCRIPTID_INIT},
1241 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1242#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1243 (char_u *)VAR_WIN, PV_FDE,
1244 {(char_u *)"0", (char_u *)NULL}
1245#else
1246 (char_u *)NULL, PV_NONE,
1247 {(char_u *)NULL, (char_u *)0L}
1248#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001249 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001250 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001251#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001253 {(char_u *)"#", (char_u *)NULL}
1254#else
1255 (char_u *)NULL, PV_NONE,
1256 {(char_u *)NULL, (char_u *)0L}
1257#endif
1258 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001260#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001261 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001262 {(char_u *)0L, (char_u *)0L}
1263#else
1264 (char_u *)NULL, PV_NONE,
1265 {(char_u *)NULL, (char_u *)0L}
1266#endif
1267 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001268 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001269#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001270 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001271 {(char_u *)-1L, (char_u *)0L}
1272#else
1273 (char_u *)NULL, PV_NONE,
1274 {(char_u *)NULL, (char_u *)0L}
1275#endif
1276 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001278 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001279#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001280 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001281 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001282#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001286 SCRIPTID_INIT},
1287 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1288#ifdef FEAT_FOLDING
1289 (char_u *)VAR_WIN, PV_FDM,
1290 {(char_u *)"manual", (char_u *)NULL}
1291#else
1292 (char_u *)NULL, PV_NONE,
1293 {(char_u *)NULL, (char_u *)0L}
1294#endif
1295 SCRIPTID_INIT},
1296 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1297#ifdef FEAT_FOLDING
1298 (char_u *)VAR_WIN, PV_FML,
1299 {(char_u *)1L, (char_u *)0L}
1300#else
1301 (char_u *)NULL, PV_NONE,
1302 {(char_u *)NULL, (char_u *)0L}
1303#endif
1304 SCRIPTID_INIT},
1305 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1306#ifdef FEAT_FOLDING
1307 (char_u *)VAR_WIN, PV_FDN,
1308 {(char_u *)20L, (char_u *)0L}
1309#else
1310 (char_u *)NULL, PV_NONE,
1311 {(char_u *)NULL, (char_u *)0L}
1312#endif
1313 SCRIPTID_INIT},
1314 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1315#ifdef FEAT_FOLDING
1316 (char_u *)&p_fdo, PV_NONE,
1317 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1318 (char_u *)0L}
1319#else
1320 (char_u *)NULL, PV_NONE,
1321 {(char_u *)NULL, (char_u *)0L}
1322#endif
1323 SCRIPTID_INIT},
1324 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1325#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1326 (char_u *)VAR_WIN, PV_FDT,
1327 {(char_u *)"foldtext()", (char_u *)NULL}
1328#else
1329 (char_u *)NULL, PV_NONE,
1330 {(char_u *)NULL, (char_u *)0L}
1331#endif
1332 SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001333 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001334#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001335 (char_u *)&p_fex, PV_FEX,
1336 {(char_u *)"", (char_u *)0L}
1337#else
1338 (char_u *)NULL, PV_NONE,
1339 {(char_u *)0L, (char_u *)0L}
1340#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001341 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001342 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1343 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001344 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1345 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001346 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1347 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001348 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1349 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001350 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001351 (char_u *)&p_fp, PV_FP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001352 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001353 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1354#ifdef HAVE_FSYNC
1355 (char_u *)&p_fs, PV_NONE,
1356 {(char_u *)TRUE, (char_u *)0L}
1357#else
1358 (char_u *)NULL, PV_NONE,
1359 {(char_u *)FALSE, (char_u *)0L}
1360#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001361 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1363 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001364 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 {"graphic", "gr", P_BOOL|P_VI_DEF,
1366 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001367 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001368 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369#ifdef FEAT_QUICKFIX
1370 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001371 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372#else
1373 (char_u *)NULL, PV_NONE,
1374 {(char_u *)NULL, (char_u *)0L}
1375#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001376 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001377 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1378#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001379 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001380 {
1381# ifdef WIN3264
1382 /* may be changed to "grep -n" in os_win32.c */
1383 (char_u *)"findstr /n",
1384# else
1385# ifdef UNIX
1386 /* Add an extra file name so that grep will always
1387 * insert a file name in the match line. */
1388 (char_u *)"grep -n $* /dev/null",
1389# else
1390# ifdef VMS
1391 (char_u *)"SEARCH/NUMBERS ",
1392# else
1393 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001394# endif
1395# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001396# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001397 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001398#else
1399 (char_u *)NULL, PV_NONE,
1400 {(char_u *)NULL, (char_u *)0L}
1401#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001403 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001404#ifdef CURSOR_SHAPE
1405 (char_u *)&p_guicursor, PV_NONE,
1406 {
1407# ifdef FEAT_GUI
1408 (char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001409# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1411# endif
1412 (char_u *)0L}
1413#else
1414 (char_u *)NULL, PV_NONE,
1415 {(char_u *)NULL, (char_u *)0L}
1416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001417 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001418 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001419#ifdef FEAT_GUI
1420 (char_u *)&p_guifont, PV_NONE,
1421 {(char_u *)"", (char_u *)0L}
1422#else
1423 (char_u *)NULL, PV_NONE,
1424 {(char_u *)NULL, (char_u *)0L}
1425#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001426 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001427 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001428#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1429 (char_u *)&p_guifontset, PV_NONE,
1430 {(char_u *)"", (char_u *)0L}
1431#else
1432 (char_u *)NULL, PV_NONE,
1433 {(char_u *)NULL, (char_u *)0L}
1434#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001435 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001436 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001437#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1438 (char_u *)&p_guifontwide, PV_NONE,
1439 {(char_u *)"", (char_u *)0L}
1440#else
1441 (char_u *)NULL, PV_NONE,
1442 {(char_u *)NULL, (char_u *)0L}
1443#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001444 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001445 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001446#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447 (char_u *)&p_ghr, PV_NONE,
1448#else
1449 (char_u *)NULL, PV_NONE,
1450#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001451 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001452 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001453#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001454 (char_u *)&p_go, PV_NONE,
1455# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001456 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001458 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001459# endif
1460#else
1461 (char_u *)NULL, PV_NONE,
1462 {(char_u *)NULL, (char_u *)0L}
1463#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001464 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001465 {"guipty", NULL, P_BOOL|P_VI_DEF,
1466#if defined(FEAT_GUI)
1467 (char_u *)&p_guipty, PV_NONE,
1468#else
1469 (char_u *)NULL, PV_NONE,
1470#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001471 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001472 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001473#if defined(FEAT_GUI_TABLINE)
1474 (char_u *)&p_gtl, PV_NONE,
1475 {(char_u *)"", (char_u *)0L}
1476#else
1477 (char_u *)NULL, PV_NONE,
1478 {(char_u *)NULL, (char_u *)0L}
1479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001480 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001481 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001482#if defined(FEAT_GUI_TABLINE)
1483 (char_u *)&p_gtt, PV_NONE,
1484 {(char_u *)"", (char_u *)0L}
1485#else
1486 (char_u *)NULL, PV_NONE,
1487 {(char_u *)NULL, (char_u *)0L}
1488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001489 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001490 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1491 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001492 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001493 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1494 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001495 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1496 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001497 {"helpheight", "hh", P_NUM|P_VI_DEF,
1498#ifdef FEAT_WINDOWS
1499 (char_u *)&p_hh, PV_NONE,
1500#else
1501 (char_u *)NULL, PV_NONE,
1502#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001503 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001504 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001505#ifdef FEAT_MULTI_LANG
1506 (char_u *)&p_hlg, PV_NONE,
1507 {(char_u *)"", (char_u *)0L}
1508#else
1509 (char_u *)NULL, PV_NONE,
1510 {(char_u *)0L, (char_u *)0L}
1511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001512 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001513 {"hidden", "hid", P_BOOL|P_VI_DEF,
1514 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001515 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001516 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001517 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001518 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1519 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001520 {"history", "hi", P_NUM|P_VIM,
1521 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001522 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001523 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1524#ifdef FEAT_RIGHTLEFT
1525 (char_u *)&p_hkmap, PV_NONE,
1526#else
1527 (char_u *)NULL, PV_NONE,
1528#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001529 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1531#ifdef FEAT_RIGHTLEFT
1532 (char_u *)&p_hkmapp, PV_NONE,
1533#else
1534 (char_u *)NULL, PV_NONE,
1535#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001536 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001537 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1538 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001540 {"icon", NULL, P_BOOL|P_VI_DEF,
1541#ifdef FEAT_TITLE
1542 (char_u *)&p_icon, PV_NONE,
1543#else
1544 (char_u *)NULL, PV_NONE,
1545#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001547 {"iconstring", NULL, P_STRING|P_VI_DEF,
1548#ifdef FEAT_TITLE
1549 (char_u *)&p_iconstring, PV_NONE,
1550#else
1551 (char_u *)NULL, PV_NONE,
1552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001553 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001554 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1555 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001557 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1558# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1559 (char_u *)&p_imaf, PV_NONE,
1560 {(char_u *)"", (char_u *)NULL}
1561# else
1562 (char_u *)NULL, PV_NONE,
1563 {(char_u *)NULL, (char_u *)0L}
1564# endif
1565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001566 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001567#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001568 (char_u *)&p_imak, PV_NONE,
1569#else
1570 (char_u *)NULL, PV_NONE,
1571#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001572 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001573 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1574#ifdef USE_IM_CONTROL
1575 (char_u *)&p_imcmdline, PV_NONE,
1576#else
1577 (char_u *)NULL, PV_NONE,
1578#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001579 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001580 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1581#ifdef USE_IM_CONTROL
1582 (char_u *)&p_imdisable, PV_NONE,
1583#else
1584 (char_u *)NULL, PV_NONE,
1585#endif
1586#ifdef __sgi
1587 {(char_u *)TRUE, (char_u *)0L}
1588#else
1589 {(char_u *)FALSE, (char_u *)0L}
1590#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001591 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001592 {"iminsert", "imi", P_NUM|P_VI_DEF,
1593 (char_u *)&p_iminsert, PV_IMI,
1594#ifdef B_IMODE_IM
1595 {(char_u *)B_IMODE_IM, (char_u *)0L}
1596#else
1597 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1598#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001599 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001600 {"imsearch", "ims", P_NUM|P_VI_DEF,
1601 (char_u *)&p_imsearch, PV_IMS,
1602#ifdef B_IMODE_IM
1603 {(char_u *)B_IMODE_IM, (char_u *)0L}
1604#else
1605 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001607 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001608 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001609# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1610 (char_u *)&p_imsf, PV_NONE,
1611 {(char_u *)"", (char_u *)NULL}
1612# else
1613 (char_u *)NULL, PV_NONE,
1614 {(char_u *)NULL, (char_u *)0L}
1615# endif
1616 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001617 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1618#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001619 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001620 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1621#else
1622 (char_u *)NULL, PV_NONE,
1623 {(char_u *)0L, (char_u *)0L}
1624#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001625 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001626 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1627#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1628 (char_u *)&p_inex, PV_INEX,
1629 {(char_u *)"", (char_u *)0L}
1630#else
1631 (char_u *)NULL, PV_NONE,
1632 {(char_u *)0L, (char_u *)0L}
1633#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001634 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001635 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1636 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001637 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001638 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1639#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1640 (char_u *)&p_inde, PV_INDE,
1641 {(char_u *)"", (char_u *)0L}
1642#else
1643 (char_u *)NULL, PV_NONE,
1644 {(char_u *)0L, (char_u *)0L}
1645#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001646 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001647 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001648#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1649 (char_u *)&p_indk, PV_INDK,
1650 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1651#else
1652 (char_u *)NULL, PV_NONE,
1653 {(char_u *)0L, (char_u *)0L}
1654#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001655 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001656 {"infercase", "inf", P_BOOL|P_VI_DEF,
1657 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001658 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001659 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1660 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001661 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001662 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1663 (char_u *)&p_isf, PV_NONE,
1664 {
1665#ifdef BACKSLASH_IN_FILENAME
1666 /* Excluded are: & and ^ are special in cmd.exe
1667 * ( and ) are used in text separating fnames */
1668 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1669#else
1670# ifdef AMIGA
1671 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1672# else
1673# ifdef VMS
1674 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1675# else /* UNIX et al. */
1676# ifdef EBCDIC
1677 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1678# else
1679 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1680# endif
1681# endif
1682# endif
1683#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001684 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001685 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1686 (char_u *)&p_isi, PV_NONE,
1687 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001688#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001689 (char_u *)"@,48-57,_,128-167,224-235",
1690#else
1691# ifdef EBCDIC
1692 /* TODO: EBCDIC Check this! @ == isalpha()*/
1693 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1694 "112-120,128,140-142,156,158,172,"
1695 "174,186,191,203-207,219-225,235-239,"
1696 "251-254",
1697# else
1698 (char_u *)"@,48-57,_,192-255",
1699# endif
1700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001701 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1703 (char_u *)&p_isk, PV_ISK,
1704 {
1705#ifdef EBCDIC
1706 (char_u *)"@,240-249,_",
1707 /* TODO: EBCDIC Check this! @ == isalpha()*/
1708 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1709 "112-120,128,140-142,156,158,172,"
1710 "174,186,191,203-207,219-225,235-239,"
1711 "251-254",
1712#else
1713 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001714# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 (char_u *)"@,48-57,_,128-167,224-235"
1716# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001717 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718# endif
1719#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001720 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001721 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1722 (char_u *)&p_isp, PV_NONE,
1723 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001724#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 || defined(VMS)
1726 (char_u *)"@,~-255",
1727#else
1728# ifdef EBCDIC
1729 /* all chars above 63 are printable */
1730 (char_u *)"63-255",
1731# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001732 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733# endif
1734#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001735 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001736 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1737 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001738 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1740#ifdef FEAT_CRYPT
1741 (char_u *)&p_key, PV_KEY,
1742 {(char_u *)"", (char_u *)0L}
1743#else
1744 (char_u *)NULL, PV_NONE,
1745 {(char_u *)0L, (char_u *)0L}
1746#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001747 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001748 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001749#ifdef FEAT_KEYMAP
1750 (char_u *)&p_keymap, PV_KMAP,
1751 {(char_u *)"", (char_u *)0L}
1752#else
1753 (char_u *)NULL, PV_NONE,
1754 {(char_u *)"", (char_u *)0L}
1755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001756 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001757 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001758 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001760 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001761 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001762 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001763#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 (char_u *)":help",
1765#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001766# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001768# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001769# ifdef USEMAN_S
1770 (char_u *)"man -s",
1771# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001773# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774# endif
1775#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001776 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001777 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778#ifdef FEAT_LANGMAP
1779 (char_u *)&p_langmap, PV_NONE,
1780 {(char_u *)"", /* unmatched } */
1781#else
1782 (char_u *)NULL, PV_NONE,
1783 {(char_u *)NULL,
1784#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001785 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001786 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1788 (char_u *)&p_lm, PV_NONE,
1789#else
1790 (char_u *)NULL, PV_NONE,
1791#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001793 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1794#ifdef FEAT_LANGMAP
1795 (char_u *)&p_lnr, PV_NONE,
1796#else
1797 (char_u *)NULL, PV_NONE,
1798#endif
1799 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001800 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1801#ifdef FEAT_LANGMAP
1802 (char_u *)&p_lrm, PV_NONE,
1803#else
1804 (char_u *)NULL, PV_NONE,
1805#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001806 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001807 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1808#ifdef FEAT_WINDOWS
1809 (char_u *)&p_ls, PV_NONE,
1810#else
1811 (char_u *)NULL, PV_NONE,
1812#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001813 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1815 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001816 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1818#ifdef FEAT_LINEBREAK
1819 (char_u *)VAR_WIN, PV_LBR,
1820#else
1821 (char_u *)NULL, PV_NONE,
1822#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001823 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1825 (char_u *)&Rows, PV_NONE,
1826 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001827#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001828 (char_u *)25L,
1829#else
1830 (char_u *)24L,
1831#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001832 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1834#ifdef FEAT_GUI
1835 (char_u *)&p_linespace, PV_NONE,
1836#else
1837 (char_u *)NULL, PV_NONE,
1838#endif
1839#ifdef FEAT_GUI_W32
1840 {(char_u *)1L, (char_u *)0L}
1841#else
1842 {(char_u *)0L, (char_u *)0L}
1843#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 {"lisp", NULL, P_BOOL|P_VI_DEF,
1846#ifdef FEAT_LISP
1847 (char_u *)&p_lisp, PV_LISP,
1848#else
1849 (char_u *)NULL, PV_NONE,
1850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001851 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001852 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001854 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001855 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1856#else
1857 (char_u *)NULL, PV_NONE,
1858 {(char_u *)"", (char_u *)0L}
1859#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001860 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001861 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1862 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001863 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001864 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001866 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1868 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001869 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001870 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001871#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001872 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001873 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001874#else
1875 (char_u *)NULL, PV_NONE,
1876 {(char_u *)"", (char_u *)0L}
1877#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001878 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001879 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001880#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001881 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001882 {(char_u *)TRUE, (char_u *)0L}
1883#else
1884 (char_u *)NULL, PV_NONE,
1885 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001886#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001887 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001888 {"magic", NULL, P_BOOL|P_VI_DEF,
1889 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001890 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001891 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001892#ifdef FEAT_QUICKFIX
1893 (char_u *)&p_mef, PV_NONE,
1894 {(char_u *)"", (char_u *)0L}
1895#else
1896 (char_u *)NULL, PV_NONE,
1897 {(char_u *)NULL, (char_u *)0L}
1898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 SCRIPTID_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001900 {"makeencoding","menc", P_STRING|P_VI_DEF,
1901#ifdef FEAT_MBYTE
1902 (char_u *)&p_menc, PV_MENC,
1903 {(char_u *)"", (char_u *)0L}
1904#else
1905 (char_u *)NULL, PV_NONE,
1906 {(char_u *)0L, (char_u *)0L}
1907#endif
1908 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001909 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1910#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001911 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001912# ifdef VMS
1913 {(char_u *)"MMS", (char_u *)0L}
1914# else
1915 {(char_u *)"make", (char_u *)0L}
1916# endif
1917#else
1918 (char_u *)NULL, PV_NONE,
1919 {(char_u *)NULL, (char_u *)0L}
1920#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001921 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001922 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001923 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001924 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1925 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001926 {"matchtime", "mat", P_NUM|P_VI_DEF,
1927 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001928 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001929 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001930#ifdef FEAT_MBYTE
1931 (char_u *)&p_mco, PV_NONE,
1932#else
1933 (char_u *)NULL, PV_NONE,
1934#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001935 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1937#ifdef FEAT_EVAL
1938 (char_u *)&p_mfd, PV_NONE,
1939#else
1940 (char_u *)NULL, PV_NONE,
1941#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001942 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1944 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 {"maxmem", "mm", P_NUM|P_VI_DEF,
1947 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1949 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001950 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1951 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001952 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1954 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1956 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001957 {"menuitems", "mis", P_NUM|P_VI_DEF,
1958#ifdef FEAT_MENU
1959 (char_u *)&p_mis, PV_NONE,
1960#else
1961 (char_u *)NULL, PV_NONE,
1962#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 {"mesg", NULL, P_BOOL|P_VI_DEF,
1965 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001966 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001967 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001968#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001969 (char_u *)&p_msm, PV_NONE,
1970 {(char_u *)"460000,2000,500", (char_u *)0L}
1971#else
1972 (char_u *)NULL, PV_NONE,
1973 {(char_u *)0L, (char_u *)0L}
1974#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001975 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001976 {"modeline", "ml", P_BOOL|P_VIM,
1977 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001978 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 {"modelines", "mls", P_NUM|P_VI_DEF,
1980 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1983 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001985 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1986 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"more", NULL, P_BOOL|P_VIM,
1989 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001990 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1992 (char_u *)&p_mouse, PV_NONE,
1993 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001994#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 (char_u *)"a",
1996#else
1997 (char_u *)"",
1998#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
2001#ifdef FEAT_GUI
2002 (char_u *)&p_mousef, PV_NONE,
2003#else
2004 (char_u *)NULL, PV_NONE,
2005#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002006 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 {"mousehide", "mh", P_BOOL|P_VI_DEF,
2008#ifdef FEAT_GUI
2009 (char_u *)&p_mh, PV_NONE,
2010#else
2011 (char_u *)NULL, PV_NONE,
2012#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002013 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002014 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
2015 (char_u *)&p_mousem, PV_NONE,
2016 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002017#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018 (char_u *)"popup",
2019#else
2020# if defined(MACOS)
2021 (char_u *)"popup_setpos",
2022# else
2023 (char_u *)"extend",
2024# endif
2025#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002026 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002027 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002028#ifdef FEAT_MOUSESHAPE
2029 (char_u *)&p_mouseshape, PV_NONE,
2030 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2031#else
2032 (char_u *)NULL, PV_NONE,
2033 {(char_u *)NULL, (char_u *)0L}
2034#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002035 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002036 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2037 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002038 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002039 {"mzquantum", "mzq", P_NUM,
2040#ifdef FEAT_MZSCHEME
2041 (char_u *)&p_mzq, PV_NONE,
2042#else
2043 (char_u *)NULL, PV_NONE,
2044#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002045 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002046 {"novice", NULL, P_BOOL|P_VI_DEF,
2047 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002048 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002049 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002050 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002051 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002052 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002053 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2054 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002055 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002056 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2057#ifdef FEAT_LINEBREAK
2058 (char_u *)VAR_WIN, PV_NUW,
2059#else
2060 (char_u *)NULL, PV_NONE,
2061#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002062 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002063 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002064#ifdef FEAT_COMPL_FUNC
2065 (char_u *)&p_ofu, PV_OFU,
2066 {(char_u *)"", (char_u *)0L}
2067#else
2068 (char_u *)NULL, PV_NONE,
2069 {(char_u *)0L, (char_u *)0L}
2070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002071 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 {"open", NULL, P_BOOL|P_VI_DEF,
2073 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002074 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002075 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002076#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002077 (char_u *)&p_odev, PV_NONE,
2078#else
2079 (char_u *)NULL, PV_NONE,
2080#endif
2081 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002082 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002083 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2084 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086 {"optimize", "opt", P_BOOL|P_VI_DEF,
2087 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002089 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002090 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02002091 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002092 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2093 |P_SECURE,
2094 (char_u *)&p_pp, PV_NONE,
2095 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2096 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002097 {"paragraphs", "para", P_STRING|P_VI_DEF,
2098 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002099 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002100 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002101 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002102 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002103 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002104 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2105 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002106 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002107 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2108#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2109 (char_u *)&p_pex, PV_NONE,
2110 {(char_u *)"", (char_u *)0L}
2111#else
2112 (char_u *)NULL, PV_NONE,
2113 {(char_u *)0L, (char_u *)0L}
2114#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002115 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002116 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002118 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002119 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002120 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002121 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002122#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 (char_u *)".,,",
2124#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002125 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002127 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002128 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002129#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002130 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002131 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002132#else
2133 (char_u *)NULL, PV_NONE,
2134 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002135#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002136 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002137 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2138 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002139 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002140 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002141#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2142 (char_u *)&p_pvh, PV_NONE,
2143#else
2144 (char_u *)NULL, PV_NONE,
2145#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002146 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2148#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2149 (char_u *)VAR_WIN, PV_PVW,
2150#else
2151 (char_u *)NULL, PV_NONE,
2152#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002153 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002154 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155#ifdef FEAT_PRINTER
2156 (char_u *)&p_pdev, PV_NONE,
2157 {(char_u *)"", (char_u *)0L}
2158#else
2159 (char_u *)NULL, PV_NONE,
2160 {(char_u *)NULL, (char_u *)0L}
2161#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002162 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002163 {"printencoding", "penc", P_STRING|P_VI_DEF,
2164#ifdef FEAT_POSTSCRIPT
2165 (char_u *)&p_penc, PV_NONE,
2166 {(char_u *)"", (char_u *)0L}
2167#else
2168 (char_u *)NULL, PV_NONE,
2169 {(char_u *)NULL, (char_u *)0L}
2170#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002171 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002172 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002173#ifdef FEAT_POSTSCRIPT
2174 (char_u *)&p_pexpr, PV_NONE,
2175 {(char_u *)"", (char_u *)0L}
2176#else
2177 (char_u *)NULL, PV_NONE,
2178 {(char_u *)NULL, (char_u *)0L}
2179#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002180 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002181 {"printfont", "pfn", P_STRING|P_VI_DEF,
2182#ifdef FEAT_PRINTER
2183 (char_u *)&p_pfn, PV_NONE,
2184 {
2185# ifdef MSWIN
2186 (char_u *)"Courier_New:h10",
2187# else
2188 (char_u *)"courier",
2189# endif
2190 (char_u *)0L}
2191#else
2192 (char_u *)NULL, PV_NONE,
2193 {(char_u *)NULL, (char_u *)0L}
2194#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002195 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002196 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2197#ifdef FEAT_PRINTER
2198 (char_u *)&p_header, PV_NONE,
2199 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2200#else
2201 (char_u *)NULL, PV_NONE,
2202 {(char_u *)NULL, (char_u *)0L}
2203#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002204 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002205 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2206#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2207 (char_u *)&p_pmcs, PV_NONE,
2208 {(char_u *)"", (char_u *)0L}
2209#else
2210 (char_u *)NULL, PV_NONE,
2211 {(char_u *)NULL, (char_u *)0L}
2212#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002213 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002214 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2215#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2216 (char_u *)&p_pmfn, PV_NONE,
2217 {(char_u *)"", (char_u *)0L}
2218#else
2219 (char_u *)NULL, PV_NONE,
2220 {(char_u *)NULL, (char_u *)0L}
2221#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002222 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002223 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002224#ifdef FEAT_PRINTER
2225 (char_u *)&p_popt, PV_NONE,
2226 {(char_u *)"", (char_u *)0L}
2227#else
2228 (char_u *)NULL, PV_NONE,
2229 {(char_u *)NULL, (char_u *)0L}
2230#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002231 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002232 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002233 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002234 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002235 {"pumheight", "ph", P_NUM|P_VI_DEF,
2236#ifdef FEAT_INS_EXPAND
2237 (char_u *)&p_ph, PV_NONE,
2238#else
2239 (char_u *)NULL, PV_NONE,
2240#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002242 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002243#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002244 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002245 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002246#else
2247 (char_u *)NULL, PV_NONE,
2248 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002249#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002250 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002251 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002252#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002253 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002254 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002255#else
2256 (char_u *)NULL, PV_NONE,
2257 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002258#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002259 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002260 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2261#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2262 (char_u *)&p_pyx, PV_NONE,
2263#else
2264 (char_u *)NULL, PV_NONE,
2265#endif
2266 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2267 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002268 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2269#ifdef FEAT_TEXTOBJ
2270 (char_u *)&p_qe, PV_QE,
2271 {(char_u *)"\\", (char_u *)0L}
2272#else
2273 (char_u *)NULL, PV_NONE,
2274 {(char_u *)NULL, (char_u *)0L}
2275#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002276 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002277 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2278 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002279 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002280 {"redraw", NULL, P_BOOL|P_VI_DEF,
2281 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002282 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002283 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2284#ifdef FEAT_RELTIME
2285 (char_u *)&p_rdt, PV_NONE,
2286#else
2287 (char_u *)NULL, PV_NONE,
2288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002290 {"regexpengine", "re", P_NUM|P_VI_DEF,
2291 (char_u *)&p_re, PV_NONE,
2292 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002293 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2294 (char_u *)VAR_WIN, PV_RNU,
2295 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002296 {"remap", NULL, P_BOOL|P_VI_DEF,
2297 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002298 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002299 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002300#ifdef FEAT_RENDER_OPTIONS
2301 (char_u *)&p_rop, PV_NONE,
2302 {(char_u *)"", (char_u *)0L}
2303#else
2304 (char_u *)NULL, PV_NONE,
2305 {(char_u *)NULL, (char_u *)0L}
2306#endif
2307 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 {"report", NULL, P_NUM|P_VI_DEF,
2309 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002310 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2312#ifdef WIN3264
2313 (char_u *)&p_rs, PV_NONE,
2314#else
2315 (char_u *)NULL, PV_NONE,
2316#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002317 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2319#ifdef FEAT_RIGHTLEFT
2320 (char_u *)&p_ri, PV_NONE,
2321#else
2322 (char_u *)NULL, PV_NONE,
2323#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002324 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2326#ifdef FEAT_RIGHTLEFT
2327 (char_u *)VAR_WIN, PV_RL,
2328#else
2329 (char_u *)NULL, PV_NONE,
2330#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002331 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002332 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2333#ifdef FEAT_RIGHTLEFT
2334 (char_u *)VAR_WIN, PV_RLC,
2335 {(char_u *)"search", (char_u *)NULL}
2336#else
2337 (char_u *)NULL, PV_NONE,
2338 {(char_u *)NULL, (char_u *)0L}
2339#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002340 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002341 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002342#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002343 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002344 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002345#else
2346 (char_u *)NULL, PV_NONE,
2347 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002348#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002349 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002350 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2351#ifdef FEAT_CMDL_INFO
2352 (char_u *)&p_ru, PV_NONE,
2353#else
2354 (char_u *)NULL, PV_NONE,
2355#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002356 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002357 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2358#ifdef FEAT_STL_OPT
2359 (char_u *)&p_ruf, PV_NONE,
2360#else
2361 (char_u *)NULL, PV_NONE,
2362#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002363 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002364 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2365 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002366 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002367 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2368 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002369 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2370 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002371 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2373#ifdef FEAT_SCROLLBIND
2374 (char_u *)VAR_WIN, PV_SCBIND,
2375#else
2376 (char_u *)NULL, PV_NONE,
2377#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2380 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002381 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2383 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002384 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002385 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386#ifdef FEAT_SCROLLBIND
2387 (char_u *)&p_sbo, PV_NONE,
2388 {(char_u *)"ver,jump", (char_u *)0L}
2389#else
2390 (char_u *)NULL, PV_NONE,
2391 {(char_u *)0L, (char_u *)0L}
2392#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002393 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002394 {"sections", "sect", P_STRING|P_VI_DEF,
2395 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002396 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2397 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002398 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2399 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)"inclusive", (char_u *)0L}
2404 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002405 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002406 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002407 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002408 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409#ifdef FEAT_SESSION
2410 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002411 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 (char_u *)0L}
2413#else
2414 (char_u *)NULL, PV_NONE,
2415 {(char_u *)0L, (char_u *)0L}
2416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002417 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2419 (char_u *)&p_sh, PV_NONE,
2420 {
2421#ifdef VMS
2422 (char_u *)"-",
2423#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002424# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002426# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002427 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428# endif
2429#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002430 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2432 (char_u *)&p_shcf, PV_NONE,
2433 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002434#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 (char_u *)"/c",
2436#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002439 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002440 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2441#ifdef FEAT_QUICKFIX
2442 (char_u *)&p_sp, PV_NONE,
2443 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002444#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446#else
2447 (char_u *)">",
2448#endif
2449 (char_u *)0L}
2450#else
2451 (char_u *)NULL, PV_NONE,
2452 {(char_u *)0L, (char_u *)0L}
2453#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002454 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2456 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002457 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2459 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002460 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2462#ifdef BACKSLASH_IN_FILENAME
2463 (char_u *)&p_ssl, PV_NONE,
2464#else
2465 (char_u *)NULL, PV_NONE,
2466#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002468 {"shelltemp", "stmp", P_BOOL,
2469 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002471 {"shelltype", "st", P_NUM|P_VI_DEF,
2472#ifdef AMIGA
2473 (char_u *)&p_st, PV_NONE,
2474#else
2475 (char_u *)NULL, PV_NONE,
2476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002478 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2479 (char_u *)&p_sxq, PV_NONE,
2480 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002481#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 (char_u *)"\"",
2483#else
2484 (char_u *)"",
2485#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002486 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002487 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2488 (char_u *)&p_sxe, PV_NONE,
2489 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002490#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002491 (char_u *)"\"&|<>()@^",
2492#else
2493 (char_u *)"",
2494#endif
2495 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002496 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2497 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002498 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002499 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2500 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002501 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2503 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002504 {(char_u *)"", (char_u *)"filnxtToO"}
2505 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002508 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2510#ifdef FEAT_LINEBREAK
2511 (char_u *)&p_sbr, PV_NONE,
2512#else
2513 (char_u *)NULL, PV_NONE,
2514#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002515 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"showcmd", "sc", P_BOOL|P_VIM,
2517#ifdef FEAT_CMDL_INFO
2518 (char_u *)&p_sc, PV_NONE,
2519#else
2520 (char_u *)NULL, PV_NONE,
2521#endif
2522 {(char_u *)FALSE,
2523#ifdef UNIX
2524 (char_u *)FALSE
2525#else
2526 (char_u *)TRUE
2527#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002528 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002529 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2530 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002531 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002532 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2533 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002534 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002535 {"showmode", "smd", P_BOOL|P_VIM,
2536 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002537 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002538 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2539#ifdef FEAT_WINDOWS
2540 (char_u *)&p_stal, PV_NONE,
2541#else
2542 (char_u *)NULL, PV_NONE,
2543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2546 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002547 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002548 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2549 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002550 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002551 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2552#ifdef FEAT_SIGNS
2553 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002554 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002555#else
2556 (char_u *)NULL, PV_NONE,
2557 {(char_u *)NULL, (char_u *)0L}
2558#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002559 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002560 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2561 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2564 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002565 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2567#ifdef FEAT_SMARTINDENT
2568 (char_u *)&p_si, PV_SI,
2569#else
2570 (char_u *)NULL, PV_NONE,
2571#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002572 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2574 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002575 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2577 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2580 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002582 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002583#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002584 (char_u *)VAR_WIN, PV_SPELL,
2585#else
2586 (char_u *)NULL, PV_NONE,
2587#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002589 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002590#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002591 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002592 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002593#else
2594 (char_u *)NULL, PV_NONE,
2595 {(char_u *)0L, (char_u *)0L}
2596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002597 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002598 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2599 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002600#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002601 (char_u *)&p_spf, PV_SPF,
2602 {(char_u *)"", (char_u *)0L}
2603#else
2604 (char_u *)NULL, PV_NONE,
2605 {(char_u *)0L, (char_u *)0L}
2606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002607 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002608 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2609 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002610#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002611 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002612 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002613#else
2614 (char_u *)NULL, PV_NONE,
2615 {(char_u *)0L, (char_u *)0L}
2616#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002617 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002618 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002619#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002620 (char_u *)&p_sps, PV_NONE,
2621 {(char_u *)"best", (char_u *)0L}
2622#else
2623 (char_u *)NULL, PV_NONE,
2624 {(char_u *)0L, (char_u *)0L}
2625#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002626 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2628#ifdef FEAT_WINDOWS
2629 (char_u *)&p_sb, PV_NONE,
2630#else
2631 (char_u *)NULL, PV_NONE,
2632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002633 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002635#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 (char_u *)&p_spr, PV_NONE,
2637#else
2638 (char_u *)NULL, PV_NONE,
2639#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002640 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2642 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002643 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2645#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002646 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647#else
2648 (char_u *)NULL, PV_NONE,
2649#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002651 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002652 (char_u *)&p_su, PV_NONE,
2653 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002654 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002655 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002656#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657 (char_u *)&p_sua, PV_SUA,
2658 {(char_u *)"", (char_u *)0L}
2659#else
2660 (char_u *)NULL, PV_NONE,
2661 {(char_u *)0L, (char_u *)0L}
2662#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002663 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2665 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002666 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667 {"swapsync", "sws", P_STRING|P_VI_DEF,
2668 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002670 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002671 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002672 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002673 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2674#ifdef FEAT_SYN_HL
2675 (char_u *)&p_smc, PV_SMC,
2676 {(char_u *)3000L, (char_u *)0L}
2677#else
2678 (char_u *)NULL, PV_NONE,
2679 {(char_u *)0L, (char_u *)0L}
2680#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002681 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002682 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002683#ifdef FEAT_SYN_HL
2684 (char_u *)&p_syn, PV_SYN,
2685 {(char_u *)"", (char_u *)0L}
2686#else
2687 (char_u *)NULL, PV_NONE,
2688 {(char_u *)0L, (char_u *)0L}
2689#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002690 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002691 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2692#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002693 (char_u *)&p_tal, PV_NONE,
2694#else
2695 (char_u *)NULL, PV_NONE,
2696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002697 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002698 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2699#ifdef FEAT_WINDOWS
2700 (char_u *)&p_tpm, PV_NONE,
2701#else
2702 (char_u *)NULL, PV_NONE,
2703#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002704 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002705 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2706 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002707 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002708 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2709 (char_u *)&p_tbs, PV_NONE,
2710#ifdef VMS /* binary searching doesn't appear to work on VMS */
2711 {(char_u *)0L, (char_u *)0L}
2712#else
2713 {(char_u *)TRUE, (char_u *)0L}
2714#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002715 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002716 {"tagcase", "tc", P_STRING|P_VIM,
2717 (char_u *)&p_tc, PV_TC,
2718 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719 {"taglength", "tl", P_NUM|P_VI_DEF,
2720 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002721 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002722 {"tagrelative", "tr", P_BOOL|P_VIM,
2723 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002724 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002725 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002726 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {
2728#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2729 (char_u *)"./tags,./TAGS,tags,TAGS",
2730#else
2731 (char_u *)"./tags,tags",
2732#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002733 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2735 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002736 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002737 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002738#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002739 (char_u *)&p_tcldll, PV_NONE,
2740 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002741#else
2742 (char_u *)NULL, PV_NONE,
2743 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002744#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002745 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002746 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2747 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002748 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002749 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2750#ifdef FEAT_ARABIC
2751 (char_u *)&p_tbidi, PV_NONE,
2752#else
2753 (char_u *)NULL, PV_NONE,
2754#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2757#ifdef FEAT_MBYTE
2758 (char_u *)&p_tenc, PV_NONE,
2759 {(char_u *)"", (char_u *)0L}
2760#else
2761 (char_u *)NULL, PV_NONE,
2762 {(char_u *)0L, (char_u *)0L}
2763#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002764 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002765 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2766#ifdef FEAT_TERMGUICOLORS
2767 (char_u *)&p_tgc, PV_NONE,
2768 {(char_u *)FALSE, (char_u *)FALSE}
2769#else
2770 (char_u*)NULL, PV_NONE,
2771 {(char_u *)FALSE, (char_u *)FALSE}
2772#endif
2773 SCRIPTID_INIT},
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002774 {"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2775#ifdef FEAT_TERMINAL
2776 (char_u *)VAR_WIN, PV_TK,
Bram Moolenaar1f28b4c2017-07-28 13:48:34 +02002777 {(char_u *)"", (char_u *)NULL}
Bram Moolenaar1b0675c2017-07-15 14:04:01 +02002778#else
2779 (char_u *)NULL, PV_NONE,
2780 {(char_u *)NULL, (char_u *)0L}
2781#endif
2782 SCRIPTID_INIT},
Bram Moolenaare4f25e42017-07-07 11:54:15 +02002783 {"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
2784#ifdef FEAT_TERMINAL
2785 (char_u *)VAR_WIN, PV_TMS,
2786 {(char_u *)"", (char_u *)NULL}
2787#else
2788 (char_u *)NULL, PV_NONE,
2789 {(char_u *)NULL, (char_u *)0L}
2790#endif
2791 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002792 {"terse", NULL, P_BOOL|P_VI_DEF,
2793 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002794 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002795 {"textauto", "ta", P_BOOL|P_VIM,
2796 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002797 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2798 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002799 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2800 (char_u *)&p_tx, PV_TX,
2801 {
2802#ifdef USE_CRNL
2803 (char_u *)TRUE,
2804#else
2805 (char_u *)FALSE,
2806#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002808 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002811 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002813 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814#else
2815 (char_u *)NULL, PV_NONE,
2816#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002817 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002818 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2819 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002820 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 {"timeout", "to", P_BOOL|P_VI_DEF,
2822 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002823 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2825 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002826 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002827 {"title", NULL, P_BOOL|P_VI_DEF,
2828#ifdef FEAT_TITLE
2829 (char_u *)&p_title, PV_NONE,
2830#else
2831 (char_u *)NULL, PV_NONE,
2832#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002833 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002834 {"titlelen", NULL, P_NUM|P_VI_DEF,
2835#ifdef FEAT_TITLE
2836 (char_u *)&p_titlelen, PV_NONE,
2837#else
2838 (char_u *)NULL, PV_NONE,
2839#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002840 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002841 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002842#ifdef FEAT_TITLE
2843 (char_u *)&p_titleold, PV_NONE,
2844 {(char_u *)N_("Thanks for flying Vim"),
2845 (char_u *)0L}
2846#else
2847 (char_u *)NULL, PV_NONE,
2848 {(char_u *)0L, (char_u *)0L}
2849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002850 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002851 {"titlestring", NULL, P_STRING|P_VI_DEF,
2852#ifdef FEAT_TITLE
2853 (char_u *)&p_titlestring, PV_NONE,
2854#else
2855 (char_u *)NULL, PV_NONE,
2856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002857 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002858 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002859#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002860 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002862#else
2863 (char_u *)NULL, PV_NONE,
2864 {(char_u *)0L, (char_u *)0L}
2865#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002866 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002868#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002869 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002870 {(char_u *)"small", (char_u *)0L}
2871#else
2872 (char_u *)NULL, PV_NONE,
2873 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002875 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002876 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2877 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002878 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002879 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2880 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002881 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002882 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2883 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002884 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002885 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2886 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002887 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002888 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2889#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2890 (char_u *)&p_ttym, PV_NONE,
2891#else
2892 (char_u *)NULL, PV_NONE,
2893#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002894 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002895 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2896 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002897 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2899 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002900 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002901 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2902 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002903#ifdef FEAT_PERSISTENT_UNDO
2904 (char_u *)&p_udir, PV_NONE,
2905 {(char_u *)".", (char_u *)0L}
2906#else
2907 (char_u *)NULL, PV_NONE,
2908 {(char_u *)0L, (char_u *)0L}
2909#endif
2910 SCRIPTID_INIT},
2911 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2912#ifdef FEAT_PERSISTENT_UNDO
2913 (char_u *)&p_udf, PV_UDF,
2914#else
2915 (char_u *)NULL, PV_NONE,
2916#endif
2917 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002918 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002919 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002920 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002921#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 (char_u *)1000L,
2923#else
2924 (char_u *)100L,
2925#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002926 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002927 {"undoreload", "ur", P_NUM|P_VI_DEF,
2928 (char_u *)&p_ur, PV_NONE,
2929 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930 {"updatecount", "uc", P_NUM|P_VI_DEF,
2931 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002932 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002933 {"updatetime", "ut", P_NUM|P_VI_DEF,
2934 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002935 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002936 {"verbose", "vbs", P_NUM|P_VI_DEF,
2937 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002938 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002939 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2940 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002941 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002942 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2943#ifdef FEAT_SESSION
2944 (char_u *)&p_vdir, PV_NONE,
2945 {(char_u *)DFLT_VDIR, (char_u *)0L}
2946#else
2947 (char_u *)NULL, PV_NONE,
2948 {(char_u *)0L, (char_u *)0L}
2949#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002950 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002951 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002952#ifdef FEAT_SESSION
2953 (char_u *)&p_vop, PV_NONE,
2954 {(char_u *)"folds,options,cursor", (char_u *)0L}
2955#else
2956 (char_u *)NULL, PV_NONE,
2957 {(char_u *)0L, (char_u *)0L}
2958#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002959 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002960 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002961#ifdef FEAT_VIMINFO
2962 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002963#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002964 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002965#else
2966# ifdef AMIGA
2967 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002968 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002969# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002970 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971# endif
2972#endif
2973#else
2974 (char_u *)NULL, PV_NONE,
2975 {(char_u *)0L, (char_u *)0L}
2976#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002977 SCRIPTID_INIT},
Bram Moolenaarc4da1132017-07-15 19:39:43 +02002978 {"viminfofile", "vif", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE|P_VI_DEF,
2979#ifdef FEAT_VIMINFO
2980 (char_u *)&p_viminfofile, PV_NONE,
2981 {(char_u *)"", (char_u *)0L}
2982#else
2983 (char_u *)NULL, PV_NONE,
2984 {(char_u *)0L, (char_u *)0L}
2985#endif
2986 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002987 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2988 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989#ifdef FEAT_VIRTUALEDIT
2990 (char_u *)&p_ve, PV_NONE,
2991 {(char_u *)"", (char_u *)""}
2992#else
2993 (char_u *)NULL, PV_NONE,
2994 {(char_u *)0L, (char_u *)0L}
2995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002996 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002997 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2998 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002999 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003000 {"w300", NULL, P_NUM|P_VI_DEF,
3001 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003002 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 {"w1200", NULL, P_NUM|P_VI_DEF,
3004 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003005 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003006 {"w9600", NULL, P_NUM|P_VI_DEF,
3007 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003008 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003009 {"warn", NULL, P_BOOL|P_VI_DEF,
3010 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003011 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
3013 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003014 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003015 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003016 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003017 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018 {"wildchar", "wc", P_NUM|P_VIM,
3019 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003020 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3021 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003022 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003024 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003025 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003026#ifdef FEAT_WILDIGN
3027 (char_u *)&p_wig, PV_NONE,
3028#else
3029 (char_u *)NULL, PV_NONE,
3030#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003031 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003032 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3033 (char_u *)&p_wic, PV_NONE,
3034 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003035 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3036#ifdef FEAT_WILDMENU
3037 (char_u *)&p_wmnu, PV_NONE,
3038#else
3039 (char_u *)NULL, PV_NONE,
3040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003041 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003042 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003043 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003044 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003045 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3046#ifdef FEAT_CMDL_COMPL
3047 (char_u *)&p_wop, PV_NONE,
3048 {(char_u *)"", (char_u *)0L}
3049#else
3050 (char_u *)NULL, PV_NONE,
3051 {(char_u *)NULL, (char_u *)0L}
3052#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003053 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3055#ifdef FEAT_WAK
3056 (char_u *)&p_wak, PV_NONE,
3057 {(char_u *)"menu", (char_u *)0L}
3058#else
3059 (char_u *)NULL, PV_NONE,
3060 {(char_u *)NULL, (char_u *)0L}
3061#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003062 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003063 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003064 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003065 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003066 {"winheight", "wh", P_NUM|P_VI_DEF,
3067#ifdef FEAT_WINDOWS
3068 (char_u *)&p_wh, PV_NONE,
3069#else
3070 (char_u *)NULL, PV_NONE,
3071#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003072 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003074#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003075 (char_u *)VAR_WIN, PV_WFH,
3076#else
3077 (char_u *)NULL, PV_NONE,
3078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003079 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003080 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003081#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003082 (char_u *)VAR_WIN, PV_WFW,
3083#else
3084 (char_u *)NULL, PV_NONE,
3085#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003086 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3088#ifdef FEAT_WINDOWS
3089 (char_u *)&p_wmh, PV_NONE,
3090#else
3091 (char_u *)NULL, PV_NONE,
3092#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003093 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003095#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096 (char_u *)&p_wmw, PV_NONE,
3097#else
3098 (char_u *)NULL, PV_NONE,
3099#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003100 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003101 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003102#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103 (char_u *)&p_wiw, PV_NONE,
3104#else
3105 (char_u *)NULL, PV_NONE,
3106#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003107 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003108 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3109 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003110 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003111 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3112 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003113 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3115 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003116 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117 {"write", NULL, P_BOOL|P_VI_DEF,
3118 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003119 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003120 {"writeany", "wa", P_BOOL|P_VI_DEF,
3121 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003122 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003123 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3124 (char_u *)&p_wb, PV_NONE,
3125 {
3126#ifdef FEAT_WRITEBACKUP
3127 (char_u *)TRUE,
3128#else
3129 (char_u *)FALSE,
3130#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003131 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003132 {"writedelay", "wd", P_NUM|P_VI_DEF,
3133 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003134 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003135
3136/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003137#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003138 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003139 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140
3141 p_term("t_AB", T_CAB)
3142 p_term("t_AF", T_CAF)
3143 p_term("t_AL", T_CAL)
3144 p_term("t_al", T_AL)
3145 p_term("t_bc", T_BC)
3146 p_term("t_cd", T_CD)
3147 p_term("t_ce", T_CE)
3148 p_term("t_cl", T_CL)
3149 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003150 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151 p_term("t_Co", T_CCO)
3152 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003153 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003154 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003155#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156 p_term("t_CV", T_CSV)
3157#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158 p_term("t_da", T_DA)
3159 p_term("t_db", T_DB)
3160 p_term("t_DL", T_CDL)
3161 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02003162 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 p_term("t_fs", T_FS)
3164 p_term("t_IE", T_CIE)
Bram Moolenaar3cd43cc2017-08-12 19:51:41 +02003165 p_term("t_SC", T_CSC)
3166 p_term("t_EC", T_CEC)
3167 p_term("t_SH", T_CSH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168 p_term("t_IS", T_CIS)
3169 p_term("t_ke", T_KE)
3170 p_term("t_ks", T_KS)
3171 p_term("t_le", T_LE)
3172 p_term("t_mb", T_MB)
3173 p_term("t_md", T_MD)
3174 p_term("t_me", T_ME)
3175 p_term("t_mr", T_MR)
3176 p_term("t_ms", T_MS)
3177 p_term("t_nd", T_ND)
3178 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003179 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003180 p_term("t_RI", T_CRI)
3181 p_term("t_RV", T_CRV)
3182 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003183 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003184 p_term("t_Sf", T_CSF)
3185 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003186 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003187 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003188 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003189 p_term("t_te", T_TE)
3190 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003191 p_term("t_ts", T_TS)
3192 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003193 p_term("t_ue", T_UE)
3194 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003195 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003196 p_term("t_vb", T_VB)
3197 p_term("t_ve", T_VE)
3198 p_term("t_vi", T_VI)
3199 p_term("t_vs", T_VS)
3200 p_term("t_WP", T_CWP)
Bram Moolenaar9f928862017-04-11 22:44:05 +02003201 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003203 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003204 p_term("t_xs", T_XS)
3205 p_term("t_ZH", T_CZH)
3206 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003207 p_term("t_8f", T_8F)
3208 p_term("t_8b", T_8B)
Bram Moolenaarec2da362017-01-21 20:04:22 +01003209 p_term("t_BE", T_BE)
3210 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211
3212/* terminal key codes are not in here */
3213
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003214 /* end marker */
3215 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216};
3217
3218#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3219
3220#ifdef FEAT_MBYTE
3221static char *(p_ambw_values[]) = {"single", "double", NULL};
3222#endif
3223static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003224static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003225static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003226#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003227static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003228#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003229#ifdef FEAT_CMDL_COMPL
3230static char *(p_wop_values[]) = {"tagfile", NULL};
3231#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232#ifdef FEAT_WAK
3233static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3234#endif
3235static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003236static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3237static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003239#ifdef FEAT_BROWSE
3240static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3241#endif
3242#ifdef FEAT_SCROLLBIND
3243static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3244#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003245static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003246#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003247static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3248#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003249#ifdef FEAT_AUTOCMD
3250static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL};
3251#else
3252static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253#endif
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02003254static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3256#ifdef FEAT_FOLDING
3257static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003258# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003259 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003260# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003261 NULL};
3262static char *(p_fcl_values[]) = {"all", NULL};
3263#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003264#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003265static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003266#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003267#ifdef FEAT_SIGNS
3268static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3269#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003270
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003271static void set_option_default(int, int opt_flags, int compatible);
3272static void set_options_default(int opt_flags);
3273static char_u *term_bg_default(void);
3274static void did_set_option(int opt_idx, int opt_flags, int new_value);
3275static char_u *illegal_char(char_u *, int);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003276#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003277static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278#endif
3279#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003280static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003282static char_u *option_expand(int opt_idx, char_u *val);
3283static void didset_options(void);
3284static void didset_options2(void);
3285static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003286#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003287static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003288#else
3289# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3290#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003291static void set_string_option_global(int opt_idx, char_u **varp);
3292static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3293static 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);
3294static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003295#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003296static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003297#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003298#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003299static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003300#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003301#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003302static char_u *did_set_spell_option(int is_spellfile);
3303static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003304#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003305#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003306static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003307#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003308static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3309static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3310static void check_redraw(long_u flags);
3311static int findoption(char_u *);
3312static int find_key_option(char_u *);
3313static void showoptions(int all, int opt_flags);
3314static int optval_default(struct vimoption *, char_u *varp);
3315static void showoneopt(struct vimoption *, int opt_flags);
3316static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3317static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3318static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3319static int istermoption(struct vimoption *);
3320static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3321static char_u *get_varp(struct vimoption *);
3322static void option_value2string(struct vimoption *, int opt_flags);
3323static void check_winopt(winopt_T *wop);
3324static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003325#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003326static void langmap_init(void);
3327static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003328#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003329static void paste_option_changed(void);
3330static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003331#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003332static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003333#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003334static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3335static int check_opt_strings(char_u *val, char **values, int);
3336static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003337#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003338static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003339#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003340
3341/*
3342 * Initialize the options, first part.
3343 *
3344 * Called only once from main(), just after creating the first buffer.
3345 */
3346 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003347set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348{
3349 char_u *p;
3350 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003351 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003352
3353#ifdef FEAT_LANGMAP
3354 langmap_init();
3355#endif
3356
3357 /* Be Vi compatible by default */
3358 p_cp = TRUE;
3359
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003360 /* Use POSIX compatibility when $VIM_POSIX is set. */
3361 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003362 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003363 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003364 set_string_default("shm", (char_u *)"A");
3365 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003366
Bram Moolenaar071d4272004-06-13 20:20:40 +00003367 /*
3368 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003369 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003371 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003372#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003373 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003374# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003375 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003376# endif
3377#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003378 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003379 set_string_default("sh", p);
3380
3381#ifdef FEAT_WILDIGN
3382 /*
3383 * Set the default for 'backupskip' to include environment variables for
3384 * temp files.
3385 */
3386 {
3387# ifdef UNIX
3388 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3389# else
3390 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3391# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003392 int len;
3393 garray_T ga;
3394 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395
3396 ga_init2(&ga, 1, 100);
3397 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3398 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003399 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003400# ifdef UNIX
3401 if (*names[n] == NUL)
3402 p = (char_u *)"/tmp";
3403 else
3404# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003405 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003406 if (p != NULL && *p != NUL)
3407 {
3408 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003409 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003410 if (ga_grow(&ga, len) == OK)
3411 {
3412 if (ga.ga_len > 0)
3413 STRCAT(ga.ga_data, ",");
3414 STRCAT(ga.ga_data, p);
3415 add_pathsep(ga.ga_data);
3416 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003417 ga.ga_len += len;
3418 }
3419 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003420 if (mustfree)
3421 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003422 }
3423 if (ga.ga_data != NULL)
3424 {
3425 set_string_default("bsk", ga.ga_data);
3426 vim_free(ga.ga_data);
3427 }
3428 }
3429#endif
3430
3431 /*
3432 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3433 */
3434 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003435 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003436 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003437#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3438 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3439#endif
3440 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003441#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003442 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003443 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003444#else
3445# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003446 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003447 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003448# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003449 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003450# endif
3451#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003453 opt_idx = findoption((char_u *)"maxmem");
3454 if (opt_idx >= 0)
3455 {
3456#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003457 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3458 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003459#endif
3460 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3461 }
3462 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003463 }
3464
Bram Moolenaar071d4272004-06-13 20:20:40 +00003465#ifdef FEAT_SEARCHPATH
3466 {
3467 char_u *cdpath;
3468 char_u *buf;
3469 int i;
3470 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003471 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003472
3473 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003474 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003475 if (cdpath != NULL)
3476 {
3477 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3478 if (buf != NULL)
3479 {
3480 buf[0] = ','; /* start with ",", current dir first */
3481 j = 1;
3482 for (i = 0; cdpath[i] != NUL; ++i)
3483 {
3484 if (vim_ispathlistsep(cdpath[i]))
3485 buf[j++] = ',';
3486 else
3487 {
3488 if (cdpath[i] == ' ' || cdpath[i] == ',')
3489 buf[j++] = '\\';
3490 buf[j++] = cdpath[i];
3491 }
3492 }
3493 buf[j] = NUL;
3494 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003495 if (opt_idx >= 0)
3496 {
3497 options[opt_idx].def_val[VI_DEFAULT] = buf;
3498 options[opt_idx].flags |= P_DEF_ALLOCED;
3499 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003500 else
3501 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003502 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003503 if (mustfree)
3504 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003505 }
3506 }
3507#endif
3508
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003509#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003510 /* Set print encoding on platforms that don't default to latin1 */
3511 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003512# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003513 (char_u *)"cp1252"
3514# else
3515# ifdef VMS
3516 (char_u *)"dec-mcs"
3517# else
3518# ifdef EBCDIC
3519 (char_u *)"ebcdic-uk"
3520# else
3521# ifdef MAC
3522 (char_u *)"mac-roman"
3523# else /* HPUX */
3524 (char_u *)"hp-roman8"
3525# endif
3526# endif
3527# endif
3528# endif
3529 );
3530#endif
3531
3532#ifdef FEAT_POSTSCRIPT
3533 /* 'printexpr' must be allocated to be able to evaluate it. */
3534 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003535# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003536 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003537# else
3538# ifdef VMS
3539 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3540
3541# else
3542 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3543# endif
3544# endif
3545 );
3546#endif
3547
3548 /*
3549 * Set all the options (except the terminal options) to their default
3550 * value. Also set the global value for local options.
3551 */
3552 set_options_default(0);
3553
3554#ifdef FEAT_GUI
3555 if (found_reverse_arg)
3556 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3557#endif
3558
3559 curbuf->b_p_initialized = TRUE;
3560 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003561 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003562 check_buf_options(curbuf);
3563 check_win_options(curwin);
3564 check_options();
3565
3566 /* Must be before option_expand(), because that one needs vim_isIDc() */
3567 didset_options();
3568
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003569#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003570 /* Use the current chartab for the generic chartab. This is not in
3571 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003572 init_spell_chartab();
3573#endif
3574
Bram Moolenaar071d4272004-06-13 20:20:40 +00003575 /*
3576 * Expand environment variables and things like "~" for the defaults.
3577 * If option_expand() returns non-NULL the variable is expanded. This can
3578 * only happen for non-indirect options.
3579 * Also set the default to the expanded value, so ":set" does not list
3580 * them.
3581 * Don't set the P_ALLOCED flag, because we don't want to free the
3582 * default.
3583 */
3584 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3585 {
3586 if ((options[opt_idx].flags & P_GETTEXT)
3587 && options[opt_idx].var != NULL)
3588 p = (char_u *)_(*(char **)options[opt_idx].var);
3589 else
3590 p = option_expand(opt_idx, NULL);
3591 if (p != NULL && (p = vim_strsave(p)) != NULL)
3592 {
3593 *(char_u **)options[opt_idx].var = p;
3594 /* VIMEXP
3595 * Defaults for all expanded options are currently the same for Vi
3596 * and Vim. When this changes, add some code here! Also need to
3597 * split P_DEF_ALLOCED in two.
3598 */
3599 if (options[opt_idx].flags & P_DEF_ALLOCED)
3600 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3601 options[opt_idx].def_val[VI_DEFAULT] = p;
3602 options[opt_idx].flags |= P_DEF_ALLOCED;
3603 }
3604 }
3605
Bram Moolenaar071d4272004-06-13 20:20:40 +00003606 save_file_ff(curbuf); /* Buffer is unchanged */
3607
Bram Moolenaar071d4272004-06-13 20:20:40 +00003608#if defined(FEAT_ARABIC)
3609 /* Detect use of mlterm.
3610 * Mlterm is a terminal emulator akin to xterm that has some special
3611 * abilities (bidi namely).
3612 * NOTE: mlterm's author is being asked to 'set' a variable
3613 * instead of an environment variable due to inheritance.
3614 */
3615 if (mch_getenv((char_u *)"MLTERM") != NULL)
3616 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3617#endif
3618
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003619 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003620
3621#ifdef FEAT_MBYTE
3622# if defined(WIN3264) && defined(FEAT_GETTEXT)
3623 /*
3624 * If $LANG isn't set, try to get a good value for it. This makes the
3625 * right language be used automatically. Don't do this for English.
3626 */
3627 if (mch_getenv((char_u *)"LANG") == NULL)
3628 {
3629 char buf[20];
3630
3631 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3632 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3633 * only the first two. */
3634 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3635 (LPTSTR)buf, 20);
3636 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3637 {
3638 /* There are a few exceptions (probably more) */
3639 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3640 STRCPY(buf, "zh_TW");
3641 else if (STRNICMP(buf, "chs", 3) == 0
3642 || STRNICMP(buf, "zhc", 3) == 0)
3643 STRCPY(buf, "zh_CN");
3644 else if (STRNICMP(buf, "jp", 2) == 0)
3645 STRCPY(buf, "ja");
3646 else
3647 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003648 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003649 }
3650 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003651# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003652# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003653 /* Moved to os_mac_conv.c to avoid dependency problems. */
3654 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003655# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003656# endif
3657
3658 /* enc_locale() will try to find the encoding of the current locale. */
3659 p = enc_locale();
3660 if (p != NULL)
3661 {
3662 char_u *save_enc;
3663
3664 /* Try setting 'encoding' and check if the value is valid.
3665 * If not, go back to the default "latin1". */
3666 save_enc = p_enc;
3667 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003668 if (STRCMP(p_enc, "gb18030") == 0)
3669 {
3670 /* We don't support "gb18030", but "cp936" is a good substitute
3671 * for practical purposes, thus use that. It's not an alias to
3672 * still support conversion between gb18030 and utf-8. */
3673 p_enc = vim_strsave((char_u *)"cp936");
3674 vim_free(p);
3675 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003676 if (mb_init() == NULL)
3677 {
3678 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003679 if (opt_idx >= 0)
3680 {
3681 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3682 options[opt_idx].flags |= P_DEF_ALLOCED;
3683 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003684
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003685#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003686 if (STRCMP(p_enc, "latin1") == 0
3687# ifdef FEAT_MBYTE
3688 || enc_utf8
3689# endif
3690 )
3691 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003692 /* Adjust the default for 'isprint' and 'iskeyword' to match
3693 * latin1. Also set the defaults for when 'nocompatible' is
3694 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003695 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003696 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003697 set_string_option_direct((char_u *)"isk", -1,
3698 ISK_LATIN1, OPT_FREE, SID_NONE);
3699 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003700 if (opt_idx >= 0)
3701 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003702 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003703 if (opt_idx >= 0)
3704 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003705 (void)init_chartab();
3706 }
3707#endif
3708
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709# if defined(WIN3264) && !defined(FEAT_GUI)
3710 /* Win32 console: When GetACP() returns a different value from
3711 * GetConsoleCP() set 'termencoding'. */
3712 if (GetACP() != GetConsoleCP())
3713 {
3714 char buf[50];
3715
3716 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3717 p_tenc = vim_strsave((char_u *)buf);
3718 if (p_tenc != NULL)
3719 {
3720 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003721 if (opt_idx >= 0)
3722 {
3723 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3724 options[opt_idx].flags |= P_DEF_ALLOCED;
3725 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003726 convert_setup(&input_conv, p_tenc, p_enc);
3727 convert_setup(&output_conv, p_enc, p_tenc);
3728 }
3729 else
3730 p_tenc = empty_option;
3731 }
3732# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003733# if defined(WIN3264) && defined(FEAT_MBYTE)
3734 /* $HOME may have characters in active code page. */
3735 init_homedir();
3736# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003737 }
3738 else
3739 {
3740 vim_free(p_enc);
3741 p_enc = save_enc;
3742 }
3743 }
3744#endif
3745
3746#ifdef FEAT_MULTI_LANG
3747 /* Set the default for 'helplang'. */
3748 set_helplang_default(get_mess_lang());
3749#endif
3750}
3751
3752/*
3753 * Set an option to its default value.
3754 * This does not take care of side effects!
3755 */
3756 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003757set_option_default(
3758 int opt_idx,
3759 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3760 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003761{
3762 char_u *varp; /* pointer to variable for current option */
3763 int dvi; /* index in def_val[] */
3764 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003765 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003766 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3767
3768 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3769 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003770 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003771 {
3772 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3773 if (flags & P_STRING)
3774 {
3775 /* Use set_string_option_direct() for local options to handle
3776 * freeing and allocating the value. */
3777 if (options[opt_idx].indir != PV_NONE)
3778 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003779 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003780 else
3781 {
3782 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3783 free_string_option(*(char_u **)(varp));
3784 *(char_u **)varp = options[opt_idx].def_val[dvi];
3785 options[opt_idx].flags &= ~P_ALLOCED;
3786 }
3787 }
3788 else if (flags & P_NUM)
3789 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003790 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003791 win_comp_scroll(curwin);
3792 else
3793 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003794 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795 /* May also set global value for local option. */
3796 if (both)
3797 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3798 *(long *)varp;
3799 }
3800 }
3801 else /* P_BOOL */
3802 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003803 /* the cast to long is required for Manx C, long_i is needed for
3804 * MSVC */
3805 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003806#ifdef UNIX
3807 /* 'modeline' defaults to off for root */
3808 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3809 *(int *)varp = FALSE;
3810#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003811 /* May also set global value for local option. */
3812 if (both)
3813 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3814 *(int *)varp;
3815 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003816
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003817 /* The default value is not insecure. */
3818 flagsp = insecure_flag(opt_idx, opt_flags);
3819 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003820 }
3821
3822#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003823 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003824#endif
3825}
3826
3827/*
3828 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003829 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003830 */
3831 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003832set_options_default(
3833 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003834{
3835 int i;
3836#ifdef FEAT_WINDOWS
3837 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003838 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003839#endif
3840
3841 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003842 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003843#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003844 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003845 || (TRUE
3846# if defined(FEAT_MBYTE)
3847 && options[i].var != (char_u *)&p_enc
3848# endif
3849# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003850 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003851 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003852# endif
3853 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003854#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003855 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003856 set_option_default(i, opt_flags, p_cp);
3857
3858#ifdef FEAT_WINDOWS
3859 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003860 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003861 win_comp_scroll(wp);
3862#else
3863 win_comp_scroll(curwin);
3864#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003865#ifdef FEAT_CINDENT
3866 parse_cino(curbuf);
3867#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003868}
3869
3870/*
3871 * Set the Vi-default value of a string option.
3872 * Used for 'sh', 'backupskip' and 'term'.
3873 */
3874 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003875set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876{
3877 char_u *p;
3878 int opt_idx;
3879
3880 p = vim_strsave(val);
3881 if (p != NULL) /* we don't want a NULL */
3882 {
3883 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003884 if (opt_idx >= 0)
3885 {
3886 if (options[opt_idx].flags & P_DEF_ALLOCED)
3887 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3888 options[opt_idx].def_val[VI_DEFAULT] = p;
3889 options[opt_idx].flags |= P_DEF_ALLOCED;
3890 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003891 }
3892}
3893
3894/*
3895 * Set the Vi-default value of a number option.
3896 * Used for 'lines' and 'columns'.
3897 */
3898 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003899set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003900{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003901 int opt_idx;
3902
3903 opt_idx = findoption((char_u *)name);
3904 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003905 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906}
3907
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003908#if defined(EXITFREE) || defined(PROTO)
3909/*
3910 * Free all options.
3911 */
3912 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003913free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003914{
3915 int i;
3916
3917 for (i = 0; !istermoption(&options[i]); i++)
3918 {
3919 if (options[i].indir == PV_NONE)
3920 {
3921 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003922 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003923 free_string_option(*(char_u **)options[i].var);
3924 if (options[i].flags & P_DEF_ALLOCED)
3925 free_string_option(options[i].def_val[VI_DEFAULT]);
3926 }
3927 else if (options[i].var != VAR_WIN
3928 && (options[i].flags & P_STRING))
3929 /* buffer-local option: free global value */
3930 free_string_option(*(char_u **)options[i].var);
3931 }
3932}
3933#endif
3934
3935
Bram Moolenaar071d4272004-06-13 20:20:40 +00003936/*
3937 * Initialize the options, part two: After getting Rows and Columns and
3938 * setting 'term'.
3939 */
3940 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003941set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003942{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003943 int idx;
3944
Bram Moolenaar071d4272004-06-13 20:20:40 +00003945 /*
3946 * 'scroll' defaults to half the window height. Note that this default is
3947 * wrong when the window height changes.
3948 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003949 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003950 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003951 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003952 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003953 comp_col();
3954
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003955 /*
3956 * 'window' is only for backwards compatibility with Vi.
3957 * Default is Rows - 1.
3958 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003959 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003960 p_window = Rows - 1;
3961 set_number_default("window", Rows - 1);
3962
Bram Moolenaarf740b292006-02-16 22:11:02 +00003963 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003964#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003965 /*
3966 * If 'background' wasn't set by the user, try guessing the value,
3967 * depending on the terminal name. Only need to check for terminals
3968 * with a dark background, that can handle color.
3969 */
3970 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003971 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3972 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003973 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003974 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003975 /* don't mark it as set, when starting the GUI it may be
3976 * changed again */
3977 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003978 }
3979#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003980
3981#ifdef CURSOR_SHAPE
3982 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3983#endif
3984#ifdef FEAT_MOUSESHAPE
3985 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3986#endif
3987#ifdef FEAT_PRINTER
3988 (void)parse_printoptions(); /* parse 'printoptions' default value */
3989#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003990}
3991
3992/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003993 * Return "dark" or "light" depending on the kind of terminal.
3994 * This is just guessing! Recognized are:
3995 * "linux" Linux console
3996 * "screen.linux" Linux console with screen
3997 * "cygwin" Cygwin shell
3998 * "putty" Putty program
3999 * We also check the COLORFGBG environment variable, which is set by
4000 * rxvt and derivatives. This variable contains either two or three
4001 * values separated by semicolons; we want the last value in either
4002 * case. If this value is 0-6 or 8, our background is dark.
4003 */
4004 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004005term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004006{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004007#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00004008 /* DOS console nearly always black */
4009 return (char_u *)"dark";
4010#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00004011 char_u *p;
4012
Bram Moolenaarf740b292006-02-16 22:11:02 +00004013 if (STRCMP(T_NAME, "linux") == 0
4014 || STRCMP(T_NAME, "screen.linux") == 0
4015 || STRCMP(T_NAME, "cygwin") == 0
4016 || STRCMP(T_NAME, "putty") == 0
4017 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
4018 && (p = vim_strrchr(p, ';')) != NULL
4019 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4020 && p[2] == NUL))
4021 return (char_u *)"dark";
4022 return (char_u *)"light";
4023#endif
4024}
4025
4026/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004027 * Initialize the options, part three: After reading the .vimrc
4028 */
4029 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004030set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004031{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004032#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004033/*
4034 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4035 * This is done after other initializations, where 'shell' might have been
4036 * set, but only if they have not been set before.
4037 */
4038 char_u *p;
4039 int idx_srr;
4040 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004041# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004042 int idx_sp;
4043 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004044# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045
4046 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004047 if (idx_srr < 0)
4048 do_srr = FALSE;
4049 else
4050 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004051# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004052 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004053 if (idx_sp < 0)
4054 do_sp = FALSE;
4055 else
4056 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004057# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004058 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059 if (p != NULL)
4060 {
4061 /*
4062 * Default for p_sp is "| tee", for p_srr is ">".
4063 * For known shells it is changed here to include stderr.
4064 */
4065 if ( fnamecmp(p, "csh") == 0
4066 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004067# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004068 || fnamecmp(p, "csh.exe") == 0
4069 || fnamecmp(p, "tcsh.exe") == 0
4070# endif
4071 )
4072 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004073# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004074 if (do_sp)
4075 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004076# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004077 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004078# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004079 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004080# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4082 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004083# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004084 if (do_srr)
4085 {
4086 p_srr = (char_u *)">&";
4087 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4088 }
4089 }
4090 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004091 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092 if ( fnamecmp(p, "sh") == 0
4093 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004094 || fnamecmp(p, "mksh") == 0
4095 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004096 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004097 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004099 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004100# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004101 || fnamecmp(p, "cmd") == 0
4102 || fnamecmp(p, "sh.exe") == 0
4103 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004104 || fnamecmp(p, "mksh.exe") == 0
4105 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004106 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004107 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004108 || fnamecmp(p, "bash.exe") == 0
4109 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004110# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004111 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004112 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004113# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004114 if (do_sp)
4115 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004116# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004118# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004120# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4122 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004123# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 if (do_srr)
4125 {
4126 p_srr = (char_u *)">%s 2>&1";
4127 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4128 }
4129 }
4130 vim_free(p);
4131 }
4132#endif
4133
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004134#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004135 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004136 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4137 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004138 * This is done after other initializations, where 'shell' might have been
4139 * set, but only if they have not been set before. Default for p_shcf is
4140 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004141 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004142 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004143 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004144 {
4145 int idx3;
4146
4147 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004148 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004149 {
4150 p_shcf = (char_u *)"-c";
4151 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4152 }
4153
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154 /* Somehow Win32 requires the quotes around the redirection too */
4155 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004156 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004157 {
4158 p_sxq = (char_u *)"\"";
4159 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4160 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004161 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004162 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4163 {
4164 int idx3;
4165
4166 /*
4167 * cmd.exe on Windows will strip the first and last double quote given
4168 * on the command line, e.g. most of the time things like:
4169 * cmd /c "my path/to/echo" "my args to echo"
4170 * become:
4171 * my path/to/echo" "my args to echo
4172 * when executed.
4173 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004174 * To avoid this, set shellxquote to surround the command in
4175 * parenthesis. This appears to make most commands work, without
4176 * breaking commands that worked previously, such as
4177 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004178 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004179 idx3 = findoption((char_u *)"sxq");
4180 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4181 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004182 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004183 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4184 }
4185
Bram Moolenaara64ba222012-02-12 23:23:31 +01004186 idx3 = findoption((char_u *)"shcf");
4187 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4188 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004189 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004190 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4191 }
4192 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004193#endif
4194
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004195 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004196 {
4197 int idx_ffs = findoption((char_u *)"ffs");
4198
4199 /* Apply the first entry of 'fileformats' to the initial buffer. */
4200 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4201 set_fileformat(default_fileformat(), OPT_LOCAL);
4202 }
4203
Bram Moolenaar071d4272004-06-13 20:20:40 +00004204#ifdef FEAT_TITLE
4205 set_title_defaults();
4206#endif
4207}
4208
4209#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4210/*
4211 * When 'helplang' is still at its default value, set it to "lang".
4212 * Only the first two characters of "lang" are used.
4213 */
4214 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004215set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004216{
4217 int idx;
4218
4219 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4220 return;
4221 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004222 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004223 {
4224 if (options[idx].flags & P_ALLOCED)
4225 free_string_option(p_hlg);
4226 p_hlg = vim_strsave(lang);
4227 if (p_hlg == NULL)
4228 p_hlg = empty_option;
4229 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004230 {
4231 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4232 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4233 {
4234 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4235 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4236 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004237 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004238 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239 options[idx].flags |= P_ALLOCED;
4240 }
4241}
4242#endif
4243
4244#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004245static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004246
4247 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004248gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004249{
4250 if (gui_get_lightness(gui.back_pixel) < 127)
4251 return (char_u *)"dark";
4252 return (char_u *)"light";
4253}
4254
4255/*
4256 * Option initializations that can only be done after opening the GUI window.
4257 */
4258 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004259init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004260{
4261 /* Set the 'background' option according to the lightness of the
4262 * background color, unless the user has set it already. */
4263 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4264 {
4265 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4266 highlight_changed();
4267 }
4268}
4269#endif
4270
4271#ifdef FEAT_TITLE
4272/*
4273 * 'title' and 'icon' only default to true if they have not been set or reset
4274 * in .vimrc and we can read the old value.
4275 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4276 * they can be reset. This reduces startup time when using X on a remote
4277 * machine.
4278 */
4279 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004280set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004281{
4282 int idx1;
4283 long val;
4284
4285 /*
4286 * If GUI is (going to be) used, we can always set the window title and
4287 * icon name. Saves a bit of time, because the X11 display server does
4288 * not need to be contacted.
4289 */
4290 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004291 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004292 {
4293#ifdef FEAT_GUI
4294 if (gui.starting || gui.in_use)
4295 val = TRUE;
4296 else
4297#endif
4298 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004299 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004300 p_title = val;
4301 }
4302 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004303 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004304 {
4305#ifdef FEAT_GUI
4306 if (gui.starting || gui.in_use)
4307 val = TRUE;
4308 else
4309#endif
4310 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004311 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004312 p_icon = val;
4313 }
4314}
4315#endif
4316
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004317#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4318 static void
4319trigger_optionsset_string(
4320 int opt_idx,
4321 int opt_flags,
4322 char_u *oldval,
4323 char_u *newval)
4324{
4325 if (oldval != NULL && newval != NULL)
4326 {
4327 char_u buf_type[7];
4328
4329 sprintf((char *)buf_type, "%s",
4330 (opt_flags & OPT_LOCAL) ? "local" : "global");
4331 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4332 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4333 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4334 apply_autocmds(EVENT_OPTIONSET,
4335 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4336 reset_v_option_vars();
4337 }
4338 vim_free(oldval);
4339 vim_free(newval);
4340}
4341#endif
4342
Bram Moolenaar071d4272004-06-13 20:20:40 +00004343/*
4344 * Parse 'arg' for option settings.
4345 *
4346 * 'arg' may be IObuff, but only when no errors can be present and option
4347 * does not need to be expanded with option_expand().
4348 * "opt_flags":
4349 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004350 * OPT_GLOBAL for ":setglobal"
4351 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004352 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004353 * OPT_WINONLY to only set window-local options
4354 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004355 *
4356 * returns FAIL if an error is detected, OK otherwise
4357 */
4358 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004359do_set(
4360 char_u *arg, /* option string (may be written to!) */
4361 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004362{
4363 int opt_idx;
4364 char_u *errmsg;
4365 char_u errbuf[80];
4366 char_u *startarg;
4367 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4368 int nextchar; /* next non-white char after option name */
4369 int afterchar; /* character just after option name */
4370 int len;
4371 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004372 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004373 int key;
4374 long_u flags; /* flags for current option */
4375 char_u *varp = NULL; /* pointer to variable for current option */
4376 int did_show = FALSE; /* already showed one value */
4377 int adding; /* "opt+=arg" */
4378 int prepending; /* "opt^=arg" */
4379 int removing; /* "opt-=arg" */
4380 int cp_val = 0;
4381 char_u key_name[2];
4382
4383 if (*arg == NUL)
4384 {
4385 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004386 did_show = TRUE;
4387 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004388 }
4389
4390 while (*arg != NUL) /* loop to process all options */
4391 {
4392 errmsg = NULL;
4393 startarg = arg; /* remember for error message */
4394
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004395 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4396 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004397 {
4398 /*
4399 * ":set all" show all options.
4400 * ":set all&" set all options to their default value.
4401 */
4402 arg += 3;
4403 if (*arg == '&')
4404 {
4405 ++arg;
4406 /* Only for :set command set global value of local options. */
4407 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004408 didset_options();
4409 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004410 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004411 }
4412 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004413 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004414 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004415 did_show = TRUE;
4416 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004417 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004418 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004419 {
4420 showoptions(2, opt_flags);
4421 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004422 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004423 arg += 7;
4424 }
4425 else
4426 {
4427 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004428 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004429 {
4430 prefix = 0;
4431 arg += 2;
4432 }
4433 else if (STRNCMP(arg, "inv", 3) == 0)
4434 {
4435 prefix = 2;
4436 arg += 3;
4437 }
4438
4439 /* find end of name */
4440 key = 0;
4441 if (*arg == '<')
4442 {
4443 nextchar = 0;
4444 opt_idx = -1;
4445 /* look out for <t_>;> */
4446 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4447 len = 5;
4448 else
4449 {
4450 len = 1;
4451 while (arg[len] != NUL && arg[len] != '>')
4452 ++len;
4453 }
4454 if (arg[len] != '>')
4455 {
4456 errmsg = e_invarg;
4457 goto skip;
4458 }
4459 arg[len] = NUL; /* put NUL after name */
4460 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4461 opt_idx = findoption(arg + 1);
4462 arg[len++] = '>'; /* restore '>' */
4463 if (opt_idx == -1)
4464 key = find_key_option(arg + 1);
4465 }
4466 else
4467 {
4468 len = 0;
4469 /*
4470 * The two characters after "t_" may not be alphanumeric.
4471 */
4472 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4473 len = 4;
4474 else
4475 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4476 ++len;
4477 nextchar = arg[len];
4478 arg[len] = NUL; /* put NUL after name */
4479 opt_idx = findoption(arg);
4480 arg[len] = nextchar; /* restore nextchar */
4481 if (opt_idx == -1)
4482 key = find_key_option(arg);
4483 }
4484
4485 /* remember character after option name */
4486 afterchar = arg[len];
4487
4488 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004489 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004490 ++len;
4491
4492 adding = FALSE;
4493 prepending = FALSE;
4494 removing = FALSE;
4495 if (arg[len] != NUL && arg[len + 1] == '=')
4496 {
4497 if (arg[len] == '+')
4498 {
4499 adding = TRUE; /* "+=" */
4500 ++len;
4501 }
4502 else if (arg[len] == '^')
4503 {
4504 prepending = TRUE; /* "^=" */
4505 ++len;
4506 }
4507 else if (arg[len] == '-')
4508 {
4509 removing = TRUE; /* "-=" */
4510 ++len;
4511 }
4512 }
4513 nextchar = arg[len];
4514
4515 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4516 {
4517 errmsg = (char_u *)N_("E518: Unknown option");
4518 goto skip;
4519 }
4520
4521 if (opt_idx >= 0)
4522 {
4523 if (options[opt_idx].var == NULL) /* hidden option: skip */
4524 {
4525 /* Only give an error message when requesting the value of
4526 * a hidden option, ignore setting it. */
4527 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4528 && (!(options[opt_idx].flags & P_BOOL)
4529 || nextchar == '?'))
4530 errmsg = (char_u *)N_("E519: Option not supported");
4531 goto skip;
4532 }
4533
4534 flags = options[opt_idx].flags;
4535 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4536 }
4537 else
4538 {
4539 flags = P_STRING;
4540 if (key < 0)
4541 {
4542 key_name[0] = KEY2TERMCAP0(key);
4543 key_name[1] = KEY2TERMCAP1(key);
4544 }
4545 else
4546 {
4547 key_name[0] = KS_KEY;
4548 key_name[1] = (key & 0xff);
4549 }
4550 }
4551
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004552 /* Skip all options that are not window-local (used when showing
4553 * an already loaded buffer in a window). */
4554 if ((opt_flags & OPT_WINONLY)
4555 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4556 goto skip;
4557
Bram Moolenaara3227e22006-03-08 21:32:40 +00004558 /* Skip all options that are window-local (used for :vimgrep). */
4559 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4560 && options[opt_idx].var == VAR_WIN)
4561 goto skip;
4562
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004563 /* Disallow changing some options from modelines. */
4564 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004565 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004566 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004567 {
4568 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4569 goto skip;
4570 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004571#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004572 /* In diff mode some options are overruled. This avoids that
4573 * 'foldmethod' becomes "marker" instead of "diff" and that
4574 * "wrap" gets set. */
4575 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004576 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004577 && (
4578#ifdef FEAT_FOLDING
4579 options[opt_idx].indir == PV_FDM ||
4580#endif
4581 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004582 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004583#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004584 }
4585
4586#ifdef HAVE_SANDBOX
4587 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004588 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004589 {
4590 errmsg = (char_u *)_(e_sandbox);
4591 goto skip;
4592 }
4593#endif
4594
4595 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4596 {
4597 arg += len;
4598 cp_val = p_cp;
4599 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4600 {
4601 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4602 {
4603 cp_val = FALSE;
4604 arg += 3;
4605 }
4606 else /* "opt&vi": set to Vi default */
4607 {
4608 cp_val = TRUE;
4609 arg += 2;
4610 }
4611 }
4612 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004613 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004614 {
4615 errmsg = e_trailing;
4616 goto skip;
4617 }
4618 }
4619
4620 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004621 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4622 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004623 */
4624 if (nextchar == '?'
4625 || (prefix == 1
4626 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4627 && !(flags & P_BOOL)))
4628 {
4629 /*
4630 * print value
4631 */
4632 if (did_show)
4633 msg_putchar('\n'); /* cursor below last one */
4634 else
4635 {
4636 gotocmdline(TRUE); /* cursor at status line */
4637 did_show = TRUE; /* remember that we did a line */
4638 }
4639 if (opt_idx >= 0)
4640 {
4641 showoneopt(&options[opt_idx], opt_flags);
4642#ifdef FEAT_EVAL
4643 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004644 {
4645 /* Mention where the option was last set. */
4646 if (varp == options[opt_idx].var)
4647 last_set_msg(options[opt_idx].scriptID);
4648 else if ((int)options[opt_idx].indir & PV_WIN)
4649 last_set_msg(curwin->w_p_scriptID[
4650 (int)options[opt_idx].indir & PV_MASK]);
4651 else if ((int)options[opt_idx].indir & PV_BUF)
4652 last_set_msg(curbuf->b_p_scriptID[
4653 (int)options[opt_idx].indir & PV_MASK]);
4654 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004655#endif
4656 }
4657 else
4658 {
4659 char_u *p;
4660
4661 p = find_termcode(key_name);
4662 if (p == NULL)
4663 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004664 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004665 goto skip;
4666 }
4667 else
4668 (void)show_one_termcode(key_name, p, TRUE);
4669 }
4670 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004671 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004672 errmsg = e_trailing;
4673 }
4674 else
4675 {
4676 if (flags & P_BOOL) /* boolean */
4677 {
4678 if (nextchar == '=' || nextchar == ':')
4679 {
4680 errmsg = e_invarg;
4681 goto skip;
4682 }
4683
4684 /*
4685 * ":set opt!": invert
4686 * ":set opt&": reset to default value
4687 * ":set opt<": reset to global value
4688 */
4689 if (nextchar == '!')
4690 value = *(int *)(varp) ^ 1;
4691 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004692 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004693 ((flags & P_VI_DEF) || cp_val)
4694 ? VI_DEFAULT : VIM_DEFAULT];
4695 else if (nextchar == '<')
4696 {
4697 /* For 'autoread' -1 means to use global value. */
4698 if ((int *)varp == &curbuf->b_p_ar
4699 && opt_flags == OPT_LOCAL)
4700 value = -1;
4701 else
4702 value = *(int *)get_varp_scope(&(options[opt_idx]),
4703 OPT_GLOBAL);
4704 }
4705 else
4706 {
4707 /*
4708 * ":set invopt": invert
4709 * ":set opt" or ":set noopt": set or reset
4710 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004711 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004712 {
4713 errmsg = e_trailing;
4714 goto skip;
4715 }
4716 if (prefix == 2) /* inv */
4717 value = *(int *)(varp) ^ 1;
4718 else
4719 value = prefix;
4720 }
4721
4722 errmsg = set_bool_option(opt_idx, varp, (int)value,
4723 opt_flags);
4724 }
4725 else /* numeric or string */
4726 {
4727 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4728 || prefix != 1)
4729 {
4730 errmsg = e_invarg;
4731 goto skip;
4732 }
4733
4734 if (flags & P_NUM) /* numeric */
4735 {
4736 /*
4737 * Different ways to set a number option:
4738 * & set to default value
4739 * < set to global value
4740 * <xx> accept special key codes for 'wildchar'
4741 * c accept any non-digit for 'wildchar'
4742 * [-]0-9 set number
4743 * other error
4744 */
4745 ++arg;
4746 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004747 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004748 ((flags & P_VI_DEF) || cp_val)
4749 ? VI_DEFAULT : VIM_DEFAULT];
4750 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004751 {
4752 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4753 * use the global value. */
4754 if ((long *)varp == &curbuf->b_p_ul
4755 && opt_flags == OPT_LOCAL)
4756 value = NO_LOCAL_UNDOLEVEL;
4757 else
4758 value = *(long *)get_varp_scope(
4759 &(options[opt_idx]), OPT_GLOBAL);
4760 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004761 else if (((long *)varp == &p_wc
4762 || (long *)varp == &p_wcm)
4763 && (*arg == '<'
4764 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004765 || (*arg != NUL
4766 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004767 && !VIM_ISDIGIT(*arg))))
4768 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02004769 value = string_to_key(arg, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004770 if (value == 0 && (long *)varp != &p_wcm)
4771 {
4772 errmsg = e_invarg;
4773 goto skip;
4774 }
4775 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004776 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4777 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004778 /* Allow negative (for 'undolevels'), octal and
4779 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004780 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4781 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004782 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004783 {
4784 errmsg = e_invarg;
4785 goto skip;
4786 }
4787 }
4788 else
4789 {
4790 errmsg = (char_u *)N_("E521: Number required after =");
4791 goto skip;
4792 }
4793
4794 if (adding)
4795 value = *(long *)varp + value;
4796 if (prepending)
4797 value = *(long *)varp * value;
4798 if (removing)
4799 value = *(long *)varp - value;
4800 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004801 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004802 }
4803 else if (opt_idx >= 0) /* string */
4804 {
4805 char_u *save_arg = NULL;
4806 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004807 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004808 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004809 char_u *origval = NULL;
4810#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4811 char_u *saved_origval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004812 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004813#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004814 unsigned newlen;
4815 int comma;
4816 int bs;
4817 int new_value_alloced; /* new string option
4818 was allocated */
4819
4820 /* When using ":set opt=val" for a global option
4821 * with a local value the local value will be
4822 * reset, use the global value here. */
4823 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004824 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004825 varp = options[opt_idx].var;
4826
4827 /* The old value is kept until we are sure that the
4828 * new value is valid. */
4829 oldval = *(char_u **)varp;
4830 if (nextchar == '&') /* set to default val */
4831 {
4832 newval = options[opt_idx].def_val[
4833 ((flags & P_VI_DEF) || cp_val)
4834 ? VI_DEFAULT : VIM_DEFAULT];
4835 if ((char_u **)varp == &p_bg)
4836 {
4837 /* guess the value of 'background' */
4838#ifdef FEAT_GUI
4839 if (gui.in_use)
4840 newval = gui_bg_default();
4841 else
4842#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004843 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004844 }
4845
4846 /* expand environment variables and ~ (since the
4847 * default value was already expanded, only
4848 * required when an environment variable was set
4849 * later */
4850 if (newval == NULL)
4851 newval = empty_option;
4852 else
4853 {
4854 s = option_expand(opt_idx, newval);
4855 if (s == NULL)
4856 s = newval;
4857 newval = vim_strsave(s);
4858 }
4859 new_value_alloced = TRUE;
4860 }
4861 else if (nextchar == '<') /* set to global val */
4862 {
4863 newval = vim_strsave(*(char_u **)get_varp_scope(
4864 &(options[opt_idx]), OPT_GLOBAL));
4865 new_value_alloced = TRUE;
4866 }
4867 else
4868 {
4869 ++arg; /* jump to after the '=' or ':' */
4870
4871 /*
4872 * Set 'keywordprg' to ":help" if an empty
4873 * value was passed to :set by the user.
4874 * Misuse errbuf[] for the resulting string.
4875 */
4876 if (varp == (char_u *)&p_kp
4877 && (*arg == NUL || *arg == ' '))
4878 {
4879 STRCPY(errbuf, ":help");
4880 save_arg = arg;
4881 arg = errbuf;
4882 }
4883 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004884 * Convert 'backspace' number to string, for
4885 * adding, prepending and removing string.
4886 */
4887 else if (varp == (char_u *)&p_bs
4888 && VIM_ISDIGIT(**(char_u **)varp))
4889 {
4890 i = getdigits((char_u **)varp);
4891 switch (i)
4892 {
4893 case 0:
4894 *(char_u **)varp = empty_option;
4895 break;
4896 case 1:
4897 *(char_u **)varp = vim_strsave(
4898 (char_u *)"indent,eol");
4899 break;
4900 case 2:
4901 *(char_u **)varp = vim_strsave(
4902 (char_u *)"indent,eol,start");
4903 break;
4904 }
4905 vim_free(oldval);
4906 oldval = *(char_u **)varp;
4907 }
4908 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004909 * Convert 'whichwrap' number to string, for
4910 * backwards compatibility with Vim 3.0.
4911 * Misuse errbuf[] for the resulting string.
4912 */
4913 else if (varp == (char_u *)&p_ww
4914 && VIM_ISDIGIT(*arg))
4915 {
4916 *errbuf = NUL;
4917 i = getdigits(&arg);
4918 if (i & 1)
4919 STRCAT(errbuf, "b,");
4920 if (i & 2)
4921 STRCAT(errbuf, "s,");
4922 if (i & 4)
4923 STRCAT(errbuf, "h,l,");
4924 if (i & 8)
4925 STRCAT(errbuf, "<,>,");
4926 if (i & 16)
4927 STRCAT(errbuf, "[,],");
4928 if (*errbuf != NUL) /* remove trailing , */
4929 errbuf[STRLEN(errbuf) - 1] = NUL;
4930 save_arg = arg;
4931 arg = errbuf;
4932 }
4933 /*
4934 * Remove '>' before 'dir' and 'bdir', for
4935 * backwards compatibility with version 3.0
4936 */
4937 else if ( *arg == '>'
4938 && (varp == (char_u *)&p_dir
4939 || varp == (char_u *)&p_bdir))
4940 {
4941 ++arg;
4942 }
4943
4944 /* When setting the local value of a global
4945 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004946 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004947 && (opt_flags & OPT_LOCAL))
4948 origval = *(char_u **)get_varp(
4949 &options[opt_idx]);
4950 else
4951 origval = oldval;
4952
4953 /*
4954 * Copy the new string into allocated memory.
4955 * Can't use set_string_option_direct(), because
4956 * we need to remove the backslashes.
4957 */
4958 /* get a bit too much */
4959 newlen = (unsigned)STRLEN(arg) + 1;
4960 if (adding || prepending || removing)
4961 newlen += (unsigned)STRLEN(origval) + 1;
4962 newval = alloc(newlen);
4963 if (newval == NULL) /* out of mem, don't change */
4964 break;
4965 s = newval;
4966
4967 /*
4968 * Copy the string, skip over escaped chars.
4969 * For MS-DOS and WIN32 backslashes before normal
4970 * file name characters are not removed, and keep
4971 * backslash at start, for "\\machine\path", but
4972 * do remove it for "\\\\machine\\path".
4973 * The reverse is found in ExpandOldSetting().
4974 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004975 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004976 {
4977 if (*arg == '\\' && arg[1] != NUL
4978#ifdef BACKSLASH_IN_FILENAME
4979 && !((flags & P_EXPAND)
4980 && vim_isfilec(arg[1])
4981 && (arg[1] != '\\'
4982 || (s == newval
4983 && arg[2] != '\\')))
4984#endif
4985 )
4986 ++arg; /* remove backslash */
4987#ifdef FEAT_MBYTE
4988 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004989 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004990 {
4991 /* copy multibyte char */
4992 mch_memmove(s, arg, (size_t)i);
4993 arg += i;
4994 s += i;
4995 }
4996 else
4997#endif
4998 *s++ = *arg++;
4999 }
5000 *s = NUL;
5001
5002 /*
5003 * Expand environment variables and ~.
5004 * Don't do it when adding without inserting a
5005 * comma.
5006 */
5007 if (!(adding || prepending || removing)
5008 || (flags & P_COMMA))
5009 {
5010 s = option_expand(opt_idx, newval);
5011 if (s != NULL)
5012 {
5013 vim_free(newval);
5014 newlen = (unsigned)STRLEN(s) + 1;
5015 if (adding || prepending || removing)
5016 newlen += (unsigned)STRLEN(origval) + 1;
5017 newval = alloc(newlen);
5018 if (newval == NULL)
5019 break;
5020 STRCPY(newval, s);
5021 }
5022 }
5023
5024 /* locate newval[] in origval[] when removing it
5025 * and when adding to avoid duplicates */
5026 i = 0; /* init for GCC */
5027 if (removing || (flags & P_NODUP))
5028 {
5029 i = (int)STRLEN(newval);
5030 bs = 0;
5031 for (s = origval; *s; ++s)
5032 {
5033 if ((!(flags & P_COMMA)
5034 || s == origval
5035 || (s[-1] == ',' && !(bs & 1)))
5036 && STRNCMP(s, newval, i) == 0
5037 && (!(flags & P_COMMA)
5038 || s[i] == ','
5039 || s[i] == NUL))
5040 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005041 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005042 * even number of backslashes or a single
5043 * backslash preceded by a comma before it
5044 * is recognized as a separator */
5045 if ((s > origval + 1
5046 && s[-1] == '\\'
5047 && s[-2] != ',')
5048 || (s == origval + 1
5049 && s[-1] == '\\'))
5050
Bram Moolenaar071d4272004-06-13 20:20:40 +00005051 ++bs;
5052 else
5053 bs = 0;
5054 }
5055
5056 /* do not add if already there */
5057 if ((adding || prepending) && *s)
5058 {
5059 prepending = FALSE;
5060 adding = FALSE;
5061 STRCPY(newval, origval);
5062 }
5063 }
5064
5065 /* concatenate the two strings; add a ',' if
5066 * needed */
5067 if (adding || prepending)
5068 {
5069 comma = ((flags & P_COMMA) && *origval != NUL
5070 && *newval != NUL);
5071 if (adding)
5072 {
5073 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005074 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005075 if (comma && i > 1
5076 && (flags & P_ONECOMMA) == P_ONECOMMA
5077 && origval[i - 1] == ','
5078 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005079 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005080 mch_memmove(newval + i + comma, newval,
5081 STRLEN(newval) + 1);
5082 mch_memmove(newval, origval, (size_t)i);
5083 }
5084 else
5085 {
5086 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005087 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005088 }
5089 if (comma)
5090 newval[i] = ',';
5091 }
5092
5093 /* Remove newval[] from origval[]. (Note: "i" has
5094 * been set above and is used here). */
5095 if (removing)
5096 {
5097 STRCPY(newval, origval);
5098 if (*s)
5099 {
5100 /* may need to remove a comma */
5101 if (flags & P_COMMA)
5102 {
5103 if (s == origval)
5104 {
5105 /* include comma after string */
5106 if (s[i] == ',')
5107 ++i;
5108 }
5109 else
5110 {
5111 /* include comma before string */
5112 --s;
5113 ++i;
5114 }
5115 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005116 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005117 }
5118 }
5119
5120 if (flags & P_FLAGLIST)
5121 {
5122 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005123 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005124 {
5125 /* if options have P_FLAGLIST and
5126 * P_ONECOMMA such as 'whichwrap' */
5127 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005128 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005129 if (*s != ',' && *(s + 1) == ','
5130 && vim_strchr(s + 2, *s) != NULL)
5131 {
5132 /* Remove the duplicated value and
5133 * the next comma. */
5134 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005135 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005136 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005137 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005138 else
5139 {
5140 if ((!(flags & P_COMMA) || *s != ',')
5141 && vim_strchr(s + 1, *s) != NULL)
5142 {
5143 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005144 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005145 }
5146 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005147 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005148 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005149 }
5150
5151 if (save_arg != NULL) /* number for 'whichwrap' */
5152 arg = save_arg;
5153 new_value_alloced = TRUE;
5154 }
5155
5156 /* Set the new value. */
5157 *(char_u **)(varp) = newval;
5158
Bram Moolenaar53744302015-07-17 17:38:22 +02005159#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005160 if (!starting
5161# ifdef FEAT_CRYPT
5162 && options[opt_idx].indir != PV_KEY
5163# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005164 && origval != NULL && newval != NULL)
5165 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005166 /* origval may be freed by
5167 * did_set_string_option(), make a copy. */
5168 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005169 /* newval (and varp) may become invalid if the
5170 * buffer is closed by autocommands. */
5171 saved_newval = vim_strsave(newval);
5172 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005173#endif
5174
Bram Moolenaar071d4272004-06-13 20:20:40 +00005175 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005176 * ":set" on local options. Note: when setting 'syntax'
5177 * or 'filetype' autocommands may be triggered that can
5178 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005179 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5180 new_value_alloced, oldval, errbuf, opt_flags);
5181
5182 /* If error detected, print the error message. */
5183 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01005184 {
5185#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5186 vim_free(saved_origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005187 vim_free(saved_newval);
Bram Moolenaara9884962015-12-13 15:08:56 +01005188#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005189 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01005190 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005191#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005192 trigger_optionsset_string(opt_idx, opt_flags,
5193 saved_origval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005194#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005195 }
5196 else /* key code option */
5197 {
5198 char_u *p;
5199
5200 if (nextchar == '&')
5201 {
5202 if (add_termcap_entry(key_name, TRUE) == FAIL)
5203 errmsg = (char_u *)N_("E522: Not found in termcap");
5204 }
5205 else
5206 {
5207 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005208 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005209 if (*p == '\\' && p[1] != NUL)
5210 ++p;
5211 nextchar = *p;
5212 *p = NUL;
5213 add_termcode(key_name, arg, FALSE);
5214 *p = nextchar;
5215 }
5216 if (full_screen)
5217 ttest(FALSE);
5218 redraw_all_later(CLEAR);
5219 }
5220 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005221
Bram Moolenaar071d4272004-06-13 20:20:40 +00005222 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005223 did_set_option(opt_idx, opt_flags,
5224 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005225 }
5226
5227skip:
5228 /*
5229 * Advance to next argument.
5230 * - skip until a blank found, taking care of backslashes
5231 * - skip blanks
5232 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5233 */
5234 for (i = 0; i < 2 ; ++i)
5235 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005236 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005237 if (*arg++ == '\\' && *arg != NUL)
5238 ++arg;
5239 arg = skipwhite(arg);
5240 if (*arg != '=')
5241 break;
5242 }
5243 }
5244
5245 if (errmsg != NULL)
5246 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005247 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005248 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005249 if (i + (arg - startarg) < IOSIZE)
5250 {
5251 /* append the argument with the error */
5252 STRCAT(IObuff, ": ");
5253 mch_memmove(IObuff + i, startarg, (arg - startarg));
5254 IObuff[i + (arg - startarg)] = NUL;
5255 }
5256 /* make sure all characters are printable */
5257 trans_characters(IObuff, IOSIZE);
5258
5259 ++no_wait_return; /* wait_return done later */
5260 emsg(IObuff); /* show error highlighted */
5261 --no_wait_return;
5262
5263 return FAIL;
5264 }
5265
5266 arg = skipwhite(arg);
5267 }
5268
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005269theend:
5270 if (silent_mode && did_show)
5271 {
5272 /* After displaying option values in silent mode. */
5273 silent_mode = FALSE;
5274 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5275 msg_putchar('\n');
5276 cursor_on(); /* msg_start() switches it off */
5277 out_flush();
5278 silent_mode = TRUE;
5279 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5280 }
5281
Bram Moolenaar071d4272004-06-13 20:20:40 +00005282 return OK;
5283}
5284
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005285/*
5286 * Call this when an option has been given a new value through a user command.
5287 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5288 */
5289 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005290did_set_option(
5291 int opt_idx,
5292 int opt_flags, /* possibly with OPT_MODELINE */
5293 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005294{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005295 long_u *p;
5296
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005297 options[opt_idx].flags |= P_WAS_SET;
5298
5299 /* When an option is set in the sandbox, from a modeline or in secure mode
5300 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005301 * flag. */
5302 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005303 if (secure
5304#ifdef HAVE_SANDBOX
5305 || sandbox != 0
5306#endif
5307 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005308 *p = *p | P_INSECURE;
5309 else if (new_value)
5310 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005311}
5312
Bram Moolenaar071d4272004-06-13 20:20:40 +00005313 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005314illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005315{
5316 if (errbuf == NULL)
5317 return (char_u *)"";
5318 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005319 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005320 return errbuf;
5321}
5322
5323/*
5324 * Convert a key name or string into a key value.
5325 * Used for 'wildchar' and 'cedit' options.
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005326 * When "multi_byte" is TRUE allow for multi-byte characters.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005327 */
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005328 int
5329string_to_key(char_u *arg, int multi_byte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005330{
5331 if (*arg == '<')
5332 return find_key_option(arg + 1);
5333 if (*arg == '^')
5334 return Ctrl_chr(arg[1]);
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005335 if (multi_byte)
5336 return PTR2CHAR(arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005337 return *arg;
5338}
5339
5340#ifdef FEAT_CMDWIN
5341/*
5342 * Check value of 'cedit' and set cedit_key.
5343 * Returns NULL if value is OK, error message otherwise.
5344 */
5345 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005346check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005347{
5348 int n;
5349
5350 if (*p_cedit == NUL)
5351 cedit_key = -1;
5352 else
5353 {
Bram Moolenaardbe948d2017-07-23 22:50:51 +02005354 n = string_to_key(p_cedit, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005355 if (vim_isprintc(n))
5356 return e_invarg;
5357 cedit_key = n;
5358 }
5359 return NULL;
5360}
5361#endif
5362
5363#ifdef FEAT_TITLE
5364/*
5365 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5366 * maketitle() to create and display it.
5367 * When switching the title or icon off, call mch_restore_title() to get
5368 * the old value back.
5369 */
5370 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005371did_set_title(
5372 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005373{
5374 if (starting != NO_SCREEN
5375#ifdef FEAT_GUI
5376 && !gui.starting
5377#endif
5378 )
5379 {
5380 maketitle();
5381 if (icon)
5382 {
5383 if (!p_icon)
5384 mch_restore_title(2);
5385 }
5386 else
5387 {
5388 if (!p_title)
5389 mch_restore_title(1);
5390 }
5391 }
5392}
5393#endif
5394
5395/*
5396 * set_options_bin - called when 'bin' changes value.
5397 */
5398 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005399set_options_bin(
5400 int oldval,
5401 int newval,
5402 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005403{
5404 /*
5405 * The option values that are changed when 'bin' changes are
5406 * copied when 'bin is set and restored when 'bin' is reset.
5407 */
5408 if (newval)
5409 {
5410 if (!oldval) /* switched on */
5411 {
5412 if (!(opt_flags & OPT_GLOBAL))
5413 {
5414 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5415 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5416 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5417 curbuf->b_p_et_nobin = curbuf->b_p_et;
5418 }
5419 if (!(opt_flags & OPT_LOCAL))
5420 {
5421 p_tw_nobin = p_tw;
5422 p_wm_nobin = p_wm;
5423 p_ml_nobin = p_ml;
5424 p_et_nobin = p_et;
5425 }
5426 }
5427
5428 if (!(opt_flags & OPT_GLOBAL))
5429 {
5430 curbuf->b_p_tw = 0; /* no automatic line wrap */
5431 curbuf->b_p_wm = 0; /* no automatic line wrap */
5432 curbuf->b_p_ml = 0; /* no modelines */
5433 curbuf->b_p_et = 0; /* no expandtab */
5434 }
5435 if (!(opt_flags & OPT_LOCAL))
5436 {
5437 p_tw = 0;
5438 p_wm = 0;
5439 p_ml = FALSE;
5440 p_et = FALSE;
5441 p_bin = TRUE; /* needed when called for the "-b" argument */
5442 }
5443 }
5444 else if (oldval) /* switched off */
5445 {
5446 if (!(opt_flags & OPT_GLOBAL))
5447 {
5448 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5449 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5450 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5451 curbuf->b_p_et = curbuf->b_p_et_nobin;
5452 }
5453 if (!(opt_flags & OPT_LOCAL))
5454 {
5455 p_tw = p_tw_nobin;
5456 p_wm = p_wm_nobin;
5457 p_ml = p_ml_nobin;
5458 p_et = p_et_nobin;
5459 }
5460 }
5461}
5462
5463#ifdef FEAT_VIMINFO
5464/*
5465 * Find the parameter represented by the given character (eg ', :, ", or /),
5466 * and return its associated value in the 'viminfo' string.
5467 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005468 * If the parameter is not specified in the string or there is no following
5469 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005470 */
5471 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005472get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005473{
5474 char_u *p;
5475
5476 p = find_viminfo_parameter(type);
5477 if (p != NULL && VIM_ISDIGIT(*p))
5478 return atoi((char *)p);
5479 return -1;
5480}
5481
5482/*
5483 * Find the parameter represented by the given character (eg ''', ':', '"', or
5484 * '/') in the 'viminfo' option and return a pointer to the string after it.
5485 * Return NULL if the parameter is not specified in the string.
5486 */
5487 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005488find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005489{
5490 char_u *p;
5491
5492 for (p = p_viminfo; *p; ++p)
5493 {
5494 if (*p == type)
5495 return p + 1;
5496 if (*p == 'n') /* 'n' is always the last one */
5497 break;
5498 p = vim_strchr(p, ','); /* skip until next ',' */
5499 if (p == NULL) /* hit the end without finding parameter */
5500 break;
5501 }
5502 return NULL;
5503}
5504#endif
5505
5506/*
5507 * Expand environment variables for some string options.
5508 * These string options cannot be indirect!
5509 * If "val" is NULL expand the current value of the option.
5510 * Return pointer to NameBuff, or NULL when not expanded.
5511 */
5512 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005513option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005514{
5515 /* if option doesn't need expansion nothing to do */
5516 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5517 return NULL;
5518
5519 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5520 * expand_env() would truncate the string. */
5521 if (val != NULL && STRLEN(val) > MAXPATHL)
5522 return NULL;
5523
5524 if (val == NULL)
5525 val = *(char_u **)options[opt_idx].var;
5526
5527 /*
5528 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5529 * Escape spaces when expanding 'tags', they are used to separate file
5530 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005531 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005532 */
5533 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005534 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005535#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005536 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5537#endif
5538 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005539 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5540 return NULL;
5541
5542 return NameBuff;
5543}
5544
5545/*
5546 * After setting various option values: recompute variables that depend on
5547 * option values.
5548 */
5549 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005550didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005551{
5552 /* initialize the table for 'iskeyword' et.al. */
5553 (void)init_chartab();
5554
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005555#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005556 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005557#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005558 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005559 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005560#ifdef FEAT_SESSION
5561 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5562 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5563#endif
5564#ifdef FEAT_FOLDING
5565 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5566#endif
5567 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005568 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005569#ifdef FEAT_VIRTUALEDIT
5570 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5571#endif
5572#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5573 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5574#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005575#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005576 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005577 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005578 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005579 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005580#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005581#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5582 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5583#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005584#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005585 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5586#endif
5587#ifdef FEAT_CMDWIN
5588 /* set cedit_key */
5589 (void)check_cedit();
5590#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005591#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005592 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005593#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005594#ifdef FEAT_LINEBREAK
5595 /* initialize the table for 'breakat'. */
5596 fill_breakat_flags();
5597#endif
5598
5599}
5600
5601/*
5602 * More side effects of setting options.
5603 */
5604 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005605didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005606{
5607 /* Initialize the highlight_attr[] table. */
5608 (void)highlight_changed();
5609
5610 /* Parse default for 'wildmode' */
5611 check_opt_wim();
5612
5613 (void)set_chars_option(&p_lcs);
5614#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5615 /* Parse default for 'fillchars'. */
5616 (void)set_chars_option(&p_fcs);
5617#endif
5618
5619#ifdef FEAT_CLIPBOARD
5620 /* Parse default for 'clipboard' */
5621 (void)check_clipboard_option();
5622#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005623}
5624
5625/*
5626 * Check for string options that are NULL (normally only termcap options).
5627 */
5628 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005629check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005630{
5631 int opt_idx;
5632
5633 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5634 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5635 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5636}
5637
5638/*
5639 * Check string options in a buffer for NULL value.
5640 */
5641 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005642check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005643{
Bram Moolenaar071d4272004-06-13 20:20:40 +00005644 check_string_option(&buf->b_p_bh);
5645 check_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005646#ifdef FEAT_MBYTE
5647 check_string_option(&buf->b_p_fenc);
5648#endif
5649 check_string_option(&buf->b_p_ff);
5650#ifdef FEAT_FIND_ID
5651 check_string_option(&buf->b_p_def);
5652 check_string_option(&buf->b_p_inc);
5653# ifdef FEAT_EVAL
5654 check_string_option(&buf->b_p_inex);
5655# endif
5656#endif
5657#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5658 check_string_option(&buf->b_p_inde);
5659 check_string_option(&buf->b_p_indk);
5660#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005661#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5662 check_string_option(&buf->b_p_bexpr);
5663#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005664#if defined(FEAT_CRYPT)
5665 check_string_option(&buf->b_p_cm);
5666#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005667 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005668#if defined(FEAT_EVAL)
5669 check_string_option(&buf->b_p_fex);
5670#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005671#ifdef FEAT_CRYPT
5672 check_string_option(&buf->b_p_key);
5673#endif
5674 check_string_option(&buf->b_p_kp);
5675 check_string_option(&buf->b_p_mps);
5676 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005677 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005678 check_string_option(&buf->b_p_isk);
5679#ifdef FEAT_COMMENTS
5680 check_string_option(&buf->b_p_com);
5681#endif
5682#ifdef FEAT_FOLDING
5683 check_string_option(&buf->b_p_cms);
5684#endif
5685 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005686#ifdef FEAT_TEXTOBJ
5687 check_string_option(&buf->b_p_qe);
5688#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005689#ifdef FEAT_SYN_HL
5690 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005691 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005692#endif
5693#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005694 check_string_option(&buf->b_s.b_p_spc);
5695 check_string_option(&buf->b_s.b_p_spf);
5696 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005697#endif
5698#ifdef FEAT_SEARCHPATH
5699 check_string_option(&buf->b_p_sua);
5700#endif
5701#ifdef FEAT_CINDENT
5702 check_string_option(&buf->b_p_cink);
5703 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005704 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005705#endif
5706#ifdef FEAT_AUTOCMD
5707 check_string_option(&buf->b_p_ft);
5708#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005709#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5710 check_string_option(&buf->b_p_cinw);
5711#endif
5712#ifdef FEAT_INS_EXPAND
5713 check_string_option(&buf->b_p_cpt);
5714#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005715#ifdef FEAT_COMPL_FUNC
5716 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005717 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005719#ifdef FEAT_KEYMAP
5720 check_string_option(&buf->b_p_keymap);
5721#endif
5722#ifdef FEAT_QUICKFIX
5723 check_string_option(&buf->b_p_gp);
5724 check_string_option(&buf->b_p_mp);
5725 check_string_option(&buf->b_p_efm);
5726#endif
5727 check_string_option(&buf->b_p_ep);
5728 check_string_option(&buf->b_p_path);
5729 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005730 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005731#ifdef FEAT_INS_EXPAND
5732 check_string_option(&buf->b_p_dict);
5733 check_string_option(&buf->b_p_tsr);
5734#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005735#ifdef FEAT_LISP
5736 check_string_option(&buf->b_p_lw);
5737#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005738 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005739#ifdef FEAT_MBYTE
5740 check_string_option(&buf->b_p_menc);
5741#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005742}
5743
5744/*
5745 * Free the string allocated for an option.
5746 * Checks for the string being empty_option. This may happen if we're out of
5747 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5748 * check_options().
5749 * Does NOT check for P_ALLOCED flag!
5750 */
5751 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005752free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005753{
5754 if (p != empty_option)
5755 vim_free(p);
5756}
5757
5758 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005759clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005760{
5761 if (*pp != empty_option)
5762 vim_free(*pp);
5763 *pp = empty_option;
5764}
5765
5766 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005767check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005768{
5769 if (*pp == NULL)
5770 *pp = empty_option;
5771}
5772
5773/*
5774 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5775 */
5776 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005777set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005778{
5779 int opt_idx;
5780
5781 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5782 if (options[opt_idx].var == (char_u *)p)
5783 {
5784 options[opt_idx].flags |= P_ALLOCED;
5785 return;
5786 }
5787 return; /* cannot happen: didn't find it! */
5788}
5789
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005790#if defined(FEAT_EVAL) || defined(PROTO)
5791/*
5792 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5793 * Return FALSE when it wasn't.
5794 * Return -1 for an unknown option.
5795 */
5796 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005797was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005798{
5799 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005800 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005801
5802 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005803 {
5804 flagp = insecure_flag(idx, opt_flags);
5805 return (*flagp & P_INSECURE) != 0;
5806 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005807 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005808 return -1;
5809}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005810
5811/*
5812 * Get a pointer to the flags used for the P_INSECURE flag of option
5813 * "opt_idx". For some local options a local flags field is used.
5814 */
5815 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005816insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005817{
5818 if (opt_flags & OPT_LOCAL)
5819 switch ((int)options[opt_idx].indir)
5820 {
5821#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005822 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005823#endif
5824#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005825# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005826 case PV_FDE: return &curwin->w_p_fde_flags;
5827 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005828# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005829# ifdef FEAT_BEVAL
5830 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5831# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005832# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005833 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005834# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005835 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005836# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005837 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005838# endif
5839#endif
5840 }
5841
5842 /* Nothing special, return global flags field. */
5843 return &options[opt_idx].flags;
5844}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005845#endif
5846
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005847#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005848static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005849
5850/*
5851 * Redraw the window title and/or tab page text later.
5852 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005853static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005854{
5855 need_maketitle = TRUE;
5856# ifdef FEAT_WINDOWS
5857 redraw_tabline = TRUE;
5858# endif
5859}
5860#endif
5861
Bram Moolenaar071d4272004-06-13 20:20:40 +00005862/*
5863 * Set a string option to a new value (without checking the effect).
5864 * The string is copied into allocated memory.
5865 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005866 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005867 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005868 */
5869 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005870set_string_option_direct(
5871 char_u *name,
5872 int opt_idx,
5873 char_u *val,
5874 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5875 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005876{
5877 char_u *s;
5878 char_u **varp;
5879 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005880 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005881
Bram Moolenaar89d40322006-08-29 15:30:07 +00005882 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005883 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005884 idx = findoption(name);
5885 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005886 {
5887 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005888 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005889 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005890 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005891 }
5892
Bram Moolenaar89d40322006-08-29 15:30:07 +00005893 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005894 return;
5895
5896 s = vim_strsave(val);
5897 if (s != NULL)
5898 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005899 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005900 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005901 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005902 free_string_option(*varp);
5903 *varp = s;
5904
5905 /* For buffer/window local option may also set the global value. */
5906 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005907 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005908
Bram Moolenaar89d40322006-08-29 15:30:07 +00005909 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005910
5911 /* When setting both values of a global option with a local value,
5912 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005913 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005914 {
5915 free_string_option(*varp);
5916 *varp = empty_option;
5917 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005918# ifdef FEAT_EVAL
5919 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005920 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005921 set_sid == 0 ? current_SID : set_sid);
5922# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005923 }
5924}
5925
5926/*
5927 * Set global value for string option when it's a local option.
5928 */
5929 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005930set_string_option_global(
5931 int opt_idx, /* option index */
5932 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005933{
5934 char_u **p, *s;
5935
5936 /* the global value is always allocated */
5937 if (options[opt_idx].var == VAR_WIN)
5938 p = (char_u **)GLOBAL_WO(varp);
5939 else
5940 p = (char_u **)options[opt_idx].var;
5941 if (options[opt_idx].indir != PV_NONE
5942 && p != varp
5943 && (s = vim_strsave(*varp)) != NULL)
5944 {
5945 free_string_option(*p);
5946 *p = s;
5947 }
5948}
5949
5950/*
5951 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005952 *
5953 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005954 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005955 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005956set_string_option(
5957 int opt_idx,
5958 char_u *value,
5959 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005960{
5961 char_u *s;
5962 char_u **varp;
5963 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005964#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5965 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005966 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005967#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005968 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005969
5970 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005971 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005972
5973 s = vim_strsave(value);
5974 if (s != NULL)
5975 {
5976 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5977 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005978 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005979 ? OPT_GLOBAL : OPT_LOCAL)
5980 : opt_flags);
5981 oldval = *varp;
5982 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005983
5984#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005985 if (!starting
5986# ifdef FEAT_CRYPT
5987 && options[opt_idx].indir != PV_KEY
5988# endif
5989 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005990 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005991 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005992 saved_newval = vim_strsave(s);
5993 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005994#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005995 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5996 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005997 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005998
Bram Moolenaar53744302015-07-17 17:38:22 +02005999#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02006000 /* call autocommand after handling side effects */
6001 trigger_optionsset_string(opt_idx, opt_flags,
6002 saved_oldval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02006003#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006004 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02006005 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006006}
6007
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006008#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006009/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01006010 * Return TRUE if "val" is a valid 'filetype' name.
6011 * Also used for 'syntax' and 'keymap'.
6012 */
6013 static int
6014valid_filetype(char_u *val)
6015{
6016 char_u *s;
6017
6018 for (s = val; *s != NUL; ++s)
6019 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
6020 return FALSE;
6021 return TRUE;
6022}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006023#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006024
6025/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006026 * Handle string options that need some action to perform when changed.
6027 * Returns NULL for success, or an error message for an error.
6028 */
6029 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006030did_set_string_option(
6031 int opt_idx, /* index in options[] table */
6032 char_u **varp, /* pointer to the option variable */
6033 int new_value_alloced, /* new value was allocated */
6034 char_u *oldval, /* previous value of the option */
6035 char_u *errbuf, /* buffer for errors, or NULL */
6036 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006037{
6038 char_u *errmsg = NULL;
6039 char_u *s, *p;
6040 int did_chartab = FALSE;
6041 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006042 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006043#ifdef FEAT_GUI
6044 /* set when changing an option that only requires a redraw in the GUI */
6045 int redraw_gui_only = FALSE;
6046#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006047#ifdef FEAT_AUTOCMD
6048 int ft_changed = FALSE;
6049#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006050
6051 /* Get the global option to compare with, otherwise we would have to check
6052 * two values for all local options. */
6053 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6054
6055 /* Disallow changing some options from secure mode */
6056 if ((secure
6057#ifdef HAVE_SANDBOX
6058 || sandbox != 0
6059#endif
6060 ) && (options[opt_idx].flags & P_SECURE))
6061 {
6062 errmsg = e_secure;
6063 }
6064
Bram Moolenaar7554da42016-11-25 22:04:13 +01006065 /* Check for a "normal" directory or file name in some options. Disallow a
6066 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006067 * are often illegal in a file name. Be more permissive if "secure" is off.
6068 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006069 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006070 && vim_strpbrk(*varp, (char_u *)(secure
6071 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006072 || ((options[opt_idx].flags & P_NDNAME)
6073 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006074 {
6075 errmsg = e_invarg;
6076 }
6077
Bram Moolenaar071d4272004-06-13 20:20:40 +00006078 /* 'term' */
6079 else if (varp == &T_NAME)
6080 {
6081 if (T_NAME[0] == NUL)
6082 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6083#ifdef FEAT_GUI
6084 if (gui.in_use)
6085 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6086 else if (term_is_gui(T_NAME))
6087 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6088#endif
6089 else if (set_termname(T_NAME) == FAIL)
6090 errmsg = (char_u *)N_("E522: Not found in termcap");
6091 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006092 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006093 /* Screen colors may have changed. */
6094 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006095
6096 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6097 * P_ALLOCED flag on 'term'. */
6098 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006099 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006100 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006101 }
6102
6103 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006104 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006105 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006106 char_u *bkc = p_bkc;
6107 unsigned int *flags = &bkc_flags;
6108
6109 if (opt_flags & OPT_LOCAL)
6110 {
6111 bkc = curbuf->b_p_bkc;
6112 flags = &curbuf->b_bkc_flags;
6113 }
6114
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006115 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6116 /* make the local value empty: use the global value */
6117 *flags = 0;
6118 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006119 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006120 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6121 errmsg = e_invarg;
6122 if ((((int)*flags & BKC_AUTO) != 0)
6123 + (((int)*flags & BKC_YES) != 0)
6124 + (((int)*flags & BKC_NO) != 0) != 1)
6125 {
6126 /* Must have exactly one of "auto", "yes" and "no". */
6127 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6128 errmsg = e_invarg;
6129 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006130 }
6131 }
6132
6133 /* 'backupext' and 'patchmode' */
6134 else if (varp == &p_bex || varp == &p_pm)
6135 {
6136 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6137 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6138 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6139 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006140#ifdef FEAT_LINEBREAK
6141 /* 'breakindentopt' */
6142 else if (varp == &curwin->w_p_briopt)
6143 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006144 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006145 errmsg = e_invarg;
6146 }
6147#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006148
6149 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006150 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006151 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006152 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006153 */
6154 else if ( varp == &p_isi
6155 || varp == &(curbuf->b_p_isk)
6156 || varp == &p_isp
6157 || varp == &p_isf)
6158 {
6159 if (init_chartab() == FAIL)
6160 {
6161 did_chartab = TRUE; /* need to restore it below */
6162 errmsg = e_invarg; /* error in value */
6163 }
6164 }
6165
6166 /* 'helpfile' */
6167 else if (varp == &p_hf)
6168 {
6169 /* May compute new values for $VIM and $VIMRUNTIME */
6170 if (didset_vim)
6171 {
6172 vim_setenv((char_u *)"VIM", (char_u *)"");
6173 didset_vim = FALSE;
6174 }
6175 if (didset_vimruntime)
6176 {
6177 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6178 didset_vimruntime = FALSE;
6179 }
6180 }
6181
Bram Moolenaar1a384422010-07-14 19:53:30 +02006182#ifdef FEAT_SYN_HL
6183 /* 'colorcolumn' */
6184 else if (varp == &curwin->w_p_cc)
6185 errmsg = check_colorcolumn(curwin);
6186#endif
6187
Bram Moolenaar071d4272004-06-13 20:20:40 +00006188#ifdef FEAT_MULTI_LANG
6189 /* 'helplang' */
6190 else if (varp == &p_hlg)
6191 {
6192 /* Check for "", "ab", "ab,cd", etc. */
6193 for (s = p_hlg; *s != NUL; s += 3)
6194 {
6195 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6196 {
6197 errmsg = e_invarg;
6198 break;
6199 }
6200 if (s[2] == NUL)
6201 break;
6202 }
6203 }
6204#endif
6205
6206 /* 'highlight' */
6207 else if (varp == &p_hl)
6208 {
6209 if (highlight_changed() == FAIL)
6210 errmsg = e_invarg; /* invalid flags */
6211 }
6212
6213 /* 'nrformats' */
6214 else if (gvarp == &p_nf)
6215 {
6216 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6217 errmsg = e_invarg;
6218 }
6219
6220#ifdef FEAT_SESSION
6221 /* 'sessionoptions' */
6222 else if (varp == &p_ssop)
6223 {
6224 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6225 errmsg = e_invarg;
6226 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6227 {
6228 /* Don't allow both "sesdir" and "curdir". */
6229 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6230 errmsg = e_invarg;
6231 }
6232 }
6233 /* 'viewoptions' */
6234 else if (varp == &p_vop)
6235 {
6236 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6237 errmsg = e_invarg;
6238 }
6239#endif
6240
6241 /* 'scrollopt' */
6242#ifdef FEAT_SCROLLBIND
6243 else if (varp == &p_sbo)
6244 {
6245 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6246 errmsg = e_invarg;
6247 }
6248#endif
6249
6250 /* 'ambiwidth' */
6251#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006252 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006253 {
6254 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6255 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006256 else if (set_chars_option(&p_lcs) != NULL)
6257 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6258# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6259 else if (set_chars_option(&p_fcs) != NULL)
6260 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6261# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006262 }
6263#endif
6264
6265 /* 'background' */
6266 else if (varp == &p_bg)
6267 {
6268 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6269 {
6270#ifdef FEAT_EVAL
6271 int dark = (*p_bg == 'd');
6272#endif
6273
6274 init_highlight(FALSE, FALSE);
6275
6276#ifdef FEAT_EVAL
6277 if (dark != (*p_bg == 'd')
6278 && get_var_value((char_u *)"g:colors_name") != NULL)
6279 {
6280 /* The color scheme must have set 'background' back to another
6281 * value, that's not what we want here. Disable the color
6282 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006283 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006284 free_string_option(p_bg);
6285 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6286 check_string_option(&p_bg);
6287 init_highlight(FALSE, FALSE);
6288 }
6289#endif
6290 }
6291 else
6292 errmsg = e_invarg;
6293 }
6294
6295 /* 'wildmode' */
6296 else if (varp == &p_wim)
6297 {
6298 if (check_opt_wim() == FAIL)
6299 errmsg = e_invarg;
6300 }
6301
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006302#ifdef FEAT_CMDL_COMPL
6303 /* 'wildoptions' */
6304 else if (varp == &p_wop)
6305 {
6306 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6307 errmsg = e_invarg;
6308 }
6309#endif
6310
Bram Moolenaar071d4272004-06-13 20:20:40 +00006311#ifdef FEAT_WAK
6312 /* 'winaltkeys' */
6313 else if (varp == &p_wak)
6314 {
6315 if (*p_wak == NUL
6316 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6317 errmsg = e_invarg;
6318# ifdef FEAT_MENU
6319# ifdef FEAT_GUI_MOTIF
6320 else if (gui.in_use)
6321 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6322# else
6323# ifdef FEAT_GUI_GTK
6324 else if (gui.in_use)
6325 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6326# endif
6327# endif
6328# endif
6329 }
6330#endif
6331
6332#ifdef FEAT_AUTOCMD
6333 /* 'eventignore' */
6334 else if (varp == &p_ei)
6335 {
6336 if (check_ei() == FAIL)
6337 errmsg = e_invarg;
6338 }
6339#endif
6340
6341#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006342 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6343 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6344 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006345 {
6346 if (gvarp == &p_fenc)
6347 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006348 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006349 errmsg = e_modifiable;
6350 else if (vim_strchr(*varp, ',') != NULL)
6351 /* No comma allowed in 'fileencoding'; catches confusing it
6352 * with 'fileencodings'. */
6353 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006354 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006355 {
6356# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006357 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006358 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006359# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006360 /* Add 'fileencoding' to the swap file. */
6361 ml_setflags(curbuf);
6362 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006363 }
6364 if (errmsg == NULL)
6365 {
6366 /* canonize the value, so that STRCMP() can be used on it */
6367 p = enc_canonize(*varp);
6368 if (p != NULL)
6369 {
6370 vim_free(*varp);
6371 *varp = p;
6372 }
6373 if (varp == &p_enc)
6374 {
6375 errmsg = mb_init();
6376# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006377 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006378# endif
6379 }
6380 }
6381
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006382# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006383 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6384 {
6385 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6386 if (STRCMP(p_tenc, "utf-8") != 0)
6387 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6388 }
6389# endif
6390
6391 if (errmsg == NULL)
6392 {
6393# ifdef FEAT_KEYMAP
6394 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6395 * (with another encoding). */
6396 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6397 (void)keymap_init();
6398# endif
6399
6400 /* When 'termencoding' is not empty and 'encoding' changes or when
6401 * 'termencoding' changes, need to setup for keyboard input and
6402 * display output conversion. */
6403 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6404 {
6405 convert_setup(&input_conv, p_tenc, p_enc);
6406 convert_setup(&output_conv, p_enc, p_tenc);
6407 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006408
6409# if defined(WIN3264) && defined(FEAT_MBYTE)
6410 /* $HOME may have characters in active code page. */
6411 if (varp == &p_enc)
6412 init_homedir();
6413# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006414 }
6415 }
6416#endif
6417
6418#if defined(FEAT_POSTSCRIPT)
6419 else if (varp == &p_penc)
6420 {
6421 /* Canonize printencoding if VIM standard one */
6422 p = enc_canonize(p_penc);
6423 if (p != NULL)
6424 {
6425 vim_free(p_penc);
6426 p_penc = p;
6427 }
6428 else
6429 {
6430 /* Ensure lower case and '-' for '_' */
6431 for (s = p_penc; *s != NUL; s++)
6432 {
6433 if (*s == '_')
6434 *s = '-';
6435 else
6436 *s = TOLOWER_ASC(*s);
6437 }
6438 }
6439 }
6440#endif
6441
Bram Moolenaar9372a112005-12-06 19:59:18 +00006442#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006443 else if (varp == &p_imak)
6444 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006445 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006446 errmsg = e_invarg;
6447 }
6448#endif
6449
6450#ifdef FEAT_KEYMAP
6451 else if (varp == &curbuf->b_p_keymap)
6452 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006453 if (!valid_filetype(*varp))
6454 errmsg = e_invarg;
6455 else
6456 /* load or unload key mapping tables */
6457 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006458
Bram Moolenaarfab06232009-03-04 03:13:35 +00006459 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006460 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006461 if (*curbuf->b_p_keymap != NUL)
6462 {
6463 /* Installed a new keymap, switch on using it. */
6464 curbuf->b_p_iminsert = B_IMODE_LMAP;
6465 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6466 curbuf->b_p_imsearch = B_IMODE_LMAP;
6467 }
6468 else
6469 {
6470 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6471 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6472 curbuf->b_p_iminsert = B_IMODE_NONE;
6473 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6474 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6475 }
6476 if ((opt_flags & OPT_LOCAL) == 0)
6477 {
6478 set_iminsert_global();
6479 set_imsearch_global();
6480 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006481# ifdef FEAT_WINDOWS
6482 status_redraw_curbuf();
6483# endif
6484 }
6485 }
6486#endif
6487
6488 /* 'fileformat' */
6489 else if (gvarp == &p_ff)
6490 {
6491 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6492 errmsg = e_modifiable;
6493 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6494 errmsg = e_invarg;
6495 else
6496 {
6497 /* may also change 'textmode' */
6498 if (get_fileformat(curbuf) == EOL_DOS)
6499 curbuf->b_p_tx = TRUE;
6500 else
6501 curbuf->b_p_tx = FALSE;
6502#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006503 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006504#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006505 /* update flag in swap file */
6506 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006507 /* Redraw needed when switching to/from "mac": a CR in the text
6508 * will be displayed differently. */
6509 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6510 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006511 }
6512 }
6513
6514 /* 'fileformats' */
6515 else if (varp == &p_ffs)
6516 {
6517 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6518 errmsg = e_invarg;
6519 else
6520 {
6521 /* also change 'textauto' */
6522 if (*p_ffs == NUL)
6523 p_ta = FALSE;
6524 else
6525 p_ta = TRUE;
6526 }
6527 }
6528
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006529#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006530 /* 'cryptkey' */
6531 else if (gvarp == &p_key)
6532 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006533# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006534 /* Make sure the ":set" command doesn't show the new value in the
6535 * history. */
6536 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006537# endif
6538 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6539 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006540 ml_set_crypt_key(curbuf, oldval,
6541 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006542 }
6543
6544 else if (gvarp == &p_cm)
6545 {
6546 if (opt_flags & OPT_LOCAL)
6547 p = curbuf->b_p_cm;
6548 else
6549 p = p_cm;
6550 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6551 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006552 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006553 errmsg = e_invarg;
6554 else
6555 {
6556 /* When setting the global value to empty, make it "zip". */
6557 if (*p_cm == NUL)
6558 {
6559 if (new_value_alloced)
6560 free_string_option(p_cm);
6561 p_cm = vim_strsave((char_u *)"zip");
6562 new_value_alloced = TRUE;
6563 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006564 /* When using ":set cm=name" the local value is going to be empty.
6565 * Do that here, otherwise the crypt functions will still use the
6566 * local value. */
6567 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6568 {
6569 free_string_option(curbuf->b_p_cm);
6570 curbuf->b_p_cm = empty_option;
6571 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006572
6573 /* Need to update the swapfile when the effective method changed.
6574 * Set "s" to the effective old value, "p" to the effective new
6575 * method and compare. */
6576 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6577 s = p_cm; /* was previously using the global value */
6578 else
6579 s = oldval;
6580 if (*curbuf->b_p_cm == NUL)
6581 p = p_cm; /* is now using the global value */
6582 else
6583 p = curbuf->b_p_cm;
6584 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006585 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006586
6587 /* If the global value changes need to update the swapfile for all
6588 * buffers using that value. */
6589 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6590 {
6591 buf_T *buf;
6592
Bram Moolenaar29323592016-07-24 22:04:11 +02006593 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006594 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006595 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006596 }
6597 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006598 }
6599#endif
6600
6601 /* 'matchpairs' */
6602 else if (gvarp == &p_mps)
6603 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006604#ifdef FEAT_MBYTE
6605 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006606 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006607 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006608 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006609 int x2 = -1;
6610 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006611
6612 if (*p != NUL)
6613 p += mb_ptr2len(p);
6614 if (*p != NUL)
6615 x2 = *p++;
6616 if (*p != NUL)
6617 {
6618 x3 = mb_ptr2char(p);
6619 p += mb_ptr2len(p);
6620 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006621 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006622 {
6623 errmsg = e_invarg;
6624 break;
6625 }
6626 if (*p == NUL)
6627 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006628 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006629 }
6630 else
6631#endif
6632 {
6633 /* Check for "x:y,x:y" */
6634 for (p = *varp; *p != NUL; p += 4)
6635 {
6636 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6637 {
6638 errmsg = e_invarg;
6639 break;
6640 }
6641 if (p[3] == NUL)
6642 break;
6643 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006644 }
6645 }
6646
6647#ifdef FEAT_COMMENTS
6648 /* 'comments' */
6649 else if (gvarp == &p_com)
6650 {
6651 for (s = *varp; *s; )
6652 {
6653 while (*s && *s != ':')
6654 {
6655 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6656 && !VIM_ISDIGIT(*s) && *s != '-')
6657 {
6658 errmsg = illegal_char(errbuf, *s);
6659 break;
6660 }
6661 ++s;
6662 }
6663 if (*s++ == NUL)
6664 errmsg = (char_u *)N_("E524: Missing colon");
6665 else if (*s == ',' || *s == NUL)
6666 errmsg = (char_u *)N_("E525: Zero length string");
6667 if (errmsg != NULL)
6668 break;
6669 while (*s && *s != ',')
6670 {
6671 if (*s == '\\' && s[1] != NUL)
6672 ++s;
6673 ++s;
6674 }
6675 s = skip_to_option_part(s);
6676 }
6677 }
6678#endif
6679
6680 /* 'listchars' */
6681 else if (varp == &p_lcs)
6682 {
6683 errmsg = set_chars_option(varp);
6684 }
6685
6686#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6687 /* 'fillchars' */
6688 else if (varp == &p_fcs)
6689 {
6690 errmsg = set_chars_option(varp);
6691 }
6692#endif
6693
6694#ifdef FEAT_CMDWIN
6695 /* 'cedit' */
6696 else if (varp == &p_cedit)
6697 {
6698 errmsg = check_cedit();
6699 }
6700#endif
6701
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006702 /* 'verbosefile' */
6703 else if (varp == &p_vfile)
6704 {
6705 verbose_stop();
6706 if (*p_vfile != NUL && verbose_open() == FAIL)
6707 errmsg = e_invarg;
6708 }
6709
Bram Moolenaar071d4272004-06-13 20:20:40 +00006710#ifdef FEAT_VIMINFO
6711 /* 'viminfo' */
6712 else if (varp == &p_viminfo)
6713 {
6714 for (s = p_viminfo; *s;)
6715 {
6716 /* Check it's a valid character */
6717 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6718 {
6719 errmsg = illegal_char(errbuf, *s);
6720 break;
6721 }
6722 if (*s == 'n') /* name is always last one */
6723 {
6724 break;
6725 }
6726 else if (*s == 'r') /* skip until next ',' */
6727 {
6728 while (*++s && *s != ',')
6729 ;
6730 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006731 else if (*s == '%')
6732 {
6733 /* optional number */
6734 while (vim_isdigit(*++s))
6735 ;
6736 }
6737 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006738 ++s; /* no extra chars */
6739 else /* must have a number */
6740 {
6741 while (vim_isdigit(*++s))
6742 ;
6743
6744 if (!VIM_ISDIGIT(*(s - 1)))
6745 {
6746 if (errbuf != NULL)
6747 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006748 sprintf((char *)errbuf,
6749 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006750 transchar_byte(*(s - 1)));
6751 errmsg = errbuf;
6752 }
6753 else
6754 errmsg = (char_u *)"";
6755 break;
6756 }
6757 }
6758 if (*s == ',')
6759 ++s;
6760 else if (*s)
6761 {
6762 if (errbuf != NULL)
6763 errmsg = (char_u *)N_("E527: Missing comma");
6764 else
6765 errmsg = (char_u *)"";
6766 break;
6767 }
6768 }
6769 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6770 errmsg = (char_u *)N_("E528: Must specify a ' value");
6771 }
6772#endif /* FEAT_VIMINFO */
6773
6774 /* terminal options */
6775 else if (istermoption(&options[opt_idx]) && full_screen)
6776 {
6777 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6778 if (varp == &T_CCO)
6779 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006780 int colors = atoi((char *)T_CCO);
6781
6782 /* Only reinitialize colors if t_Co value has really changed to
6783 * avoid expensive reload of colorscheme if t_Co is set to the
6784 * same value multiple times. */
6785 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006786 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006787 t_colors = colors;
6788 if (t_colors <= 1)
6789 {
6790 if (new_value_alloced)
6791 vim_free(T_CCO);
6792 T_CCO = empty_option;
6793 }
6794 /* We now have a different color setup, initialize it again. */
6795 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006796 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006797 }
6798 ttest(FALSE);
6799 if (varp == &T_ME)
6800 {
6801 out_str(T_ME);
6802 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006803#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006804 /* Since t_me has been set, this probably means that the user
6805 * wants to use this as default colors. Need to reset default
6806 * background/foreground colors. */
6807 mch_set_normal_colors();
6808#endif
6809 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006810 if (varp == &T_BE && termcap_active)
6811 {
6812 if (*T_BE == NUL)
6813 /* When clearing t_BE we assume the user no longer wants
6814 * bracketed paste, thus disable it by writing t_BD. */
6815 out_str(T_BD);
6816 else
6817 out_str(T_BE);
6818 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006819 }
6820
6821#ifdef FEAT_LINEBREAK
6822 /* 'showbreak' */
6823 else if (varp == &p_sbr)
6824 {
6825 for (s = p_sbr; *s; )
6826 {
6827 if (ptr2cells(s) != 1)
6828 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006829 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006830 }
6831 }
6832#endif
6833
6834#ifdef FEAT_GUI
6835 /* 'guifont' */
6836 else if (varp == &p_guifont)
6837 {
6838 if (gui.in_use)
6839 {
6840 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006841# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006842 /*
6843 * Put up a font dialog and let the user select a new value.
6844 * If this is cancelled go back to the old value but don't
6845 * give an error message.
6846 */
6847 if (STRCMP(p, "*") == 0)
6848 {
6849 p = gui_mch_font_dialog(oldval);
6850
6851 if (new_value_alloced)
6852 free_string_option(p_guifont);
6853
6854 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6855 new_value_alloced = TRUE;
6856 }
6857# endif
6858 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6859 {
6860# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6861 if (STRCMP(p_guifont, "*") == 0)
6862 {
6863 /* Dialog was cancelled: Keep the old value without giving
6864 * an error message. */
6865 if (new_value_alloced)
6866 free_string_option(p_guifont);
6867 p_guifont = vim_strsave(oldval);
6868 new_value_alloced = TRUE;
6869 }
6870 else
6871# endif
6872 errmsg = (char_u *)N_("E596: Invalid font(s)");
6873 }
6874 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006875 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006876 }
6877# ifdef FEAT_XFONTSET
6878 else if (varp == &p_guifontset)
6879 {
6880 if (STRCMP(p_guifontset, "*") == 0)
6881 errmsg = (char_u *)N_("E597: can't select fontset");
6882 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6883 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006884 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006885 }
6886# endif
6887# ifdef FEAT_MBYTE
6888 else if (varp == &p_guifontwide)
6889 {
6890 if (STRCMP(p_guifontwide, "*") == 0)
6891 errmsg = (char_u *)N_("E533: can't select wide font");
6892 else if (gui_get_wide_font() == FAIL)
6893 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006894 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006895 }
6896# endif
6897#endif
6898
6899#ifdef CURSOR_SHAPE
6900 /* 'guicursor' */
6901 else if (varp == &p_guicursor)
6902 errmsg = parse_shape_opt(SHAPE_CURSOR);
6903#endif
6904
6905#ifdef FEAT_MOUSESHAPE
6906 /* 'mouseshape' */
6907 else if (varp == &p_mouseshape)
6908 {
6909 errmsg = parse_shape_opt(SHAPE_MOUSE);
6910 update_mouseshape(-1);
6911 }
6912#endif
6913
6914#ifdef FEAT_PRINTER
6915 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006916 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006917# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006918 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006919 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006920# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006921#endif
6922
6923#ifdef FEAT_LANGMAP
6924 /* 'langmap' */
6925 else if (varp == &p_langmap)
6926 langmap_set();
6927#endif
6928
6929#ifdef FEAT_LINEBREAK
6930 /* 'breakat' */
6931 else if (varp == &p_breakat)
6932 fill_breakat_flags();
6933#endif
6934
6935#ifdef FEAT_TITLE
6936 /* 'titlestring' and 'iconstring' */
6937 else if (varp == &p_titlestring || varp == &p_iconstring)
6938 {
6939# ifdef FEAT_STL_OPT
6940 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6941
6942 /* NULL => statusline syntax */
6943 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6944 stl_syntax |= flagval;
6945 else
6946 stl_syntax &= ~flagval;
6947# endif
6948 did_set_title(varp == &p_iconstring);
6949
6950 }
6951#endif
6952
6953#ifdef FEAT_GUI
6954 /* 'guioptions' */
6955 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006956 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006957 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006958 redraw_gui_only = TRUE;
6959 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006960#endif
6961
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006962#if defined(FEAT_GUI_TABLINE)
6963 /* 'guitablabel' */
6964 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006965 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006966 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006967 redraw_gui_only = TRUE;
6968 }
6969 /* 'guitabtooltip' */
6970 else if (varp == &p_gtt)
6971 {
6972 redraw_gui_only = TRUE;
6973 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006974#endif
6975
Bram Moolenaar071d4272004-06-13 20:20:40 +00006976#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6977 /* 'ttymouse' */
6978 else if (varp == &p_ttym)
6979 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006980 /* Switch the mouse off before changing the escape sequences used for
6981 * that. */
6982 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006983 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6984 errmsg = e_invarg;
6985 else
6986 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006987 if (termcap_active)
6988 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006989 }
6990#endif
6991
Bram Moolenaar071d4272004-06-13 20:20:40 +00006992 /* 'selection' */
6993 else if (varp == &p_sel)
6994 {
6995 if (*p_sel == NUL
6996 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6997 errmsg = e_invarg;
6998 }
6999
7000 /* 'selectmode' */
7001 else if (varp == &p_slm)
7002 {
7003 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
7004 errmsg = e_invarg;
7005 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007006
7007#ifdef FEAT_BROWSE
7008 /* 'browsedir' */
7009 else if (varp == &p_bsdir)
7010 {
7011 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
7012 && !mch_isdir(p_bsdir))
7013 errmsg = e_invarg;
7014 }
7015#endif
7016
Bram Moolenaar071d4272004-06-13 20:20:40 +00007017 /* 'keymodel' */
7018 else if (varp == &p_km)
7019 {
7020 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7021 errmsg = e_invarg;
7022 else
7023 {
7024 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7025 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7026 }
7027 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028
7029 /* 'mousemodel' */
7030 else if (varp == &p_mousem)
7031 {
7032 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7033 errmsg = e_invarg;
7034#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7035 else if (*p_mousem != *oldval)
7036 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7037 * to create or delete the popup menus. */
7038 gui_motif_update_mousemodel(root_menu);
7039#endif
7040 }
7041
7042 /* 'switchbuf' */
7043 else if (varp == &p_swb)
7044 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007045 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007046 errmsg = e_invarg;
7047 }
7048
7049 /* 'debug' */
7050 else if (varp == &p_debug)
7051 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007052 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007053 errmsg = e_invarg;
7054 }
7055
7056 /* 'display' */
7057 else if (varp == &p_dy)
7058 {
7059 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7060 errmsg = e_invarg;
7061 else
7062 (void)init_chartab();
7063
7064 }
7065
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007066#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007067 /* 'eadirection' */
7068 else if (varp == &p_ead)
7069 {
7070 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7071 errmsg = e_invarg;
7072 }
7073#endif
7074
7075#ifdef FEAT_CLIPBOARD
7076 /* 'clipboard' */
7077 else if (varp == &p_cb)
7078 errmsg = check_clipboard_option();
7079#endif
7080
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007081#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007082 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7083 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007084 else if (varp == &(curwin->w_s->b_p_spl)
7085 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007086 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007087 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007088 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007089 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007090 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007091 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007092 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007093 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007094 /* 'spellsuggest' */
7095 else if (varp == &p_sps)
7096 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007097 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007098 errmsg = e_invarg;
7099 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007100 /* 'mkspellmem' */
7101 else if (varp == &p_msm)
7102 {
7103 if (spell_check_msm() != OK)
7104 errmsg = e_invarg;
7105 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007106#endif
7107
Bram Moolenaar071d4272004-06-13 20:20:40 +00007108 /* When 'bufhidden' is set, check for valid value. */
7109 else if (gvarp == &p_bh)
7110 {
7111 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7112 errmsg = e_invarg;
7113 }
7114
7115 /* When 'buftype' is set, check for valid value. */
7116 else if (gvarp == &p_bt)
7117 {
7118 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7119 errmsg = e_invarg;
7120 else
7121 {
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007122#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007123 if (curwin->w_status_height)
7124 {
7125 curwin->w_redr_status = TRUE;
7126 redraw_later(VALID);
7127 }
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007128#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007129 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007130#ifdef FEAT_TITLE
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007131 redraw_titles();
Bram Moolenaar1f2903c2017-07-23 19:51:01 +02007132#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007133 }
7134 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007135
7136#ifdef FEAT_STL_OPT
7137 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007138 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007139 {
7140 int wid;
7141
7142 if (varp == &p_ruf) /* reset ru_wid first */
7143 ru_wid = 0;
7144 s = *varp;
7145 if (varp == &p_ruf && *s == '%')
7146 {
7147 /* set ru_wid if 'ruf' starts with "%99(" */
7148 if (*++s == '-') /* ignore a '-' */
7149 s++;
7150 wid = getdigits(&s);
7151 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7152 ru_wid = wid;
7153 else
7154 errmsg = check_stl_option(p_ruf);
7155 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007156 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007157 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007158 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007159 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007160 comp_col();
7161 }
7162#endif
7163
7164#ifdef FEAT_INS_EXPAND
7165 /* check if it is a valid value for 'complete' -- Acevedo */
7166 else if (gvarp == &p_cpt)
7167 {
7168 for (s = *varp; *s;)
7169 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007170 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007171 s++;
7172 if (!*s)
7173 break;
7174 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7175 {
7176 errmsg = illegal_char(errbuf, *s);
7177 break;
7178 }
7179 if (*++s != NUL && *s != ',' && *s != ' ')
7180 {
7181 if (s[-1] == 'k' || s[-1] == 's')
7182 {
7183 /* skip optional filename after 'k' and 's' */
7184 while (*s && *s != ',' && *s != ' ')
7185 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007186 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007187 ++s;
7188 ++s;
7189 }
7190 }
7191 else
7192 {
7193 if (errbuf != NULL)
7194 {
7195 sprintf((char *)errbuf,
7196 _("E535: Illegal character after <%c>"),
7197 *--s);
7198 errmsg = errbuf;
7199 }
7200 else
7201 errmsg = (char_u *)"";
7202 break;
7203 }
7204 }
7205 }
7206 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007207
7208 /* 'completeopt' */
7209 else if (varp == &p_cot)
7210 {
7211 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7212 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007213 else
7214 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007215 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007216#endif /* FEAT_INS_EXPAND */
7217
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007218#ifdef FEAT_SIGNS
7219 /* 'signcolumn' */
7220 else if (varp == &curwin->w_p_scl)
7221 {
7222 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7223 errmsg = e_invarg;
7224 }
7225#endif
7226
Bram Moolenaar071d4272004-06-13 20:20:40 +00007227
7228#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007229 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007230 else if (varp == &p_toolbar)
7231 {
7232 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7233 &toolbar_flags, TRUE) != OK)
7234 errmsg = e_invarg;
7235 else
7236 {
7237 out_flush();
7238 gui_mch_show_toolbar((toolbar_flags &
7239 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7240 }
7241 }
7242#endif
7243
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007244#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007245 /* 'toolbariconsize': GTK+ 2 only */
7246 else if (varp == &p_tbis)
7247 {
7248 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7249 errmsg = e_invarg;
7250 else
7251 {
7252 out_flush();
7253 gui_mch_show_toolbar((toolbar_flags &
7254 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7255 }
7256 }
7257#endif
7258
7259 /* 'pastetoggle': translate key codes like in a mapping */
7260 else if (varp == &p_pt)
7261 {
7262 if (*p_pt)
7263 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007264 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007265 if (p != NULL)
7266 {
7267 if (new_value_alloced)
7268 free_string_option(p_pt);
7269 p_pt = p;
7270 new_value_alloced = TRUE;
7271 }
7272 }
7273 }
7274
7275 /* 'backspace' */
7276 else if (varp == &p_bs)
7277 {
7278 if (VIM_ISDIGIT(*p_bs))
7279 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007280 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007281 errmsg = e_invarg;
7282 }
7283 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7284 errmsg = e_invarg;
7285 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007286 else if (varp == &p_bo)
7287 {
7288 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7289 errmsg = e_invarg;
7290 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007291
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007292 /* 'tagcase' */
7293 else if (gvarp == &p_tc)
7294 {
7295 unsigned int *flags;
7296
7297 if (opt_flags & OPT_LOCAL)
7298 {
7299 p = curbuf->b_p_tc;
7300 flags = &curbuf->b_tc_flags;
7301 }
7302 else
7303 {
7304 p = p_tc;
7305 flags = &tc_flags;
7306 }
7307
7308 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7309 /* make the local value empty: use the global value */
7310 *flags = 0;
7311 else if (*p == NUL
7312 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7313 errmsg = e_invarg;
7314 }
7315
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007316#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007317 /* 'casemap' */
7318 else if (varp == &p_cmp)
7319 {
7320 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7321 errmsg = e_invarg;
7322 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007323#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007324
7325#ifdef FEAT_DIFF
7326 /* 'diffopt' */
7327 else if (varp == &p_dip)
7328 {
7329 if (diffopt_changed() == FAIL)
7330 errmsg = e_invarg;
7331 }
7332#endif
7333
7334#ifdef FEAT_FOLDING
7335 /* 'foldmethod' */
7336 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7337 {
7338 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7339 || *curwin->w_p_fdm == NUL)
7340 errmsg = e_invarg;
7341 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007342 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007343 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007344 if (foldmethodIsDiff(curwin))
7345 newFoldLevel();
7346 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007347 }
7348# ifdef FEAT_EVAL
7349 /* 'foldexpr' */
7350 else if (varp == &curwin->w_p_fde)
7351 {
7352 if (foldmethodIsExpr(curwin))
7353 foldUpdateAll(curwin);
7354 }
7355# endif
7356 /* 'foldmarker' */
7357 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7358 {
7359 p = vim_strchr(*varp, ',');
7360 if (p == NULL)
7361 errmsg = (char_u *)N_("E536: comma required");
7362 else if (p == *varp || p[1] == NUL)
7363 errmsg = e_invarg;
7364 else if (foldmethodIsMarker(curwin))
7365 foldUpdateAll(curwin);
7366 }
7367 /* 'commentstring' */
7368 else if (gvarp == &p_cms)
7369 {
7370 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7371 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7372 }
7373 /* 'foldopen' */
7374 else if (varp == &p_fdo)
7375 {
7376 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7377 errmsg = e_invarg;
7378 }
7379 /* 'foldclose' */
7380 else if (varp == &p_fcl)
7381 {
7382 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7383 errmsg = e_invarg;
7384 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007385 /* 'foldignore' */
7386 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7387 {
7388 if (foldmethodIsIndent(curwin))
7389 foldUpdateAll(curwin);
7390 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007391#endif
7392
7393#ifdef FEAT_VIRTUALEDIT
7394 /* 'virtualedit' */
7395 else if (varp == &p_ve)
7396 {
7397 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7398 errmsg = e_invarg;
7399 else if (STRCMP(p_ve, oldval) != 0)
7400 {
7401 /* Recompute cursor position in case the new 've' setting
7402 * changes something. */
7403 validate_virtcol();
7404 coladvance(curwin->w_virtcol);
7405 }
7406 }
7407#endif
7408
7409#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7410 else if (varp == &p_csqf)
7411 {
7412 if (p_csqf != NULL)
7413 {
7414 p = p_csqf;
7415 while (*p != NUL)
7416 {
7417 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7418 || p[1] == NUL
7419 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7420 || (p[2] != NUL && p[2] != ','))
7421 {
7422 errmsg = e_invarg;
7423 break;
7424 }
7425 else if (p[2] == NUL)
7426 break;
7427 else
7428 p += 3;
7429 }
7430 }
7431 }
7432#endif
7433
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007434#ifdef FEAT_CINDENT
7435 /* 'cinoptions' */
7436 else if (gvarp == &p_cino)
7437 {
7438 /* TODO: recognize errors */
7439 parse_cino(curbuf);
7440 }
7441#endif
7442
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007443#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007444 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007445 else if (varp == &p_rop && gui.in_use)
7446 {
7447 if (!gui_mch_set_rendering_options(p_rop))
7448 errmsg = e_invarg;
7449 }
7450#endif
7451
Bram Moolenaard0b51382016-11-04 15:23:45 +01007452#ifdef FEAT_AUTOCMD
7453 else if (gvarp == &p_ft)
7454 {
7455 if (!valid_filetype(*varp))
7456 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007457 else
7458 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007459 }
7460#endif
7461
7462#ifdef FEAT_SYN_HL
7463 else if (gvarp == &p_syn)
7464 {
7465 if (!valid_filetype(*varp))
7466 errmsg = e_invarg;
7467 }
7468#endif
7469
Bram Moolenaar825680f2017-07-22 17:04:02 +02007470#ifdef FEAT_TERMINAL
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007471 /* 'termkey' */
Bram Moolenaarc4f43bc2017-07-24 20:03:01 +02007472 else if (varp == &curwin->w_p_tk)
Bram Moolenaardbe948d2017-07-23 22:50:51 +02007473 {
7474 if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0)
7475 errmsg = e_invarg;
7476 }
Bram Moolenaar825680f2017-07-22 17:04:02 +02007477 /* 'termsize' */
7478 else if (varp == &curwin->w_p_tms)
7479 {
7480 if (*curwin->w_p_tms != NUL)
7481 {
7482 p = skipdigits(curwin->w_p_tms);
7483 if (p == curwin->w_p_tms || *p != 'x' || *skipdigits(p + 1) != NUL)
7484 errmsg = e_invarg;
7485 }
7486 }
7487#endif
7488
Bram Moolenaar071d4272004-06-13 20:20:40 +00007489 /* Options that are a list of flags. */
7490 else
7491 {
7492 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007493 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007494 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007495 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007496 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007497 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007498 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007499 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007500 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007501#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007502 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007503 p = (char_u *)COCU_ALL;
7504#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007505 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007506 {
7507#ifdef FEAT_MOUSE
7508 p = (char_u *)MOUSE_ALL;
7509#else
7510 if (*p_mouse != NUL)
7511 errmsg = (char_u *)N_("E538: No mouse support");
7512#endif
7513 }
7514#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007515 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007516 p = (char_u *)GO_ALL;
7517#endif
7518 if (p != NULL)
7519 {
7520 for (s = *varp; *s; ++s)
7521 if (vim_strchr(p, *s) == NULL)
7522 {
7523 errmsg = illegal_char(errbuf, *s);
7524 break;
7525 }
7526 }
7527 }
7528
7529 /*
7530 * If error detected, restore the previous value.
7531 */
7532 if (errmsg != NULL)
7533 {
7534 if (new_value_alloced)
7535 free_string_option(*varp);
7536 *varp = oldval;
7537 /*
7538 * When resetting some values, need to act on it.
7539 */
7540 if (did_chartab)
7541 (void)init_chartab();
7542 if (varp == &p_hl)
7543 (void)highlight_changed();
7544 }
7545 else
7546 {
7547#ifdef FEAT_EVAL
7548 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007549 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007550#endif
7551 /*
7552 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007553 * Use "free_oldval", because recursiveness may change the flags under
7554 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007555 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007556 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007557 free_string_option(oldval);
7558 if (new_value_alloced)
7559 options[opt_idx].flags |= P_ALLOCED;
7560 else
7561 options[opt_idx].flags &= ~P_ALLOCED;
7562
7563 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007564 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007565 {
7566 /* global option with local value set to use global value; free
7567 * the local value and make it empty */
7568 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7569 free_string_option(*(char_u **)p);
7570 *(char_u **)p = empty_option;
7571 }
7572
7573 /* May set global value for local option. */
7574 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7575 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007576
7577#ifdef FEAT_AUTOCMD
7578 /*
7579 * Trigger the autocommand only after setting the flags.
7580 */
7581# ifdef FEAT_SYN_HL
7582 /* When 'syntax' is set, load the syntax of that name */
7583 if (varp == &(curbuf->b_p_syn))
7584 {
7585 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7586 curbuf->b_fname, TRUE, curbuf);
7587 }
7588# endif
7589 else if (varp == &(curbuf->b_p_ft))
7590 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007591 /* 'filetype' is set, trigger the FileType autocommand.
7592 * Skip this when called from a modeline and the filetype was
7593 * already set to this value. */
7594 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7595 {
7596 did_filetype = TRUE;
7597 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007598 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar163095f2017-07-09 15:41:53 +02007599 /* Just in case the old "curbuf" is now invalid. */
7600 if (varp != &(curbuf->b_p_ft))
7601 varp = NULL;
Bram Moolenaar90492982017-06-22 14:16:31 +02007602 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007603 }
7604#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007605#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007606 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007607 {
7608 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007609 char_u *q = curwin->w_s->b_p_spl;
7610
7611 /* Skip the first name if it is "cjk". */
7612 if (STRNCMP(q, "cjk,", 4) == 0)
7613 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007614
7615 /*
7616 * Source the spell/LANG.vim in 'runtimepath'.
7617 * They could set 'spellcapcheck' depending on the language.
7618 * Use the first name in 'spelllang' up to '_region' or
7619 * '.encoding'.
7620 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007621 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007622 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7623 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007624 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007625 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007626 }
7627#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007628 }
7629
7630#ifdef FEAT_MOUSE
7631 if (varp == &p_mouse)
7632 {
7633# ifdef FEAT_MOUSE_TTY
7634 if (*p_mouse == NUL)
7635 mch_setmouse(FALSE); /* switch mouse off */
7636 else
7637# endif
7638 setmouse(); /* in case 'mouse' changed */
7639 }
7640#endif
7641
Bram Moolenaar913077c2012-03-28 19:59:04 +02007642 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007643 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007644 curwin->w_set_curswant = TRUE;
7645
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007646#ifdef FEAT_GUI
7647 /* check redraw when it's not a GUI option or the GUI is active. */
7648 if (!redraw_gui_only || gui.in_use)
7649#endif
7650 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007651
7652 return errmsg;
7653}
7654
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007655#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007656/*
7657 * Simple int comparison function for use with qsort()
7658 */
7659 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007660int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007661{
7662 return *(const int *)a - *(const int *)b;
7663}
7664
7665/*
7666 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7667 * Returns error message, NULL if it's OK.
7668 */
7669 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007670check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007671{
7672 char_u *s;
7673 int col;
7674 int count = 0;
7675 int color_cols[256];
7676 int i;
7677 int j = 0;
7678
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007679 if (wp->w_buffer == NULL)
7680 return NULL; /* buffer was closed */
7681
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007682 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007683 {
7684 if (*s == '-' || *s == '+')
7685 {
7686 /* -N and +N: add to 'textwidth' */
7687 col = (*s == '-') ? -1 : 1;
7688 ++s;
7689 if (!VIM_ISDIGIT(*s))
7690 return e_invarg;
7691 col = col * getdigits(&s);
7692 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007693 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007694 col += wp->w_buffer->b_p_tw;
7695 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007696 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007697 }
7698 else if (VIM_ISDIGIT(*s))
7699 col = getdigits(&s);
7700 else
7701 return e_invarg;
7702 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007703skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007704 if (*s == NUL)
7705 break;
7706 if (*s != ',')
7707 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007708 if (*++s == NUL)
7709 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007710 }
7711
7712 vim_free(wp->w_p_cc_cols);
7713 if (count == 0)
7714 wp->w_p_cc_cols = NULL;
7715 else
7716 {
7717 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7718 if (wp->w_p_cc_cols != NULL)
7719 {
7720 /* sort the columns for faster usage on screen redraw inside
7721 * win_line() */
7722 qsort(color_cols, count, sizeof(int), int_cmp);
7723
7724 for (i = 0; i < count; ++i)
7725 /* skip duplicates */
7726 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7727 wp->w_p_cc_cols[j++] = color_cols[i];
7728 wp->w_p_cc_cols[j] = -1; /* end marker */
7729 }
7730 }
7731
7732 return NULL; /* no error */
7733}
7734#endif
7735
Bram Moolenaar071d4272004-06-13 20:20:40 +00007736/*
7737 * Handle setting 'listchars' or 'fillchars'.
7738 * Returns error message, NULL if it's OK.
7739 */
7740 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007741set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007742{
7743 int round, i, len, entries;
7744 char_u *p, *s;
7745 int c1, c2 = 0;
7746 struct charstab
7747 {
7748 int *cp;
7749 char *name;
7750 };
7751#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7752 static struct charstab filltab[] =
7753 {
7754 {&fill_stl, "stl"},
7755 {&fill_stlnc, "stlnc"},
7756 {&fill_vert, "vert"},
7757 {&fill_fold, "fold"},
7758 {&fill_diff, "diff"},
7759 };
7760#endif
7761 static struct charstab lcstab[] =
7762 {
7763 {&lcs_eol, "eol"},
7764 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007765 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007766 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007767 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007768 {&lcs_tab2, "tab"},
7769 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007770#ifdef FEAT_CONCEAL
7771 {&lcs_conceal, "conceal"},
7772#else
7773 {NULL, "conceal"},
7774#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007775 };
7776 struct charstab *tab;
7777
7778#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7779 if (varp == &p_lcs)
7780#endif
7781 {
7782 tab = lcstab;
7783 entries = sizeof(lcstab) / sizeof(struct charstab);
7784 }
7785#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7786 else
7787 {
7788 tab = filltab;
7789 entries = sizeof(filltab) / sizeof(struct charstab);
7790 }
7791#endif
7792
7793 /* first round: check for valid value, second round: assign values */
7794 for (round = 0; round <= 1; ++round)
7795 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007796 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007797 {
7798 /* After checking that the value is valid: set defaults: space for
7799 * 'fillchars', NUL for 'listchars' */
7800 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007801 if (tab[i].cp != NULL)
7802 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007803 if (varp == &p_lcs)
7804 lcs_tab1 = NUL;
7805#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7806 else
7807 fill_diff = '-';
7808#endif
7809 }
7810 p = *varp;
7811 while (*p)
7812 {
7813 for (i = 0; i < entries; ++i)
7814 {
7815 len = (int)STRLEN(tab[i].name);
7816 if (STRNCMP(p, tab[i].name, len) == 0
7817 && p[len] == ':'
7818 && p[len + 1] != NUL)
7819 {
7820 s = p + len + 1;
7821#ifdef FEAT_MBYTE
7822 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007823 if (mb_char2cells(c1) > 1)
7824 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007825#else
7826 c1 = *s++;
7827#endif
7828 if (tab[i].cp == &lcs_tab2)
7829 {
7830 if (*s == NUL)
7831 continue;
7832#ifdef FEAT_MBYTE
7833 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007834 if (mb_char2cells(c2) > 1)
7835 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007836#else
7837 c2 = *s++;
7838#endif
7839 }
7840 if (*s == ',' || *s == NUL)
7841 {
7842 if (round)
7843 {
7844 if (tab[i].cp == &lcs_tab2)
7845 {
7846 lcs_tab1 = c1;
7847 lcs_tab2 = c2;
7848 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007849 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007850 *(tab[i].cp) = c1;
7851
7852 }
7853 p = s;
7854 break;
7855 }
7856 }
7857 }
7858
7859 if (i == entries)
7860 return e_invarg;
7861 if (*p == ',')
7862 ++p;
7863 }
7864 }
7865
7866 return NULL; /* no error */
7867}
7868
7869#ifdef FEAT_STL_OPT
7870/*
7871 * Check validity of options with the 'statusline' format.
7872 * Return error message or NULL.
7873 */
7874 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007875check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007876{
7877 int itemcnt = 0;
7878 int groupdepth = 0;
7879 static char_u errbuf[80];
7880
7881 while (*s && itemcnt < STL_MAX_ITEM)
7882 {
7883 /* Check for valid keys after % sequences */
7884 while (*s && *s != '%')
7885 s++;
7886 if (!*s)
7887 break;
7888 s++;
7889 if (*s != '%' && *s != ')')
7890 ++itemcnt;
7891 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7892 {
7893 s++;
7894 continue;
7895 }
7896 if (*s == ')')
7897 {
7898 s++;
7899 if (--groupdepth < 0)
7900 break;
7901 continue;
7902 }
7903 if (*s == '-')
7904 s++;
7905 while (VIM_ISDIGIT(*s))
7906 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007907 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007908 continue;
7909 if (*s == '.')
7910 {
7911 s++;
7912 while (*s && VIM_ISDIGIT(*s))
7913 s++;
7914 }
7915 if (*s == '(')
7916 {
7917 groupdepth++;
7918 continue;
7919 }
7920 if (vim_strchr(STL_ALL, *s) == NULL)
7921 {
7922 return illegal_char(errbuf, *s);
7923 }
7924 if (*s == '{')
7925 {
7926 s++;
7927 while (*s != '}' && *s)
7928 s++;
7929 if (*s != '}')
7930 return (char_u *)N_("E540: Unclosed expression sequence");
7931 }
7932 }
7933 if (itemcnt >= STL_MAX_ITEM)
7934 return (char_u *)N_("E541: too many items");
7935 if (groupdepth != 0)
7936 return (char_u *)N_("E542: unbalanced groups");
7937 return NULL;
7938}
7939#endif
7940
7941#ifdef FEAT_CLIPBOARD
7942/*
7943 * Extract the items in the 'clipboard' option and set global values.
7944 */
7945 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007946check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007947{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007948 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007949 int new_autoselect_star = FALSE;
7950 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007951 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007952 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007953 regprog_T *new_exclude_prog = NULL;
7954 char_u *errmsg = NULL;
7955 char_u *p;
7956
7957 for (p = p_cb; *p != NUL; )
7958 {
7959 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7960 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007961 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007962 p += 7;
7963 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007964 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007965 && (p[11] == ',' || p[11] == NUL))
7966 {
7967 new_unnamed |= CLIP_UNNAMED_PLUS;
7968 p += 11;
7969 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007970 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007971 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007972 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007973 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007974 p += 10;
7975 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007976 else if (STRNCMP(p, "autoselectplus", 14) == 0
7977 && (p[14] == ',' || p[14] == NUL))
7978 {
7979 new_autoselect_plus = TRUE;
7980 p += 14;
7981 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007982 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007983 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007984 {
7985 new_autoselectml = TRUE;
7986 p += 12;
7987 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007988 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7989 {
7990 new_html = TRUE;
7991 p += 4;
7992 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007993 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7994 {
7995 p += 8;
7996 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7997 if (new_exclude_prog == NULL)
7998 errmsg = e_invarg;
7999 break;
8000 }
8001 else
8002 {
8003 errmsg = e_invarg;
8004 break;
8005 }
8006 if (*p == ',')
8007 ++p;
8008 }
8009 if (errmsg == NULL)
8010 {
8011 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02008012 clip_autoselect_star = new_autoselect_star;
8013 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008014 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00008015 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02008016 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008017 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02008018#ifdef FEAT_GUI_GTK
8019 if (gui.in_use)
8020 {
8021 gui_gtk_set_selection_targets();
8022 gui_gtk_set_dnd_targets();
8023 }
8024#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008025 }
8026 else
Bram Moolenaar473de612013-06-08 18:19:48 +02008027 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008028
8029 return errmsg;
8030}
8031#endif
8032
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008033#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008034 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008035did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02008036{
8037 char_u *errmsg = NULL;
8038 win_T *wp;
8039 int l;
8040
8041 if (is_spellfile)
8042 {
8043 l = (int)STRLEN(curwin->w_s->b_p_spf);
8044 if (l > 0 && (l < 4
8045 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8046 errmsg = e_invarg;
8047 }
8048
8049 if (errmsg == NULL)
8050 {
8051 FOR_ALL_WINDOWS(wp)
8052 if (wp->w_buffer == curbuf && wp->w_p_spell)
8053 {
8054 errmsg = did_set_spelllang(wp);
8055# ifdef FEAT_WINDOWS
8056 break;
8057# endif
8058 }
8059 }
8060 return errmsg;
8061}
8062
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008063/*
8064 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8065 * Return error message when failed, NULL when OK.
8066 */
8067 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008068compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008069{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008070 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008071 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008072
Bram Moolenaar860cae12010-06-05 23:22:07 +02008073 if (*synblock->b_p_spc == NUL)
8074 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008075 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008076 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008077 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008078 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008079 if (re != NULL)
8080 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008081 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008082 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008083 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008084 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008085 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008086 return e_invarg;
8087 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008088 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008089 }
8090
Bram Moolenaar473de612013-06-08 18:19:48 +02008091 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008092 return NULL;
8093}
8094#endif
8095
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008096#if defined(FEAT_EVAL) || defined(PROTO)
8097/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008098 * Set the scriptID for an option, taking care of setting the buffer- or
8099 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008100 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008101 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008102set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008103{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008104 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8105 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008106
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008107 /* Remember where the option was set. For local options need to do that
8108 * in the buffer or window structure. */
8109 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008110 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008111 if (both || (opt_flags & OPT_LOCAL))
8112 {
8113 if (indir & PV_BUF)
8114 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8115 else if (indir & PV_WIN)
8116 curwin->w_p_scriptID[indir & PV_MASK] = id;
8117 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008118}
8119#endif
8120
Bram Moolenaar071d4272004-06-13 20:20:40 +00008121/*
8122 * Set the value of a boolean option, and take care of side effects.
8123 * Returns NULL for success, or an error message for an error.
8124 */
8125 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008126set_bool_option(
8127 int opt_idx, /* index in options[] table */
8128 char_u *varp, /* pointer to the option variable */
8129 int value, /* new value */
8130 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008131{
8132 int old_value = *(int *)varp;
8133
Bram Moolenaar071d4272004-06-13 20:20:40 +00008134 /* Disallow changing some options from secure mode */
8135 if ((secure
8136#ifdef HAVE_SANDBOX
8137 || sandbox != 0
8138#endif
8139 ) && (options[opt_idx].flags & P_SECURE))
8140 return e_secure;
8141
8142 *(int *)varp = value; /* set the new value */
8143#ifdef FEAT_EVAL
8144 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008145 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008146#endif
8147
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008148#ifdef FEAT_GUI
8149 need_mouse_correct = TRUE;
8150#endif
8151
Bram Moolenaar071d4272004-06-13 20:20:40 +00008152 /* May set global value for local option. */
8153 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8154 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8155
8156 /*
8157 * Handle side effects of changing a bool option.
8158 */
8159
8160 /* 'compatible' */
8161 if ((int *)varp == &p_cp)
8162 {
8163 compatible_set();
8164 }
8165
Bram Moolenaar920694c2016-08-21 17:45:02 +02008166#ifdef FEAT_LANGMAP
8167 if ((int *)varp == &p_lrm)
8168 /* 'langremap' -> !'langnoremap' */
8169 p_lnr = !p_lrm;
8170 else if ((int *)varp == &p_lnr)
8171 /* 'langnoremap' -> !'langremap' */
8172 p_lrm = !p_lnr;
8173#endif
8174
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008175#ifdef FEAT_PERSISTENT_UNDO
8176 /* 'undofile' */
8177 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8178 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008179 /* Only take action when the option was set. When reset we do not
8180 * delete the undo file, the option may be set again without making
8181 * any changes in between. */
8182 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008183 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008184 char_u hash[UNDO_HASH_SIZE];
8185 buf_T *save_curbuf = curbuf;
8186
Bram Moolenaar29323592016-07-24 22:04:11 +02008187 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008188 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008189 /* When 'undofile' is set globally: for every buffer, otherwise
8190 * only for the current buffer: Try to read in the undofile,
8191 * if one exists, the buffer wasn't changed and the buffer was
8192 * loaded */
8193 if ((curbuf == save_curbuf
8194 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8195 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8196 {
8197 u_compute_hash(hash);
8198 u_read_undo(NULL, hash, curbuf->b_fname);
8199 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008200 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008201 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008202 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008203 }
8204#endif
8205
Bram Moolenaar071d4272004-06-13 20:20:40 +00008206 else if ((int *)varp == &curbuf->b_p_ro)
8207 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008208 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008209 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8210 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008211
8212 /* when 'readonly' is set may give W10 again */
8213 if (curbuf->b_p_ro)
8214 curbuf->b_did_warn = FALSE;
8215
Bram Moolenaar071d4272004-06-13 20:20:40 +00008216#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008217 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008218#endif
8219 }
8220
Bram Moolenaar9c449722010-07-20 18:44:27 +02008221#ifdef FEAT_GUI
8222 else if ((int *)varp == &p_mh)
8223 {
8224 if (!p_mh)
8225 gui_mch_mousehide(FALSE);
8226 }
8227#endif
8228
Bram Moolenaara539df02010-08-01 14:35:05 +02008229 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008230 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008231 {
Bram Moolenaar423802d2017-07-30 16:52:24 +02008232# ifdef FEAT_TERMINAL
8233 /* Cannot set 'modifiable' when in Terminal mode. */
Bram Moolenaar6d819742017-08-06 14:57:49 +02008234 if (term_in_normal_mode()
Bram Moolenaar20e6cd02017-08-01 20:25:22 +02008235 || (bt_terminal(curbuf) && !term_is_finished(curbuf)))
Bram Moolenaar423802d2017-07-30 16:52:24 +02008236 {
8237 curbuf->b_p_ma = FALSE;
8238 return (char_u *)N_("E946: Cannot make a terminal with running job modifiable");
8239 }
8240# endif
8241# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008242 redraw_titles();
Bram Moolenaar423802d2017-07-30 16:52:24 +02008243# endif
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008244 }
Bram Moolenaar423802d2017-07-30 16:52:24 +02008245#ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00008246 /* when 'endofline' is changed, redraw the window title */
8247 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008248 {
8249 redraw_titles();
8250 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008251 /* when 'fixeol' is changed, redraw the window title */
8252 else if ((int *)varp == &curbuf->b_p_fixeol)
8253 {
8254 redraw_titles();
8255 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008256# ifdef FEAT_MBYTE
8257 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008258 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008259 {
8260 redraw_titles();
8261 }
8262# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008263#endif
8264
8265 /* when 'bin' is set also set some other options */
8266 else if ((int *)varp == &curbuf->b_p_bin)
8267 {
8268 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8269#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008270 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008271#endif
8272 }
8273
8274#ifdef FEAT_AUTOCMD
8275 /* when 'buflisted' changes, trigger autocommands */
8276 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8277 {
8278 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8279 NULL, NULL, TRUE, curbuf);
8280 }
8281#endif
8282
8283 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8284 else if ((int *)varp == &curbuf->b_p_swf)
8285 {
8286 if (curbuf->b_p_swf && p_uc)
8287 ml_open_file(curbuf); /* create the swap file */
8288 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008289 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8290 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008291 mf_close_file(curbuf, TRUE); /* remove the swap file */
8292 }
8293
8294 /* when 'terse' is set change 'shortmess' */
8295 else if ((int *)varp == &p_terse)
8296 {
8297 char_u *p;
8298
8299 p = vim_strchr(p_shm, SHM_SEARCH);
8300
8301 /* insert 's' in p_shm */
8302 if (p_terse && p == NULL)
8303 {
8304 STRCPY(IObuff, p_shm);
8305 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008306 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008307 }
8308 /* remove 's' from p_shm */
8309 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008310 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008311 }
8312
8313 /* when 'paste' is set or reset also change other options */
8314 else if ((int *)varp == &p_paste)
8315 {
8316 paste_option_changed();
8317 }
8318
8319 /* when 'insertmode' is set from an autocommand need to do work here */
8320 else if ((int *)varp == &p_im)
8321 {
8322 if (p_im)
8323 {
8324 if ((State & INSERT) == 0)
8325 need_start_insertmode = TRUE;
8326 stop_insert_mode = FALSE;
8327 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008328 /* only reset if it was set previously */
8329 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008330 {
8331 need_start_insertmode = FALSE;
8332 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008333 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008334 clear_cmdline = TRUE; /* remove "(insert)" */
8335 restart_edit = 0;
8336 }
8337 }
8338
8339 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8340 else if ((int *)varp == &p_ic && p_hls)
8341 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008342 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008343 }
8344
8345#ifdef FEAT_SEARCH_EXTRA
8346 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8347 else if ((int *)varp == &p_hls)
8348 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008349 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008350 }
8351#endif
8352
8353#ifdef FEAT_SCROLLBIND
8354 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8355 * at the end of normal_cmd() */
8356 else if ((int *)varp == &curwin->w_p_scb)
8357 {
8358 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008359 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008360 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008361 curwin->w_scbind_pos = curwin->w_topline;
8362 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008363 }
8364#endif
8365
8366#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8367 /* There can be only one window with 'previewwindow' set. */
8368 else if ((int *)varp == &curwin->w_p_pvw)
8369 {
8370 if (curwin->w_p_pvw)
8371 {
8372 win_T *win;
8373
Bram Moolenaar29323592016-07-24 22:04:11 +02008374 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008375 if (win->w_p_pvw && win != curwin)
8376 {
8377 curwin->w_p_pvw = FALSE;
8378 return (char_u *)N_("E590: A preview window already exists");
8379 }
8380 }
8381 }
8382#endif
8383
8384 /* when 'textmode' is set or reset also change 'fileformat' */
8385 else if ((int *)varp == &curbuf->b_p_tx)
8386 {
8387 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8388 }
8389
8390 /* when 'textauto' is set or reset also change 'fileformats' */
8391 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008392 set_string_option_direct((char_u *)"ffs", -1,
8393 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008394 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008395
8396 /*
8397 * When 'lisp' option changes include/exclude '-' in
8398 * keyword characters.
8399 */
8400#ifdef FEAT_LISP
8401 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8402 {
8403 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8404 }
8405#endif
8406
8407#ifdef FEAT_TITLE
8408 /* when 'title' changed, may need to change the title; same for 'icon' */
8409 else if ((int *)varp == &p_title)
8410 {
8411 did_set_title(FALSE);
8412 }
8413
8414 else if ((int *)varp == &p_icon)
8415 {
8416 did_set_title(TRUE);
8417 }
8418#endif
8419
8420 else if ((int *)varp == &curbuf->b_changed)
8421 {
8422 if (!value)
8423 save_file_ff(curbuf); /* Buffer is unchanged */
8424#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008425 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008426#endif
8427#ifdef FEAT_AUTOCMD
8428 modified_was_set = value;
8429#endif
8430 }
8431
8432#ifdef BACKSLASH_IN_FILENAME
8433 else if ((int *)varp == &p_ssl)
8434 {
8435 if (p_ssl)
8436 {
8437 psepc = '/';
8438 psepcN = '\\';
8439 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008440 }
8441 else
8442 {
8443 psepc = '\\';
8444 psepcN = '/';
8445 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008446 }
8447
8448 /* need to adjust the file name arguments and buffer names. */
8449 buflist_slash_adjust();
8450 alist_slash_adjust();
8451# ifdef FEAT_EVAL
8452 scriptnames_slash_adjust();
8453# endif
8454 }
8455#endif
8456
8457 /* If 'wrap' is set, set w_leftcol to zero. */
8458 else if ((int *)varp == &curwin->w_p_wrap)
8459 {
8460 if (curwin->w_p_wrap)
8461 curwin->w_leftcol = 0;
8462 }
8463
8464#ifdef FEAT_WINDOWS
8465 else if ((int *)varp == &p_ea)
8466 {
8467 if (p_ea && !old_value)
8468 win_equal(curwin, FALSE, 0);
8469 }
8470#endif
8471
8472 else if ((int *)varp == &p_wiv)
8473 {
8474 /*
8475 * When 'weirdinvert' changed, set/reset 't_xs'.
8476 * Then set 'weirdinvert' according to value of 't_xs'.
8477 */
8478 if (p_wiv && !old_value)
8479 T_XS = (char_u *)"y";
8480 else if (!p_wiv && old_value)
8481 T_XS = empty_option;
8482 p_wiv = (*T_XS != NUL);
8483 }
8484
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008485#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008486 else if ((int *)varp == &p_beval)
8487 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008488 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008489 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008490 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008491 gui_mch_disable_beval_area(balloonEval);
8492 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008493#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008494
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008495#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008496 else if ((int *)varp == &p_acd)
8497 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008498 /* Change directories when the 'acd' option is set now. */
8499 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008500 }
8501#endif
8502
8503#ifdef FEAT_DIFF
8504 /* 'diff' */
8505 else if ((int *)varp == &curwin->w_p_diff)
8506 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008507 /* May add or remove the buffer from the list of diff buffers. */
8508 diff_buf_adjust(curwin);
8509# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008510 if (foldmethodIsDiff(curwin))
8511 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008512# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008513 }
8514#endif
8515
8516#ifdef USE_IM_CONTROL
8517 /* 'imdisable' */
8518 else if ((int *)varp == &p_imdisable)
8519 {
8520 /* Only de-activate it here, it will be enabled when changing mode. */
8521 if (p_imdisable)
8522 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008523 else if (State & INSERT)
8524 /* When the option is set from an autocommand, it may need to take
8525 * effect right away. */
8526 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008527 }
8528#endif
8529
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008530#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008531 /* 'spell' */
8532 else if ((int *)varp == &curwin->w_p_spell)
8533 {
8534 if (curwin->w_p_spell)
8535 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008536 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008537 if (errmsg != NULL)
8538 EMSG(_(errmsg));
8539 }
8540 }
8541#endif
8542
Bram Moolenaar071d4272004-06-13 20:20:40 +00008543#ifdef FEAT_FKMAP
8544 else if ((int *)varp == &p_altkeymap)
8545 {
8546 if (old_value != p_altkeymap)
8547 {
8548 if (!p_altkeymap)
8549 {
8550 p_hkmap = p_fkmap;
8551 p_fkmap = 0;
8552 }
8553 else
8554 {
8555 p_fkmap = p_hkmap;
8556 p_hkmap = 0;
8557 }
8558 (void)init_chartab();
8559 }
8560 }
8561
8562 /*
8563 * In case some second language keymapping options have changed, check
8564 * and correct the setting in a consistent way.
8565 */
8566
8567 /*
8568 * If hkmap or fkmap are set, reset Arabic keymapping.
8569 */
8570 if ((p_hkmap || p_fkmap) && p_altkeymap)
8571 {
8572 p_altkeymap = p_fkmap;
8573# ifdef FEAT_ARABIC
8574 curwin->w_p_arab = FALSE;
8575# endif
8576 (void)init_chartab();
8577 }
8578
8579 /*
8580 * If hkmap set, reset Farsi keymapping.
8581 */
8582 if (p_hkmap && p_altkeymap)
8583 {
8584 p_altkeymap = 0;
8585 p_fkmap = 0;
8586# ifdef FEAT_ARABIC
8587 curwin->w_p_arab = FALSE;
8588# endif
8589 (void)init_chartab();
8590 }
8591
8592 /*
8593 * If fkmap set, reset Hebrew keymapping.
8594 */
8595 if (p_fkmap && !p_altkeymap)
8596 {
8597 p_altkeymap = 1;
8598 p_hkmap = 0;
8599# ifdef FEAT_ARABIC
8600 curwin->w_p_arab = FALSE;
8601# endif
8602 (void)init_chartab();
8603 }
8604#endif
8605
8606#ifdef FEAT_ARABIC
8607 if ((int *)varp == &curwin->w_p_arab)
8608 {
8609 if (curwin->w_p_arab)
8610 {
8611 /*
8612 * 'arabic' is set, handle various sub-settings.
8613 */
8614 if (!p_tbidi)
8615 {
8616 /* set rightleft mode */
8617 if (!curwin->w_p_rl)
8618 {
8619 curwin->w_p_rl = TRUE;
8620 changed_window_setting();
8621 }
8622
8623 /* Enable Arabic shaping (major part of what Arabic requires) */
8624 if (!p_arshape)
8625 {
8626 p_arshape = TRUE;
8627 redraw_later_clear();
8628 }
8629 }
8630
8631 /* Arabic requires a utf-8 encoding, inform the user if its not
8632 * set. */
8633 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008634 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008635 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8636
Bram Moolenaar8820b482017-03-16 17:23:31 +01008637 msg_source(HL_ATTR(HLF_W));
8638 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008639#ifdef FEAT_EVAL
8640 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8641#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008642 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008643
8644# ifdef FEAT_MBYTE
8645 /* set 'delcombine' */
8646 p_deco = TRUE;
8647# endif
8648
8649# ifdef FEAT_KEYMAP
8650 /* Force-set the necessary keymap for arabic */
8651 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8652 OPT_LOCAL);
8653# endif
8654# ifdef FEAT_FKMAP
8655 p_altkeymap = 0;
8656 p_hkmap = 0;
8657 p_fkmap = 0;
8658 (void)init_chartab();
8659# endif
8660 }
8661 else
8662 {
8663 /*
8664 * 'arabic' is reset, handle various sub-settings.
8665 */
8666 if (!p_tbidi)
8667 {
8668 /* reset rightleft mode */
8669 if (curwin->w_p_rl)
8670 {
8671 curwin->w_p_rl = FALSE;
8672 changed_window_setting();
8673 }
8674
8675 /* 'arabicshape' isn't reset, it is a global option and
8676 * another window may still need it "on". */
8677 }
8678
8679 /* 'delcombine' isn't reset, it is a global option and another
8680 * window may still want it "on". */
8681
8682# ifdef FEAT_KEYMAP
8683 /* Revert to the default keymap */
8684 curbuf->b_p_iminsert = B_IMODE_NONE;
8685 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8686# endif
8687 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008688 }
8689
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008690#endif
8691
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008692#ifdef FEAT_TERMGUICOLORS
8693 /* 'termguicolors' */
8694 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008695 {
8696# ifdef FEAT_GUI
8697 if (!gui.in_use && !gui.starting)
8698# endif
8699 highlight_gui_started();
8700 }
8701#endif
8702
Bram Moolenaar071d4272004-06-13 20:20:40 +00008703 /*
8704 * End of handling side effects for bool options.
8705 */
8706
Bram Moolenaar53744302015-07-17 17:38:22 +02008707 /* after handling side effects, call autocommand */
8708
Bram Moolenaar071d4272004-06-13 20:20:40 +00008709 options[opt_idx].flags |= P_WAS_SET;
8710
Bram Moolenaar53744302015-07-17 17:38:22 +02008711#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8712 if (!starting)
8713 {
8714 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008715 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8716 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8717 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008718 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8719 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8720 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8721 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8722 reset_v_option_vars();
8723 }
8724#endif
8725
Bram Moolenaar071d4272004-06-13 20:20:40 +00008726 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008727 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008728 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008729 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008730 check_redraw(options[opt_idx].flags);
8731
8732 return NULL;
8733}
8734
8735/*
8736 * Set the value of a number option, and take care of side effects.
8737 * Returns NULL for success, or an error message for an error.
8738 */
8739 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008740set_num_option(
8741 int opt_idx, /* index in options[] table */
8742 char_u *varp, /* pointer to the option variable */
8743 long value, /* new value */
8744 char_u *errbuf, /* buffer for error messages */
8745 size_t errbuflen, /* length of "errbuf" */
8746 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008747 OPT_MODELINE */
8748{
8749 char_u *errmsg = NULL;
8750 long old_value = *(long *)varp;
8751 long old_Rows = Rows; /* remember old Rows */
8752 long old_Columns = Columns; /* remember old Columns */
8753 long *pp = (long *)varp;
8754
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008755 /* Disallow changing some options from secure mode. */
8756 if ((secure
8757#ifdef HAVE_SANDBOX
8758 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008759#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008760 ) && (options[opt_idx].flags & P_SECURE))
8761 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008762
8763 *pp = value;
8764#ifdef FEAT_EVAL
8765 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008766 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008767#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008768#ifdef FEAT_GUI
8769 need_mouse_correct = TRUE;
8770#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008771
Bram Moolenaar14f24742012-08-08 18:01:05 +02008772 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008773 {
8774 errmsg = e_positive;
8775 curbuf->b_p_sw = curbuf->b_p_ts;
8776 }
8777
8778 /*
8779 * Number options that need some action when changed
8780 */
8781#ifdef FEAT_WINDOWS
8782 if (pp == &p_wh || pp == &p_hh)
8783 {
8784 if (p_wh < 1)
8785 {
8786 errmsg = e_positive;
8787 p_wh = 1;
8788 }
8789 if (p_wmh > p_wh)
8790 {
8791 errmsg = e_winheight;
8792 p_wh = p_wmh;
8793 }
8794 if (p_hh < 0)
8795 {
8796 errmsg = e_positive;
8797 p_hh = 0;
8798 }
8799
8800 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008801 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008802 {
8803 if (pp == &p_wh && curwin->w_height < p_wh)
8804 win_setheight((int)p_wh);
8805 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8806 win_setheight((int)p_hh);
8807 }
8808 }
8809
8810 /* 'winminheight' */
8811 else if (pp == &p_wmh)
8812 {
8813 if (p_wmh < 0)
8814 {
8815 errmsg = e_positive;
8816 p_wmh = 0;
8817 }
8818 if (p_wmh > p_wh)
8819 {
8820 errmsg = e_winheight;
8821 p_wmh = p_wh;
8822 }
8823 win_setminheight();
8824 }
8825
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008826# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008827 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008828 {
8829 if (p_wiw < 1)
8830 {
8831 errmsg = e_positive;
8832 p_wiw = 1;
8833 }
8834 if (p_wmw > p_wiw)
8835 {
8836 errmsg = e_winwidth;
8837 p_wiw = p_wmw;
8838 }
8839
8840 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008841 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008842 win_setwidth((int)p_wiw);
8843 }
8844
8845 /* 'winminwidth' */
8846 else if (pp == &p_wmw)
8847 {
8848 if (p_wmw < 0)
8849 {
8850 errmsg = e_positive;
8851 p_wmw = 0;
8852 }
8853 if (p_wmw > p_wiw)
8854 {
8855 errmsg = e_winwidth;
8856 p_wmw = p_wiw;
8857 }
8858 win_setminheight();
8859 }
8860# endif
8861
8862#endif
8863
8864#ifdef FEAT_WINDOWS
8865 /* (re)set last window status line */
8866 else if (pp == &p_ls)
8867 {
8868 last_status(FALSE);
8869 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008870
8871 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008872 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008873 {
8874 shell_new_rows(); /* recompute window positions and heights */
8875 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008876#endif
8877
8878#ifdef FEAT_GUI
8879 else if (pp == &p_linespace)
8880 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008881 /* Recompute gui.char_height and resize the Vim window to keep the
8882 * same number of lines. */
8883 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008884 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008885 }
8886#endif
8887
8888#ifdef FEAT_FOLDING
8889 /* 'foldlevel' */
8890 else if (pp == &curwin->w_p_fdl)
8891 {
8892 if (curwin->w_p_fdl < 0)
8893 curwin->w_p_fdl = 0;
8894 newFoldLevel();
8895 }
8896
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008897 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008898 else if (pp == &curwin->w_p_fml)
8899 {
8900 foldUpdateAll(curwin);
8901 }
8902
8903 /* 'foldnestmax' */
8904 else if (pp == &curwin->w_p_fdn)
8905 {
8906 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8907 foldUpdateAll(curwin);
8908 }
8909
8910 /* 'foldcolumn' */
8911 else if (pp == &curwin->w_p_fdc)
8912 {
8913 if (curwin->w_p_fdc < 0)
8914 {
8915 errmsg = e_positive;
8916 curwin->w_p_fdc = 0;
8917 }
8918 else if (curwin->w_p_fdc > 12)
8919 {
8920 errmsg = e_invarg;
8921 curwin->w_p_fdc = 12;
8922 }
8923 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008924#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008925
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008926#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008927 /* 'shiftwidth' or 'tabstop' */
8928 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8929 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008930# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008931 if (foldmethodIsIndent(curwin))
8932 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008933# endif
8934# ifdef FEAT_CINDENT
8935 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8936 * parse 'cinoptions'. */
8937 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8938 parse_cino(curbuf);
8939# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008940 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008941#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008942
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008943#ifdef FEAT_MBYTE
8944 /* 'maxcombine' */
8945 else if (pp == &p_mco)
8946 {
8947 if (p_mco > MAX_MCO)
8948 p_mco = MAX_MCO;
8949 else if (p_mco < 0)
8950 p_mco = 0;
8951 screenclear(); /* will re-allocate the screen */
8952 }
8953#endif
8954
Bram Moolenaar071d4272004-06-13 20:20:40 +00008955 else if (pp == &curbuf->b_p_iminsert)
8956 {
8957 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8958 {
8959 errmsg = e_invarg;
8960 curbuf->b_p_iminsert = B_IMODE_NONE;
8961 }
8962 p_iminsert = curbuf->b_p_iminsert;
8963 if (termcap_active) /* don't do this in the alternate screen */
8964 showmode();
8965#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8966 /* Show/unshow value of 'keymap' in status lines. */
8967 status_redraw_curbuf();
8968#endif
8969 }
8970
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008971 else if (pp == &p_window)
8972 {
8973 if (p_window < 1)
8974 p_window = 1;
8975 else if (p_window >= Rows)
8976 p_window = Rows - 1;
8977 }
8978
Bram Moolenaar071d4272004-06-13 20:20:40 +00008979 else if (pp == &curbuf->b_p_imsearch)
8980 {
8981 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8982 {
8983 errmsg = e_invarg;
8984 curbuf->b_p_imsearch = B_IMODE_NONE;
8985 }
8986 p_imsearch = curbuf->b_p_imsearch;
8987 }
8988
8989#ifdef FEAT_TITLE
8990 /* if 'titlelen' has changed, redraw the title */
8991 else if (pp == &p_titlelen)
8992 {
8993 if (p_titlelen < 0)
8994 {
8995 errmsg = e_positive;
8996 p_titlelen = 85;
8997 }
8998 if (starting != NO_SCREEN && old_value != p_titlelen)
8999 need_maketitle = TRUE;
9000 }
9001#endif
9002
9003 /* if p_ch changed value, change the command line height */
9004 else if (pp == &p_ch)
9005 {
9006 if (p_ch < 1)
9007 {
9008 errmsg = e_positive;
9009 p_ch = 1;
9010 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00009011 if (p_ch > Rows - min_rows() + 1)
9012 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009013
9014 /* Only compute the new window layout when startup has been
9015 * completed. Otherwise the frame sizes may be wrong. */
9016 if (p_ch != old_value && full_screen
9017#ifdef FEAT_GUI
9018 && !gui.starting
9019#endif
9020 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00009021 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009022 }
9023
9024 /* when 'updatecount' changes from zero to non-zero, open swap files */
9025 else if (pp == &p_uc)
9026 {
9027 if (p_uc < 0)
9028 {
9029 errmsg = e_positive;
9030 p_uc = 100;
9031 }
9032 if (p_uc && !old_value)
9033 ml_open_files();
9034 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02009035#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009036 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009037 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009038 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009039 {
9040 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009041 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009042 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009043 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02009044 {
9045 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009046 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02009047 }
9048 }
9049#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00009050#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009051 else if (pp == &p_mzq)
9052 mzvim_reset_timer();
9053#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009054
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009055#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9056 /* 'pyxversion' */
9057 else if (pp == &p_pyx)
9058 {
9059 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9060 errmsg = e_invarg;
9061 }
9062#endif
9063
Bram Moolenaar071d4272004-06-13 20:20:40 +00009064 /* sync undo before 'undolevels' changes */
9065 else if (pp == &p_ul)
9066 {
9067 /* use the old value, otherwise u_sync() may not work properly */
9068 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009069 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009070 p_ul = value;
9071 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009072 else if (pp == &curbuf->b_p_ul)
9073 {
9074 /* use the old value, otherwise u_sync() may not work properly */
9075 curbuf->b_p_ul = old_value;
9076 u_sync(TRUE);
9077 curbuf->b_p_ul = value;
9078 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009079
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009080#ifdef FEAT_LINEBREAK
9081 /* 'numberwidth' must be positive */
9082 else if (pp == &curwin->w_p_nuw)
9083 {
9084 if (curwin->w_p_nuw < 1)
9085 {
9086 errmsg = e_positive;
9087 curwin->w_p_nuw = 1;
9088 }
9089 if (curwin->w_p_nuw > 10)
9090 {
9091 errmsg = e_invarg;
9092 curwin->w_p_nuw = 10;
9093 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009094 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009095 }
9096#endif
9097
Bram Moolenaar1a384422010-07-14 19:53:30 +02009098 else if (pp == &curbuf->b_p_tw)
9099 {
9100 if (curbuf->b_p_tw < 0)
9101 {
9102 errmsg = e_positive;
9103 curbuf->b_p_tw = 0;
9104 }
9105#ifdef FEAT_SYN_HL
9106# ifdef FEAT_WINDOWS
9107 {
9108 win_T *wp;
9109 tabpage_T *tp;
9110
9111 FOR_ALL_TAB_WINDOWS(tp, wp)
9112 check_colorcolumn(wp);
9113 }
9114# else
9115 check_colorcolumn(curwin);
9116# endif
9117#endif
9118 }
9119
Bram Moolenaar071d4272004-06-13 20:20:40 +00009120 /*
9121 * Check the bounds for numeric options here
9122 */
9123 if (Rows < min_rows() && full_screen)
9124 {
9125 if (errbuf != NULL)
9126 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009127 vim_snprintf((char *)errbuf, errbuflen,
9128 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009129 errmsg = errbuf;
9130 }
9131 Rows = min_rows();
9132 }
9133 if (Columns < MIN_COLUMNS && full_screen)
9134 {
9135 if (errbuf != NULL)
9136 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009137 vim_snprintf((char *)errbuf, errbuflen,
9138 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009139 errmsg = errbuf;
9140 }
9141 Columns = MIN_COLUMNS;
9142 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009143 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009144
Bram Moolenaar071d4272004-06-13 20:20:40 +00009145 /*
9146 * If the screen (shell) height has been changed, assume it is the
9147 * physical screenheight.
9148 */
9149 if (old_Rows != Rows || old_Columns != Columns)
9150 {
9151 /* Changing the screen size is not allowed while updating the screen. */
9152 if (updating_screen)
9153 *pp = old_value;
9154 else if (full_screen
9155#ifdef FEAT_GUI
9156 && !gui.starting
9157#endif
9158 )
9159 set_shellsize((int)Columns, (int)Rows, TRUE);
9160 else
9161 {
9162 /* Postpone the resizing; check the size and cmdline position for
9163 * messages. */
9164 check_shellsize();
9165 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9166 cmdline_row = Rows - p_ch;
9167 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009168 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009169 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009170 }
9171
Bram Moolenaar071d4272004-06-13 20:20:40 +00009172 if (curbuf->b_p_ts <= 0)
9173 {
9174 errmsg = e_positive;
9175 curbuf->b_p_ts = 8;
9176 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009177 if (p_tm < 0)
9178 {
9179 errmsg = e_positive;
9180 p_tm = 0;
9181 }
9182 if ((curwin->w_p_scr <= 0
9183 || (curwin->w_p_scr > curwin->w_height
9184 && curwin->w_height > 0))
9185 && full_screen)
9186 {
9187 if (pp == &(curwin->w_p_scr))
9188 {
9189 if (curwin->w_p_scr != 0)
9190 errmsg = e_scroll;
9191 win_comp_scroll(curwin);
9192 }
9193 /* If 'scroll' became invalid because of a side effect silently adjust
9194 * it. */
9195 else if (curwin->w_p_scr <= 0)
9196 curwin->w_p_scr = 1;
9197 else /* curwin->w_p_scr > curwin->w_height */
9198 curwin->w_p_scr = curwin->w_height;
9199 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009200 if (p_hi < 0)
9201 {
9202 errmsg = e_positive;
9203 p_hi = 0;
9204 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009205 else if (p_hi > 10000)
9206 {
9207 errmsg = e_invarg;
9208 p_hi = 10000;
9209 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009210 if (p_re < 0 || p_re > 2)
9211 {
9212 errmsg = e_invarg;
9213 p_re = 0;
9214 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009215 if (p_report < 0)
9216 {
9217 errmsg = e_positive;
9218 p_report = 1;
9219 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009220 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009221 {
9222 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9223 p_sj = Rows / 2;
9224 else
9225 {
9226 errmsg = e_scroll;
9227 p_sj = 1;
9228 }
9229 }
9230 if (p_so < 0 && full_screen)
9231 {
9232 errmsg = e_scroll;
9233 p_so = 0;
9234 }
9235 if (p_siso < 0 && full_screen)
9236 {
9237 errmsg = e_positive;
9238 p_siso = 0;
9239 }
9240#ifdef FEAT_CMDWIN
9241 if (p_cwh < 1)
9242 {
9243 errmsg = e_positive;
9244 p_cwh = 1;
9245 }
9246#endif
9247 if (p_ut < 0)
9248 {
9249 errmsg = e_positive;
9250 p_ut = 2000;
9251 }
9252 if (p_ss < 0)
9253 {
9254 errmsg = e_positive;
9255 p_ss = 0;
9256 }
9257
9258 /* May set global value for local option. */
9259 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9260 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9261
9262 options[opt_idx].flags |= P_WAS_SET;
9263
Bram Moolenaar53744302015-07-17 17:38:22 +02009264#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9265 if (!starting && errmsg == NULL)
9266 {
9267 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009268 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9269 vim_snprintf((char *)buf_new, 10, "%ld", value);
9270 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009271 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9272 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9273 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9274 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9275 reset_v_option_vars();
9276 }
9277#endif
9278
Bram Moolenaar071d4272004-06-13 20:20:40 +00009279 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009280 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009281 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009282 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009283 check_redraw(options[opt_idx].flags);
9284
9285 return errmsg;
9286}
9287
9288/*
9289 * Called after an option changed: check if something needs to be redrawn.
9290 */
9291 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009292check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009293{
9294 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009295 int doclear = (flags & P_RCLR) == P_RCLR;
9296 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009297
9298#ifdef FEAT_WINDOWS
9299 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9300 status_redraw_all();
9301#endif
9302
9303 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9304 changed_window_setting();
9305 if (flags & P_RBUF)
9306 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009307 if (flags & P_RWINONLY)
9308 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009309 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009310 redraw_all_later(CLEAR);
9311 else if (all)
9312 redraw_all_later(NOT_VALID);
9313}
9314
9315/*
9316 * Find index for option 'arg'.
9317 * Return -1 if not found.
9318 */
9319 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009320findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009321{
9322 int opt_idx;
9323 char *s, *p;
9324 static short quick_tab[27] = {0, 0}; /* quick access table */
9325 int is_term_opt;
9326
9327 /*
9328 * For first call: Initialize the quick-access table.
9329 * It contains the index for the first option that starts with a certain
9330 * letter. There are 26 letters, plus the first "t_" option.
9331 */
9332 if (quick_tab[1] == 0)
9333 {
9334 p = options[0].fullname;
9335 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9336 {
9337 if (s[0] != p[0])
9338 {
9339 if (s[0] == 't' && s[1] == '_')
9340 quick_tab[26] = opt_idx;
9341 else
9342 quick_tab[CharOrdLow(s[0])] = opt_idx;
9343 }
9344 p = s;
9345 }
9346 }
9347
9348 /*
9349 * Check for name starting with an illegal character.
9350 */
9351#ifdef EBCDIC
9352 if (!islower(arg[0]))
9353#else
9354 if (arg[0] < 'a' || arg[0] > 'z')
9355#endif
9356 return -1;
9357
9358 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9359 if (is_term_opt)
9360 opt_idx = quick_tab[26];
9361 else
9362 opt_idx = quick_tab[CharOrdLow(arg[0])];
9363 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9364 {
9365 if (STRCMP(arg, s) == 0) /* match full name */
9366 break;
9367 }
9368 if (s == NULL && !is_term_opt)
9369 {
9370 opt_idx = quick_tab[CharOrdLow(arg[0])];
9371 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9372 {
9373 s = options[opt_idx].shortname;
9374 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9375 break;
9376 s = NULL;
9377 }
9378 }
9379 if (s == NULL)
9380 opt_idx = -1;
9381 return opt_idx;
9382}
9383
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009384#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009385/*
9386 * Get the value for an option.
9387 *
9388 * Returns:
9389 * Number or Toggle option: 1, *numval gets value.
9390 * String option: 0, *stringval gets allocated string.
9391 * Hidden Number or Toggle option: -1.
9392 * hidden String option: -2.
9393 * unknown option: -3.
9394 */
9395 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009396get_option_value(
9397 char_u *name,
9398 long *numval,
9399 char_u **stringval, /* NULL when only checking existence */
9400 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009401{
9402 int opt_idx;
9403 char_u *varp;
9404
9405 opt_idx = findoption(name);
9406 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009407 {
9408 int key;
9409
9410 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9411 && (key = find_key_option(name)) != 0)
9412 {
9413 char_u key_name[2];
9414 char_u *p;
9415
9416 if (key < 0)
9417 {
9418 key_name[0] = KEY2TERMCAP0(key);
9419 key_name[1] = KEY2TERMCAP1(key);
9420 }
9421 else
9422 {
9423 key_name[0] = KS_KEY;
9424 key_name[1] = (key & 0xff);
9425 }
9426 p = find_termcode(key_name);
9427 if (p != NULL)
9428 {
9429 if (stringval != NULL)
9430 *stringval = vim_strsave(p);
9431 return 0;
9432 }
9433 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009434 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009435 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009436
9437 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9438
9439 if (options[opt_idx].flags & P_STRING)
9440 {
9441 if (varp == NULL) /* hidden option */
9442 return -2;
9443 if (stringval != NULL)
9444 {
9445#ifdef FEAT_CRYPT
9446 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009447 if ((char_u **)varp == &curbuf->b_p_key
9448 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009449 *stringval = vim_strsave((char_u *)"*****");
9450 else
9451#endif
9452 *stringval = vim_strsave(*(char_u **)(varp));
9453 }
9454 return 0;
9455 }
9456
9457 if (varp == NULL) /* hidden option */
9458 return -1;
9459 if (options[opt_idx].flags & P_NUM)
9460 *numval = *(long *)varp;
9461 else
9462 {
9463 /* Special case: 'modified' is b_changed, but we also want to consider
9464 * it set when 'ff' or 'fenc' changed. */
9465 if ((int *)varp == &curbuf->b_changed)
9466 *numval = curbufIsChanged();
9467 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009468 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009469 }
9470 return 1;
9471}
9472#endif
9473
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009474#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009475/*
9476 * Returns the option attributes and its value. Unlike the above function it
9477 * will return either global value or local value of the option depending on
9478 * what was requested, but it will never return global value if it was
9479 * requested to return local one and vice versa. Neither it will return
9480 * buffer-local value if it was requested to return window-local one.
9481 *
9482 * Pretends that option is absent if it is not present in the requested scope
9483 * (i.e. has no global, window-local or buffer-local value depending on
9484 * opt_type). Uses
9485 *
9486 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009487 * 0 hidden or unknown option, also option that does not have requested
9488 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009489 * see SOPT_* in vim.h for other flags
9490 *
9491 * Possible opt_type values: see SREQ_* in vim.h
9492 */
9493 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009494get_option_value_strict(
9495 char_u *name,
9496 long *numval,
9497 char_u **stringval, /* NULL when only obtaining attributes */
9498 int opt_type,
9499 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009500{
9501 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009502 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009503 struct vimoption *p;
9504 int r = 0;
9505
9506 opt_idx = findoption(name);
9507 if (opt_idx < 0)
9508 return 0;
9509
9510 p = &(options[opt_idx]);
9511
9512 /* Hidden option */
9513 if (p->var == NULL)
9514 return 0;
9515
9516 if (p->flags & P_BOOL)
9517 r |= SOPT_BOOL;
9518 else if (p->flags & P_NUM)
9519 r |= SOPT_NUM;
9520 else if (p->flags & P_STRING)
9521 r |= SOPT_STRING;
9522
9523 if (p->indir == PV_NONE)
9524 {
9525 if (opt_type == SREQ_GLOBAL)
9526 r |= SOPT_GLOBAL;
9527 else
9528 return 0; /* Did not request global-only option */
9529 }
9530 else
9531 {
9532 if (p->indir & PV_BOTH)
9533 r |= SOPT_GLOBAL;
9534 else if (opt_type == SREQ_GLOBAL)
9535 return 0; /* Requested global option */
9536
9537 if (p->indir & PV_WIN)
9538 {
9539 if (opt_type == SREQ_BUF)
9540 return 0; /* Did not request window-local option */
9541 else
9542 r |= SOPT_WIN;
9543 }
9544 else if (p->indir & PV_BUF)
9545 {
9546 if (opt_type == SREQ_WIN)
9547 return 0; /* Did not request buffer-local option */
9548 else
9549 r |= SOPT_BUF;
9550 }
9551 }
9552
9553 if (stringval == NULL)
9554 return r;
9555
9556 if (opt_type == SREQ_GLOBAL)
9557 varp = p->var;
9558 else
9559 {
9560 if (opt_type == SREQ_BUF)
9561 {
9562 /* Special case: 'modified' is b_changed, but we also want to
9563 * consider it set when 'ff' or 'fenc' changed. */
9564 if (p->indir == PV_MOD)
9565 {
9566 *numval = bufIsChanged((buf_T *) from);
9567 varp = NULL;
9568 }
9569#ifdef FEAT_CRYPT
9570 else if (p->indir == PV_KEY)
9571 {
9572 /* never return the value of the crypt key */
9573 *stringval = NULL;
9574 varp = NULL;
9575 }
9576#endif
9577 else
9578 {
9579 aco_save_T aco;
9580 aucmd_prepbuf(&aco, (buf_T *) from);
9581 varp = get_varp(p);
9582 aucmd_restbuf(&aco);
9583 }
9584 }
9585 else if (opt_type == SREQ_WIN)
9586 {
9587 win_T *save_curwin;
9588 save_curwin = curwin;
9589 curwin = (win_T *) from;
9590 curbuf = curwin->w_buffer;
9591 varp = get_varp(p);
9592 curwin = save_curwin;
9593 curbuf = curwin->w_buffer;
9594 }
9595 if (varp == p->var)
9596 return (r | SOPT_UNSET);
9597 }
9598
9599 if (varp != NULL)
9600 {
9601 if (p->flags & P_STRING)
9602 *stringval = vim_strsave(*(char_u **)(varp));
9603 else if (p->flags & P_NUM)
9604 *numval = *(long *) varp;
9605 else
9606 *numval = *(int *)varp;
9607 }
9608
9609 return r;
9610}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009611
9612/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009613 * Iterate over options. First argument is a pointer to a pointer to a
9614 * structure inside options[] array, second is option type like in the above
9615 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009616 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009617 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009618 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009619 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009620 * first argument to NULL.
9621 *
9622 * Returns full option name for current option on each call.
9623 */
9624 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009625option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009626{
9627 struct vimoption *ret = NULL;
9628 do
9629 {
9630 if (*option == NULL)
9631 *option = (void *) options;
9632 else if (((struct vimoption *) (*option))->fullname == NULL)
9633 {
9634 *option = NULL;
9635 return NULL;
9636 }
9637 else
9638 *option = (void *) (((struct vimoption *) (*option)) + 1);
9639
9640 ret = ((struct vimoption *) (*option));
9641
9642 /* Hidden option */
9643 if (ret->var == NULL)
9644 {
9645 ret = NULL;
9646 continue;
9647 }
9648
9649 switch (opt_type)
9650 {
9651 case SREQ_GLOBAL:
9652 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9653 ret = NULL;
9654 break;
9655 case SREQ_BUF:
9656 if (!(ret->indir & PV_BUF))
9657 ret = NULL;
9658 break;
9659 case SREQ_WIN:
9660 if (!(ret->indir & PV_WIN))
9661 ret = NULL;
9662 break;
9663 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009664 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009665 return NULL;
9666 }
9667 }
9668 while (ret == NULL);
9669
9670 return (char_u *)ret->fullname;
9671}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009672#endif
9673
Bram Moolenaar071d4272004-06-13 20:20:40 +00009674/*
9675 * Set the value of option "name".
9676 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009677 *
9678 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009679 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009680 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009681set_option_value(
9682 char_u *name,
9683 long number,
9684 char_u *string,
9685 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009686{
9687 int opt_idx;
9688 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009689 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009690
9691 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009692 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009693 {
9694 int key;
9695
9696 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9697 && (key = find_key_option(name)) != 0)
9698 {
9699 char_u key_name[2];
9700
9701 if (key < 0)
9702 {
9703 key_name[0] = KEY2TERMCAP0(key);
9704 key_name[1] = KEY2TERMCAP1(key);
9705 }
9706 else
9707 {
9708 key_name[0] = KS_KEY;
9709 key_name[1] = (key & 0xff);
9710 }
9711 add_termcode(key_name, string, FALSE);
9712 if (full_screen)
9713 ttest(FALSE);
9714 redraw_all_later(CLEAR);
9715 return NULL;
9716 }
9717
Bram Moolenaar071d4272004-06-13 20:20:40 +00009718 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009719 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009720 else
9721 {
9722 flags = options[opt_idx].flags;
9723#ifdef HAVE_SANDBOX
9724 /* Disallow changing some options in the sandbox */
9725 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009726 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009727 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009728 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009729 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009730#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009731 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009732 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009733 else
9734 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009735 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009736 if (varp != NULL) /* hidden option is not changed */
9737 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009738 if (number == 0 && string != NULL)
9739 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009740 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009741
9742 /* Either we are given a string or we are setting option
9743 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009744 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009745 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009746 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009747 {
9748 /* There's another character after zeros or the string
9749 * is empty. In both cases, we are trying to set a
9750 * num option using a string. */
9751 EMSG3(_("E521: Number required: &%s = '%s'"),
9752 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009753 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009754
9755 }
9756 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009757 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009758 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009759 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009760 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009761 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009762 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009763 }
9764 }
9765 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009766 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009767}
9768
9769/*
9770 * Get the terminal code for a terminal option.
9771 * Returns NULL when not found.
9772 */
9773 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009774get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009775{
9776 int opt_idx;
9777 char_u *varp;
9778
9779 if (tname[0] != 't' || tname[1] != '_' ||
9780 tname[2] == NUL || tname[3] == NUL)
9781 return NULL;
9782 if ((opt_idx = findoption(tname)) >= 0)
9783 {
9784 varp = get_varp(&(options[opt_idx]));
9785 if (varp != NULL)
9786 varp = *(char_u **)(varp);
9787 return varp;
9788 }
9789 return find_termcode(tname + 2);
9790}
9791
9792 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009793get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009794{
9795 int i;
9796
9797 i = findoption((char_u *)"hl");
9798 if (i >= 0)
9799 return options[i].def_val[VI_DEFAULT];
9800 return (char_u *)NULL;
9801}
9802
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009803#if defined(FEAT_MBYTE) || defined(PROTO)
9804 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009805get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009806{
9807 int i;
9808
9809 i = findoption((char_u *)"enc");
9810 if (i >= 0)
9811 return options[i].def_val[VI_DEFAULT];
9812 return (char_u *)NULL;
9813}
9814#endif
9815
Bram Moolenaar071d4272004-06-13 20:20:40 +00009816/*
9817 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9818 */
9819 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009820find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009821{
9822 int key;
9823 int modifiers;
9824
9825 /*
9826 * Don't use get_special_key_code() for t_xx, we don't want it to call
9827 * add_termcap_entry().
9828 */
9829 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9830 key = TERMCAP2KEY(arg[2], arg[3]);
9831 else
9832 {
9833 --arg; /* put arg at the '<' */
9834 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009835 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009836 if (modifiers) /* can't handle modifiers here */
9837 key = 0;
9838 }
9839 return key;
9840}
9841
9842/*
9843 * if 'all' == 0: show changed options
9844 * if 'all' == 1: show all normal options
9845 * if 'all' == 2: show all terminal options
9846 */
9847 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009848showoptions(
9849 int all,
9850 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009851{
9852 struct vimoption *p;
9853 int col;
9854 int isterm;
9855 char_u *varp;
9856 struct vimoption **items;
9857 int item_count;
9858 int run;
9859 int row, rows;
9860 int cols;
9861 int i;
9862 int len;
9863
9864#define INC 20
9865#define GAP 3
9866
9867 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9868 PARAM_COUNT));
9869 if (items == NULL)
9870 return;
9871
9872 /* Highlight title */
9873 if (all == 2)
9874 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9875 else if (opt_flags & OPT_GLOBAL)
9876 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9877 else if (opt_flags & OPT_LOCAL)
9878 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9879 else
9880 MSG_PUTS_TITLE(_("\n--- Options ---"));
9881
9882 /*
9883 * do the loop two times:
9884 * 1. display the short items
9885 * 2. display the long items (only strings and numbers)
9886 */
9887 for (run = 1; run <= 2 && !got_int; ++run)
9888 {
9889 /*
9890 * collect the items in items[]
9891 */
9892 item_count = 0;
9893 for (p = &options[0]; p->fullname != NULL; p++)
9894 {
9895 varp = NULL;
9896 isterm = istermoption(p);
9897 if (opt_flags != 0)
9898 {
9899 if (p->indir != PV_NONE && !isterm)
9900 varp = get_varp_scope(p, opt_flags);
9901 }
9902 else
9903 varp = get_varp(p);
9904 if (varp != NULL
9905 && ((all == 2 && isterm)
9906 || (all == 1 && !isterm)
9907 || (all == 0 && !optval_default(p, varp))))
9908 {
9909 if (p->flags & P_BOOL)
9910 len = 1; /* a toggle option fits always */
9911 else
9912 {
9913 option_value2string(p, opt_flags);
9914 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9915 }
9916 if ((len <= INC - GAP && run == 1) ||
9917 (len > INC - GAP && run == 2))
9918 items[item_count++] = p;
9919 }
9920 }
9921
9922 /*
9923 * display the items
9924 */
9925 if (run == 1)
9926 {
9927 cols = (Columns + GAP - 3) / INC;
9928 if (cols == 0)
9929 cols = 1;
9930 rows = (item_count + cols - 1) / cols;
9931 }
9932 else /* run == 2 */
9933 rows = item_count;
9934 for (row = 0; row < rows && !got_int; ++row)
9935 {
9936 msg_putchar('\n'); /* go to next line */
9937 if (got_int) /* 'q' typed in more */
9938 break;
9939 col = 0;
9940 for (i = row; i < item_count; i += rows)
9941 {
9942 msg_col = col; /* make columns */
9943 showoneopt(items[i], opt_flags);
9944 col += INC;
9945 }
9946 out_flush();
9947 ui_breakcheck();
9948 }
9949 }
9950 vim_free(items);
9951}
9952
9953/*
9954 * Return TRUE if option "p" has its default value.
9955 */
9956 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009957optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009958{
9959 int dvi;
9960
9961 if (varp == NULL)
9962 return TRUE; /* hidden option is always at default */
9963 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9964 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009965 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009966 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009967 /* the cast to long is required for Manx C, long_i is
9968 * needed for MSVC */
9969 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009970 /* P_STRING */
9971 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9972}
9973
9974/*
9975 * showoneopt: show the value of one option
9976 * must not be called with a hidden option!
9977 */
9978 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009979showoneopt(
9980 struct vimoption *p,
9981 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009982{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009983 char_u *varp;
9984 int save_silent = silent_mode;
9985
9986 silent_mode = FALSE;
9987 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009988
9989 varp = get_varp_scope(p, opt_flags);
9990
9991 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9992 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9993 ? !curbufIsChanged() : !*(int *)varp))
9994 MSG_PUTS("no");
9995 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9996 MSG_PUTS("--");
9997 else
9998 MSG_PUTS(" ");
9999 MSG_PUTS(p->fullname);
10000 if (!(p->flags & P_BOOL))
10001 {
10002 msg_putchar('=');
10003 /* put value string in NameBuff */
10004 option_value2string(p, opt_flags);
10005 msg_outtrans(NameBuff);
10006 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +000010007
10008 silent_mode = save_silent;
10009 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010010}
10011
10012/*
10013 * Write modified options as ":set" commands to a file.
10014 *
10015 * There are three values for "opt_flags":
10016 * OPT_GLOBAL: Write global option values and fresh values of
10017 * buffer-local options (used for start of a session
10018 * file).
10019 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
10020 * curwin (used for a vimrc file).
10021 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
10022 * and local values for window-local options of
10023 * curwin. Local values are also written when at the
10024 * default value, because a modeline or autocommand
10025 * may have set them when doing ":edit file" and the
10026 * user has set them back at the default or fresh
10027 * value.
10028 * When "local_only" is TRUE, don't write fresh
10029 * values, only local values (for ":mkview").
10030 * (fresh value = value used for a new buffer or window for a local option).
10031 *
10032 * Return FAIL on error, OK otherwise.
10033 */
10034 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010035makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010036{
10037 struct vimoption *p;
10038 char_u *varp; /* currently used value */
10039 char_u *varp_fresh; /* local value */
10040 char_u *varp_local = NULL; /* fresh value */
10041 char *cmd;
10042 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010043 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010044
10045 /*
10046 * The options that don't have a default (terminal name, columns, lines)
10047 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010048 * Do the loop over "options[]" twice: once for options with the
10049 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010050 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010051 for (pri = 1; pri >= 0; --pri)
10052 {
10053 for (p = &options[0]; !istermoption(p); p++)
10054 if (!(p->flags & P_NO_MKRC)
10055 && !istermoption(p)
10056 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010057 {
10058 /* skip global option when only doing locals */
10059 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10060 continue;
10061
10062 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10063 * file, they are always buffer-specific. */
10064 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10065 continue;
10066
10067 /* Global values are only written when not at the default value. */
10068 varp = get_varp_scope(p, opt_flags);
10069 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10070 continue;
10071
10072 round = 2;
10073 if (p->indir != PV_NONE)
10074 {
10075 if (p->var == VAR_WIN)
10076 {
10077 /* skip window-local option when only doing globals */
10078 if (!(opt_flags & OPT_LOCAL))
10079 continue;
10080 /* When fresh value of window-local option is not at the
10081 * default, need to write it too. */
10082 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10083 {
10084 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10085 if (!optval_default(p, varp_fresh))
10086 {
10087 round = 1;
10088 varp_local = varp;
10089 varp = varp_fresh;
10090 }
10091 }
10092 }
10093 }
10094
10095 /* Round 1: fresh value for window-local options.
10096 * Round 2: other values */
10097 for ( ; round <= 2; varp = varp_local, ++round)
10098 {
10099 if (round == 1 || (opt_flags & OPT_GLOBAL))
10100 cmd = "set";
10101 else
10102 cmd = "setlocal";
10103
10104 if (p->flags & P_BOOL)
10105 {
10106 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10107 return FAIL;
10108 }
10109 else if (p->flags & P_NUM)
10110 {
10111 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10112 return FAIL;
10113 }
10114 else /* P_STRING */
10115 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010116#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10117 int do_endif = FALSE;
10118
Bram Moolenaar071d4272004-06-13 20:20:40 +000010119 /* Don't set 'syntax' and 'filetype' again if the value is
10120 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010121 if (
10122# if defined(FEAT_SYN_HL)
10123 p->indir == PV_SYN
10124# if defined(FEAT_AUTOCMD)
10125 ||
10126# endif
10127# endif
10128# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010129 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010130# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010131 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010132 {
10133 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10134 *(char_u **)(varp)) < 0
10135 || put_eol(fd) < 0)
10136 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010137 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010138 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010139#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010140 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10141 (p->flags & P_EXPAND) != 0) == FAIL)
10142 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010143#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10144 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010145 {
10146 if (put_line(fd, "endif") == FAIL)
10147 return FAIL;
10148 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010149#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010150 }
10151 }
10152 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010153 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010154 return OK;
10155}
10156
10157#if defined(FEAT_FOLDING) || defined(PROTO)
10158/*
10159 * Generate set commands for the local fold options only. Used when
10160 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10161 */
10162 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010163makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010164{
10165 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10166# ifdef FEAT_EVAL
10167 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10168 == FAIL
10169# endif
10170 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10171 == FAIL
10172 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10173 == FAIL
10174 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10175 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10176 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10177 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10178 )
10179 return FAIL;
10180
10181 return OK;
10182}
10183#endif
10184
10185 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010186put_setstring(
10187 FILE *fd,
10188 char *cmd,
10189 char *name,
10190 char_u **valuep,
10191 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010192{
10193 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010194 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010195
10196 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10197 return FAIL;
10198 if (*valuep != NULL)
10199 {
10200 /* Output 'pastetoggle' as key names. For other
10201 * options some characters have to be escaped with
10202 * CTRL-V or backslash */
10203 if (valuep == &p_pt)
10204 {
10205 s = *valuep;
10206 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010207 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010208 return FAIL;
10209 }
10210 else if (expand)
10211 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010212 buf = alloc(MAXPATHL);
10213 if (buf == NULL)
10214 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010215 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10216 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010217 {
10218 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010219 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010220 }
10221 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010222 }
10223 else if (put_escstr(fd, *valuep, 2) == FAIL)
10224 return FAIL;
10225 }
10226 if (put_eol(fd) < 0)
10227 return FAIL;
10228 return OK;
10229}
10230
10231 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010232put_setnum(
10233 FILE *fd,
10234 char *cmd,
10235 char *name,
10236 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237{
10238 long wc;
10239
10240 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10241 return FAIL;
10242 if (wc_use_keyname((char_u *)valuep, &wc))
10243 {
10244 /* print 'wildchar' and 'wildcharm' as a key name */
10245 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10246 return FAIL;
10247 }
10248 else if (fprintf(fd, "%ld", *valuep) < 0)
10249 return FAIL;
10250 if (put_eol(fd) < 0)
10251 return FAIL;
10252 return OK;
10253}
10254
10255 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010256put_setbool(
10257 FILE *fd,
10258 char *cmd,
10259 char *name,
10260 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010261{
Bram Moolenaar893de922007-10-02 18:40:57 +000010262 if (value < 0) /* global/local option using global value */
10263 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010264 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10265 || put_eol(fd) < 0)
10266 return FAIL;
10267 return OK;
10268}
10269
10270/*
10271 * Clear all the terminal options.
10272 * If the option has been allocated, free the memory.
10273 * Terminal options are never hidden or indirect.
10274 */
10275 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010276clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010277{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010278 /*
10279 * Reset a few things before clearing the old options. This may cause
10280 * outputting a few things that the terminal doesn't understand, but the
10281 * screen will be cleared later, so this is OK.
10282 */
10283#ifdef FEAT_MOUSE_TTY
10284 mch_setmouse(FALSE); /* switch mouse off */
10285#endif
10286#ifdef FEAT_TITLE
10287 mch_restore_title(3); /* restore window titles */
10288#endif
10289#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10290 /* When starting the GUI close the display opened for the clipboard.
10291 * After restoring the title, because that will need the display. */
10292 if (gui.starting)
10293 clear_xterm_clip();
10294#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010295 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010296
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010297 free_termoptions();
10298}
10299
10300 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010301free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010302{
10303 struct vimoption *p;
10304
Bram Moolenaar071d4272004-06-13 20:20:40 +000010305 for (p = &options[0]; p->fullname != NULL; p++)
10306 if (istermoption(p))
10307 {
10308 if (p->flags & P_ALLOCED)
10309 free_string_option(*(char_u **)(p->var));
10310 if (p->flags & P_DEF_ALLOCED)
10311 free_string_option(p->def_val[VI_DEFAULT]);
10312 *(char_u **)(p->var) = empty_option;
10313 p->def_val[VI_DEFAULT] = empty_option;
10314 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10315 }
10316 clear_termcodes();
10317}
10318
10319/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010320 * Free the string for one term option, if it was allocated.
10321 * Set the string to empty_option and clear allocated flag.
10322 * "var" points to the option value.
10323 */
10324 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010325free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010326{
10327 struct vimoption *p;
10328
10329 for (p = &options[0]; p->fullname != NULL; p++)
10330 if (p->var == var)
10331 {
10332 if (p->flags & P_ALLOCED)
10333 free_string_option(*(char_u **)(p->var));
10334 *(char_u **)(p->var) = empty_option;
10335 p->flags &= ~P_ALLOCED;
10336 break;
10337 }
10338}
10339
10340/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010341 * Set the terminal option defaults to the current value.
10342 * Used after setting the terminal name.
10343 */
10344 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010345set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010346{
10347 struct vimoption *p;
10348
10349 for (p = &options[0]; p->fullname != NULL; p++)
10350 {
10351 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10352 {
10353 if (p->flags & P_DEF_ALLOCED)
10354 {
10355 free_string_option(p->def_val[VI_DEFAULT]);
10356 p->flags &= ~P_DEF_ALLOCED;
10357 }
10358 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10359 if (p->flags & P_ALLOCED)
10360 {
10361 p->flags |= P_DEF_ALLOCED;
10362 p->flags &= ~P_ALLOCED; /* don't free the value now */
10363 }
10364 }
10365 }
10366}
10367
10368/*
10369 * return TRUE if 'p' starts with 't_'
10370 */
10371 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010372istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010373{
10374 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10375}
10376
10377/*
10378 * Compute columns for ruler and shown command. 'sc_col' is also used to
10379 * decide what the maximum length of a message on the status line can be.
10380 * If there is a status line for the last window, 'sc_col' is independent
10381 * of 'ru_col'.
10382 */
10383
10384#define COL_RULER 17 /* columns needed by standard ruler */
10385
10386 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010387comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010388{
10389#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010390 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010391
10392 sc_col = 0;
10393 ru_col = 0;
10394 if (p_ru)
10395 {
10396#ifdef FEAT_STL_OPT
10397 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10398#else
10399 ru_col = COL_RULER + 1;
10400#endif
10401 /* no last status line, adjust sc_col */
10402 if (!last_has_status)
10403 sc_col = ru_col;
10404 }
10405 if (p_sc)
10406 {
10407 sc_col += SHOWCMD_COLS;
10408 if (!p_ru || last_has_status) /* no need for separating space */
10409 ++sc_col;
10410 }
10411 sc_col = Columns - sc_col;
10412 ru_col = Columns - ru_col;
10413 if (sc_col <= 0) /* screen too narrow, will become a mess */
10414 sc_col = 1;
10415 if (ru_col <= 0)
10416 ru_col = 1;
10417#else
10418 sc_col = Columns;
10419 ru_col = Columns;
10420#endif
10421}
10422
10423/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010424 * Unset local option value, similar to ":set opt<".
10425 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010426 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010427unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010428{
10429 struct vimoption *p;
10430 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010431 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010432
10433 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010434 if (opt_idx < 0)
10435 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010436 p = &(options[opt_idx]);
10437
10438 switch ((int)p->indir)
10439 {
10440 /* global option with local value: use local value if it's been set */
10441 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010442 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010443 break;
10444 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010445 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010446 break;
10447 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010448 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010449 break;
10450 case PV_AR:
10451 buf->b_p_ar = -1;
10452 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010453 case PV_BKC:
10454 clear_string_option(&buf->b_p_bkc);
10455 buf->b_bkc_flags = 0;
10456 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010457 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010458 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010459 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010460 case PV_TC:
10461 clear_string_option(&buf->b_p_tc);
10462 buf->b_tc_flags = 0;
10463 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010464#ifdef FEAT_FIND_ID
10465 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010466 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010467 break;
10468 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010469 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010470 break;
10471#endif
10472#ifdef FEAT_INS_EXPAND
10473 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010474 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010475 break;
10476 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010477 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010478 break;
10479#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010480 case PV_FP:
10481 clear_string_option(&buf->b_p_fp);
10482 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010483#ifdef FEAT_QUICKFIX
10484 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010485 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010486 break;
10487 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010488 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010489 break;
10490 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010491 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010492 break;
10493#endif
10494#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10495 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010496 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010497 break;
10498#endif
10499#if defined(FEAT_CRYPT)
10500 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010501 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010502 break;
10503#endif
10504#ifdef FEAT_STL_OPT
10505 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010506 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010507 break;
10508#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010509 case PV_UL:
10510 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10511 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010512#ifdef FEAT_LISP
10513 case PV_LW:
10514 clear_string_option(&buf->b_p_lw);
10515 break;
10516#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010517#ifdef FEAT_MBYTE
10518 case PV_MENC:
10519 clear_string_option(&buf->b_p_menc);
10520 break;
10521#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010522 }
10523}
10524
10525/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010526 * Get pointer to option variable, depending on local or global scope.
10527 */
10528 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010529get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010530{
10531 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10532 {
10533 if (p->var == VAR_WIN)
10534 return (char_u *)GLOBAL_WO(get_varp(p));
10535 return p->var;
10536 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010537 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010538 {
10539 switch ((int)p->indir)
10540 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010541 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010542#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010543 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10544 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10545 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010546#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010547 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10548 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10549 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010550 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010551 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010552 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010553#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010554 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10555 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010556#endif
10557#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010558 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10559 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010560#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010561#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10562 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10563#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010564#if defined(FEAT_CRYPT)
10565 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10566#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010567#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010568 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010569#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010570 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010571#ifdef FEAT_LISP
10572 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10573#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010574 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010575#ifdef FEAT_MBYTE
10576 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10577#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010578 }
10579 return NULL; /* "cannot happen" */
10580 }
10581 return get_varp(p);
10582}
10583
10584/*
10585 * Get pointer to option variable.
10586 */
10587 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010588get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010589{
10590 /* hidden option, always return NULL */
10591 if (p->var == NULL)
10592 return NULL;
10593
10594 switch ((int)p->indir)
10595 {
10596 case PV_NONE: return p->var;
10597
10598 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010599 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010600 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010601 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010602 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010603 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010604 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010605 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010606 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010607 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010608 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010609 case PV_TC: return *curbuf->b_p_tc != NUL
10610 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010611 case PV_BKC: return *curbuf->b_p_bkc != NUL
10612 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010613#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010614 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010615 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010616 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010617 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10618#endif
10619#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010620 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010621 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010622 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010623 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10624#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010625 case PV_FP: return *curbuf->b_p_fp != NUL
10626 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010627#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010628 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010629 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010630 case PV_GP: return *curbuf->b_p_gp != NUL
10631 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10632 case PV_MP: return *curbuf->b_p_mp != NUL
10633 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010634#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010635#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10636 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10637 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10638#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010639#if defined(FEAT_CRYPT)
10640 case PV_CM: return *curbuf->b_p_cm != NUL
10641 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10642#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010643#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010644 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010645 ? (char_u *)&(curwin->w_p_stl) : p->var;
10646#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010647 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10648 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010649#ifdef FEAT_LISP
10650 case PV_LW: return *curbuf->b_p_lw != NUL
10651 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10652#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010653#ifdef FEAT_MBYTE
10654 case PV_MENC: return *curbuf->b_p_menc != NUL
10655 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10656#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010657
10658#ifdef FEAT_ARABIC
10659 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10660#endif
10661 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010662#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010663 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10664#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010665#ifdef FEAT_SYN_HL
10666 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10667 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010668 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010669#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010670#ifdef FEAT_DIFF
10671 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10672#endif
10673#ifdef FEAT_FOLDING
10674 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10675 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10676 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10677 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10678 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10679 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10680 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10681# ifdef FEAT_EVAL
10682 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10683 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10684# endif
10685 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10686#endif
10687 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010688 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010689#ifdef FEAT_LINEBREAK
10690 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10691#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010692#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010693 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010694 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10695#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010696#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10697 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10698#endif
10699#ifdef FEAT_RIGHTLEFT
10700 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10701 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10702#endif
10703 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10704 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10705#ifdef FEAT_LINEBREAK
10706 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010707 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10708 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010709#endif
10710#ifdef FEAT_SCROLLBIND
10711 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10712#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010713#ifdef FEAT_CURSORBIND
10714 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10715#endif
10716#ifdef FEAT_CONCEAL
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010717 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10718 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
10719#endif
10720#ifdef FEAT_TERMINAL
Bram Moolenaar1b0675c2017-07-15 14:04:01 +020010721 case PV_TK: return (char_u *)&(curwin->w_p_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010722 case PV_TMS: return (char_u *)&(curwin->w_p_tms);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010723#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010724
10725 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10726 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10727#ifdef FEAT_MBYTE
10728 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10729#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010730 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10731 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010732 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10733 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10734#ifdef FEAT_CINDENT
10735 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10736 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10737 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10738#endif
10739#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10740 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10741#endif
10742#ifdef FEAT_COMMENTS
10743 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10744#endif
10745#ifdef FEAT_FOLDING
10746 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10747#endif
10748#ifdef FEAT_INS_EXPAND
10749 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10750#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010751#ifdef FEAT_COMPL_FUNC
10752 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010753 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010754#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010755 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010756 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010757 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10758#ifdef FEAT_MBYTE
10759 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10760#endif
10761 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10762#ifdef FEAT_AUTOCMD
10763 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10764#endif
10765 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010766 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010767 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10768 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10769 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10770 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10771#ifdef FEAT_FIND_ID
10772# ifdef FEAT_EVAL
10773 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10774# endif
10775#endif
10776#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10777 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10778 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10779#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010780#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010781 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10782#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010783#ifdef FEAT_CRYPT
10784 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10785#endif
10786#ifdef FEAT_LISP
10787 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10788#endif
10789 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10790 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10791 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10792 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10793 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010794 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010795#ifdef FEAT_TEXTOBJ
10796 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10797#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010798 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10799#ifdef FEAT_SMARTINDENT
10800 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10801#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010802 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010803 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10804#ifdef FEAT_SEARCHPATH
10805 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10806#endif
10807 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10808#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010809 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010810 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10811#endif
10812#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010813 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10814 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10815 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010816#endif
10817 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10818 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10819 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10820 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010821#ifdef FEAT_PERSISTENT_UNDO
10822 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10823#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10825#ifdef FEAT_KEYMAP
10826 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10827#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010828#ifdef FEAT_SIGNS
10829 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10830#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010831 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010832 }
10833 /* always return a valid pointer to avoid a crash! */
10834 return (char_u *)&(curbuf->b_p_wm);
10835}
10836
10837/*
10838 * Get the value of 'equalprg', either the buffer-local one or the global one.
10839 */
10840 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010841get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010842{
10843 if (*curbuf->b_p_ep == NUL)
10844 return p_ep;
10845 return curbuf->b_p_ep;
10846}
10847
10848#if defined(FEAT_WINDOWS) || defined(PROTO)
10849/*
10850 * Copy options from one window to another.
10851 * Used when splitting a window.
10852 */
10853 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010854win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010855{
10856 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10857 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10858# ifdef FEAT_RIGHTLEFT
10859# ifdef FEAT_FKMAP
10860 /* Is this right? */
10861 wp_to->w_farsi = wp_from->w_farsi;
10862# endif
10863# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010864#if defined(FEAT_LINEBREAK)
10865 briopt_check(wp_to);
10866#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010867}
10868#endif
10869
10870/*
10871 * Copy the options from one winopt_T to another.
10872 * Doesn't free the old option values in "to", use clear_winopt() for that.
10873 * The 'scroll' option is not copied, because it depends on the window height.
10874 * The 'previewwindow' option is reset, there can be only one preview window.
10875 */
10876 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010877copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010878{
10879#ifdef FEAT_ARABIC
10880 to->wo_arab = from->wo_arab;
10881#endif
10882 to->wo_list = from->wo_list;
10883 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010884 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010885#ifdef FEAT_LINEBREAK
10886 to->wo_nuw = from->wo_nuw;
10887#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010888#ifdef FEAT_RIGHTLEFT
10889 to->wo_rl = from->wo_rl;
10890 to->wo_rlc = vim_strsave(from->wo_rlc);
10891#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010892#ifdef FEAT_STL_OPT
10893 to->wo_stl = vim_strsave(from->wo_stl);
10894#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010895 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010896#ifdef FEAT_DIFF
10897 to->wo_wrap_save = from->wo_wrap_save;
10898#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010899#ifdef FEAT_LINEBREAK
10900 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010901 to->wo_bri = from->wo_bri;
10902 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010903#endif
10904#ifdef FEAT_SCROLLBIND
10905 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010906 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010907#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010908#ifdef FEAT_CURSORBIND
10909 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010910 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010911#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010912#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010913 to->wo_spell = from->wo_spell;
10914#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010915#ifdef FEAT_SYN_HL
10916 to->wo_cuc = from->wo_cuc;
10917 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010918 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010919#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010920#ifdef FEAT_DIFF
10921 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010922 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010923#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010924#ifdef FEAT_CONCEAL
10925 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010926 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010927#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010928#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010929 to->wo_tk = vim_strsave(from->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010930 to->wo_tms = vim_strsave(from->wo_tms);
10931#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010932#ifdef FEAT_FOLDING
10933 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010934 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010935 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010936 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010937 to->wo_fdi = vim_strsave(from->wo_fdi);
10938 to->wo_fml = from->wo_fml;
10939 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010940 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010941 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010942 to->wo_fdm_save = from->wo_diff_saved
10943 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010944 to->wo_fdn = from->wo_fdn;
10945# ifdef FEAT_EVAL
10946 to->wo_fde = vim_strsave(from->wo_fde);
10947 to->wo_fdt = vim_strsave(from->wo_fdt);
10948# endif
10949 to->wo_fmr = vim_strsave(from->wo_fmr);
10950#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010951#ifdef FEAT_SIGNS
10952 to->wo_scl = vim_strsave(from->wo_scl);
10953#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010954 check_winopt(to); /* don't want NULL pointers */
10955}
10956
10957/*
10958 * Check string options in a window for a NULL value.
10959 */
10960 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010961check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010962{
10963 check_winopt(&win->w_onebuf_opt);
10964 check_winopt(&win->w_allbuf_opt);
10965}
10966
10967/*
10968 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10969 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010970 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010971check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010972{
10973#ifdef FEAT_FOLDING
10974 check_string_option(&wop->wo_fdi);
10975 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010976 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010977# ifdef FEAT_EVAL
10978 check_string_option(&wop->wo_fde);
10979 check_string_option(&wop->wo_fdt);
10980# endif
10981 check_string_option(&wop->wo_fmr);
10982#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010983#ifdef FEAT_SIGNS
10984 check_string_option(&wop->wo_scl);
10985#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010986#ifdef FEAT_RIGHTLEFT
10987 check_string_option(&wop->wo_rlc);
10988#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010989#ifdef FEAT_STL_OPT
10990 check_string_option(&wop->wo_stl);
10991#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010992#ifdef FEAT_SYN_HL
10993 check_string_option(&wop->wo_cc);
10994#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010995#ifdef FEAT_CONCEAL
10996 check_string_option(&wop->wo_cocu);
10997#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020010998#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020010999 check_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011000 check_string_option(&wop->wo_tms);
11001#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011002#ifdef FEAT_LINEBREAK
11003 check_string_option(&wop->wo_briopt);
11004#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011005}
11006
11007/*
11008 * Free the allocated memory inside a winopt_T.
11009 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011010 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011011clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011012{
11013#ifdef FEAT_FOLDING
11014 clear_string_option(&wop->wo_fdi);
11015 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020011016 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011017# ifdef FEAT_EVAL
11018 clear_string_option(&wop->wo_fde);
11019 clear_string_option(&wop->wo_fdt);
11020# endif
11021 clear_string_option(&wop->wo_fmr);
11022#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020011023#ifdef FEAT_SIGNS
11024 clear_string_option(&wop->wo_scl);
11025#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020011026#ifdef FEAT_LINEBREAK
11027 clear_string_option(&wop->wo_briopt);
11028#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011029#ifdef FEAT_RIGHTLEFT
11030 clear_string_option(&wop->wo_rlc);
11031#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000011032#ifdef FEAT_STL_OPT
11033 clear_string_option(&wop->wo_stl);
11034#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020011035#ifdef FEAT_SYN_HL
11036 clear_string_option(&wop->wo_cc);
11037#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020011038#ifdef FEAT_CONCEAL
11039 clear_string_option(&wop->wo_cocu);
11040#endif
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011041#ifdef FEAT_TERMINAL
Bram Moolenaar0daf8432017-07-15 15:16:40 +020011042 clear_string_option(&wop->wo_tk);
Bram Moolenaare4f25e42017-07-07 11:54:15 +020011043 clear_string_option(&wop->wo_tms);
11044#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011045}
11046
11047/*
11048 * Copy global option values to local options for one buffer.
11049 * Used when creating a new buffer and sometimes when entering a buffer.
11050 * flags:
11051 * BCO_ENTER We will enter the buf buffer.
11052 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
11053 * appropriate.
11054 * BCO_NOHELP Don't copy the values to a help buffer.
11055 */
11056 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011057buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011058{
11059 int should_copy = TRUE;
11060 char_u *save_p_isk = NULL; /* init for GCC */
11061 int dont_do_help;
11062 int did_isk = FALSE;
11063
11064 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011065 * Skip this when the option defaults have not been set yet. Happens when
11066 * main() allocates the first buffer.
11067 */
11068 if (p_cpo != NULL)
11069 {
11070 /*
11071 * Always copy when entering and 'cpo' contains 'S'.
11072 * Don't copy when already initialized.
11073 * Don't copy when 'cpo' contains 's' and not entering.
11074 * 'S' BCO_ENTER initialized 's' should_copy
11075 * yes yes X X TRUE
11076 * yes no yes X FALSE
11077 * no X yes X FALSE
11078 * X no no yes FALSE
11079 * X no no no TRUE
11080 * no yes no X TRUE
11081 */
11082 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11083 && (buf->b_p_initialized
11084 || (!(flags & BCO_ENTER)
11085 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11086 should_copy = FALSE;
11087
11088 if (should_copy || (flags & BCO_ALWAYS))
11089 {
11090 /* Don't copy the options specific to a help buffer when
11091 * BCO_NOHELP is given or the options were initialized already
11092 * (jumping back to a help file with CTRL-T or CTRL-O) */
11093 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11094 || buf->b_p_initialized;
11095 if (dont_do_help) /* don't free b_p_isk */
11096 {
11097 save_p_isk = buf->b_p_isk;
11098 buf->b_p_isk = NULL;
11099 }
11100 /*
11101 * Always free the allocated strings.
11102 * If not already initialized, set 'readonly' and copy 'fileformat'.
11103 */
11104 if (!buf->b_p_initialized)
11105 {
11106 free_buf_options(buf, TRUE);
11107 buf->b_p_ro = FALSE; /* don't copy readonly */
11108 buf->b_p_tx = p_tx;
11109#ifdef FEAT_MBYTE
11110 buf->b_p_fenc = vim_strsave(p_fenc);
11111#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011112 switch (*p_ffs)
11113 {
11114 case 'm':
11115 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11116 case 'd':
11117 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11118 case 'u':
11119 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11120 default:
11121 buf->b_p_ff = vim_strsave(p_ff);
11122 }
11123 if (buf->b_p_ff != NULL)
11124 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011125 buf->b_p_bh = empty_option;
11126 buf->b_p_bt = empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011127 }
11128 else
11129 free_buf_options(buf, FALSE);
11130
11131 buf->b_p_ai = p_ai;
11132 buf->b_p_ai_nopaste = p_ai_nopaste;
11133 buf->b_p_sw = p_sw;
11134 buf->b_p_tw = p_tw;
11135 buf->b_p_tw_nopaste = p_tw_nopaste;
11136 buf->b_p_tw_nobin = p_tw_nobin;
11137 buf->b_p_wm = p_wm;
11138 buf->b_p_wm_nopaste = p_wm_nopaste;
11139 buf->b_p_wm_nobin = p_wm_nobin;
11140 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011141#ifdef FEAT_MBYTE
11142 buf->b_p_bomb = p_bomb;
11143#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011144 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011145 buf->b_p_et = p_et;
11146 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011147 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011148 buf->b_p_ml = p_ml;
11149 buf->b_p_ml_nobin = p_ml_nobin;
11150 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011151 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011152#ifdef FEAT_INS_EXPAND
11153 buf->b_p_cpt = vim_strsave(p_cpt);
11154#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011155#ifdef FEAT_COMPL_FUNC
11156 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011157 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011158#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011159 buf->b_p_sts = p_sts;
11160 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011161 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011162#ifdef FEAT_COMMENTS
11163 buf->b_p_com = vim_strsave(p_com);
11164#endif
11165#ifdef FEAT_FOLDING
11166 buf->b_p_cms = vim_strsave(p_cms);
11167#endif
11168 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011169 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011170 buf->b_p_nf = vim_strsave(p_nf);
11171 buf->b_p_mps = vim_strsave(p_mps);
11172#ifdef FEAT_SMARTINDENT
11173 buf->b_p_si = p_si;
11174#endif
11175 buf->b_p_ci = p_ci;
11176#ifdef FEAT_CINDENT
11177 buf->b_p_cin = p_cin;
11178 buf->b_p_cink = vim_strsave(p_cink);
11179 buf->b_p_cino = vim_strsave(p_cino);
11180#endif
11181#ifdef FEAT_AUTOCMD
11182 /* Don't copy 'filetype', it must be detected */
11183 buf->b_p_ft = empty_option;
11184#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011185 buf->b_p_pi = p_pi;
11186#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11187 buf->b_p_cinw = vim_strsave(p_cinw);
11188#endif
11189#ifdef FEAT_LISP
11190 buf->b_p_lisp = p_lisp;
11191#endif
11192#ifdef FEAT_SYN_HL
11193 /* Don't copy 'syntax', it must be set */
11194 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011195 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011196 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011197#endif
11198#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011199 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011200 (void)compile_cap_prog(&buf->b_s);
11201 buf->b_s.b_p_spf = vim_strsave(p_spf);
11202 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011203#endif
11204#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11205 buf->b_p_inde = vim_strsave(p_inde);
11206 buf->b_p_indk = vim_strsave(p_indk);
11207#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011208 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011209#if defined(FEAT_EVAL)
11210 buf->b_p_fex = vim_strsave(p_fex);
11211#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011212#ifdef FEAT_CRYPT
11213 buf->b_p_key = vim_strsave(p_key);
11214#endif
11215#ifdef FEAT_SEARCHPATH
11216 buf->b_p_sua = vim_strsave(p_sua);
11217#endif
11218#ifdef FEAT_KEYMAP
11219 buf->b_p_keymap = vim_strsave(p_keymap);
11220 buf->b_kmap_state |= KEYMAP_INIT;
11221#endif
11222 /* This isn't really an option, but copying the langmap and IME
11223 * state from the current buffer is better than resetting it. */
11224 buf->b_p_iminsert = p_iminsert;
11225 buf->b_p_imsearch = p_imsearch;
11226
11227 /* options that are normally global but also have a local value
11228 * are not copied, start using the global value */
11229 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011230 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011231 buf->b_p_bkc = empty_option;
11232 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011233#ifdef FEAT_QUICKFIX
11234 buf->b_p_gp = empty_option;
11235 buf->b_p_mp = empty_option;
11236 buf->b_p_efm = empty_option;
11237#endif
11238 buf->b_p_ep = empty_option;
11239 buf->b_p_kp = empty_option;
11240 buf->b_p_path = empty_option;
11241 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011242 buf->b_p_tc = empty_option;
11243 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011244#ifdef FEAT_FIND_ID
11245 buf->b_p_def = empty_option;
11246 buf->b_p_inc = empty_option;
11247# ifdef FEAT_EVAL
11248 buf->b_p_inex = vim_strsave(p_inex);
11249# endif
11250#endif
11251#ifdef FEAT_INS_EXPAND
11252 buf->b_p_dict = empty_option;
11253 buf->b_p_tsr = empty_option;
11254#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011255#ifdef FEAT_TEXTOBJ
11256 buf->b_p_qe = vim_strsave(p_qe);
11257#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011258#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11259 buf->b_p_bexpr = empty_option;
11260#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011261#if defined(FEAT_CRYPT)
11262 buf->b_p_cm = empty_option;
11263#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011264#ifdef FEAT_PERSISTENT_UNDO
11265 buf->b_p_udf = p_udf;
11266#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011267#ifdef FEAT_LISP
11268 buf->b_p_lw = empty_option;
11269#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011270#ifdef FEAT_MBYTE
11271 buf->b_p_menc = empty_option;
11272#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011273
11274 /*
11275 * Don't copy the options set by ex_help(), use the saved values,
11276 * when going from a help buffer to a non-help buffer.
11277 * Don't touch these at all when BCO_NOHELP is used and going from
11278 * or to a help buffer.
11279 */
11280 if (dont_do_help)
11281 buf->b_p_isk = save_p_isk;
11282 else
11283 {
11284 buf->b_p_isk = vim_strsave(p_isk);
11285 did_isk = TRUE;
11286 buf->b_p_ts = p_ts;
11287 buf->b_help = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011288 if (buf->b_p_bt[0] == 'h')
11289 clear_string_option(&buf->b_p_bt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011290 buf->b_p_ma = p_ma;
11291 }
11292 }
11293
11294 /*
11295 * When the options should be copied (ignoring BCO_ALWAYS), set the
11296 * flag that indicates that the options have been initialized.
11297 */
11298 if (should_copy)
11299 buf->b_p_initialized = TRUE;
11300 }
11301
11302 check_buf_options(buf); /* make sure we don't have NULLs */
11303 if (did_isk)
11304 (void)buf_init_chartab(buf, FALSE);
11305}
11306
11307/*
11308 * Reset the 'modifiable' option and its default value.
11309 */
11310 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011311reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011312{
11313 int opt_idx;
11314
11315 curbuf->b_p_ma = FALSE;
11316 p_ma = FALSE;
11317 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011318 if (opt_idx >= 0)
11319 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011320}
11321
11322/*
11323 * Set the global value for 'iminsert' to the local value.
11324 */
11325 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011326set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011327{
11328 p_iminsert = curbuf->b_p_iminsert;
11329}
11330
11331/*
11332 * Set the global value for 'imsearch' to the local value.
11333 */
11334 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011335set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011336{
11337 p_imsearch = curbuf->b_p_imsearch;
11338}
11339
11340#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11341static int expand_option_idx = -1;
11342static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11343static int expand_option_flags = 0;
11344
11345 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011346set_context_in_set_cmd(
11347 expand_T *xp,
11348 char_u *arg,
11349 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011350{
11351 int nextchar;
11352 long_u flags = 0; /* init for GCC */
11353 int opt_idx = 0; /* init for GCC */
11354 char_u *p;
11355 char_u *s;
11356 int is_term_option = FALSE;
11357 int key;
11358
11359 expand_option_flags = opt_flags;
11360
11361 xp->xp_context = EXPAND_SETTINGS;
11362 if (*arg == NUL)
11363 {
11364 xp->xp_pattern = arg;
11365 return;
11366 }
11367 p = arg + STRLEN(arg) - 1;
11368 if (*p == ' ' && *(p - 1) != '\\')
11369 {
11370 xp->xp_pattern = p + 1;
11371 return;
11372 }
11373 while (p > arg)
11374 {
11375 s = p;
11376 /* count number of backslashes before ' ' or ',' */
11377 if (*p == ' ' || *p == ',')
11378 {
11379 while (s > arg && *(s - 1) == '\\')
11380 --s;
11381 }
11382 /* break at a space with an even number of backslashes */
11383 if (*p == ' ' && ((p - s) & 1) == 0)
11384 {
11385 ++p;
11386 break;
11387 }
11388 --p;
11389 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011390 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011391 {
11392 xp->xp_context = EXPAND_BOOL_SETTINGS;
11393 p += 2;
11394 }
11395 if (STRNCMP(p, "inv", 3) == 0)
11396 {
11397 xp->xp_context = EXPAND_BOOL_SETTINGS;
11398 p += 3;
11399 }
11400 xp->xp_pattern = arg = p;
11401 if (*arg == '<')
11402 {
11403 while (*p != '>')
11404 if (*p++ == NUL) /* expand terminal option name */
11405 return;
11406 key = get_special_key_code(arg + 1);
11407 if (key == 0) /* unknown name */
11408 {
11409 xp->xp_context = EXPAND_NOTHING;
11410 return;
11411 }
11412 nextchar = *++p;
11413 is_term_option = TRUE;
11414 expand_option_name[2] = KEY2TERMCAP0(key);
11415 expand_option_name[3] = KEY2TERMCAP1(key);
11416 }
11417 else
11418 {
11419 if (p[0] == 't' && p[1] == '_')
11420 {
11421 p += 2;
11422 if (*p != NUL)
11423 ++p;
11424 if (*p == NUL)
11425 return; /* expand option name */
11426 nextchar = *++p;
11427 is_term_option = TRUE;
11428 expand_option_name[2] = p[-2];
11429 expand_option_name[3] = p[-1];
11430 }
11431 else
11432 {
11433 /* Allow * wildcard */
11434 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11435 p++;
11436 if (*p == NUL)
11437 return;
11438 nextchar = *p;
11439 *p = NUL;
11440 opt_idx = findoption(arg);
11441 *p = nextchar;
11442 if (opt_idx == -1 || options[opt_idx].var == NULL)
11443 {
11444 xp->xp_context = EXPAND_NOTHING;
11445 return;
11446 }
11447 flags = options[opt_idx].flags;
11448 if (flags & P_BOOL)
11449 {
11450 xp->xp_context = EXPAND_NOTHING;
11451 return;
11452 }
11453 }
11454 }
11455 /* handle "-=" and "+=" */
11456 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11457 {
11458 ++p;
11459 nextchar = '=';
11460 }
11461 if ((nextchar != '=' && nextchar != ':')
11462 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11463 {
11464 xp->xp_context = EXPAND_UNSUCCESSFUL;
11465 return;
11466 }
11467 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11468 {
11469 xp->xp_context = EXPAND_OLD_SETTING;
11470 if (is_term_option)
11471 expand_option_idx = -1;
11472 else
11473 expand_option_idx = opt_idx;
11474 xp->xp_pattern = p + 1;
11475 return;
11476 }
11477 xp->xp_context = EXPAND_NOTHING;
11478 if (is_term_option || (flags & P_NUM))
11479 return;
11480
11481 xp->xp_pattern = p + 1;
11482
11483 if (flags & P_EXPAND)
11484 {
11485 p = options[opt_idx].var;
11486 if (p == (char_u *)&p_bdir
11487 || p == (char_u *)&p_dir
11488 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011489 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011490 || p == (char_u *)&p_rtp
11491#ifdef FEAT_SEARCHPATH
11492 || p == (char_u *)&p_cdpath
11493#endif
11494#ifdef FEAT_SESSION
11495 || p == (char_u *)&p_vdir
11496#endif
11497 )
11498 {
11499 xp->xp_context = EXPAND_DIRECTORIES;
11500 if (p == (char_u *)&p_path
11501#ifdef FEAT_SEARCHPATH
11502 || p == (char_u *)&p_cdpath
11503#endif
11504 )
11505 xp->xp_backslash = XP_BS_THREE;
11506 else
11507 xp->xp_backslash = XP_BS_ONE;
11508 }
11509 else
11510 {
11511 xp->xp_context = EXPAND_FILES;
11512 /* for 'tags' need three backslashes for a space */
11513 if (p == (char_u *)&p_tags)
11514 xp->xp_backslash = XP_BS_THREE;
11515 else
11516 xp->xp_backslash = XP_BS_ONE;
11517 }
11518 }
11519
11520 /* For an option that is a list of file names, find the start of the
11521 * last file name. */
11522 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11523 {
11524 /* count number of backslashes before ' ' or ',' */
11525 if (*p == ' ' || *p == ',')
11526 {
11527 s = p;
11528 while (s > xp->xp_pattern && *(s - 1) == '\\')
11529 --s;
11530 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11531 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11532 {
11533 xp->xp_pattern = p + 1;
11534 break;
11535 }
11536 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011537
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011538#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011539 /* for 'spellsuggest' start at "file:" */
11540 if (options[opt_idx].var == (char_u *)&p_sps
11541 && STRNCMP(p, "file:", 5) == 0)
11542 {
11543 xp->xp_pattern = p + 5;
11544 break;
11545 }
11546#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011547 }
11548
11549 return;
11550}
11551
11552 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011553ExpandSettings(
11554 expand_T *xp,
11555 regmatch_T *regmatch,
11556 int *num_file,
11557 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011558{
11559 int num_normal = 0; /* Nr of matching non-term-code settings */
11560 int num_term = 0; /* Nr of matching terminal code settings */
11561 int opt_idx;
11562 int match;
11563 int count = 0;
11564 char_u *str;
11565 int loop;
11566 int is_term_opt;
11567 char_u name_buf[MAX_KEY_NAME_LEN];
11568 static char *(names[]) = {"all", "termcap"};
11569 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11570
11571 /* do this loop twice:
11572 * loop == 0: count the number of matching options
11573 * loop == 1: copy the matching options into allocated memory
11574 */
11575 for (loop = 0; loop <= 1; ++loop)
11576 {
11577 regmatch->rm_ic = ic;
11578 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11579 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011580 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11581 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011582 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11583 {
11584 if (loop == 0)
11585 num_normal++;
11586 else
11587 (*file)[count++] = vim_strsave((char_u *)names[match]);
11588 }
11589 }
11590 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11591 opt_idx++)
11592 {
11593 if (options[opt_idx].var == NULL)
11594 continue;
11595 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11596 && !(options[opt_idx].flags & P_BOOL))
11597 continue;
11598 is_term_opt = istermoption(&options[opt_idx]);
11599 if (is_term_opt && num_normal > 0)
11600 continue;
11601 match = FALSE;
11602 if (vim_regexec(regmatch, str, (colnr_T)0)
11603 || (options[opt_idx].shortname != NULL
11604 && vim_regexec(regmatch,
11605 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11606 match = TRUE;
11607 else if (is_term_opt)
11608 {
11609 name_buf[0] = '<';
11610 name_buf[1] = 't';
11611 name_buf[2] = '_';
11612 name_buf[3] = str[2];
11613 name_buf[4] = str[3];
11614 name_buf[5] = '>';
11615 name_buf[6] = NUL;
11616 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11617 {
11618 match = TRUE;
11619 str = name_buf;
11620 }
11621 }
11622 if (match)
11623 {
11624 if (loop == 0)
11625 {
11626 if (is_term_opt)
11627 num_term++;
11628 else
11629 num_normal++;
11630 }
11631 else
11632 (*file)[count++] = vim_strsave(str);
11633 }
11634 }
11635 /*
11636 * Check terminal key codes, these are not in the option table
11637 */
11638 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11639 {
11640 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11641 {
11642 if (!isprint(str[0]) || !isprint(str[1]))
11643 continue;
11644
11645 name_buf[0] = 't';
11646 name_buf[1] = '_';
11647 name_buf[2] = str[0];
11648 name_buf[3] = str[1];
11649 name_buf[4] = NUL;
11650
11651 match = FALSE;
11652 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11653 match = TRUE;
11654 else
11655 {
11656 name_buf[0] = '<';
11657 name_buf[1] = 't';
11658 name_buf[2] = '_';
11659 name_buf[3] = str[0];
11660 name_buf[4] = str[1];
11661 name_buf[5] = '>';
11662 name_buf[6] = NUL;
11663
11664 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11665 match = TRUE;
11666 }
11667 if (match)
11668 {
11669 if (loop == 0)
11670 num_term++;
11671 else
11672 (*file)[count++] = vim_strsave(name_buf);
11673 }
11674 }
11675
11676 /*
11677 * Check special key names.
11678 */
11679 regmatch->rm_ic = TRUE; /* ignore case here */
11680 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11681 {
11682 name_buf[0] = '<';
11683 STRCPY(name_buf + 1, str);
11684 STRCAT(name_buf, ">");
11685
11686 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11687 {
11688 if (loop == 0)
11689 num_term++;
11690 else
11691 (*file)[count++] = vim_strsave(name_buf);
11692 }
11693 }
11694 }
11695 if (loop == 0)
11696 {
11697 if (num_normal > 0)
11698 *num_file = num_normal;
11699 else if (num_term > 0)
11700 *num_file = num_term;
11701 else
11702 return OK;
11703 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11704 if (*file == NULL)
11705 {
11706 *file = (char_u **)"";
11707 return FAIL;
11708 }
11709 }
11710 }
11711 return OK;
11712}
11713
11714 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011715ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011716{
11717 char_u *var = NULL; /* init for GCC */
11718 char_u *buf;
11719
11720 *num_file = 0;
11721 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11722 if (*file == NULL)
11723 return FAIL;
11724
11725 /*
11726 * For a terminal key code expand_option_idx is < 0.
11727 */
11728 if (expand_option_idx < 0)
11729 {
11730 var = find_termcode(expand_option_name + 2);
11731 if (var == NULL)
11732 expand_option_idx = findoption(expand_option_name);
11733 }
11734
11735 if (expand_option_idx >= 0)
11736 {
11737 /* put string of option value in NameBuff */
11738 option_value2string(&options[expand_option_idx], expand_option_flags);
11739 var = NameBuff;
11740 }
11741 else if (var == NULL)
11742 var = (char_u *)"";
11743
11744 /* A backslash is required before some characters. This is the reverse of
11745 * what happens in do_set(). */
11746 buf = vim_strsave_escaped(var, escape_chars);
11747
11748 if (buf == NULL)
11749 {
11750 vim_free(*file);
11751 *file = NULL;
11752 return FAIL;
11753 }
11754
11755#ifdef BACKSLASH_IN_FILENAME
11756 /* For MS-Windows et al. we don't double backslashes at the start and
11757 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011758 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011759 if (var[0] == '\\' && var[1] == '\\'
11760 && expand_option_idx >= 0
11761 && (options[expand_option_idx].flags & P_EXPAND)
11762 && vim_isfilec(var[2])
11763 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011764 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011765#endif
11766
11767 *file[0] = buf;
11768 *num_file = 1;
11769 return OK;
11770}
11771#endif
11772
11773/*
11774 * Get the value for the numeric or string option *opp in a nice format into
11775 * NameBuff[]. Must not be called with a hidden option!
11776 */
11777 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011778option_value2string(
11779 struct vimoption *opp,
11780 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011781{
11782 char_u *varp;
11783
11784 varp = get_varp_scope(opp, opt_flags);
11785
11786 if (opp->flags & P_NUM)
11787 {
11788 long wc = 0;
11789
11790 if (wc_use_keyname(varp, &wc))
11791 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11792 else if (wc != 0)
11793 STRCPY(NameBuff, transchar((int)wc));
11794 else
11795 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11796 }
11797 else /* P_STRING */
11798 {
11799 varp = *(char_u **)(varp);
11800 if (varp == NULL) /* just in case */
11801 NameBuff[0] = NUL;
11802#ifdef FEAT_CRYPT
11803 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011804 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011805 STRCPY(NameBuff, "*****");
11806#endif
11807 else if (opp->flags & P_EXPAND)
11808 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11809 /* Translate 'pastetoggle' into special key names */
11810 else if ((char_u **)opp->var == &p_pt)
11811 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11812 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011813 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011814 }
11815}
11816
11817/*
11818 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11819 * printed as a keyname.
11820 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11821 */
11822 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011823wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011824{
11825 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11826 {
11827 *wcp = *(long *)varp;
11828 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11829 return TRUE;
11830 }
11831 return FALSE;
11832}
11833
Bram Moolenaar01615492015-02-03 13:00:38 +010011834#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011835/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011836 * Any character has an equivalent 'langmap' character. This is used for
11837 * keyboards that have a special language mode that sends characters above
11838 * 128 (although other characters can be translated too). The "to" field is a
11839 * Vim command character. This avoids having to switch the keyboard back to
11840 * ASCII mode when leaving Insert mode.
11841 *
11842 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11843 * commands.
11844 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11845 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11846 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011847 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011848# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011849/*
11850 * With multi-byte support use growarray for 'langmap' chars >= 256
11851 */
11852typedef struct
11853{
11854 int from;
11855 int to;
11856} langmap_entry_T;
11857
11858static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011859static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011860
11861/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011862 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11863 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011864 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011865 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011866langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011867{
11868 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011869 int a = 0;
11870 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011871
11872 /* Do a binary search for an existing entry. */
11873 while (a != b)
11874 {
11875 int i = (a + b) / 2;
11876 int d = entries[i].from - from;
11877
11878 if (d == 0)
11879 {
11880 entries[i].to = to;
11881 return;
11882 }
11883 if (d < 0)
11884 a = i + 1;
11885 else
11886 b = i;
11887 }
11888
11889 if (ga_grow(&langmap_mapga, 1) != OK)
11890 return; /* out of memory */
11891
11892 /* insert new entry at position "a" */
11893 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11894 mch_memmove(entries + 1, entries,
11895 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11896 ++langmap_mapga.ga_len;
11897 entries[0].from = from;
11898 entries[0].to = to;
11899}
11900
11901/*
11902 * Apply 'langmap' to multi-byte character "c" and return the result.
11903 */
11904 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011905langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011906{
11907 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11908 int a = 0;
11909 int b = langmap_mapga.ga_len;
11910
11911 while (a != b)
11912 {
11913 int i = (a + b) / 2;
11914 int d = entries[i].from - c;
11915
11916 if (d == 0)
11917 return entries[i].to; /* found matching entry */
11918 if (d < 0)
11919 a = i + 1;
11920 else
11921 b = i;
11922 }
11923 return c; /* no entry found, return "c" unmodified */
11924}
11925# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011926
11927 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011928langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011929{
11930 int i;
11931
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011932 for (i = 0; i < 256; i++)
11933 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11934# ifdef FEAT_MBYTE
11935 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11936# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011937}
11938
11939/*
11940 * Called when langmap option is set; the language map can be
11941 * changed at any time!
11942 */
11943 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011944langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011945{
11946 char_u *p;
11947 char_u *p2;
11948 int from, to;
11949
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011950#ifdef FEAT_MBYTE
11951 ga_clear(&langmap_mapga); /* clear the previous map first */
11952#endif
11953 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011954
11955 for (p = p_langmap; p[0] != NUL; )
11956 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011957 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011958 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011959 {
11960 if (p2[0] == '\\' && p2[1] != NUL)
11961 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011962 }
11963 if (p2[0] == ';')
11964 ++p2; /* abcd;ABCD form, p2 points to A */
11965 else
11966 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11967 while (p[0])
11968 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011969 if (p[0] == ',')
11970 {
11971 ++p;
11972 break;
11973 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011974 if (p[0] == '\\' && p[1] != NUL)
11975 ++p;
11976#ifdef FEAT_MBYTE
11977 from = (*mb_ptr2char)(p);
11978#else
11979 from = p[0];
11980#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011981 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011982 if (p2 == NULL)
11983 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011984 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011985 if (p[0] != ',')
11986 {
11987 if (p[0] == '\\')
11988 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011989#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011990 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011991#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011992 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011993#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011994 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011995 }
11996 else
11997 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011998 if (p2[0] != ',')
11999 {
12000 if (p2[0] == '\\')
12001 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012002#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020012003 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012004#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020012005 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000012006#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020012007 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012008 }
12009 if (to == NUL)
12010 {
12011 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
12012 transchar(from));
12013 return;
12014 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000012015
12016#ifdef FEAT_MBYTE
12017 if (from >= 256)
12018 langmap_set_entry(from, to);
12019 else
12020#endif
12021 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012022
12023 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012024 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020012025 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012026 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010012027 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000012028 if (*p == ';')
12029 {
12030 p = p2;
12031 if (p[0] != NUL)
12032 {
12033 if (p[0] != ',')
12034 {
12035 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
12036 return;
12037 }
12038 ++p;
12039 }
12040 break;
12041 }
12042 }
12043 }
12044 }
12045}
12046#endif
12047
12048/*
12049 * Return TRUE if format option 'x' is in effect.
12050 * Take care of no formatting when 'paste' is set.
12051 */
12052 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012053has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012054{
12055 if (p_paste)
12056 return FALSE;
12057 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
12058}
12059
12060/*
12061 * Return TRUE if "x" is present in 'shortmess' option, or
12062 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12063 */
12064 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012065shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012066{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012067 return p_shm != NULL &&
12068 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012069 || (vim_strchr(p_shm, 'a') != NULL
12070 && vim_strchr((char_u *)SHM_A, x) != NULL));
12071}
12072
12073/*
12074 * paste_option_changed() - Called after p_paste was set or reset.
12075 */
12076 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012077paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012078{
12079 static int old_p_paste = FALSE;
12080 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012081 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012082#ifdef FEAT_CMDL_INFO
12083 static int save_ru = 0;
12084#endif
12085#ifdef FEAT_RIGHTLEFT
12086 static int save_ri = 0;
12087 static int save_hkmap = 0;
12088#endif
12089 buf_T *buf;
12090
12091 if (p_paste)
12092 {
12093 /*
12094 * Paste switched from off to on.
12095 * Save the current values, so they can be restored later.
12096 */
12097 if (!old_p_paste)
12098 {
12099 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012100 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012101 {
12102 buf->b_p_tw_nopaste = buf->b_p_tw;
12103 buf->b_p_wm_nopaste = buf->b_p_wm;
12104 buf->b_p_sts_nopaste = buf->b_p_sts;
12105 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012106 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012107 }
12108
12109 /* save global options */
12110 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012111 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012112#ifdef FEAT_CMDL_INFO
12113 save_ru = p_ru;
12114#endif
12115#ifdef FEAT_RIGHTLEFT
12116 save_ri = p_ri;
12117 save_hkmap = p_hkmap;
12118#endif
12119 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012120 p_ai_nopaste = p_ai;
12121 p_et_nopaste = p_et;
12122 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012123 p_tw_nopaste = p_tw;
12124 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012125 }
12126
12127 /*
12128 * Always set the option values, also when 'paste' is set when it is
12129 * already on.
12130 */
12131 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012132 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012133 {
12134 buf->b_p_tw = 0; /* textwidth is 0 */
12135 buf->b_p_wm = 0; /* wrapmargin is 0 */
12136 buf->b_p_sts = 0; /* softtabstop is 0 */
12137 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012138 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012139 }
12140
12141 /* set global options */
12142 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012143 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012144#ifdef FEAT_CMDL_INFO
12145# ifdef FEAT_WINDOWS
12146 if (p_ru)
12147 status_redraw_all(); /* redraw to remove the ruler */
12148# endif
12149 p_ru = 0; /* no ruler */
12150#endif
12151#ifdef FEAT_RIGHTLEFT
12152 p_ri = 0; /* no reverse insert */
12153 p_hkmap = 0; /* no Hebrew keyboard */
12154#endif
12155 /* set global values for local buffer options */
12156 p_tw = 0;
12157 p_wm = 0;
12158 p_sts = 0;
12159 p_ai = 0;
12160 }
12161
12162 /*
12163 * Paste switched from on to off: Restore saved values.
12164 */
12165 else if (old_p_paste)
12166 {
12167 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012168 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012169 {
12170 buf->b_p_tw = buf->b_p_tw_nopaste;
12171 buf->b_p_wm = buf->b_p_wm_nopaste;
12172 buf->b_p_sts = buf->b_p_sts_nopaste;
12173 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012174 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012175 }
12176
12177 /* restore global options */
12178 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012179 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012180#ifdef FEAT_CMDL_INFO
12181# ifdef FEAT_WINDOWS
12182 if (p_ru != save_ru)
12183 status_redraw_all(); /* redraw to draw the ruler */
12184# endif
12185 p_ru = save_ru;
12186#endif
12187#ifdef FEAT_RIGHTLEFT
12188 p_ri = save_ri;
12189 p_hkmap = save_hkmap;
12190#endif
12191 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012192 p_ai = p_ai_nopaste;
12193 p_et = p_et_nopaste;
12194 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012195 p_tw = p_tw_nopaste;
12196 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012197 }
12198
12199 old_p_paste = p_paste;
12200}
12201
12202/*
12203 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12204 *
12205 * Reset 'compatible' and set the values for options that didn't get set yet
12206 * to the Vim defaults.
12207 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012208 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012209 */
12210 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012211vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012212{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012213 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012214 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012215 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012216
12217 if (!option_was_set((char_u *)"cp"))
12218 {
12219 p_cp = FALSE;
12220 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12221 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12222 set_option_default(opt_idx, OPT_FREE, FALSE);
12223 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012224 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012225 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012226
12227 if (fname != NULL)
12228 {
12229 p = vim_getenv(envname, &dofree);
12230 if (p == NULL)
12231 {
12232 /* Set $MYVIMRC to the first vimrc file found. */
12233 p = FullName_save(fname, FALSE);
12234 if (p != NULL)
12235 {
12236 vim_setenv(envname, p);
12237 vim_free(p);
12238 }
12239 }
12240 else if (dofree)
12241 vim_free(p);
12242 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012243}
12244
12245/*
12246 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12247 */
12248 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012249change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012250{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012251 int opt_idx;
12252
Bram Moolenaar071d4272004-06-13 20:20:40 +000012253 if (p_cp != on)
12254 {
12255 p_cp = on;
12256 compatible_set();
12257 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012258 opt_idx = findoption((char_u *)"cp");
12259 if (opt_idx >= 0)
12260 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012261}
12262
12263/*
12264 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012265 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012266 */
12267 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012268option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012269{
12270 int idx;
12271
12272 idx = findoption(name);
12273 if (idx < 0) /* unknown option */
12274 return FALSE;
12275 if (options[idx].flags & P_WAS_SET)
12276 return TRUE;
12277 return FALSE;
12278}
12279
12280/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012281 * Reset the flag indicating option "name" was set.
12282 */
12283 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012284reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012285{
12286 int idx = findoption(name);
12287
12288 if (idx >= 0)
12289 options[idx].flags &= ~P_WAS_SET;
12290}
12291
12292/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012293 * compatible_set() - Called when 'compatible' has been set or unset.
12294 *
12295 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12296 * flag) to a Vi compatible value.
12297 * When 'compatible' is unset: Set all options that have a different default
12298 * for Vim (without the P_VI_DEF flag) to that default.
12299 */
12300 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012301compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012302{
12303 int opt_idx;
12304
12305 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12306 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12307 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12308 set_option_default(opt_idx, OPT_FREE, p_cp);
12309 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012310 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012311}
12312
12313#ifdef FEAT_LINEBREAK
12314
12315# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12316 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012317 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012318# endif
12319
12320/*
12321 * fill_breakat_flags() -- called when 'breakat' changes value.
12322 */
12323 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012324fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012325{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012326 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012327 int i;
12328
12329 for (i = 0; i < 256; i++)
12330 breakat_flags[i] = FALSE;
12331
12332 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012333 for (p = p_breakat; *p; p++)
12334 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012335}
12336
12337# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012338 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012339# endif
12340
12341#endif
12342
12343/*
12344 * Check an option that can be a range of string values.
12345 *
12346 * Return OK for correct value, FAIL otherwise.
12347 * Empty is always OK.
12348 */
12349 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012350check_opt_strings(
12351 char_u *val,
12352 char **values,
12353 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012354{
12355 return opt_strings_flags(val, values, NULL, list);
12356}
12357
12358/*
12359 * Handle an option that can be a range of string values.
12360 * Set a flag in "*flagp" for each string present.
12361 *
12362 * Return OK for correct value, FAIL otherwise.
12363 * Empty is always OK.
12364 */
12365 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012366opt_strings_flags(
12367 char_u *val, /* new value */
12368 char **values, /* array of valid string values */
12369 unsigned *flagp,
12370 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012371{
12372 int i;
12373 int len;
12374 unsigned new_flags = 0;
12375
12376 while (*val)
12377 {
12378 for (i = 0; ; ++i)
12379 {
12380 if (values[i] == NULL) /* val not found in values[] */
12381 return FAIL;
12382
12383 len = (int)STRLEN(values[i]);
12384 if (STRNCMP(values[i], val, len) == 0
12385 && ((list && val[len] == ',') || val[len] == NUL))
12386 {
12387 val += len + (val[len] == ',');
12388 new_flags |= (1 << i);
12389 break; /* check next item in val list */
12390 }
12391 }
12392 }
12393 if (flagp != NULL)
12394 *flagp = new_flags;
12395
12396 return OK;
12397}
12398
12399/*
12400 * Read the 'wildmode' option, fill wim_flags[].
12401 */
12402 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012403check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012404{
12405 char_u new_wim_flags[4];
12406 char_u *p;
12407 int i;
12408 int idx = 0;
12409
12410 for (i = 0; i < 4; ++i)
12411 new_wim_flags[i] = 0;
12412
12413 for (p = p_wim; *p; ++p)
12414 {
12415 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12416 ;
12417 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12418 return FAIL;
12419 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12420 new_wim_flags[idx] |= WIM_LONGEST;
12421 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12422 new_wim_flags[idx] |= WIM_FULL;
12423 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12424 new_wim_flags[idx] |= WIM_LIST;
12425 else
12426 return FAIL;
12427 p += i;
12428 if (*p == NUL)
12429 break;
12430 if (*p == ',')
12431 {
12432 if (idx == 3)
12433 return FAIL;
12434 ++idx;
12435 }
12436 }
12437
12438 /* fill remaining entries with last flag */
12439 while (idx < 3)
12440 {
12441 new_wim_flags[idx + 1] = new_wim_flags[idx];
12442 ++idx;
12443 }
12444
12445 /* only when there are no errors, wim_flags[] is changed */
12446 for (i = 0; i < 4; ++i)
12447 wim_flags[i] = new_wim_flags[i];
12448 return OK;
12449}
12450
12451/*
12452 * Check if backspacing over something is allowed.
12453 */
12454 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012455can_bs(
12456 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012457{
12458 switch (*p_bs)
12459 {
12460 case '2': return TRUE;
12461 case '1': return (what != BS_START);
12462 case '0': return FALSE;
12463 }
12464 return vim_strchr(p_bs, what) != NULL;
12465}
12466
12467/*
12468 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12469 * the file must be considered changed when the value is different.
12470 */
12471 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012472save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012473{
12474 buf->b_start_ffc = *buf->b_p_ff;
12475 buf->b_start_eol = buf->b_p_eol;
12476#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012477 buf->b_start_bomb = buf->b_p_bomb;
12478
Bram Moolenaar071d4272004-06-13 20:20:40 +000012479 /* Only use free/alloc when necessary, they take time. */
12480 if (buf->b_start_fenc == NULL
12481 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12482 {
12483 vim_free(buf->b_start_fenc);
12484 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12485 }
12486#endif
12487}
12488
12489/*
12490 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12491 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012492 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12493 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012494 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012495 * When "ignore_empty" is true don't consider a new, empty buffer to be
12496 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012497 */
12498 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012499file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012500{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012501 /* In a buffer that was never loaded the options are not valid. */
12502 if (buf->b_flags & BF_NEVERLOADED)
12503 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012504 if (ignore_empty
12505 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012506 && buf->b_ml.ml_line_count == 1
12507 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12508 return FALSE;
12509 if (buf->b_start_ffc != *buf->b_p_ff)
12510 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012511 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012512 return TRUE;
12513#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012514 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12515 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012516 if (buf->b_start_fenc == NULL)
12517 return (*buf->b_p_fenc != NUL);
12518 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12519#else
12520 return FALSE;
12521#endif
12522}
12523
12524/*
12525 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12526 */
12527 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012528check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012529{
12530 return check_opt_strings(p, p_ff_values, FALSE);
12531}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012532
12533/*
12534 * Return the effective shiftwidth value for current buffer, using the
12535 * 'tabstop' value when 'shiftwidth' is zero.
12536 */
12537 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012538get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012539{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012540 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012541}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012542
12543/*
12544 * Return the effective softtabstop value for the current buffer, using the
12545 * 'tabstop' value when 'softtabstop' is negative.
12546 */
12547 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012548get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012549{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012550 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012551}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012552
12553/*
12554 * Check matchpairs option for "*initc".
12555 * If there is a match set "*initc" to the matching character and "*findc" to
12556 * the opposite character. Set "*backwards" to the direction.
12557 * When "switchit" is TRUE swap the direction.
12558 */
12559 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012560find_mps_values(
12561 int *initc,
12562 int *findc,
12563 int *backwards,
12564 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012565{
12566 char_u *ptr;
12567
12568 ptr = curbuf->b_p_mps;
12569 while (*ptr != NUL)
12570 {
12571#ifdef FEAT_MBYTE
12572 if (has_mbyte)
12573 {
12574 char_u *prev;
12575
12576 if (mb_ptr2char(ptr) == *initc)
12577 {
12578 if (switchit)
12579 {
12580 *findc = *initc;
12581 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12582 *backwards = TRUE;
12583 }
12584 else
12585 {
12586 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12587 *backwards = FALSE;
12588 }
12589 return;
12590 }
12591 prev = ptr;
12592 ptr += mb_ptr2len(ptr) + 1;
12593 if (mb_ptr2char(ptr) == *initc)
12594 {
12595 if (switchit)
12596 {
12597 *findc = *initc;
12598 *initc = mb_ptr2char(prev);
12599 *backwards = FALSE;
12600 }
12601 else
12602 {
12603 *findc = mb_ptr2char(prev);
12604 *backwards = TRUE;
12605 }
12606 return;
12607 }
12608 ptr += mb_ptr2len(ptr);
12609 }
12610 else
12611#endif
12612 {
12613 if (*ptr == *initc)
12614 {
12615 if (switchit)
12616 {
12617 *backwards = TRUE;
12618 *findc = *initc;
12619 *initc = ptr[2];
12620 }
12621 else
12622 {
12623 *backwards = FALSE;
12624 *findc = ptr[2];
12625 }
12626 return;
12627 }
12628 ptr += 2;
12629 if (*ptr == *initc)
12630 {
12631 if (switchit)
12632 {
12633 *backwards = FALSE;
12634 *findc = *initc;
12635 *initc = ptr[-2];
12636 }
12637 else
12638 {
12639 *backwards = TRUE;
12640 *findc = ptr[-2];
12641 }
12642 return;
12643 }
12644 ++ptr;
12645 }
12646 if (*ptr == ',')
12647 ++ptr;
12648 }
12649}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012650
12651#if defined(FEAT_LINEBREAK) || defined(PROTO)
12652/*
12653 * This is called when 'breakindentopt' is changed and when a window is
12654 * initialized.
12655 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012656 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012657briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012658{
12659 char_u *p;
12660 int bri_shift = 0;
12661 long bri_min = 20;
12662 int bri_sbr = FALSE;
12663
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012664 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012665 while (*p != NUL)
12666 {
12667 if (STRNCMP(p, "shift:", 6) == 0
12668 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12669 {
12670 p += 6;
12671 bri_shift = getdigits(&p);
12672 }
12673 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12674 {
12675 p += 4;
12676 bri_min = getdigits(&p);
12677 }
12678 else if (STRNCMP(p, "sbr", 3) == 0)
12679 {
12680 p += 3;
12681 bri_sbr = TRUE;
12682 }
12683 if (*p != ',' && *p != NUL)
12684 return FAIL;
12685 if (*p == ',')
12686 ++p;
12687 }
12688
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012689 wp->w_p_brishift = bri_shift;
12690 wp->w_p_brimin = bri_min;
12691 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012692
12693 return OK;
12694}
12695#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012696
12697/*
12698 * Get the local or global value of 'backupcopy'.
12699 */
12700 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012701get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012702{
12703 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12704}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012705
12706#if defined(FEAT_SIGNS) || defined(PROTO)
12707/*
12708 * Return TRUE when window "wp" has a column to draw signs in.
12709 */
12710 int
12711signcolumn_on(win_T *wp)
12712{
12713 if (*wp->w_p_scl == 'n')
12714 return FALSE;
12715 if (*wp->w_p_scl == 'y')
12716 return TRUE;
12717 return (wp->w_buffer->b_signlist != NULL
12718# ifdef FEAT_NETBEANS_INTG
12719 || wp->w_buffer->b_has_sign_column
12720# endif
12721 );
12722}
12723#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012724
12725#if defined(FEAT_EVAL) || defined(PROTO)
12726/*
12727 * Get window or buffer local options.
12728 */
12729 dict_T *
12730get_winbuf_options(int bufopt)
12731{
12732 dict_T *d;
12733 int opt_idx;
12734
12735 d = dict_alloc();
12736 if (d == NULL)
12737 return NULL;
12738
12739 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12740 {
12741 struct vimoption *opt = &options[opt_idx];
12742
12743 if ((bufopt && (opt->indir & PV_BUF))
12744 || (!bufopt && (opt->indir & PV_WIN)))
12745 {
12746 char_u *varp = get_varp(opt);
12747
12748 if (varp != NULL)
12749 {
12750 if (opt->flags & P_STRING)
12751 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012752 else if (opt->flags & P_NUM)
12753 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012754 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012755 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012756 }
12757 }
12758 }
12759
12760 return d;
12761}
12762#endif