Merge branch 'vim' into feat/indent-wrap-lines
[vim_extended.git] / src / option.c
bloba968a0c792fcc53bfa54cfaa74ae4e553461705a
1 /* vi:set ts=8 sts=4 sw=4:
3 * VIM - Vi IMproved by Bram Moolenaar
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 */
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.
25 * - Add documentation! One line in doc/help.txt, full description in
26 * 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.
34 #define IN_OPTION_C
35 #include "vim.h"
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.
41 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
43 * PV_BOTH is added: global option which also has a local value.
45 #define PV_BOTH 0x1000
46 #define PV_WIN 0x2000
47 #define PV_BUF 0x4000
48 #define PV_MASK 0x0fff
49 #define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50 #define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
51 #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
54 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
57 #define PV_AI OPT_BUF(BV_AI)
58 #define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
59 #ifdef FEAT_QUICKFIX
60 # define PV_BH OPT_BUF(BV_BH)
61 # define PV_BT OPT_BUF(BV_BT)
62 # define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
63 # define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
64 # define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
65 #endif
66 #define PV_BIN OPT_BUF(BV_BIN)
67 #define PV_BL OPT_BUF(BV_BL)
68 #ifdef FEAT_MBYTE
69 # define PV_BOMB OPT_BUF(BV_BOMB)
70 #endif
71 #define PV_CI OPT_BUF(BV_CI)
72 #ifdef FEAT_CINDENT
73 # define PV_CIN OPT_BUF(BV_CIN)
74 # define PV_CINK OPT_BUF(BV_CINK)
75 # define PV_CINO OPT_BUF(BV_CINO)
76 #endif
77 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
78 # define PV_CINW OPT_BUF(BV_CINW)
79 #endif
80 #ifdef FEAT_FOLDING
81 # define PV_CMS OPT_BUF(BV_CMS)
82 #endif
83 #ifdef FEAT_COMMENTS
84 # define PV_COM OPT_BUF(BV_COM)
85 #endif
86 #ifdef FEAT_INS_EXPAND
87 # define PV_CPT OPT_BUF(BV_CPT)
88 # define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
89 # define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
90 #endif
91 #ifdef FEAT_COMPL_FUNC
92 # define PV_CFU OPT_BUF(BV_CFU)
93 #endif
94 #ifdef FEAT_FIND_ID
95 # define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
96 # define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
97 #endif
98 #define PV_EOL OPT_BUF(BV_EOL)
99 #define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
100 #define PV_ET OPT_BUF(BV_ET)
101 #ifdef FEAT_MBYTE
102 # define PV_FENC OPT_BUF(BV_FENC)
103 #endif
104 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
105 # define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
106 #endif
107 #ifdef FEAT_EVAL
108 # define PV_FEX OPT_BUF(BV_FEX)
109 #endif
110 #define PV_FF OPT_BUF(BV_FF)
111 #define PV_FLP OPT_BUF(BV_FLP)
112 #define PV_FO OPT_BUF(BV_FO)
113 #ifdef FEAT_AUTOCMD
114 # define PV_FT OPT_BUF(BV_FT)
115 #endif
116 #define PV_IMI OPT_BUF(BV_IMI)
117 #define PV_IMS OPT_BUF(BV_IMS)
118 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
119 # define PV_INDE OPT_BUF(BV_INDE)
120 # define PV_INDK OPT_BUF(BV_INDK)
121 #endif
122 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
123 # define PV_INEX OPT_BUF(BV_INEX)
124 #endif
125 #define PV_INF OPT_BUF(BV_INF)
126 #define PV_ISK OPT_BUF(BV_ISK)
127 #ifdef FEAT_CRYPT
128 # define PV_KEY OPT_BUF(BV_KEY)
129 #endif
130 #ifdef FEAT_KEYMAP
131 # define PV_KMAP OPT_BUF(BV_KMAP)
132 #endif
133 #define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
134 #ifdef FEAT_LISP
135 # define PV_LISP OPT_BUF(BV_LISP)
136 #endif
137 #define PV_MA OPT_BUF(BV_MA)
138 #define PV_ML OPT_BUF(BV_ML)
139 #define PV_MOD OPT_BUF(BV_MOD)
140 #define PV_MPS OPT_BUF(BV_MPS)
141 #define PV_NF OPT_BUF(BV_NF)
142 #ifdef FEAT_OSFILETYPE
143 # define PV_OFT OPT_BUF(BV_OFT)
144 #endif
145 #ifdef FEAT_COMPL_FUNC
146 # define PV_OFU OPT_BUF(BV_OFU)
147 #endif
148 #define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
149 #define PV_PI OPT_BUF(BV_PI)
150 #ifdef FEAT_TEXTOBJ
151 # define PV_QE OPT_BUF(BV_QE)
152 #endif
153 #define PV_RO OPT_BUF(BV_RO)
154 #ifdef FEAT_SMARTINDENT
155 # define PV_SI OPT_BUF(BV_SI)
156 #endif
157 #ifndef SHORT_FNAME
158 # define PV_SN OPT_BUF(BV_SN)
159 #endif
160 #ifdef FEAT_SYN_HL
161 # define PV_SMC OPT_BUF(BV_SMC)
162 # define PV_SYN OPT_BUF(BV_SYN)
163 #endif
164 #ifdef FEAT_SPELL
165 # define PV_SPC OPT_BUF(BV_SPC)
166 # define PV_SPF OPT_BUF(BV_SPF)
167 # define PV_SPL OPT_BUF(BV_SPL)
168 #endif
169 #define PV_STS OPT_BUF(BV_STS)
170 #ifdef FEAT_SEARCHPATH
171 # define PV_SUA OPT_BUF(BV_SUA)
172 #endif
173 #define PV_SW OPT_BUF(BV_SW)
174 #define PV_SWF OPT_BUF(BV_SWF)
175 #define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
176 #define PV_TS OPT_BUF(BV_TS)
177 #define PV_TW OPT_BUF(BV_TW)
178 #define PV_TX OPT_BUF(BV_TX)
179 #define PV_WM OPT_BUF(BV_WM)
182 * Definition of the PV_ values for window-local options.
183 * The WV_ values are defined in option.h.
185 #define PV_LIST OPT_WIN(WV_LIST)
186 #ifdef FEAT_ARABIC
187 # define PV_ARAB OPT_WIN(WV_ARAB)
188 #endif
189 #ifdef FEAT_LINEBREAK
190 # define PV_BRI OPT_WIN(WV_BRI)
191 # define PV_BRIMIN OPT_WIN(WV_BRIMIN)
192 # define PV_BRISHIFT OPT_WIN(WV_BRISHIFT)
193 #endif
194 #ifdef FEAT_DIFF
195 # define PV_DIFF OPT_WIN(WV_DIFF)
196 #endif
197 #ifdef FEAT_FOLDING
198 # define PV_FDC OPT_WIN(WV_FDC)
199 # define PV_FEN OPT_WIN(WV_FEN)
200 # define PV_FDI OPT_WIN(WV_FDI)
201 # define PV_FDL OPT_WIN(WV_FDL)
202 # define PV_FDM OPT_WIN(WV_FDM)
203 # define PV_FML OPT_WIN(WV_FML)
204 # define PV_FDN OPT_WIN(WV_FDN)
205 # ifdef FEAT_EVAL
206 # define PV_FDE OPT_WIN(WV_FDE)
207 # define PV_FDT OPT_WIN(WV_FDT)
208 # endif
209 # define PV_FMR OPT_WIN(WV_FMR)
210 #endif
211 #ifdef FEAT_LINEBREAK
212 # define PV_LBR OPT_WIN(WV_LBR)
213 #endif
214 #define PV_NU OPT_WIN(WV_NU)
215 #ifdef FEAT_LINEBREAK
216 # define PV_NUW OPT_WIN(WV_NUW)
217 #endif
218 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
219 # define PV_PVW OPT_WIN(WV_PVW)
220 #endif
221 #ifdef FEAT_RIGHTLEFT
222 # define PV_RL OPT_WIN(WV_RL)
223 # define PV_RLC OPT_WIN(WV_RLC)
224 #endif
225 #ifdef FEAT_SCROLLBIND
226 # define PV_SCBIND OPT_WIN(WV_SCBIND)
227 #endif
228 #define PV_SCROLL OPT_WIN(WV_SCROLL)
229 #ifdef FEAT_SPELL
230 # define PV_SPELL OPT_WIN(WV_SPELL)
231 #endif
232 #ifdef FEAT_SYN_HL
233 # define PV_CUC OPT_WIN(WV_CUC)
234 # define PV_CUL OPT_WIN(WV_CUL)
235 #endif
236 #ifdef FEAT_STL_OPT
237 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
238 #endif
239 #ifdef FEAT_WINDOWS
240 # define PV_WFH OPT_WIN(WV_WFH)
241 #endif
242 #ifdef FEAT_VERTSPLIT
243 # define PV_WFW OPT_WIN(WV_WFW)
244 #endif
245 #define PV_WRAP OPT_WIN(WV_WRAP)
248 /* WV_ and BV_ values get typecasted to this for the "indir" field */
249 typedef enum
251 PV_NONE = 0,
252 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
253 } idopt_T;
256 * Options local to a window have a value local to a buffer and global to all
257 * buffers. Indicate this by setting "var" to VAR_WIN.
259 #define VAR_WIN ((char_u *)-1)
262 * These are the global values for options which are also local to a buffer.
263 * Only to be used in option.c!
265 static int p_ai;
266 static int p_bin;
267 #ifdef FEAT_MBYTE
268 static int p_bomb;
269 #endif
270 #if defined(FEAT_QUICKFIX)
271 static char_u *p_bh;
272 static char_u *p_bt;
273 #endif
274 static int p_bl;
275 static int p_ci;
276 #ifdef FEAT_CINDENT
277 static int p_cin;
278 static char_u *p_cink;
279 static char_u *p_cino;
280 #endif
281 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
282 static char_u *p_cinw;
283 #endif
284 #ifdef FEAT_COMMENTS
285 static char_u *p_com;
286 #endif
287 #ifdef FEAT_FOLDING
288 static char_u *p_cms;
289 #endif
290 #ifdef FEAT_INS_EXPAND
291 static char_u *p_cpt;
292 #endif
293 #ifdef FEAT_COMPL_FUNC
294 static char_u *p_cfu;
295 static char_u *p_ofu;
296 #endif
297 static int p_eol;
298 static int p_et;
299 #ifdef FEAT_MBYTE
300 static char_u *p_fenc;
301 #endif
302 static char_u *p_ff;
303 static char_u *p_fo;
304 static char_u *p_flp;
305 #ifdef FEAT_AUTOCMD
306 static char_u *p_ft;
307 #endif
308 static long p_iminsert;
309 static long p_imsearch;
310 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
311 static char_u *p_inex;
312 #endif
313 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
314 static char_u *p_inde;
315 static char_u *p_indk;
316 #endif
317 #if defined(FEAT_EVAL)
318 static char_u *p_fex;
319 #endif
320 static int p_inf;
321 static char_u *p_isk;
322 #ifdef FEAT_CRYPT
323 static char_u *p_key;
324 #endif
325 #ifdef FEAT_LISP
326 static int p_lisp;
327 #endif
328 static int p_ml;
329 static int p_ma;
330 static int p_mod;
331 static char_u *p_mps;
332 static char_u *p_nf;
333 #ifdef FEAT_OSFILETYPE
334 static char_u *p_oft;
335 #endif
336 static int p_pi;
337 #ifdef FEAT_TEXTOBJ
338 static char_u *p_qe;
339 #endif
340 static int p_ro;
341 #ifdef FEAT_SMARTINDENT
342 static int p_si;
343 #endif
344 #ifndef SHORT_FNAME
345 static int p_sn;
346 #endif
347 static long p_sts;
348 #if defined(FEAT_SEARCHPATH)
349 static char_u *p_sua;
350 #endif
351 static long p_sw;
352 static int p_swf;
353 #ifdef FEAT_SYN_HL
354 static long p_smc;
355 static char_u *p_syn;
356 #endif
357 #ifdef FEAT_SPELL
358 static char_u *p_spc;
359 static char_u *p_spf;
360 static char_u *p_spl;
361 #endif
362 static long p_ts;
363 static long p_tw;
364 static int p_tx;
365 static long p_wm;
366 #ifdef FEAT_KEYMAP
367 static char_u *p_keymap;
368 #endif
370 /* Saved values for when 'bin' is set. */
371 static int p_et_nobin;
372 static int p_ml_nobin;
373 static long p_tw_nobin;
374 static long p_wm_nobin;
376 /* Saved values for when 'paste' is set */
377 static long p_tw_nopaste;
378 static long p_wm_nopaste;
379 static long p_sts_nopaste;
380 static int p_ai_nopaste;
382 struct vimoption
384 char *fullname; /* full option name */
385 char *shortname; /* permissible abbreviation */
386 long_u flags; /* see below */
387 char_u *var; /* global option: pointer to variable;
388 * window-local option: VAR_WIN;
389 * buffer-local option: global value */
390 idopt_T indir; /* global option: PV_NONE;
391 * local option: indirect option index */
392 char_u *def_val[2]; /* default values for variable (vi and vim) */
393 #ifdef FEAT_EVAL
394 scid_T scriptID; /* script in which the option was last set */
395 # define SCRIPTID_INIT , 0
396 #else
397 # define SCRIPTID_INIT
398 #endif
401 #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
402 #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
405 * Flags
407 #define P_BOOL 0x01 /* the option is boolean */
408 #define P_NUM 0x02 /* the option is numeric */
409 #define P_STRING 0x04 /* the option is a string */
410 #define P_ALLOCED 0x08 /* the string option is in allocated memory,
411 must use free_string_option() when
412 assigning new value. Not set if default is
413 the same. */
414 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
415 never be used for local or hidden options! */
416 #define P_NODEFAULT 0x40 /* don't set to default value */
417 #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
418 use vim_free() when assigning new value */
419 #define P_WAS_SET 0x100 /* option has been set/reset */
420 #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
421 #define P_VI_DEF 0x400 /* Use Vi default for Vim */
422 #define P_VIM 0x800 /* Vim option, reset when 'cp' set */
424 /* when option changed, what to display: */
425 #define P_RSTAT 0x1000 /* redraw status lines */
426 #define P_RWIN 0x2000 /* redraw current window */
427 #define P_RBUF 0x4000 /* redraw current buffer */
428 #define P_RALL 0x6000 /* redraw all windows */
429 #define P_RCLR 0x7000 /* clear and redraw all */
431 #define P_COMMA 0x8000 /* comma separated list */
432 #define P_NODUP 0x10000L/* don't allow duplicate strings */
433 #define P_FLAGLIST 0x20000L/* list of single-char flags */
435 #define P_SECURE 0x40000L/* cannot change in modeline or secure mode */
436 #define P_GETTEXT 0x80000L/* expand default value with _() */
437 #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */
438 #define P_NFNAME 0x200000L/* only normal file name chars allowed */
439 #define P_INSECURE 0x400000L/* option was set from a modeline */
440 #define P_PRI_MKRC 0x800000L/* priority for :mkvimrc (setting option has
441 side effects) */
443 #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
445 /* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
446 * for the currency sign. */
447 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
448 # define ISP_LATIN1 (char_u *)"@,~-255"
449 #else
450 # define ISP_LATIN1 (char_u *)"@,161-255"
451 #endif
453 /* The 16 bit MS-DOS version is low on space, make the string as short as
454 * possible when compiling with few features. */
455 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
456 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
457 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL)
458 # define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,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,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine"
459 #else
460 # define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
461 #endif
464 * options[] is initialized here.
465 * The order of the options MUST be alphabetic for ":set all" and findoption().
466 * All option names MUST start with a lowercase letter (for findoption()).
467 * Exception: "t_" options are at the end.
468 * The options with a NULL variable are 'hidden': a set command for them is
469 * ignored and they are not printed.
471 static struct vimoption
472 #ifdef FEAT_GUI_W16
473 _far
474 #endif
475 options[] =
477 {"aleph", "al", P_NUM|P_VI_DEF,
478 #ifdef FEAT_RIGHTLEFT
479 (char_u *)&p_aleph, PV_NONE,
480 #else
481 (char_u *)NULL, PV_NONE,
482 #endif
484 #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
485 (char_u *)128L,
486 #else
487 (char_u *)224L,
488 #endif
489 (char_u *)0L} SCRIPTID_INIT},
490 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
491 #if defined(FEAT_GUI) && defined(MACOS_X)
492 (char_u *)&p_antialias, PV_NONE,
493 {(char_u *)FALSE, (char_u *)FALSE}
494 #else
495 (char_u *)NULL, PV_NONE,
496 {(char_u *)FALSE, (char_u *)FALSE}
497 #endif
498 SCRIPTID_INIT},
499 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
500 #ifdef FEAT_ARABIC
501 (char_u *)VAR_WIN, PV_ARAB,
502 #else
503 (char_u *)NULL, PV_NONE,
504 #endif
505 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
506 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
507 #ifdef FEAT_ARABIC
508 (char_u *)&p_arshape, PV_NONE,
509 #else
510 (char_u *)NULL, PV_NONE,
511 #endif
512 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
513 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
514 #ifdef FEAT_RIGHTLEFT
515 (char_u *)&p_ari, PV_NONE,
516 #else
517 (char_u *)NULL, PV_NONE,
518 #endif
519 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
520 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
521 #ifdef FEAT_FKMAP
522 (char_u *)&p_altkeymap, PV_NONE,
523 #else
524 (char_u *)NULL, PV_NONE,
525 #endif
526 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
527 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
528 #if defined(FEAT_MBYTE)
529 (char_u *)&p_ambw, PV_NONE,
530 {(char_u *)"single", (char_u *)0L}
531 #else
532 (char_u *)NULL, PV_NONE,
533 {(char_u *)0L, (char_u *)0L}
534 #endif
535 SCRIPTID_INIT},
536 #ifdef FEAT_AUTOCHDIR
537 {"autochdir", "acd", P_BOOL|P_VI_DEF,
538 (char_u *)&p_acd, PV_NONE,
539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
540 #endif
541 {"autoindent", "ai", P_BOOL|P_VI_DEF,
542 (char_u *)&p_ai, PV_AI,
543 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
544 {"autoprint", "ap", P_BOOL|P_VI_DEF,
545 (char_u *)NULL, PV_NONE,
546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
547 {"autoread", "ar", P_BOOL|P_VI_DEF,
548 (char_u *)&p_ar, PV_AR,
549 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
550 {"autowrite", "aw", P_BOOL|P_VI_DEF,
551 (char_u *)&p_aw, PV_NONE,
552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
553 {"autowriteall","awa", P_BOOL|P_VI_DEF,
554 (char_u *)&p_awa, PV_NONE,
555 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
556 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
557 (char_u *)&p_bg, PV_NONE,
559 #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
560 (char_u *)"dark",
561 #else
562 (char_u *)"light",
563 #endif
564 (char_u *)0L} SCRIPTID_INIT},
565 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
566 (char_u *)&p_bs, PV_NONE,
567 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
568 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
569 (char_u *)&p_bk, PV_NONE,
570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
571 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
572 (char_u *)&p_bkc, PV_NONE,
573 #ifdef UNIX
574 {(char_u *)"yes", (char_u *)"auto"}
575 #else
576 {(char_u *)"auto", (char_u *)"auto"}
577 #endif
578 SCRIPTID_INIT},
579 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
580 (char_u *)&p_bdir, PV_NONE,
581 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
582 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
583 (char_u *)&p_bex, PV_NONE,
585 #ifdef VMS
586 (char_u *)"_",
587 #else
588 (char_u *)"~",
589 #endif
590 (char_u *)0L} SCRIPTID_INIT},
591 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
592 #ifdef FEAT_WILDIGN
593 (char_u *)&p_bsk, PV_NONE,
594 {(char_u *)"", (char_u *)0L}
595 #else
596 (char_u *)NULL, PV_NONE,
597 {(char_u *)0L, (char_u *)0L}
598 #endif
599 SCRIPTID_INIT},
600 #ifdef FEAT_BEVAL
601 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
602 (char_u *)&p_bdlay, PV_NONE,
603 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
604 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
605 (char_u *)&p_beval, PV_NONE,
606 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
607 # ifdef FEAT_EVAL
608 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
609 (char_u *)&p_bexpr, PV_BEXPR,
610 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
611 # endif
612 #endif
613 {"beautify", "bf", P_BOOL|P_VI_DEF,
614 (char_u *)NULL, PV_NONE,
615 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
616 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
617 (char_u *)&p_bin, PV_BIN,
618 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
619 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
620 #ifdef MSDOS
621 (char_u *)&p_biosk, PV_NONE,
622 #else
623 (char_u *)NULL, PV_NONE,
624 #endif
625 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
626 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
627 #ifdef FEAT_MBYTE
628 (char_u *)&p_bomb, PV_BOMB,
629 #else
630 (char_u *)NULL, PV_NONE,
631 #endif
632 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
633 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
634 #ifdef FEAT_LINEBREAK
635 (char_u *)&p_breakat, PV_NONE,
636 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
637 #else
638 (char_u *)NULL, PV_NONE,
639 {(char_u *)0L, (char_u *)0L}
640 #endif
641 SCRIPTID_INIT},
642 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
643 #ifdef FEAT_LINEBREAK
644 (char_u *)VAR_WIN, PV_BRI,
645 #else
646 (char_u *)NULL, PV_NONE,
647 #endif
648 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
649 {"breakindentmin", "brimin", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
650 #ifdef FEAT_LINEBREAK
651 (char_u *)VAR_WIN, PV_BRIMIN,
652 #else
653 (char_u *)NULL, PV_NONE,
654 #endif
655 {(char_u *)20L, (char_u *)20L} SCRIPTID_INIT},
656 {"breakindentshift", "brishift", P_NUM|P_VI_DEF|P_VIM|P_RWIN,
657 #ifdef FEAT_LINEBREAK
658 (char_u *)VAR_WIN, PV_BRISHIFT,
659 #else
660 (char_u *)NULL, PV_NONE,
661 #endif
662 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
663 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
664 #ifdef FEAT_BROWSE
665 (char_u *)&p_bsdir, PV_NONE,
666 {(char_u *)"last", (char_u *)0L}
667 #else
668 (char_u *)NULL, PV_NONE,
669 {(char_u *)0L, (char_u *)0L}
670 #endif
671 SCRIPTID_INIT},
672 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
673 #if defined(FEAT_QUICKFIX)
674 (char_u *)&p_bh, PV_BH,
675 {(char_u *)"", (char_u *)0L}
676 #else
677 (char_u *)NULL, PV_NONE,
678 {(char_u *)0L, (char_u *)0L}
679 #endif
680 SCRIPTID_INIT},
681 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
682 (char_u *)&p_bl, PV_BL,
683 {(char_u *)1L, (char_u *)0L}
684 SCRIPTID_INIT},
685 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
686 #if defined(FEAT_QUICKFIX)
687 (char_u *)&p_bt, PV_BT,
688 {(char_u *)"", (char_u *)0L}
689 #else
690 (char_u *)NULL, PV_NONE,
691 {(char_u *)0L, (char_u *)0L}
692 #endif
693 SCRIPTID_INIT},
694 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
695 #ifdef FEAT_MBYTE
696 (char_u *)&p_cmp, PV_NONE,
697 {(char_u *)"internal,keepascii", (char_u *)0L}
698 #else
699 (char_u *)NULL, PV_NONE,
700 {(char_u *)0L, (char_u *)0L}
701 #endif
702 SCRIPTID_INIT},
703 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
704 #ifdef FEAT_SEARCHPATH
705 (char_u *)&p_cdpath, PV_NONE,
706 {(char_u *)",,", (char_u *)0L}
707 #else
708 (char_u *)NULL, PV_NONE,
709 {(char_u *)0L, (char_u *)0L}
710 #endif
711 SCRIPTID_INIT},
712 {"cedit", NULL, P_STRING,
713 #ifdef FEAT_CMDWIN
714 (char_u *)&p_cedit, PV_NONE,
715 {(char_u *)"", (char_u *)CTRL_F_STR}
716 #else
717 (char_u *)NULL, PV_NONE,
718 {(char_u *)0L, (char_u *)0L}
719 #endif
720 SCRIPTID_INIT},
721 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
722 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
723 (char_u *)&p_ccv, PV_NONE,
724 {(char_u *)"", (char_u *)0L}
725 #else
726 (char_u *)NULL, PV_NONE,
727 {(char_u *)0L, (char_u *)0L}
728 #endif
729 SCRIPTID_INIT},
730 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
731 #ifdef FEAT_CINDENT
732 (char_u *)&p_cin, PV_CIN,
733 #else
734 (char_u *)NULL, PV_NONE,
735 #endif
736 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
737 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
738 #ifdef FEAT_CINDENT
739 (char_u *)&p_cink, PV_CINK,
740 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
741 #else
742 (char_u *)NULL, PV_NONE,
743 {(char_u *)0L, (char_u *)0L}
744 #endif
745 SCRIPTID_INIT},
746 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
747 #ifdef FEAT_CINDENT
748 (char_u *)&p_cino, PV_CINO,
749 #else
750 (char_u *)NULL, PV_NONE,
751 #endif
752 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
753 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
754 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
755 (char_u *)&p_cinw, PV_CINW,
756 {(char_u *)"if,else,while,do,for,switch",
757 (char_u *)0L}
758 #else
759 (char_u *)NULL, PV_NONE,
760 {(char_u *)0L, (char_u *)0L}
761 #endif
762 SCRIPTID_INIT},
763 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
764 #ifdef FEAT_CLIPBOARD
765 (char_u *)&p_cb, PV_NONE,
766 # ifdef FEAT_XCLIPBOARD
767 {(char_u *)"autoselect,exclude:cons\\|linux",
768 (char_u *)0L}
769 # else
770 {(char_u *)"", (char_u *)0L}
771 # endif
772 #else
773 (char_u *)NULL, PV_NONE,
774 {(char_u *)"", (char_u *)0L}
775 #endif
776 SCRIPTID_INIT},
777 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
778 (char_u *)&p_ch, PV_NONE,
779 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
780 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
781 #ifdef FEAT_CMDWIN
782 (char_u *)&p_cwh, PV_NONE,
783 #else
784 (char_u *)NULL, PV_NONE,
785 #endif
786 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
787 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
788 (char_u *)&Columns, PV_NONE,
789 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
790 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
791 #ifdef FEAT_COMMENTS
792 (char_u *)&p_com, PV_COM,
793 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
794 (char_u *)0L}
795 #else
796 (char_u *)NULL, PV_NONE,
797 {(char_u *)0L, (char_u *)0L}
798 #endif
799 SCRIPTID_INIT},
800 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
801 #ifdef FEAT_FOLDING
802 (char_u *)&p_cms, PV_CMS,
803 {(char_u *)"/*%s*/", (char_u *)0L}
804 #else
805 (char_u *)NULL, PV_NONE,
806 {(char_u *)0L, (char_u *)0L}
807 #endif
808 SCRIPTID_INIT},
809 /* P_PRI_MKRC isn't needed here, optval_default()
810 * always returns TRUE for 'compatible' */
811 {"compatible", "cp", P_BOOL|P_RALL,
812 (char_u *)&p_cp, PV_NONE,
813 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
814 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
815 #ifdef FEAT_INS_EXPAND
816 (char_u *)&p_cpt, PV_CPT,
817 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
818 #else
819 (char_u *)NULL, PV_NONE,
820 {(char_u *)0L, (char_u *)0L}
821 #endif
822 SCRIPTID_INIT},
823 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
824 #ifdef FEAT_COMPL_FUNC
825 (char_u *)&p_cfu, PV_CFU,
826 {(char_u *)"", (char_u *)0L}
827 #else
828 (char_u *)NULL, PV_NONE,
829 {(char_u *)0L, (char_u *)0L}
830 #endif
831 SCRIPTID_INIT},
832 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
833 #ifdef FEAT_INS_EXPAND
834 (char_u *)&p_cot, PV_NONE,
835 {(char_u *)"menu,preview", (char_u *)0L}
836 #else
837 (char_u *)NULL, PV_NONE,
838 {(char_u *)0L, (char_u *)0L}
839 #endif
840 SCRIPTID_INIT},
841 {"confirm", "cf", P_BOOL|P_VI_DEF,
842 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
843 (char_u *)&p_confirm, PV_NONE,
844 #else
845 (char_u *)NULL, PV_NONE,
846 #endif
847 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
848 {"conskey", "consk",P_BOOL|P_VI_DEF,
849 #ifdef MSDOS
850 (char_u *)&p_consk, PV_NONE,
851 #else
852 (char_u *)NULL, PV_NONE,
853 #endif
854 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
855 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
856 (char_u *)&p_ci, PV_CI,
857 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
858 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
859 (char_u *)&p_cpo, PV_NONE,
860 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
861 SCRIPTID_INIT},
862 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
863 #ifdef FEAT_CSCOPE
864 (char_u *)&p_cspc, PV_NONE,
865 #else
866 (char_u *)NULL, PV_NONE,
867 #endif
868 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
869 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
870 #ifdef FEAT_CSCOPE
871 (char_u *)&p_csprg, PV_NONE,
872 {(char_u *)"cscope", (char_u *)0L}
873 #else
874 (char_u *)NULL, PV_NONE,
875 {(char_u *)0L, (char_u *)0L}
876 #endif
877 SCRIPTID_INIT},
878 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
879 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
880 (char_u *)&p_csqf, PV_NONE,
881 {(char_u *)"", (char_u *)0L}
882 #else
883 (char_u *)NULL, PV_NONE,
884 {(char_u *)0L, (char_u *)0L}
885 #endif
886 SCRIPTID_INIT},
887 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
888 #ifdef FEAT_CSCOPE
889 (char_u *)&p_cst, PV_NONE,
890 #else
891 (char_u *)NULL, PV_NONE,
892 #endif
893 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
894 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
895 #ifdef FEAT_CSCOPE
896 (char_u *)&p_csto, PV_NONE,
897 #else
898 (char_u *)NULL, PV_NONE,
899 #endif
900 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
901 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
902 #ifdef FEAT_CSCOPE
903 (char_u *)&p_csverbose, PV_NONE,
904 #else
905 (char_u *)NULL, PV_NONE,
906 #endif
907 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
908 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
909 #ifdef FEAT_SYN_HL
910 (char_u *)VAR_WIN, PV_CUC,
911 #else
912 (char_u *)NULL, PV_NONE,
913 #endif
914 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
915 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
916 #ifdef FEAT_SYN_HL
917 (char_u *)VAR_WIN, PV_CUL,
918 #else
919 (char_u *)NULL, PV_NONE,
920 #endif
921 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
922 {"debug", NULL, P_STRING|P_VI_DEF,
923 (char_u *)&p_debug, PV_NONE,
924 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
925 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF,
926 #ifdef FEAT_FIND_ID
927 (char_u *)&p_def, PV_DEF,
928 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
929 #else
930 (char_u *)NULL, PV_NONE,
931 {(char_u *)NULL, (char_u *)0L}
932 #endif
933 SCRIPTID_INIT},
934 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
935 #ifdef FEAT_MBYTE
936 (char_u *)&p_deco, PV_NONE,
937 #else
938 (char_u *)NULL, PV_NONE,
939 #endif
940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
941 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
942 #ifdef FEAT_INS_EXPAND
943 (char_u *)&p_dict, PV_DICT,
944 #else
945 (char_u *)NULL, PV_NONE,
946 #endif
947 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
948 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
949 #ifdef FEAT_DIFF
950 (char_u *)VAR_WIN, PV_DIFF,
951 #else
952 (char_u *)NULL, PV_NONE,
953 #endif
954 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
955 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE,
956 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
957 (char_u *)&p_dex, PV_NONE,
958 {(char_u *)"", (char_u *)0L}
959 #else
960 (char_u *)NULL, PV_NONE,
961 {(char_u *)0L, (char_u *)0L}
962 #endif
963 SCRIPTID_INIT},
964 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
965 #ifdef FEAT_DIFF
966 (char_u *)&p_dip, PV_NONE,
967 {(char_u *)"filler", (char_u *)NULL}
968 #else
969 (char_u *)NULL, PV_NONE,
970 {(char_u *)"", (char_u *)NULL}
971 #endif
972 SCRIPTID_INIT},
973 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
974 #ifdef FEAT_DIGRAPHS
975 (char_u *)&p_dg, PV_NONE,
976 #else
977 (char_u *)NULL, PV_NONE,
978 #endif
979 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
980 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
981 (char_u *)&p_dir, PV_NONE,
982 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
983 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
984 (char_u *)&p_dy, PV_NONE,
985 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
986 {"eadirection", "ead", P_STRING|P_VI_DEF,
987 #ifdef FEAT_VERTSPLIT
988 (char_u *)&p_ead, PV_NONE,
989 {(char_u *)"both", (char_u *)0L}
990 #else
991 (char_u *)NULL, PV_NONE,
992 {(char_u *)NULL, (char_u *)0L}
993 #endif
994 SCRIPTID_INIT},
995 {"edcompatible","ed", P_BOOL|P_VI_DEF,
996 (char_u *)&p_ed, PV_NONE,
997 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
998 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR,
999 #ifdef FEAT_MBYTE
1000 (char_u *)&p_enc, PV_NONE,
1001 {(char_u *)ENC_DFLT, (char_u *)0L}
1002 #else
1003 (char_u *)NULL, PV_NONE,
1004 {(char_u *)0L, (char_u *)0L}
1005 #endif
1006 SCRIPTID_INIT},
1007 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1008 (char_u *)&p_eol, PV_EOL,
1009 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1010 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1011 (char_u *)&p_ea, PV_NONE,
1012 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1013 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1014 (char_u *)&p_ep, PV_EP,
1015 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1016 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1017 (char_u *)&p_eb, PV_NONE,
1018 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1019 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1020 #ifdef FEAT_QUICKFIX
1021 (char_u *)&p_ef, PV_NONE,
1022 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1023 #else
1024 (char_u *)NULL, PV_NONE,
1025 {(char_u *)NULL, (char_u *)0L}
1026 #endif
1027 SCRIPTID_INIT},
1028 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1029 #ifdef FEAT_QUICKFIX
1030 (char_u *)&p_efm, PV_EFM,
1031 {(char_u *)DFLT_EFM, (char_u *)0L}
1032 #else
1033 (char_u *)NULL, PV_NONE,
1034 {(char_u *)NULL, (char_u *)0L}
1035 #endif
1036 SCRIPTID_INIT},
1037 {"esckeys", "ek", P_BOOL|P_VIM,
1038 (char_u *)&p_ek, PV_NONE,
1039 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
1040 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1041 #ifdef FEAT_AUTOCMD
1042 (char_u *)&p_ei, PV_NONE,
1043 #else
1044 (char_u *)NULL, PV_NONE,
1045 #endif
1046 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1047 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1048 (char_u *)&p_et, PV_ET,
1049 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1050 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1051 (char_u *)&p_exrc, PV_NONE,
1052 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1053 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
1054 #ifdef FEAT_MBYTE
1055 (char_u *)&p_fenc, PV_FENC,
1056 {(char_u *)"", (char_u *)0L}
1057 #else
1058 (char_u *)NULL, PV_NONE,
1059 {(char_u *)0L, (char_u *)0L}
1060 #endif
1061 SCRIPTID_INIT},
1062 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
1063 #ifdef FEAT_MBYTE
1064 (char_u *)&p_fencs, PV_NONE,
1065 {(char_u *)"ucs-bom", (char_u *)0L}
1066 #else
1067 (char_u *)NULL, PV_NONE,
1068 {(char_u *)0L, (char_u *)0L}
1069 #endif
1070 SCRIPTID_INIT},
1071 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC,
1072 (char_u *)&p_ff, PV_FF,
1073 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
1074 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
1075 (char_u *)&p_ffs, PV_NONE,
1076 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1077 SCRIPTID_INIT},
1078 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
1079 #ifdef FEAT_AUTOCMD
1080 (char_u *)&p_ft, PV_FT,
1081 {(char_u *)"", (char_u *)0L}
1082 #else
1083 (char_u *)NULL, PV_NONE,
1084 {(char_u *)0L, (char_u *)0L}
1085 #endif
1086 SCRIPTID_INIT},
1087 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1088 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1089 (char_u *)&p_fcs, PV_NONE,
1090 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1091 #else
1092 (char_u *)NULL, PV_NONE,
1093 {(char_u *)"", (char_u *)0L}
1094 #endif
1095 SCRIPTID_INIT},
1096 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1097 #ifdef FEAT_FKMAP
1098 (char_u *)&p_fkmap, PV_NONE,
1099 #else
1100 (char_u *)NULL, PV_NONE,
1101 #endif
1102 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1103 {"flash", "fl", P_BOOL|P_VI_DEF,
1104 (char_u *)NULL, PV_NONE,
1105 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1106 #ifdef FEAT_FOLDING
1107 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
1108 (char_u *)&p_fcl, PV_NONE,
1109 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1110 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1111 (char_u *)VAR_WIN, PV_FDC,
1112 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1113 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1114 (char_u *)VAR_WIN, PV_FEN,
1115 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1116 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1117 # ifdef FEAT_EVAL
1118 (char_u *)VAR_WIN, PV_FDE,
1119 {(char_u *)"0", (char_u *)NULL}
1120 # else
1121 (char_u *)NULL, PV_NONE,
1122 {(char_u *)NULL, (char_u *)0L}
1123 # endif
1124 SCRIPTID_INIT},
1125 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1126 (char_u *)VAR_WIN, PV_FDI,
1127 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
1128 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1129 (char_u *)VAR_WIN, PV_FDL,
1130 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
1131 {"foldlevelstart","fdls", P_NUM|P_VI_DEF,
1132 (char_u *)&p_fdls, PV_NONE,
1133 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
1134 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
1135 P_RWIN|P_COMMA|P_NODUP,
1136 (char_u *)VAR_WIN, PV_FMR,
1137 {(char_u *)"{{{,}}}", (char_u *)NULL}
1138 SCRIPTID_INIT},
1139 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1140 (char_u *)VAR_WIN, PV_FDM,
1141 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
1142 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1143 (char_u *)VAR_WIN, PV_FML,
1144 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
1145 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1146 (char_u *)VAR_WIN, PV_FDN,
1147 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
1148 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1149 (char_u *)&p_fdo, PV_NONE,
1150 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1151 (char_u *)0L} SCRIPTID_INIT},
1152 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1153 # ifdef FEAT_EVAL
1154 (char_u *)VAR_WIN, PV_FDT,
1155 {(char_u *)"foldtext()", (char_u *)NULL}
1156 # else
1157 (char_u *)NULL, PV_NONE,
1158 {(char_u *)NULL, (char_u *)0L}
1159 # endif
1160 SCRIPTID_INIT},
1161 #endif
1162 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1163 #ifdef FEAT_EVAL
1164 (char_u *)&p_fex, PV_FEX,
1165 {(char_u *)"", (char_u *)0L}
1166 #else
1167 (char_u *)NULL, PV_NONE,
1168 {(char_u *)0L, (char_u *)0L}
1169 #endif
1170 SCRIPTID_INIT},
1171 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1172 (char_u *)&p_fo, PV_FO,
1173 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1174 SCRIPTID_INIT},
1175 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1176 (char_u *)&p_flp, PV_FLP,
1177 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1178 (char_u *)0L} SCRIPTID_INIT},
1179 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1180 (char_u *)&p_fp, PV_NONE,
1181 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1182 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1183 #ifdef HAVE_FSYNC
1184 (char_u *)&p_fs, PV_NONE,
1185 {(char_u *)TRUE, (char_u *)0L}
1186 #else
1187 (char_u *)NULL, PV_NONE,
1188 {(char_u *)FALSE, (char_u *)0L}
1189 #endif
1190 SCRIPTID_INIT},
1191 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1192 (char_u *)&p_gd, PV_NONE,
1193 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1194 {"graphic", "gr", P_BOOL|P_VI_DEF,
1195 (char_u *)NULL, PV_NONE,
1196 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1197 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1198 #ifdef FEAT_QUICKFIX
1199 (char_u *)&p_gefm, PV_NONE,
1200 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
1201 #else
1202 (char_u *)NULL, PV_NONE,
1203 {(char_u *)NULL, (char_u *)0L}
1204 #endif
1205 SCRIPTID_INIT},
1206 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1207 #ifdef FEAT_QUICKFIX
1208 (char_u *)&p_gp, PV_GP,
1210 # ifdef WIN3264
1211 /* may be changed to "grep -n" in os_win32.c */
1212 (char_u *)"findstr /n",
1213 # else
1214 # ifdef UNIX
1215 /* Add an extra file name so that grep will always
1216 * insert a file name in the match line. */
1217 (char_u *)"grep -n $* /dev/null",
1218 # else
1219 # ifdef VMS
1220 (char_u *)"SEARCH/NUMBERS ",
1221 # else
1222 (char_u *)"grep -n ",
1223 # endif
1224 # endif
1225 # endif
1226 (char_u *)0L}
1227 #else
1228 (char_u *)NULL, PV_NONE,
1229 {(char_u *)NULL, (char_u *)0L}
1230 #endif
1231 SCRIPTID_INIT},
1232 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1233 #ifdef CURSOR_SHAPE
1234 (char_u *)&p_guicursor, PV_NONE,
1236 # ifdef FEAT_GUI
1237 (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",
1238 # else /* MSDOS or Win32 console */
1239 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1240 # endif
1241 (char_u *)0L}
1242 #else
1243 (char_u *)NULL, PV_NONE,
1244 {(char_u *)NULL, (char_u *)0L}
1245 #endif
1246 SCRIPTID_INIT},
1247 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1248 #ifdef FEAT_GUI
1249 (char_u *)&p_guifont, PV_NONE,
1250 {(char_u *)"", (char_u *)0L}
1251 #else
1252 (char_u *)NULL, PV_NONE,
1253 {(char_u *)NULL, (char_u *)0L}
1254 #endif
1255 SCRIPTID_INIT},
1256 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
1257 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1258 (char_u *)&p_guifontset, PV_NONE,
1259 {(char_u *)"", (char_u *)0L}
1260 #else
1261 (char_u *)NULL, PV_NONE,
1262 {(char_u *)NULL, (char_u *)0L}
1263 #endif
1264 SCRIPTID_INIT},
1265 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1266 #if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1267 (char_u *)&p_guifontwide, PV_NONE,
1268 {(char_u *)"", (char_u *)0L}
1269 #else
1270 (char_u *)NULL, PV_NONE,
1271 {(char_u *)NULL, (char_u *)0L}
1272 #endif
1273 SCRIPTID_INIT},
1274 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
1275 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
1276 (char_u *)&p_ghr, PV_NONE,
1277 #else
1278 (char_u *)NULL, PV_NONE,
1279 #endif
1280 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
1281 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
1282 #if defined(FEAT_GUI)
1283 (char_u *)&p_go, PV_NONE,
1284 # if defined(UNIX) && !defined(MACOS)
1285 {(char_u *)"aegimrLtT", (char_u *)0L}
1286 # else
1287 {(char_u *)"egmrLtT", (char_u *)0L}
1288 # endif
1289 #else
1290 (char_u *)NULL, PV_NONE,
1291 {(char_u *)NULL, (char_u *)0L}
1292 #endif
1293 SCRIPTID_INIT},
1294 {"guipty", NULL, P_BOOL|P_VI_DEF,
1295 #if defined(FEAT_GUI)
1296 (char_u *)&p_guipty, PV_NONE,
1297 #else
1298 (char_u *)NULL, PV_NONE,
1299 #endif
1300 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1301 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
1302 #if defined(FEAT_GUI_TABLINE)
1303 (char_u *)&p_gtl, PV_NONE,
1304 {(char_u *)"", (char_u *)0L}
1305 #else
1306 (char_u *)NULL, PV_NONE,
1307 {(char_u *)NULL, (char_u *)0L}
1308 #endif
1309 SCRIPTID_INIT},
1310 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
1311 #if defined(FEAT_GUI_TABLINE)
1312 (char_u *)&p_gtt, PV_NONE,
1313 {(char_u *)"", (char_u *)0L}
1314 #else
1315 (char_u *)NULL, PV_NONE,
1316 {(char_u *)NULL, (char_u *)0L}
1317 #endif
1318 SCRIPTID_INIT},
1319 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1320 (char_u *)NULL, PV_NONE,
1321 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
1322 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1323 (char_u *)&p_hf, PV_NONE,
1324 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1325 SCRIPTID_INIT},
1326 {"helpheight", "hh", P_NUM|P_VI_DEF,
1327 #ifdef FEAT_WINDOWS
1328 (char_u *)&p_hh, PV_NONE,
1329 #else
1330 (char_u *)NULL, PV_NONE,
1331 #endif
1332 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
1333 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
1334 #ifdef FEAT_MULTI_LANG
1335 (char_u *)&p_hlg, PV_NONE,
1336 {(char_u *)"", (char_u *)0L}
1337 #else
1338 (char_u *)NULL, PV_NONE,
1339 {(char_u *)0L, (char_u *)0L}
1340 #endif
1341 SCRIPTID_INIT},
1342 {"hidden", "hid", P_BOOL|P_VI_DEF,
1343 (char_u *)&p_hid, PV_NONE,
1344 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1345 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1346 (char_u *)&p_hl, PV_NONE,
1347 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1348 SCRIPTID_INIT},
1349 {"history", "hi", P_NUM|P_VIM,
1350 (char_u *)&p_hi, PV_NONE,
1351 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
1352 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1353 #ifdef FEAT_RIGHTLEFT
1354 (char_u *)&p_hkmap, PV_NONE,
1355 #else
1356 (char_u *)NULL, PV_NONE,
1357 #endif
1358 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1359 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1360 #ifdef FEAT_RIGHTLEFT
1361 (char_u *)&p_hkmapp, PV_NONE,
1362 #else
1363 (char_u *)NULL, PV_NONE,
1364 #endif
1365 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1366 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1367 (char_u *)&p_hls, PV_NONE,
1368 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1369 {"icon", NULL, P_BOOL|P_VI_DEF,
1370 #ifdef FEAT_TITLE
1371 (char_u *)&p_icon, PV_NONE,
1372 #else
1373 (char_u *)NULL, PV_NONE,
1374 #endif
1375 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1376 {"iconstring", NULL, P_STRING|P_VI_DEF,
1377 #ifdef FEAT_TITLE
1378 (char_u *)&p_iconstring, PV_NONE,
1379 #else
1380 (char_u *)NULL, PV_NONE,
1381 #endif
1382 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1383 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1384 (char_u *)&p_ic, PV_NONE,
1385 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1386 {"imactivatekey","imak",P_STRING|P_VI_DEF,
1387 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1388 (char_u *)&p_imak, PV_NONE,
1389 #else
1390 (char_u *)NULL, PV_NONE,
1391 #endif
1392 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1393 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1394 #ifdef USE_IM_CONTROL
1395 (char_u *)&p_imcmdline, PV_NONE,
1396 #else
1397 (char_u *)NULL, PV_NONE,
1398 #endif
1399 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1400 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1401 #ifdef USE_IM_CONTROL
1402 (char_u *)&p_imdisable, PV_NONE,
1403 #else
1404 (char_u *)NULL, PV_NONE,
1405 #endif
1406 #ifdef __sgi
1407 {(char_u *)TRUE, (char_u *)0L}
1408 #else
1409 {(char_u *)FALSE, (char_u *)0L}
1410 #endif
1411 SCRIPTID_INIT},
1412 {"iminsert", "imi", P_NUM|P_VI_DEF,
1413 (char_u *)&p_iminsert, PV_IMI,
1414 #ifdef B_IMODE_IM
1415 {(char_u *)B_IMODE_IM, (char_u *)0L}
1416 #else
1417 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1418 #endif
1419 SCRIPTID_INIT},
1420 {"imsearch", "ims", P_NUM|P_VI_DEF,
1421 (char_u *)&p_imsearch, PV_IMS,
1422 #ifdef B_IMODE_IM
1423 {(char_u *)B_IMODE_IM, (char_u *)0L}
1424 #else
1425 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1426 #endif
1427 SCRIPTID_INIT},
1428 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1429 #ifdef FEAT_FIND_ID
1430 (char_u *)&p_inc, PV_INC,
1431 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1432 #else
1433 (char_u *)NULL, PV_NONE,
1434 {(char_u *)0L, (char_u *)0L}
1435 #endif
1436 SCRIPTID_INIT},
1437 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1438 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1439 (char_u *)&p_inex, PV_INEX,
1440 {(char_u *)"", (char_u *)0L}
1441 #else
1442 (char_u *)NULL, PV_NONE,
1443 {(char_u *)0L, (char_u *)0L}
1444 #endif
1445 SCRIPTID_INIT},
1446 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1447 (char_u *)&p_is, PV_NONE,
1448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1449 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1450 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1451 (char_u *)&p_inde, PV_INDE,
1452 {(char_u *)"", (char_u *)0L}
1453 #else
1454 (char_u *)NULL, PV_NONE,
1455 {(char_u *)0L, (char_u *)0L}
1456 #endif
1457 SCRIPTID_INIT},
1458 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1459 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1460 (char_u *)&p_indk, PV_INDK,
1461 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1462 #else
1463 (char_u *)NULL, PV_NONE,
1464 {(char_u *)0L, (char_u *)0L}
1465 #endif
1466 SCRIPTID_INIT},
1467 {"infercase", "inf", P_BOOL|P_VI_DEF,
1468 (char_u *)&p_inf, PV_INF,
1469 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1470 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1471 (char_u *)&p_im, PV_NONE,
1472 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1473 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1474 (char_u *)&p_isf, PV_NONE,
1476 #ifdef BACKSLASH_IN_FILENAME
1477 /* Excluded are: & and ^ are special in cmd.exe
1478 * ( and ) are used in text separating fnames */
1479 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1480 #else
1481 # ifdef AMIGA
1482 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1483 # else
1484 # ifdef VMS
1485 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1486 # else /* UNIX et al. */
1487 # ifdef EBCDIC
1488 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1489 # else
1490 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1491 # endif
1492 # endif
1493 # endif
1494 #endif
1495 (char_u *)0L} SCRIPTID_INIT},
1496 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1497 (char_u *)&p_isi, PV_NONE,
1499 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1500 (char_u *)"@,48-57,_,128-167,224-235",
1501 #else
1502 # ifdef EBCDIC
1503 /* TODO: EBCDIC Check this! @ == isalpha()*/
1504 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1505 "112-120,128,140-142,156,158,172,"
1506 "174,186,191,203-207,219-225,235-239,"
1507 "251-254",
1508 # else
1509 (char_u *)"@,48-57,_,192-255",
1510 # endif
1511 #endif
1512 (char_u *)0L} SCRIPTID_INIT},
1513 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1514 (char_u *)&p_isk, PV_ISK,
1516 #ifdef EBCDIC
1517 (char_u *)"@,240-249,_",
1518 /* TODO: EBCDIC Check this! @ == isalpha()*/
1519 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1520 "112-120,128,140-142,156,158,172,"
1521 "174,186,191,203-207,219-225,235-239,"
1522 "251-254",
1523 #else
1524 (char_u *)"@,48-57,_",
1525 # if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1526 (char_u *)"@,48-57,_,128-167,224-235"
1527 # else
1528 ISK_LATIN1
1529 # endif
1530 #endif
1531 } SCRIPTID_INIT},
1532 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1533 (char_u *)&p_isp, PV_NONE,
1535 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1536 || (defined(MACOS) && !defined(MACOS_X)) \
1537 || defined(VMS)
1538 (char_u *)"@,~-255",
1539 #else
1540 # ifdef EBCDIC
1541 /* all chars above 63 are printable */
1542 (char_u *)"63-255",
1543 # else
1544 ISP_LATIN1,
1545 # endif
1546 #endif
1547 (char_u *)0L} SCRIPTID_INIT},
1548 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1549 (char_u *)&p_js, PV_NONE,
1550 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1551 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1552 #ifdef FEAT_CRYPT
1553 (char_u *)&p_key, PV_KEY,
1554 {(char_u *)"", (char_u *)0L}
1555 #else
1556 (char_u *)NULL, PV_NONE,
1557 {(char_u *)0L, (char_u *)0L}
1558 #endif
1559 SCRIPTID_INIT},
1560 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
1561 #ifdef FEAT_KEYMAP
1562 (char_u *)&p_keymap, PV_KMAP,
1563 {(char_u *)"", (char_u *)0L}
1564 #else
1565 (char_u *)NULL, PV_NONE,
1566 {(char_u *)"", (char_u *)0L}
1567 #endif
1568 SCRIPTID_INIT},
1569 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1570 #ifdef FEAT_VISUAL
1571 (char_u *)&p_km, PV_NONE,
1572 #else
1573 (char_u *)NULL, PV_NONE,
1574 #endif
1575 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1576 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1577 (char_u *)&p_kp, PV_KP,
1579 #if defined(MSDOS) || defined(MSWIN)
1580 (char_u *)":help",
1581 #else
1582 #ifdef VMS
1583 (char_u *)"help",
1584 #else
1585 # if defined(OS2)
1586 (char_u *)"view /",
1587 # else
1588 # ifdef USEMAN_S
1589 (char_u *)"man -s",
1590 # else
1591 (char_u *)"man",
1592 # endif
1593 # endif
1594 #endif
1595 #endif
1596 (char_u *)0L} SCRIPTID_INIT},
1597 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1598 #ifdef FEAT_LANGMAP
1599 (char_u *)&p_langmap, PV_NONE,
1600 {(char_u *)"", /* unmatched } */
1601 #else
1602 (char_u *)NULL, PV_NONE,
1603 {(char_u *)NULL,
1604 #endif
1605 (char_u *)0L} SCRIPTID_INIT},
1606 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
1607 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1608 (char_u *)&p_lm, PV_NONE,
1609 #else
1610 (char_u *)NULL, PV_NONE,
1611 #endif
1612 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1613 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1614 #ifdef FEAT_WINDOWS
1615 (char_u *)&p_ls, PV_NONE,
1616 #else
1617 (char_u *)NULL, PV_NONE,
1618 #endif
1619 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
1620 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1621 (char_u *)&p_lz, PV_NONE,
1622 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1623 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1624 #ifdef FEAT_LINEBREAK
1625 (char_u *)VAR_WIN, PV_LBR,
1626 #else
1627 (char_u *)NULL, PV_NONE,
1628 #endif
1629 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1630 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1631 (char_u *)&Rows, PV_NONE,
1633 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1634 (char_u *)25L,
1635 #else
1636 (char_u *)24L,
1637 #endif
1638 (char_u *)0L} SCRIPTID_INIT},
1639 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1640 #ifdef FEAT_GUI
1641 (char_u *)&p_linespace, PV_NONE,
1642 #else
1643 (char_u *)NULL, PV_NONE,
1644 #endif
1645 #ifdef FEAT_GUI_W32
1646 {(char_u *)1L, (char_u *)0L}
1647 #else
1648 {(char_u *)0L, (char_u *)0L}
1649 #endif
1650 SCRIPTID_INIT},
1651 {"lisp", NULL, P_BOOL|P_VI_DEF,
1652 #ifdef FEAT_LISP
1653 (char_u *)&p_lisp, PV_LISP,
1654 #else
1655 (char_u *)NULL, PV_NONE,
1656 #endif
1657 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1658 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1659 #ifdef FEAT_LISP
1660 (char_u *)&p_lispwords, PV_NONE,
1661 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1662 #else
1663 (char_u *)NULL, PV_NONE,
1664 {(char_u *)"", (char_u *)0L}
1665 #endif
1666 SCRIPTID_INIT},
1667 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1668 (char_u *)VAR_WIN, PV_LIST,
1669 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1670 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1671 (char_u *)&p_lcs, PV_NONE,
1672 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
1673 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1674 (char_u *)&p_lpl, PV_NONE,
1675 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1676 #ifdef FEAT_GUI_MAC
1677 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1678 (char_u *)&p_macatsui, PV_NONE,
1679 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1680 #endif
1681 {"magic", NULL, P_BOOL|P_VI_DEF,
1682 (char_u *)&p_magic, PV_NONE,
1683 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1684 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1685 #ifdef FEAT_QUICKFIX
1686 (char_u *)&p_mef, PV_NONE,
1687 {(char_u *)"", (char_u *)0L}
1688 #else
1689 (char_u *)NULL, PV_NONE,
1690 {(char_u *)NULL, (char_u *)0L}
1691 #endif
1692 SCRIPTID_INIT},
1693 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1694 #ifdef FEAT_QUICKFIX
1695 (char_u *)&p_mp, PV_MP,
1696 # ifdef VMS
1697 {(char_u *)"MMS", (char_u *)0L}
1698 # else
1699 {(char_u *)"make", (char_u *)0L}
1700 # endif
1701 #else
1702 (char_u *)NULL, PV_NONE,
1703 {(char_u *)NULL, (char_u *)0L}
1704 #endif
1705 SCRIPTID_INIT},
1706 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1707 (char_u *)&p_mps, PV_MPS,
1708 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1709 SCRIPTID_INIT},
1710 {"matchtime", "mat", P_NUM|P_VI_DEF,
1711 (char_u *)&p_mat, PV_NONE,
1712 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
1713 {"maxcombine", "mco", P_NUM|P_VI_DEF,
1714 #ifdef FEAT_MBYTE
1715 (char_u *)&p_mco, PV_NONE,
1716 #else
1717 (char_u *)NULL, PV_NONE,
1718 #endif
1719 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
1720 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1721 #ifdef FEAT_EVAL
1722 (char_u *)&p_mfd, PV_NONE,
1723 #else
1724 (char_u *)NULL, PV_NONE,
1725 #endif
1726 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
1727 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1728 (char_u *)&p_mmd, PV_NONE,
1729 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
1730 {"maxmem", "mm", P_NUM|P_VI_DEF,
1731 (char_u *)&p_mm, PV_NONE,
1732 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1733 SCRIPTID_INIT},
1734 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1735 (char_u *)&p_mmp, PV_NONE,
1736 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
1737 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1738 (char_u *)&p_mmt, PV_NONE,
1739 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1740 SCRIPTID_INIT},
1741 {"menuitems", "mis", P_NUM|P_VI_DEF,
1742 #ifdef FEAT_MENU
1743 (char_u *)&p_mis, PV_NONE,
1744 #else
1745 (char_u *)NULL, PV_NONE,
1746 #endif
1747 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
1748 {"mesg", NULL, P_BOOL|P_VI_DEF,
1749 (char_u *)NULL, PV_NONE,
1750 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1751 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
1752 #ifdef FEAT_SPELL
1753 (char_u *)&p_msm, PV_NONE,
1754 {(char_u *)"460000,2000,500", (char_u *)0L}
1755 #else
1756 (char_u *)NULL, PV_NONE,
1757 {(char_u *)0L, (char_u *)0L}
1758 #endif
1759 SCRIPTID_INIT},
1760 {"modeline", "ml", P_BOOL|P_VIM,
1761 (char_u *)&p_ml, PV_ML,
1762 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
1763 {"modelines", "mls", P_NUM|P_VI_DEF,
1764 (char_u *)&p_mls, PV_NONE,
1765 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
1766 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1767 (char_u *)&p_ma, PV_MA,
1768 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1769 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1770 (char_u *)&p_mod, PV_MOD,
1771 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1772 {"more", NULL, P_BOOL|P_VIM,
1773 (char_u *)&p_more, PV_NONE,
1774 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
1775 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1776 (char_u *)&p_mouse, PV_NONE,
1778 #if defined(MSDOS) || defined(WIN3264)
1779 (char_u *)"a",
1780 #else
1781 (char_u *)"",
1782 #endif
1783 (char_u *)0L} SCRIPTID_INIT},
1784 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1785 #ifdef FEAT_GUI
1786 (char_u *)&p_mousef, PV_NONE,
1787 #else
1788 (char_u *)NULL, PV_NONE,
1789 #endif
1790 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1791 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1792 #ifdef FEAT_GUI
1793 (char_u *)&p_mh, PV_NONE,
1794 #else
1795 (char_u *)NULL, PV_NONE,
1796 #endif
1797 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1798 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1799 (char_u *)&p_mousem, PV_NONE,
1801 #if defined(MSDOS) || defined(MSWIN)
1802 (char_u *)"popup",
1803 #else
1804 # if defined(MACOS)
1805 (char_u *)"popup_setpos",
1806 # else
1807 (char_u *)"extend",
1808 # endif
1809 #endif
1810 (char_u *)0L} SCRIPTID_INIT},
1811 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1812 #ifdef FEAT_MOUSESHAPE
1813 (char_u *)&p_mouseshape, PV_NONE,
1814 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1815 #else
1816 (char_u *)NULL, PV_NONE,
1817 {(char_u *)NULL, (char_u *)0L}
1818 #endif
1819 SCRIPTID_INIT},
1820 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1821 (char_u *)&p_mouset, PV_NONE,
1822 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
1823 {"mzquantum", "mzq", P_NUM,
1824 #ifdef FEAT_MZSCHEME
1825 (char_u *)&p_mzq, PV_NONE,
1826 #else
1827 (char_u *)NULL, PV_NONE,
1828 #endif
1829 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
1830 {"novice", NULL, P_BOOL|P_VI_DEF,
1831 (char_u *)NULL, PV_NONE,
1832 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1833 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1834 (char_u *)&p_nf, PV_NF,
1835 {(char_u *)"octal,hex", (char_u *)0L}
1836 SCRIPTID_INIT},
1837 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1838 (char_u *)VAR_WIN, PV_NU,
1839 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1840 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1841 #ifdef FEAT_LINEBREAK
1842 (char_u *)VAR_WIN, PV_NUW,
1843 #else
1844 (char_u *)NULL, PV_NONE,
1845 #endif
1846 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
1847 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
1848 #ifdef FEAT_COMPL_FUNC
1849 (char_u *)&p_ofu, PV_OFU,
1850 {(char_u *)"", (char_u *)0L}
1851 #else
1852 (char_u *)NULL, PV_NONE,
1853 {(char_u *)0L, (char_u *)0L}
1854 #endif
1855 SCRIPTID_INIT},
1856 {"open", NULL, P_BOOL|P_VI_DEF,
1857 (char_u *)NULL, PV_NONE,
1858 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1859 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1860 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1861 (char_u *)&p_odev, PV_NONE,
1862 #else
1863 (char_u *)NULL, PV_NONE,
1864 #endif
1865 {(char_u *)FALSE, (char_u *)FALSE}
1866 SCRIPTID_INIT},
1867 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1868 (char_u *)&p_opfunc, PV_NONE,
1869 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1870 {"optimize", "opt", P_BOOL|P_VI_DEF,
1871 (char_u *)NULL, PV_NONE,
1872 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1873 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
1874 #ifdef FEAT_OSFILETYPE
1875 (char_u *)&p_oft, PV_OFT,
1876 {(char_u *)DFLT_OFT, (char_u *)0L}
1877 #else
1878 (char_u *)NULL, PV_NONE,
1879 {(char_u *)0L, (char_u *)0L}
1880 #endif
1881 SCRIPTID_INIT},
1882 {"paragraphs", "para", P_STRING|P_VI_DEF,
1883 (char_u *)&p_para, PV_NONE,
1884 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
1885 (char_u *)0L} SCRIPTID_INIT},
1886 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
1887 (char_u *)&p_paste, PV_NONE,
1888 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1889 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1890 (char_u *)&p_pt, PV_NONE,
1891 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1892 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1893 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1894 (char_u *)&p_pex, PV_NONE,
1895 {(char_u *)"", (char_u *)0L}
1896 #else
1897 (char_u *)NULL, PV_NONE,
1898 {(char_u *)0L, (char_u *)0L}
1899 #endif
1900 SCRIPTID_INIT},
1901 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
1902 (char_u *)&p_pm, PV_NONE,
1903 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1904 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
1905 (char_u *)&p_path, PV_PATH,
1907 #if defined AMIGA || defined MSDOS || defined MSWIN
1908 (char_u *)".,,",
1909 #else
1910 # if defined(__EMX__)
1911 (char_u *)".,/emx/include,,",
1912 # else /* Unix, probably */
1913 (char_u *)".,/usr/include,,",
1914 # endif
1915 #endif
1916 (char_u *)0L} SCRIPTID_INIT},
1917 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
1918 (char_u *)&p_pi, PV_PI,
1919 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1920 {"previewheight", "pvh", P_NUM|P_VI_DEF,
1921 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1922 (char_u *)&p_pvh, PV_NONE,
1923 #else
1924 (char_u *)NULL, PV_NONE,
1925 #endif
1926 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
1927 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
1928 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1929 (char_u *)VAR_WIN, PV_PVW,
1930 #else
1931 (char_u *)NULL, PV_NONE,
1932 #endif
1933 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1934 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
1935 #ifdef FEAT_PRINTER
1936 (char_u *)&p_pdev, PV_NONE,
1937 {(char_u *)"", (char_u *)0L}
1938 #else
1939 (char_u *)NULL, PV_NONE,
1940 {(char_u *)NULL, (char_u *)0L}
1941 #endif
1942 SCRIPTID_INIT},
1943 {"printencoding", "penc", P_STRING|P_VI_DEF,
1944 #ifdef FEAT_POSTSCRIPT
1945 (char_u *)&p_penc, PV_NONE,
1946 {(char_u *)"", (char_u *)0L}
1947 #else
1948 (char_u *)NULL, PV_NONE,
1949 {(char_u *)NULL, (char_u *)0L}
1950 #endif
1951 SCRIPTID_INIT},
1952 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
1953 #ifdef FEAT_POSTSCRIPT
1954 (char_u *)&p_pexpr, PV_NONE,
1955 {(char_u *)"", (char_u *)0L}
1956 #else
1957 (char_u *)NULL, PV_NONE,
1958 {(char_u *)NULL, (char_u *)0L}
1959 #endif
1960 SCRIPTID_INIT},
1961 {"printfont", "pfn", P_STRING|P_VI_DEF,
1962 #ifdef FEAT_PRINTER
1963 (char_u *)&p_pfn, PV_NONE,
1965 # ifdef MSWIN
1966 (char_u *)"Courier_New:h10",
1967 # else
1968 (char_u *)"courier",
1969 # endif
1970 (char_u *)0L}
1971 #else
1972 (char_u *)NULL, PV_NONE,
1973 {(char_u *)NULL, (char_u *)0L}
1974 #endif
1975 SCRIPTID_INIT},
1976 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
1977 #ifdef FEAT_PRINTER
1978 (char_u *)&p_header, PV_NONE,
1979 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
1980 #else
1981 (char_u *)NULL, PV_NONE,
1982 {(char_u *)NULL, (char_u *)0L}
1983 #endif
1984 SCRIPTID_INIT},
1985 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
1986 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
1987 (char_u *)&p_pmcs, PV_NONE,
1988 {(char_u *)"", (char_u *)0L}
1989 #else
1990 (char_u *)NULL, PV_NONE,
1991 {(char_u *)NULL, (char_u *)0L}
1992 #endif
1993 SCRIPTID_INIT},
1994 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
1995 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
1996 (char_u *)&p_pmfn, PV_NONE,
1997 {(char_u *)"", (char_u *)0L}
1998 #else
1999 (char_u *)NULL, PV_NONE,
2000 {(char_u *)NULL, (char_u *)0L}
2001 #endif
2002 SCRIPTID_INIT},
2003 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2004 #ifdef FEAT_PRINTER
2005 (char_u *)&p_popt, PV_NONE,
2006 {(char_u *)"", (char_u *)0L}
2007 #else
2008 (char_u *)NULL, PV_NONE,
2009 {(char_u *)NULL, (char_u *)0L}
2010 #endif
2011 SCRIPTID_INIT},
2012 {"prompt", NULL, P_BOOL|P_VI_DEF,
2013 (char_u *)&p_prompt, PV_NONE,
2014 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2015 {"pumheight", "ph", P_NUM|P_VI_DEF,
2016 #ifdef FEAT_INS_EXPAND
2017 (char_u *)&p_ph, PV_NONE,
2018 #else
2019 (char_u *)NULL, PV_NONE,
2020 #endif
2021 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2022 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2023 #ifdef FEAT_TEXTOBJ
2024 (char_u *)&p_qe, PV_QE,
2025 {(char_u *)"\\", (char_u *)0L}
2026 #else
2027 (char_u *)NULL, PV_NONE,
2028 {(char_u *)NULL, (char_u *)0L}
2029 #endif
2030 SCRIPTID_INIT},
2031 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2032 (char_u *)&p_ro, PV_RO,
2033 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2034 {"redraw", NULL, P_BOOL|P_VI_DEF,
2035 (char_u *)NULL, PV_NONE,
2036 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2037 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2038 #ifdef FEAT_RELTIME
2039 (char_u *)&p_rdt, PV_NONE,
2040 #else
2041 (char_u *)NULL, PV_NONE,
2042 #endif
2043 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
2044 {"remap", NULL, P_BOOL|P_VI_DEF,
2045 (char_u *)&p_remap, PV_NONE,
2046 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2047 {"report", NULL, P_NUM|P_VI_DEF,
2048 (char_u *)&p_report, PV_NONE,
2049 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
2050 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2051 #ifdef WIN3264
2052 (char_u *)&p_rs, PV_NONE,
2053 #else
2054 (char_u *)NULL, PV_NONE,
2055 #endif
2056 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2057 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2058 #ifdef FEAT_RIGHTLEFT
2059 (char_u *)&p_ri, PV_NONE,
2060 #else
2061 (char_u *)NULL, PV_NONE,
2062 #endif
2063 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2064 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2065 #ifdef FEAT_RIGHTLEFT
2066 (char_u *)VAR_WIN, PV_RL,
2067 #else
2068 (char_u *)NULL, PV_NONE,
2069 #endif
2070 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2071 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2072 #ifdef FEAT_RIGHTLEFT
2073 (char_u *)VAR_WIN, PV_RLC,
2074 {(char_u *)"search", (char_u *)NULL}
2075 #else
2076 (char_u *)NULL, PV_NONE,
2077 {(char_u *)NULL, (char_u *)0L}
2078 #endif
2079 SCRIPTID_INIT},
2080 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2081 #ifdef FEAT_CMDL_INFO
2082 (char_u *)&p_ru, PV_NONE,
2083 #else
2084 (char_u *)NULL, PV_NONE,
2085 #endif
2086 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2087 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2088 #ifdef FEAT_STL_OPT
2089 (char_u *)&p_ruf, PV_NONE,
2090 #else
2091 (char_u *)NULL, PV_NONE,
2092 #endif
2093 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2094 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
2095 (char_u *)&p_rtp, PV_NONE,
2096 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2097 SCRIPTID_INIT},
2098 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2099 (char_u *)VAR_WIN, PV_SCROLL,
2100 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
2101 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2102 #ifdef FEAT_SCROLLBIND
2103 (char_u *)VAR_WIN, PV_SCBIND,
2104 #else
2105 (char_u *)NULL, PV_NONE,
2106 #endif
2107 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2108 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2109 (char_u *)&p_sj, PV_NONE,
2110 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2111 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2112 (char_u *)&p_so, PV_NONE,
2113 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2114 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2115 #ifdef FEAT_SCROLLBIND
2116 (char_u *)&p_sbo, PV_NONE,
2117 {(char_u *)"ver,jump", (char_u *)0L}
2118 #else
2119 (char_u *)NULL, PV_NONE,
2120 {(char_u *)0L, (char_u *)0L}
2121 #endif
2122 SCRIPTID_INIT},
2123 {"sections", "sect", P_STRING|P_VI_DEF,
2124 (char_u *)&p_sections, PV_NONE,
2125 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2126 SCRIPTID_INIT},
2127 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2128 (char_u *)&p_secure, PV_NONE,
2129 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2130 {"selection", "sel", P_STRING|P_VI_DEF,
2131 #ifdef FEAT_VISUAL
2132 (char_u *)&p_sel, PV_NONE,
2133 #else
2134 (char_u *)NULL, PV_NONE,
2135 #endif
2136 {(char_u *)"inclusive", (char_u *)0L}
2137 SCRIPTID_INIT},
2138 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2139 #ifdef FEAT_VISUAL
2140 (char_u *)&p_slm, PV_NONE,
2141 #else
2142 (char_u *)NULL, PV_NONE,
2143 #endif
2144 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2145 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2146 #ifdef FEAT_SESSION
2147 (char_u *)&p_ssop, PV_NONE,
2148 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
2149 (char_u *)0L}
2150 #else
2151 (char_u *)NULL, PV_NONE,
2152 {(char_u *)0L, (char_u *)0L}
2153 #endif
2154 SCRIPTID_INIT},
2155 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2156 (char_u *)&p_sh, PV_NONE,
2158 #ifdef VMS
2159 (char_u *)"-",
2160 #else
2161 # if defined(MSDOS)
2162 (char_u *)"command",
2163 # else
2164 # if defined(WIN16)
2165 (char_u *)"command.com",
2166 # else
2167 # if defined(WIN3264)
2168 (char_u *)"", /* set in set_init_1() */
2169 # else
2170 # if defined(OS2)
2171 (char_u *)"cmd.exe",
2172 # else
2173 # if defined(ARCHIE)
2174 (char_u *)"gos",
2175 # else
2176 (char_u *)"sh",
2177 # endif
2178 # endif
2179 # endif
2180 # endif
2181 # endif
2182 #endif /* VMS */
2183 (char_u *)0L} SCRIPTID_INIT},
2184 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2185 (char_u *)&p_shcf, PV_NONE,
2187 #if defined(MSDOS) || defined(MSWIN)
2188 (char_u *)"/c",
2189 #else
2190 # if defined(OS2)
2191 (char_u *)"/c",
2192 # else
2193 (char_u *)"-c",
2194 # endif
2195 #endif
2196 (char_u *)0L} SCRIPTID_INIT},
2197 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2198 #ifdef FEAT_QUICKFIX
2199 (char_u *)&p_sp, PV_NONE,
2201 #if defined(UNIX) || defined(OS2)
2202 # ifdef ARCHIE
2203 (char_u *)"2>",
2204 # else
2205 (char_u *)"| tee",
2206 # endif
2207 #else
2208 (char_u *)">",
2209 #endif
2210 (char_u *)0L}
2211 #else
2212 (char_u *)NULL, PV_NONE,
2213 {(char_u *)0L, (char_u *)0L}
2214 #endif
2215 SCRIPTID_INIT},
2216 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2217 (char_u *)&p_shq, PV_NONE,
2218 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2219 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2220 (char_u *)&p_srr, PV_NONE,
2221 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
2222 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2223 #ifdef BACKSLASH_IN_FILENAME
2224 (char_u *)&p_ssl, PV_NONE,
2225 #else
2226 (char_u *)NULL, PV_NONE,
2227 #endif
2228 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2229 {"shelltemp", "stmp", P_BOOL,
2230 (char_u *)&p_stmp, PV_NONE,
2231 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
2232 {"shelltype", "st", P_NUM|P_VI_DEF,
2233 #ifdef AMIGA
2234 (char_u *)&p_st, PV_NONE,
2235 #else
2236 (char_u *)NULL, PV_NONE,
2237 #endif
2238 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2239 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2240 (char_u *)&p_sxq, PV_NONE,
2242 #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2243 (char_u *)"\"",
2244 #else
2245 (char_u *)"",
2246 #endif
2247 (char_u *)0L} SCRIPTID_INIT},
2248 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2249 (char_u *)&p_sr, PV_NONE,
2250 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2251 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2252 (char_u *)&p_sw, PV_SW,
2253 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
2254 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2255 (char_u *)&p_shm, PV_NONE,
2256 {(char_u *)"", (char_u *)"filnxtToO"}
2257 SCRIPTID_INIT},
2258 {"shortname", "sn", P_BOOL|P_VI_DEF,
2259 #ifdef SHORT_FNAME
2260 (char_u *)NULL, PV_NONE,
2261 #else
2262 (char_u *)&p_sn, PV_SN,
2263 #endif
2264 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2265 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2266 #ifdef FEAT_LINEBREAK
2267 (char_u *)&p_sbr, PV_NONE,
2268 #else
2269 (char_u *)NULL, PV_NONE,
2270 #endif
2271 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2272 {"showcmd", "sc", P_BOOL|P_VIM,
2273 #ifdef FEAT_CMDL_INFO
2274 (char_u *)&p_sc, PV_NONE,
2275 #else
2276 (char_u *)NULL, PV_NONE,
2277 #endif
2278 {(char_u *)FALSE,
2279 #ifdef UNIX
2280 (char_u *)FALSE
2281 #else
2282 (char_u *)TRUE
2283 #endif
2284 } SCRIPTID_INIT},
2285 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2286 (char_u *)&p_sft, PV_NONE,
2287 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2288 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2289 (char_u *)&p_sm, PV_NONE,
2290 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2291 {"showmode", "smd", P_BOOL|P_VIM,
2292 (char_u *)&p_smd, PV_NONE,
2293 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
2294 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2295 #ifdef FEAT_WINDOWS
2296 (char_u *)&p_stal, PV_NONE,
2297 #else
2298 (char_u *)NULL, PV_NONE,
2299 #endif
2300 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2301 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2302 (char_u *)&p_ss, PV_NONE,
2303 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2304 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2305 (char_u *)&p_siso, PV_NONE,
2306 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2307 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2308 (char_u *)NULL, PV_NONE,
2309 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2310 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2311 (char_u *)&p_scs, PV_NONE,
2312 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2313 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2314 #ifdef FEAT_SMARTINDENT
2315 (char_u *)&p_si, PV_SI,
2316 #else
2317 (char_u *)NULL, PV_NONE,
2318 #endif
2319 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2320 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2321 (char_u *)&p_sta, PV_NONE,
2322 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2323 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2324 (char_u *)&p_sts, PV_STS,
2325 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2326 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2327 (char_u *)NULL, PV_NONE,
2328 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2329 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2330 #ifdef FEAT_SPELL
2331 (char_u *)VAR_WIN, PV_SPELL,
2332 #else
2333 (char_u *)NULL, PV_NONE,
2334 #endif
2335 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2336 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
2337 #ifdef FEAT_SPELL
2338 (char_u *)&p_spc, PV_SPC,
2339 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
2340 #else
2341 (char_u *)NULL, PV_NONE,
2342 {(char_u *)0L, (char_u *)0L}
2343 #endif
2344 SCRIPTID_INIT},
2345 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
2346 #ifdef FEAT_SPELL
2347 (char_u *)&p_spf, PV_SPF,
2348 {(char_u *)"", (char_u *)0L}
2349 #else
2350 (char_u *)NULL, PV_NONE,
2351 {(char_u *)0L, (char_u *)0L}
2352 #endif
2353 SCRIPTID_INIT},
2354 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
2355 #ifdef FEAT_SPELL
2356 (char_u *)&p_spl, PV_SPL,
2357 {(char_u *)"en", (char_u *)0L}
2358 #else
2359 (char_u *)NULL, PV_NONE,
2360 {(char_u *)0L, (char_u *)0L}
2361 #endif
2362 SCRIPTID_INIT},
2363 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
2364 #ifdef FEAT_SPELL
2365 (char_u *)&p_sps, PV_NONE,
2366 {(char_u *)"best", (char_u *)0L}
2367 #else
2368 (char_u *)NULL, PV_NONE,
2369 {(char_u *)0L, (char_u *)0L}
2370 #endif
2371 SCRIPTID_INIT},
2372 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2373 #ifdef FEAT_WINDOWS
2374 (char_u *)&p_sb, PV_NONE,
2375 #else
2376 (char_u *)NULL, PV_NONE,
2377 #endif
2378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2379 {"splitright", "spr", P_BOOL|P_VI_DEF,
2380 #ifdef FEAT_VERTSPLIT
2381 (char_u *)&p_spr, PV_NONE,
2382 #else
2383 (char_u *)NULL, PV_NONE,
2384 #endif
2385 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2386 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2387 (char_u *)&p_sol, PV_NONE,
2388 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2389 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2390 #ifdef FEAT_STL_OPT
2391 (char_u *)&p_stl, PV_STL,
2392 #else
2393 (char_u *)NULL, PV_NONE,
2394 #endif
2395 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2396 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2397 (char_u *)&p_su, PV_NONE,
2398 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
2399 (char_u *)0L} SCRIPTID_INIT},
2400 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
2401 #ifdef FEAT_SEARCHPATH
2402 (char_u *)&p_sua, PV_SUA,
2403 {(char_u *)"", (char_u *)0L}
2404 #else
2405 (char_u *)NULL, PV_NONE,
2406 {(char_u *)0L, (char_u *)0L}
2407 #endif
2408 SCRIPTID_INIT},
2409 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2410 (char_u *)&p_swf, PV_SWF,
2411 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2412 {"swapsync", "sws", P_STRING|P_VI_DEF,
2413 (char_u *)&p_sws, PV_NONE,
2414 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
2415 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2416 (char_u *)&p_swb, PV_NONE,
2417 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2418 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2419 #ifdef FEAT_SYN_HL
2420 (char_u *)&p_smc, PV_SMC,
2421 {(char_u *)3000L, (char_u *)0L}
2422 #else
2423 (char_u *)NULL, PV_NONE,
2424 {(char_u *)0L, (char_u *)0L}
2425 #endif
2426 SCRIPTID_INIT},
2427 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
2428 #ifdef FEAT_SYN_HL
2429 (char_u *)&p_syn, PV_SYN,
2430 {(char_u *)"", (char_u *)0L}
2431 #else
2432 (char_u *)NULL, PV_NONE,
2433 {(char_u *)0L, (char_u *)0L}
2434 #endif
2435 SCRIPTID_INIT},
2436 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2437 #ifdef FEAT_STL_OPT
2438 (char_u *)&p_tal, PV_NONE,
2439 #else
2440 (char_u *)NULL, PV_NONE,
2441 #endif
2442 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2443 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2444 #ifdef FEAT_WINDOWS
2445 (char_u *)&p_tpm, PV_NONE,
2446 #else
2447 (char_u *)NULL, PV_NONE,
2448 #endif
2449 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
2450 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2451 (char_u *)&p_ts, PV_TS,
2452 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
2453 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2454 (char_u *)&p_tbs, PV_NONE,
2455 #ifdef VMS /* binary searching doesn't appear to work on VMS */
2456 {(char_u *)0L, (char_u *)0L}
2457 #else
2458 {(char_u *)TRUE, (char_u *)0L}
2459 #endif
2460 SCRIPTID_INIT},
2461 {"taglength", "tl", P_NUM|P_VI_DEF,
2462 (char_u *)&p_tl, PV_NONE,
2463 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2464 {"tagrelative", "tr", P_BOOL|P_VIM,
2465 (char_u *)&p_tr, PV_NONE,
2466 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
2467 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2468 (char_u *)&p_tags, PV_TAGS,
2470 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2471 (char_u *)"./tags,./TAGS,tags,TAGS",
2472 #else
2473 (char_u *)"./tags,tags",
2474 #endif
2475 (char_u *)0L} SCRIPTID_INIT},
2476 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2477 (char_u *)&p_tgst, PV_NONE,
2478 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2479 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2480 (char_u *)&T_NAME, PV_NONE,
2481 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2482 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2483 #ifdef FEAT_ARABIC
2484 (char_u *)&p_tbidi, PV_NONE,
2485 #else
2486 (char_u *)NULL, PV_NONE,
2487 #endif
2488 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2489 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2490 #ifdef FEAT_MBYTE
2491 (char_u *)&p_tenc, PV_NONE,
2492 {(char_u *)"", (char_u *)0L}
2493 #else
2494 (char_u *)NULL, PV_NONE,
2495 {(char_u *)0L, (char_u *)0L}
2496 #endif
2497 SCRIPTID_INIT},
2498 {"terse", NULL, P_BOOL|P_VI_DEF,
2499 (char_u *)&p_terse, PV_NONE,
2500 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2501 {"textauto", "ta", P_BOOL|P_VIM,
2502 (char_u *)&p_ta, PV_NONE,
2503 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2504 SCRIPTID_INIT},
2505 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2506 (char_u *)&p_tx, PV_TX,
2508 #ifdef USE_CRNL
2509 (char_u *)TRUE,
2510 #else
2511 (char_u *)FALSE,
2512 #endif
2513 (char_u *)0L} SCRIPTID_INIT},
2514 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM,
2515 (char_u *)&p_tw, PV_TW,
2516 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2517 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2518 #ifdef FEAT_INS_EXPAND
2519 (char_u *)&p_tsr, PV_TSR,
2520 #else
2521 (char_u *)NULL, PV_NONE,
2522 #endif
2523 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2524 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2525 (char_u *)&p_to, PV_NONE,
2526 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2527 {"timeout", "to", P_BOOL|P_VI_DEF,
2528 (char_u *)&p_timeout, PV_NONE,
2529 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2530 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2531 (char_u *)&p_tm, PV_NONE,
2532 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
2533 {"title", NULL, P_BOOL|P_VI_DEF,
2534 #ifdef FEAT_TITLE
2535 (char_u *)&p_title, PV_NONE,
2536 #else
2537 (char_u *)NULL, PV_NONE,
2538 #endif
2539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2540 {"titlelen", NULL, P_NUM|P_VI_DEF,
2541 #ifdef FEAT_TITLE
2542 (char_u *)&p_titlelen, PV_NONE,
2543 #else
2544 (char_u *)NULL, PV_NONE,
2545 #endif
2546 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
2547 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
2548 #ifdef FEAT_TITLE
2549 (char_u *)&p_titleold, PV_NONE,
2550 {(char_u *)N_("Thanks for flying Vim"),
2551 (char_u *)0L}
2552 #else
2553 (char_u *)NULL, PV_NONE,
2554 {(char_u *)0L, (char_u *)0L}
2555 #endif
2556 SCRIPTID_INIT},
2557 {"titlestring", NULL, P_STRING|P_VI_DEF,
2558 #ifdef FEAT_TITLE
2559 (char_u *)&p_titlestring, PV_NONE,
2560 #else
2561 (char_u *)NULL, PV_NONE,
2562 #endif
2563 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2564 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
2565 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
2566 (char_u *)&p_toolbar, PV_NONE,
2567 {(char_u *)"icons,tooltips", (char_u *)0L}
2568 SCRIPTID_INIT},
2569 #endif
2570 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
2571 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2572 (char_u *)&p_tbis, PV_NONE,
2573 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
2574 #endif
2575 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2576 (char_u *)&p_ttimeout, PV_NONE,
2577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2578 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2579 (char_u *)&p_ttm, PV_NONE,
2580 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
2581 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2582 (char_u *)&p_tbi, PV_NONE,
2583 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2584 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2585 (char_u *)&p_tf, PV_NONE,
2586 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2587 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2588 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2589 (char_u *)&p_ttym, PV_NONE,
2590 #else
2591 (char_u *)NULL, PV_NONE,
2592 #endif
2593 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2594 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2595 (char_u *)&p_ttyscroll, PV_NONE,
2596 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
2597 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2598 (char_u *)&T_NAME, PV_NONE,
2599 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2600 {"undolevels", "ul", P_NUM|P_VI_DEF,
2601 (char_u *)&p_ul, PV_NONE,
2603 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2604 (char_u *)1000L,
2605 #else
2606 (char_u *)100L,
2607 #endif
2608 (char_u *)0L} SCRIPTID_INIT},
2609 {"updatecount", "uc", P_NUM|P_VI_DEF,
2610 (char_u *)&p_uc, PV_NONE,
2611 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
2612 {"updatetime", "ut", P_NUM|P_VI_DEF,
2613 (char_u *)&p_ut, PV_NONE,
2614 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
2615 {"verbose", "vbs", P_NUM|P_VI_DEF,
2616 (char_u *)&p_verbose, PV_NONE,
2617 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2618 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2619 (char_u *)&p_vfile, PV_NONE,
2620 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2621 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2622 #ifdef FEAT_SESSION
2623 (char_u *)&p_vdir, PV_NONE,
2624 {(char_u *)DFLT_VDIR, (char_u *)0L}
2625 #else
2626 (char_u *)NULL, PV_NONE,
2627 {(char_u *)0L, (char_u *)0L}
2628 #endif
2629 SCRIPTID_INIT},
2630 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2631 #ifdef FEAT_SESSION
2632 (char_u *)&p_vop, PV_NONE,
2633 {(char_u *)"folds,options,cursor", (char_u *)0L}
2634 #else
2635 (char_u *)NULL, PV_NONE,
2636 {(char_u *)0L, (char_u *)0L}
2637 #endif
2638 SCRIPTID_INIT},
2639 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
2640 #ifdef FEAT_VIMINFO
2641 (char_u *)&p_viminfo, PV_NONE,
2642 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
2643 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
2644 #else
2645 # ifdef AMIGA
2646 {(char_u *)"",
2647 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
2648 # else
2649 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
2650 # endif
2651 #endif
2652 #else
2653 (char_u *)NULL, PV_NONE,
2654 {(char_u *)0L, (char_u *)0L}
2655 #endif
2656 SCRIPTID_INIT},
2657 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM,
2658 #ifdef FEAT_VIRTUALEDIT
2659 (char_u *)&p_ve, PV_NONE,
2660 {(char_u *)"", (char_u *)""}
2661 #else
2662 (char_u *)NULL, PV_NONE,
2663 {(char_u *)0L, (char_u *)0L}
2664 #endif
2665 SCRIPTID_INIT},
2666 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2667 (char_u *)&p_vb, PV_NONE,
2668 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2669 {"w300", NULL, P_NUM|P_VI_DEF,
2670 (char_u *)NULL, PV_NONE,
2671 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2672 {"w1200", NULL, P_NUM|P_VI_DEF,
2673 (char_u *)NULL, PV_NONE,
2674 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2675 {"w9600", NULL, P_NUM|P_VI_DEF,
2676 (char_u *)NULL, PV_NONE,
2677 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2678 {"warn", NULL, P_BOOL|P_VI_DEF,
2679 (char_u *)&p_warn, PV_NONE,
2680 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2681 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2682 (char_u *)&p_wiv, PV_NONE,
2683 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2684 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
2685 (char_u *)&p_ww, PV_NONE,
2686 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
2687 {"wildchar", "wc", P_NUM|P_VIM,
2688 (char_u *)&p_wc, PV_NONE,
2689 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2690 SCRIPTID_INIT},
2691 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
2692 (char_u *)&p_wcm, PV_NONE,
2693 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2694 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2695 #ifdef FEAT_WILDIGN
2696 (char_u *)&p_wig, PV_NONE,
2697 #else
2698 (char_u *)NULL, PV_NONE,
2699 #endif
2700 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2701 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2702 #ifdef FEAT_WILDMENU
2703 (char_u *)&p_wmnu, PV_NONE,
2704 #else
2705 (char_u *)NULL, PV_NONE,
2706 #endif
2707 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2708 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2709 (char_u *)&p_wim, PV_NONE,
2710 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
2711 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2712 #ifdef FEAT_CMDL_COMPL
2713 (char_u *)&p_wop, PV_NONE,
2714 {(char_u *)"", (char_u *)0L}
2715 #else
2716 (char_u *)NULL, PV_NONE,
2717 {(char_u *)NULL, (char_u *)0L}
2718 #endif
2719 SCRIPTID_INIT},
2720 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2721 #ifdef FEAT_WAK
2722 (char_u *)&p_wak, PV_NONE,
2723 {(char_u *)"menu", (char_u *)0L}
2724 #else
2725 (char_u *)NULL, PV_NONE,
2726 {(char_u *)NULL, (char_u *)0L}
2727 #endif
2728 SCRIPTID_INIT},
2729 {"window", "wi", P_NUM|P_VI_DEF,
2730 (char_u *)&p_window, PV_NONE,
2731 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2732 {"winheight", "wh", P_NUM|P_VI_DEF,
2733 #ifdef FEAT_WINDOWS
2734 (char_u *)&p_wh, PV_NONE,
2735 #else
2736 (char_u *)NULL, PV_NONE,
2737 #endif
2738 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2739 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
2740 #ifdef FEAT_WINDOWS
2741 (char_u *)VAR_WIN, PV_WFH,
2742 #else
2743 (char_u *)NULL, PV_NONE,
2744 #endif
2745 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2746 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2747 #ifdef FEAT_VERTSPLIT
2748 (char_u *)VAR_WIN, PV_WFW,
2749 #else
2750 (char_u *)NULL, PV_NONE,
2751 #endif
2752 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2753 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2754 #ifdef FEAT_WINDOWS
2755 (char_u *)&p_wmh, PV_NONE,
2756 #else
2757 (char_u *)NULL, PV_NONE,
2758 #endif
2759 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2760 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2761 #ifdef FEAT_VERTSPLIT
2762 (char_u *)&p_wmw, PV_NONE,
2763 #else
2764 (char_u *)NULL, PV_NONE,
2765 #endif
2766 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2767 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2768 #ifdef FEAT_VERTSPLIT
2769 (char_u *)&p_wiw, PV_NONE,
2770 #else
2771 (char_u *)NULL, PV_NONE,
2772 #endif
2773 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
2774 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2775 (char_u *)VAR_WIN, PV_WRAP,
2776 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2777 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2778 (char_u *)&p_wm, PV_WM,
2779 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2780 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2781 (char_u *)&p_ws, PV_NONE,
2782 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2783 {"write", NULL, P_BOOL|P_VI_DEF,
2784 (char_u *)&p_write, PV_NONE,
2785 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2786 {"writeany", "wa", P_BOOL|P_VI_DEF,
2787 (char_u *)&p_wa, PV_NONE,
2788 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2789 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2790 (char_u *)&p_wb, PV_NONE,
2792 #ifdef FEAT_WRITEBACKUP
2793 (char_u *)TRUE,
2794 #else
2795 (char_u *)FALSE,
2796 #endif
2797 (char_u *)0L} SCRIPTID_INIT},
2798 {"writedelay", "wd", P_NUM|P_VI_DEF,
2799 (char_u *)&p_wd, PV_NONE,
2800 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2802 /* terminal output codes */
2803 #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
2804 (char_u *)&vvv, PV_NONE, \
2805 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2807 p_term("t_AB", T_CAB)
2808 p_term("t_AF", T_CAF)
2809 p_term("t_AL", T_CAL)
2810 p_term("t_al", T_AL)
2811 p_term("t_bc", T_BC)
2812 p_term("t_cd", T_CD)
2813 p_term("t_ce", T_CE)
2814 p_term("t_cl", T_CL)
2815 p_term("t_cm", T_CM)
2816 p_term("t_Co", T_CCO)
2817 p_term("t_CS", T_CCS)
2818 p_term("t_cs", T_CS)
2819 #ifdef FEAT_VERTSPLIT
2820 p_term("t_CV", T_CSV)
2821 #endif
2822 p_term("t_ut", T_UT)
2823 p_term("t_da", T_DA)
2824 p_term("t_db", T_DB)
2825 p_term("t_DL", T_CDL)
2826 p_term("t_dl", T_DL)
2827 p_term("t_fs", T_FS)
2828 p_term("t_IE", T_CIE)
2829 p_term("t_IS", T_CIS)
2830 p_term("t_ke", T_KE)
2831 p_term("t_ks", T_KS)
2832 p_term("t_le", T_LE)
2833 p_term("t_mb", T_MB)
2834 p_term("t_md", T_MD)
2835 p_term("t_me", T_ME)
2836 p_term("t_mr", T_MR)
2837 p_term("t_ms", T_MS)
2838 p_term("t_nd", T_ND)
2839 p_term("t_op", T_OP)
2840 p_term("t_RI", T_CRI)
2841 p_term("t_RV", T_CRV)
2842 p_term("t_Sb", T_CSB)
2843 p_term("t_Sf", T_CSF)
2844 p_term("t_se", T_SE)
2845 p_term("t_so", T_SO)
2846 p_term("t_sr", T_SR)
2847 p_term("t_ts", T_TS)
2848 p_term("t_te", T_TE)
2849 p_term("t_ti", T_TI)
2850 p_term("t_ue", T_UE)
2851 p_term("t_us", T_US)
2852 p_term("t_vb", T_VB)
2853 p_term("t_ve", T_VE)
2854 p_term("t_vi", T_VI)
2855 p_term("t_vs", T_VS)
2856 p_term("t_WP", T_CWP)
2857 p_term("t_WS", T_CWS)
2858 p_term("t_SI", T_CSI)
2859 p_term("t_EI", T_CEI)
2860 p_term("t_xs", T_XS)
2861 p_term("t_ZH", T_CZH)
2862 p_term("t_ZR", T_CZR)
2864 /* terminal key codes are not in here */
2866 /* end marker */
2867 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
2870 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
2872 #ifdef FEAT_MBYTE
2873 static char *(p_ambw_values[]) = {"single", "double", NULL};
2874 #endif
2875 static char *(p_bg_values[]) = {"light", "dark", NULL};
2876 static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
2877 static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
2878 #ifdef FEAT_CMDL_COMPL
2879 static char *(p_wop_values[]) = {"tagfile", NULL};
2880 #endif
2881 #ifdef FEAT_WAK
2882 static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
2883 #endif
2884 static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
2885 #ifdef FEAT_VISUAL
2886 static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
2887 static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
2888 #endif
2889 #ifdef FEAT_VISUAL
2890 static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
2891 #endif
2892 #ifdef FEAT_BROWSE
2893 static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
2894 #endif
2895 #ifdef FEAT_SCROLLBIND
2896 static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
2897 #endif
2898 static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
2899 #ifdef FEAT_VERTSPLIT
2900 static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
2901 #endif
2902 #if defined(FEAT_QUICKFIX)
2903 # ifdef FEAT_AUTOCMD
2904 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
2905 # else
2906 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
2907 # endif
2908 static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
2909 #endif
2910 static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
2911 #ifdef FEAT_FOLDING
2912 static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
2913 # ifdef FEAT_DIFF
2914 "diff",
2915 # endif
2916 NULL};
2917 static char *(p_fcl_values[]) = {"all", NULL};
2918 #endif
2919 #ifdef FEAT_INS_EXPAND
2920 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
2921 #endif
2923 static void set_option_default __ARGS((int, int opt_flags, int compatible));
2924 static void set_options_default __ARGS((int opt_flags));
2925 static char_u *term_bg_default __ARGS((void));
2926 static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
2927 static char_u *illegal_char __ARGS((char_u *, int));
2928 static int string_to_key __ARGS((char_u *arg));
2929 #ifdef FEAT_CMDWIN
2930 static char_u *check_cedit __ARGS((void));
2931 #endif
2932 #ifdef FEAT_TITLE
2933 static void did_set_title __ARGS((int icon));
2934 #endif
2935 static char_u *option_expand __ARGS((int opt_idx, char_u *val));
2936 static void didset_options __ARGS((void));
2937 static void check_string_option __ARGS((char_u **pp));
2938 #if defined(FEAT_EVAL) || defined(PROTO)
2939 static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
2940 #else
2941 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
2942 #endif
2943 static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
2944 static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
2945 static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags));
2946 static char_u *set_chars_option __ARGS((char_u **varp));
2947 #ifdef FEAT_CLIPBOARD
2948 static char_u *check_clipboard_option __ARGS((void));
2949 #endif
2950 #ifdef FEAT_SPELL
2951 static char_u *compile_cap_prog __ARGS((buf_T *buf));
2952 #endif
2953 #ifdef FEAT_EVAL
2954 static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
2955 #endif
2956 static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
2957 static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags));
2958 static void check_redraw __ARGS((long_u flags));
2959 static int findoption __ARGS((char_u *));
2960 static int find_key_option __ARGS((char_u *));
2961 static void showoptions __ARGS((int all, int opt_flags));
2962 static int optval_default __ARGS((struct vimoption *, char_u *varp));
2963 static void showoneopt __ARGS((struct vimoption *, int opt_flags));
2964 static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
2965 static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
2966 static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
2967 static int istermoption __ARGS((struct vimoption *));
2968 static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
2969 static char_u *get_varp __ARGS((struct vimoption *));
2970 static void option_value2string __ARGS((struct vimoption *, int opt_flags));
2971 static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
2972 #ifdef FEAT_LANGMAP
2973 static void langmap_init __ARGS((void));
2974 static void langmap_set __ARGS((void));
2975 #endif
2976 static void paste_option_changed __ARGS((void));
2977 static void compatible_set __ARGS((void));
2978 #ifdef FEAT_LINEBREAK
2979 static void fill_breakat_flags __ARGS((void));
2980 #endif
2981 static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
2982 static int check_opt_strings __ARGS((char_u *val, char **values, int));
2983 static int check_opt_wim __ARGS((void));
2986 * Initialize the options, first part.
2988 * Called only once from main(), just after creating the first buffer.
2990 void
2991 set_init_1()
2993 char_u *p;
2994 int opt_idx;
2995 long_u n;
2997 #ifdef FEAT_LANGMAP
2998 langmap_init();
2999 #endif
3001 /* Be Vi compatible by default */
3002 p_cp = TRUE;
3004 /* Use POSIX compatibility when $VIM_POSIX is set. */
3005 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
3007 set_string_default("cpo", (char_u *)CPO_ALL);
3008 set_string_default("shm", (char_u *)"A");
3012 * Find default value for 'shell' option.
3013 * Don't use it if it is empty.
3015 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
3016 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3017 # ifdef __EMX__
3018 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
3019 # endif
3020 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
3021 # ifdef WIN3264
3022 || ((p = default_shell()) != NULL && *p != NUL)
3023 # endif
3024 #endif
3026 set_string_default("sh", p);
3028 #ifdef FEAT_WILDIGN
3030 * Set the default for 'backupskip' to include environment variables for
3031 * temp files.
3034 # ifdef UNIX
3035 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3036 # else
3037 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3038 # endif
3039 int len;
3040 garray_T ga;
3041 int mustfree;
3043 ga_init2(&ga, 1, 100);
3044 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3046 mustfree = FALSE;
3047 # ifdef UNIX
3048 if (*names[n] == NUL)
3049 p = (char_u *)"/tmp";
3050 else
3051 # endif
3052 p = vim_getenv((char_u *)names[n], &mustfree);
3053 if (p != NULL && *p != NUL)
3055 /* First time count the NUL, otherwise count the ','. */
3056 len = (int)STRLEN(p) + 3;
3057 if (ga_grow(&ga, len) == OK)
3059 if (ga.ga_len > 0)
3060 STRCAT(ga.ga_data, ",");
3061 STRCAT(ga.ga_data, p);
3062 add_pathsep(ga.ga_data);
3063 STRCAT(ga.ga_data, "*");
3064 ga.ga_len += len;
3067 if (mustfree)
3068 vim_free(p);
3070 if (ga.ga_data != NULL)
3072 set_string_default("bsk", ga.ga_data);
3073 vim_free(ga.ga_data);
3076 #endif
3079 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3081 opt_idx = findoption((char_u *)"maxmemtot");
3082 if (opt_idx >= 0)
3084 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3085 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3086 #endif
3088 #ifdef HAVE_AVAIL_MEM
3089 /* Use amount of memory available at this moment. */
3090 n = (mch_avail_mem(FALSE) >> 11);
3091 #else
3092 # ifdef HAVE_TOTAL_MEM
3093 /* Use amount of memory available to Vim. */
3094 n = (mch_total_mem(FALSE) >> 1);
3095 # else
3096 n = (0x7fffffff >> 11);
3097 # endif
3098 #endif
3099 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3100 opt_idx = findoption((char_u *)"maxmem");
3101 if (opt_idx >= 0)
3103 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3104 if ((long)options[opt_idx].def_val[VI_DEFAULT] > n
3105 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3106 #endif
3107 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3112 #ifdef FEAT_GUI_W32
3113 /* force 'shortname' for Win32s */
3114 if (gui_is_win32s())
3116 opt_idx = findoption((char_u *)"shortname");
3117 if (opt_idx >= 0)
3118 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3120 #endif
3122 #ifdef FEAT_SEARCHPATH
3124 char_u *cdpath;
3125 char_u *buf;
3126 int i;
3127 int j;
3128 int mustfree = FALSE;
3130 /* Initialize the 'cdpath' option's default value. */
3131 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
3132 if (cdpath != NULL)
3134 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3135 if (buf != NULL)
3137 buf[0] = ','; /* start with ",", current dir first */
3138 j = 1;
3139 for (i = 0; cdpath[i] != NUL; ++i)
3141 if (vim_ispathlistsep(cdpath[i]))
3142 buf[j++] = ',';
3143 else
3145 if (cdpath[i] == ' ' || cdpath[i] == ',')
3146 buf[j++] = '\\';
3147 buf[j++] = cdpath[i];
3150 buf[j] = NUL;
3151 opt_idx = findoption((char_u *)"cdpath");
3152 if (opt_idx >= 0)
3154 options[opt_idx].def_val[VI_DEFAULT] = buf;
3155 options[opt_idx].flags |= P_DEF_ALLOCED;
3158 if (mustfree)
3159 vim_free(cdpath);
3162 #endif
3164 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3165 /* Set print encoding on platforms that don't default to latin1 */
3166 set_string_default("penc",
3167 # if defined(MSWIN) || defined(OS2)
3168 (char_u *)"cp1252"
3169 # else
3170 # ifdef VMS
3171 (char_u *)"dec-mcs"
3172 # else
3173 # ifdef EBCDIC
3174 (char_u *)"ebcdic-uk"
3175 # else
3176 # ifdef MAC
3177 (char_u *)"mac-roman"
3178 # else /* HPUX */
3179 (char_u *)"hp-roman8"
3180 # endif
3181 # endif
3182 # endif
3183 # endif
3185 #endif
3187 #ifdef FEAT_POSTSCRIPT
3188 /* 'printexpr' must be allocated to be able to evaluate it. */
3189 set_string_default("pexpr",
3190 # if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3191 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
3192 # else
3193 # ifdef VMS
3194 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3196 # else
3197 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3198 # endif
3199 # endif
3201 #endif
3204 * Set all the options (except the terminal options) to their default
3205 * value. Also set the global value for local options.
3207 set_options_default(0);
3209 #ifdef FEAT_GUI
3210 if (found_reverse_arg)
3211 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3212 #endif
3214 curbuf->b_p_initialized = TRUE;
3215 curbuf->b_p_ar = -1; /* no local 'autoread' value */
3216 check_buf_options(curbuf);
3217 check_win_options(curwin);
3218 check_options();
3220 /* Must be before option_expand(), because that one needs vim_isIDc() */
3221 didset_options();
3223 #ifdef FEAT_SPELL
3224 /* Use the current chartab for the generic chartab. */
3225 init_spell_chartab();
3226 #endif
3228 #ifdef FEAT_LINEBREAK
3230 * initialize the table for 'breakat'.
3232 fill_breakat_flags();
3233 #endif
3236 * Expand environment variables and things like "~" for the defaults.
3237 * If option_expand() returns non-NULL the variable is expanded. This can
3238 * only happen for non-indirect options.
3239 * Also set the default to the expanded value, so ":set" does not list
3240 * them.
3241 * Don't set the P_ALLOCED flag, because we don't want to free the
3242 * default.
3244 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3246 if ((options[opt_idx].flags & P_GETTEXT)
3247 && options[opt_idx].var != NULL)
3248 p = (char_u *)_(*(char **)options[opt_idx].var);
3249 else
3250 p = option_expand(opt_idx, NULL);
3251 if (p != NULL && (p = vim_strsave(p)) != NULL)
3253 *(char_u **)options[opt_idx].var = p;
3254 /* VIMEXP
3255 * Defaults for all expanded options are currently the same for Vi
3256 * and Vim. When this changes, add some code here! Also need to
3257 * split P_DEF_ALLOCED in two.
3259 if (options[opt_idx].flags & P_DEF_ALLOCED)
3260 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3261 options[opt_idx].def_val[VI_DEFAULT] = p;
3262 options[opt_idx].flags |= P_DEF_ALLOCED;
3266 /* Initialize the highlight_attr[] table. */
3267 highlight_changed();
3269 save_file_ff(curbuf); /* Buffer is unchanged */
3271 /* Parse default for 'wildmode' */
3272 check_opt_wim();
3274 #if defined(FEAT_ARABIC)
3275 /* Detect use of mlterm.
3276 * Mlterm is a terminal emulator akin to xterm that has some special
3277 * abilities (bidi namely).
3278 * NOTE: mlterm's author is being asked to 'set' a variable
3279 * instead of an environment variable due to inheritance.
3281 if (mch_getenv((char_u *)"MLTERM") != NULL)
3282 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3283 #endif
3285 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3286 /* Parse default for 'fillchars'. */
3287 (void)set_chars_option(&p_fcs);
3288 #endif
3290 #ifdef FEAT_CLIPBOARD
3291 /* Parse default for 'clipboard' */
3292 (void)check_clipboard_option();
3293 #endif
3295 #ifdef FEAT_MBYTE
3296 # if defined(WIN3264) && defined(FEAT_GETTEXT)
3298 * If $LANG isn't set, try to get a good value for it. This makes the
3299 * right language be used automatically. Don't do this for English.
3301 if (mch_getenv((char_u *)"LANG") == NULL)
3303 char buf[20];
3305 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3306 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3307 * only the first two. */
3308 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3309 (LPTSTR)buf, 20);
3310 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3312 /* There are a few exceptions (probably more) */
3313 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3314 STRCPY(buf, "zh_TW");
3315 else if (STRNICMP(buf, "chs", 3) == 0
3316 || STRNICMP(buf, "zhc", 3) == 0)
3317 STRCPY(buf, "zh_CN");
3318 else if (STRNICMP(buf, "jp", 2) == 0)
3319 STRCPY(buf, "ja");
3320 else
3321 buf[2] = NUL; /* truncate to two-letter code */
3322 vim_setenv("LANG", buf);
3325 # else
3326 # ifdef MACOS_CONVERT
3327 /* Moved to os_mac_conv.c to avoid dependency problems. */
3328 mac_lang_init();
3329 # endif
3330 # endif
3332 /* enc_locale() will try to find the encoding of the current locale. */
3333 p = enc_locale();
3334 if (p != NULL)
3336 char_u *save_enc;
3338 /* Try setting 'encoding' and check if the value is valid.
3339 * If not, go back to the default "latin1". */
3340 save_enc = p_enc;
3341 p_enc = p;
3342 if (STRCMP(p_enc, "gb18030") == 0)
3344 /* We don't support "gb18030", but "cp936" is a good substitute
3345 * for practical purposes, thus use that. It's not an alias to
3346 * still support conversion between gb18030 and utf-8. */
3347 p_enc = vim_strsave((char_u *)"cp936");
3348 vim_free(p);
3350 if (mb_init() == NULL)
3352 opt_idx = findoption((char_u *)"encoding");
3353 if (opt_idx >= 0)
3355 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3356 options[opt_idx].flags |= P_DEF_ALLOCED;
3359 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3360 || defined(VMS)
3361 if (STRCMP(p_enc, "latin1") == 0
3362 # ifdef FEAT_MBYTE
3363 || enc_utf8
3364 # endif
3367 /* Adjust the default for 'isprint' and 'iskeyword' to match
3368 * latin1. Also set the defaults for when 'nocompatible' is
3369 * set. */
3370 set_string_option_direct((char_u *)"isp", -1,
3371 ISP_LATIN1, OPT_FREE, SID_NONE);
3372 set_string_option_direct((char_u *)"isk", -1,
3373 ISK_LATIN1, OPT_FREE, SID_NONE);
3374 opt_idx = findoption((char_u *)"isp");
3375 if (opt_idx >= 0)
3376 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
3377 opt_idx = findoption((char_u *)"isk");
3378 if (opt_idx >= 0)
3379 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
3380 (void)init_chartab();
3382 #endif
3384 # if defined(WIN3264) && !defined(FEAT_GUI)
3385 /* Win32 console: When GetACP() returns a different value from
3386 * GetConsoleCP() set 'termencoding'. */
3387 if (GetACP() != GetConsoleCP())
3389 char buf[50];
3391 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3392 p_tenc = vim_strsave((char_u *)buf);
3393 if (p_tenc != NULL)
3395 opt_idx = findoption((char_u *)"termencoding");
3396 if (opt_idx >= 0)
3398 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3399 options[opt_idx].flags |= P_DEF_ALLOCED;
3401 convert_setup(&input_conv, p_tenc, p_enc);
3402 convert_setup(&output_conv, p_enc, p_tenc);
3404 else
3405 p_tenc = empty_option;
3407 # endif
3408 # if defined(WIN3264) && defined(FEAT_MBYTE)
3409 /* $HOME may have characters in active code page. */
3410 init_homedir();
3411 # endif
3413 else
3415 vim_free(p_enc);
3416 p_enc = save_enc;
3419 #endif
3421 #ifdef FEAT_MULTI_LANG
3422 /* Set the default for 'helplang'. */
3423 set_helplang_default(get_mess_lang());
3424 #endif
3428 * Set an option to its default value.
3429 * This does not take care of side effects!
3431 static void
3432 set_option_default(opt_idx, opt_flags, compatible)
3433 int opt_idx;
3434 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3435 int compatible; /* use Vi default value */
3437 char_u *varp; /* pointer to variable for current option */
3438 int dvi; /* index in def_val[] */
3439 long_u flags;
3440 long_u *flagsp;
3441 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3443 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3444 flags = options[opt_idx].flags;
3445 if (varp != NULL) /* skip hidden option, nothing to do for it */
3447 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3448 if (flags & P_STRING)
3450 /* Use set_string_option_direct() for local options to handle
3451 * freeing and allocating the value. */
3452 if (options[opt_idx].indir != PV_NONE)
3453 set_string_option_direct(NULL, opt_idx,
3454 options[opt_idx].def_val[dvi], opt_flags, 0);
3455 else
3457 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3458 free_string_option(*(char_u **)(varp));
3459 *(char_u **)varp = options[opt_idx].def_val[dvi];
3460 options[opt_idx].flags &= ~P_ALLOCED;
3463 else if (flags & P_NUM)
3465 if (options[opt_idx].indir == PV_SCROLL)
3466 win_comp_scroll(curwin);
3467 else
3469 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
3470 /* May also set global value for local option. */
3471 if (both)
3472 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3473 *(long *)varp;
3476 else /* P_BOOL */
3478 /* the cast to long is required for Manx C, long_i is needed for
3479 * MSVC */
3480 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
3481 #ifdef UNIX
3482 /* 'modeline' defaults to off for root */
3483 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3484 *(int *)varp = FALSE;
3485 #endif
3486 /* May also set global value for local option. */
3487 if (both)
3488 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3489 *(int *)varp;
3492 /* The default value is not insecure. */
3493 flagsp = insecure_flag(opt_idx, opt_flags);
3494 *flagsp = *flagsp & ~P_INSECURE;
3497 #ifdef FEAT_EVAL
3498 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
3499 #endif
3503 * Set all options (except terminal options) to their default value.
3505 static void
3506 set_options_default(opt_flags)
3507 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3509 int i;
3510 #ifdef FEAT_WINDOWS
3511 win_T *wp;
3512 tabpage_T *tp;
3513 #endif
3515 for (i = 0; !istermoption(&options[i]); i++)
3516 if (!(options[i].flags & P_NODEFAULT))
3517 set_option_default(i, opt_flags, p_cp);
3519 #ifdef FEAT_WINDOWS
3520 /* The 'scroll' option must be computed for all windows. */
3521 FOR_ALL_TAB_WINDOWS(tp, wp)
3522 win_comp_scroll(wp);
3523 #else
3524 win_comp_scroll(curwin);
3525 #endif
3529 * Set the Vi-default value of a string option.
3530 * Used for 'sh', 'backupskip' and 'term'.
3532 void
3533 set_string_default(name, val)
3534 char *name;
3535 char_u *val;
3537 char_u *p;
3538 int opt_idx;
3540 p = vim_strsave(val);
3541 if (p != NULL) /* we don't want a NULL */
3543 opt_idx = findoption((char_u *)name);
3544 if (opt_idx >= 0)
3546 if (options[opt_idx].flags & P_DEF_ALLOCED)
3547 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3548 options[opt_idx].def_val[VI_DEFAULT] = p;
3549 options[opt_idx].flags |= P_DEF_ALLOCED;
3555 * Set the Vi-default value of a number option.
3556 * Used for 'lines' and 'columns'.
3558 void
3559 set_number_default(name, val)
3560 char *name;
3561 long val;
3563 int opt_idx;
3565 opt_idx = findoption((char_u *)name);
3566 if (opt_idx >= 0)
3567 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3570 #if defined(EXITFREE) || defined(PROTO)
3572 * Free all options.
3574 void
3575 free_all_options()
3577 int i;
3579 for (i = 0; !istermoption(&options[i]); i++)
3581 if (options[i].indir == PV_NONE)
3583 /* global option: free value and default value. */
3584 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3585 free_string_option(*(char_u **)options[i].var);
3586 if (options[i].flags & P_DEF_ALLOCED)
3587 free_string_option(options[i].def_val[VI_DEFAULT]);
3589 else if (options[i].var != VAR_WIN
3590 && (options[i].flags & P_STRING))
3591 /* buffer-local option: free global value */
3592 free_string_option(*(char_u **)options[i].var);
3595 #endif
3599 * Initialize the options, part two: After getting Rows and Columns and
3600 * setting 'term'.
3602 void
3603 set_init_2()
3605 int idx;
3608 * 'scroll' defaults to half the window height. Note that this default is
3609 * wrong when the window height changes.
3611 set_number_default("scroll", (long)((long_u)Rows >> 1));
3612 idx = findoption((char_u *)"scroll");
3613 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
3614 set_option_default(idx, OPT_LOCAL, p_cp);
3615 comp_col();
3618 * 'window' is only for backwards compatibility with Vi.
3619 * Default is Rows - 1.
3621 if (!option_was_set((char_u *)"window"))
3622 p_window = Rows - 1;
3623 set_number_default("window", Rows - 1);
3625 /* For DOS console the default is always black. */
3626 #if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
3628 * If 'background' wasn't set by the user, try guessing the value,
3629 * depending on the terminal name. Only need to check for terminals
3630 * with a dark background, that can handle color.
3632 idx = findoption((char_u *)"bg");
3633 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3634 && *term_bg_default() == 'd')
3636 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
3637 /* don't mark it as set, when starting the GUI it may be
3638 * changed again */
3639 options[idx].flags &= ~P_WAS_SET;
3641 #endif
3643 #ifdef CURSOR_SHAPE
3644 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3645 #endif
3646 #ifdef FEAT_MOUSESHAPE
3647 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3648 #endif
3649 #ifdef FEAT_PRINTER
3650 (void)parse_printoptions(); /* parse 'printoptions' default value */
3651 #endif
3655 * Return "dark" or "light" depending on the kind of terminal.
3656 * This is just guessing! Recognized are:
3657 * "linux" Linux console
3658 * "screen.linux" Linux console with screen
3659 * "cygwin" Cygwin shell
3660 * "putty" Putty program
3661 * We also check the COLORFGBG environment variable, which is set by
3662 * rxvt and derivatives. This variable contains either two or three
3663 * values separated by semicolons; we want the last value in either
3664 * case. If this value is 0-6 or 8, our background is dark.
3666 static char_u *
3667 term_bg_default()
3669 #if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3670 /* DOS console nearly always black */
3671 return (char_u *)"dark";
3672 #else
3673 char_u *p;
3675 if (STRCMP(T_NAME, "linux") == 0
3676 || STRCMP(T_NAME, "screen.linux") == 0
3677 || STRCMP(T_NAME, "cygwin") == 0
3678 || STRCMP(T_NAME, "putty") == 0
3679 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3680 && (p = vim_strrchr(p, ';')) != NULL
3681 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3682 && p[2] == NUL))
3683 return (char_u *)"dark";
3684 return (char_u *)"light";
3685 #endif
3689 * Initialize the options, part three: After reading the .vimrc
3691 void
3692 set_init_3()
3694 #if defined(UNIX) || defined(OS2) || defined(WIN3264)
3696 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3697 * This is done after other initializations, where 'shell' might have been
3698 * set, but only if they have not been set before.
3700 char_u *p;
3701 int idx_srr;
3702 int do_srr;
3703 #ifdef FEAT_QUICKFIX
3704 int idx_sp;
3705 int do_sp;
3706 #endif
3708 idx_srr = findoption((char_u *)"srr");
3709 if (idx_srr < 0)
3710 do_srr = FALSE;
3711 else
3712 do_srr = !(options[idx_srr].flags & P_WAS_SET);
3713 #ifdef FEAT_QUICKFIX
3714 idx_sp = findoption((char_u *)"sp");
3715 if (idx_sp < 0)
3716 do_sp = FALSE;
3717 else
3718 do_sp = !(options[idx_sp].flags & P_WAS_SET);
3719 #endif
3722 * Isolate the name of the shell:
3723 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
3724 * - Remove any argument. E.g., "csh -f" -> "csh".
3726 p = gettail(p_sh);
3727 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
3728 if (p != NULL)
3731 * Default for p_sp is "| tee", for p_srr is ">".
3732 * For known shells it is changed here to include stderr.
3734 if ( fnamecmp(p, "csh") == 0
3735 || fnamecmp(p, "tcsh") == 0
3736 # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3737 || fnamecmp(p, "csh.exe") == 0
3738 || fnamecmp(p, "tcsh.exe") == 0
3739 # endif
3742 #if defined(FEAT_QUICKFIX)
3743 if (do_sp)
3745 # ifdef WIN3264
3746 p_sp = (char_u *)">&";
3747 # else
3748 p_sp = (char_u *)"|& tee";
3749 # endif
3750 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3752 #endif
3753 if (do_srr)
3755 p_srr = (char_u *)">&";
3756 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3759 else
3760 # ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3761 if ( fnamecmp(p, "sh") == 0
3762 || fnamecmp(p, "ksh") == 0
3763 || fnamecmp(p, "zsh") == 0
3764 || fnamecmp(p, "zsh-beta") == 0
3765 || fnamecmp(p, "bash") == 0
3766 # ifdef WIN3264
3767 || fnamecmp(p, "cmd") == 0
3768 || fnamecmp(p, "sh.exe") == 0
3769 || fnamecmp(p, "ksh.exe") == 0
3770 || fnamecmp(p, "zsh.exe") == 0
3771 || fnamecmp(p, "zsh-beta.exe") == 0
3772 || fnamecmp(p, "bash.exe") == 0
3773 || fnamecmp(p, "cmd.exe") == 0
3774 # endif
3776 # endif
3778 #if defined(FEAT_QUICKFIX)
3779 if (do_sp)
3781 # ifdef WIN3264
3782 p_sp = (char_u *)">%s 2>&1";
3783 # else
3784 p_sp = (char_u *)"2>&1| tee";
3785 # endif
3786 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3788 #endif
3789 if (do_srr)
3791 p_srr = (char_u *)">%s 2>&1";
3792 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3795 vim_free(p);
3797 #endif
3799 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3801 * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
3802 * This is done after other initializations, where 'shell' might have been
3803 * set, but only if they have not been set before. Default for p_shcf is
3804 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3805 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3806 * command.com. And for Win32 we need to set p_sxq instead.
3808 if (strstr((char *)gettail(p_sh), "sh") != NULL)
3810 int idx3;
3812 idx3 = findoption((char_u *)"shcf");
3813 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3815 p_shcf = (char_u *)"-c";
3816 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3819 # ifndef DJGPP
3820 # ifdef WIN3264
3821 /* Somehow Win32 requires the quotes around the redirection too */
3822 idx3 = findoption((char_u *)"sxq");
3823 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3825 p_sxq = (char_u *)"\"";
3826 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3828 # else
3829 idx3 = findoption((char_u *)"shq");
3830 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3832 p_shq = (char_u *)"\"";
3833 options[idx3].def_val[VI_DEFAULT] = p_shq;
3835 # endif
3836 # endif
3838 #endif
3840 #ifdef FEAT_TITLE
3841 set_title_defaults();
3842 #endif
3845 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
3847 * When 'helplang' is still at its default value, set it to "lang".
3848 * Only the first two characters of "lang" are used.
3850 void
3851 set_helplang_default(lang)
3852 char_u *lang;
3854 int idx;
3856 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
3857 return;
3858 idx = findoption((char_u *)"hlg");
3859 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
3861 if (options[idx].flags & P_ALLOCED)
3862 free_string_option(p_hlg);
3863 p_hlg = vim_strsave(lang);
3864 if (p_hlg == NULL)
3865 p_hlg = empty_option;
3866 else
3868 /* zh_CN becomes "cn", zh_TW becomes "tw". */
3869 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
3871 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
3872 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
3874 p_hlg[2] = NUL;
3876 options[idx].flags |= P_ALLOCED;
3879 #endif
3881 #ifdef FEAT_GUI
3882 static char_u *gui_bg_default __ARGS((void));
3884 static char_u *
3885 gui_bg_default()
3887 if (gui_get_lightness(gui.back_pixel) < 127)
3888 return (char_u *)"dark";
3889 return (char_u *)"light";
3893 * Option initializations that can only be done after opening the GUI window.
3895 void
3896 init_gui_options()
3898 /* Set the 'background' option according to the lightness of the
3899 * background color, unless the user has set it already. */
3900 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
3902 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
3903 highlight_changed();
3906 #endif
3908 #ifdef FEAT_TITLE
3910 * 'title' and 'icon' only default to true if they have not been set or reset
3911 * in .vimrc and we can read the old value.
3912 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
3913 * they can be reset. This reduces startup time when using X on a remote
3914 * machine.
3916 void
3917 set_title_defaults()
3919 int idx1;
3920 long val;
3923 * If GUI is (going to be) used, we can always set the window title and
3924 * icon name. Saves a bit of time, because the X11 display server does
3925 * not need to be contacted.
3927 idx1 = findoption((char_u *)"title");
3928 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
3930 #ifdef FEAT_GUI
3931 if (gui.starting || gui.in_use)
3932 val = TRUE;
3933 else
3934 #endif
3935 val = mch_can_restore_title();
3936 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3937 p_title = val;
3939 idx1 = findoption((char_u *)"icon");
3940 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
3942 #ifdef FEAT_GUI
3943 if (gui.starting || gui.in_use)
3944 val = TRUE;
3945 else
3946 #endif
3947 val = mch_can_restore_icon();
3948 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3949 p_icon = val;
3952 #endif
3955 * Parse 'arg' for option settings.
3957 * 'arg' may be IObuff, but only when no errors can be present and option
3958 * does not need to be expanded with option_expand().
3959 * "opt_flags":
3960 * 0 for ":set"
3961 * OPT_GLOBAL for ":setglobal"
3962 * OPT_LOCAL for ":setlocal" and a modeline
3963 * OPT_MODELINE for a modeline
3964 * OPT_WINONLY to only set window-local options
3965 * OPT_NOWIN to skip setting window-local options
3967 * returns FAIL if an error is detected, OK otherwise
3970 do_set(arg, opt_flags)
3971 char_u *arg; /* option string (may be written to!) */
3972 int opt_flags;
3974 int opt_idx;
3975 char_u *errmsg;
3976 char_u errbuf[80];
3977 char_u *startarg;
3978 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
3979 int nextchar; /* next non-white char after option name */
3980 int afterchar; /* character just after option name */
3981 int len;
3982 int i;
3983 long value;
3984 int key;
3985 long_u flags; /* flags for current option */
3986 char_u *varp = NULL; /* pointer to variable for current option */
3987 int did_show = FALSE; /* already showed one value */
3988 int adding; /* "opt+=arg" */
3989 int prepending; /* "opt^=arg" */
3990 int removing; /* "opt-=arg" */
3991 int cp_val = 0;
3992 char_u key_name[2];
3994 if (*arg == NUL)
3996 showoptions(0, opt_flags);
3997 did_show = TRUE;
3998 goto theend;
4001 while (*arg != NUL) /* loop to process all options */
4003 errmsg = NULL;
4004 startarg = arg; /* remember for error message */
4006 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4007 && !(opt_flags & OPT_MODELINE))
4010 * ":set all" show all options.
4011 * ":set all&" set all options to their default value.
4013 arg += 3;
4014 if (*arg == '&')
4016 ++arg;
4017 /* Only for :set command set global value of local options. */
4018 set_options_default(OPT_FREE | opt_flags);
4020 else
4022 showoptions(1, opt_flags);
4023 did_show = TRUE;
4026 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
4028 showoptions(2, opt_flags);
4029 show_termcodes();
4030 did_show = TRUE;
4031 arg += 7;
4033 else
4035 prefix = 1;
4036 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
4038 prefix = 0;
4039 arg += 2;
4041 else if (STRNCMP(arg, "inv", 3) == 0)
4043 prefix = 2;
4044 arg += 3;
4047 /* find end of name */
4048 key = 0;
4049 if (*arg == '<')
4051 nextchar = 0;
4052 opt_idx = -1;
4053 /* look out for <t_>;> */
4054 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4055 len = 5;
4056 else
4058 len = 1;
4059 while (arg[len] != NUL && arg[len] != '>')
4060 ++len;
4062 if (arg[len] != '>')
4064 errmsg = e_invarg;
4065 goto skip;
4067 arg[len] = NUL; /* put NUL after name */
4068 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4069 opt_idx = findoption(arg + 1);
4070 arg[len++] = '>'; /* restore '>' */
4071 if (opt_idx == -1)
4072 key = find_key_option(arg + 1);
4074 else
4076 len = 0;
4078 * The two characters after "t_" may not be alphanumeric.
4080 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4081 len = 4;
4082 else
4083 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4084 ++len;
4085 nextchar = arg[len];
4086 arg[len] = NUL; /* put NUL after name */
4087 opt_idx = findoption(arg);
4088 arg[len] = nextchar; /* restore nextchar */
4089 if (opt_idx == -1)
4090 key = find_key_option(arg);
4093 /* remember character after option name */
4094 afterchar = arg[len];
4096 /* skip white space, allow ":set ai ?" */
4097 while (vim_iswhite(arg[len]))
4098 ++len;
4100 adding = FALSE;
4101 prepending = FALSE;
4102 removing = FALSE;
4103 if (arg[len] != NUL && arg[len + 1] == '=')
4105 if (arg[len] == '+')
4107 adding = TRUE; /* "+=" */
4108 ++len;
4110 else if (arg[len] == '^')
4112 prepending = TRUE; /* "^=" */
4113 ++len;
4115 else if (arg[len] == '-')
4117 removing = TRUE; /* "-=" */
4118 ++len;
4121 nextchar = arg[len];
4123 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4125 errmsg = (char_u *)N_("E518: Unknown option");
4126 goto skip;
4129 if (opt_idx >= 0)
4131 if (options[opt_idx].var == NULL) /* hidden option: skip */
4133 /* Only give an error message when requesting the value of
4134 * a hidden option, ignore setting it. */
4135 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4136 && (!(options[opt_idx].flags & P_BOOL)
4137 || nextchar == '?'))
4138 errmsg = (char_u *)N_("E519: Option not supported");
4139 goto skip;
4142 flags = options[opt_idx].flags;
4143 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4145 else
4147 flags = P_STRING;
4148 if (key < 0)
4150 key_name[0] = KEY2TERMCAP0(key);
4151 key_name[1] = KEY2TERMCAP1(key);
4153 else
4155 key_name[0] = KS_KEY;
4156 key_name[1] = (key & 0xff);
4160 /* Skip all options that are not window-local (used when showing
4161 * an already loaded buffer in a window). */
4162 if ((opt_flags & OPT_WINONLY)
4163 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4164 goto skip;
4166 /* Skip all options that are window-local (used for :vimgrep). */
4167 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4168 && options[opt_idx].var == VAR_WIN)
4169 goto skip;
4171 /* Disallow changing some options from modelines. */
4172 if (opt_flags & OPT_MODELINE)
4174 if (flags & P_SECURE)
4176 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4177 goto skip;
4179 #ifdef FEAT_DIFF
4180 /* In diff mode some options are overruled. This avoids that
4181 * 'foldmethod' becomes "marker" instead of "diff" and that
4182 * "wrap" gets set. */
4183 if (curwin->w_p_diff
4184 && (options[opt_idx].indir == PV_FDM
4185 || options[opt_idx].indir == PV_WRAP))
4186 goto skip;
4187 #endif
4190 #ifdef HAVE_SANDBOX
4191 /* Disallow changing some options in the sandbox */
4192 if (sandbox != 0 && (flags & P_SECURE))
4194 errmsg = (char_u *)_(e_sandbox);
4195 goto skip;
4197 #endif
4199 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4201 arg += len;
4202 cp_val = p_cp;
4203 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4205 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4207 cp_val = FALSE;
4208 arg += 3;
4210 else /* "opt&vi": set to Vi default */
4212 cp_val = TRUE;
4213 arg += 2;
4216 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4217 && arg[1] != NUL && !vim_iswhite(arg[1]))
4219 errmsg = e_trailing;
4220 goto skip;
4225 * allow '=' and ':' as MSDOS command.com allows only one
4226 * '=' character per "set" command line. grrr. (jw)
4228 if (nextchar == '?'
4229 || (prefix == 1
4230 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4231 && !(flags & P_BOOL)))
4234 * print value
4236 if (did_show)
4237 msg_putchar('\n'); /* cursor below last one */
4238 else
4240 gotocmdline(TRUE); /* cursor at status line */
4241 did_show = TRUE; /* remember that we did a line */
4243 if (opt_idx >= 0)
4245 showoneopt(&options[opt_idx], opt_flags);
4246 #ifdef FEAT_EVAL
4247 if (p_verbose > 0)
4249 /* Mention where the option was last set. */
4250 if (varp == options[opt_idx].var)
4251 last_set_msg(options[opt_idx].scriptID);
4252 else if ((int)options[opt_idx].indir & PV_WIN)
4253 last_set_msg(curwin->w_p_scriptID[
4254 (int)options[opt_idx].indir & PV_MASK]);
4255 else if ((int)options[opt_idx].indir & PV_BUF)
4256 last_set_msg(curbuf->b_p_scriptID[
4257 (int)options[opt_idx].indir & PV_MASK]);
4259 #endif
4261 else
4263 char_u *p;
4265 p = find_termcode(key_name);
4266 if (p == NULL)
4268 errmsg = (char_u *)N_("E518: Unknown option");
4269 goto skip;
4271 else
4272 (void)show_one_termcode(key_name, p, TRUE);
4274 if (nextchar != '?'
4275 && nextchar != NUL && !vim_iswhite(afterchar))
4276 errmsg = e_trailing;
4278 else
4280 if (flags & P_BOOL) /* boolean */
4282 if (nextchar == '=' || nextchar == ':')
4284 errmsg = e_invarg;
4285 goto skip;
4289 * ":set opt!": invert
4290 * ":set opt&": reset to default value
4291 * ":set opt<": reset to global value
4293 if (nextchar == '!')
4294 value = *(int *)(varp) ^ 1;
4295 else if (nextchar == '&')
4296 value = (int)(long)(long_i)options[opt_idx].def_val[
4297 ((flags & P_VI_DEF) || cp_val)
4298 ? VI_DEFAULT : VIM_DEFAULT];
4299 else if (nextchar == '<')
4301 /* For 'autoread' -1 means to use global value. */
4302 if ((int *)varp == &curbuf->b_p_ar
4303 && opt_flags == OPT_LOCAL)
4304 value = -1;
4305 else
4306 value = *(int *)get_varp_scope(&(options[opt_idx]),
4307 OPT_GLOBAL);
4309 else
4312 * ":set invopt": invert
4313 * ":set opt" or ":set noopt": set or reset
4315 if (nextchar != NUL && !vim_iswhite(afterchar))
4317 errmsg = e_trailing;
4318 goto skip;
4320 if (prefix == 2) /* inv */
4321 value = *(int *)(varp) ^ 1;
4322 else
4323 value = prefix;
4326 errmsg = set_bool_option(opt_idx, varp, (int)value,
4327 opt_flags);
4329 else /* numeric or string */
4331 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4332 || prefix != 1)
4334 errmsg = e_invarg;
4335 goto skip;
4338 if (flags & P_NUM) /* numeric */
4341 * Different ways to set a number option:
4342 * & set to default value
4343 * < set to global value
4344 * <xx> accept special key codes for 'wildchar'
4345 * c accept any non-digit for 'wildchar'
4346 * [-]0-9 set number
4347 * other error
4349 ++arg;
4350 if (nextchar == '&')
4351 value = (long)(long_i)options[opt_idx].def_val[
4352 ((flags & P_VI_DEF) || cp_val)
4353 ? VI_DEFAULT : VIM_DEFAULT];
4354 else if (nextchar == '<')
4355 value = *(long *)get_varp_scope(&(options[opt_idx]),
4356 OPT_GLOBAL);
4357 else if (((long *)varp == &p_wc
4358 || (long *)varp == &p_wcm)
4359 && (*arg == '<'
4360 || *arg == '^'
4361 || ((!arg[1] || vim_iswhite(arg[1]))
4362 && !VIM_ISDIGIT(*arg))))
4364 value = string_to_key(arg);
4365 if (value == 0 && (long *)varp != &p_wcm)
4367 errmsg = e_invarg;
4368 goto skip;
4371 /* allow negative numbers (for 'undolevels') */
4372 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4374 i = 0;
4375 if (*arg == '-')
4376 i = 1;
4377 #ifdef HAVE_STRTOL
4378 value = strtol((char *)arg, NULL, 0);
4379 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
4380 i += 2;
4381 #else
4382 value = atol((char *)arg);
4383 #endif
4384 while (VIM_ISDIGIT(arg[i]))
4385 ++i;
4386 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4388 errmsg = e_invarg;
4389 goto skip;
4392 else
4394 errmsg = (char_u *)N_("E521: Number required after =");
4395 goto skip;
4398 if (adding)
4399 value = *(long *)varp + value;
4400 if (prepending)
4401 value = *(long *)varp * value;
4402 if (removing)
4403 value = *(long *)varp - value;
4404 errmsg = set_num_option(opt_idx, varp, value,
4405 errbuf, sizeof(errbuf), opt_flags);
4407 else if (opt_idx >= 0) /* string */
4409 char_u *save_arg = NULL;
4410 char_u *s = NULL;
4411 char_u *oldval; /* previous value if *varp */
4412 char_u *newval;
4413 char_u *origval;
4414 unsigned newlen;
4415 int comma;
4416 int bs;
4417 int new_value_alloced; /* new string option
4418 was allocated */
4420 /* When using ":set opt=val" for a global option
4421 * with a local value the local value will be
4422 * reset, use the global value here. */
4423 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
4424 && ((int)options[opt_idx].indir & PV_BOTH))
4425 varp = options[opt_idx].var;
4427 /* The old value is kept until we are sure that the
4428 * new value is valid. */
4429 oldval = *(char_u **)varp;
4430 if (nextchar == '&') /* set to default val */
4432 newval = options[opt_idx].def_val[
4433 ((flags & P_VI_DEF) || cp_val)
4434 ? VI_DEFAULT : VIM_DEFAULT];
4435 if ((char_u **)varp == &p_bg)
4437 /* guess the value of 'background' */
4438 #ifdef FEAT_GUI
4439 if (gui.in_use)
4440 newval = gui_bg_default();
4441 else
4442 #endif
4443 newval = term_bg_default();
4446 /* expand environment variables and ~ (since the
4447 * default value was already expanded, only
4448 * required when an environment variable was set
4449 * later */
4450 if (newval == NULL)
4451 newval = empty_option;
4452 else
4454 s = option_expand(opt_idx, newval);
4455 if (s == NULL)
4456 s = newval;
4457 newval = vim_strsave(s);
4459 new_value_alloced = TRUE;
4461 else if (nextchar == '<') /* set to global val */
4463 newval = vim_strsave(*(char_u **)get_varp_scope(
4464 &(options[opt_idx]), OPT_GLOBAL));
4465 new_value_alloced = TRUE;
4467 else
4469 ++arg; /* jump to after the '=' or ':' */
4472 * Set 'keywordprg' to ":help" if an empty
4473 * value was passed to :set by the user.
4474 * Misuse errbuf[] for the resulting string.
4476 if (varp == (char_u *)&p_kp
4477 && (*arg == NUL || *arg == ' '))
4479 STRCPY(errbuf, ":help");
4480 save_arg = arg;
4481 arg = errbuf;
4484 * Convert 'whichwrap' number to string, for
4485 * backwards compatibility with Vim 3.0.
4486 * Misuse errbuf[] for the resulting string.
4488 else if (varp == (char_u *)&p_ww
4489 && VIM_ISDIGIT(*arg))
4491 *errbuf = NUL;
4492 i = getdigits(&arg);
4493 if (i & 1)
4494 STRCAT(errbuf, "b,");
4495 if (i & 2)
4496 STRCAT(errbuf, "s,");
4497 if (i & 4)
4498 STRCAT(errbuf, "h,l,");
4499 if (i & 8)
4500 STRCAT(errbuf, "<,>,");
4501 if (i & 16)
4502 STRCAT(errbuf, "[,],");
4503 if (*errbuf != NUL) /* remove trailing , */
4504 errbuf[STRLEN(errbuf) - 1] = NUL;
4505 save_arg = arg;
4506 arg = errbuf;
4509 * Remove '>' before 'dir' and 'bdir', for
4510 * backwards compatibility with version 3.0
4512 else if ( *arg == '>'
4513 && (varp == (char_u *)&p_dir
4514 || varp == (char_u *)&p_bdir))
4516 ++arg;
4519 /* When setting the local value of a global
4520 * option, the old value may be the global value. */
4521 if (((int)options[opt_idx].indir & PV_BOTH)
4522 && (opt_flags & OPT_LOCAL))
4523 origval = *(char_u **)get_varp(
4524 &options[opt_idx]);
4525 else
4526 origval = oldval;
4529 * Copy the new string into allocated memory.
4530 * Can't use set_string_option_direct(), because
4531 * we need to remove the backslashes.
4533 /* get a bit too much */
4534 newlen = (unsigned)STRLEN(arg) + 1;
4535 if (adding || prepending || removing)
4536 newlen += (unsigned)STRLEN(origval) + 1;
4537 newval = alloc(newlen);
4538 if (newval == NULL) /* out of mem, don't change */
4539 break;
4540 s = newval;
4543 * Copy the string, skip over escaped chars.
4544 * For MS-DOS and WIN32 backslashes before normal
4545 * file name characters are not removed, and keep
4546 * backslash at start, for "\\machine\path", but
4547 * do remove it for "\\\\machine\\path".
4548 * The reverse is found in ExpandOldSetting().
4550 while (*arg && !vim_iswhite(*arg))
4552 if (*arg == '\\' && arg[1] != NUL
4553 #ifdef BACKSLASH_IN_FILENAME
4554 && !((flags & P_EXPAND)
4555 && vim_isfilec(arg[1])
4556 && (arg[1] != '\\'
4557 || (s == newval
4558 && arg[2] != '\\')))
4559 #endif
4561 ++arg; /* remove backslash */
4562 #ifdef FEAT_MBYTE
4563 if (has_mbyte
4564 && (i = (*mb_ptr2len)(arg)) > 1)
4566 /* copy multibyte char */
4567 mch_memmove(s, arg, (size_t)i);
4568 arg += i;
4569 s += i;
4571 else
4572 #endif
4573 *s++ = *arg++;
4575 *s = NUL;
4578 * Expand environment variables and ~.
4579 * Don't do it when adding without inserting a
4580 * comma.
4582 if (!(adding || prepending || removing)
4583 || (flags & P_COMMA))
4585 s = option_expand(opt_idx, newval);
4586 if (s != NULL)
4588 vim_free(newval);
4589 newlen = (unsigned)STRLEN(s) + 1;
4590 if (adding || prepending || removing)
4591 newlen += (unsigned)STRLEN(origval) + 1;
4592 newval = alloc(newlen);
4593 if (newval == NULL)
4594 break;
4595 STRCPY(newval, s);
4599 /* locate newval[] in origval[] when removing it
4600 * and when adding to avoid duplicates */
4601 i = 0; /* init for GCC */
4602 if (removing || (flags & P_NODUP))
4604 i = (int)STRLEN(newval);
4605 bs = 0;
4606 for (s = origval; *s; ++s)
4608 if ((!(flags & P_COMMA)
4609 || s == origval
4610 || (s[-1] == ',' && !(bs & 1)))
4611 && STRNCMP(s, newval, i) == 0
4612 && (!(flags & P_COMMA)
4613 || s[i] == ','
4614 || s[i] == NUL))
4615 break;
4616 /* Count backspaces. Only a comma with an
4617 * even number of backspaces before it is
4618 * recognized as a separator */
4619 if (s > origval && s[-1] == '\\')
4620 ++bs;
4621 else
4622 bs = 0;
4625 /* do not add if already there */
4626 if ((adding || prepending) && *s)
4628 prepending = FALSE;
4629 adding = FALSE;
4630 STRCPY(newval, origval);
4634 /* concatenate the two strings; add a ',' if
4635 * needed */
4636 if (adding || prepending)
4638 comma = ((flags & P_COMMA) && *origval != NUL
4639 && *newval != NUL);
4640 if (adding)
4642 i = (int)STRLEN(origval);
4643 mch_memmove(newval + i + comma, newval,
4644 STRLEN(newval) + 1);
4645 mch_memmove(newval, origval, (size_t)i);
4647 else
4649 i = (int)STRLEN(newval);
4650 STRMOVE(newval + i + comma, origval);
4652 if (comma)
4653 newval[i] = ',';
4656 /* Remove newval[] from origval[]. (Note: "i" has
4657 * been set above and is used here). */
4658 if (removing)
4660 STRCPY(newval, origval);
4661 if (*s)
4663 /* may need to remove a comma */
4664 if (flags & P_COMMA)
4666 if (s == origval)
4668 /* include comma after string */
4669 if (s[i] == ',')
4670 ++i;
4672 else
4674 /* include comma before string */
4675 --s;
4676 ++i;
4679 STRMOVE(newval + (s - origval), s + i);
4683 if (flags & P_FLAGLIST)
4685 /* Remove flags that appear twice. */
4686 for (s = newval; *s; ++s)
4687 if ((!(flags & P_COMMA) || *s != ',')
4688 && vim_strchr(s + 1, *s) != NULL)
4690 STRMOVE(s, s + 1);
4691 --s;
4695 if (save_arg != NULL) /* number for 'whichwrap' */
4696 arg = save_arg;
4697 new_value_alloced = TRUE;
4700 /* Set the new value. */
4701 *(char_u **)(varp) = newval;
4703 /* Handle side effects, and set the global value for
4704 * ":set" on local options. */
4705 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4706 new_value_alloced, oldval, errbuf, opt_flags);
4708 /* If error detected, print the error message. */
4709 if (errmsg != NULL)
4710 goto skip;
4712 else /* key code option */
4714 char_u *p;
4716 if (nextchar == '&')
4718 if (add_termcap_entry(key_name, TRUE) == FAIL)
4719 errmsg = (char_u *)N_("E522: Not found in termcap");
4721 else
4723 ++arg; /* jump to after the '=' or ':' */
4724 for (p = arg; *p && !vim_iswhite(*p); ++p)
4725 if (*p == '\\' && p[1] != NUL)
4726 ++p;
4727 nextchar = *p;
4728 *p = NUL;
4729 add_termcode(key_name, arg, FALSE);
4730 *p = nextchar;
4732 if (full_screen)
4733 ttest(FALSE);
4734 redraw_all_later(CLEAR);
4738 if (opt_idx >= 0)
4739 did_set_option(opt_idx, opt_flags,
4740 !prepending && !adding && !removing);
4743 skip:
4745 * Advance to next argument.
4746 * - skip until a blank found, taking care of backslashes
4747 * - skip blanks
4748 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4750 for (i = 0; i < 2 ; ++i)
4752 while (*arg != NUL && !vim_iswhite(*arg))
4753 if (*arg++ == '\\' && *arg != NUL)
4754 ++arg;
4755 arg = skipwhite(arg);
4756 if (*arg != '=')
4757 break;
4761 if (errmsg != NULL)
4763 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
4764 i = (int)STRLEN(IObuff) + 2;
4765 if (i + (arg - startarg) < IOSIZE)
4767 /* append the argument with the error */
4768 STRCAT(IObuff, ": ");
4769 mch_memmove(IObuff + i, startarg, (arg - startarg));
4770 IObuff[i + (arg - startarg)] = NUL;
4772 /* make sure all characters are printable */
4773 trans_characters(IObuff, IOSIZE);
4775 ++no_wait_return; /* wait_return done later */
4776 emsg(IObuff); /* show error highlighted */
4777 --no_wait_return;
4779 return FAIL;
4782 arg = skipwhite(arg);
4785 theend:
4786 if (silent_mode && did_show)
4788 /* After displaying option values in silent mode. */
4789 silent_mode = FALSE;
4790 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
4791 msg_putchar('\n');
4792 cursor_on(); /* msg_start() switches it off */
4793 out_flush();
4794 silent_mode = TRUE;
4795 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
4798 return OK;
4802 * Call this when an option has been given a new value through a user command.
4803 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4805 static void
4806 did_set_option(opt_idx, opt_flags, new_value)
4807 int opt_idx;
4808 int opt_flags; /* possibly with OPT_MODELINE */
4809 int new_value; /* value was replaced completely */
4811 long_u *p;
4813 options[opt_idx].flags |= P_WAS_SET;
4815 /* When an option is set in the sandbox, from a modeline or in secure mode
4816 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
4817 * flag. */
4818 p = insecure_flag(opt_idx, opt_flags);
4819 if (secure
4820 #ifdef HAVE_SANDBOX
4821 || sandbox != 0
4822 #endif
4823 || (opt_flags & OPT_MODELINE))
4824 *p = *p | P_INSECURE;
4825 else if (new_value)
4826 *p = *p & ~P_INSECURE;
4829 static char_u *
4830 illegal_char(errbuf, c)
4831 char_u *errbuf;
4832 int c;
4834 if (errbuf == NULL)
4835 return (char_u *)"";
4836 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
4837 (char *)transchar(c));
4838 return errbuf;
4842 * Convert a key name or string into a key value.
4843 * Used for 'wildchar' and 'cedit' options.
4845 static int
4846 string_to_key(arg)
4847 char_u *arg;
4849 if (*arg == '<')
4850 return find_key_option(arg + 1);
4851 if (*arg == '^')
4852 return Ctrl_chr(arg[1]);
4853 return *arg;
4856 #ifdef FEAT_CMDWIN
4858 * Check value of 'cedit' and set cedit_key.
4859 * Returns NULL if value is OK, error message otherwise.
4861 static char_u *
4862 check_cedit()
4864 int n;
4866 if (*p_cedit == NUL)
4867 cedit_key = -1;
4868 else
4870 n = string_to_key(p_cedit);
4871 if (vim_isprintc(n))
4872 return e_invarg;
4873 cedit_key = n;
4875 return NULL;
4877 #endif
4879 #ifdef FEAT_TITLE
4881 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
4882 * maketitle() to create and display it.
4883 * When switching the title or icon off, call mch_restore_title() to get
4884 * the old value back.
4886 static void
4887 did_set_title(icon)
4888 int icon; /* Did set icon instead of title */
4890 if (starting != NO_SCREEN
4891 #ifdef FEAT_GUI
4892 && !gui.starting
4893 #endif
4896 maketitle();
4897 if (icon)
4899 if (!p_icon)
4900 mch_restore_title(2);
4902 else
4904 if (!p_title)
4905 mch_restore_title(1);
4909 #endif
4912 * set_options_bin - called when 'bin' changes value.
4914 void
4915 set_options_bin(oldval, newval, opt_flags)
4916 int oldval;
4917 int newval;
4918 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
4921 * The option values that are changed when 'bin' changes are
4922 * copied when 'bin is set and restored when 'bin' is reset.
4924 if (newval)
4926 if (!oldval) /* switched on */
4928 if (!(opt_flags & OPT_GLOBAL))
4930 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
4931 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
4932 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
4933 curbuf->b_p_et_nobin = curbuf->b_p_et;
4935 if (!(opt_flags & OPT_LOCAL))
4937 p_tw_nobin = p_tw;
4938 p_wm_nobin = p_wm;
4939 p_ml_nobin = p_ml;
4940 p_et_nobin = p_et;
4944 if (!(opt_flags & OPT_GLOBAL))
4946 curbuf->b_p_tw = 0; /* no automatic line wrap */
4947 curbuf->b_p_wm = 0; /* no automatic line wrap */
4948 curbuf->b_p_ml = 0; /* no modelines */
4949 curbuf->b_p_et = 0; /* no expandtab */
4951 if (!(opt_flags & OPT_LOCAL))
4953 p_tw = 0;
4954 p_wm = 0;
4955 p_ml = FALSE;
4956 p_et = FALSE;
4957 p_bin = TRUE; /* needed when called for the "-b" argument */
4960 else if (oldval) /* switched off */
4962 if (!(opt_flags & OPT_GLOBAL))
4964 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
4965 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
4966 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
4967 curbuf->b_p_et = curbuf->b_p_et_nobin;
4969 if (!(opt_flags & OPT_LOCAL))
4971 p_tw = p_tw_nobin;
4972 p_wm = p_wm_nobin;
4973 p_ml = p_ml_nobin;
4974 p_et = p_et_nobin;
4979 #ifdef FEAT_VIMINFO
4981 * Find the parameter represented by the given character (eg ', :, ", or /),
4982 * and return its associated value in the 'viminfo' string.
4983 * Only works for number parameters, not for 'r' or 'n'.
4984 * If the parameter is not specified in the string or there is no following
4985 * number, return -1.
4988 get_viminfo_parameter(type)
4989 int type;
4991 char_u *p;
4993 p = find_viminfo_parameter(type);
4994 if (p != NULL && VIM_ISDIGIT(*p))
4995 return atoi((char *)p);
4996 return -1;
5000 * Find the parameter represented by the given character (eg ''', ':', '"', or
5001 * '/') in the 'viminfo' option and return a pointer to the string after it.
5002 * Return NULL if the parameter is not specified in the string.
5004 char_u *
5005 find_viminfo_parameter(type)
5006 int type;
5008 char_u *p;
5010 for (p = p_viminfo; *p; ++p)
5012 if (*p == type)
5013 return p + 1;
5014 if (*p == 'n') /* 'n' is always the last one */
5015 break;
5016 p = vim_strchr(p, ','); /* skip until next ',' */
5017 if (p == NULL) /* hit the end without finding parameter */
5018 break;
5020 return NULL;
5022 #endif
5025 * Expand environment variables for some string options.
5026 * These string options cannot be indirect!
5027 * If "val" is NULL expand the current value of the option.
5028 * Return pointer to NameBuff, or NULL when not expanded.
5030 static char_u *
5031 option_expand(opt_idx, val)
5032 int opt_idx;
5033 char_u *val;
5035 /* if option doesn't need expansion nothing to do */
5036 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5037 return NULL;
5039 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5040 * expand_env() would truncate the string. */
5041 if (val != NULL && STRLEN(val) > MAXPATHL)
5042 return NULL;
5044 if (val == NULL)
5045 val = *(char_u **)options[opt_idx].var;
5048 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5049 * Escape spaces when expanding 'tags', they are used to separate file
5050 * names.
5051 * For 'spellsuggest' expand after "file:".
5053 expand_env_esc(val, NameBuff, MAXPATHL,
5054 (char_u **)options[opt_idx].var == &p_tags, FALSE,
5055 #ifdef FEAT_SPELL
5056 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5057 #endif
5058 NULL);
5059 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5060 return NULL;
5062 return NameBuff;
5066 * After setting various option values: recompute variables that depend on
5067 * option values.
5069 static void
5070 didset_options()
5072 /* initialize the table for 'iskeyword' et.al. */
5073 (void)init_chartab();
5075 #ifdef FEAT_MBYTE
5076 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
5077 #endif
5078 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5079 #ifdef FEAT_SESSION
5080 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5081 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5082 #endif
5083 #ifdef FEAT_FOLDING
5084 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5085 #endif
5086 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5087 #ifdef FEAT_VIRTUALEDIT
5088 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5089 #endif
5090 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5091 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5092 #endif
5093 #ifdef FEAT_SPELL
5094 (void)spell_check_msm();
5095 (void)spell_check_sps();
5096 (void)compile_cap_prog(curbuf);
5097 #endif
5098 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5099 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5100 #endif
5101 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
5102 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5103 #endif
5104 #ifdef FEAT_CMDWIN
5105 /* set cedit_key */
5106 (void)check_cedit();
5107 #endif
5111 * Check for string options that are NULL (normally only termcap options).
5113 void
5114 check_options()
5116 int opt_idx;
5118 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5119 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5120 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5124 * Check string options in a buffer for NULL value.
5126 void
5127 check_buf_options(buf)
5128 buf_T *buf;
5130 #if defined(FEAT_QUICKFIX)
5131 check_string_option(&buf->b_p_bh);
5132 check_string_option(&buf->b_p_bt);
5133 #endif
5134 #ifdef FEAT_MBYTE
5135 check_string_option(&buf->b_p_fenc);
5136 #endif
5137 check_string_option(&buf->b_p_ff);
5138 #ifdef FEAT_FIND_ID
5139 check_string_option(&buf->b_p_def);
5140 check_string_option(&buf->b_p_inc);
5141 # ifdef FEAT_EVAL
5142 check_string_option(&buf->b_p_inex);
5143 # endif
5144 #endif
5145 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5146 check_string_option(&buf->b_p_inde);
5147 check_string_option(&buf->b_p_indk);
5148 #endif
5149 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5150 check_string_option(&buf->b_p_bexpr);
5151 #endif
5152 #if defined(FEAT_EVAL)
5153 check_string_option(&buf->b_p_fex);
5154 #endif
5155 #ifdef FEAT_CRYPT
5156 check_string_option(&buf->b_p_key);
5157 #endif
5158 check_string_option(&buf->b_p_kp);
5159 check_string_option(&buf->b_p_mps);
5160 check_string_option(&buf->b_p_fo);
5161 check_string_option(&buf->b_p_flp);
5162 check_string_option(&buf->b_p_isk);
5163 #ifdef FEAT_COMMENTS
5164 check_string_option(&buf->b_p_com);
5165 #endif
5166 #ifdef FEAT_FOLDING
5167 check_string_option(&buf->b_p_cms);
5168 #endif
5169 check_string_option(&buf->b_p_nf);
5170 #ifdef FEAT_TEXTOBJ
5171 check_string_option(&buf->b_p_qe);
5172 #endif
5173 #ifdef FEAT_SYN_HL
5174 check_string_option(&buf->b_p_syn);
5175 #endif
5176 #ifdef FEAT_SPELL
5177 check_string_option(&buf->b_p_spc);
5178 check_string_option(&buf->b_p_spf);
5179 check_string_option(&buf->b_p_spl);
5180 #endif
5181 #ifdef FEAT_SEARCHPATH
5182 check_string_option(&buf->b_p_sua);
5183 #endif
5184 #ifdef FEAT_CINDENT
5185 check_string_option(&buf->b_p_cink);
5186 check_string_option(&buf->b_p_cino);
5187 #endif
5188 #ifdef FEAT_AUTOCMD
5189 check_string_option(&buf->b_p_ft);
5190 #endif
5191 #ifdef FEAT_OSFILETYPE
5192 check_string_option(&buf->b_p_oft);
5193 #endif
5194 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5195 check_string_option(&buf->b_p_cinw);
5196 #endif
5197 #ifdef FEAT_INS_EXPAND
5198 check_string_option(&buf->b_p_cpt);
5199 #endif
5200 #ifdef FEAT_COMPL_FUNC
5201 check_string_option(&buf->b_p_cfu);
5202 check_string_option(&buf->b_p_ofu);
5203 #endif
5204 #ifdef FEAT_KEYMAP
5205 check_string_option(&buf->b_p_keymap);
5206 #endif
5207 #ifdef FEAT_QUICKFIX
5208 check_string_option(&buf->b_p_gp);
5209 check_string_option(&buf->b_p_mp);
5210 check_string_option(&buf->b_p_efm);
5211 #endif
5212 check_string_option(&buf->b_p_ep);
5213 check_string_option(&buf->b_p_path);
5214 check_string_option(&buf->b_p_tags);
5215 #ifdef FEAT_INS_EXPAND
5216 check_string_option(&buf->b_p_dict);
5217 check_string_option(&buf->b_p_tsr);
5218 #endif
5222 * Free the string allocated for an option.
5223 * Checks for the string being empty_option. This may happen if we're out of
5224 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5225 * check_options().
5226 * Does NOT check for P_ALLOCED flag!
5228 void
5229 free_string_option(p)
5230 char_u *p;
5232 if (p != empty_option)
5233 vim_free(p);
5236 void
5237 clear_string_option(pp)
5238 char_u **pp;
5240 if (*pp != empty_option)
5241 vim_free(*pp);
5242 *pp = empty_option;
5245 static void
5246 check_string_option(pp)
5247 char_u **pp;
5249 if (*pp == NULL)
5250 *pp = empty_option;
5254 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5256 void
5257 set_term_option_alloced(p)
5258 char_u **p;
5260 int opt_idx;
5262 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5263 if (options[opt_idx].var == (char_u *)p)
5265 options[opt_idx].flags |= P_ALLOCED;
5266 return;
5268 return; /* cannot happen: didn't find it! */
5271 #if defined(FEAT_EVAL) || defined(PROTO)
5273 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5274 * Return FALSE when it wasn't.
5275 * Return -1 for an unknown option.
5278 was_set_insecurely(opt, opt_flags)
5279 char_u *opt;
5280 int opt_flags;
5282 int idx = findoption(opt);
5283 long_u *flagp;
5285 if (idx >= 0)
5287 flagp = insecure_flag(idx, opt_flags);
5288 return (*flagp & P_INSECURE) != 0;
5290 EMSG2(_(e_intern2), "was_set_insecurely()");
5291 return -1;
5295 * Get a pointer to the flags used for the P_INSECURE flag of option
5296 * "opt_idx". For some local options a local flags field is used.
5298 static long_u *
5299 insecure_flag(opt_idx, opt_flags)
5300 int opt_idx;
5301 int opt_flags;
5303 if (opt_flags & OPT_LOCAL)
5304 switch ((int)options[opt_idx].indir)
5306 #ifdef FEAT_STL_OPT
5307 case PV_STL: return &curwin->w_p_stl_flags;
5308 #endif
5309 #ifdef FEAT_EVAL
5310 # ifdef FEAT_FOLDING
5311 case PV_FDE: return &curwin->w_p_fde_flags;
5312 case PV_FDT: return &curwin->w_p_fdt_flags;
5313 # endif
5314 # ifdef FEAT_BEVAL
5315 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5316 # endif
5317 # if defined(FEAT_CINDENT)
5318 case PV_INDE: return &curbuf->b_p_inde_flags;
5319 # endif
5320 case PV_FEX: return &curbuf->b_p_fex_flags;
5321 # ifdef FEAT_FIND_ID
5322 case PV_INEX: return &curbuf->b_p_inex_flags;
5323 # endif
5324 #endif
5327 /* Nothing special, return global flags field. */
5328 return &options[opt_idx].flags;
5330 #endif
5332 #ifdef FEAT_TITLE
5333 static void redraw_titles __ARGS((void));
5336 * Redraw the window title and/or tab page text later.
5338 static void redraw_titles()
5340 need_maketitle = TRUE;
5341 # ifdef FEAT_WINDOWS
5342 redraw_tabline = TRUE;
5343 # endif
5345 #endif
5348 * Set a string option to a new value (without checking the effect).
5349 * The string is copied into allocated memory.
5350 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
5351 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
5352 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
5354 void
5355 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
5356 char_u *name;
5357 int opt_idx;
5358 char_u *val;
5359 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5360 int set_sid UNUSED;
5362 char_u *s;
5363 char_u **varp;
5364 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
5365 int idx = opt_idx;
5367 if (idx == -1) /* use name */
5369 idx = findoption(name);
5370 if (idx < 0) /* not found (should not happen) */
5372 EMSG2(_(e_intern2), "set_string_option_direct()");
5373 return;
5377 if (options[idx].var == NULL) /* can't set hidden option */
5378 return;
5380 s = vim_strsave(val);
5381 if (s != NULL)
5383 varp = (char_u **)get_varp_scope(&(options[idx]),
5384 both ? OPT_LOCAL : opt_flags);
5385 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
5386 free_string_option(*varp);
5387 *varp = s;
5389 /* For buffer/window local option may also set the global value. */
5390 if (both)
5391 set_string_option_global(idx, varp);
5393 options[idx].flags |= P_ALLOCED;
5395 /* When setting both values of a global option with a local value,
5396 * make the local value empty, so that the global value is used. */
5397 if (((int)options[idx].indir & PV_BOTH) && both)
5399 free_string_option(*varp);
5400 *varp = empty_option;
5402 # ifdef FEAT_EVAL
5403 if (set_sid != SID_NONE)
5404 set_option_scriptID_idx(idx, opt_flags,
5405 set_sid == 0 ? current_SID : set_sid);
5406 # endif
5411 * Set global value for string option when it's a local option.
5413 static void
5414 set_string_option_global(opt_idx, varp)
5415 int opt_idx; /* option index */
5416 char_u **varp; /* pointer to option variable */
5418 char_u **p, *s;
5420 /* the global value is always allocated */
5421 if (options[opt_idx].var == VAR_WIN)
5422 p = (char_u **)GLOBAL_WO(varp);
5423 else
5424 p = (char_u **)options[opt_idx].var;
5425 if (options[opt_idx].indir != PV_NONE
5426 && p != varp
5427 && (s = vim_strsave(*varp)) != NULL)
5429 free_string_option(*p);
5430 *p = s;
5435 * Set a string option to a new value, and handle the effects.
5437 static void
5438 set_string_option(opt_idx, value, opt_flags)
5439 int opt_idx;
5440 char_u *value;
5441 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5443 char_u *s;
5444 char_u **varp;
5445 char_u *oldval;
5447 if (options[opt_idx].var == NULL) /* don't set hidden option */
5448 return;
5450 s = vim_strsave(value);
5451 if (s != NULL)
5453 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5454 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
5455 ? (((int)options[opt_idx].indir & PV_BOTH)
5456 ? OPT_GLOBAL : OPT_LOCAL)
5457 : opt_flags);
5458 oldval = *varp;
5459 *varp = s;
5460 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5461 opt_flags) == NULL)
5462 did_set_option(opt_idx, opt_flags, TRUE);
5467 * Handle string options that need some action to perform when changed.
5468 * Returns NULL for success, or an error message for an error.
5470 static char_u *
5471 did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5472 opt_flags)
5473 int opt_idx; /* index in options[] table */
5474 char_u **varp; /* pointer to the option variable */
5475 int new_value_alloced; /* new value was allocated */
5476 char_u *oldval; /* previous value of the option */
5477 char_u *errbuf; /* buffer for errors, or NULL */
5478 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5480 char_u *errmsg = NULL;
5481 char_u *s, *p;
5482 int did_chartab = FALSE;
5483 char_u **gvarp;
5484 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
5485 #ifdef FEAT_GUI
5486 /* set when changing an option that only requires a redraw in the GUI */
5487 int redraw_gui_only = FALSE;
5488 #endif
5490 /* Get the global option to compare with, otherwise we would have to check
5491 * two values for all local options. */
5492 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5494 /* Disallow changing some options from secure mode */
5495 if ((secure
5496 #ifdef HAVE_SANDBOX
5497 || sandbox != 0
5498 #endif
5499 ) && (options[opt_idx].flags & P_SECURE))
5501 errmsg = e_secure;
5504 /* Check for a "normal" file name in some options. Disallow a path
5505 * separator (slash and/or backslash), wildcards and characters that are
5506 * often illegal in a file name. */
5507 else if ((options[opt_idx].flags & P_NFNAME)
5508 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
5510 errmsg = e_invarg;
5513 /* 'term' */
5514 else if (varp == &T_NAME)
5516 if (T_NAME[0] == NUL)
5517 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5518 #ifdef FEAT_GUI
5519 if (gui.in_use)
5520 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5521 else if (term_is_gui(T_NAME))
5522 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5523 #endif
5524 else if (set_termname(T_NAME) == FAIL)
5525 errmsg = (char_u *)N_("E522: Not found in termcap");
5526 else
5527 /* Screen colors may have changed. */
5528 redraw_later_clear();
5531 /* 'backupcopy' */
5532 else if (varp == &p_bkc)
5534 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
5535 errmsg = e_invarg;
5536 if (((bkc_flags & BKC_AUTO) != 0)
5537 + ((bkc_flags & BKC_YES) != 0)
5538 + ((bkc_flags & BKC_NO) != 0) != 1)
5540 /* Must have exactly one of "auto", "yes" and "no". */
5541 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
5542 errmsg = e_invarg;
5546 /* 'backupext' and 'patchmode' */
5547 else if (varp == &p_bex || varp == &p_pm)
5549 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5550 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5551 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5555 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5556 * If the new option is invalid, use old value. 'lisp' option: refill
5557 * chartab[] for '-' char
5559 else if ( varp == &p_isi
5560 || varp == &(curbuf->b_p_isk)
5561 || varp == &p_isp
5562 || varp == &p_isf)
5564 if (init_chartab() == FAIL)
5566 did_chartab = TRUE; /* need to restore it below */
5567 errmsg = e_invarg; /* error in value */
5571 /* 'helpfile' */
5572 else if (varp == &p_hf)
5574 /* May compute new values for $VIM and $VIMRUNTIME */
5575 if (didset_vim)
5577 vim_setenv((char_u *)"VIM", (char_u *)"");
5578 didset_vim = FALSE;
5580 if (didset_vimruntime)
5582 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5583 didset_vimruntime = FALSE;
5587 #ifdef FEAT_MULTI_LANG
5588 /* 'helplang' */
5589 else if (varp == &p_hlg)
5591 /* Check for "", "ab", "ab,cd", etc. */
5592 for (s = p_hlg; *s != NUL; s += 3)
5594 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5596 errmsg = e_invarg;
5597 break;
5599 if (s[2] == NUL)
5600 break;
5603 #endif
5605 /* 'highlight' */
5606 else if (varp == &p_hl)
5608 if (highlight_changed() == FAIL)
5609 errmsg = e_invarg; /* invalid flags */
5612 /* 'nrformats' */
5613 else if (gvarp == &p_nf)
5615 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5616 errmsg = e_invarg;
5619 #ifdef FEAT_SESSION
5620 /* 'sessionoptions' */
5621 else if (varp == &p_ssop)
5623 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5624 errmsg = e_invarg;
5625 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5627 /* Don't allow both "sesdir" and "curdir". */
5628 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5629 errmsg = e_invarg;
5632 /* 'viewoptions' */
5633 else if (varp == &p_vop)
5635 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5636 errmsg = e_invarg;
5638 #endif
5640 /* 'scrollopt' */
5641 #ifdef FEAT_SCROLLBIND
5642 else if (varp == &p_sbo)
5644 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5645 errmsg = e_invarg;
5647 #endif
5649 /* 'ambiwidth' */
5650 #ifdef FEAT_MBYTE
5651 else if (varp == &p_ambw)
5653 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5654 errmsg = e_invarg;
5656 #endif
5658 /* 'background' */
5659 else if (varp == &p_bg)
5661 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5663 #ifdef FEAT_EVAL
5664 int dark = (*p_bg == 'd');
5665 #endif
5667 init_highlight(FALSE, FALSE);
5669 #ifdef FEAT_EVAL
5670 if (dark != (*p_bg == 'd')
5671 && get_var_value((char_u *)"g:colors_name") != NULL)
5673 /* The color scheme must have set 'background' back to another
5674 * value, that's not what we want here. Disable the color
5675 * scheme and set the colors again. */
5676 do_unlet((char_u *)"g:colors_name", TRUE);
5677 free_string_option(p_bg);
5678 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5679 check_string_option(&p_bg);
5680 init_highlight(FALSE, FALSE);
5682 #endif
5684 else
5685 errmsg = e_invarg;
5688 /* 'wildmode' */
5689 else if (varp == &p_wim)
5691 if (check_opt_wim() == FAIL)
5692 errmsg = e_invarg;
5695 #ifdef FEAT_CMDL_COMPL
5696 /* 'wildoptions' */
5697 else if (varp == &p_wop)
5699 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
5700 errmsg = e_invarg;
5702 #endif
5704 #ifdef FEAT_WAK
5705 /* 'winaltkeys' */
5706 else if (varp == &p_wak)
5708 if (*p_wak == NUL
5709 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
5710 errmsg = e_invarg;
5711 # ifdef FEAT_MENU
5712 # ifdef FEAT_GUI_MOTIF
5713 else if (gui.in_use)
5714 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5715 # else
5716 # ifdef FEAT_GUI_GTK
5717 else if (gui.in_use)
5718 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5719 # endif
5720 # endif
5721 # endif
5723 #endif
5725 #ifdef FEAT_AUTOCMD
5726 /* 'eventignore' */
5727 else if (varp == &p_ei)
5729 if (check_ei() == FAIL)
5730 errmsg = e_invarg;
5732 #endif
5734 #ifdef FEAT_MBYTE
5735 /* 'encoding' and 'fileencoding' */
5736 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
5738 if (gvarp == &p_fenc)
5740 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
5741 errmsg = e_modifiable;
5742 else if (vim_strchr(*varp, ',') != NULL)
5743 /* No comma allowed in 'fileencoding'; catches confusing it
5744 * with 'fileencodings'. */
5745 errmsg = e_invarg;
5746 else
5748 # ifdef FEAT_TITLE
5749 /* May show a "+" in the title now. */
5750 redraw_titles();
5751 # endif
5752 /* Add 'fileencoding' to the swap file. */
5753 ml_setflags(curbuf);
5756 if (errmsg == NULL)
5758 /* canonize the value, so that STRCMP() can be used on it */
5759 p = enc_canonize(*varp);
5760 if (p != NULL)
5762 vim_free(*varp);
5763 *varp = p;
5765 if (varp == &p_enc)
5767 errmsg = mb_init();
5768 # ifdef FEAT_TITLE
5769 redraw_titles();
5770 # endif
5774 # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
5775 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
5777 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
5778 if (STRCMP(p_tenc, "utf-8") != 0)
5779 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
5781 # endif
5783 if (errmsg == NULL)
5785 # ifdef FEAT_KEYMAP
5786 /* When 'keymap' is used and 'encoding' changes, reload the keymap
5787 * (with another encoding). */
5788 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
5789 (void)keymap_init();
5790 # endif
5792 /* When 'termencoding' is not empty and 'encoding' changes or when
5793 * 'termencoding' changes, need to setup for keyboard input and
5794 * display output conversion. */
5795 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
5797 convert_setup(&input_conv, p_tenc, p_enc);
5798 convert_setup(&output_conv, p_enc, p_tenc);
5801 # if defined(WIN3264) && defined(FEAT_MBYTE)
5802 /* $HOME may have characters in active code page. */
5803 if (varp == &p_enc)
5804 init_homedir();
5805 # endif
5808 #endif
5810 #if defined(FEAT_POSTSCRIPT)
5811 else if (varp == &p_penc)
5813 /* Canonize printencoding if VIM standard one */
5814 p = enc_canonize(p_penc);
5815 if (p != NULL)
5817 vim_free(p_penc);
5818 p_penc = p;
5820 else
5822 /* Ensure lower case and '-' for '_' */
5823 for (s = p_penc; *s != NUL; s++)
5825 if (*s == '_')
5826 *s = '-';
5827 else
5828 *s = TOLOWER_ASC(*s);
5832 #endif
5834 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
5835 else if (varp == &p_imak)
5837 if (gui.in_use && !im_xim_isvalid_imactivate())
5838 errmsg = e_invarg;
5840 #endif
5842 #ifdef FEAT_KEYMAP
5843 else if (varp == &curbuf->b_p_keymap)
5845 /* load or unload key mapping tables */
5846 errmsg = keymap_init();
5848 if (errmsg == NULL)
5850 if (*curbuf->b_p_keymap != NUL)
5852 /* Installed a new keymap, switch on using it. */
5853 curbuf->b_p_iminsert = B_IMODE_LMAP;
5854 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
5855 curbuf->b_p_imsearch = B_IMODE_LMAP;
5857 else
5859 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
5860 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
5861 curbuf->b_p_iminsert = B_IMODE_NONE;
5862 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
5863 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
5865 if ((opt_flags & OPT_LOCAL) == 0)
5867 set_iminsert_global();
5868 set_imsearch_global();
5870 # ifdef FEAT_WINDOWS
5871 status_redraw_curbuf();
5872 # endif
5875 #endif
5877 /* 'fileformat' */
5878 else if (gvarp == &p_ff)
5880 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
5881 errmsg = e_modifiable;
5882 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
5883 errmsg = e_invarg;
5884 else
5886 /* may also change 'textmode' */
5887 if (get_fileformat(curbuf) == EOL_DOS)
5888 curbuf->b_p_tx = TRUE;
5889 else
5890 curbuf->b_p_tx = FALSE;
5891 #ifdef FEAT_TITLE
5892 redraw_titles();
5893 #endif
5894 /* update flag in swap file */
5895 ml_setflags(curbuf);
5896 /* Redraw needed when switching to/from "mac": a CR in the text
5897 * will be displayed differently. */
5898 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
5899 redraw_curbuf_later(NOT_VALID);
5903 /* 'fileformats' */
5904 else if (varp == &p_ffs)
5906 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
5907 errmsg = e_invarg;
5908 else
5910 /* also change 'textauto' */
5911 if (*p_ffs == NUL)
5912 p_ta = FALSE;
5913 else
5914 p_ta = TRUE;
5918 #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST)
5919 /* 'cryptkey' */
5920 else if (gvarp == &p_key)
5922 /* Make sure the ":set" command doesn't show the new value in the
5923 * history. */
5924 remove_key_from_history();
5926 #endif
5928 /* 'matchpairs' */
5929 else if (gvarp == &p_mps)
5931 /* Check for "x:y,x:y" */
5932 for (p = *varp; *p != NUL; p += 4)
5934 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
5936 errmsg = e_invarg;
5937 break;
5939 if (p[3] == NUL)
5940 break;
5944 #ifdef FEAT_COMMENTS
5945 /* 'comments' */
5946 else if (gvarp == &p_com)
5948 for (s = *varp; *s; )
5950 while (*s && *s != ':')
5952 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
5953 && !VIM_ISDIGIT(*s) && *s != '-')
5955 errmsg = illegal_char(errbuf, *s);
5956 break;
5958 ++s;
5960 if (*s++ == NUL)
5961 errmsg = (char_u *)N_("E524: Missing colon");
5962 else if (*s == ',' || *s == NUL)
5963 errmsg = (char_u *)N_("E525: Zero length string");
5964 if (errmsg != NULL)
5965 break;
5966 while (*s && *s != ',')
5968 if (*s == '\\' && s[1] != NUL)
5969 ++s;
5970 ++s;
5972 s = skip_to_option_part(s);
5975 #endif
5977 /* 'listchars' */
5978 else if (varp == &p_lcs)
5980 errmsg = set_chars_option(varp);
5983 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5984 /* 'fillchars' */
5985 else if (varp == &p_fcs)
5987 errmsg = set_chars_option(varp);
5989 #endif
5991 #ifdef FEAT_CMDWIN
5992 /* 'cedit' */
5993 else if (varp == &p_cedit)
5995 errmsg = check_cedit();
5997 #endif
5999 /* 'verbosefile' */
6000 else if (varp == &p_vfile)
6002 verbose_stop();
6003 if (*p_vfile != NUL && verbose_open() == FAIL)
6004 errmsg = e_invarg;
6007 #ifdef FEAT_VIMINFO
6008 /* 'viminfo' */
6009 else if (varp == &p_viminfo)
6011 for (s = p_viminfo; *s;)
6013 /* Check it's a valid character */
6014 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6016 errmsg = illegal_char(errbuf, *s);
6017 break;
6019 if (*s == 'n') /* name is always last one */
6021 break;
6023 else if (*s == 'r') /* skip until next ',' */
6025 while (*++s && *s != ',')
6028 else if (*s == '%')
6030 /* optional number */
6031 while (vim_isdigit(*++s))
6034 else if (*s == '!' || *s == 'h' || *s == 'c')
6035 ++s; /* no extra chars */
6036 else /* must have a number */
6038 while (vim_isdigit(*++s))
6041 if (!VIM_ISDIGIT(*(s - 1)))
6043 if (errbuf != NULL)
6045 sprintf((char *)errbuf,
6046 _("E526: Missing number after <%s>"),
6047 transchar_byte(*(s - 1)));
6048 errmsg = errbuf;
6050 else
6051 errmsg = (char_u *)"";
6052 break;
6055 if (*s == ',')
6056 ++s;
6057 else if (*s)
6059 if (errbuf != NULL)
6060 errmsg = (char_u *)N_("E527: Missing comma");
6061 else
6062 errmsg = (char_u *)"";
6063 break;
6066 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6067 errmsg = (char_u *)N_("E528: Must specify a ' value");
6069 #endif /* FEAT_VIMINFO */
6071 /* terminal options */
6072 else if (istermoption(&options[opt_idx]) && full_screen)
6074 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6075 if (varp == &T_CCO)
6077 int colors = atoi((char *)T_CCO);
6079 /* Only reinitialize colors if t_Co value has really changed to
6080 * avoid expensive reload of colorscheme if t_Co is set to the
6081 * same value multiple times. */
6082 if (colors != t_colors)
6084 t_colors = colors;
6085 if (t_colors <= 1)
6087 if (new_value_alloced)
6088 vim_free(T_CCO);
6089 T_CCO = empty_option;
6091 /* We now have a different color setup, initialize it again. */
6092 init_highlight(TRUE, FALSE);
6095 ttest(FALSE);
6096 if (varp == &T_ME)
6098 out_str(T_ME);
6099 redraw_later(CLEAR);
6100 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6101 /* Since t_me has been set, this probably means that the user
6102 * wants to use this as default colors. Need to reset default
6103 * background/foreground colors. */
6104 mch_set_normal_colors();
6105 #endif
6109 #ifdef FEAT_LINEBREAK
6110 /* 'showbreak' */
6111 else if (varp == &p_sbr)
6113 for (s = p_sbr; *s; )
6115 if (ptr2cells(s) != 1)
6116 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
6117 mb_ptr_adv(s);
6120 #endif
6122 #ifdef FEAT_GUI
6123 /* 'guifont' */
6124 else if (varp == &p_guifont)
6126 if (gui.in_use)
6128 p = p_guifont;
6129 # if defined(FEAT_GUI_GTK)
6131 * Put up a font dialog and let the user select a new value.
6132 * If this is cancelled go back to the old value but don't
6133 * give an error message.
6135 if (STRCMP(p, "*") == 0)
6137 p = gui_mch_font_dialog(oldval);
6139 if (new_value_alloced)
6140 free_string_option(p_guifont);
6142 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6143 new_value_alloced = TRUE;
6145 # endif
6146 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6148 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6149 if (STRCMP(p_guifont, "*") == 0)
6151 /* Dialog was cancelled: Keep the old value without giving
6152 * an error message. */
6153 if (new_value_alloced)
6154 free_string_option(p_guifont);
6155 p_guifont = vim_strsave(oldval);
6156 new_value_alloced = TRUE;
6158 else
6159 # endif
6160 errmsg = (char_u *)N_("E596: Invalid font(s)");
6163 redraw_gui_only = TRUE;
6165 # ifdef FEAT_XFONTSET
6166 else if (varp == &p_guifontset)
6168 if (STRCMP(p_guifontset, "*") == 0)
6169 errmsg = (char_u *)N_("E597: can't select fontset");
6170 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6171 errmsg = (char_u *)N_("E598: Invalid fontset");
6172 redraw_gui_only = TRUE;
6174 # endif
6175 # ifdef FEAT_MBYTE
6176 else if (varp == &p_guifontwide)
6178 if (STRCMP(p_guifontwide, "*") == 0)
6179 errmsg = (char_u *)N_("E533: can't select wide font");
6180 else if (gui_get_wide_font() == FAIL)
6181 errmsg = (char_u *)N_("E534: Invalid wide font");
6182 redraw_gui_only = TRUE;
6184 # endif
6185 #endif
6187 #ifdef CURSOR_SHAPE
6188 /* 'guicursor' */
6189 else if (varp == &p_guicursor)
6190 errmsg = parse_shape_opt(SHAPE_CURSOR);
6191 #endif
6193 #ifdef FEAT_MOUSESHAPE
6194 /* 'mouseshape' */
6195 else if (varp == &p_mouseshape)
6197 errmsg = parse_shape_opt(SHAPE_MOUSE);
6198 update_mouseshape(-1);
6200 #endif
6202 #ifdef FEAT_PRINTER
6203 else if (varp == &p_popt)
6204 errmsg = parse_printoptions();
6205 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
6206 else if (varp == &p_pmfn)
6207 errmsg = parse_printmbfont();
6208 # endif
6209 #endif
6211 #ifdef FEAT_LANGMAP
6212 /* 'langmap' */
6213 else if (varp == &p_langmap)
6214 langmap_set();
6215 #endif
6217 #ifdef FEAT_LINEBREAK
6218 /* 'breakat' */
6219 else if (varp == &p_breakat)
6220 fill_breakat_flags();
6221 #endif
6223 #ifdef FEAT_TITLE
6224 /* 'titlestring' and 'iconstring' */
6225 else if (varp == &p_titlestring || varp == &p_iconstring)
6227 # ifdef FEAT_STL_OPT
6228 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6230 /* NULL => statusline syntax */
6231 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6232 stl_syntax |= flagval;
6233 else
6234 stl_syntax &= ~flagval;
6235 # endif
6236 did_set_title(varp == &p_iconstring);
6239 #endif
6241 #ifdef FEAT_GUI
6242 /* 'guioptions' */
6243 else if (varp == &p_go)
6245 gui_init_which_components(oldval);
6246 redraw_gui_only = TRUE;
6248 #endif
6250 #if defined(FEAT_GUI_TABLINE)
6251 /* 'guitablabel' */
6252 else if (varp == &p_gtl)
6254 redraw_tabline = TRUE;
6255 redraw_gui_only = TRUE;
6257 /* 'guitabtooltip' */
6258 else if (varp == &p_gtt)
6260 redraw_gui_only = TRUE;
6262 #endif
6264 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6265 /* 'ttymouse' */
6266 else if (varp == &p_ttym)
6268 /* Switch the mouse off before changing the escape sequences used for
6269 * that. */
6270 mch_setmouse(FALSE);
6271 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6272 errmsg = e_invarg;
6273 else
6274 check_mouse_termcode();
6275 if (termcap_active)
6276 setmouse(); /* may switch it on again */
6278 #endif
6280 #ifdef FEAT_VISUAL
6281 /* 'selection' */
6282 else if (varp == &p_sel)
6284 if (*p_sel == NUL
6285 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6286 errmsg = e_invarg;
6289 /* 'selectmode' */
6290 else if (varp == &p_slm)
6292 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6293 errmsg = e_invarg;
6295 #endif
6297 #ifdef FEAT_BROWSE
6298 /* 'browsedir' */
6299 else if (varp == &p_bsdir)
6301 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6302 && !mch_isdir(p_bsdir))
6303 errmsg = e_invarg;
6305 #endif
6307 #ifdef FEAT_VISUAL
6308 /* 'keymodel' */
6309 else if (varp == &p_km)
6311 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6312 errmsg = e_invarg;
6313 else
6315 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6316 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6319 #endif
6321 /* 'mousemodel' */
6322 else if (varp == &p_mousem)
6324 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6325 errmsg = e_invarg;
6326 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6327 else if (*p_mousem != *oldval)
6328 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6329 * to create or delete the popup menus. */
6330 gui_motif_update_mousemodel(root_menu);
6331 #endif
6334 /* 'switchbuf' */
6335 else if (varp == &p_swb)
6337 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
6338 errmsg = e_invarg;
6341 /* 'debug' */
6342 else if (varp == &p_debug)
6344 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
6345 errmsg = e_invarg;
6348 /* 'display' */
6349 else if (varp == &p_dy)
6351 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6352 errmsg = e_invarg;
6353 else
6354 (void)init_chartab();
6358 #ifdef FEAT_VERTSPLIT
6359 /* 'eadirection' */
6360 else if (varp == &p_ead)
6362 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6363 errmsg = e_invarg;
6365 #endif
6367 #ifdef FEAT_CLIPBOARD
6368 /* 'clipboard' */
6369 else if (varp == &p_cb)
6370 errmsg = check_clipboard_option();
6371 #endif
6373 #ifdef FEAT_SPELL
6374 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6375 * buffer in which 'spell' is set load the wordlists. */
6376 else if (varp == &(curbuf->b_p_spl) || varp == &(curbuf->b_p_spf))
6378 win_T *wp;
6379 int l;
6381 if (varp == &(curbuf->b_p_spf))
6383 l = (int)STRLEN(curbuf->b_p_spf);
6384 if (l > 0 && (l < 4 || STRCMP(curbuf->b_p_spf + l - 4,
6385 ".add") != 0))
6386 errmsg = e_invarg;
6389 if (errmsg == NULL)
6391 FOR_ALL_WINDOWS(wp)
6392 if (wp->w_buffer == curbuf && wp->w_p_spell)
6394 errmsg = did_set_spelllang(curbuf);
6395 # ifdef FEAT_WINDOWS
6396 break;
6397 # endif
6401 /* When 'spellcapcheck' is set compile the regexp program. */
6402 else if (varp == &(curbuf->b_p_spc))
6404 errmsg = compile_cap_prog(curbuf);
6406 /* 'spellsuggest' */
6407 else if (varp == &p_sps)
6409 if (spell_check_sps() != OK)
6410 errmsg = e_invarg;
6412 /* 'mkspellmem' */
6413 else if (varp == &p_msm)
6415 if (spell_check_msm() != OK)
6416 errmsg = e_invarg;
6418 #endif
6420 #ifdef FEAT_QUICKFIX
6421 /* When 'bufhidden' is set, check for valid value. */
6422 else if (gvarp == &p_bh)
6424 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6425 errmsg = e_invarg;
6428 /* When 'buftype' is set, check for valid value. */
6429 else if (gvarp == &p_bt)
6431 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6432 errmsg = e_invarg;
6433 else
6435 # ifdef FEAT_WINDOWS
6436 if (curwin->w_status_height)
6438 curwin->w_redr_status = TRUE;
6439 redraw_later(VALID);
6441 # endif
6442 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
6443 # ifdef FEAT_TITLE
6444 redraw_titles();
6445 # endif
6448 #endif
6450 #ifdef FEAT_STL_OPT
6451 /* 'statusline' or 'rulerformat' */
6452 else if (gvarp == &p_stl || varp == &p_ruf)
6454 int wid;
6456 if (varp == &p_ruf) /* reset ru_wid first */
6457 ru_wid = 0;
6458 s = *varp;
6459 if (varp == &p_ruf && *s == '%')
6461 /* set ru_wid if 'ruf' starts with "%99(" */
6462 if (*++s == '-') /* ignore a '-' */
6463 s++;
6464 wid = getdigits(&s);
6465 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6466 ru_wid = wid;
6467 else
6468 errmsg = check_stl_option(p_ruf);
6470 /* check 'statusline' only if it doesn't start with "%!" */
6471 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
6472 errmsg = check_stl_option(s);
6473 if (varp == &p_ruf && errmsg == NULL)
6474 comp_col();
6476 #endif
6478 #ifdef FEAT_INS_EXPAND
6479 /* check if it is a valid value for 'complete' -- Acevedo */
6480 else if (gvarp == &p_cpt)
6482 for (s = *varp; *s;)
6484 while(*s == ',' || *s == ' ')
6485 s++;
6486 if (!*s)
6487 break;
6488 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6490 errmsg = illegal_char(errbuf, *s);
6491 break;
6493 if (*++s != NUL && *s != ',' && *s != ' ')
6495 if (s[-1] == 'k' || s[-1] == 's')
6497 /* skip optional filename after 'k' and 's' */
6498 while (*s && *s != ',' && *s != ' ')
6500 if (*s == '\\')
6501 ++s;
6502 ++s;
6505 else
6507 if (errbuf != NULL)
6509 sprintf((char *)errbuf,
6510 _("E535: Illegal character after <%c>"),
6511 *--s);
6512 errmsg = errbuf;
6514 else
6515 errmsg = (char_u *)"";
6516 break;
6522 /* 'completeopt' */
6523 else if (varp == &p_cot)
6525 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6526 errmsg = e_invarg;
6528 #endif /* FEAT_INS_EXPAND */
6531 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6532 else if (varp == &p_toolbar)
6534 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6535 &toolbar_flags, TRUE) != OK)
6536 errmsg = e_invarg;
6537 else
6539 out_flush();
6540 gui_mch_show_toolbar((toolbar_flags &
6541 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6544 #endif
6546 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
6547 /* 'toolbariconsize': GTK+ 2 only */
6548 else if (varp == &p_tbis)
6550 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6551 errmsg = e_invarg;
6552 else
6554 out_flush();
6555 gui_mch_show_toolbar((toolbar_flags &
6556 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6559 #endif
6561 /* 'pastetoggle': translate key codes like in a mapping */
6562 else if (varp == &p_pt)
6564 if (*p_pt)
6566 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
6567 if (p != NULL)
6569 if (new_value_alloced)
6570 free_string_option(p_pt);
6571 p_pt = p;
6572 new_value_alloced = TRUE;
6577 /* 'backspace' */
6578 else if (varp == &p_bs)
6580 if (VIM_ISDIGIT(*p_bs))
6582 if (*p_bs >'2' || p_bs[1] != NUL)
6583 errmsg = e_invarg;
6585 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6586 errmsg = e_invarg;
6589 #ifdef FEAT_MBYTE
6590 /* 'casemap' */
6591 else if (varp == &p_cmp)
6593 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6594 errmsg = e_invarg;
6596 #endif
6598 #ifdef FEAT_DIFF
6599 /* 'diffopt' */
6600 else if (varp == &p_dip)
6602 if (diffopt_changed() == FAIL)
6603 errmsg = e_invarg;
6605 #endif
6607 #ifdef FEAT_FOLDING
6608 /* 'foldmethod' */
6609 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
6611 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
6612 || *curwin->w_p_fdm == NUL)
6613 errmsg = e_invarg;
6614 else
6615 foldUpdateAll(curwin);
6617 # ifdef FEAT_EVAL
6618 /* 'foldexpr' */
6619 else if (varp == &curwin->w_p_fde)
6621 if (foldmethodIsExpr(curwin))
6622 foldUpdateAll(curwin);
6624 # endif
6625 /* 'foldmarker' */
6626 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
6628 p = vim_strchr(*varp, ',');
6629 if (p == NULL)
6630 errmsg = (char_u *)N_("E536: comma required");
6631 else if (p == *varp || p[1] == NUL)
6632 errmsg = e_invarg;
6633 else if (foldmethodIsMarker(curwin))
6634 foldUpdateAll(curwin);
6636 /* 'commentstring' */
6637 else if (gvarp == &p_cms)
6639 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
6640 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
6642 /* 'foldopen' */
6643 else if (varp == &p_fdo)
6645 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
6646 errmsg = e_invarg;
6648 /* 'foldclose' */
6649 else if (varp == &p_fcl)
6651 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
6652 errmsg = e_invarg;
6654 /* 'foldignore' */
6655 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
6657 if (foldmethodIsIndent(curwin))
6658 foldUpdateAll(curwin);
6660 #endif
6662 #ifdef FEAT_VIRTUALEDIT
6663 /* 'virtualedit' */
6664 else if (varp == &p_ve)
6666 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
6667 errmsg = e_invarg;
6668 else if (STRCMP(p_ve, oldval) != 0)
6670 /* Recompute cursor position in case the new 've' setting
6671 * changes something. */
6672 validate_virtcol();
6673 coladvance(curwin->w_virtcol);
6676 #endif
6678 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
6679 else if (varp == &p_csqf)
6681 if (p_csqf != NULL)
6683 p = p_csqf;
6684 while (*p != NUL)
6686 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
6687 || p[1] == NUL
6688 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
6689 || (p[2] != NUL && p[2] != ','))
6691 errmsg = e_invarg;
6692 break;
6694 else if (p[2] == NUL)
6695 break;
6696 else
6697 p += 3;
6701 #endif
6703 /* Options that are a list of flags. */
6704 else
6706 p = NULL;
6707 if (varp == &p_ww)
6708 p = (char_u *)WW_ALL;
6709 if (varp == &p_shm)
6710 p = (char_u *)SHM_ALL;
6711 else if (varp == &(p_cpo))
6712 p = (char_u *)CPO_ALL;
6713 else if (varp == &(curbuf->b_p_fo))
6714 p = (char_u *)FO_ALL;
6715 else if (varp == &p_mouse)
6717 #ifdef FEAT_MOUSE
6718 p = (char_u *)MOUSE_ALL;
6719 #else
6720 if (*p_mouse != NUL)
6721 errmsg = (char_u *)N_("E538: No mouse support");
6722 #endif
6724 #if defined(FEAT_GUI)
6725 else if (varp == &p_go)
6726 p = (char_u *)GO_ALL;
6727 #endif
6728 if (p != NULL)
6730 for (s = *varp; *s; ++s)
6731 if (vim_strchr(p, *s) == NULL)
6733 errmsg = illegal_char(errbuf, *s);
6734 break;
6740 * If error detected, restore the previous value.
6742 if (errmsg != NULL)
6744 if (new_value_alloced)
6745 free_string_option(*varp);
6746 *varp = oldval;
6748 * When resetting some values, need to act on it.
6750 if (did_chartab)
6751 (void)init_chartab();
6752 if (varp == &p_hl)
6753 (void)highlight_changed();
6755 else
6757 #ifdef FEAT_EVAL
6758 /* Remember where the option was set. */
6759 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
6760 #endif
6762 * Free string options that are in allocated memory.
6763 * Use "free_oldval", because recursiveness may change the flags under
6764 * our fingers (esp. init_highlight()).
6766 if (free_oldval)
6767 free_string_option(oldval);
6768 if (new_value_alloced)
6769 options[opt_idx].flags |= P_ALLOCED;
6770 else
6771 options[opt_idx].flags &= ~P_ALLOCED;
6773 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
6774 && ((int)options[opt_idx].indir & PV_BOTH))
6776 /* global option with local value set to use global value; free
6777 * the local value and make it empty */
6778 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
6779 free_string_option(*(char_u **)p);
6780 *(char_u **)p = empty_option;
6783 /* May set global value for local option. */
6784 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
6785 set_string_option_global(opt_idx, varp);
6787 #ifdef FEAT_AUTOCMD
6789 * Trigger the autocommand only after setting the flags.
6791 # ifdef FEAT_SYN_HL
6792 /* When 'syntax' is set, load the syntax of that name */
6793 if (varp == &(curbuf->b_p_syn))
6795 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
6796 curbuf->b_fname, TRUE, curbuf);
6798 # endif
6799 else if (varp == &(curbuf->b_p_ft))
6801 /* 'filetype' is set, trigger the FileType autocommand */
6802 did_filetype = TRUE;
6803 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
6804 curbuf->b_fname, TRUE, curbuf);
6806 #endif
6807 #ifdef FEAT_SPELL
6808 if (varp == &(curbuf->b_p_spl))
6810 char_u fname[200];
6813 * Source the spell/LANG.vim in 'runtimepath'.
6814 * They could set 'spellcapcheck' depending on the language.
6815 * Use the first name in 'spelllang' up to '_region' or
6816 * '.encoding'.
6818 for (p = curbuf->b_p_spl; *p != NUL; ++p)
6819 if (vim_strchr((char_u *)"_.,", *p) != NULL)
6820 break;
6821 vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
6822 (int)(p - curbuf->b_p_spl), curbuf->b_p_spl);
6823 source_runtime(fname, TRUE);
6825 #endif
6828 #ifdef FEAT_MOUSE
6829 if (varp == &p_mouse)
6831 # ifdef FEAT_MOUSE_TTY
6832 if (*p_mouse == NUL)
6833 mch_setmouse(FALSE); /* switch mouse off */
6834 else
6835 # endif
6836 setmouse(); /* in case 'mouse' changed */
6838 #endif
6840 if (curwin->w_curswant != MAXCOL)
6841 curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */
6842 #ifdef FEAT_GUI
6843 /* check redraw when it's not a GUI option or the GUI is active. */
6844 if (!redraw_gui_only || gui.in_use)
6845 #endif
6846 check_redraw(options[opt_idx].flags);
6848 return errmsg;
6852 * Handle setting 'listchars' or 'fillchars'.
6853 * Returns error message, NULL if it's OK.
6855 static char_u *
6856 set_chars_option(varp)
6857 char_u **varp;
6859 int round, i, len, entries;
6860 char_u *p, *s;
6861 int c1, c2 = 0;
6862 struct charstab
6864 int *cp;
6865 char *name;
6867 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6868 static struct charstab filltab[] =
6870 {&fill_stl, "stl"},
6871 {&fill_stlnc, "stlnc"},
6872 {&fill_vert, "vert"},
6873 {&fill_fold, "fold"},
6874 {&fill_diff, "diff"},
6876 #endif
6877 static struct charstab lcstab[] =
6879 {&lcs_eol, "eol"},
6880 {&lcs_ext, "extends"},
6881 {&lcs_nbsp, "nbsp"},
6882 {&lcs_prec, "precedes"},
6883 {&lcs_tab2, "tab"},
6884 {&lcs_trail, "trail"},
6886 struct charstab *tab;
6888 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6889 if (varp == &p_lcs)
6890 #endif
6892 tab = lcstab;
6893 entries = sizeof(lcstab) / sizeof(struct charstab);
6895 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6896 else
6898 tab = filltab;
6899 entries = sizeof(filltab) / sizeof(struct charstab);
6901 #endif
6903 /* first round: check for valid value, second round: assign values */
6904 for (round = 0; round <= 1; ++round)
6906 if (round)
6908 /* After checking that the value is valid: set defaults: space for
6909 * 'fillchars', NUL for 'listchars' */
6910 for (i = 0; i < entries; ++i)
6911 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
6912 if (varp == &p_lcs)
6913 lcs_tab1 = NUL;
6914 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6915 else
6916 fill_diff = '-';
6917 #endif
6919 p = *varp;
6920 while (*p)
6922 for (i = 0; i < entries; ++i)
6924 len = (int)STRLEN(tab[i].name);
6925 if (STRNCMP(p, tab[i].name, len) == 0
6926 && p[len] == ':'
6927 && p[len + 1] != NUL)
6929 s = p + len + 1;
6930 #ifdef FEAT_MBYTE
6931 c1 = mb_ptr2char_adv(&s);
6932 if (mb_char2cells(c1) > 1)
6933 continue;
6934 #else
6935 c1 = *s++;
6936 #endif
6937 if (tab[i].cp == &lcs_tab2)
6939 if (*s == NUL)
6940 continue;
6941 #ifdef FEAT_MBYTE
6942 c2 = mb_ptr2char_adv(&s);
6943 if (mb_char2cells(c2) > 1)
6944 continue;
6945 #else
6946 c2 = *s++;
6947 #endif
6949 if (*s == ',' || *s == NUL)
6951 if (round)
6953 if (tab[i].cp == &lcs_tab2)
6955 lcs_tab1 = c1;
6956 lcs_tab2 = c2;
6958 else
6959 *(tab[i].cp) = c1;
6962 p = s;
6963 break;
6968 if (i == entries)
6969 return e_invarg;
6970 if (*p == ',')
6971 ++p;
6975 return NULL; /* no error */
6978 #ifdef FEAT_STL_OPT
6980 * Check validity of options with the 'statusline' format.
6981 * Return error message or NULL.
6983 char_u *
6984 check_stl_option(s)
6985 char_u *s;
6987 int itemcnt = 0;
6988 int groupdepth = 0;
6989 static char_u errbuf[80];
6991 while (*s && itemcnt < STL_MAX_ITEM)
6993 /* Check for valid keys after % sequences */
6994 while (*s && *s != '%')
6995 s++;
6996 if (!*s)
6997 break;
6998 s++;
6999 if (*s != '%' && *s != ')')
7000 ++itemcnt;
7001 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7003 s++;
7004 continue;
7006 if (*s == ')')
7008 s++;
7009 if (--groupdepth < 0)
7010 break;
7011 continue;
7013 if (*s == '-')
7014 s++;
7015 while (VIM_ISDIGIT(*s))
7016 s++;
7017 if (*s == STL_USER_HL)
7018 continue;
7019 if (*s == '.')
7021 s++;
7022 while (*s && VIM_ISDIGIT(*s))
7023 s++;
7025 if (*s == '(')
7027 groupdepth++;
7028 continue;
7030 if (vim_strchr(STL_ALL, *s) == NULL)
7032 return illegal_char(errbuf, *s);
7034 if (*s == '{')
7036 s++;
7037 while (*s != '}' && *s)
7038 s++;
7039 if (*s != '}')
7040 return (char_u *)N_("E540: Unclosed expression sequence");
7043 if (itemcnt >= STL_MAX_ITEM)
7044 return (char_u *)N_("E541: too many items");
7045 if (groupdepth != 0)
7046 return (char_u *)N_("E542: unbalanced groups");
7047 return NULL;
7049 #endif
7051 #ifdef FEAT_CLIPBOARD
7053 * Extract the items in the 'clipboard' option and set global values.
7055 static char_u *
7056 check_clipboard_option()
7058 int new_unnamed = FALSE;
7059 int new_autoselect = FALSE;
7060 int new_autoselectml = FALSE;
7061 int new_html = FALSE;
7062 regprog_T *new_exclude_prog = NULL;
7063 char_u *errmsg = NULL;
7064 char_u *p;
7066 for (p = p_cb; *p != NUL; )
7068 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7070 new_unnamed = TRUE;
7071 p += 7;
7073 else if (STRNCMP(p, "autoselect", 10) == 0
7074 && (p[10] == ',' || p[10] == NUL))
7076 new_autoselect = TRUE;
7077 p += 10;
7079 else if (STRNCMP(p, "autoselectml", 12) == 0
7080 && (p[12] == ',' || p[12] == NUL))
7082 new_autoselectml = TRUE;
7083 p += 12;
7085 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7087 new_html = TRUE;
7088 p += 4;
7090 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7092 p += 8;
7093 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7094 if (new_exclude_prog == NULL)
7095 errmsg = e_invarg;
7096 break;
7098 else
7100 errmsg = e_invarg;
7101 break;
7103 if (*p == ',')
7104 ++p;
7106 if (errmsg == NULL)
7108 clip_unnamed = new_unnamed;
7109 clip_autoselect = new_autoselect;
7110 clip_autoselectml = new_autoselectml;
7111 clip_html = new_html;
7112 vim_free(clip_exclude_prog);
7113 clip_exclude_prog = new_exclude_prog;
7115 else
7116 vim_free(new_exclude_prog);
7118 return errmsg;
7120 #endif
7122 #ifdef FEAT_SPELL
7124 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7125 * Return error message when failed, NULL when OK.
7127 static char_u *
7128 compile_cap_prog(buf)
7129 buf_T *buf;
7131 regprog_T *rp = buf->b_cap_prog;
7132 char_u *re;
7134 if (*buf->b_p_spc == NUL)
7135 buf->b_cap_prog = NULL;
7136 else
7138 /* Prepend a ^ so that we only match at one column */
7139 re = concat_str((char_u *)"^", buf->b_p_spc);
7140 if (re != NULL)
7142 buf->b_cap_prog = vim_regcomp(re, RE_MAGIC);
7143 if (buf->b_cap_prog == NULL)
7145 buf->b_cap_prog = rp; /* restore the previous program */
7146 return e_invarg;
7148 vim_free(re);
7152 vim_free(rp);
7153 return NULL;
7155 #endif
7157 #if defined(FEAT_EVAL) || defined(PROTO)
7159 * Set the scriptID for an option, taking care of setting the buffer- or
7160 * window-local value.
7162 static void
7163 set_option_scriptID_idx(opt_idx, opt_flags, id)
7164 int opt_idx;
7165 int opt_flags;
7166 int id;
7168 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7169 int indir = (int)options[opt_idx].indir;
7171 /* Remember where the option was set. For local options need to do that
7172 * in the buffer or window structure. */
7173 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
7174 options[opt_idx].scriptID = id;
7175 if (both || (opt_flags & OPT_LOCAL))
7177 if (indir & PV_BUF)
7178 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7179 else if (indir & PV_WIN)
7180 curwin->w_p_scriptID[indir & PV_MASK] = id;
7183 #endif
7186 * Set the value of a boolean option, and take care of side effects.
7187 * Returns NULL for success, or an error message for an error.
7189 static char_u *
7190 set_bool_option(opt_idx, varp, value, opt_flags)
7191 int opt_idx; /* index in options[] table */
7192 char_u *varp; /* pointer to the option variable */
7193 int value; /* new value */
7194 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7196 int old_value = *(int *)varp;
7198 /* Disallow changing some options from secure mode */
7199 if ((secure
7200 #ifdef HAVE_SANDBOX
7201 || sandbox != 0
7202 #endif
7203 ) && (options[opt_idx].flags & P_SECURE))
7204 return e_secure;
7206 *(int *)varp = value; /* set the new value */
7207 #ifdef FEAT_EVAL
7208 /* Remember where the option was set. */
7209 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
7210 #endif
7212 #ifdef FEAT_GUI
7213 need_mouse_correct = TRUE;
7214 #endif
7216 /* May set global value for local option. */
7217 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7218 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7221 * Handle side effects of changing a bool option.
7224 /* 'compatible' */
7225 if ((int *)varp == &p_cp)
7227 compatible_set();
7230 /* 'list', 'number' */
7231 else if ((int *)varp == &curwin->w_p_list
7232 || (int *)varp == &curwin->w_p_nu)
7234 if (curwin->w_curswant != MAXCOL)
7235 curwin->w_set_curswant = TRUE;
7238 else if ((int *)varp == &curbuf->b_p_ro)
7240 /* when 'readonly' is reset globally, also reset readonlymode */
7241 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7242 readonlymode = FALSE;
7244 /* when 'readonly' is set may give W10 again */
7245 if (curbuf->b_p_ro)
7246 curbuf->b_did_warn = FALSE;
7248 #ifdef FEAT_TITLE
7249 redraw_titles();
7250 #endif
7253 #ifdef FEAT_TITLE
7254 /* when 'modifiable' is changed, redraw the window title */
7255 else if ((int *)varp == &curbuf->b_p_ma)
7257 redraw_titles();
7259 /* when 'endofline' is changed, redraw the window title */
7260 else if ((int *)varp == &curbuf->b_p_eol)
7262 redraw_titles();
7264 # ifdef FEAT_MBYTE
7265 /* when 'bomb' is changed, redraw the window title and tab page text */
7266 else if ((int *)varp == &curbuf->b_p_bomb)
7268 redraw_titles();
7270 # endif
7271 #endif
7273 /* when 'bin' is set also set some other options */
7274 else if ((int *)varp == &curbuf->b_p_bin)
7276 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7277 #ifdef FEAT_TITLE
7278 redraw_titles();
7279 #endif
7282 #ifdef FEAT_AUTOCMD
7283 /* when 'buflisted' changes, trigger autocommands */
7284 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7286 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7287 NULL, NULL, TRUE, curbuf);
7289 #endif
7291 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7292 else if ((int *)varp == &curbuf->b_p_swf)
7294 if (curbuf->b_p_swf && p_uc)
7295 ml_open_file(curbuf); /* create the swap file */
7296 else
7297 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7298 * buf->b_p_swf */
7299 mf_close_file(curbuf, TRUE); /* remove the swap file */
7302 /* when 'terse' is set change 'shortmess' */
7303 else if ((int *)varp == &p_terse)
7305 char_u *p;
7307 p = vim_strchr(p_shm, SHM_SEARCH);
7309 /* insert 's' in p_shm */
7310 if (p_terse && p == NULL)
7312 STRCPY(IObuff, p_shm);
7313 STRCAT(IObuff, "s");
7314 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
7316 /* remove 's' from p_shm */
7317 else if (!p_terse && p != NULL)
7318 STRMOVE(p, p + 1);
7321 /* when 'paste' is set or reset also change other options */
7322 else if ((int *)varp == &p_paste)
7324 paste_option_changed();
7327 /* when 'insertmode' is set from an autocommand need to do work here */
7328 else if ((int *)varp == &p_im)
7330 if (p_im)
7332 if ((State & INSERT) == 0)
7333 need_start_insertmode = TRUE;
7334 stop_insert_mode = FALSE;
7336 else
7338 need_start_insertmode = FALSE;
7339 stop_insert_mode = TRUE;
7340 if (restart_edit != 0 && mode_displayed)
7341 clear_cmdline = TRUE; /* remove "(insert)" */
7342 restart_edit = 0;
7346 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7347 else if ((int *)varp == &p_ic && p_hls)
7349 redraw_all_later(SOME_VALID);
7352 #ifdef FEAT_SEARCH_EXTRA
7353 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7354 else if ((int *)varp == &p_hls)
7356 no_hlsearch = FALSE;
7358 #endif
7360 #ifdef FEAT_SCROLLBIND
7361 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7362 * at the end of normal_cmd() */
7363 else if ((int *)varp == &curwin->w_p_scb)
7365 if (curwin->w_p_scb)
7366 do_check_scrollbind(FALSE);
7368 #endif
7370 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7371 /* There can be only one window with 'previewwindow' set. */
7372 else if ((int *)varp == &curwin->w_p_pvw)
7374 if (curwin->w_p_pvw)
7376 win_T *win;
7378 for (win = firstwin; win != NULL; win = win->w_next)
7379 if (win->w_p_pvw && win != curwin)
7381 curwin->w_p_pvw = FALSE;
7382 return (char_u *)N_("E590: A preview window already exists");
7386 #endif
7388 /* when 'textmode' is set or reset also change 'fileformat' */
7389 else if ((int *)varp == &curbuf->b_p_tx)
7391 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7394 /* when 'textauto' is set or reset also change 'fileformats' */
7395 else if ((int *)varp == &p_ta)
7396 set_string_option_direct((char_u *)"ffs", -1,
7397 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
7398 OPT_FREE | opt_flags, 0);
7401 * When 'lisp' option changes include/exclude '-' in
7402 * keyword characters.
7404 #ifdef FEAT_LISP
7405 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7407 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7409 #endif
7411 #ifdef FEAT_TITLE
7412 /* when 'title' changed, may need to change the title; same for 'icon' */
7413 else if ((int *)varp == &p_title)
7415 did_set_title(FALSE);
7418 else if ((int *)varp == &p_icon)
7420 did_set_title(TRUE);
7422 #endif
7424 else if ((int *)varp == &curbuf->b_changed)
7426 if (!value)
7427 save_file_ff(curbuf); /* Buffer is unchanged */
7428 #ifdef FEAT_TITLE
7429 redraw_titles();
7430 #endif
7431 #ifdef FEAT_AUTOCMD
7432 modified_was_set = value;
7433 #endif
7436 #ifdef BACKSLASH_IN_FILENAME
7437 else if ((int *)varp == &p_ssl)
7439 if (p_ssl)
7441 psepc = '/';
7442 psepcN = '\\';
7443 pseps[0] = '/';
7445 else
7447 psepc = '\\';
7448 psepcN = '/';
7449 pseps[0] = '\\';
7452 /* need to adjust the file name arguments and buffer names. */
7453 buflist_slash_adjust();
7454 alist_slash_adjust();
7455 # ifdef FEAT_EVAL
7456 scriptnames_slash_adjust();
7457 # endif
7459 #endif
7461 /* If 'wrap' is set, set w_leftcol to zero. */
7462 else if ((int *)varp == &curwin->w_p_wrap)
7464 if (curwin->w_p_wrap)
7465 curwin->w_leftcol = 0;
7466 if (curwin->w_curswant != MAXCOL)
7467 curwin->w_set_curswant = TRUE;
7470 #ifdef FEAT_WINDOWS
7471 else if ((int *)varp == &p_ea)
7473 if (p_ea && !old_value)
7474 win_equal(curwin, FALSE, 0);
7476 #endif
7478 else if ((int *)varp == &p_wiv)
7481 * When 'weirdinvert' changed, set/reset 't_xs'.
7482 * Then set 'weirdinvert' according to value of 't_xs'.
7484 if (p_wiv && !old_value)
7485 T_XS = (char_u *)"y";
7486 else if (!p_wiv && old_value)
7487 T_XS = empty_option;
7488 p_wiv = (*T_XS != NUL);
7491 #ifdef FEAT_BEVAL
7492 else if ((int *)varp == &p_beval)
7494 if (p_beval == TRUE)
7495 gui_mch_enable_beval_area(balloonEval);
7496 else
7497 gui_mch_disable_beval_area(balloonEval);
7499 #endif
7501 #ifdef FEAT_AUTOCHDIR
7502 else if ((int *)varp == &p_acd)
7504 /* Change directories when the 'acd' option is set now. */
7505 DO_AUTOCHDIR
7507 #endif
7509 #ifdef FEAT_DIFF
7510 /* 'diff' */
7511 else if ((int *)varp == &curwin->w_p_diff)
7513 /* May add or remove the buffer from the list of diff buffers. */
7514 diff_buf_adjust(curwin);
7515 # ifdef FEAT_FOLDING
7516 if (foldmethodIsDiff(curwin))
7517 foldUpdateAll(curwin);
7518 # endif
7520 #endif
7522 #ifdef USE_IM_CONTROL
7523 /* 'imdisable' */
7524 else if ((int *)varp == &p_imdisable)
7526 /* Only de-activate it here, it will be enabled when changing mode. */
7527 if (p_imdisable)
7528 im_set_active(FALSE);
7530 #endif
7532 #ifdef FEAT_SPELL
7533 /* 'spell' */
7534 else if ((int *)varp == &curwin->w_p_spell)
7536 if (curwin->w_p_spell)
7538 char_u *errmsg = did_set_spelllang(curbuf);
7540 if (errmsg != NULL)
7541 EMSG(_(errmsg));
7544 #endif
7546 #ifdef FEAT_FKMAP
7547 else if ((int *)varp == &p_altkeymap)
7549 if (old_value != p_altkeymap)
7551 if (!p_altkeymap)
7553 p_hkmap = p_fkmap;
7554 p_fkmap = 0;
7556 else
7558 p_fkmap = p_hkmap;
7559 p_hkmap = 0;
7561 (void)init_chartab();
7566 * In case some second language keymapping options have changed, check
7567 * and correct the setting in a consistent way.
7571 * If hkmap or fkmap are set, reset Arabic keymapping.
7573 if ((p_hkmap || p_fkmap) && p_altkeymap)
7575 p_altkeymap = p_fkmap;
7576 # ifdef FEAT_ARABIC
7577 curwin->w_p_arab = FALSE;
7578 # endif
7579 (void)init_chartab();
7583 * If hkmap set, reset Farsi keymapping.
7585 if (p_hkmap && p_altkeymap)
7587 p_altkeymap = 0;
7588 p_fkmap = 0;
7589 # ifdef FEAT_ARABIC
7590 curwin->w_p_arab = FALSE;
7591 # endif
7592 (void)init_chartab();
7596 * If fkmap set, reset Hebrew keymapping.
7598 if (p_fkmap && !p_altkeymap)
7600 p_altkeymap = 1;
7601 p_hkmap = 0;
7602 # ifdef FEAT_ARABIC
7603 curwin->w_p_arab = FALSE;
7604 # endif
7605 (void)init_chartab();
7607 #endif
7609 #ifdef FEAT_ARABIC
7610 if ((int *)varp == &curwin->w_p_arab)
7612 if (curwin->w_p_arab)
7615 * 'arabic' is set, handle various sub-settings.
7617 if (!p_tbidi)
7619 /* set rightleft mode */
7620 if (!curwin->w_p_rl)
7622 curwin->w_p_rl = TRUE;
7623 changed_window_setting();
7626 /* Enable Arabic shaping (major part of what Arabic requires) */
7627 if (!p_arshape)
7629 p_arshape = TRUE;
7630 redraw_later_clear();
7634 /* Arabic requires a utf-8 encoding, inform the user if its not
7635 * set. */
7636 if (STRCMP(p_enc, "utf-8") != 0)
7638 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
7640 msg_source(hl_attr(HLF_W));
7641 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
7642 #ifdef FEAT_EVAL
7643 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
7644 #endif
7647 # ifdef FEAT_MBYTE
7648 /* set 'delcombine' */
7649 p_deco = TRUE;
7650 # endif
7652 # ifdef FEAT_KEYMAP
7653 /* Force-set the necessary keymap for arabic */
7654 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
7655 OPT_LOCAL);
7656 # endif
7657 # ifdef FEAT_FKMAP
7658 p_altkeymap = 0;
7659 p_hkmap = 0;
7660 p_fkmap = 0;
7661 (void)init_chartab();
7662 # endif
7664 else
7667 * 'arabic' is reset, handle various sub-settings.
7669 if (!p_tbidi)
7671 /* reset rightleft mode */
7672 if (curwin->w_p_rl)
7674 curwin->w_p_rl = FALSE;
7675 changed_window_setting();
7678 /* 'arabicshape' isn't reset, it is a global option and
7679 * another window may still need it "on". */
7682 /* 'delcombine' isn't reset, it is a global option and another
7683 * window may still want it "on". */
7685 # ifdef FEAT_KEYMAP
7686 /* Revert to the default keymap */
7687 curbuf->b_p_iminsert = B_IMODE_NONE;
7688 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
7689 # endif
7691 if (curwin->w_curswant != MAXCOL)
7692 curwin->w_set_curswant = TRUE;
7695 else if ((int *)varp == &p_arshape)
7697 if (curwin->w_curswant != MAXCOL)
7698 curwin->w_set_curswant = TRUE;
7700 #endif
7702 #ifdef FEAT_LINEBREAK
7703 if ((int *)varp == &curwin->w_p_lbr)
7705 if (curwin->w_curswant != MAXCOL)
7706 curwin->w_set_curswant = TRUE;
7708 #endif
7710 #ifdef FEAT_RIGHTLEFT
7711 if ((int *)varp == &curwin->w_p_rl)
7713 if (curwin->w_curswant != MAXCOL)
7714 curwin->w_set_curswant = TRUE;
7716 #endif
7719 * End of handling side effects for bool options.
7722 options[opt_idx].flags |= P_WAS_SET;
7724 comp_col(); /* in case 'ruler' or 'showcmd' changed */
7726 check_redraw(options[opt_idx].flags);
7728 return NULL;
7732 * Set the value of a number option, and take care of side effects.
7733 * Returns NULL for success, or an error message for an error.
7735 static char_u *
7736 set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
7737 int opt_idx; /* index in options[] table */
7738 char_u *varp; /* pointer to the option variable */
7739 long value; /* new value */
7740 char_u *errbuf; /* buffer for error messages */
7741 size_t errbuflen; /* length of "errbuf" */
7742 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
7743 OPT_MODELINE */
7745 char_u *errmsg = NULL;
7746 long old_value = *(long *)varp;
7747 long old_Rows = Rows; /* remember old Rows */
7748 long old_Columns = Columns; /* remember old Columns */
7749 long *pp = (long *)varp;
7751 /* Disallow changing some options from secure mode. */
7752 if ((secure
7753 #ifdef HAVE_SANDBOX
7754 || sandbox != 0
7755 #endif
7756 ) && (options[opt_idx].flags & P_SECURE))
7757 return e_secure;
7759 *pp = value;
7760 #ifdef FEAT_EVAL
7761 /* Remember where the option was set. */
7762 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
7763 #endif
7764 #ifdef FEAT_GUI
7765 need_mouse_correct = TRUE;
7766 #endif
7768 if (curbuf->b_p_sw <= 0)
7770 errmsg = e_positive;
7771 curbuf->b_p_sw = curbuf->b_p_ts;
7775 * Number options that need some action when changed
7777 #ifdef FEAT_WINDOWS
7778 if (pp == &p_wh || pp == &p_hh)
7780 if (p_wh < 1)
7782 errmsg = e_positive;
7783 p_wh = 1;
7785 if (p_wmh > p_wh)
7787 errmsg = e_winheight;
7788 p_wh = p_wmh;
7790 if (p_hh < 0)
7792 errmsg = e_positive;
7793 p_hh = 0;
7796 /* Change window height NOW */
7797 if (lastwin != firstwin)
7799 if (pp == &p_wh && curwin->w_height < p_wh)
7800 win_setheight((int)p_wh);
7801 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
7802 win_setheight((int)p_hh);
7806 /* 'winminheight' */
7807 else if (pp == &p_wmh)
7809 if (p_wmh < 0)
7811 errmsg = e_positive;
7812 p_wmh = 0;
7814 if (p_wmh > p_wh)
7816 errmsg = e_winheight;
7817 p_wmh = p_wh;
7819 win_setminheight();
7822 # ifdef FEAT_VERTSPLIT
7823 else if (pp == &p_wiw)
7825 if (p_wiw < 1)
7827 errmsg = e_positive;
7828 p_wiw = 1;
7830 if (p_wmw > p_wiw)
7832 errmsg = e_winwidth;
7833 p_wiw = p_wmw;
7836 /* Change window width NOW */
7837 if (lastwin != firstwin && curwin->w_width < p_wiw)
7838 win_setwidth((int)p_wiw);
7841 /* 'winminwidth' */
7842 else if (pp == &p_wmw)
7844 if (p_wmw < 0)
7846 errmsg = e_positive;
7847 p_wmw = 0;
7849 if (p_wmw > p_wiw)
7851 errmsg = e_winwidth;
7852 p_wmw = p_wiw;
7854 win_setminheight();
7856 # endif
7858 #endif
7860 #ifdef FEAT_WINDOWS
7861 /* (re)set last window status line */
7862 else if (pp == &p_ls)
7864 last_status(FALSE);
7867 /* (re)set tab page line */
7868 else if (pp == &p_stal)
7870 shell_new_rows(); /* recompute window positions and heights */
7872 #endif
7874 #ifdef FEAT_GUI
7875 else if (pp == &p_linespace)
7877 /* Recompute gui.char_height and resize the Vim window to keep the
7878 * same number of lines. */
7879 if (gui.in_use && gui_mch_adjust_charheight() == OK)
7880 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
7882 #endif
7884 #ifdef FEAT_FOLDING
7885 /* 'foldlevel' */
7886 else if (pp == &curwin->w_p_fdl)
7888 if (curwin->w_p_fdl < 0)
7889 curwin->w_p_fdl = 0;
7890 newFoldLevel();
7893 /* 'foldminlines' */
7894 else if (pp == &curwin->w_p_fml)
7896 foldUpdateAll(curwin);
7899 /* 'foldnestmax' */
7900 else if (pp == &curwin->w_p_fdn)
7902 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
7903 foldUpdateAll(curwin);
7906 /* 'foldcolumn' */
7907 else if (pp == &curwin->w_p_fdc)
7909 if (curwin->w_p_fdc < 0)
7911 errmsg = e_positive;
7912 curwin->w_p_fdc = 0;
7914 else if (curwin->w_p_fdc > 12)
7916 errmsg = e_invarg;
7917 curwin->w_p_fdc = 12;
7921 /* 'shiftwidth' or 'tabstop' */
7922 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
7924 if (foldmethodIsIndent(curwin))
7925 foldUpdateAll(curwin);
7927 #endif /* FEAT_FOLDING */
7929 #ifdef FEAT_MBYTE
7930 /* 'maxcombine' */
7931 else if (pp == &p_mco)
7933 if (p_mco > MAX_MCO)
7934 p_mco = MAX_MCO;
7935 else if (p_mco < 0)
7936 p_mco = 0;
7937 screenclear(); /* will re-allocate the screen */
7939 #endif
7941 else if (pp == &curbuf->b_p_iminsert)
7943 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
7945 errmsg = e_invarg;
7946 curbuf->b_p_iminsert = B_IMODE_NONE;
7948 p_iminsert = curbuf->b_p_iminsert;
7949 if (termcap_active) /* don't do this in the alternate screen */
7950 showmode();
7951 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
7952 /* Show/unshow value of 'keymap' in status lines. */
7953 status_redraw_curbuf();
7954 #endif
7957 else if (pp == &p_window)
7959 if (p_window < 1)
7960 p_window = 1;
7961 else if (p_window >= Rows)
7962 p_window = Rows - 1;
7965 else if (pp == &curbuf->b_p_imsearch)
7967 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
7969 errmsg = e_invarg;
7970 curbuf->b_p_imsearch = B_IMODE_NONE;
7972 p_imsearch = curbuf->b_p_imsearch;
7975 #ifdef FEAT_TITLE
7976 /* if 'titlelen' has changed, redraw the title */
7977 else if (pp == &p_titlelen)
7979 if (p_titlelen < 0)
7981 errmsg = e_positive;
7982 p_titlelen = 85;
7984 if (starting != NO_SCREEN && old_value != p_titlelen)
7985 need_maketitle = TRUE;
7987 #endif
7989 /* if p_ch changed value, change the command line height */
7990 else if (pp == &p_ch)
7992 if (p_ch < 1)
7994 errmsg = e_positive;
7995 p_ch = 1;
7997 if (p_ch > Rows - min_rows() + 1)
7998 p_ch = Rows - min_rows() + 1;
8000 /* Only compute the new window layout when startup has been
8001 * completed. Otherwise the frame sizes may be wrong. */
8002 if (p_ch != old_value && full_screen
8003 #ifdef FEAT_GUI
8004 && !gui.starting
8005 #endif
8007 command_height();
8010 /* when 'updatecount' changes from zero to non-zero, open swap files */
8011 else if (pp == &p_uc)
8013 if (p_uc < 0)
8015 errmsg = e_positive;
8016 p_uc = 100;
8018 if (p_uc && !old_value)
8019 ml_open_files();
8021 #ifdef MZSCHEME_GUI_THREADS
8022 else if (pp == &p_mzq)
8023 mzvim_reset_timer();
8024 #endif
8026 /* sync undo before 'undolevels' changes */
8027 else if (pp == &p_ul)
8029 /* use the old value, otherwise u_sync() may not work properly */
8030 p_ul = old_value;
8031 u_sync(TRUE);
8032 p_ul = value;
8035 #ifdef FEAT_LINEBREAK
8036 /* 'numberwidth' must be positive */
8037 else if (pp == &curwin->w_p_nuw)
8039 if (curwin->w_p_nuw < 1)
8041 errmsg = e_positive;
8042 curwin->w_p_nuw = 1;
8044 if (curwin->w_p_nuw > 10)
8046 errmsg = e_invarg;
8047 curwin->w_p_nuw = 10;
8049 curwin->w_nrwidth_line_count = 0;
8052 /* 'breakindentmin' must be positive */
8053 else if (pp == &curwin->w_p_brimin)
8055 if (curwin->w_p_brimin < 1)
8057 errmsg = e_positive;
8058 curwin->w_p_brimin = 1;
8061 #endif
8064 * Check the bounds for numeric options here
8066 if (Rows < min_rows() && full_screen)
8068 if (errbuf != NULL)
8070 vim_snprintf((char *)errbuf, errbuflen,
8071 _("E593: Need at least %d lines"), min_rows());
8072 errmsg = errbuf;
8074 Rows = min_rows();
8076 if (Columns < MIN_COLUMNS && full_screen)
8078 if (errbuf != NULL)
8080 vim_snprintf((char *)errbuf, errbuflen,
8081 _("E594: Need at least %d columns"), MIN_COLUMNS);
8082 errmsg = errbuf;
8084 Columns = MIN_COLUMNS;
8086 /* Limit the values to avoid an overflow in Rows * Columns. */
8087 if (Columns > 10000)
8088 Columns = 10000;
8089 if (Rows > 1000)
8090 Rows = 1000;
8092 #ifdef DJGPP
8093 /* avoid a crash by checking for a too large value of 'columns' */
8094 if (old_Columns != Columns && full_screen && term_console)
8095 mch_check_columns();
8096 #endif
8099 * If the screen (shell) height has been changed, assume it is the
8100 * physical screenheight.
8102 if (old_Rows != Rows || old_Columns != Columns)
8104 /* Changing the screen size is not allowed while updating the screen. */
8105 if (updating_screen)
8106 *pp = old_value;
8107 else if (full_screen
8108 #ifdef FEAT_GUI
8109 && !gui.starting
8110 #endif
8112 set_shellsize((int)Columns, (int)Rows, TRUE);
8113 else
8115 /* Postpone the resizing; check the size and cmdline position for
8116 * messages. */
8117 check_shellsize();
8118 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8119 cmdline_row = Rows - p_ch;
8121 if (p_window >= Rows || !option_was_set((char_u *)"window"))
8122 p_window = Rows - 1;
8125 if (curbuf->b_p_sts < 0)
8127 errmsg = e_positive;
8128 curbuf->b_p_sts = 0;
8130 if (curbuf->b_p_ts <= 0)
8132 errmsg = e_positive;
8133 curbuf->b_p_ts = 8;
8135 if (curbuf->b_p_tw < 0)
8137 errmsg = e_positive;
8138 curbuf->b_p_tw = 0;
8140 if (p_tm < 0)
8142 errmsg = e_positive;
8143 p_tm = 0;
8145 if ((curwin->w_p_scr <= 0
8146 || (curwin->w_p_scr > curwin->w_height
8147 && curwin->w_height > 0))
8148 && full_screen)
8150 if (pp == &(curwin->w_p_scr))
8152 if (curwin->w_p_scr != 0)
8153 errmsg = e_scroll;
8154 win_comp_scroll(curwin);
8156 /* If 'scroll' became invalid because of a side effect silently adjust
8157 * it. */
8158 else if (curwin->w_p_scr <= 0)
8159 curwin->w_p_scr = 1;
8160 else /* curwin->w_p_scr > curwin->w_height */
8161 curwin->w_p_scr = curwin->w_height;
8163 if (p_hi < 0)
8165 errmsg = e_positive;
8166 p_hi = 0;
8168 if (p_report < 0)
8170 errmsg = e_positive;
8171 p_report = 1;
8173 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
8175 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8176 p_sj = Rows / 2;
8177 else
8179 errmsg = e_scroll;
8180 p_sj = 1;
8183 if (p_so < 0 && full_screen)
8185 errmsg = e_scroll;
8186 p_so = 0;
8188 if (p_siso < 0 && full_screen)
8190 errmsg = e_positive;
8191 p_siso = 0;
8193 #ifdef FEAT_CMDWIN
8194 if (p_cwh < 1)
8196 errmsg = e_positive;
8197 p_cwh = 1;
8199 #endif
8200 if (p_ut < 0)
8202 errmsg = e_positive;
8203 p_ut = 2000;
8205 if (p_ss < 0)
8207 errmsg = e_positive;
8208 p_ss = 0;
8211 /* May set global value for local option. */
8212 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8213 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8215 options[opt_idx].flags |= P_WAS_SET;
8217 comp_col(); /* in case 'columns' or 'ls' changed */
8218 if (curwin->w_curswant != MAXCOL)
8219 curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */
8220 check_redraw(options[opt_idx].flags);
8222 return errmsg;
8226 * Called after an option changed: check if something needs to be redrawn.
8228 static void
8229 check_redraw(flags)
8230 long_u flags;
8232 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
8233 int clear = (flags & P_RCLR) == P_RCLR;
8234 int all = ((flags & P_RALL) == P_RALL || clear);
8236 #ifdef FEAT_WINDOWS
8237 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8238 status_redraw_all();
8239 #endif
8241 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8242 changed_window_setting();
8243 if (flags & P_RBUF)
8244 redraw_curbuf_later(NOT_VALID);
8245 if (clear)
8246 redraw_all_later(CLEAR);
8247 else if (all)
8248 redraw_all_later(NOT_VALID);
8252 * Find index for option 'arg'.
8253 * Return -1 if not found.
8255 static int
8256 findoption(arg)
8257 char_u *arg;
8259 int opt_idx;
8260 char *s, *p;
8261 static short quick_tab[27] = {0, 0}; /* quick access table */
8262 int is_term_opt;
8265 * For first call: Initialize the quick-access table.
8266 * It contains the index for the first option that starts with a certain
8267 * letter. There are 26 letters, plus the first "t_" option.
8269 if (quick_tab[1] == 0)
8271 p = options[0].fullname;
8272 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8274 if (s[0] != p[0])
8276 if (s[0] == 't' && s[1] == '_')
8277 quick_tab[26] = opt_idx;
8278 else
8279 quick_tab[CharOrdLow(s[0])] = opt_idx;
8281 p = s;
8286 * Check for name starting with an illegal character.
8288 #ifdef EBCDIC
8289 if (!islower(arg[0]))
8290 #else
8291 if (arg[0] < 'a' || arg[0] > 'z')
8292 #endif
8293 return -1;
8295 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8296 if (is_term_opt)
8297 opt_idx = quick_tab[26];
8298 else
8299 opt_idx = quick_tab[CharOrdLow(arg[0])];
8300 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8302 if (STRCMP(arg, s) == 0) /* match full name */
8303 break;
8305 if (s == NULL && !is_term_opt)
8307 opt_idx = quick_tab[CharOrdLow(arg[0])];
8308 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8310 s = options[opt_idx].shortname;
8311 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8312 break;
8313 s = NULL;
8316 if (s == NULL)
8317 opt_idx = -1;
8318 return opt_idx;
8321 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
8323 * Get the value for an option.
8325 * Returns:
8326 * Number or Toggle option: 1, *numval gets value.
8327 * String option: 0, *stringval gets allocated string.
8328 * Hidden Number or Toggle option: -1.
8329 * hidden String option: -2.
8330 * unknown option: -3.
8333 get_option_value(name, numval, stringval, opt_flags)
8334 char_u *name;
8335 long *numval;
8336 char_u **stringval; /* NULL when only checking existance */
8337 int opt_flags;
8339 int opt_idx;
8340 char_u *varp;
8342 opt_idx = findoption(name);
8343 if (opt_idx < 0) /* unknown option */
8344 return -3;
8346 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8348 if (options[opt_idx].flags & P_STRING)
8350 if (varp == NULL) /* hidden option */
8351 return -2;
8352 if (stringval != NULL)
8354 #ifdef FEAT_CRYPT
8355 /* never return the value of the crypt key */
8356 if ((char_u **)varp == &curbuf->b_p_key
8357 && **(char_u **)(varp) != NUL)
8358 *stringval = vim_strsave((char_u *)"*****");
8359 else
8360 #endif
8361 *stringval = vim_strsave(*(char_u **)(varp));
8363 return 0;
8366 if (varp == NULL) /* hidden option */
8367 return -1;
8368 if (options[opt_idx].flags & P_NUM)
8369 *numval = *(long *)varp;
8370 else
8372 /* Special case: 'modified' is b_changed, but we also want to consider
8373 * it set when 'ff' or 'fenc' changed. */
8374 if ((int *)varp == &curbuf->b_changed)
8375 *numval = curbufIsChanged();
8376 else
8377 *numval = *(int *)varp;
8379 return 1;
8381 #endif
8384 * Set the value of option "name".
8385 * Use "string" for string options, use "number" for other options.
8387 void
8388 set_option_value(name, number, string, opt_flags)
8389 char_u *name;
8390 long number;
8391 char_u *string;
8392 int opt_flags; /* OPT_LOCAL or 0 (both) */
8394 int opt_idx;
8395 char_u *varp;
8396 long_u flags;
8398 opt_idx = findoption(name);
8399 if (opt_idx < 0)
8400 EMSG2(_("E355: Unknown option: %s"), name);
8401 else
8403 flags = options[opt_idx].flags;
8404 #ifdef HAVE_SANDBOX
8405 /* Disallow changing some options in the sandbox */
8406 if (sandbox > 0 && (flags & P_SECURE))
8408 EMSG(_(e_sandbox));
8409 return;
8411 #endif
8412 if (flags & P_STRING)
8413 set_string_option(opt_idx, string, opt_flags);
8414 else
8416 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8417 if (varp != NULL) /* hidden option is not changed */
8419 if (number == 0 && string != NULL)
8421 int idx;
8423 /* Either we are given a string or we are setting option
8424 * to zero. */
8425 for (idx = 0; string[idx] == '0'; ++idx)
8427 if (string[idx] != NUL || idx == 0)
8429 /* There's another character after zeros or the string
8430 * is empty. In both cases, we are trying to set a
8431 * num option using a string. */
8432 EMSG3(_("E521: Number required: &%s = '%s'"),
8433 name, string);
8434 return; /* do nothing as we hit an error */
8438 if (flags & P_NUM)
8439 (void)set_num_option(opt_idx, varp, number,
8440 NULL, 0, opt_flags);
8441 else
8442 (void)set_bool_option(opt_idx, varp, (int)number,
8443 opt_flags);
8450 * Get the terminal code for a terminal option.
8451 * Returns NULL when not found.
8453 char_u *
8454 get_term_code(tname)
8455 char_u *tname;
8457 int opt_idx;
8458 char_u *varp;
8460 if (tname[0] != 't' || tname[1] != '_' ||
8461 tname[2] == NUL || tname[3] == NUL)
8462 return NULL;
8463 if ((opt_idx = findoption(tname)) >= 0)
8465 varp = get_varp(&(options[opt_idx]));
8466 if (varp != NULL)
8467 varp = *(char_u **)(varp);
8468 return varp;
8470 return find_termcode(tname + 2);
8473 char_u *
8474 get_highlight_default()
8476 int i;
8478 i = findoption((char_u *)"hl");
8479 if (i >= 0)
8480 return options[i].def_val[VI_DEFAULT];
8481 return (char_u *)NULL;
8484 #if defined(FEAT_MBYTE) || defined(PROTO)
8485 char_u *
8486 get_encoding_default()
8488 int i;
8490 i = findoption((char_u *)"enc");
8491 if (i >= 0)
8492 return options[i].def_val[VI_DEFAULT];
8493 return (char_u *)NULL;
8495 #endif
8498 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
8500 static int
8501 find_key_option(arg)
8502 char_u *arg;
8504 int key;
8505 int modifiers;
8508 * Don't use get_special_key_code() for t_xx, we don't want it to call
8509 * add_termcap_entry().
8511 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
8512 key = TERMCAP2KEY(arg[2], arg[3]);
8513 else
8515 --arg; /* put arg at the '<' */
8516 modifiers = 0;
8517 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
8518 if (modifiers) /* can't handle modifiers here */
8519 key = 0;
8521 return key;
8525 * if 'all' == 0: show changed options
8526 * if 'all' == 1: show all normal options
8527 * if 'all' == 2: show all terminal options
8529 static void
8530 showoptions(all, opt_flags)
8531 int all;
8532 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
8534 struct vimoption *p;
8535 int col;
8536 int isterm;
8537 char_u *varp;
8538 struct vimoption **items;
8539 int item_count;
8540 int run;
8541 int row, rows;
8542 int cols;
8543 int i;
8544 int len;
8546 #define INC 20
8547 #define GAP 3
8549 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
8550 PARAM_COUNT));
8551 if (items == NULL)
8552 return;
8554 /* Highlight title */
8555 if (all == 2)
8556 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
8557 else if (opt_flags & OPT_GLOBAL)
8558 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
8559 else if (opt_flags & OPT_LOCAL)
8560 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
8561 else
8562 MSG_PUTS_TITLE(_("\n--- Options ---"));
8565 * do the loop two times:
8566 * 1. display the short items
8567 * 2. display the long items (only strings and numbers)
8569 for (run = 1; run <= 2 && !got_int; ++run)
8572 * collect the items in items[]
8574 item_count = 0;
8575 for (p = &options[0]; p->fullname != NULL; p++)
8577 varp = NULL;
8578 isterm = istermoption(p);
8579 if (opt_flags != 0)
8581 if (p->indir != PV_NONE && !isterm)
8582 varp = get_varp_scope(p, opt_flags);
8584 else
8585 varp = get_varp(p);
8586 if (varp != NULL
8587 && ((all == 2 && isterm)
8588 || (all == 1 && !isterm)
8589 || (all == 0 && !optval_default(p, varp))))
8591 if (p->flags & P_BOOL)
8592 len = 1; /* a toggle option fits always */
8593 else
8595 option_value2string(p, opt_flags);
8596 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
8598 if ((len <= INC - GAP && run == 1) ||
8599 (len > INC - GAP && run == 2))
8600 items[item_count++] = p;
8605 * display the items
8607 if (run == 1)
8609 cols = (Columns + GAP - 3) / INC;
8610 if (cols == 0)
8611 cols = 1;
8612 rows = (item_count + cols - 1) / cols;
8614 else /* run == 2 */
8615 rows = item_count;
8616 for (row = 0; row < rows && !got_int; ++row)
8618 msg_putchar('\n'); /* go to next line */
8619 if (got_int) /* 'q' typed in more */
8620 break;
8621 col = 0;
8622 for (i = row; i < item_count; i += rows)
8624 msg_col = col; /* make columns */
8625 showoneopt(items[i], opt_flags);
8626 col += INC;
8628 out_flush();
8629 ui_breakcheck();
8632 vim_free(items);
8636 * Return TRUE if option "p" has its default value.
8638 static int
8639 optval_default(p, varp)
8640 struct vimoption *p;
8641 char_u *varp;
8643 int dvi;
8645 if (varp == NULL)
8646 return TRUE; /* hidden option is always at default */
8647 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
8648 if (p->flags & P_NUM)
8649 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
8650 if (p->flags & P_BOOL)
8651 /* the cast to long is required for Manx C, long_i is
8652 * needed for MSVC */
8653 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
8654 /* P_STRING */
8655 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
8659 * showoneopt: show the value of one option
8660 * must not be called with a hidden option!
8662 static void
8663 showoneopt(p, opt_flags)
8664 struct vimoption *p;
8665 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
8667 char_u *varp;
8668 int save_silent = silent_mode;
8670 silent_mode = FALSE;
8671 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
8673 varp = get_varp_scope(p, opt_flags);
8675 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
8676 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
8677 ? !curbufIsChanged() : !*(int *)varp))
8678 MSG_PUTS("no");
8679 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
8680 MSG_PUTS("--");
8681 else
8682 MSG_PUTS(" ");
8683 MSG_PUTS(p->fullname);
8684 if (!(p->flags & P_BOOL))
8686 msg_putchar('=');
8687 /* put value string in NameBuff */
8688 option_value2string(p, opt_flags);
8689 msg_outtrans(NameBuff);
8692 silent_mode = save_silent;
8693 info_message = FALSE;
8697 * Write modified options as ":set" commands to a file.
8699 * There are three values for "opt_flags":
8700 * OPT_GLOBAL: Write global option values and fresh values of
8701 * buffer-local options (used for start of a session
8702 * file).
8703 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
8704 * curwin (used for a vimrc file).
8705 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
8706 * and local values for window-local options of
8707 * curwin. Local values are also written when at the
8708 * default value, because a modeline or autocommand
8709 * may have set them when doing ":edit file" and the
8710 * user has set them back at the default or fresh
8711 * value.
8712 * When "local_only" is TRUE, don't write fresh
8713 * values, only local values (for ":mkview").
8714 * (fresh value = value used for a new buffer or window for a local option).
8716 * Return FAIL on error, OK otherwise.
8719 makeset(fd, opt_flags, local_only)
8720 FILE *fd;
8721 int opt_flags;
8722 int local_only;
8724 struct vimoption *p;
8725 char_u *varp; /* currently used value */
8726 char_u *varp_fresh; /* local value */
8727 char_u *varp_local = NULL; /* fresh value */
8728 char *cmd;
8729 int round;
8730 int pri;
8733 * The options that don't have a default (terminal name, columns, lines)
8734 * are never written. Terminal options are also not written.
8735 * Do the loop over "options[]" twice: once for options with the
8736 * P_PRI_MKRC flag and once without.
8738 for (pri = 1; pri >= 0; --pri)
8740 for (p = &options[0]; !istermoption(p); p++)
8741 if (!(p->flags & P_NO_MKRC)
8742 && !istermoption(p)
8743 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
8745 /* skip global option when only doing locals */
8746 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
8747 continue;
8749 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
8750 * file, they are always buffer-specific. */
8751 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
8752 continue;
8754 /* Global values are only written when not at the default value. */
8755 varp = get_varp_scope(p, opt_flags);
8756 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
8757 continue;
8759 round = 2;
8760 if (p->indir != PV_NONE)
8762 if (p->var == VAR_WIN)
8764 /* skip window-local option when only doing globals */
8765 if (!(opt_flags & OPT_LOCAL))
8766 continue;
8767 /* When fresh value of window-local option is not at the
8768 * default, need to write it too. */
8769 if (!(opt_flags & OPT_GLOBAL) && !local_only)
8771 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
8772 if (!optval_default(p, varp_fresh))
8774 round = 1;
8775 varp_local = varp;
8776 varp = varp_fresh;
8782 /* Round 1: fresh value for window-local options.
8783 * Round 2: other values */
8784 for ( ; round <= 2; varp = varp_local, ++round)
8786 if (round == 1 || (opt_flags & OPT_GLOBAL))
8787 cmd = "set";
8788 else
8789 cmd = "setlocal";
8791 if (p->flags & P_BOOL)
8793 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
8794 return FAIL;
8796 else if (p->flags & P_NUM)
8798 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
8799 return FAIL;
8801 else /* P_STRING */
8803 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
8804 int do_endif = FALSE;
8806 /* Don't set 'syntax' and 'filetype' again if the value is
8807 * already right, avoids reloading the syntax file. */
8808 if (
8809 # if defined(FEAT_SYN_HL)
8810 p->indir == PV_SYN
8811 # if defined(FEAT_AUTOCMD)
8813 # endif
8814 # endif
8815 # if defined(FEAT_AUTOCMD)
8816 p->indir == PV_FT
8817 # endif
8820 if (fprintf(fd, "if &%s != '%s'", p->fullname,
8821 *(char_u **)(varp)) < 0
8822 || put_eol(fd) < 0)
8823 return FAIL;
8824 do_endif = TRUE;
8826 #endif
8827 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
8828 (p->flags & P_EXPAND) != 0) == FAIL)
8829 return FAIL;
8830 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
8831 if (do_endif)
8833 if (put_line(fd, "endif") == FAIL)
8834 return FAIL;
8836 #endif
8841 return OK;
8844 #if defined(FEAT_FOLDING) || defined(PROTO)
8846 * Generate set commands for the local fold options only. Used when
8847 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
8850 makefoldset(fd)
8851 FILE *fd;
8853 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
8854 # ifdef FEAT_EVAL
8855 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
8856 == FAIL
8857 # endif
8858 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
8859 == FAIL
8860 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
8861 == FAIL
8862 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
8863 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
8864 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
8865 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
8867 return FAIL;
8869 return OK;
8871 #endif
8873 static int
8874 put_setstring(fd, cmd, name, valuep, expand)
8875 FILE *fd;
8876 char *cmd;
8877 char *name;
8878 char_u **valuep;
8879 int expand;
8881 char_u *s;
8882 char_u buf[MAXPATHL];
8884 if (fprintf(fd, "%s %s=", cmd, name) < 0)
8885 return FAIL;
8886 if (*valuep != NULL)
8888 /* Output 'pastetoggle' as key names. For other
8889 * options some characters have to be escaped with
8890 * CTRL-V or backslash */
8891 if (valuep == &p_pt)
8893 s = *valuep;
8894 while (*s != NUL)
8895 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
8896 return FAIL;
8898 else if (expand)
8900 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
8901 if (put_escstr(fd, buf, 2) == FAIL)
8902 return FAIL;
8904 else if (put_escstr(fd, *valuep, 2) == FAIL)
8905 return FAIL;
8907 if (put_eol(fd) < 0)
8908 return FAIL;
8909 return OK;
8912 static int
8913 put_setnum(fd, cmd, name, valuep)
8914 FILE *fd;
8915 char *cmd;
8916 char *name;
8917 long *valuep;
8919 long wc;
8921 if (fprintf(fd, "%s %s=", cmd, name) < 0)
8922 return FAIL;
8923 if (wc_use_keyname((char_u *)valuep, &wc))
8925 /* print 'wildchar' and 'wildcharm' as a key name */
8926 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
8927 return FAIL;
8929 else if (fprintf(fd, "%ld", *valuep) < 0)
8930 return FAIL;
8931 if (put_eol(fd) < 0)
8932 return FAIL;
8933 return OK;
8936 static int
8937 put_setbool(fd, cmd, name, value)
8938 FILE *fd;
8939 char *cmd;
8940 char *name;
8941 int value;
8943 if (value < 0) /* global/local option using global value */
8944 return OK;
8945 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
8946 || put_eol(fd) < 0)
8947 return FAIL;
8948 return OK;
8952 * Clear all the terminal options.
8953 * If the option has been allocated, free the memory.
8954 * Terminal options are never hidden or indirect.
8956 void
8957 clear_termoptions()
8960 * Reset a few things before clearing the old options. This may cause
8961 * outputting a few things that the terminal doesn't understand, but the
8962 * screen will be cleared later, so this is OK.
8964 #ifdef FEAT_MOUSE_TTY
8965 mch_setmouse(FALSE); /* switch mouse off */
8966 #endif
8967 #ifdef FEAT_TITLE
8968 mch_restore_title(3); /* restore window titles */
8969 #endif
8970 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
8971 /* When starting the GUI close the display opened for the clipboard.
8972 * After restoring the title, because that will need the display. */
8973 if (gui.starting)
8974 clear_xterm_clip();
8975 #endif
8976 #ifdef WIN3264
8978 * Check if this is allowed now.
8980 if (can_end_termcap_mode(FALSE) == TRUE)
8981 #endif
8982 stoptermcap(); /* stop termcap mode */
8984 free_termoptions();
8987 void
8988 free_termoptions()
8990 struct vimoption *p;
8992 for (p = &options[0]; p->fullname != NULL; p++)
8993 if (istermoption(p))
8995 if (p->flags & P_ALLOCED)
8996 free_string_option(*(char_u **)(p->var));
8997 if (p->flags & P_DEF_ALLOCED)
8998 free_string_option(p->def_val[VI_DEFAULT]);
8999 *(char_u **)(p->var) = empty_option;
9000 p->def_val[VI_DEFAULT] = empty_option;
9001 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9003 clear_termcodes();
9007 * Free the string for one term option, if it was allocated.
9008 * Set the string to empty_option and clear allocated flag.
9009 * "var" points to the option value.
9011 void
9012 free_one_termoption(var)
9013 char_u *var;
9015 struct vimoption *p;
9017 for (p = &options[0]; p->fullname != NULL; p++)
9018 if (p->var == var)
9020 if (p->flags & P_ALLOCED)
9021 free_string_option(*(char_u **)(p->var));
9022 *(char_u **)(p->var) = empty_option;
9023 p->flags &= ~P_ALLOCED;
9024 break;
9029 * Set the terminal option defaults to the current value.
9030 * Used after setting the terminal name.
9032 void
9033 set_term_defaults()
9035 struct vimoption *p;
9037 for (p = &options[0]; p->fullname != NULL; p++)
9039 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9041 if (p->flags & P_DEF_ALLOCED)
9043 free_string_option(p->def_val[VI_DEFAULT]);
9044 p->flags &= ~P_DEF_ALLOCED;
9046 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9047 if (p->flags & P_ALLOCED)
9049 p->flags |= P_DEF_ALLOCED;
9050 p->flags &= ~P_ALLOCED; /* don't free the value now */
9057 * return TRUE if 'p' starts with 't_'
9059 static int
9060 istermoption(p)
9061 struct vimoption *p;
9063 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9067 * Compute columns for ruler and shown command. 'sc_col' is also used to
9068 * decide what the maximum length of a message on the status line can be.
9069 * If there is a status line for the last window, 'sc_col' is independent
9070 * of 'ru_col'.
9073 #define COL_RULER 17 /* columns needed by standard ruler */
9075 void
9076 comp_col()
9078 #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9079 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9081 sc_col = 0;
9082 ru_col = 0;
9083 if (p_ru)
9085 #ifdef FEAT_STL_OPT
9086 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9087 #else
9088 ru_col = COL_RULER + 1;
9089 #endif
9090 /* no last status line, adjust sc_col */
9091 if (!last_has_status)
9092 sc_col = ru_col;
9094 if (p_sc)
9096 sc_col += SHOWCMD_COLS;
9097 if (!p_ru || last_has_status) /* no need for separating space */
9098 ++sc_col;
9100 sc_col = Columns - sc_col;
9101 ru_col = Columns - ru_col;
9102 if (sc_col <= 0) /* screen too narrow, will become a mess */
9103 sc_col = 1;
9104 if (ru_col <= 0)
9105 ru_col = 1;
9106 #else
9107 sc_col = Columns;
9108 ru_col = Columns;
9109 #endif
9113 * Get pointer to option variable, depending on local or global scope.
9115 static char_u *
9116 get_varp_scope(p, opt_flags)
9117 struct vimoption *p;
9118 int opt_flags;
9120 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9122 if (p->var == VAR_WIN)
9123 return (char_u *)GLOBAL_WO(get_varp(p));
9124 return p->var;
9126 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
9128 switch ((int)p->indir)
9130 #ifdef FEAT_QUICKFIX
9131 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9132 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9133 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
9134 #endif
9135 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9136 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9137 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
9138 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
9139 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
9140 #ifdef FEAT_FIND_ID
9141 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9142 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
9143 #endif
9144 #ifdef FEAT_INS_EXPAND
9145 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9146 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
9147 #endif
9148 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9149 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9150 #endif
9151 #ifdef FEAT_STL_OPT
9152 case PV_STL: return (char_u *)&(curwin->w_p_stl);
9153 #endif
9155 return NULL; /* "cannot happen" */
9157 return get_varp(p);
9161 * Get pointer to option variable.
9163 static char_u *
9164 get_varp(p)
9165 struct vimoption *p;
9167 /* hidden option, always return NULL */
9168 if (p->var == NULL)
9169 return NULL;
9171 switch ((int)p->indir)
9173 case PV_NONE: return p->var;
9175 /* global option with local value: use local value if it's been set */
9176 case PV_EP: return *curbuf->b_p_ep != NUL
9177 ? (char_u *)&curbuf->b_p_ep : p->var;
9178 case PV_KP: return *curbuf->b_p_kp != NUL
9179 ? (char_u *)&curbuf->b_p_kp : p->var;
9180 case PV_PATH: return *curbuf->b_p_path != NUL
9181 ? (char_u *)&(curbuf->b_p_path) : p->var;
9182 case PV_AR: return curbuf->b_p_ar >= 0
9183 ? (char_u *)&(curbuf->b_p_ar) : p->var;
9184 case PV_TAGS: return *curbuf->b_p_tags != NUL
9185 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9186 #ifdef FEAT_FIND_ID
9187 case PV_DEF: return *curbuf->b_p_def != NUL
9188 ? (char_u *)&(curbuf->b_p_def) : p->var;
9189 case PV_INC: return *curbuf->b_p_inc != NUL
9190 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9191 #endif
9192 #ifdef FEAT_INS_EXPAND
9193 case PV_DICT: return *curbuf->b_p_dict != NUL
9194 ? (char_u *)&(curbuf->b_p_dict) : p->var;
9195 case PV_TSR: return *curbuf->b_p_tsr != NUL
9196 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9197 #endif
9198 #ifdef FEAT_QUICKFIX
9199 case PV_EFM: return *curbuf->b_p_efm != NUL
9200 ? (char_u *)&(curbuf->b_p_efm) : p->var;
9201 case PV_GP: return *curbuf->b_p_gp != NUL
9202 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9203 case PV_MP: return *curbuf->b_p_mp != NUL
9204 ? (char_u *)&(curbuf->b_p_mp) : p->var;
9205 #endif
9206 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9207 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9208 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9209 #endif
9210 #ifdef FEAT_STL_OPT
9211 case PV_STL: return *curwin->w_p_stl != NUL
9212 ? (char_u *)&(curwin->w_p_stl) : p->var;
9213 #endif
9215 #ifdef FEAT_ARABIC
9216 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9217 #endif
9218 case PV_LIST: return (char_u *)&(curwin->w_p_list);
9219 #ifdef FEAT_SPELL
9220 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
9221 #endif
9222 #ifdef FEAT_SYN_HL
9223 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
9224 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
9225 #endif
9226 #ifdef FEAT_DIFF
9227 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
9228 #endif
9229 #ifdef FEAT_FOLDING
9230 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
9231 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
9232 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
9233 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
9234 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
9235 case PV_FML: return (char_u *)&(curwin->w_p_fml);
9236 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
9237 # ifdef FEAT_EVAL
9238 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
9239 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
9240 # endif
9241 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
9242 #endif
9243 case PV_NU: return (char_u *)&(curwin->w_p_nu);
9244 #ifdef FEAT_LINEBREAK
9245 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
9246 #endif
9247 #ifdef FEAT_WINDOWS
9248 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
9249 #endif
9250 #ifdef FEAT_VERTSPLIT
9251 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
9252 #endif
9253 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
9254 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
9255 #endif
9256 #ifdef FEAT_RIGHTLEFT
9257 case PV_RL: return (char_u *)&(curwin->w_p_rl);
9258 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
9259 #endif
9260 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
9261 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
9262 #ifdef FEAT_LINEBREAK
9263 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
9264 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
9265 case PV_BRIMIN: return (char_u *)&(curwin->w_p_brimin);
9266 case PV_BRISHIFT: return (char_u *)&(curwin->w_p_brishift);
9267 #endif
9268 #ifdef FEAT_SCROLLBIND
9269 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
9270 #endif
9272 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
9273 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
9274 #ifdef FEAT_MBYTE
9275 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
9276 #endif
9277 #if defined(FEAT_QUICKFIX)
9278 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
9279 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
9280 #endif
9281 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
9282 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
9283 #ifdef FEAT_CINDENT
9284 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
9285 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
9286 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
9287 #endif
9288 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9289 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
9290 #endif
9291 #ifdef FEAT_COMMENTS
9292 case PV_COM: return (char_u *)&(curbuf->b_p_com);
9293 #endif
9294 #ifdef FEAT_FOLDING
9295 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
9296 #endif
9297 #ifdef FEAT_INS_EXPAND
9298 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
9299 #endif
9300 #ifdef FEAT_COMPL_FUNC
9301 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
9302 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
9303 #endif
9304 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
9305 case PV_ET: return (char_u *)&(curbuf->b_p_et);
9306 #ifdef FEAT_MBYTE
9307 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
9308 #endif
9309 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
9310 #ifdef FEAT_AUTOCMD
9311 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
9312 #endif
9313 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
9314 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
9315 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
9316 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
9317 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
9318 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
9319 #ifdef FEAT_FIND_ID
9320 # ifdef FEAT_EVAL
9321 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
9322 # endif
9323 #endif
9324 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9325 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
9326 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
9327 #endif
9328 #ifdef FEAT_EVAL
9329 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
9330 #endif
9331 #ifdef FEAT_CRYPT
9332 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
9333 #endif
9334 #ifdef FEAT_LISP
9335 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
9336 #endif
9337 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
9338 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
9339 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
9340 case PV_MOD: return (char_u *)&(curbuf->b_changed);
9341 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
9342 #ifdef FEAT_OSFILETYPE
9343 case PV_OFT: return (char_u *)&(curbuf->b_p_oft);
9344 #endif
9345 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
9346 #ifdef FEAT_TEXTOBJ
9347 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
9348 #endif
9349 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
9350 #ifdef FEAT_SMARTINDENT
9351 case PV_SI: return (char_u *)&(curbuf->b_p_si);
9352 #endif
9353 #ifndef SHORT_FNAME
9354 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
9355 #endif
9356 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
9357 #ifdef FEAT_SEARCHPATH
9358 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
9359 #endif
9360 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
9361 #ifdef FEAT_SYN_HL
9362 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
9363 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
9364 #endif
9365 #ifdef FEAT_SPELL
9366 case PV_SPC: return (char_u *)&(curbuf->b_p_spc);
9367 case PV_SPF: return (char_u *)&(curbuf->b_p_spf);
9368 case PV_SPL: return (char_u *)&(curbuf->b_p_spl);
9369 #endif
9370 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
9371 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
9372 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
9373 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
9374 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
9375 #ifdef FEAT_KEYMAP
9376 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
9377 #endif
9378 default: EMSG(_("E356: get_varp ERROR"));
9380 /* always return a valid pointer to avoid a crash! */
9381 return (char_u *)&(curbuf->b_p_wm);
9385 * Get the value of 'equalprg', either the buffer-local one or the global one.
9387 char_u *
9388 get_equalprg()
9390 if (*curbuf->b_p_ep == NUL)
9391 return p_ep;
9392 return curbuf->b_p_ep;
9395 #if defined(FEAT_WINDOWS) || defined(PROTO)
9397 * Copy options from one window to another.
9398 * Used when splitting a window.
9400 void
9401 win_copy_options(wp_from, wp_to)
9402 win_T *wp_from;
9403 win_T *wp_to;
9405 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
9406 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
9407 # ifdef FEAT_RIGHTLEFT
9408 # ifdef FEAT_FKMAP
9409 /* Is this right? */
9410 wp_to->w_farsi = wp_from->w_farsi;
9411 # endif
9412 # endif
9414 #endif
9417 * Copy the options from one winopt_T to another.
9418 * Doesn't free the old option values in "to", use clear_winopt() for that.
9419 * The 'scroll' option is not copied, because it depends on the window height.
9420 * The 'previewwindow' option is reset, there can be only one preview window.
9422 void
9423 copy_winopt(from, to)
9424 winopt_T *from;
9425 winopt_T *to;
9427 #ifdef FEAT_ARABIC
9428 to->wo_arab = from->wo_arab;
9429 #endif
9430 to->wo_list = from->wo_list;
9431 to->wo_nu = from->wo_nu;
9432 #ifdef FEAT_LINEBREAK
9433 to->wo_nuw = from->wo_nuw;
9434 #endif
9435 #ifdef FEAT_RIGHTLEFT
9436 to->wo_rl = from->wo_rl;
9437 to->wo_rlc = vim_strsave(from->wo_rlc);
9438 #endif
9439 #ifdef FEAT_STL_OPT
9440 to->wo_stl = vim_strsave(from->wo_stl);
9441 #endif
9442 to->wo_wrap = from->wo_wrap;
9443 #ifdef FEAT_LINEBREAK
9444 to->wo_lbr = from->wo_lbr;
9445 to->wo_bri = from->wo_bri;
9446 to->wo_brimin = from->wo_brimin;
9447 #endif
9448 #ifdef FEAT_SCROLLBIND
9449 to->wo_scb = from->wo_scb;
9450 #endif
9451 #ifdef FEAT_SPELL
9452 to->wo_spell = from->wo_spell;
9453 #endif
9454 #ifdef FEAT_SYN_HL
9455 to->wo_cuc = from->wo_cuc;
9456 to->wo_cul = from->wo_cul;
9457 #endif
9458 #ifdef FEAT_DIFF
9459 to->wo_diff = from->wo_diff;
9460 #endif
9461 #ifdef FEAT_FOLDING
9462 to->wo_fdc = from->wo_fdc;
9463 to->wo_fen = from->wo_fen;
9464 to->wo_fdi = vim_strsave(from->wo_fdi);
9465 to->wo_fml = from->wo_fml;
9466 to->wo_fdl = from->wo_fdl;
9467 to->wo_fdm = vim_strsave(from->wo_fdm);
9468 to->wo_fdn = from->wo_fdn;
9469 # ifdef FEAT_EVAL
9470 to->wo_fde = vim_strsave(from->wo_fde);
9471 to->wo_fdt = vim_strsave(from->wo_fdt);
9472 # endif
9473 to->wo_fmr = vim_strsave(from->wo_fmr);
9474 #endif
9475 check_winopt(to); /* don't want NULL pointers */
9479 * Check string options in a window for a NULL value.
9481 void
9482 check_win_options(win)
9483 win_T *win;
9485 check_winopt(&win->w_onebuf_opt);
9486 check_winopt(&win->w_allbuf_opt);
9490 * Check for NULL pointers in a winopt_T and replace them with empty_option.
9492 void
9493 check_winopt(wop)
9494 winopt_T *wop UNUSED;
9496 #ifdef FEAT_FOLDING
9497 check_string_option(&wop->wo_fdi);
9498 check_string_option(&wop->wo_fdm);
9499 # ifdef FEAT_EVAL
9500 check_string_option(&wop->wo_fde);
9501 check_string_option(&wop->wo_fdt);
9502 # endif
9503 check_string_option(&wop->wo_fmr);
9504 #endif
9505 #ifdef FEAT_RIGHTLEFT
9506 check_string_option(&wop->wo_rlc);
9507 #endif
9508 #ifdef FEAT_STL_OPT
9509 check_string_option(&wop->wo_stl);
9510 #endif
9514 * Free the allocated memory inside a winopt_T.
9516 void
9517 clear_winopt(wop)
9518 winopt_T *wop UNUSED;
9520 #ifdef FEAT_FOLDING
9521 clear_string_option(&wop->wo_fdi);
9522 clear_string_option(&wop->wo_fdm);
9523 # ifdef FEAT_EVAL
9524 clear_string_option(&wop->wo_fde);
9525 clear_string_option(&wop->wo_fdt);
9526 # endif
9527 clear_string_option(&wop->wo_fmr);
9528 #endif
9529 #ifdef FEAT_RIGHTLEFT
9530 clear_string_option(&wop->wo_rlc);
9531 #endif
9532 #ifdef FEAT_STL_OPT
9533 clear_string_option(&wop->wo_stl);
9534 #endif
9538 * Copy global option values to local options for one buffer.
9539 * Used when creating a new buffer and sometimes when entering a buffer.
9540 * flags:
9541 * BCO_ENTER We will enter the buf buffer.
9542 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
9543 * appropriate.
9544 * BCO_NOHELP Don't copy the values to a help buffer.
9546 void
9547 buf_copy_options(buf, flags)
9548 buf_T *buf;
9549 int flags;
9551 int should_copy = TRUE;
9552 char_u *save_p_isk = NULL; /* init for GCC */
9553 int dont_do_help;
9554 int did_isk = FALSE;
9557 * Don't do anything of the buffer is invalid.
9559 if (buf == NULL || !buf_valid(buf))
9560 return;
9563 * Skip this when the option defaults have not been set yet. Happens when
9564 * main() allocates the first buffer.
9566 if (p_cpo != NULL)
9569 * Always copy when entering and 'cpo' contains 'S'.
9570 * Don't copy when already initialized.
9571 * Don't copy when 'cpo' contains 's' and not entering.
9572 * 'S' BCO_ENTER initialized 's' should_copy
9573 * yes yes X X TRUE
9574 * yes no yes X FALSE
9575 * no X yes X FALSE
9576 * X no no yes FALSE
9577 * X no no no TRUE
9578 * no yes no X TRUE
9580 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
9581 && (buf->b_p_initialized
9582 || (!(flags & BCO_ENTER)
9583 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
9584 should_copy = FALSE;
9586 if (should_copy || (flags & BCO_ALWAYS))
9588 /* Don't copy the options specific to a help buffer when
9589 * BCO_NOHELP is given or the options were initialized already
9590 * (jumping back to a help file with CTRL-T or CTRL-O) */
9591 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
9592 || buf->b_p_initialized;
9593 if (dont_do_help) /* don't free b_p_isk */
9595 save_p_isk = buf->b_p_isk;
9596 buf->b_p_isk = NULL;
9599 * Always free the allocated strings.
9600 * If not already initialized, set 'readonly' and copy 'fileformat'.
9602 if (!buf->b_p_initialized)
9604 free_buf_options(buf, TRUE);
9605 buf->b_p_ro = FALSE; /* don't copy readonly */
9606 buf->b_p_tx = p_tx;
9607 #ifdef FEAT_MBYTE
9608 buf->b_p_fenc = vim_strsave(p_fenc);
9609 #endif
9610 buf->b_p_ff = vim_strsave(p_ff);
9611 #if defined(FEAT_QUICKFIX)
9612 buf->b_p_bh = empty_option;
9613 buf->b_p_bt = empty_option;
9614 #endif
9616 else
9617 free_buf_options(buf, FALSE);
9619 buf->b_p_ai = p_ai;
9620 buf->b_p_ai_nopaste = p_ai_nopaste;
9621 buf->b_p_sw = p_sw;
9622 buf->b_p_tw = p_tw;
9623 buf->b_p_tw_nopaste = p_tw_nopaste;
9624 buf->b_p_tw_nobin = p_tw_nobin;
9625 buf->b_p_wm = p_wm;
9626 buf->b_p_wm_nopaste = p_wm_nopaste;
9627 buf->b_p_wm_nobin = p_wm_nobin;
9628 buf->b_p_bin = p_bin;
9629 #ifdef FEAT_MBYTE
9630 buf->b_p_bomb = p_bomb;
9631 #endif
9632 buf->b_p_et = p_et;
9633 buf->b_p_et_nobin = p_et_nobin;
9634 buf->b_p_ml = p_ml;
9635 buf->b_p_ml_nobin = p_ml_nobin;
9636 buf->b_p_inf = p_inf;
9637 buf->b_p_swf = p_swf;
9638 #ifdef FEAT_INS_EXPAND
9639 buf->b_p_cpt = vim_strsave(p_cpt);
9640 #endif
9641 #ifdef FEAT_COMPL_FUNC
9642 buf->b_p_cfu = vim_strsave(p_cfu);
9643 buf->b_p_ofu = vim_strsave(p_ofu);
9644 #endif
9645 buf->b_p_sts = p_sts;
9646 buf->b_p_sts_nopaste = p_sts_nopaste;
9647 #ifndef SHORT_FNAME
9648 buf->b_p_sn = p_sn;
9649 #endif
9650 #ifdef FEAT_COMMENTS
9651 buf->b_p_com = vim_strsave(p_com);
9652 #endif
9653 #ifdef FEAT_FOLDING
9654 buf->b_p_cms = vim_strsave(p_cms);
9655 #endif
9656 buf->b_p_fo = vim_strsave(p_fo);
9657 buf->b_p_flp = vim_strsave(p_flp);
9658 buf->b_p_nf = vim_strsave(p_nf);
9659 buf->b_p_mps = vim_strsave(p_mps);
9660 #ifdef FEAT_SMARTINDENT
9661 buf->b_p_si = p_si;
9662 #endif
9663 buf->b_p_ci = p_ci;
9664 #ifdef FEAT_CINDENT
9665 buf->b_p_cin = p_cin;
9666 buf->b_p_cink = vim_strsave(p_cink);
9667 buf->b_p_cino = vim_strsave(p_cino);
9668 #endif
9669 #ifdef FEAT_AUTOCMD
9670 /* Don't copy 'filetype', it must be detected */
9671 buf->b_p_ft = empty_option;
9672 #endif
9673 #ifdef FEAT_OSFILETYPE
9674 buf->b_p_oft = vim_strsave(p_oft);
9675 #endif
9676 buf->b_p_pi = p_pi;
9677 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9678 buf->b_p_cinw = vim_strsave(p_cinw);
9679 #endif
9680 #ifdef FEAT_LISP
9681 buf->b_p_lisp = p_lisp;
9682 #endif
9683 #ifdef FEAT_SYN_HL
9684 /* Don't copy 'syntax', it must be set */
9685 buf->b_p_syn = empty_option;
9686 buf->b_p_smc = p_smc;
9687 #endif
9688 #ifdef FEAT_SPELL
9689 buf->b_p_spc = vim_strsave(p_spc);
9690 (void)compile_cap_prog(buf);
9691 buf->b_p_spf = vim_strsave(p_spf);
9692 buf->b_p_spl = vim_strsave(p_spl);
9693 #endif
9694 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9695 buf->b_p_inde = vim_strsave(p_inde);
9696 buf->b_p_indk = vim_strsave(p_indk);
9697 #endif
9698 #if defined(FEAT_EVAL)
9699 buf->b_p_fex = vim_strsave(p_fex);
9700 #endif
9701 #ifdef FEAT_CRYPT
9702 buf->b_p_key = vim_strsave(p_key);
9703 #endif
9704 #ifdef FEAT_SEARCHPATH
9705 buf->b_p_sua = vim_strsave(p_sua);
9706 #endif
9707 #ifdef FEAT_KEYMAP
9708 buf->b_p_keymap = vim_strsave(p_keymap);
9709 buf->b_kmap_state |= KEYMAP_INIT;
9710 #endif
9711 /* This isn't really an option, but copying the langmap and IME
9712 * state from the current buffer is better than resetting it. */
9713 buf->b_p_iminsert = p_iminsert;
9714 buf->b_p_imsearch = p_imsearch;
9716 /* options that are normally global but also have a local value
9717 * are not copied, start using the global value */
9718 buf->b_p_ar = -1;
9719 #ifdef FEAT_QUICKFIX
9720 buf->b_p_gp = empty_option;
9721 buf->b_p_mp = empty_option;
9722 buf->b_p_efm = empty_option;
9723 #endif
9724 buf->b_p_ep = empty_option;
9725 buf->b_p_kp = empty_option;
9726 buf->b_p_path = empty_option;
9727 buf->b_p_tags = empty_option;
9728 #ifdef FEAT_FIND_ID
9729 buf->b_p_def = empty_option;
9730 buf->b_p_inc = empty_option;
9731 # ifdef FEAT_EVAL
9732 buf->b_p_inex = vim_strsave(p_inex);
9733 # endif
9734 #endif
9735 #ifdef FEAT_INS_EXPAND
9736 buf->b_p_dict = empty_option;
9737 buf->b_p_tsr = empty_option;
9738 #endif
9739 #ifdef FEAT_TEXTOBJ
9740 buf->b_p_qe = vim_strsave(p_qe);
9741 #endif
9742 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9743 buf->b_p_bexpr = empty_option;
9744 #endif
9747 * Don't copy the options set by ex_help(), use the saved values,
9748 * when going from a help buffer to a non-help buffer.
9749 * Don't touch these at all when BCO_NOHELP is used and going from
9750 * or to a help buffer.
9752 if (dont_do_help)
9753 buf->b_p_isk = save_p_isk;
9754 else
9756 buf->b_p_isk = vim_strsave(p_isk);
9757 did_isk = TRUE;
9758 buf->b_p_ts = p_ts;
9759 buf->b_help = FALSE;
9760 #ifdef FEAT_QUICKFIX
9761 if (buf->b_p_bt[0] == 'h')
9762 clear_string_option(&buf->b_p_bt);
9763 #endif
9764 buf->b_p_ma = p_ma;
9769 * When the options should be copied (ignoring BCO_ALWAYS), set the
9770 * flag that indicates that the options have been initialized.
9772 if (should_copy)
9773 buf->b_p_initialized = TRUE;
9776 check_buf_options(buf); /* make sure we don't have NULLs */
9777 if (did_isk)
9778 (void)buf_init_chartab(buf, FALSE);
9782 * Reset the 'modifiable' option and its default value.
9784 void
9785 reset_modifiable()
9787 int opt_idx;
9789 curbuf->b_p_ma = FALSE;
9790 p_ma = FALSE;
9791 opt_idx = findoption((char_u *)"ma");
9792 if (opt_idx >= 0)
9793 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
9797 * Set the global value for 'iminsert' to the local value.
9799 void
9800 set_iminsert_global()
9802 p_iminsert = curbuf->b_p_iminsert;
9806 * Set the global value for 'imsearch' to the local value.
9808 void
9809 set_imsearch_global()
9811 p_imsearch = curbuf->b_p_imsearch;
9814 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
9815 static int expand_option_idx = -1;
9816 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
9817 static int expand_option_flags = 0;
9819 void
9820 set_context_in_set_cmd(xp, arg, opt_flags)
9821 expand_T *xp;
9822 char_u *arg;
9823 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
9825 int nextchar;
9826 long_u flags = 0; /* init for GCC */
9827 int opt_idx = 0; /* init for GCC */
9828 char_u *p;
9829 char_u *s;
9830 int is_term_option = FALSE;
9831 int key;
9833 expand_option_flags = opt_flags;
9835 xp->xp_context = EXPAND_SETTINGS;
9836 if (*arg == NUL)
9838 xp->xp_pattern = arg;
9839 return;
9841 p = arg + STRLEN(arg) - 1;
9842 if (*p == ' ' && *(p - 1) != '\\')
9844 xp->xp_pattern = p + 1;
9845 return;
9847 while (p > arg)
9849 s = p;
9850 /* count number of backslashes before ' ' or ',' */
9851 if (*p == ' ' || *p == ',')
9853 while (s > arg && *(s - 1) == '\\')
9854 --s;
9856 /* break at a space with an even number of backslashes */
9857 if (*p == ' ' && ((p - s) & 1) == 0)
9859 ++p;
9860 break;
9862 --p;
9864 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
9866 xp->xp_context = EXPAND_BOOL_SETTINGS;
9867 p += 2;
9869 if (STRNCMP(p, "inv", 3) == 0)
9871 xp->xp_context = EXPAND_BOOL_SETTINGS;
9872 p += 3;
9874 xp->xp_pattern = arg = p;
9875 if (*arg == '<')
9877 while (*p != '>')
9878 if (*p++ == NUL) /* expand terminal option name */
9879 return;
9880 key = get_special_key_code(arg + 1);
9881 if (key == 0) /* unknown name */
9883 xp->xp_context = EXPAND_NOTHING;
9884 return;
9886 nextchar = *++p;
9887 is_term_option = TRUE;
9888 expand_option_name[2] = KEY2TERMCAP0(key);
9889 expand_option_name[3] = KEY2TERMCAP1(key);
9891 else
9893 if (p[0] == 't' && p[1] == '_')
9895 p += 2;
9896 if (*p != NUL)
9897 ++p;
9898 if (*p == NUL)
9899 return; /* expand option name */
9900 nextchar = *++p;
9901 is_term_option = TRUE;
9902 expand_option_name[2] = p[-2];
9903 expand_option_name[3] = p[-1];
9905 else
9907 /* Allow * wildcard */
9908 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
9909 p++;
9910 if (*p == NUL)
9911 return;
9912 nextchar = *p;
9913 *p = NUL;
9914 opt_idx = findoption(arg);
9915 *p = nextchar;
9916 if (opt_idx == -1 || options[opt_idx].var == NULL)
9918 xp->xp_context = EXPAND_NOTHING;
9919 return;
9921 flags = options[opt_idx].flags;
9922 if (flags & P_BOOL)
9924 xp->xp_context = EXPAND_NOTHING;
9925 return;
9929 /* handle "-=" and "+=" */
9930 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
9932 ++p;
9933 nextchar = '=';
9935 if ((nextchar != '=' && nextchar != ':')
9936 || xp->xp_context == EXPAND_BOOL_SETTINGS)
9938 xp->xp_context = EXPAND_UNSUCCESSFUL;
9939 return;
9941 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
9943 xp->xp_context = EXPAND_OLD_SETTING;
9944 if (is_term_option)
9945 expand_option_idx = -1;
9946 else
9947 expand_option_idx = opt_idx;
9948 xp->xp_pattern = p + 1;
9949 return;
9951 xp->xp_context = EXPAND_NOTHING;
9952 if (is_term_option || (flags & P_NUM))
9953 return;
9955 xp->xp_pattern = p + 1;
9957 if (flags & P_EXPAND)
9959 p = options[opt_idx].var;
9960 if (p == (char_u *)&p_bdir
9961 || p == (char_u *)&p_dir
9962 || p == (char_u *)&p_path
9963 || p == (char_u *)&p_rtp
9964 #ifdef FEAT_SEARCHPATH
9965 || p == (char_u *)&p_cdpath
9966 #endif
9967 #ifdef FEAT_SESSION
9968 || p == (char_u *)&p_vdir
9969 #endif
9972 xp->xp_context = EXPAND_DIRECTORIES;
9973 if (p == (char_u *)&p_path
9974 #ifdef FEAT_SEARCHPATH
9975 || p == (char_u *)&p_cdpath
9976 #endif
9978 xp->xp_backslash = XP_BS_THREE;
9979 else
9980 xp->xp_backslash = XP_BS_ONE;
9982 else
9984 xp->xp_context = EXPAND_FILES;
9985 /* for 'tags' need three backslashes for a space */
9986 if (p == (char_u *)&p_tags)
9987 xp->xp_backslash = XP_BS_THREE;
9988 else
9989 xp->xp_backslash = XP_BS_ONE;
9993 /* For an option that is a list of file names, find the start of the
9994 * last file name. */
9995 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
9997 /* count number of backslashes before ' ' or ',' */
9998 if (*p == ' ' || *p == ',')
10000 s = p;
10001 while (s > xp->xp_pattern && *(s - 1) == '\\')
10002 --s;
10003 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10004 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10006 xp->xp_pattern = p + 1;
10007 break;
10011 #ifdef FEAT_SPELL
10012 /* for 'spellsuggest' start at "file:" */
10013 if (options[opt_idx].var == (char_u *)&p_sps
10014 && STRNCMP(p, "file:", 5) == 0)
10016 xp->xp_pattern = p + 5;
10017 break;
10019 #endif
10022 return;
10026 ExpandSettings(xp, regmatch, num_file, file)
10027 expand_T *xp;
10028 regmatch_T *regmatch;
10029 int *num_file;
10030 char_u ***file;
10032 int num_normal = 0; /* Nr of matching non-term-code settings */
10033 int num_term = 0; /* Nr of matching terminal code settings */
10034 int opt_idx;
10035 int match;
10036 int count = 0;
10037 char_u *str;
10038 int loop;
10039 int is_term_opt;
10040 char_u name_buf[MAX_KEY_NAME_LEN];
10041 static char *(names[]) = {"all", "termcap"};
10042 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10044 /* do this loop twice:
10045 * loop == 0: count the number of matching options
10046 * loop == 1: copy the matching options into allocated memory
10048 for (loop = 0; loop <= 1; ++loop)
10050 regmatch->rm_ic = ic;
10051 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10053 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10054 ++match)
10055 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10057 if (loop == 0)
10058 num_normal++;
10059 else
10060 (*file)[count++] = vim_strsave((char_u *)names[match]);
10063 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10064 opt_idx++)
10066 if (options[opt_idx].var == NULL)
10067 continue;
10068 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10069 && !(options[opt_idx].flags & P_BOOL))
10070 continue;
10071 is_term_opt = istermoption(&options[opt_idx]);
10072 if (is_term_opt && num_normal > 0)
10073 continue;
10074 match = FALSE;
10075 if (vim_regexec(regmatch, str, (colnr_T)0)
10076 || (options[opt_idx].shortname != NULL
10077 && vim_regexec(regmatch,
10078 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10079 match = TRUE;
10080 else if (is_term_opt)
10082 name_buf[0] = '<';
10083 name_buf[1] = 't';
10084 name_buf[2] = '_';
10085 name_buf[3] = str[2];
10086 name_buf[4] = str[3];
10087 name_buf[5] = '>';
10088 name_buf[6] = NUL;
10089 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10091 match = TRUE;
10092 str = name_buf;
10095 if (match)
10097 if (loop == 0)
10099 if (is_term_opt)
10100 num_term++;
10101 else
10102 num_normal++;
10104 else
10105 (*file)[count++] = vim_strsave(str);
10109 * Check terminal key codes, these are not in the option table
10111 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10113 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10115 if (!isprint(str[0]) || !isprint(str[1]))
10116 continue;
10118 name_buf[0] = 't';
10119 name_buf[1] = '_';
10120 name_buf[2] = str[0];
10121 name_buf[3] = str[1];
10122 name_buf[4] = NUL;
10124 match = FALSE;
10125 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10126 match = TRUE;
10127 else
10129 name_buf[0] = '<';
10130 name_buf[1] = 't';
10131 name_buf[2] = '_';
10132 name_buf[3] = str[0];
10133 name_buf[4] = str[1];
10134 name_buf[5] = '>';
10135 name_buf[6] = NUL;
10137 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10138 match = TRUE;
10140 if (match)
10142 if (loop == 0)
10143 num_term++;
10144 else
10145 (*file)[count++] = vim_strsave(name_buf);
10150 * Check special key names.
10152 regmatch->rm_ic = TRUE; /* ignore case here */
10153 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10155 name_buf[0] = '<';
10156 STRCPY(name_buf + 1, str);
10157 STRCAT(name_buf, ">");
10159 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10161 if (loop == 0)
10162 num_term++;
10163 else
10164 (*file)[count++] = vim_strsave(name_buf);
10168 if (loop == 0)
10170 if (num_normal > 0)
10171 *num_file = num_normal;
10172 else if (num_term > 0)
10173 *num_file = num_term;
10174 else
10175 return OK;
10176 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
10177 if (*file == NULL)
10179 *file = (char_u **)"";
10180 return FAIL;
10184 return OK;
10188 ExpandOldSetting(num_file, file)
10189 int *num_file;
10190 char_u ***file;
10192 char_u *var = NULL; /* init for GCC */
10193 char_u *buf;
10195 *num_file = 0;
10196 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
10197 if (*file == NULL)
10198 return FAIL;
10201 * For a terminal key code expand_option_idx is < 0.
10203 if (expand_option_idx < 0)
10205 var = find_termcode(expand_option_name + 2);
10206 if (var == NULL)
10207 expand_option_idx = findoption(expand_option_name);
10210 if (expand_option_idx >= 0)
10212 /* put string of option value in NameBuff */
10213 option_value2string(&options[expand_option_idx], expand_option_flags);
10214 var = NameBuff;
10216 else if (var == NULL)
10217 var = (char_u *)"";
10219 /* A backslash is required before some characters. This is the reverse of
10220 * what happens in do_set(). */
10221 buf = vim_strsave_escaped(var, escape_chars);
10223 if (buf == NULL)
10225 vim_free(*file);
10226 *file = NULL;
10227 return FAIL;
10230 #ifdef BACKSLASH_IN_FILENAME
10231 /* For MS-Windows et al. we don't double backslashes at the start and
10232 * before a file name character. */
10233 for (var = buf; *var != NUL; mb_ptr_adv(var))
10234 if (var[0] == '\\' && var[1] == '\\'
10235 && expand_option_idx >= 0
10236 && (options[expand_option_idx].flags & P_EXPAND)
10237 && vim_isfilec(var[2])
10238 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
10239 STRMOVE(var, var + 1);
10240 #endif
10242 *file[0] = buf;
10243 *num_file = 1;
10244 return OK;
10246 #endif
10249 * Get the value for the numeric or string option *opp in a nice format into
10250 * NameBuff[]. Must not be called with a hidden option!
10252 static void
10253 option_value2string(opp, opt_flags)
10254 struct vimoption *opp;
10255 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10257 char_u *varp;
10259 varp = get_varp_scope(opp, opt_flags);
10261 if (opp->flags & P_NUM)
10263 long wc = 0;
10265 if (wc_use_keyname(varp, &wc))
10266 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
10267 else if (wc != 0)
10268 STRCPY(NameBuff, transchar((int)wc));
10269 else
10270 sprintf((char *)NameBuff, "%ld", *(long *)varp);
10272 else /* P_STRING */
10274 varp = *(char_u **)(varp);
10275 if (varp == NULL) /* just in case */
10276 NameBuff[0] = NUL;
10277 #ifdef FEAT_CRYPT
10278 /* don't show the actual value of 'key', only that it's set */
10279 else if (opp->var == (char_u *)&p_key && *varp)
10280 STRCPY(NameBuff, "*****");
10281 #endif
10282 else if (opp->flags & P_EXPAND)
10283 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
10284 /* Translate 'pastetoggle' into special key names */
10285 else if ((char_u **)opp->var == &p_pt)
10286 str2specialbuf(p_pt, NameBuff, MAXPATHL);
10287 else
10288 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
10293 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
10294 * printed as a keyname.
10295 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
10297 static int
10298 wc_use_keyname(varp, wcp)
10299 char_u *varp;
10300 long *wcp;
10302 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
10304 *wcp = *(long *)varp;
10305 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
10306 return TRUE;
10308 return FALSE;
10311 #ifdef FEAT_LANGMAP
10313 * Any character has an equivalent 'langmap' character. This is used for
10314 * keyboards that have a special language mode that sends characters above
10315 * 128 (although other characters can be translated too). The "to" field is a
10316 * Vim command character. This avoids having to switch the keyboard back to
10317 * ASCII mode when leaving Insert mode.
10319 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
10320 * commands.
10321 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
10322 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
10323 * 256.
10325 # ifdef FEAT_MBYTE
10327 * With multi-byte support use growarray for 'langmap' chars >= 256
10329 typedef struct
10331 int from;
10332 int to;
10333 } langmap_entry_T;
10335 static garray_T langmap_mapga;
10336 static void langmap_set_entry __ARGS((int from, int to));
10339 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
10340 * field. If not found insert a new entry at the appropriate location.
10342 static void
10343 langmap_set_entry(from, to)
10344 int from;
10345 int to;
10347 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
10348 int a = 0;
10349 int b = langmap_mapga.ga_len;
10351 /* Do a binary search for an existing entry. */
10352 while (a != b)
10354 int i = (a + b) / 2;
10355 int d = entries[i].from - from;
10357 if (d == 0)
10359 entries[i].to = to;
10360 return;
10362 if (d < 0)
10363 a = i + 1;
10364 else
10365 b = i;
10368 if (ga_grow(&langmap_mapga, 1) != OK)
10369 return; /* out of memory */
10371 /* insert new entry at position "a" */
10372 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
10373 mch_memmove(entries + 1, entries,
10374 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
10375 ++langmap_mapga.ga_len;
10376 entries[0].from = from;
10377 entries[0].to = to;
10381 * Apply 'langmap' to multi-byte character "c" and return the result.
10384 langmap_adjust_mb(c)
10385 int c;
10387 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
10388 int a = 0;
10389 int b = langmap_mapga.ga_len;
10391 while (a != b)
10393 int i = (a + b) / 2;
10394 int d = entries[i].from - c;
10396 if (d == 0)
10397 return entries[i].to; /* found matching entry */
10398 if (d < 0)
10399 a = i + 1;
10400 else
10401 b = i;
10403 return c; /* no entry found, return "c" unmodified */
10405 # endif
10407 static void
10408 langmap_init()
10410 int i;
10412 for (i = 0; i < 256; i++)
10413 langmap_mapchar[i] = i; /* we init with a one-to-one map */
10414 # ifdef FEAT_MBYTE
10415 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
10416 # endif
10420 * Called when langmap option is set; the language map can be
10421 * changed at any time!
10423 static void
10424 langmap_set()
10426 char_u *p;
10427 char_u *p2;
10428 int from, to;
10430 #ifdef FEAT_MBYTE
10431 ga_clear(&langmap_mapga); /* clear the previous map first */
10432 #endif
10433 langmap_init(); /* back to one-to-one map */
10435 for (p = p_langmap; p[0] != NUL; )
10437 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
10438 mb_ptr_adv(p2))
10440 if (p2[0] == '\\' && p2[1] != NUL)
10441 ++p2;
10443 if (p2[0] == ';')
10444 ++p2; /* abcd;ABCD form, p2 points to A */
10445 else
10446 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
10447 while (p[0])
10449 if (p[0] == '\\' && p[1] != NUL)
10450 ++p;
10451 #ifdef FEAT_MBYTE
10452 from = (*mb_ptr2char)(p);
10453 #else
10454 from = p[0];
10455 #endif
10456 if (p2 == NULL)
10458 mb_ptr_adv(p);
10459 if (p[0] == '\\')
10460 ++p;
10461 #ifdef FEAT_MBYTE
10462 to = (*mb_ptr2char)(p);
10463 #else
10464 to = p[0];
10465 #endif
10467 else
10469 if (p2[0] == '\\')
10470 ++p2;
10471 #ifdef FEAT_MBYTE
10472 to = (*mb_ptr2char)(p2);
10473 #else
10474 to = p2[0];
10475 #endif
10477 if (to == NUL)
10479 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
10480 transchar(from));
10481 return;
10484 #ifdef FEAT_MBYTE
10485 if (from >= 256)
10486 langmap_set_entry(from, to);
10487 else
10488 #endif
10489 langmap_mapchar[from & 255] = to;
10491 /* Advance to next pair */
10492 mb_ptr_adv(p);
10493 if (p2 == NULL)
10495 if (p[0] == ',')
10497 ++p;
10498 break;
10501 else
10503 mb_ptr_adv(p2);
10504 if (*p == ';')
10506 p = p2;
10507 if (p[0] != NUL)
10509 if (p[0] != ',')
10511 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
10512 return;
10514 ++p;
10516 break;
10522 #endif
10525 * Return TRUE if format option 'x' is in effect.
10526 * Take care of no formatting when 'paste' is set.
10529 has_format_option(x)
10530 int x;
10532 if (p_paste)
10533 return FALSE;
10534 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
10538 * Return TRUE if "x" is present in 'shortmess' option, or
10539 * 'shortmess' contains 'a' and "x" is present in SHM_A.
10542 shortmess(x)
10543 int x;
10545 return ( vim_strchr(p_shm, x) != NULL
10546 || (vim_strchr(p_shm, 'a') != NULL
10547 && vim_strchr((char_u *)SHM_A, x) != NULL));
10551 * paste_option_changed() - Called after p_paste was set or reset.
10553 static void
10554 paste_option_changed()
10556 static int old_p_paste = FALSE;
10557 static int save_sm = 0;
10558 #ifdef FEAT_CMDL_INFO
10559 static int save_ru = 0;
10560 #endif
10561 #ifdef FEAT_RIGHTLEFT
10562 static int save_ri = 0;
10563 static int save_hkmap = 0;
10564 #endif
10565 buf_T *buf;
10567 if (p_paste)
10570 * Paste switched from off to on.
10571 * Save the current values, so they can be restored later.
10573 if (!old_p_paste)
10575 /* save options for each buffer */
10576 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10578 buf->b_p_tw_nopaste = buf->b_p_tw;
10579 buf->b_p_wm_nopaste = buf->b_p_wm;
10580 buf->b_p_sts_nopaste = buf->b_p_sts;
10581 buf->b_p_ai_nopaste = buf->b_p_ai;
10584 /* save global options */
10585 save_sm = p_sm;
10586 #ifdef FEAT_CMDL_INFO
10587 save_ru = p_ru;
10588 #endif
10589 #ifdef FEAT_RIGHTLEFT
10590 save_ri = p_ri;
10591 save_hkmap = p_hkmap;
10592 #endif
10593 /* save global values for local buffer options */
10594 p_tw_nopaste = p_tw;
10595 p_wm_nopaste = p_wm;
10596 p_sts_nopaste = p_sts;
10597 p_ai_nopaste = p_ai;
10601 * Always set the option values, also when 'paste' is set when it is
10602 * already on.
10604 /* set options for each buffer */
10605 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10607 buf->b_p_tw = 0; /* textwidth is 0 */
10608 buf->b_p_wm = 0; /* wrapmargin is 0 */
10609 buf->b_p_sts = 0; /* softtabstop is 0 */
10610 buf->b_p_ai = 0; /* no auto-indent */
10613 /* set global options */
10614 p_sm = 0; /* no showmatch */
10615 #ifdef FEAT_CMDL_INFO
10616 # ifdef FEAT_WINDOWS
10617 if (p_ru)
10618 status_redraw_all(); /* redraw to remove the ruler */
10619 # endif
10620 p_ru = 0; /* no ruler */
10621 #endif
10622 #ifdef FEAT_RIGHTLEFT
10623 p_ri = 0; /* no reverse insert */
10624 p_hkmap = 0; /* no Hebrew keyboard */
10625 #endif
10626 /* set global values for local buffer options */
10627 p_tw = 0;
10628 p_wm = 0;
10629 p_sts = 0;
10630 p_ai = 0;
10634 * Paste switched from on to off: Restore saved values.
10636 else if (old_p_paste)
10638 /* restore options for each buffer */
10639 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10641 buf->b_p_tw = buf->b_p_tw_nopaste;
10642 buf->b_p_wm = buf->b_p_wm_nopaste;
10643 buf->b_p_sts = buf->b_p_sts_nopaste;
10644 buf->b_p_ai = buf->b_p_ai_nopaste;
10647 /* restore global options */
10648 p_sm = save_sm;
10649 #ifdef FEAT_CMDL_INFO
10650 # ifdef FEAT_WINDOWS
10651 if (p_ru != save_ru)
10652 status_redraw_all(); /* redraw to draw the ruler */
10653 # endif
10654 p_ru = save_ru;
10655 #endif
10656 #ifdef FEAT_RIGHTLEFT
10657 p_ri = save_ri;
10658 p_hkmap = save_hkmap;
10659 #endif
10660 /* set global values for local buffer options */
10661 p_tw = p_tw_nopaste;
10662 p_wm = p_wm_nopaste;
10663 p_sts = p_sts_nopaste;
10664 p_ai = p_ai_nopaste;
10667 old_p_paste = p_paste;
10671 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
10673 * Reset 'compatible' and set the values for options that didn't get set yet
10674 * to the Vim defaults.
10675 * Don't do this if the 'compatible' option has been set or reset before.
10676 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
10678 void
10679 vimrc_found(fname, envname)
10680 char_u *fname;
10681 char_u *envname;
10683 int opt_idx;
10684 int dofree = FALSE;
10685 char_u *p;
10687 if (!option_was_set((char_u *)"cp"))
10689 p_cp = FALSE;
10690 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
10691 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
10692 set_option_default(opt_idx, OPT_FREE, FALSE);
10693 didset_options();
10696 if (fname != NULL)
10698 p = vim_getenv(envname, &dofree);
10699 if (p == NULL)
10701 /* Set $MYVIMRC to the first vimrc file found. */
10702 p = FullName_save(fname, FALSE);
10703 if (p != NULL)
10705 vim_setenv(envname, p);
10706 vim_free(p);
10709 else if (dofree)
10710 vim_free(p);
10715 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
10717 void
10718 change_compatible(on)
10719 int on;
10721 int opt_idx;
10723 if (p_cp != on)
10725 p_cp = on;
10726 compatible_set();
10728 opt_idx = findoption((char_u *)"cp");
10729 if (opt_idx >= 0)
10730 options[opt_idx].flags |= P_WAS_SET;
10734 * Return TRUE when option "name" has been set.
10737 option_was_set(name)
10738 char_u *name;
10740 int idx;
10742 idx = findoption(name);
10743 if (idx < 0) /* unknown option */
10744 return FALSE;
10745 if (options[idx].flags & P_WAS_SET)
10746 return TRUE;
10747 return FALSE;
10751 * compatible_set() - Called when 'compatible' has been set or unset.
10753 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
10754 * flag) to a Vi compatible value.
10755 * When 'compatible' is unset: Set all options that have a different default
10756 * for Vim (without the P_VI_DEF flag) to that default.
10758 static void
10759 compatible_set()
10761 int opt_idx;
10763 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
10764 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
10765 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
10766 set_option_default(opt_idx, OPT_FREE, p_cp);
10767 didset_options();
10770 #ifdef FEAT_LINEBREAK
10772 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
10773 /* Borland C++ screws up loop optimisation here (negri) */
10774 #pragma option -O-l
10775 # endif
10778 * fill_breakat_flags() -- called when 'breakat' changes value.
10780 static void
10781 fill_breakat_flags()
10783 char_u *p;
10784 int i;
10786 for (i = 0; i < 256; i++)
10787 breakat_flags[i] = FALSE;
10789 if (p_breakat != NULL)
10790 for (p = p_breakat; *p; p++)
10791 breakat_flags[*p] = TRUE;
10794 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
10795 #pragma option -O.l
10796 # endif
10798 #endif
10801 * Check an option that can be a range of string values.
10803 * Return OK for correct value, FAIL otherwise.
10804 * Empty is always OK.
10806 static int
10807 check_opt_strings(val, values, list)
10808 char_u *val;
10809 char **values;
10810 int list; /* when TRUE: accept a list of values */
10812 return opt_strings_flags(val, values, NULL, list);
10816 * Handle an option that can be a range of string values.
10817 * Set a flag in "*flagp" for each string present.
10819 * Return OK for correct value, FAIL otherwise.
10820 * Empty is always OK.
10822 static int
10823 opt_strings_flags(val, values, flagp, list)
10824 char_u *val; /* new value */
10825 char **values; /* array of valid string values */
10826 unsigned *flagp;
10827 int list; /* when TRUE: accept a list of values */
10829 int i;
10830 int len;
10831 unsigned new_flags = 0;
10833 while (*val)
10835 for (i = 0; ; ++i)
10837 if (values[i] == NULL) /* val not found in values[] */
10838 return FAIL;
10840 len = (int)STRLEN(values[i]);
10841 if (STRNCMP(values[i], val, len) == 0
10842 && ((list && val[len] == ',') || val[len] == NUL))
10844 val += len + (val[len] == ',');
10845 new_flags |= (1 << i);
10846 break; /* check next item in val list */
10850 if (flagp != NULL)
10851 *flagp = new_flags;
10853 return OK;
10857 * Read the 'wildmode' option, fill wim_flags[].
10859 static int
10860 check_opt_wim()
10862 char_u new_wim_flags[4];
10863 char_u *p;
10864 int i;
10865 int idx = 0;
10867 for (i = 0; i < 4; ++i)
10868 new_wim_flags[i] = 0;
10870 for (p = p_wim; *p; ++p)
10872 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
10874 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
10875 return FAIL;
10876 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
10877 new_wim_flags[idx] |= WIM_LONGEST;
10878 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
10879 new_wim_flags[idx] |= WIM_FULL;
10880 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
10881 new_wim_flags[idx] |= WIM_LIST;
10882 else
10883 return FAIL;
10884 p += i;
10885 if (*p == NUL)
10886 break;
10887 if (*p == ',')
10889 if (idx == 3)
10890 return FAIL;
10891 ++idx;
10895 /* fill remaining entries with last flag */
10896 while (idx < 3)
10898 new_wim_flags[idx + 1] = new_wim_flags[idx];
10899 ++idx;
10902 /* only when there are no errors, wim_flags[] is changed */
10903 for (i = 0; i < 4; ++i)
10904 wim_flags[i] = new_wim_flags[i];
10905 return OK;
10909 * Check if backspacing over something is allowed.
10912 can_bs(what)
10913 int what; /* BS_INDENT, BS_EOL or BS_START */
10915 switch (*p_bs)
10917 case '2': return TRUE;
10918 case '1': return (what != BS_START);
10919 case '0': return FALSE;
10921 return vim_strchr(p_bs, what) != NULL;
10925 * Save the current values of 'fileformat' and 'fileencoding', so that we know
10926 * the file must be considered changed when the value is different.
10928 void
10929 save_file_ff(buf)
10930 buf_T *buf;
10932 buf->b_start_ffc = *buf->b_p_ff;
10933 buf->b_start_eol = buf->b_p_eol;
10934 #ifdef FEAT_MBYTE
10935 buf->b_start_bomb = buf->b_p_bomb;
10937 /* Only use free/alloc when necessary, they take time. */
10938 if (buf->b_start_fenc == NULL
10939 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
10941 vim_free(buf->b_start_fenc);
10942 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
10944 #endif
10948 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
10949 * from when editing started (save_file_ff() called).
10950 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
10951 * changed and 'binary' is not set.
10952 * Don't consider a new, empty buffer to be changed.
10955 file_ff_differs(buf)
10956 buf_T *buf;
10958 /* In a buffer that was never loaded the options are not valid. */
10959 if (buf->b_flags & BF_NEVERLOADED)
10960 return FALSE;
10961 if ((buf->b_flags & BF_NEW)
10962 && buf->b_ml.ml_line_count == 1
10963 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
10964 return FALSE;
10965 if (buf->b_start_ffc != *buf->b_p_ff)
10966 return TRUE;
10967 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
10968 return TRUE;
10969 #ifdef FEAT_MBYTE
10970 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
10971 return TRUE;
10972 if (buf->b_start_fenc == NULL)
10973 return (*buf->b_p_fenc != NUL);
10974 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
10975 #else
10976 return FALSE;
10977 #endif
10981 * return OK if "p" is a valid fileformat name, FAIL otherwise.
10984 check_ff_value(p)
10985 char_u *p;
10987 return check_opt_strings(p, p_ff_values, FALSE);