vim72-20100325-kaoriya-w64j.zip
[MacVim/KaoriYa.git] / src / option.c
blob0d1bd8b22f77389f99083ad659e0200c02afdfb2
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 #ifdef USE_MIGEMO
139 # define PV_MIG OPT_BUF(BV_MIG)
140 #endif
141 #define PV_ML OPT_BUF(BV_ML)
142 #define PV_MOD OPT_BUF(BV_MOD)
143 #define PV_MPS OPT_BUF(BV_MPS)
144 #define PV_NF OPT_BUF(BV_NF)
145 #ifdef FEAT_OSFILETYPE
146 # define PV_OFT OPT_BUF(BV_OFT)
147 #endif
148 #ifdef FEAT_COMPL_FUNC
149 # define PV_OFU OPT_BUF(BV_OFU)
150 #endif
151 #define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
152 #define PV_PI OPT_BUF(BV_PI)
153 #ifdef FEAT_TEXTOBJ
154 # define PV_QE OPT_BUF(BV_QE)
155 #endif
156 #define PV_RO OPT_BUF(BV_RO)
157 #ifdef FEAT_SMARTINDENT
158 # define PV_SI OPT_BUF(BV_SI)
159 #endif
160 #ifndef SHORT_FNAME
161 # define PV_SN OPT_BUF(BV_SN)
162 #endif
163 #ifdef FEAT_SYN_HL
164 # define PV_SMC OPT_BUF(BV_SMC)
165 # define PV_SYN OPT_BUF(BV_SYN)
166 #endif
167 #ifdef FEAT_SPELL
168 # define PV_SPC OPT_BUF(BV_SPC)
169 # define PV_SPF OPT_BUF(BV_SPF)
170 # define PV_SPL OPT_BUF(BV_SPL)
171 #endif
172 #define PV_STS OPT_BUF(BV_STS)
173 #ifdef FEAT_SEARCHPATH
174 # define PV_SUA OPT_BUF(BV_SUA)
175 #endif
176 #define PV_SW OPT_BUF(BV_SW)
177 #define PV_SWF OPT_BUF(BV_SWF)
178 #define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
179 #define PV_TS OPT_BUF(BV_TS)
180 #define PV_TW OPT_BUF(BV_TW)
181 #define PV_TX OPT_BUF(BV_TX)
182 #define PV_WM OPT_BUF(BV_WM)
185 * Definition of the PV_ values for window-local options.
186 * The WV_ values are defined in option.h.
188 #define PV_LIST OPT_WIN(WV_LIST)
189 #ifdef FEAT_ARABIC
190 # define PV_ARAB OPT_WIN(WV_ARAB)
191 #endif
192 #ifdef FEAT_DIFF
193 # define PV_DIFF OPT_WIN(WV_DIFF)
194 #endif
195 #ifdef FEAT_FOLDING
196 # define PV_FDC OPT_WIN(WV_FDC)
197 # define PV_FEN OPT_WIN(WV_FEN)
198 # define PV_FDI OPT_WIN(WV_FDI)
199 # define PV_FDL OPT_WIN(WV_FDL)
200 # define PV_FDM OPT_WIN(WV_FDM)
201 # define PV_FML OPT_WIN(WV_FML)
202 # define PV_FDN OPT_WIN(WV_FDN)
203 # ifdef FEAT_EVAL
204 # define PV_FDE OPT_WIN(WV_FDE)
205 # define PV_FDT OPT_WIN(WV_FDT)
206 # endif
207 # define PV_FMR OPT_WIN(WV_FMR)
208 #endif
209 #ifdef FEAT_LINEBREAK
210 # define PV_LBR OPT_WIN(WV_LBR)
211 #endif
212 #define PV_NU OPT_WIN(WV_NU)
213 #ifdef FEAT_LINEBREAK
214 # define PV_NUW OPT_WIN(WV_NUW)
215 #endif
216 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
217 # define PV_PVW OPT_WIN(WV_PVW)
218 #endif
219 #ifdef FEAT_RIGHTLEFT
220 # define PV_RL OPT_WIN(WV_RL)
221 # define PV_RLC OPT_WIN(WV_RLC)
222 #endif
223 #ifdef FEAT_SCROLLBIND
224 # define PV_SCBIND OPT_WIN(WV_SCBIND)
225 #endif
226 #define PV_SCROLL OPT_WIN(WV_SCROLL)
227 #ifdef FEAT_SPELL
228 # define PV_SPELL OPT_WIN(WV_SPELL)
229 #endif
230 #ifdef FEAT_SYN_HL
231 # define PV_CUC OPT_WIN(WV_CUC)
232 # define PV_CUL OPT_WIN(WV_CUL)
233 #endif
234 #ifdef FEAT_STL_OPT
235 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
236 #endif
237 #ifdef FEAT_WINDOWS
238 # define PV_WFH OPT_WIN(WV_WFH)
239 #endif
240 #ifdef FEAT_VERTSPLIT
241 # define PV_WFW OPT_WIN(WV_WFW)
242 #endif
243 #define PV_WRAP OPT_WIN(WV_WRAP)
246 /* WV_ and BV_ values get typecasted to this for the "indir" field */
247 typedef enum
249 PV_NONE = 0,
250 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
251 } idopt_T;
254 * Options local to a window have a value local to a buffer and global to all
255 * buffers. Indicate this by setting "var" to VAR_WIN.
257 #define VAR_WIN ((char_u *)-1)
260 * These are the global values for options which are also local to a buffer.
261 * Only to be used in option.c!
263 static int p_ai;
264 static int p_bin;
265 #ifdef FEAT_MBYTE
266 static int p_bomb;
267 #endif
268 #if defined(FEAT_QUICKFIX)
269 static char_u *p_bh;
270 static char_u *p_bt;
271 #endif
272 static int p_bl;
273 static int p_ci;
274 #ifdef FEAT_CINDENT
275 static int p_cin;
276 static char_u *p_cink;
277 static char_u *p_cino;
278 #endif
279 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
280 static char_u *p_cinw;
281 #endif
282 #ifdef FEAT_COMMENTS
283 static char_u *p_com;
284 #endif
285 #ifdef FEAT_FOLDING
286 static char_u *p_cms;
287 #endif
288 #ifdef FEAT_INS_EXPAND
289 static char_u *p_cpt;
290 #endif
291 #ifdef FEAT_COMPL_FUNC
292 static char_u *p_cfu;
293 static char_u *p_ofu;
294 #endif
295 static int p_eol;
296 static int p_et;
297 #ifdef FEAT_MBYTE
298 static char_u *p_fenc;
299 #endif
300 static char_u *p_ff;
301 static char_u *p_fo;
302 static char_u *p_flp;
303 #ifdef FEAT_AUTOCMD
304 static char_u *p_ft;
305 #endif
306 static long p_iminsert;
307 static long p_imsearch;
308 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
309 static char_u *p_inex;
310 #endif
311 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
312 static char_u *p_inde;
313 static char_u *p_indk;
314 #endif
315 #if defined(FEAT_EVAL)
316 static char_u *p_fex;
317 #endif
318 static int p_inf;
319 static char_u *p_isk;
320 #ifdef FEAT_CRYPT
321 static char_u *p_key;
322 #endif
323 #ifdef FEAT_LISP
324 static int p_lisp;
325 #endif
326 static int p_ml;
327 static int p_ma;
328 static int p_mod;
329 static char_u *p_mps;
330 static char_u *p_nf;
331 #ifdef FEAT_OSFILETYPE
332 static char_u *p_oft;
333 #endif
334 static int p_pi;
335 #ifdef FEAT_TEXTOBJ
336 static char_u *p_qe;
337 #endif
338 static int p_ro;
339 #ifdef FEAT_SMARTINDENT
340 static int p_si;
341 #endif
342 #ifndef SHORT_FNAME
343 static int p_sn;
344 #endif
345 static long p_sts;
346 #if defined(FEAT_SEARCHPATH)
347 static char_u *p_sua;
348 #endif
349 static long p_sw;
350 static int p_swf;
351 #ifdef FEAT_SYN_HL
352 static long p_smc;
353 static char_u *p_syn;
354 #endif
355 #ifdef FEAT_SPELL
356 static char_u *p_spc;
357 static char_u *p_spf;
358 static char_u *p_spl;
359 #endif
360 static long p_ts;
361 static long p_tw;
362 static int p_tx;
363 static long p_wm;
364 #ifdef FEAT_KEYMAP
365 static char_u *p_keymap;
366 #endif
368 /* Saved values for when 'bin' is set. */
369 static int p_et_nobin;
370 static int p_ml_nobin;
371 static long p_tw_nobin;
372 static long p_wm_nobin;
374 /* Saved values for when 'paste' is set */
375 static long p_tw_nopaste;
376 static long p_wm_nopaste;
377 static long p_sts_nopaste;
378 static int p_ai_nopaste;
380 struct vimoption
382 char *fullname; /* full option name */
383 char *shortname; /* permissible abbreviation */
384 long_u flags; /* see below */
385 char_u *var; /* global option: pointer to variable;
386 * window-local option: VAR_WIN;
387 * buffer-local option: global value */
388 idopt_T indir; /* global option: PV_NONE;
389 * local option: indirect option index */
390 char_u *def_val[2]; /* default values for variable (vi and vim) */
391 #ifdef FEAT_EVAL
392 scid_T scriptID; /* script in which the option was last set */
393 # define SCRIPTID_INIT , 0
394 #else
395 # define SCRIPTID_INIT
396 #endif
399 #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
400 #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
403 * Flags
405 #define P_BOOL 0x01 /* the option is boolean */
406 #define P_NUM 0x02 /* the option is numeric */
407 #define P_STRING 0x04 /* the option is a string */
408 #define P_ALLOCED 0x08 /* the string option is in allocated memory,
409 must use free_string_option() when
410 assigning new value. Not set if default is
411 the same. */
412 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
413 never be used for local or hidden options! */
414 #define P_NODEFAULT 0x40 /* don't set to default value */
415 #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
416 use vim_free() when assigning new value */
417 #define P_WAS_SET 0x100 /* option has been set/reset */
418 #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
419 #define P_VI_DEF 0x400 /* Use Vi default for Vim */
420 #define P_VIM 0x800 /* Vim option, reset when 'cp' set */
422 /* when option changed, what to display: */
423 #define P_RSTAT 0x1000 /* redraw status lines */
424 #define P_RWIN 0x2000 /* redraw current window */
425 #define P_RBUF 0x4000 /* redraw current buffer */
426 #define P_RALL 0x6000 /* redraw all windows */
427 #define P_RCLR 0x7000 /* clear and redraw all */
429 #define P_COMMA 0x8000 /* comma separated list */
430 #define P_NODUP 0x10000L/* don't allow duplicate strings */
431 #define P_FLAGLIST 0x20000L/* list of single-char flags */
433 #define P_SECURE 0x40000L/* cannot change in modeline or secure mode */
434 #define P_GETTEXT 0x80000L/* expand default value with _() */
435 #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */
436 #define P_NFNAME 0x200000L/* only normal file name chars allowed */
437 #define P_INSECURE 0x400000L/* option was set from a modeline */
438 #define P_PRI_MKRC 0x800000L/* priority for :mkvimrc (setting option has
439 side effects) */
441 #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
443 /* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
444 * for the currency sign. */
445 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
446 # define ISP_LATIN1 (char_u *)"@,~-255"
447 #else
448 # define ISP_LATIN1 (char_u *)"@,161-255"
449 #endif
451 /* The 16 bit MS-DOS version is low on space, make the string as short as
452 * possible when compiling with few features. */
453 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
454 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
455 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL)
456 # 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"
457 #else
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,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
459 #endif
462 * options[] is initialized here.
463 * The order of the options MUST be alphabetic for ":set all" and findoption().
464 * All option names MUST start with a lowercase letter (for findoption()).
465 * Exception: "t_" options are at the end.
466 * The options with a NULL variable are 'hidden': a set command for them is
467 * ignored and they are not printed.
469 static struct vimoption
470 #ifdef FEAT_GUI_W16
471 _far
472 #endif
473 options[] =
475 {"aleph", "al", P_NUM|P_VI_DEF,
476 #ifdef FEAT_RIGHTLEFT
477 (char_u *)&p_aleph, PV_NONE,
478 #else
479 (char_u *)NULL, PV_NONE,
480 #endif
482 #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
483 (char_u *)128L,
484 #else
485 (char_u *)224L,
486 #endif
487 (char_u *)0L} SCRIPTID_INIT},
488 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
489 #if defined(FEAT_GUI) && defined(MACOS_X)
490 (char_u *)&p_antialias, PV_NONE,
491 {(char_u *)FALSE, (char_u *)FALSE}
492 #else
493 (char_u *)NULL, PV_NONE,
494 {(char_u *)FALSE, (char_u *)FALSE}
495 #endif
496 SCRIPTID_INIT},
497 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
498 #ifdef FEAT_ARABIC
499 (char_u *)VAR_WIN, PV_ARAB,
500 #else
501 (char_u *)NULL, PV_NONE,
502 #endif
503 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
504 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
505 #ifdef FEAT_ARABIC
506 (char_u *)&p_arshape, PV_NONE,
507 #else
508 (char_u *)NULL, PV_NONE,
509 #endif
510 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
511 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
512 #ifdef FEAT_RIGHTLEFT
513 (char_u *)&p_ari, PV_NONE,
514 #else
515 (char_u *)NULL, PV_NONE,
516 #endif
517 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
518 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
519 #ifdef FEAT_FKMAP
520 (char_u *)&p_altkeymap, PV_NONE,
521 #else
522 (char_u *)NULL, PV_NONE,
523 #endif
524 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
525 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
526 #if defined(FEAT_MBYTE)
527 (char_u *)&p_ambw, PV_NONE,
528 {(char_u *)"single", (char_u *)0L}
529 #else
530 (char_u *)NULL, PV_NONE,
531 {(char_u *)0L, (char_u *)0L}
532 #endif
533 SCRIPTID_INIT},
534 #ifdef FEAT_AUTOCHDIR
535 {"autochdir", "acd", P_BOOL|P_VI_DEF,
536 (char_u *)&p_acd, PV_NONE,
537 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
538 #endif
539 {"autoindent", "ai", P_BOOL|P_VI_DEF,
540 (char_u *)&p_ai, PV_AI,
541 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
542 {"autoprint", "ap", P_BOOL|P_VI_DEF,
543 (char_u *)NULL, PV_NONE,
544 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
545 {"autoread", "ar", P_BOOL|P_VI_DEF,
546 (char_u *)&p_ar, PV_AR,
547 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
548 {"autowrite", "aw", P_BOOL|P_VI_DEF,
549 (char_u *)&p_aw, PV_NONE,
550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
551 {"autowriteall","awa", P_BOOL|P_VI_DEF,
552 (char_u *)&p_awa, PV_NONE,
553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
554 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
555 (char_u *)&p_bg, PV_NONE,
557 #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
558 (char_u *)"dark",
559 #else
560 (char_u *)"light",
561 #endif
562 (char_u *)0L} SCRIPTID_INIT},
563 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
564 (char_u *)&p_bs, PV_NONE,
565 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
566 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
567 (char_u *)&p_bk, PV_NONE,
568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
569 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
570 (char_u *)&p_bkc, PV_NONE,
571 #ifdef UNIX
572 {(char_u *)"yes", (char_u *)"auto"}
573 #else
574 {(char_u *)"auto", (char_u *)"auto"}
575 #endif
576 SCRIPTID_INIT},
577 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
578 (char_u *)&p_bdir, PV_NONE,
579 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
580 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
581 (char_u *)&p_bex, PV_NONE,
583 #ifdef VMS
584 (char_u *)"_",
585 #else
586 (char_u *)"~",
587 #endif
588 (char_u *)0L} SCRIPTID_INIT},
589 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
590 #ifdef FEAT_WILDIGN
591 (char_u *)&p_bsk, PV_NONE,
592 {(char_u *)"", (char_u *)0L}
593 #else
594 (char_u *)NULL, PV_NONE,
595 {(char_u *)0L, (char_u *)0L}
596 #endif
597 SCRIPTID_INIT},
598 #ifdef FEAT_BEVAL
599 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
600 (char_u *)&p_bdlay, PV_NONE,
601 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
602 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
603 (char_u *)&p_beval, PV_NONE,
604 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
605 # ifdef FEAT_EVAL
606 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
607 (char_u *)&p_bexpr, PV_BEXPR,
608 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
609 # endif
610 #endif
611 {"beautify", "bf", P_BOOL|P_VI_DEF,
612 (char_u *)NULL, PV_NONE,
613 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
614 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
615 (char_u *)&p_bin, PV_BIN,
616 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
617 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
618 #ifdef MSDOS
619 (char_u *)&p_biosk, PV_NONE,
620 #else
621 (char_u *)NULL, PV_NONE,
622 #endif
623 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
624 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
625 #ifdef FEAT_MBYTE
626 (char_u *)&p_bomb, PV_BOMB,
627 #else
628 (char_u *)NULL, PV_NONE,
629 #endif
630 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
631 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
632 #ifdef FEAT_LINEBREAK
633 (char_u *)&p_breakat, PV_NONE,
634 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
635 #else
636 (char_u *)NULL, PV_NONE,
637 {(char_u *)0L, (char_u *)0L}
638 #endif
639 SCRIPTID_INIT},
640 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
641 #ifdef FEAT_BROWSE
642 (char_u *)&p_bsdir, PV_NONE,
643 {(char_u *)"last", (char_u *)0L}
644 #else
645 (char_u *)NULL, PV_NONE,
646 {(char_u *)0L, (char_u *)0L}
647 #endif
648 SCRIPTID_INIT},
649 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
650 #if defined(FEAT_QUICKFIX)
651 (char_u *)&p_bh, PV_BH,
652 {(char_u *)"", (char_u *)0L}
653 #else
654 (char_u *)NULL, PV_NONE,
655 {(char_u *)0L, (char_u *)0L}
656 #endif
657 SCRIPTID_INIT},
658 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
659 (char_u *)&p_bl, PV_BL,
660 {(char_u *)1L, (char_u *)0L}
661 SCRIPTID_INIT},
662 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
663 #if defined(FEAT_QUICKFIX)
664 (char_u *)&p_bt, PV_BT,
665 {(char_u *)"", (char_u *)0L}
666 #else
667 (char_u *)NULL, PV_NONE,
668 {(char_u *)0L, (char_u *)0L}
669 #endif
670 SCRIPTID_INIT},
671 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
672 #ifdef FEAT_MBYTE
673 (char_u *)&p_cmp, PV_NONE,
674 {(char_u *)"internal,keepascii", (char_u *)0L}
675 #else
676 (char_u *)NULL, PV_NONE,
677 {(char_u *)0L, (char_u *)0L}
678 #endif
679 SCRIPTID_INIT},
680 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
681 #ifdef FEAT_SEARCHPATH
682 (char_u *)&p_cdpath, PV_NONE,
683 {(char_u *)",,", (char_u *)0L}
684 #else
685 (char_u *)NULL, PV_NONE,
686 {(char_u *)0L, (char_u *)0L}
687 #endif
688 SCRIPTID_INIT},
689 {"cedit", NULL, P_STRING,
690 #ifdef FEAT_CMDWIN
691 (char_u *)&p_cedit, PV_NONE,
692 {(char_u *)"", (char_u *)CTRL_F_STR}
693 #else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696 #endif
697 SCRIPTID_INIT},
698 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
699 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
700 (char_u *)&p_ccv, PV_NONE,
701 {(char_u *)"", (char_u *)0L}
702 #else
703 (char_u *)NULL, PV_NONE,
704 {(char_u *)0L, (char_u *)0L}
705 #endif
706 SCRIPTID_INIT},
707 {"charspace", "csp", P_NUM|P_NODEFAULT|P_VIM|P_RCLR,
708 #ifdef FEAT_GUI
709 (char_u *)&p_charspace, PV_NONE,
710 #else
711 (char_u *)NULL, PV_NONE,
712 #endif
713 {(char_u *)0L, (char_u *)0L}
714 SCRIPTID_INIT},
715 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
716 #ifdef FEAT_CINDENT
717 (char_u *)&p_cin, PV_CIN,
718 #else
719 (char_u *)NULL, PV_NONE,
720 #endif
721 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
722 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
723 #ifdef FEAT_CINDENT
724 (char_u *)&p_cink, PV_CINK,
725 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
726 #else
727 (char_u *)NULL, PV_NONE,
728 {(char_u *)0L, (char_u *)0L}
729 #endif
730 SCRIPTID_INIT},
731 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
732 #ifdef FEAT_CINDENT
733 (char_u *)&p_cino, PV_CINO,
734 #else
735 (char_u *)NULL, PV_NONE,
736 #endif
737 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
738 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
739 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
740 (char_u *)&p_cinw, PV_CINW,
741 {(char_u *)"if,else,while,do,for,switch",
742 (char_u *)0L}
743 #else
744 (char_u *)NULL, PV_NONE,
745 {(char_u *)0L, (char_u *)0L}
746 #endif
747 SCRIPTID_INIT},
748 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
749 #ifdef FEAT_CLIPBOARD
750 (char_u *)&p_cb, PV_NONE,
751 # ifdef FEAT_XCLIPBOARD
752 {(char_u *)"autoselect,exclude:cons\\|linux",
753 (char_u *)0L}
754 # else
755 {(char_u *)"", (char_u *)0L}
756 # endif
757 #else
758 (char_u *)NULL, PV_NONE,
759 {(char_u *)"", (char_u *)0L}
760 #endif
761 SCRIPTID_INIT},
762 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
763 (char_u *)&p_ch, PV_NONE,
764 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
765 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
766 #ifdef FEAT_CMDWIN
767 (char_u *)&p_cwh, PV_NONE,
768 #else
769 (char_u *)NULL, PV_NONE,
770 #endif
771 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
772 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
773 (char_u *)&Columns, PV_NONE,
774 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
775 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
776 #ifdef FEAT_COMMENTS
777 (char_u *)&p_com, PV_COM,
778 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
779 (char_u *)0L}
780 #else
781 (char_u *)NULL, PV_NONE,
782 {(char_u *)0L, (char_u *)0L}
783 #endif
784 SCRIPTID_INIT},
785 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
786 #ifdef FEAT_FOLDING
787 (char_u *)&p_cms, PV_CMS,
788 {(char_u *)"/*%s*/", (char_u *)0L}
789 #else
790 (char_u *)NULL, PV_NONE,
791 {(char_u *)0L, (char_u *)0L}
792 #endif
793 SCRIPTID_INIT},
794 /* P_PRI_MKRC isn't needed here, optval_default()
795 * always returns TRUE for 'compatible' */
796 {"compatible", "cp", P_BOOL|P_RALL,
797 (char_u *)&p_cp, PV_NONE,
798 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
799 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
800 #ifdef FEAT_INS_EXPAND
801 (char_u *)&p_cpt, PV_CPT,
802 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
803 #else
804 (char_u *)NULL, PV_NONE,
805 {(char_u *)0L, (char_u *)0L}
806 #endif
807 SCRIPTID_INIT},
808 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
809 #ifdef FEAT_COMPL_FUNC
810 (char_u *)&p_cfu, PV_CFU,
811 {(char_u *)"", (char_u *)0L}
812 #else
813 (char_u *)NULL, PV_NONE,
814 {(char_u *)0L, (char_u *)0L}
815 #endif
816 SCRIPTID_INIT},
817 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
818 #ifdef FEAT_INS_EXPAND
819 (char_u *)&p_cot, PV_NONE,
820 {(char_u *)"menu,preview", (char_u *)0L}
821 #else
822 (char_u *)NULL, PV_NONE,
823 {(char_u *)0L, (char_u *)0L}
824 #endif
825 SCRIPTID_INIT},
826 {"confirm", "cf", P_BOOL|P_VI_DEF,
827 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
828 (char_u *)&p_confirm, PV_NONE,
829 #else
830 (char_u *)NULL, PV_NONE,
831 #endif
832 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
833 {"conskey", "consk",P_BOOL|P_VI_DEF,
834 #ifdef MSDOS
835 (char_u *)&p_consk, PV_NONE,
836 #else
837 (char_u *)NULL, PV_NONE,
838 #endif
839 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
840 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
841 (char_u *)&p_ci, PV_CI,
842 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
843 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
844 (char_u *)&p_cpo, PV_NONE,
845 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
846 SCRIPTID_INIT},
847 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
848 #ifdef FEAT_CSCOPE
849 (char_u *)&p_cspc, PV_NONE,
850 #else
851 (char_u *)NULL, PV_NONE,
852 #endif
853 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
854 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
855 #ifdef FEAT_CSCOPE
856 (char_u *)&p_csprg, PV_NONE,
857 {(char_u *)"cscope", (char_u *)0L}
858 #else
859 (char_u *)NULL, PV_NONE,
860 {(char_u *)0L, (char_u *)0L}
861 #endif
862 SCRIPTID_INIT},
863 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
864 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
865 (char_u *)&p_csqf, PV_NONE,
866 {(char_u *)"", (char_u *)0L}
867 #else
868 (char_u *)NULL, PV_NONE,
869 {(char_u *)0L, (char_u *)0L}
870 #endif
871 SCRIPTID_INIT},
872 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
873 #ifdef FEAT_CSCOPE
874 (char_u *)&p_cst, PV_NONE,
875 #else
876 (char_u *)NULL, PV_NONE,
877 #endif
878 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
879 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
880 #ifdef FEAT_CSCOPE
881 (char_u *)&p_csto, PV_NONE,
882 #else
883 (char_u *)NULL, PV_NONE,
884 #endif
885 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
886 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
887 #ifdef FEAT_CSCOPE
888 (char_u *)&p_csverbose, PV_NONE,
889 #else
890 (char_u *)NULL, PV_NONE,
891 #endif
892 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
893 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
894 #ifdef FEAT_SYN_HL
895 (char_u *)VAR_WIN, PV_CUC,
896 #else
897 (char_u *)NULL, PV_NONE,
898 #endif
899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
900 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
901 #ifdef FEAT_SYN_HL
902 (char_u *)VAR_WIN, PV_CUL,
903 #else
904 (char_u *)NULL, PV_NONE,
905 #endif
906 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
907 {"debug", NULL, P_STRING|P_VI_DEF,
908 (char_u *)&p_debug, PV_NONE,
909 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
910 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF,
911 #ifdef FEAT_FIND_ID
912 (char_u *)&p_def, PV_DEF,
913 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
914 #else
915 (char_u *)NULL, PV_NONE,
916 {(char_u *)NULL, (char_u *)0L}
917 #endif
918 SCRIPTID_INIT},
919 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
920 #ifdef FEAT_MBYTE
921 (char_u *)&p_deco, PV_NONE,
922 #else
923 (char_u *)NULL, PV_NONE,
924 #endif
925 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
926 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
927 #ifdef FEAT_INS_EXPAND
928 (char_u *)&p_dict, PV_DICT,
929 #else
930 (char_u *)NULL, PV_NONE,
931 #endif
932 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
933 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
934 #ifdef FEAT_DIFF
935 (char_u *)VAR_WIN, PV_DIFF,
936 #else
937 (char_u *)NULL, PV_NONE,
938 #endif
939 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
940 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE,
941 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
942 (char_u *)&p_dex, PV_NONE,
943 {(char_u *)"", (char_u *)0L}
944 #else
945 (char_u *)NULL, PV_NONE,
946 {(char_u *)0L, (char_u *)0L}
947 #endif
948 SCRIPTID_INIT},
949 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
950 #ifdef FEAT_DIFF
951 (char_u *)&p_dip, PV_NONE,
952 {(char_u *)"filler", (char_u *)NULL}
953 #else
954 (char_u *)NULL, PV_NONE,
955 {(char_u *)"", (char_u *)NULL}
956 #endif
957 SCRIPTID_INIT},
958 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
959 #ifdef FEAT_DIGRAPHS
960 (char_u *)&p_dg, PV_NONE,
961 #else
962 (char_u *)NULL, PV_NONE,
963 #endif
964 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
965 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
966 (char_u *)&p_dir, PV_NONE,
967 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
968 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
969 (char_u *)&p_dy, PV_NONE,
970 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
971 {"eadirection", "ead", P_STRING|P_VI_DEF,
972 #ifdef FEAT_VERTSPLIT
973 (char_u *)&p_ead, PV_NONE,
974 {(char_u *)"both", (char_u *)0L}
975 #else
976 (char_u *)NULL, PV_NONE,
977 {(char_u *)NULL, (char_u *)0L}
978 #endif
979 SCRIPTID_INIT},
980 {"edcompatible","ed", P_BOOL|P_VI_DEF,
981 (char_u *)&p_ed, PV_NONE,
982 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
983 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR,
984 #ifdef FEAT_MBYTE
985 (char_u *)&p_enc, PV_NONE,
986 {(char_u *)ENC_DFLT, (char_u *)0L}
987 #else
988 (char_u *)NULL, PV_NONE,
989 {(char_u *)0L, (char_u *)0L}
990 #endif
991 SCRIPTID_INIT},
992 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
993 (char_u *)&p_eol, PV_EOL,
994 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
995 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
996 (char_u *)&p_ea, PV_NONE,
997 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
998 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
999 (char_u *)&p_ep, PV_EP,
1000 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1001 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1002 (char_u *)&p_eb, PV_NONE,
1003 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1004 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1005 #ifdef FEAT_QUICKFIX
1006 (char_u *)&p_ef, PV_NONE,
1007 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1008 #else
1009 (char_u *)NULL, PV_NONE,
1010 {(char_u *)NULL, (char_u *)0L}
1011 #endif
1012 SCRIPTID_INIT},
1013 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1014 #ifdef FEAT_QUICKFIX
1015 (char_u *)&p_efm, PV_EFM,
1016 {(char_u *)DFLT_EFM, (char_u *)0L}
1017 #else
1018 (char_u *)NULL, PV_NONE,
1019 {(char_u *)NULL, (char_u *)0L}
1020 #endif
1021 SCRIPTID_INIT},
1022 {"esckeys", "ek", P_BOOL|P_VIM,
1023 (char_u *)&p_ek, PV_NONE,
1024 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
1025 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1026 #ifdef FEAT_AUTOCMD
1027 (char_u *)&p_ei, PV_NONE,
1028 #else
1029 (char_u *)NULL, PV_NONE,
1030 #endif
1031 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1032 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1033 (char_u *)&p_et, PV_ET,
1034 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1035 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1036 (char_u *)&p_exrc, PV_NONE,
1037 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1038 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
1039 #ifdef FEAT_MBYTE
1040 (char_u *)&p_fenc, PV_FENC,
1041 {(char_u *)"", (char_u *)0L}
1042 #else
1043 (char_u *)NULL, PV_NONE,
1044 {(char_u *)0L, (char_u *)0L}
1045 #endif
1046 SCRIPTID_INIT},
1047 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
1048 #ifdef FEAT_MBYTE
1049 (char_u *)&p_fencs, PV_NONE,
1050 {(char_u *)"ucs-bom", (char_u *)0L}
1051 #else
1052 (char_u *)NULL, PV_NONE,
1053 {(char_u *)0L, (char_u *)0L}
1054 #endif
1055 SCRIPTID_INIT},
1056 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC,
1057 (char_u *)&p_ff, PV_FF,
1058 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
1059 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
1060 (char_u *)&p_ffs, PV_NONE,
1061 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1062 SCRIPTID_INIT},
1063 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
1064 #ifdef FEAT_AUTOCMD
1065 (char_u *)&p_ft, PV_FT,
1066 {(char_u *)"", (char_u *)0L}
1067 #else
1068 (char_u *)NULL, PV_NONE,
1069 {(char_u *)0L, (char_u *)0L}
1070 #endif
1071 SCRIPTID_INIT},
1072 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1073 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1074 (char_u *)&p_fcs, PV_NONE,
1075 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1076 #else
1077 (char_u *)NULL, PV_NONE,
1078 {(char_u *)"", (char_u *)0L}
1079 #endif
1080 SCRIPTID_INIT},
1081 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1082 #ifdef FEAT_FKMAP
1083 (char_u *)&p_fkmap, PV_NONE,
1084 #else
1085 (char_u *)NULL, PV_NONE,
1086 #endif
1087 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1088 {"flash", "fl", P_BOOL|P_VI_DEF,
1089 (char_u *)NULL, PV_NONE,
1090 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1091 #ifdef FEAT_FOLDING
1092 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
1093 (char_u *)&p_fcl, PV_NONE,
1094 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1095 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1096 (char_u *)VAR_WIN, PV_FDC,
1097 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1098 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1099 (char_u *)VAR_WIN, PV_FEN,
1100 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1101 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1102 # ifdef FEAT_EVAL
1103 (char_u *)VAR_WIN, PV_FDE,
1104 {(char_u *)"0", (char_u *)NULL}
1105 # else
1106 (char_u *)NULL, PV_NONE,
1107 {(char_u *)NULL, (char_u *)0L}
1108 # endif
1109 SCRIPTID_INIT},
1110 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1111 (char_u *)VAR_WIN, PV_FDI,
1112 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
1113 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1114 (char_u *)VAR_WIN, PV_FDL,
1115 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
1116 {"foldlevelstart","fdls", P_NUM|P_VI_DEF,
1117 (char_u *)&p_fdls, PV_NONE,
1118 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
1119 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
1120 P_RWIN|P_COMMA|P_NODUP,
1121 (char_u *)VAR_WIN, PV_FMR,
1122 {(char_u *)"{{{,}}}", (char_u *)NULL}
1123 SCRIPTID_INIT},
1124 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1125 (char_u *)VAR_WIN, PV_FDM,
1126 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
1127 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1128 (char_u *)VAR_WIN, PV_FML,
1129 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
1130 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1131 (char_u *)VAR_WIN, PV_FDN,
1132 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
1133 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1134 (char_u *)&p_fdo, PV_NONE,
1135 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1136 (char_u *)0L} SCRIPTID_INIT},
1137 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1138 # ifdef FEAT_EVAL
1139 (char_u *)VAR_WIN, PV_FDT,
1140 {(char_u *)"foldtext()", (char_u *)NULL}
1141 # else
1142 (char_u *)NULL, PV_NONE,
1143 {(char_u *)NULL, (char_u *)0L}
1144 # endif
1145 SCRIPTID_INIT},
1146 #endif
1147 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1148 #ifdef FEAT_EVAL
1149 (char_u *)&p_fex, PV_FEX,
1150 {(char_u *)"", (char_u *)0L}
1151 #else
1152 (char_u *)NULL, PV_NONE,
1153 {(char_u *)0L, (char_u *)0L}
1154 #endif
1155 SCRIPTID_INIT},
1156 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1157 (char_u *)&p_fo, PV_FO,
1158 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1159 SCRIPTID_INIT},
1160 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1161 (char_u *)&p_flp, PV_FLP,
1162 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1163 (char_u *)0L} SCRIPTID_INIT},
1164 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1165 (char_u *)&p_fp, PV_NONE,
1166 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1167 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1168 #ifdef HAVE_FSYNC
1169 (char_u *)&p_fs, PV_NONE,
1170 {(char_u *)TRUE, (char_u *)0L}
1171 #else
1172 (char_u *)NULL, PV_NONE,
1173 {(char_u *)FALSE, (char_u *)0L}
1174 #endif
1175 SCRIPTID_INIT},
1176 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1177 (char_u *)&p_gd, PV_NONE,
1178 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1179 {"graphic", "gr", P_BOOL|P_VI_DEF,
1180 (char_u *)NULL, PV_NONE,
1181 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1182 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1183 #ifdef FEAT_QUICKFIX
1184 (char_u *)&p_gefm, PV_NONE,
1185 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
1186 #else
1187 (char_u *)NULL, PV_NONE,
1188 {(char_u *)NULL, (char_u *)0L}
1189 #endif
1190 SCRIPTID_INIT},
1191 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1192 #ifdef FEAT_QUICKFIX
1193 (char_u *)&p_gp, PV_GP,
1195 # ifdef WIN3264
1196 /* may be changed to "grep -n" in os_win32.c */
1197 (char_u *)"findstr /n",
1198 # else
1199 # ifdef UNIX
1200 /* Add an extra file name so that grep will always
1201 * insert a file name in the match line. */
1202 (char_u *)"grep -n $* /dev/null",
1203 # else
1204 # ifdef VMS
1205 (char_u *)"SEARCH/NUMBERS ",
1206 # else
1207 (char_u *)"grep -n ",
1208 # endif
1209 # endif
1210 # endif
1211 (char_u *)0L}
1212 #else
1213 (char_u *)NULL, PV_NONE,
1214 {(char_u *)NULL, (char_u *)0L}
1215 #endif
1216 SCRIPTID_INIT},
1217 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1218 #ifdef CURSOR_SHAPE
1219 (char_u *)&p_guicursor, PV_NONE,
1221 # ifdef FEAT_GUI
1222 (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",
1223 # else /* MSDOS or Win32 console */
1224 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
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 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1233 #ifdef FEAT_GUI
1234 (char_u *)&p_guifont, PV_NONE,
1235 {(char_u *)"", (char_u *)0L}
1236 #else
1237 (char_u *)NULL, PV_NONE,
1238 {(char_u *)NULL, (char_u *)0L}
1239 #endif
1240 SCRIPTID_INIT},
1241 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
1242 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1243 (char_u *)&p_guifontset, PV_NONE,
1244 {(char_u *)"", (char_u *)0L}
1245 #else
1246 (char_u *)NULL, PV_NONE,
1247 {(char_u *)NULL, (char_u *)0L}
1248 #endif
1249 SCRIPTID_INIT},
1250 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1251 #if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1252 (char_u *)&p_guifontwide, PV_NONE,
1253 {(char_u *)"", (char_u *)0L}
1254 #else
1255 (char_u *)NULL, PV_NONE,
1256 {(char_u *)NULL, (char_u *)0L}
1257 #endif
1258 SCRIPTID_INIT},
1259 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
1260 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
1261 (char_u *)&p_ghr, PV_NONE,
1262 #else
1263 (char_u *)NULL, PV_NONE,
1264 #endif
1265 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
1266 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
1267 #if defined(FEAT_GUI)
1268 (char_u *)&p_go, PV_NONE,
1269 # if defined(UNIX) && !defined(MACOS)
1270 {(char_u *)"aegimrLtT", (char_u *)0L}
1271 # else
1272 {(char_u *)"egmrLtT", (char_u *)0L}
1273 # endif
1274 #else
1275 (char_u *)NULL, PV_NONE,
1276 {(char_u *)NULL, (char_u *)0L}
1277 #endif
1278 SCRIPTID_INIT},
1279 {"guipty", NULL, P_BOOL|P_VI_DEF,
1280 #if defined(FEAT_GUI)
1281 (char_u *)&p_guipty, PV_NONE,
1282 #else
1283 (char_u *)NULL, PV_NONE,
1284 #endif
1285 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1286 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
1287 #if defined(FEAT_GUI_TABLINE)
1288 (char_u *)&p_gtl, PV_NONE,
1289 {(char_u *)"", (char_u *)0L}
1290 #else
1291 (char_u *)NULL, PV_NONE,
1292 {(char_u *)NULL, (char_u *)0L}
1293 #endif
1294 SCRIPTID_INIT},
1295 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
1296 #if defined(FEAT_GUI_TABLINE)
1297 (char_u *)&p_gtt, PV_NONE,
1298 {(char_u *)"", (char_u *)0L}
1299 #else
1300 (char_u *)NULL, PV_NONE,
1301 {(char_u *)NULL, (char_u *)0L}
1302 #endif
1303 SCRIPTID_INIT},
1304 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1305 (char_u *)NULL, PV_NONE,
1306 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
1307 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1308 (char_u *)&p_hf, PV_NONE,
1309 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1310 SCRIPTID_INIT},
1311 {"helpheight", "hh", P_NUM|P_VI_DEF,
1312 #ifdef FEAT_WINDOWS
1313 (char_u *)&p_hh, PV_NONE,
1314 #else
1315 (char_u *)NULL, PV_NONE,
1316 #endif
1317 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
1318 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
1319 #ifdef FEAT_MULTI_LANG
1320 (char_u *)&p_hlg, PV_NONE,
1321 {(char_u *)"", (char_u *)0L}
1322 #else
1323 (char_u *)NULL, PV_NONE,
1324 {(char_u *)0L, (char_u *)0L}
1325 #endif
1326 SCRIPTID_INIT},
1327 {"hidden", "hid", P_BOOL|P_VI_DEF,
1328 (char_u *)&p_hid, PV_NONE,
1329 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1330 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1331 (char_u *)&p_hl, PV_NONE,
1332 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1333 SCRIPTID_INIT},
1334 {"history", "hi", P_NUM|P_VIM,
1335 (char_u *)&p_hi, PV_NONE,
1336 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
1337 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1338 #ifdef FEAT_RIGHTLEFT
1339 (char_u *)&p_hkmap, PV_NONE,
1340 #else
1341 (char_u *)NULL, PV_NONE,
1342 #endif
1343 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1344 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1345 #ifdef FEAT_RIGHTLEFT
1346 (char_u *)&p_hkmapp, PV_NONE,
1347 #else
1348 (char_u *)NULL, PV_NONE,
1349 #endif
1350 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1351 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1352 (char_u *)&p_hls, PV_NONE,
1353 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1354 {"icon", NULL, P_BOOL|P_VI_DEF,
1355 #ifdef FEAT_TITLE
1356 (char_u *)&p_icon, PV_NONE,
1357 #else
1358 (char_u *)NULL, PV_NONE,
1359 #endif
1360 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1361 {"iconstring", NULL, P_STRING|P_VI_DEF,
1362 #ifdef FEAT_TITLE
1363 (char_u *)&p_iconstring, PV_NONE,
1364 #else
1365 (char_u *)NULL, PV_NONE,
1366 #endif
1367 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1368 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1369 (char_u *)&p_ic, PV_NONE,
1370 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1371 {"imactivatekey","imak",P_STRING|P_VI_DEF,
1372 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1373 (char_u *)&p_imak, PV_NONE,
1374 #else
1375 (char_u *)NULL, PV_NONE,
1376 #endif
1377 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1378 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1379 #ifdef USE_IM_CONTROL
1380 (char_u *)&p_imcmdline, PV_NONE,
1381 #else
1382 (char_u *)NULL, PV_NONE,
1383 #endif
1384 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1385 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1386 #ifdef USE_IM_CONTROL
1387 (char_u *)&p_imdisable, PV_NONE,
1388 #else
1389 (char_u *)NULL, PV_NONE,
1390 #endif
1391 #ifdef __sgi
1392 {(char_u *)TRUE, (char_u *)0L}
1393 #else
1394 {(char_u *)FALSE, (char_u *)0L}
1395 #endif
1396 SCRIPTID_INIT},
1397 {"iminsert", "imi", P_NUM|P_VI_DEF,
1398 (char_u *)&p_iminsert, PV_IMI,
1399 #ifdef B_IMODE_IM
1400 {(char_u *)B_IMODE_IM, (char_u *)0L}
1401 #else
1402 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1403 #endif
1404 SCRIPTID_INIT},
1405 {"imsearch", "ims", P_NUM|P_VI_DEF,
1406 (char_u *)&p_imsearch, PV_IMS,
1407 #ifdef B_IMODE_IM
1408 {(char_u *)B_IMODE_IM, (char_u *)0L}
1409 #else
1410 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1411 #endif
1412 SCRIPTID_INIT},
1413 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1414 #ifdef FEAT_FIND_ID
1415 (char_u *)&p_inc, PV_INC,
1416 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1417 #else
1418 (char_u *)NULL, PV_NONE,
1419 {(char_u *)0L, (char_u *)0L}
1420 #endif
1421 SCRIPTID_INIT},
1422 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1423 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1424 (char_u *)&p_inex, PV_INEX,
1425 {(char_u *)"", (char_u *)0L}
1426 #else
1427 (char_u *)NULL, PV_NONE,
1428 {(char_u *)0L, (char_u *)0L}
1429 #endif
1430 SCRIPTID_INIT},
1431 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1432 (char_u *)&p_is, PV_NONE,
1433 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1434 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1435 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1436 (char_u *)&p_inde, PV_INDE,
1437 {(char_u *)"", (char_u *)0L}
1438 #else
1439 (char_u *)NULL, PV_NONE,
1440 {(char_u *)0L, (char_u *)0L}
1441 #endif
1442 SCRIPTID_INIT},
1443 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1444 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1445 (char_u *)&p_indk, PV_INDK,
1446 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1447 #else
1448 (char_u *)NULL, PV_NONE,
1449 {(char_u *)0L, (char_u *)0L}
1450 #endif
1451 SCRIPTID_INIT},
1452 {"infercase", "inf", P_BOOL|P_VI_DEF,
1453 (char_u *)&p_inf, PV_INF,
1454 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1455 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1456 (char_u *)&p_im, PV_NONE,
1457 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1458 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1459 (char_u *)&p_isf, PV_NONE,
1461 #ifdef BACKSLASH_IN_FILENAME
1462 /* Excluded are: & and ^ are special in cmd.exe
1463 * ( and ) are used in text separating fnames */
1464 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1465 #else
1466 # ifdef AMIGA
1467 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1468 # else
1469 # ifdef VMS
1470 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1471 # else /* UNIX et al. */
1472 # ifdef EBCDIC
1473 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1474 # else
1475 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1476 # endif
1477 # endif
1478 # endif
1479 #endif
1480 (char_u *)0L} SCRIPTID_INIT},
1481 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1482 (char_u *)&p_isi, PV_NONE,
1484 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1485 (char_u *)"@,48-57,_,128-167,224-235",
1486 #else
1487 # ifdef EBCDIC
1488 /* TODO: EBCDIC Check this! @ == isalpha()*/
1489 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1490 "112-120,128,140-142,156,158,172,"
1491 "174,186,191,203-207,219-225,235-239,"
1492 "251-254",
1493 # else
1494 (char_u *)"@,48-57,_,192-255",
1495 # endif
1496 #endif
1497 (char_u *)0L} SCRIPTID_INIT},
1498 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1499 (char_u *)&p_isk, PV_ISK,
1501 #ifdef EBCDIC
1502 (char_u *)"@,240-249,_",
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,_",
1510 # if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1511 (char_u *)"@,48-57,_,128-167,224-235"
1512 # else
1513 ISK_LATIN1
1514 # endif
1515 #endif
1516 } SCRIPTID_INIT},
1517 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1518 (char_u *)&p_isp, PV_NONE,
1520 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1521 || (defined(MACOS) && !defined(MACOS_X)) \
1522 || defined(VMS)
1523 (char_u *)"@,~-255",
1524 #else
1525 # ifdef EBCDIC
1526 /* all chars above 63 are printable */
1527 (char_u *)"63-255",
1528 # else
1529 ISP_LATIN1,
1530 # endif
1531 #endif
1532 (char_u *)0L} SCRIPTID_INIT},
1533 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1534 (char_u *)&p_js, PV_NONE,
1535 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1536 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1537 #ifdef FEAT_CRYPT
1538 (char_u *)&p_key, PV_KEY,
1539 {(char_u *)"", (char_u *)0L}
1540 #else
1541 (char_u *)NULL, PV_NONE,
1542 {(char_u *)0L, (char_u *)0L}
1543 #endif
1544 SCRIPTID_INIT},
1545 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
1546 #ifdef FEAT_KEYMAP
1547 (char_u *)&p_keymap, PV_KMAP,
1548 {(char_u *)"", (char_u *)0L}
1549 #else
1550 (char_u *)NULL, PV_NONE,
1551 {(char_u *)"", (char_u *)0L}
1552 #endif
1553 SCRIPTID_INIT},
1554 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1555 #ifdef FEAT_VISUAL
1556 (char_u *)&p_km, PV_NONE,
1557 #else
1558 (char_u *)NULL, PV_NONE,
1559 #endif
1560 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1561 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1562 (char_u *)&p_kp, PV_KP,
1564 #if defined(MSDOS) || defined(MSWIN)
1565 (char_u *)":help",
1566 #else
1567 #ifdef VMS
1568 (char_u *)"help",
1569 #else
1570 # if defined(OS2)
1571 (char_u *)"view /",
1572 # else
1573 # ifdef USEMAN_S
1574 (char_u *)"man -s",
1575 # else
1576 (char_u *)"man",
1577 # endif
1578 # endif
1579 #endif
1580 #endif
1581 (char_u *)0L} SCRIPTID_INIT},
1582 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1583 #ifdef FEAT_LANGMAP
1584 (char_u *)&p_langmap, PV_NONE,
1585 {(char_u *)"", /* unmatched } */
1586 #else
1587 (char_u *)NULL, PV_NONE,
1588 {(char_u *)NULL,
1589 #endif
1590 (char_u *)0L} SCRIPTID_INIT},
1591 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
1592 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1593 (char_u *)&p_lm, PV_NONE,
1594 #else
1595 (char_u *)NULL, PV_NONE,
1596 #endif
1597 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1598 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1599 #ifdef FEAT_WINDOWS
1600 (char_u *)&p_ls, PV_NONE,
1601 #else
1602 (char_u *)NULL, PV_NONE,
1603 #endif
1604 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
1605 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1606 (char_u *)&p_lz, PV_NONE,
1607 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1608 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1609 #ifdef FEAT_LINEBREAK
1610 (char_u *)VAR_WIN, PV_LBR,
1611 #else
1612 (char_u *)NULL, PV_NONE,
1613 #endif
1614 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1615 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1616 (char_u *)&Rows, PV_NONE,
1618 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1619 (char_u *)25L,
1620 #else
1621 (char_u *)24L,
1622 #endif
1623 (char_u *)0L} SCRIPTID_INIT},
1624 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1625 #ifdef FEAT_GUI
1626 (char_u *)&p_linespace, PV_NONE,
1627 #else
1628 (char_u *)NULL, PV_NONE,
1629 #endif
1630 #ifdef FEAT_GUI_W32
1631 {(char_u *)1L, (char_u *)0L}
1632 #else
1633 {(char_u *)0L, (char_u *)0L}
1634 #endif
1635 SCRIPTID_INIT},
1636 {"lisp", NULL, P_BOOL|P_VI_DEF,
1637 #ifdef FEAT_LISP
1638 (char_u *)&p_lisp, PV_LISP,
1639 #else
1640 (char_u *)NULL, PV_NONE,
1641 #endif
1642 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1643 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1644 #ifdef FEAT_LISP
1645 (char_u *)&p_lispwords, PV_NONE,
1646 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1647 #else
1648 (char_u *)NULL, PV_NONE,
1649 {(char_u *)"", (char_u *)0L}
1650 #endif
1651 SCRIPTID_INIT},
1652 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1653 (char_u *)VAR_WIN, PV_LIST,
1654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1655 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1656 (char_u *)&p_lcs, PV_NONE,
1657 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
1658 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1659 (char_u *)&p_lpl, PV_NONE,
1660 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1661 #ifdef FEAT_GUI_MAC
1662 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1663 (char_u *)&p_macatsui, PV_NONE,
1664 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1665 #endif
1666 {"magic", NULL, P_BOOL|P_VI_DEF,
1667 (char_u *)&p_magic, PV_NONE,
1668 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1669 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1670 #ifdef FEAT_QUICKFIX
1671 (char_u *)&p_mef, PV_NONE,
1672 {(char_u *)"", (char_u *)0L}
1673 #else
1674 (char_u *)NULL, PV_NONE,
1675 {(char_u *)NULL, (char_u *)0L}
1676 #endif
1677 SCRIPTID_INIT},
1678 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1679 #ifdef FEAT_QUICKFIX
1680 (char_u *)&p_mp, PV_MP,
1681 # ifdef VMS
1682 {(char_u *)"MMS", (char_u *)0L}
1683 # else
1684 {(char_u *)"make", (char_u *)0L}
1685 # endif
1686 #else
1687 (char_u *)NULL, PV_NONE,
1688 {(char_u *)NULL, (char_u *)0L}
1689 #endif
1690 SCRIPTID_INIT},
1691 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1692 (char_u *)&p_mps, PV_MPS,
1693 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1694 SCRIPTID_INIT},
1695 {"matchtime", "mat", P_NUM|P_VI_DEF,
1696 (char_u *)&p_mat, PV_NONE,
1697 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
1698 {"maxcombine", "mco", P_NUM|P_VI_DEF,
1699 #ifdef FEAT_MBYTE
1700 (char_u *)&p_mco, PV_NONE,
1701 #else
1702 (char_u *)NULL, PV_NONE,
1703 #endif
1704 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
1705 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1706 #ifdef FEAT_EVAL
1707 (char_u *)&p_mfd, PV_NONE,
1708 #else
1709 (char_u *)NULL, PV_NONE,
1710 #endif
1711 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
1712 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1713 (char_u *)&p_mmd, PV_NONE,
1714 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
1715 {"maxmem", "mm", P_NUM|P_VI_DEF,
1716 (char_u *)&p_mm, PV_NONE,
1717 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1718 SCRIPTID_INIT},
1719 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1720 (char_u *)&p_mmp, PV_NONE,
1721 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
1722 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1723 (char_u *)&p_mmt, PV_NONE,
1724 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1725 SCRIPTID_INIT},
1726 {"menuitems", "mis", P_NUM|P_VI_DEF,
1727 #ifdef FEAT_MENU
1728 (char_u *)&p_mis, PV_NONE,
1729 #else
1730 (char_u *)NULL, PV_NONE,
1731 #endif
1732 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
1733 {"mesg", NULL, P_BOOL|P_VI_DEF,
1734 (char_u *)NULL, PV_NONE,
1735 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1736 #ifdef USE_MIGEMO
1737 {"migemo", "mgm", P_BOOL|P_VI_DEF|P_VIM,
1738 (char_u *)&p_migemo, PV_MIG,
1739 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1740 {"migemodict", "mgd", P_STRING|P_EXPAND|P_VI_DEF|P_VIM,
1741 (char_u *)&p_migdict, PV_NONE,
1742 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1743 #endif /* USE_MIGEMO */
1744 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
1745 #ifdef FEAT_SPELL
1746 (char_u *)&p_msm, PV_NONE,
1747 {(char_u *)"460000,2000,500", (char_u *)0L}
1748 #else
1749 (char_u *)NULL, PV_NONE,
1750 {(char_u *)0L, (char_u *)0L}
1751 #endif
1752 SCRIPTID_INIT},
1753 {"modeline", "ml", P_BOOL|P_VIM,
1754 (char_u *)&p_ml, PV_ML,
1755 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
1756 {"modelines", "mls", P_NUM|P_VI_DEF,
1757 (char_u *)&p_mls, PV_NONE,
1758 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
1759 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1760 (char_u *)&p_ma, PV_MA,
1761 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1762 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1763 (char_u *)&p_mod, PV_MOD,
1764 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1765 {"more", NULL, P_BOOL|P_VIM,
1766 (char_u *)&p_more, PV_NONE,
1767 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
1768 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1769 (char_u *)&p_mouse, PV_NONE,
1771 #if defined(MSDOS) || defined(WIN3264)
1772 (char_u *)"a",
1773 #else
1774 (char_u *)"",
1775 #endif
1776 (char_u *)0L} SCRIPTID_INIT},
1777 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1778 #ifdef FEAT_GUI
1779 (char_u *)&p_mousef, PV_NONE,
1780 #else
1781 (char_u *)NULL, PV_NONE,
1782 #endif
1783 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1784 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1785 #ifdef FEAT_GUI
1786 (char_u *)&p_mh, PV_NONE,
1787 #else
1788 (char_u *)NULL, PV_NONE,
1789 #endif
1790 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
1791 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1792 (char_u *)&p_mousem, PV_NONE,
1794 #if defined(MSDOS) || defined(MSWIN)
1795 (char_u *)"popup",
1796 #else
1797 # if defined(MACOS)
1798 (char_u *)"popup_setpos",
1799 # else
1800 (char_u *)"extend",
1801 # endif
1802 #endif
1803 (char_u *)0L} SCRIPTID_INIT},
1804 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1805 #ifdef FEAT_MOUSESHAPE
1806 (char_u *)&p_mouseshape, PV_NONE,
1807 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1808 #else
1809 (char_u *)NULL, PV_NONE,
1810 {(char_u *)NULL, (char_u *)0L}
1811 #endif
1812 SCRIPTID_INIT},
1813 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1814 (char_u *)&p_mouset, PV_NONE,
1815 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
1816 {"mzquantum", "mzq", P_NUM,
1817 #ifdef FEAT_MZSCHEME
1818 (char_u *)&p_mzq, PV_NONE,
1819 #else
1820 (char_u *)NULL, PV_NONE,
1821 #endif
1822 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
1823 {"novice", NULL, P_BOOL|P_VI_DEF,
1824 (char_u *)NULL, PV_NONE,
1825 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1826 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1827 (char_u *)&p_nf, PV_NF,
1828 {(char_u *)"octal,hex", (char_u *)0L}
1829 SCRIPTID_INIT},
1830 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1831 (char_u *)VAR_WIN, PV_NU,
1832 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1833 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1834 #ifdef FEAT_LINEBREAK
1835 (char_u *)VAR_WIN, PV_NUW,
1836 #else
1837 (char_u *)NULL, PV_NONE,
1838 #endif
1839 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
1840 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
1841 #ifdef FEAT_COMPL_FUNC
1842 (char_u *)&p_ofu, PV_OFU,
1843 {(char_u *)"", (char_u *)0L}
1844 #else
1845 (char_u *)NULL, PV_NONE,
1846 {(char_u *)0L, (char_u *)0L}
1847 #endif
1848 SCRIPTID_INIT},
1849 {"open", NULL, P_BOOL|P_VI_DEF,
1850 (char_u *)NULL, PV_NONE,
1851 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1852 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1853 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1854 (char_u *)&p_odev, PV_NONE,
1855 #else
1856 (char_u *)NULL, PV_NONE,
1857 #endif
1858 {(char_u *)FALSE, (char_u *)FALSE}
1859 SCRIPTID_INIT},
1860 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1861 (char_u *)&p_opfunc, PV_NONE,
1862 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1863 {"optimize", "opt", P_BOOL|P_VI_DEF,
1864 (char_u *)NULL, PV_NONE,
1865 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1866 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
1867 #ifdef FEAT_OSFILETYPE
1868 (char_u *)&p_oft, PV_OFT,
1869 {(char_u *)DFLT_OFT, (char_u *)0L}
1870 #else
1871 (char_u *)NULL, PV_NONE,
1872 {(char_u *)0L, (char_u *)0L}
1873 #endif
1874 SCRIPTID_INIT},
1875 {"paragraphs", "para", P_STRING|P_VI_DEF,
1876 (char_u *)&p_para, PV_NONE,
1877 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
1878 (char_u *)0L} SCRIPTID_INIT},
1879 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
1880 (char_u *)&p_paste, PV_NONE,
1881 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1882 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1883 (char_u *)&p_pt, PV_NONE,
1884 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1885 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1886 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1887 (char_u *)&p_pex, PV_NONE,
1888 {(char_u *)"", (char_u *)0L}
1889 #else
1890 (char_u *)NULL, PV_NONE,
1891 {(char_u *)0L, (char_u *)0L}
1892 #endif
1893 SCRIPTID_INIT},
1894 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
1895 (char_u *)&p_pm, PV_NONE,
1896 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
1897 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
1898 (char_u *)&p_path, PV_PATH,
1900 #if defined AMIGA || defined MSDOS || defined MSWIN
1901 (char_u *)".,,",
1902 #else
1903 # if defined(__EMX__)
1904 (char_u *)".,/emx/include,,",
1905 # else /* Unix, probably */
1906 (char_u *)".,/usr/include,,",
1907 # endif
1908 #endif
1909 (char_u *)0L} SCRIPTID_INIT},
1910 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
1911 (char_u *)&p_pi, PV_PI,
1912 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1913 {"previewheight", "pvh", P_NUM|P_VI_DEF,
1914 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1915 (char_u *)&p_pvh, PV_NONE,
1916 #else
1917 (char_u *)NULL, PV_NONE,
1918 #endif
1919 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
1920 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
1921 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1922 (char_u *)VAR_WIN, PV_PVW,
1923 #else
1924 (char_u *)NULL, PV_NONE,
1925 #endif
1926 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
1927 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
1928 #ifdef FEAT_PRINTER
1929 (char_u *)&p_pdev, PV_NONE,
1930 {(char_u *)"", (char_u *)0L}
1931 #else
1932 (char_u *)NULL, PV_NONE,
1933 {(char_u *)NULL, (char_u *)0L}
1934 #endif
1935 SCRIPTID_INIT},
1936 {"printencoding", "penc", P_STRING|P_VI_DEF,
1937 #ifdef FEAT_POSTSCRIPT
1938 (char_u *)&p_penc, PV_NONE,
1939 {(char_u *)"", (char_u *)0L}
1940 #else
1941 (char_u *)NULL, PV_NONE,
1942 {(char_u *)NULL, (char_u *)0L}
1943 #endif
1944 SCRIPTID_INIT},
1945 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
1946 #ifdef FEAT_POSTSCRIPT
1947 (char_u *)&p_pexpr, PV_NONE,
1948 {(char_u *)"", (char_u *)0L}
1949 #else
1950 (char_u *)NULL, PV_NONE,
1951 {(char_u *)NULL, (char_u *)0L}
1952 #endif
1953 SCRIPTID_INIT},
1954 {"printfont", "pfn", P_STRING|P_VI_DEF,
1955 #ifdef FEAT_PRINTER
1956 (char_u *)&p_pfn, PV_NONE,
1958 # ifdef MSWIN
1959 (char_u *)"Courier_New:h10",
1960 # else
1961 (char_u *)"courier",
1962 # endif
1963 (char_u *)0L}
1964 #else
1965 (char_u *)NULL, PV_NONE,
1966 {(char_u *)NULL, (char_u *)0L}
1967 #endif
1968 SCRIPTID_INIT},
1969 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
1970 #ifdef FEAT_PRINTER
1971 (char_u *)&p_header, PV_NONE,
1972 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
1973 #else
1974 (char_u *)NULL, PV_NONE,
1975 {(char_u *)NULL, (char_u *)0L}
1976 #endif
1977 SCRIPTID_INIT},
1978 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
1979 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
1980 (char_u *)&p_pmcs, PV_NONE,
1981 {(char_u *)"", (char_u *)0L}
1982 #else
1983 (char_u *)NULL, PV_NONE,
1984 {(char_u *)NULL, (char_u *)0L}
1985 #endif
1986 SCRIPTID_INIT},
1987 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
1988 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
1989 (char_u *)&p_pmfn, PV_NONE,
1990 {(char_u *)"", (char_u *)0L}
1991 #else
1992 (char_u *)NULL, PV_NONE,
1993 {(char_u *)NULL, (char_u *)0L}
1994 #endif
1995 SCRIPTID_INIT},
1996 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1997 #ifdef FEAT_PRINTER
1998 (char_u *)&p_popt, PV_NONE,
1999 {(char_u *)"", (char_u *)0L}
2000 #else
2001 (char_u *)NULL, PV_NONE,
2002 {(char_u *)NULL, (char_u *)0L}
2003 #endif
2004 SCRIPTID_INIT},
2005 {"prompt", NULL, P_BOOL|P_VI_DEF,
2006 (char_u *)&p_prompt, PV_NONE,
2007 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2008 {"pumheight", "ph", P_NUM|P_VI_DEF,
2009 #ifdef FEAT_INS_EXPAND
2010 (char_u *)&p_ph, PV_NONE,
2011 #else
2012 (char_u *)NULL, PV_NONE,
2013 #endif
2014 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2015 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2016 #ifdef FEAT_TEXTOBJ
2017 (char_u *)&p_qe, PV_QE,
2018 {(char_u *)"\\", (char_u *)0L}
2019 #else
2020 (char_u *)NULL, PV_NONE,
2021 {(char_u *)NULL, (char_u *)0L}
2022 #endif
2023 SCRIPTID_INIT},
2024 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2025 (char_u *)&p_ro, PV_RO,
2026 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2027 {"redraw", NULL, P_BOOL|P_VI_DEF,
2028 (char_u *)NULL, PV_NONE,
2029 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2030 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2031 #ifdef FEAT_RELTIME
2032 (char_u *)&p_rdt, PV_NONE,
2033 #else
2034 (char_u *)NULL, PV_NONE,
2035 #endif
2036 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
2037 {"remap", NULL, P_BOOL|P_VI_DEF,
2038 (char_u *)&p_remap, PV_NONE,
2039 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2040 {"report", NULL, P_NUM|P_VI_DEF,
2041 (char_u *)&p_report, PV_NONE,
2042 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
2043 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2044 #ifdef WIN3264
2045 (char_u *)&p_rs, PV_NONE,
2046 #else
2047 (char_u *)NULL, PV_NONE,
2048 #endif
2049 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2050 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2051 #ifdef FEAT_RIGHTLEFT
2052 (char_u *)&p_ri, PV_NONE,
2053 #else
2054 (char_u *)NULL, PV_NONE,
2055 #endif
2056 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2057 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2058 #ifdef FEAT_RIGHTLEFT
2059 (char_u *)VAR_WIN, PV_RL,
2060 #else
2061 (char_u *)NULL, PV_NONE,
2062 #endif
2063 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2064 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2065 #ifdef FEAT_RIGHTLEFT
2066 (char_u *)VAR_WIN, PV_RLC,
2067 {(char_u *)"search", (char_u *)NULL}
2068 #else
2069 (char_u *)NULL, PV_NONE,
2070 {(char_u *)NULL, (char_u *)0L}
2071 #endif
2072 SCRIPTID_INIT},
2073 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2074 #ifdef FEAT_CMDL_INFO
2075 (char_u *)&p_ru, PV_NONE,
2076 #else
2077 (char_u *)NULL, PV_NONE,
2078 #endif
2079 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2080 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2081 #ifdef FEAT_STL_OPT
2082 (char_u *)&p_ruf, PV_NONE,
2083 #else
2084 (char_u *)NULL, PV_NONE,
2085 #endif
2086 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2087 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
2088 (char_u *)&p_rtp, PV_NONE,
2089 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2090 SCRIPTID_INIT},
2091 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2092 (char_u *)VAR_WIN, PV_SCROLL,
2093 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
2094 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2095 #ifdef FEAT_SCROLLBIND
2096 (char_u *)VAR_WIN, PV_SCBIND,
2097 #else
2098 (char_u *)NULL, PV_NONE,
2099 #endif
2100 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2101 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2102 (char_u *)&p_sj, PV_NONE,
2103 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2104 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2105 (char_u *)&p_so, PV_NONE,
2106 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2107 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2108 #ifdef FEAT_SCROLLBIND
2109 (char_u *)&p_sbo, PV_NONE,
2110 {(char_u *)"ver,jump", (char_u *)0L}
2111 #else
2112 (char_u *)NULL, PV_NONE,
2113 {(char_u *)0L, (char_u *)0L}
2114 #endif
2115 SCRIPTID_INIT},
2116 {"sections", "sect", P_STRING|P_VI_DEF,
2117 (char_u *)&p_sections, PV_NONE,
2118 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2119 SCRIPTID_INIT},
2120 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2121 (char_u *)&p_secure, PV_NONE,
2122 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2123 {"selection", "sel", P_STRING|P_VI_DEF,
2124 #ifdef FEAT_VISUAL
2125 (char_u *)&p_sel, PV_NONE,
2126 #else
2127 (char_u *)NULL, PV_NONE,
2128 #endif
2129 {(char_u *)"inclusive", (char_u *)0L}
2130 SCRIPTID_INIT},
2131 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2132 #ifdef FEAT_VISUAL
2133 (char_u *)&p_slm, PV_NONE,
2134 #else
2135 (char_u *)NULL, PV_NONE,
2136 #endif
2137 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2138 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2139 #ifdef FEAT_SESSION
2140 (char_u *)&p_ssop, PV_NONE,
2141 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
2142 (char_u *)0L}
2143 #else
2144 (char_u *)NULL, PV_NONE,
2145 {(char_u *)0L, (char_u *)0L}
2146 #endif
2147 SCRIPTID_INIT},
2148 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2149 (char_u *)&p_sh, PV_NONE,
2151 #ifdef VMS
2152 (char_u *)"-",
2153 #else
2154 # if defined(MSDOS)
2155 (char_u *)"command",
2156 # else
2157 # if defined(WIN16)
2158 (char_u *)"command.com",
2159 # else
2160 # if defined(WIN3264)
2161 (char_u *)"", /* set in set_init_1() */
2162 # else
2163 # if defined(OS2)
2164 (char_u *)"cmd.exe",
2165 # else
2166 # if defined(ARCHIE)
2167 (char_u *)"gos",
2168 # else
2169 (char_u *)"sh",
2170 # endif
2171 # endif
2172 # endif
2173 # endif
2174 # endif
2175 #endif /* VMS */
2176 (char_u *)0L} SCRIPTID_INIT},
2177 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2178 (char_u *)&p_shcf, PV_NONE,
2180 #if defined(MSDOS) || defined(MSWIN)
2181 (char_u *)"/c",
2182 #else
2183 # if defined(OS2)
2184 (char_u *)"/c",
2185 # else
2186 (char_u *)"-c",
2187 # endif
2188 #endif
2189 (char_u *)0L} SCRIPTID_INIT},
2190 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2191 #ifdef FEAT_QUICKFIX
2192 (char_u *)&p_sp, PV_NONE,
2194 #if defined(UNIX) || defined(OS2)
2195 # ifdef ARCHIE
2196 (char_u *)"2>",
2197 # else
2198 (char_u *)"| tee",
2199 # endif
2200 #else
2201 (char_u *)">",
2202 #endif
2203 (char_u *)0L}
2204 #else
2205 (char_u *)NULL, PV_NONE,
2206 {(char_u *)0L, (char_u *)0L}
2207 #endif
2208 SCRIPTID_INIT},
2209 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2210 (char_u *)&p_shq, PV_NONE,
2211 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2212 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2213 (char_u *)&p_srr, PV_NONE,
2214 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
2215 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2216 #ifdef BACKSLASH_IN_FILENAME
2217 (char_u *)&p_ssl, PV_NONE,
2218 #else
2219 (char_u *)NULL, PV_NONE,
2220 #endif
2221 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2222 {"shelltemp", "stmp", P_BOOL,
2223 (char_u *)&p_stmp, PV_NONE,
2224 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
2225 {"shelltype", "st", P_NUM|P_VI_DEF,
2226 #ifdef AMIGA
2227 (char_u *)&p_st, PV_NONE,
2228 #else
2229 (char_u *)NULL, PV_NONE,
2230 #endif
2231 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2232 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2233 (char_u *)&p_sxq, PV_NONE,
2235 #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2236 (char_u *)"\"",
2237 #else
2238 (char_u *)"",
2239 #endif
2240 (char_u *)0L} SCRIPTID_INIT},
2241 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2242 (char_u *)&p_sr, PV_NONE,
2243 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2244 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2245 (char_u *)&p_sw, PV_SW,
2246 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
2247 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2248 (char_u *)&p_shm, PV_NONE,
2249 {(char_u *)"", (char_u *)"filnxtToO"}
2250 SCRIPTID_INIT},
2251 {"shortname", "sn", P_BOOL|P_VI_DEF,
2252 #ifdef SHORT_FNAME
2253 (char_u *)NULL, PV_NONE,
2254 #else
2255 (char_u *)&p_sn, PV_SN,
2256 #endif
2257 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2258 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2259 #ifdef FEAT_LINEBREAK
2260 (char_u *)&p_sbr, PV_NONE,
2261 #else
2262 (char_u *)NULL, PV_NONE,
2263 #endif
2264 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2265 {"showcmd", "sc", P_BOOL|P_VIM,
2266 #ifdef FEAT_CMDL_INFO
2267 (char_u *)&p_sc, PV_NONE,
2268 #else
2269 (char_u *)NULL, PV_NONE,
2270 #endif
2271 {(char_u *)FALSE,
2272 #ifdef UNIX
2273 (char_u *)FALSE
2274 #else
2275 (char_u *)TRUE
2276 #endif
2277 } SCRIPTID_INIT},
2278 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2279 (char_u *)&p_sft, PV_NONE,
2280 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2281 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2282 (char_u *)&p_sm, PV_NONE,
2283 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2284 {"showmode", "smd", P_BOOL|P_VIM,
2285 (char_u *)&p_smd, PV_NONE,
2286 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
2287 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2288 #ifdef FEAT_WINDOWS
2289 (char_u *)&p_stal, PV_NONE,
2290 #else
2291 (char_u *)NULL, PV_NONE,
2292 #endif
2293 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2294 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2295 (char_u *)&p_ss, PV_NONE,
2296 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2297 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2298 (char_u *)&p_siso, PV_NONE,
2299 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2300 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2301 (char_u *)NULL, PV_NONE,
2302 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2303 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2304 (char_u *)&p_scs, PV_NONE,
2305 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2306 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2307 #ifdef FEAT_SMARTINDENT
2308 (char_u *)&p_si, PV_SI,
2309 #else
2310 (char_u *)NULL, PV_NONE,
2311 #endif
2312 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2313 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2314 (char_u *)&p_sta, PV_NONE,
2315 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2316 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2317 (char_u *)&p_sts, PV_STS,
2318 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2319 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2320 (char_u *)NULL, PV_NONE,
2321 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2322 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2323 #ifdef FEAT_SPELL
2324 (char_u *)VAR_WIN, PV_SPELL,
2325 #else
2326 (char_u *)NULL, PV_NONE,
2327 #endif
2328 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2329 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
2330 #ifdef FEAT_SPELL
2331 (char_u *)&p_spc, PV_SPC,
2332 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
2333 #else
2334 (char_u *)NULL, PV_NONE,
2335 {(char_u *)0L, (char_u *)0L}
2336 #endif
2337 SCRIPTID_INIT},
2338 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
2339 #ifdef FEAT_SPELL
2340 (char_u *)&p_spf, PV_SPF,
2341 {(char_u *)"", (char_u *)0L}
2342 #else
2343 (char_u *)NULL, PV_NONE,
2344 {(char_u *)0L, (char_u *)0L}
2345 #endif
2346 SCRIPTID_INIT},
2347 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
2348 #ifdef FEAT_SPELL
2349 (char_u *)&p_spl, PV_SPL,
2350 {(char_u *)"en", (char_u *)0L}
2351 #else
2352 (char_u *)NULL, PV_NONE,
2353 {(char_u *)0L, (char_u *)0L}
2354 #endif
2355 SCRIPTID_INIT},
2356 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
2357 #ifdef FEAT_SPELL
2358 (char_u *)&p_sps, PV_NONE,
2359 {(char_u *)"best", (char_u *)0L}
2360 #else
2361 (char_u *)NULL, PV_NONE,
2362 {(char_u *)0L, (char_u *)0L}
2363 #endif
2364 SCRIPTID_INIT},
2365 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2366 #ifdef FEAT_WINDOWS
2367 (char_u *)&p_sb, PV_NONE,
2368 #else
2369 (char_u *)NULL, PV_NONE,
2370 #endif
2371 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2372 {"splitright", "spr", P_BOOL|P_VI_DEF,
2373 #ifdef FEAT_VERTSPLIT
2374 (char_u *)&p_spr, PV_NONE,
2375 #else
2376 (char_u *)NULL, PV_NONE,
2377 #endif
2378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2379 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2380 (char_u *)&p_sol, PV_NONE,
2381 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2382 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2383 #ifdef FEAT_STL_OPT
2384 (char_u *)&p_stl, PV_STL,
2385 #else
2386 (char_u *)NULL, PV_NONE,
2387 #endif
2388 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2389 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2390 (char_u *)&p_su, PV_NONE,
2391 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
2392 (char_u *)0L} SCRIPTID_INIT},
2393 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
2394 #ifdef FEAT_SEARCHPATH
2395 (char_u *)&p_sua, PV_SUA,
2396 {(char_u *)"", (char_u *)0L}
2397 #else
2398 (char_u *)NULL, PV_NONE,
2399 {(char_u *)0L, (char_u *)0L}
2400 #endif
2401 SCRIPTID_INIT},
2402 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2403 (char_u *)&p_swf, PV_SWF,
2404 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2405 {"swapsync", "sws", P_STRING|P_VI_DEF,
2406 (char_u *)&p_sws, PV_NONE,
2407 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
2408 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2409 (char_u *)&p_swb, PV_NONE,
2410 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2411 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2412 #ifdef FEAT_SYN_HL
2413 (char_u *)&p_smc, PV_SMC,
2414 {(char_u *)3000L, (char_u *)0L}
2415 #else
2416 (char_u *)NULL, PV_NONE,
2417 {(char_u *)0L, (char_u *)0L}
2418 #endif
2419 SCRIPTID_INIT},
2420 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
2421 #ifdef FEAT_SYN_HL
2422 (char_u *)&p_syn, PV_SYN,
2423 {(char_u *)"", (char_u *)0L}
2424 #else
2425 (char_u *)NULL, PV_NONE,
2426 {(char_u *)0L, (char_u *)0L}
2427 #endif
2428 SCRIPTID_INIT},
2429 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2430 #ifdef FEAT_STL_OPT
2431 (char_u *)&p_tal, PV_NONE,
2432 #else
2433 (char_u *)NULL, PV_NONE,
2434 #endif
2435 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2436 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2437 #ifdef FEAT_WINDOWS
2438 (char_u *)&p_tpm, PV_NONE,
2439 #else
2440 (char_u *)NULL, PV_NONE,
2441 #endif
2442 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
2443 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2444 (char_u *)&p_ts, PV_TS,
2445 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
2446 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2447 (char_u *)&p_tbs, PV_NONE,
2448 #ifdef VMS /* binary searching doesn't appear to work on VMS */
2449 {(char_u *)0L, (char_u *)0L}
2450 #else
2451 {(char_u *)TRUE, (char_u *)0L}
2452 #endif
2453 SCRIPTID_INIT},
2454 {"taglength", "tl", P_NUM|P_VI_DEF,
2455 (char_u *)&p_tl, PV_NONE,
2456 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2457 {"tagrelative", "tr", P_BOOL|P_VIM,
2458 (char_u *)&p_tr, PV_NONE,
2459 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
2460 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2461 (char_u *)&p_tags, PV_TAGS,
2463 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2464 (char_u *)"./tags,./TAGS,tags,TAGS",
2465 #else
2466 (char_u *)"./tags,tags",
2467 #endif
2468 (char_u *)0L} SCRIPTID_INIT},
2469 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2470 (char_u *)&p_tgst, PV_NONE,
2471 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2472 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2473 (char_u *)&T_NAME, PV_NONE,
2474 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2475 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2476 #ifdef FEAT_ARABIC
2477 (char_u *)&p_tbidi, PV_NONE,
2478 #else
2479 (char_u *)NULL, PV_NONE,
2480 #endif
2481 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2482 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2483 #ifdef FEAT_MBYTE
2484 (char_u *)&p_tenc, PV_NONE,
2485 {(char_u *)"", (char_u *)0L}
2486 #else
2487 (char_u *)NULL, PV_NONE,
2488 {(char_u *)0L, (char_u *)0L}
2489 #endif
2490 SCRIPTID_INIT},
2491 {"terse", NULL, P_BOOL|P_VI_DEF,
2492 (char_u *)&p_terse, PV_NONE,
2493 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2494 {"textauto", "ta", P_BOOL|P_VIM,
2495 (char_u *)&p_ta, PV_NONE,
2496 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2497 SCRIPTID_INIT},
2498 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2499 (char_u *)&p_tx, PV_TX,
2501 #ifdef USE_CRNL
2502 (char_u *)TRUE,
2503 #else
2504 (char_u *)FALSE,
2505 #endif
2506 (char_u *)0L} SCRIPTID_INIT},
2507 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM,
2508 (char_u *)&p_tw, PV_TW,
2509 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2510 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2511 #ifdef FEAT_INS_EXPAND
2512 (char_u *)&p_tsr, PV_TSR,
2513 #else
2514 (char_u *)NULL, PV_NONE,
2515 #endif
2516 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2517 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2518 (char_u *)&p_to, PV_NONE,
2519 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2520 {"timeout", "to", P_BOOL|P_VI_DEF,
2521 (char_u *)&p_timeout, PV_NONE,
2522 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2523 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2524 (char_u *)&p_tm, PV_NONE,
2525 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
2526 {"title", NULL, P_BOOL|P_VI_DEF,
2527 #ifdef FEAT_TITLE
2528 (char_u *)&p_title, PV_NONE,
2529 #else
2530 (char_u *)NULL, PV_NONE,
2531 #endif
2532 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2533 {"titlelen", NULL, P_NUM|P_VI_DEF,
2534 #ifdef FEAT_TITLE
2535 (char_u *)&p_titlelen, PV_NONE,
2536 #else
2537 (char_u *)NULL, PV_NONE,
2538 #endif
2539 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
2540 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
2541 #ifdef FEAT_TITLE
2542 (char_u *)&p_titleold, PV_NONE,
2543 {(char_u *)N_("Thanks for flying Vim"),
2544 (char_u *)0L}
2545 #else
2546 (char_u *)NULL, PV_NONE,
2547 {(char_u *)0L, (char_u *)0L}
2548 #endif
2549 SCRIPTID_INIT},
2550 {"titlestring", NULL, P_STRING|P_VI_DEF,
2551 #ifdef FEAT_TITLE
2552 (char_u *)&p_titlestring, PV_NONE,
2553 #else
2554 (char_u *)NULL, PV_NONE,
2555 #endif
2556 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2557 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
2558 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
2559 (char_u *)&p_toolbar, PV_NONE,
2560 {(char_u *)"icons,tooltips", (char_u *)0L}
2561 SCRIPTID_INIT},
2562 #endif
2563 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
2564 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2565 (char_u *)&p_tbis, PV_NONE,
2566 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
2567 #endif
2568 #ifdef USE_TRANSPARENCY
2569 {"transparency", "tra", P_NUM|P_VI_DEF,
2570 (char_u *)&p_transparency, PV_NONE,
2571 {(char_u *)255L, (char_u *)0L}},
2572 #endif
2573 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2574 (char_u *)&p_ttimeout, PV_NONE,
2575 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2576 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2577 (char_u *)&p_ttm, PV_NONE,
2578 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
2579 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2580 (char_u *)&p_tbi, PV_NONE,
2581 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2582 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2583 (char_u *)&p_tf, PV_NONE,
2584 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2585 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2586 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2587 (char_u *)&p_ttym, PV_NONE,
2588 #else
2589 (char_u *)NULL, PV_NONE,
2590 #endif
2591 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2592 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2593 (char_u *)&p_ttyscroll, PV_NONE,
2594 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
2595 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2596 (char_u *)&T_NAME, PV_NONE,
2597 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2598 {"undolevels", "ul", P_NUM|P_VI_DEF,
2599 (char_u *)&p_ul, PV_NONE,
2601 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2602 (char_u *)1000L,
2603 #else
2604 (char_u *)100L,
2605 #endif
2606 (char_u *)0L} SCRIPTID_INIT},
2607 {"updatecount", "uc", P_NUM|P_VI_DEF,
2608 (char_u *)&p_uc, PV_NONE,
2609 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
2610 {"updatetime", "ut", P_NUM|P_VI_DEF,
2611 (char_u *)&p_ut, PV_NONE,
2612 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
2613 {"verbose", "vbs", P_NUM|P_VI_DEF,
2614 (char_u *)&p_verbose, PV_NONE,
2615 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2616 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2617 (char_u *)&p_vfile, PV_NONE,
2618 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2619 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2620 #ifdef FEAT_SESSION
2621 (char_u *)&p_vdir, PV_NONE,
2622 {(char_u *)DFLT_VDIR, (char_u *)0L}
2623 #else
2624 (char_u *)NULL, PV_NONE,
2625 {(char_u *)0L, (char_u *)0L}
2626 #endif
2627 SCRIPTID_INIT},
2628 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2629 #ifdef FEAT_SESSION
2630 (char_u *)&p_vop, PV_NONE,
2631 {(char_u *)"folds,options,cursor", (char_u *)0L}
2632 #else
2633 (char_u *)NULL, PV_NONE,
2634 {(char_u *)0L, (char_u *)0L}
2635 #endif
2636 SCRIPTID_INIT},
2637 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
2638 #ifdef FEAT_VIMINFO
2639 (char_u *)&p_viminfo, PV_NONE,
2640 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
2641 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
2642 #else
2643 # ifdef AMIGA
2644 {(char_u *)"",
2645 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
2646 # else
2647 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
2648 # endif
2649 #endif
2650 #else
2651 (char_u *)NULL, PV_NONE,
2652 {(char_u *)0L, (char_u *)0L}
2653 #endif
2654 SCRIPTID_INIT},
2655 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM,
2656 #ifdef FEAT_VIRTUALEDIT
2657 (char_u *)&p_ve, PV_NONE,
2658 {(char_u *)"", (char_u *)""}
2659 #else
2660 (char_u *)NULL, PV_NONE,
2661 {(char_u *)0L, (char_u *)0L}
2662 #endif
2663 SCRIPTID_INIT},
2664 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2665 (char_u *)&p_vb, PV_NONE,
2666 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2667 {"w300", NULL, P_NUM|P_VI_DEF,
2668 (char_u *)NULL, PV_NONE,
2669 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2670 {"w1200", NULL, P_NUM|P_VI_DEF,
2671 (char_u *)NULL, PV_NONE,
2672 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2673 {"w9600", NULL, P_NUM|P_VI_DEF,
2674 (char_u *)NULL, PV_NONE,
2675 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2676 {"warn", NULL, P_BOOL|P_VI_DEF,
2677 (char_u *)&p_warn, PV_NONE,
2678 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2679 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2680 (char_u *)&p_wiv, PV_NONE,
2681 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2682 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
2683 (char_u *)&p_ww, PV_NONE,
2684 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
2685 {"wildchar", "wc", P_NUM|P_VIM,
2686 (char_u *)&p_wc, PV_NONE,
2687 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2688 SCRIPTID_INIT},
2689 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
2690 (char_u *)&p_wcm, PV_NONE,
2691 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2692 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2693 #ifdef FEAT_WILDIGN
2694 (char_u *)&p_wig, PV_NONE,
2695 #else
2696 (char_u *)NULL, PV_NONE,
2697 #endif
2698 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2699 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2700 #ifdef FEAT_WILDMENU
2701 (char_u *)&p_wmnu, PV_NONE,
2702 #else
2703 (char_u *)NULL, PV_NONE,
2704 #endif
2705 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2706 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2707 (char_u *)&p_wim, PV_NONE,
2708 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
2709 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2710 #ifdef FEAT_CMDL_COMPL
2711 (char_u *)&p_wop, PV_NONE,
2712 {(char_u *)"", (char_u *)0L}
2713 #else
2714 (char_u *)NULL, PV_NONE,
2715 {(char_u *)NULL, (char_u *)0L}
2716 #endif
2717 SCRIPTID_INIT},
2718 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2719 #ifdef FEAT_WAK
2720 (char_u *)&p_wak, PV_NONE,
2721 {(char_u *)"menu", (char_u *)0L}
2722 #else
2723 (char_u *)NULL, PV_NONE,
2724 {(char_u *)NULL, (char_u *)0L}
2725 #endif
2726 SCRIPTID_INIT},
2727 {"window", "wi", P_NUM|P_VI_DEF,
2728 (char_u *)&p_window, PV_NONE,
2729 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2730 {"winheight", "wh", P_NUM|P_VI_DEF,
2731 #ifdef FEAT_WINDOWS
2732 (char_u *)&p_wh, PV_NONE,
2733 #else
2734 (char_u *)NULL, PV_NONE,
2735 #endif
2736 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2737 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
2738 #ifdef FEAT_WINDOWS
2739 (char_u *)VAR_WIN, PV_WFH,
2740 #else
2741 (char_u *)NULL, PV_NONE,
2742 #endif
2743 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2744 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2745 #ifdef FEAT_VERTSPLIT
2746 (char_u *)VAR_WIN, PV_WFW,
2747 #else
2748 (char_u *)NULL, PV_NONE,
2749 #endif
2750 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2751 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2752 #ifdef FEAT_WINDOWS
2753 (char_u *)&p_wmh, PV_NONE,
2754 #else
2755 (char_u *)NULL, PV_NONE,
2756 #endif
2757 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2758 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2759 #ifdef FEAT_VERTSPLIT
2760 (char_u *)&p_wmw, PV_NONE,
2761 #else
2762 (char_u *)NULL, PV_NONE,
2763 #endif
2764 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
2765 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2766 #ifdef FEAT_VERTSPLIT
2767 (char_u *)&p_wiw, PV_NONE,
2768 #else
2769 (char_u *)NULL, PV_NONE,
2770 #endif
2771 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
2772 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2773 (char_u *)VAR_WIN, PV_WRAP,
2774 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2775 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2776 (char_u *)&p_wm, PV_WM,
2777 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2778 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2779 (char_u *)&p_ws, PV_NONE,
2780 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2781 {"write", NULL, P_BOOL|P_VI_DEF,
2782 (char_u *)&p_write, PV_NONE,
2783 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
2784 {"writeany", "wa", P_BOOL|P_VI_DEF,
2785 (char_u *)&p_wa, PV_NONE,
2786 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2787 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2788 (char_u *)&p_wb, PV_NONE,
2790 #ifdef FEAT_WRITEBACKUP
2791 (char_u *)TRUE,
2792 #else
2793 (char_u *)FALSE,
2794 #endif
2795 (char_u *)0L} SCRIPTID_INIT},
2796 {"writedelay", "wd", P_NUM|P_VI_DEF,
2797 (char_u *)&p_wd, PV_NONE,
2798 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
2800 /* terminal output codes */
2801 #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
2802 (char_u *)&vvv, PV_NONE, \
2803 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
2805 p_term("t_AB", T_CAB)
2806 p_term("t_AF", T_CAF)
2807 p_term("t_AL", T_CAL)
2808 p_term("t_al", T_AL)
2809 p_term("t_bc", T_BC)
2810 p_term("t_cd", T_CD)
2811 p_term("t_ce", T_CE)
2812 p_term("t_cl", T_CL)
2813 p_term("t_cm", T_CM)
2814 p_term("t_Co", T_CCO)
2815 p_term("t_CS", T_CCS)
2816 p_term("t_cs", T_CS)
2817 #ifdef FEAT_VERTSPLIT
2818 p_term("t_CV", T_CSV)
2819 #endif
2820 p_term("t_ut", T_UT)
2821 p_term("t_da", T_DA)
2822 p_term("t_db", T_DB)
2823 p_term("t_DL", T_CDL)
2824 p_term("t_dl", T_DL)
2825 p_term("t_fs", T_FS)
2826 p_term("t_IE", T_CIE)
2827 p_term("t_IS", T_CIS)
2828 p_term("t_ke", T_KE)
2829 p_term("t_ks", T_KS)
2830 p_term("t_le", T_LE)
2831 p_term("t_mb", T_MB)
2832 p_term("t_md", T_MD)
2833 p_term("t_me", T_ME)
2834 p_term("t_mr", T_MR)
2835 p_term("t_ms", T_MS)
2836 p_term("t_nd", T_ND)
2837 p_term("t_op", T_OP)
2838 p_term("t_RI", T_CRI)
2839 p_term("t_RV", T_CRV)
2840 p_term("t_Sb", T_CSB)
2841 p_term("t_Sf", T_CSF)
2842 p_term("t_se", T_SE)
2843 p_term("t_so", T_SO)
2844 p_term("t_sr", T_SR)
2845 p_term("t_ts", T_TS)
2846 p_term("t_te", T_TE)
2847 p_term("t_ti", T_TI)
2848 p_term("t_ue", T_UE)
2849 p_term("t_us", T_US)
2850 p_term("t_vb", T_VB)
2851 p_term("t_ve", T_VE)
2852 p_term("t_vi", T_VI)
2853 p_term("t_vs", T_VS)
2854 p_term("t_WP", T_CWP)
2855 p_term("t_WS", T_CWS)
2856 p_term("t_SI", T_CSI)
2857 p_term("t_EI", T_CEI)
2858 p_term("t_xs", T_XS)
2859 p_term("t_ZH", T_CZH)
2860 p_term("t_ZR", T_CZR)
2862 /* terminal key codes are not in here */
2864 /* end marker */
2865 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
2868 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
2870 #ifdef FEAT_MBYTE
2871 static char *(p_ambw_values[]) = {"single", "double",
2872 # ifdef USE_AMBIWIDTH_AUTO
2873 "auto",
2874 # endif
2875 NULL};
2876 #endif
2877 static char *(p_bg_values[]) = {"light", "dark", NULL};
2878 static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
2879 static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
2880 #ifdef FEAT_CMDL_COMPL
2881 static char *(p_wop_values[]) = {"tagfile", NULL};
2882 #endif
2883 #ifdef FEAT_WAK
2884 static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
2885 #endif
2886 static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
2887 #ifdef FEAT_VISUAL
2888 static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
2889 static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
2890 #endif
2891 #ifdef FEAT_VISUAL
2892 static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
2893 #endif
2894 #ifdef FEAT_BROWSE
2895 static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
2896 #endif
2897 #ifdef FEAT_SCROLLBIND
2898 static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
2899 #endif
2900 static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
2901 #ifdef FEAT_VERTSPLIT
2902 static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
2903 #endif
2904 #if defined(FEAT_QUICKFIX)
2905 # ifdef FEAT_AUTOCMD
2906 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
2907 # else
2908 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
2909 # endif
2910 static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
2911 #endif
2912 static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
2913 #ifdef FEAT_FOLDING
2914 static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
2915 # ifdef FEAT_DIFF
2916 "diff",
2917 # endif
2918 NULL};
2919 static char *(p_fcl_values[]) = {"all", NULL};
2920 #endif
2921 #ifdef FEAT_INS_EXPAND
2922 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
2923 #endif
2925 static void set_option_default __ARGS((int, int opt_flags, int compatible));
2926 static void set_options_default __ARGS((int opt_flags));
2927 static char_u *term_bg_default __ARGS((void));
2928 static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
2929 static char_u *illegal_char __ARGS((char_u *, int));
2930 static int string_to_key __ARGS((char_u *arg));
2931 #ifdef FEAT_CMDWIN
2932 static char_u *check_cedit __ARGS((void));
2933 #endif
2934 #ifdef FEAT_TITLE
2935 static void did_set_title __ARGS((int icon));
2936 #endif
2937 static char_u *option_expand __ARGS((int opt_idx, char_u *val));
2938 static void didset_options __ARGS((void));
2939 static void check_string_option __ARGS((char_u **pp));
2940 #if defined(FEAT_EVAL) || defined(PROTO)
2941 static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
2942 #else
2943 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
2944 #endif
2945 static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
2946 static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
2947 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));
2948 static char_u *set_chars_option __ARGS((char_u **varp));
2949 #ifdef FEAT_CLIPBOARD
2950 static char_u *check_clipboard_option __ARGS((void));
2951 #endif
2952 #ifdef FEAT_SPELL
2953 static char_u *compile_cap_prog __ARGS((buf_T *buf));
2954 #endif
2955 #ifdef FEAT_EVAL
2956 static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
2957 #endif
2958 static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
2959 static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags));
2960 static void check_redraw __ARGS((long_u flags));
2961 static int findoption __ARGS((char_u *));
2962 static int find_key_option __ARGS((char_u *));
2963 static void showoptions __ARGS((int all, int opt_flags));
2964 static int optval_default __ARGS((struct vimoption *, char_u *varp));
2965 static void showoneopt __ARGS((struct vimoption *, int opt_flags));
2966 static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
2967 static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
2968 static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
2969 static int istermoption __ARGS((struct vimoption *));
2970 static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
2971 static char_u *get_varp __ARGS((struct vimoption *));
2972 static void option_value2string __ARGS((struct vimoption *, int opt_flags));
2973 static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
2974 #ifdef FEAT_LANGMAP
2975 static void langmap_init __ARGS((void));
2976 static void langmap_set __ARGS((void));
2977 #endif
2978 static void paste_option_changed __ARGS((void));
2979 static void compatible_set __ARGS((void));
2980 #ifdef FEAT_LINEBREAK
2981 static void fill_breakat_flags __ARGS((void));
2982 #endif
2983 static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
2984 static int check_opt_strings __ARGS((char_u *val, char **values, int));
2985 static int check_opt_wim __ARGS((void));
2988 * Initialize the options, first part.
2990 * Called only once from main(), just after creating the first buffer.
2992 void
2993 set_init_1()
2995 char_u *p;
2996 int opt_idx;
2997 long_u n;
2999 #ifdef FEAT_LANGMAP
3000 langmap_init();
3001 #endif
3003 /* Be Vi compatible by default */
3004 p_cp = TRUE;
3006 /* Use POSIX compatibility when $VIM_POSIX is set. */
3007 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
3009 set_string_default("cpo", (char_u *)CPO_ALL);
3010 set_string_default("shm", (char_u *)"A");
3014 * Find default value for 'shell' option.
3015 * Don't use it if it is empty.
3017 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
3018 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3019 # ifdef __EMX__
3020 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
3021 # endif
3022 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
3023 # ifdef WIN3264
3024 || ((p = default_shell()) != NULL && *p != NUL)
3025 # endif
3026 #endif
3028 set_string_default("sh", p);
3030 #ifdef FEAT_WILDIGN
3032 * Set the default for 'backupskip' to include environment variables for
3033 * temp files.
3036 # ifdef UNIX
3037 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3038 # else
3039 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3040 # endif
3041 int len;
3042 garray_T ga;
3043 int mustfree;
3045 ga_init2(&ga, 1, 100);
3046 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3048 mustfree = FALSE;
3049 # ifdef UNIX
3050 if (*names[n] == NUL)
3051 p = (char_u *)"/tmp";
3052 else
3053 # endif
3054 p = vim_getenv((char_u *)names[n], &mustfree);
3055 if (p != NULL && *p != NUL)
3057 /* First time count the NUL, otherwise count the ','. */
3058 len = (int)STRLEN(p) + 3;
3059 if (ga_grow(&ga, len) == OK)
3061 if (ga.ga_len > 0)
3062 STRCAT(ga.ga_data, ",");
3063 STRCAT(ga.ga_data, p);
3064 add_pathsep(ga.ga_data);
3065 STRCAT(ga.ga_data, "*");
3066 ga.ga_len += len;
3069 if (mustfree)
3070 vim_free(p);
3072 if (ga.ga_data != NULL)
3074 set_string_default("bsk", ga.ga_data);
3075 vim_free(ga.ga_data);
3078 #endif
3081 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3083 opt_idx = findoption((char_u *)"maxmemtot");
3084 if (opt_idx >= 0)
3086 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3087 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3088 #endif
3090 #ifdef HAVE_AVAIL_MEM
3091 /* Use amount of memory available at this moment. */
3092 n = (mch_avail_mem(FALSE) >> 11);
3093 #else
3094 # ifdef HAVE_TOTAL_MEM
3095 /* Use amount of memory available to Vim. */
3096 n = (mch_total_mem(FALSE) >> 1);
3097 # else
3098 n = (0x7fffffff >> 11);
3099 # endif
3100 #endif
3101 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3102 opt_idx = findoption((char_u *)"maxmem");
3103 if (opt_idx >= 0)
3105 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3106 if ((long)options[opt_idx].def_val[VI_DEFAULT] > n
3107 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3108 #endif
3109 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3114 #ifdef FEAT_GUI_W32
3115 /* force 'shortname' for Win32s */
3116 if (gui_is_win32s())
3118 opt_idx = findoption((char_u *)"shortname");
3119 if (opt_idx >= 0)
3120 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3122 #endif
3124 #ifdef FEAT_SEARCHPATH
3126 char_u *cdpath;
3127 char_u *buf;
3128 int i;
3129 int j;
3130 int mustfree = FALSE;
3132 /* Initialize the 'cdpath' option's default value. */
3133 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
3134 if (cdpath != NULL)
3136 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3137 if (buf != NULL)
3139 buf[0] = ','; /* start with ",", current dir first */
3140 j = 1;
3141 for (i = 0; cdpath[i] != NUL; ++i)
3143 if (vim_ispathlistsep(cdpath[i]))
3144 buf[j++] = ',';
3145 else
3147 if (cdpath[i] == ' ' || cdpath[i] == ',')
3148 buf[j++] = '\\';
3149 buf[j++] = cdpath[i];
3152 buf[j] = NUL;
3153 opt_idx = findoption((char_u *)"cdpath");
3154 if (opt_idx >= 0)
3156 options[opt_idx].def_val[VI_DEFAULT] = buf;
3157 options[opt_idx].flags |= P_DEF_ALLOCED;
3160 if (mustfree)
3161 vim_free(cdpath);
3164 #endif
3166 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3167 /* Set print encoding on platforms that don't default to latin1 */
3168 set_string_default("penc",
3169 # if defined(MSWIN) || defined(OS2)
3170 (char_u *)"cp1252"
3171 # else
3172 # ifdef VMS
3173 (char_u *)"dec-mcs"
3174 # else
3175 # ifdef EBCDIC
3176 (char_u *)"ebcdic-uk"
3177 # else
3178 # ifdef MAC
3179 (char_u *)"mac-roman"
3180 # else /* HPUX */
3181 (char_u *)"hp-roman8"
3182 # endif
3183 # endif
3184 # endif
3185 # endif
3187 #endif
3189 #ifdef FEAT_POSTSCRIPT
3190 /* 'printexpr' must be allocated to be able to evaluate it. */
3191 set_string_default("pexpr",
3192 # if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3193 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
3194 # else
3195 # ifdef VMS
3196 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3198 # else
3199 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3200 # endif
3201 # endif
3203 #endif
3206 * Set all the options (except the terminal options) to their default
3207 * value. Also set the global value for local options.
3209 set_options_default(0);
3211 #ifdef FEAT_GUI
3212 if (found_reverse_arg)
3213 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3214 #endif
3216 curbuf->b_p_initialized = TRUE;
3217 curbuf->b_p_ar = -1; /* no local 'autoread' value */
3218 check_buf_options(curbuf);
3219 check_win_options(curwin);
3220 check_options();
3222 /* Must be before option_expand(), because that one needs vim_isIDc() */
3223 didset_options();
3225 #ifdef FEAT_SPELL
3226 /* Use the current chartab for the generic chartab. */
3227 init_spell_chartab();
3228 #endif
3230 #ifdef FEAT_LINEBREAK
3232 * initialize the table for 'breakat'.
3234 fill_breakat_flags();
3235 #endif
3238 * Expand environment variables and things like "~" for the defaults.
3239 * If option_expand() returns non-NULL the variable is expanded. This can
3240 * only happen for non-indirect options.
3241 * Also set the default to the expanded value, so ":set" does not list
3242 * them.
3243 * Don't set the P_ALLOCED flag, because we don't want to free the
3244 * default.
3246 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3248 if ((options[opt_idx].flags & P_GETTEXT)
3249 && options[opt_idx].var != NULL)
3250 p = (char_u *)_(*(char **)options[opt_idx].var);
3251 else
3252 p = option_expand(opt_idx, NULL);
3253 if (p != NULL && (p = vim_strsave(p)) != NULL)
3255 *(char_u **)options[opt_idx].var = p;
3256 /* VIMEXP
3257 * Defaults for all expanded options are currently the same for Vi
3258 * and Vim. When this changes, add some code here! Also need to
3259 * split P_DEF_ALLOCED in two.
3261 if (options[opt_idx].flags & P_DEF_ALLOCED)
3262 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3263 options[opt_idx].def_val[VI_DEFAULT] = p;
3264 options[opt_idx].flags |= P_DEF_ALLOCED;
3268 /* Initialize the highlight_attr[] table. */
3269 highlight_changed();
3271 save_file_ff(curbuf); /* Buffer is unchanged */
3273 /* Parse default for 'wildmode' */
3274 check_opt_wim();
3276 #if defined(FEAT_ARABIC)
3277 /* Detect use of mlterm.
3278 * Mlterm is a terminal emulator akin to xterm that has some special
3279 * abilities (bidi namely).
3280 * NOTE: mlterm's author is being asked to 'set' a variable
3281 * instead of an environment variable due to inheritance.
3283 if (mch_getenv((char_u *)"MLTERM") != NULL)
3284 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3285 #endif
3287 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3288 /* Parse default for 'fillchars'. */
3289 (void)set_chars_option(&p_fcs);
3290 #endif
3292 #ifdef FEAT_CLIPBOARD
3293 /* Parse default for 'clipboard' */
3294 (void)check_clipboard_option();
3295 #endif
3297 #ifdef FEAT_MBYTE
3298 # if defined(WIN3264) && defined(FEAT_GETTEXT)
3300 * If $LANG isn't set, try to get a good value for it. This makes the
3301 * right language be used automatically. Don't do this for English.
3303 if (mch_getenv((char_u *)"LANG") == NULL)
3305 char buf[20];
3307 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3308 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3309 * only the first two. */
3310 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3311 (LPTSTR)buf, 20);
3312 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3314 /* There are a few exceptions (probably more) */
3315 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3316 STRCPY(buf, "zh_TW");
3317 else if (STRNICMP(buf, "chs", 3) == 0
3318 || STRNICMP(buf, "zhc", 3) == 0)
3319 STRCPY(buf, "zh_CN");
3320 else if (STRNICMP(buf, "jp", 2) == 0)
3321 STRCPY(buf, "ja");
3322 else
3323 buf[2] = NUL; /* truncate to two-letter code */
3324 vim_setenv("LANG", buf);
3327 # else
3328 # ifdef MACOS_CONVERT
3329 /* Moved to os_mac_conv.c to avoid dependency problems. */
3330 mac_lang_init();
3331 # endif
3332 # endif
3334 /* enc_locale() will try to find the encoding of the current locale. */
3335 p = enc_locale();
3336 if (p != NULL)
3338 char_u *save_enc;
3340 /* Try setting 'encoding' and check if the value is valid.
3341 * If not, go back to the default "latin1". */
3342 save_enc = p_enc;
3343 p_enc = p;
3344 if (STRCMP(p_enc, "gb18030") == 0)
3346 /* We don't support "gb18030", but "cp936" is a good substitute
3347 * for practical purposes, thus use that. It's not an alias to
3348 * still support conversion between gb18030 and utf-8. */
3349 p_enc = vim_strsave((char_u *)"cp936");
3350 vim_free(p);
3352 if (mb_init() == NULL)
3354 opt_idx = findoption((char_u *)"encoding");
3355 if (opt_idx >= 0)
3357 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3358 options[opt_idx].flags |= P_DEF_ALLOCED;
3361 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3362 || defined(VMS)
3363 if (STRCMP(p_enc, "latin1") == 0
3364 # ifdef FEAT_MBYTE
3365 || enc_utf8
3366 # endif
3369 /* Adjust the default for 'isprint' and 'iskeyword' to match
3370 * latin1. Also set the defaults for when 'nocompatible' is
3371 * set. */
3372 set_string_option_direct((char_u *)"isp", -1,
3373 ISP_LATIN1, OPT_FREE, SID_NONE);
3374 set_string_option_direct((char_u *)"isk", -1,
3375 ISK_LATIN1, OPT_FREE, SID_NONE);
3376 opt_idx = findoption((char_u *)"isp");
3377 if (opt_idx >= 0)
3378 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
3379 opt_idx = findoption((char_u *)"isk");
3380 if (opt_idx >= 0)
3381 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
3382 (void)init_chartab();
3384 #endif
3386 # if defined(WIN3264) && !defined(FEAT_GUI)
3387 /* Win32 console: When GetACP() returns a different value from
3388 * GetConsoleCP() set 'termencoding'. */
3389 if (GetACP() != GetConsoleCP())
3391 char buf[50];
3393 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3394 p_tenc = vim_strsave((char_u *)buf);
3395 if (p_tenc != NULL)
3397 opt_idx = findoption((char_u *)"termencoding");
3398 if (opt_idx >= 0)
3400 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3401 options[opt_idx].flags |= P_DEF_ALLOCED;
3403 convert_setup(&input_conv, p_tenc, p_enc);
3404 convert_setup(&output_conv, p_enc, p_tenc);
3406 else
3407 p_tenc = empty_option;
3409 # endif
3410 # if defined(WIN3264) && defined(FEAT_MBYTE)
3411 /* $HOME may have characters in active code page. */
3412 init_homedir();
3413 # endif
3415 else
3417 vim_free(p_enc);
3418 p_enc = save_enc;
3421 #endif
3423 #ifdef FEAT_MULTI_LANG
3424 /* Set the default for 'helplang'. */
3425 set_helplang_default(get_mess_lang());
3426 #endif
3430 * Set an option to its default value.
3431 * This does not take care of side effects!
3433 static void
3434 set_option_default(opt_idx, opt_flags, compatible)
3435 int opt_idx;
3436 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3437 int compatible; /* use Vi default value */
3439 char_u *varp; /* pointer to variable for current option */
3440 int dvi; /* index in def_val[] */
3441 long_u flags;
3442 long_u *flagsp;
3443 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3445 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3446 flags = options[opt_idx].flags;
3447 if (varp != NULL) /* skip hidden option, nothing to do for it */
3449 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3450 if (flags & P_STRING)
3452 /* Use set_string_option_direct() for local options to handle
3453 * freeing and allocating the value. */
3454 if (options[opt_idx].indir != PV_NONE)
3455 set_string_option_direct(NULL, opt_idx,
3456 options[opt_idx].def_val[dvi], opt_flags, 0);
3457 else
3459 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3460 free_string_option(*(char_u **)(varp));
3461 *(char_u **)varp = options[opt_idx].def_val[dvi];
3462 options[opt_idx].flags &= ~P_ALLOCED;
3465 else if (flags & P_NUM)
3467 if (options[opt_idx].indir == PV_SCROLL)
3468 win_comp_scroll(curwin);
3469 else
3471 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
3472 /* May also set global value for local option. */
3473 if (both)
3474 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3475 *(long *)varp;
3478 else /* P_BOOL */
3480 /* the cast to long is required for Manx C, long_i is needed for
3481 * MSVC */
3482 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
3483 #ifdef UNIX
3484 /* 'modeline' defaults to off for root */
3485 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3486 *(int *)varp = FALSE;
3487 #endif
3488 /* May also set global value for local option. */
3489 if (both)
3490 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3491 *(int *)varp;
3494 /* The default value is not insecure. */
3495 flagsp = insecure_flag(opt_idx, opt_flags);
3496 *flagsp = *flagsp & ~P_INSECURE;
3499 #ifdef FEAT_EVAL
3500 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
3501 #endif
3505 * Set all options (except terminal options) to their default value.
3507 static void
3508 set_options_default(opt_flags)
3509 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3511 int i;
3512 #ifdef FEAT_WINDOWS
3513 win_T *wp;
3514 tabpage_T *tp;
3515 #endif
3517 for (i = 0; !istermoption(&options[i]); i++)
3518 if (!(options[i].flags & P_NODEFAULT))
3519 set_option_default(i, opt_flags, p_cp);
3521 #ifdef FEAT_WINDOWS
3522 /* The 'scroll' option must be computed for all windows. */
3523 FOR_ALL_TAB_WINDOWS(tp, wp)
3524 win_comp_scroll(wp);
3525 #else
3526 win_comp_scroll(curwin);
3527 #endif
3531 * Set the Vi-default value of a string option.
3532 * Used for 'sh', 'backupskip' and 'term'.
3534 void
3535 set_string_default(name, val)
3536 char *name;
3537 char_u *val;
3539 char_u *p;
3540 int opt_idx;
3542 p = vim_strsave(val);
3543 if (p != NULL) /* we don't want a NULL */
3545 opt_idx = findoption((char_u *)name);
3546 if (opt_idx >= 0)
3548 if (options[opt_idx].flags & P_DEF_ALLOCED)
3549 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3550 options[opt_idx].def_val[VI_DEFAULT] = p;
3551 options[opt_idx].flags |= P_DEF_ALLOCED;
3557 * Set the Vi-default value of a number option.
3558 * Used for 'lines' and 'columns'.
3560 void
3561 set_number_default(name, val)
3562 char *name;
3563 long val;
3565 int opt_idx;
3567 opt_idx = findoption((char_u *)name);
3568 if (opt_idx >= 0)
3569 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3572 #if defined(EXITFREE) || defined(PROTO)
3574 * Free all options.
3576 void
3577 free_all_options()
3579 int i;
3581 for (i = 0; !istermoption(&options[i]); i++)
3583 if (options[i].indir == PV_NONE)
3585 /* global option: free value and default value. */
3586 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3587 free_string_option(*(char_u **)options[i].var);
3588 if (options[i].flags & P_DEF_ALLOCED)
3589 free_string_option(options[i].def_val[VI_DEFAULT]);
3591 else if (options[i].var != VAR_WIN
3592 && (options[i].flags & P_STRING))
3593 /* buffer-local option: free global value */
3594 free_string_option(*(char_u **)options[i].var);
3597 #endif
3601 * Initialize the options, part two: After getting Rows and Columns and
3602 * setting 'term'.
3604 void
3605 set_init_2()
3607 int idx;
3610 * 'scroll' defaults to half the window height. Note that this default is
3611 * wrong when the window height changes.
3613 set_number_default("scroll", (long)((long_u)Rows >> 1));
3614 idx = findoption((char_u *)"scroll");
3615 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
3616 set_option_default(idx, OPT_LOCAL, p_cp);
3617 comp_col();
3620 * 'window' is only for backwards compatibility with Vi.
3621 * Default is Rows - 1.
3623 if (!option_was_set((char_u *)"window"))
3624 p_window = Rows - 1;
3625 set_number_default("window", Rows - 1);
3627 /* For DOS console the default is always black. */
3628 #if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
3630 * If 'background' wasn't set by the user, try guessing the value,
3631 * depending on the terminal name. Only need to check for terminals
3632 * with a dark background, that can handle color.
3634 idx = findoption((char_u *)"bg");
3635 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3636 && *term_bg_default() == 'd')
3638 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
3639 /* don't mark it as set, when starting the GUI it may be
3640 * changed again */
3641 options[idx].flags &= ~P_WAS_SET;
3643 #endif
3645 #ifdef CURSOR_SHAPE
3646 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3647 #endif
3648 #ifdef FEAT_MOUSESHAPE
3649 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3650 #endif
3651 #ifdef FEAT_PRINTER
3652 (void)parse_printoptions(); /* parse 'printoptions' default value */
3653 #endif
3657 * Return "dark" or "light" depending on the kind of terminal.
3658 * This is just guessing! Recognized are:
3659 * "linux" Linux console
3660 * "screen.linux" Linux console with screen
3661 * "cygwin" Cygwin shell
3662 * "putty" Putty program
3663 * We also check the COLORFGBG environment variable, which is set by
3664 * rxvt and derivatives. This variable contains either two or three
3665 * values separated by semicolons; we want the last value in either
3666 * case. If this value is 0-6 or 8, our background is dark.
3668 static char_u *
3669 term_bg_default()
3671 #if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3672 /* DOS console nearly always black */
3673 return (char_u *)"dark";
3674 #else
3675 char_u *p;
3677 if (STRCMP(T_NAME, "linux") == 0
3678 || STRCMP(T_NAME, "screen.linux") == 0
3679 || STRCMP(T_NAME, "cygwin") == 0
3680 || STRCMP(T_NAME, "putty") == 0
3681 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3682 && (p = vim_strrchr(p, ';')) != NULL
3683 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3684 && p[2] == NUL))
3685 return (char_u *)"dark";
3686 return (char_u *)"light";
3687 #endif
3691 * Initialize the options, part three: After reading the .vimrc
3693 void
3694 set_init_3()
3696 #if defined(UNIX) || defined(OS2) || defined(WIN3264)
3698 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3699 * This is done after other initializations, where 'shell' might have been
3700 * set, but only if they have not been set before.
3702 char_u *p;
3703 int idx_srr;
3704 int do_srr;
3705 #ifdef FEAT_QUICKFIX
3706 int idx_sp;
3707 int do_sp;
3708 #endif
3710 idx_srr = findoption((char_u *)"srr");
3711 if (idx_srr < 0)
3712 do_srr = FALSE;
3713 else
3714 do_srr = !(options[idx_srr].flags & P_WAS_SET);
3715 #ifdef FEAT_QUICKFIX
3716 idx_sp = findoption((char_u *)"sp");
3717 if (idx_sp < 0)
3718 do_sp = FALSE;
3719 else
3720 do_sp = !(options[idx_sp].flags & P_WAS_SET);
3721 #endif
3724 * Isolate the name of the shell:
3725 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
3726 * - Remove any argument. E.g., "csh -f" -> "csh".
3728 p = gettail(p_sh);
3729 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
3730 if (p != NULL)
3733 * Default for p_sp is "| tee", for p_srr is ">".
3734 * For known shells it is changed here to include stderr.
3736 if ( fnamecmp(p, "csh") == 0
3737 || fnamecmp(p, "tcsh") == 0
3738 # if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3739 || fnamecmp(p, "csh.exe") == 0
3740 || fnamecmp(p, "tcsh.exe") == 0
3741 # endif
3744 #if defined(FEAT_QUICKFIX)
3745 if (do_sp)
3747 # ifdef WIN3264
3748 p_sp = (char_u *)">&";
3749 # else
3750 p_sp = (char_u *)"|& tee";
3751 # endif
3752 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3754 #endif
3755 if (do_srr)
3757 p_srr = (char_u *)">&";
3758 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3761 else
3762 # ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3763 if ( fnamecmp(p, "sh") == 0
3764 || fnamecmp(p, "ksh") == 0
3765 || fnamecmp(p, "zsh") == 0
3766 || fnamecmp(p, "zsh-beta") == 0
3767 || fnamecmp(p, "bash") == 0
3768 # ifdef WIN3264
3769 || fnamecmp(p, "cmd") == 0
3770 || fnamecmp(p, "sh.exe") == 0
3771 || fnamecmp(p, "ksh.exe") == 0
3772 || fnamecmp(p, "zsh.exe") == 0
3773 || fnamecmp(p, "zsh-beta.exe") == 0
3774 || fnamecmp(p, "bash.exe") == 0
3775 || fnamecmp(p, "cmd.exe") == 0
3776 # endif
3778 # endif
3780 #if defined(FEAT_QUICKFIX)
3781 if (do_sp)
3783 # ifdef WIN3264
3784 p_sp = (char_u *)">%s 2>&1";
3785 # else
3786 p_sp = (char_u *)"2>&1| tee";
3787 # endif
3788 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3790 #endif
3791 if (do_srr)
3793 p_srr = (char_u *)">%s 2>&1";
3794 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3797 vim_free(p);
3799 #endif
3801 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3803 * Set 'shellcmdflag and 'shellquote' depending on the 'shell' option.
3804 * This is done after other initializations, where 'shell' might have been
3805 * set, but only if they have not been set before. Default for p_shcf is
3806 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3807 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3808 * command.com. And for Win32 we need to set p_sxq instead.
3810 if (strstr((char *)gettail(p_sh), "sh") != NULL)
3812 int idx3;
3814 idx3 = findoption((char_u *)"shcf");
3815 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3817 p_shcf = (char_u *)"-c";
3818 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3821 # ifndef DJGPP
3822 # ifdef WIN3264
3823 /* Somehow Win32 requires the quotes around the redirection too */
3824 idx3 = findoption((char_u *)"sxq");
3825 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3827 p_sxq = (char_u *)"\"";
3828 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3830 # else
3831 idx3 = findoption((char_u *)"shq");
3832 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3834 p_shq = (char_u *)"\"";
3835 options[idx3].def_val[VI_DEFAULT] = p_shq;
3837 # endif
3838 # endif
3840 #endif
3842 #ifdef FEAT_TITLE
3843 set_title_defaults();
3844 #endif
3847 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
3849 * When 'helplang' is still at its default value, set it to "lang".
3850 * Only the first two characters of "lang" are used.
3852 void
3853 set_helplang_default(lang)
3854 char_u *lang;
3856 int idx;
3858 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
3859 return;
3860 idx = findoption((char_u *)"hlg");
3861 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
3863 if (options[idx].flags & P_ALLOCED)
3864 free_string_option(p_hlg);
3865 p_hlg = vim_strsave(lang);
3866 if (p_hlg == NULL)
3867 p_hlg = empty_option;
3868 else
3870 /* zh_CN becomes "cn", zh_TW becomes "tw". */
3871 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
3873 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
3874 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
3876 p_hlg[2] = NUL;
3878 options[idx].flags |= P_ALLOCED;
3881 #endif
3883 #ifdef FEAT_GUI
3884 static char_u *gui_bg_default __ARGS((void));
3886 static char_u *
3887 gui_bg_default()
3889 if (gui_get_lightness(gui.back_pixel) < 127)
3890 return (char_u *)"dark";
3891 return (char_u *)"light";
3895 * Option initializations that can only be done after opening the GUI window.
3897 void
3898 init_gui_options()
3900 /* Set the 'background' option according to the lightness of the
3901 * background color, unless the user has set it already. */
3902 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
3904 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
3905 highlight_changed();
3908 #endif
3910 #ifdef FEAT_TITLE
3912 * 'title' and 'icon' only default to true if they have not been set or reset
3913 * in .vimrc and we can read the old value.
3914 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
3915 * they can be reset. This reduces startup time when using X on a remote
3916 * machine.
3918 void
3919 set_title_defaults()
3921 int idx1;
3922 long val;
3925 * If GUI is (going to be) used, we can always set the window title and
3926 * icon name. Saves a bit of time, because the X11 display server does
3927 * not need to be contacted.
3929 idx1 = findoption((char_u *)"title");
3930 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
3932 #ifdef FEAT_GUI
3933 if (gui.starting || gui.in_use)
3934 val = TRUE;
3935 else
3936 #endif
3937 val = mch_can_restore_title();
3938 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3939 p_title = val;
3941 idx1 = findoption((char_u *)"icon");
3942 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
3944 #ifdef FEAT_GUI
3945 if (gui.starting || gui.in_use)
3946 val = TRUE;
3947 else
3948 #endif
3949 val = mch_can_restore_icon();
3950 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3951 p_icon = val;
3954 #endif
3957 * Parse 'arg' for option settings.
3959 * 'arg' may be IObuff, but only when no errors can be present and option
3960 * does not need to be expanded with option_expand().
3961 * "opt_flags":
3962 * 0 for ":set"
3963 * OPT_GLOBAL for ":setglobal"
3964 * OPT_LOCAL for ":setlocal" and a modeline
3965 * OPT_MODELINE for a modeline
3966 * OPT_WINONLY to only set window-local options
3967 * OPT_NOWIN to skip setting window-local options
3969 * returns FAIL if an error is detected, OK otherwise
3972 do_set(arg, opt_flags)
3973 char_u *arg; /* option string (may be written to!) */
3974 int opt_flags;
3976 int opt_idx;
3977 char_u *errmsg;
3978 char_u errbuf[80];
3979 char_u *startarg;
3980 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
3981 int nextchar; /* next non-white char after option name */
3982 int afterchar; /* character just after option name */
3983 int len;
3984 int i;
3985 long value;
3986 int key;
3987 long_u flags; /* flags for current option */
3988 char_u *varp = NULL; /* pointer to variable for current option */
3989 int did_show = FALSE; /* already showed one value */
3990 int adding; /* "opt+=arg" */
3991 int prepending; /* "opt^=arg" */
3992 int removing; /* "opt-=arg" */
3993 int cp_val = 0;
3994 char_u key_name[2];
3996 if (*arg == NUL)
3998 showoptions(0, opt_flags);
3999 did_show = TRUE;
4000 goto theend;
4003 while (*arg != NUL) /* loop to process all options */
4005 errmsg = NULL;
4006 startarg = arg; /* remember for error message */
4008 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4009 && !(opt_flags & OPT_MODELINE))
4012 * ":set all" show all options.
4013 * ":set all&" set all options to their default value.
4015 arg += 3;
4016 if (*arg == '&')
4018 ++arg;
4019 /* Only for :set command set global value of local options. */
4020 set_options_default(OPT_FREE | opt_flags);
4022 else
4024 showoptions(1, opt_flags);
4025 did_show = TRUE;
4028 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
4030 showoptions(2, opt_flags);
4031 show_termcodes();
4032 did_show = TRUE;
4033 arg += 7;
4035 else
4037 prefix = 1;
4038 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
4040 prefix = 0;
4041 arg += 2;
4043 else if (STRNCMP(arg, "inv", 3) == 0)
4045 prefix = 2;
4046 arg += 3;
4049 /* find end of name */
4050 key = 0;
4051 if (*arg == '<')
4053 nextchar = 0;
4054 opt_idx = -1;
4055 /* look out for <t_>;> */
4056 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4057 len = 5;
4058 else
4060 len = 1;
4061 while (arg[len] != NUL && arg[len] != '>')
4062 ++len;
4064 if (arg[len] != '>')
4066 errmsg = e_invarg;
4067 goto skip;
4069 arg[len] = NUL; /* put NUL after name */
4070 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4071 opt_idx = findoption(arg + 1);
4072 arg[len++] = '>'; /* restore '>' */
4073 if (opt_idx == -1)
4074 key = find_key_option(arg + 1);
4076 else
4078 len = 0;
4080 * The two characters after "t_" may not be alphanumeric.
4082 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4083 len = 4;
4084 else
4085 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4086 ++len;
4087 nextchar = arg[len];
4088 arg[len] = NUL; /* put NUL after name */
4089 opt_idx = findoption(arg);
4090 arg[len] = nextchar; /* restore nextchar */
4091 if (opt_idx == -1)
4092 key = find_key_option(arg);
4095 /* remember character after option name */
4096 afterchar = arg[len];
4098 /* skip white space, allow ":set ai ?" */
4099 while (vim_iswhite(arg[len]))
4100 ++len;
4102 adding = FALSE;
4103 prepending = FALSE;
4104 removing = FALSE;
4105 if (arg[len] != NUL && arg[len + 1] == '=')
4107 if (arg[len] == '+')
4109 adding = TRUE; /* "+=" */
4110 ++len;
4112 else if (arg[len] == '^')
4114 prepending = TRUE; /* "^=" */
4115 ++len;
4117 else if (arg[len] == '-')
4119 removing = TRUE; /* "-=" */
4120 ++len;
4123 nextchar = arg[len];
4125 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4127 errmsg = (char_u *)N_("E518: Unknown option");
4128 goto skip;
4131 if (opt_idx >= 0)
4133 if (options[opt_idx].var == NULL) /* hidden option: skip */
4135 /* Only give an error message when requesting the value of
4136 * a hidden option, ignore setting it. */
4137 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4138 && (!(options[opt_idx].flags & P_BOOL)
4139 || nextchar == '?'))
4140 errmsg = (char_u *)N_("E519: Option not supported");
4141 goto skip;
4144 flags = options[opt_idx].flags;
4145 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4147 else
4149 flags = P_STRING;
4150 if (key < 0)
4152 key_name[0] = KEY2TERMCAP0(key);
4153 key_name[1] = KEY2TERMCAP1(key);
4155 else
4157 key_name[0] = KS_KEY;
4158 key_name[1] = (key & 0xff);
4162 /* Skip all options that are not window-local (used when showing
4163 * an already loaded buffer in a window). */
4164 if ((opt_flags & OPT_WINONLY)
4165 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4166 goto skip;
4168 /* Skip all options that are window-local (used for :vimgrep). */
4169 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4170 && options[opt_idx].var == VAR_WIN)
4171 goto skip;
4173 /* Disallow changing some options from modelines. */
4174 if (opt_flags & OPT_MODELINE)
4176 if (flags & P_SECURE)
4178 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4179 goto skip;
4181 #ifdef FEAT_DIFF
4182 /* In diff mode some options are overruled. This avoids that
4183 * 'foldmethod' becomes "marker" instead of "diff" and that
4184 * "wrap" gets set. */
4185 if (curwin->w_p_diff
4186 && (options[opt_idx].indir == PV_FDM
4187 || options[opt_idx].indir == PV_WRAP))
4188 goto skip;
4189 #endif
4192 #ifdef HAVE_SANDBOX
4193 /* Disallow changing some options in the sandbox */
4194 if (sandbox != 0 && (flags & P_SECURE))
4196 errmsg = (char_u *)_(e_sandbox);
4197 goto skip;
4199 #endif
4201 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4203 arg += len;
4204 cp_val = p_cp;
4205 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4207 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4209 cp_val = FALSE;
4210 arg += 3;
4212 else /* "opt&vi": set to Vi default */
4214 cp_val = TRUE;
4215 arg += 2;
4218 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4219 && arg[1] != NUL && !vim_iswhite(arg[1]))
4221 errmsg = e_trailing;
4222 goto skip;
4227 * allow '=' and ':' as MSDOS command.com allows only one
4228 * '=' character per "set" command line. grrr. (jw)
4230 if (nextchar == '?'
4231 || (prefix == 1
4232 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4233 && !(flags & P_BOOL)))
4236 * print value
4238 if (did_show)
4239 msg_putchar('\n'); /* cursor below last one */
4240 else
4242 gotocmdline(TRUE); /* cursor at status line */
4243 did_show = TRUE; /* remember that we did a line */
4245 if (opt_idx >= 0)
4247 showoneopt(&options[opt_idx], opt_flags);
4248 #ifdef FEAT_EVAL
4249 if (p_verbose > 0)
4251 /* Mention where the option was last set. */
4252 if (varp == options[opt_idx].var)
4253 last_set_msg(options[opt_idx].scriptID);
4254 else if ((int)options[opt_idx].indir & PV_WIN)
4255 last_set_msg(curwin->w_p_scriptID[
4256 (int)options[opt_idx].indir & PV_MASK]);
4257 else if ((int)options[opt_idx].indir & PV_BUF)
4258 last_set_msg(curbuf->b_p_scriptID[
4259 (int)options[opt_idx].indir & PV_MASK]);
4261 #endif
4263 else
4265 char_u *p;
4267 p = find_termcode(key_name);
4268 if (p == NULL)
4270 errmsg = (char_u *)N_("E518: Unknown option");
4271 goto skip;
4273 else
4274 (void)show_one_termcode(key_name, p, TRUE);
4276 if (nextchar != '?'
4277 && nextchar != NUL && !vim_iswhite(afterchar))
4278 errmsg = e_trailing;
4280 else
4282 if (flags & P_BOOL) /* boolean */
4284 if (nextchar == '=' || nextchar == ':')
4286 errmsg = e_invarg;
4287 goto skip;
4291 * ":set opt!": invert
4292 * ":set opt&": reset to default value
4293 * ":set opt<": reset to global value
4295 if (nextchar == '!')
4296 value = *(int *)(varp) ^ 1;
4297 else if (nextchar == '&')
4298 value = (int)(long)(long_i)options[opt_idx].def_val[
4299 ((flags & P_VI_DEF) || cp_val)
4300 ? VI_DEFAULT : VIM_DEFAULT];
4301 else if (nextchar == '<')
4303 /* For 'autoread' -1 means to use global value. */
4304 if ((int *)varp == &curbuf->b_p_ar
4305 && opt_flags == OPT_LOCAL)
4306 value = -1;
4307 else
4308 value = *(int *)get_varp_scope(&(options[opt_idx]),
4309 OPT_GLOBAL);
4311 else
4314 * ":set invopt": invert
4315 * ":set opt" or ":set noopt": set or reset
4317 if (nextchar != NUL && !vim_iswhite(afterchar))
4319 errmsg = e_trailing;
4320 goto skip;
4322 if (prefix == 2) /* inv */
4323 value = *(int *)(varp) ^ 1;
4324 else
4325 value = prefix;
4328 errmsg = set_bool_option(opt_idx, varp, (int)value,
4329 opt_flags);
4331 else /* numeric or string */
4333 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4334 || prefix != 1)
4336 errmsg = e_invarg;
4337 goto skip;
4340 if (flags & P_NUM) /* numeric */
4343 * Different ways to set a number option:
4344 * & set to default value
4345 * < set to global value
4346 * <xx> accept special key codes for 'wildchar'
4347 * c accept any non-digit for 'wildchar'
4348 * [-]0-9 set number
4349 * other error
4351 ++arg;
4352 if (nextchar == '&')
4353 value = (long)(long_i)options[opt_idx].def_val[
4354 ((flags & P_VI_DEF) || cp_val)
4355 ? VI_DEFAULT : VIM_DEFAULT];
4356 else if (nextchar == '<')
4357 value = *(long *)get_varp_scope(&(options[opt_idx]),
4358 OPT_GLOBAL);
4359 else if (((long *)varp == &p_wc
4360 || (long *)varp == &p_wcm)
4361 && (*arg == '<'
4362 || *arg == '^'
4363 || ((!arg[1] || vim_iswhite(arg[1]))
4364 && !VIM_ISDIGIT(*arg))))
4366 value = string_to_key(arg);
4367 if (value == 0 && (long *)varp != &p_wcm)
4369 errmsg = e_invarg;
4370 goto skip;
4373 /* allow negative numbers (for 'undolevels') */
4374 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4376 i = 0;
4377 if (*arg == '-')
4378 i = 1;
4379 #ifdef HAVE_STRTOL
4380 value = strtol((char *)arg, NULL, 0);
4381 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
4382 i += 2;
4383 #else
4384 value = atol((char *)arg);
4385 #endif
4386 while (VIM_ISDIGIT(arg[i]))
4387 ++i;
4388 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4390 errmsg = e_invarg;
4391 goto skip;
4394 else
4396 errmsg = (char_u *)N_("E521: Number required after =");
4397 goto skip;
4400 if (adding)
4401 value = *(long *)varp + value;
4402 if (prepending)
4403 value = *(long *)varp * value;
4404 if (removing)
4405 value = *(long *)varp - value;
4406 errmsg = set_num_option(opt_idx, varp, value,
4407 errbuf, sizeof(errbuf), opt_flags);
4409 else if (opt_idx >= 0) /* string */
4411 char_u *save_arg = NULL;
4412 char_u *s = NULL;
4413 char_u *oldval; /* previous value if *varp */
4414 char_u *newval;
4415 char_u *origval;
4416 unsigned newlen;
4417 int comma;
4418 int bs;
4419 int new_value_alloced; /* new string option
4420 was allocated */
4422 /* When using ":set opt=val" for a global option
4423 * with a local value the local value will be
4424 * reset, use the global value here. */
4425 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
4426 && ((int)options[opt_idx].indir & PV_BOTH))
4427 varp = options[opt_idx].var;
4429 /* The old value is kept until we are sure that the
4430 * new value is valid. */
4431 oldval = *(char_u **)varp;
4432 if (nextchar == '&') /* set to default val */
4434 newval = options[opt_idx].def_val[
4435 ((flags & P_VI_DEF) || cp_val)
4436 ? VI_DEFAULT : VIM_DEFAULT];
4437 if ((char_u **)varp == &p_bg)
4439 /* guess the value of 'background' */
4440 #ifdef FEAT_GUI
4441 if (gui.in_use)
4442 newval = gui_bg_default();
4443 else
4444 #endif
4445 newval = term_bg_default();
4448 /* expand environment variables and ~ (since the
4449 * default value was already expanded, only
4450 * required when an environment variable was set
4451 * later */
4452 if (newval == NULL)
4453 newval = empty_option;
4454 else
4456 s = option_expand(opt_idx, newval);
4457 if (s == NULL)
4458 s = newval;
4459 newval = vim_strsave(s);
4461 new_value_alloced = TRUE;
4463 else if (nextchar == '<') /* set to global val */
4465 newval = vim_strsave(*(char_u **)get_varp_scope(
4466 &(options[opt_idx]), OPT_GLOBAL));
4467 new_value_alloced = TRUE;
4469 else
4471 ++arg; /* jump to after the '=' or ':' */
4474 * Set 'keywordprg' to ":help" if an empty
4475 * value was passed to :set by the user.
4476 * Misuse errbuf[] for the resulting string.
4478 if (varp == (char_u *)&p_kp
4479 && (*arg == NUL || *arg == ' '))
4481 STRCPY(errbuf, ":help");
4482 save_arg = arg;
4483 arg = errbuf;
4486 * Convert 'whichwrap' number to string, for
4487 * backwards compatibility with Vim 3.0.
4488 * Misuse errbuf[] for the resulting string.
4490 else if (varp == (char_u *)&p_ww
4491 && VIM_ISDIGIT(*arg))
4493 *errbuf = NUL;
4494 i = getdigits(&arg);
4495 if (i & 1)
4496 STRCAT(errbuf, "b,");
4497 if (i & 2)
4498 STRCAT(errbuf, "s,");
4499 if (i & 4)
4500 STRCAT(errbuf, "h,l,");
4501 if (i & 8)
4502 STRCAT(errbuf, "<,>,");
4503 if (i & 16)
4504 STRCAT(errbuf, "[,],");
4505 if (*errbuf != NUL) /* remove trailing , */
4506 errbuf[STRLEN(errbuf) - 1] = NUL;
4507 save_arg = arg;
4508 arg = errbuf;
4511 * Remove '>' before 'dir' and 'bdir', for
4512 * backwards compatibility with version 3.0
4514 else if ( *arg == '>'
4515 && (varp == (char_u *)&p_dir
4516 || varp == (char_u *)&p_bdir))
4518 ++arg;
4521 /* When setting the local value of a global
4522 * option, the old value may be the global value. */
4523 if (((int)options[opt_idx].indir & PV_BOTH)
4524 && (opt_flags & OPT_LOCAL))
4525 origval = *(char_u **)get_varp(
4526 &options[opt_idx]);
4527 else
4528 origval = oldval;
4531 * Copy the new string into allocated memory.
4532 * Can't use set_string_option_direct(), because
4533 * we need to remove the backslashes.
4535 /* get a bit too much */
4536 newlen = (unsigned)STRLEN(arg) + 1;
4537 if (adding || prepending || removing)
4538 newlen += (unsigned)STRLEN(origval) + 1;
4539 newval = alloc(newlen);
4540 if (newval == NULL) /* out of mem, don't change */
4541 break;
4542 s = newval;
4545 * Copy the string, skip over escaped chars.
4546 * For MS-DOS and WIN32 backslashes before normal
4547 * file name characters are not removed, and keep
4548 * backslash at start, for "\\machine\path", but
4549 * do remove it for "\\\\machine\\path".
4550 * The reverse is found in ExpandOldSetting().
4552 while (*arg && !vim_iswhite(*arg))
4554 if (*arg == '\\' && arg[1] != NUL
4555 #ifdef BACKSLASH_IN_FILENAME
4556 && !((flags & P_EXPAND)
4557 && vim_isfilec(arg[1])
4558 && (arg[1] != '\\'
4559 || (s == newval
4560 && arg[2] != '\\')))
4561 #endif
4563 ++arg; /* remove backslash */
4564 #ifdef FEAT_MBYTE
4565 if (has_mbyte
4566 && (i = (*mb_ptr2len)(arg)) > 1)
4568 /* copy multibyte char */
4569 mch_memmove(s, arg, (size_t)i);
4570 arg += i;
4571 s += i;
4573 else
4574 #endif
4575 *s++ = *arg++;
4577 *s = NUL;
4580 * Expand environment variables and ~.
4581 * Don't do it when adding without inserting a
4582 * comma.
4584 if (!(adding || prepending || removing)
4585 || (flags & P_COMMA))
4587 s = option_expand(opt_idx, newval);
4588 if (s != NULL)
4590 vim_free(newval);
4591 newlen = (unsigned)STRLEN(s) + 1;
4592 if (adding || prepending || removing)
4593 newlen += (unsigned)STRLEN(origval) + 1;
4594 newval = alloc(newlen);
4595 if (newval == NULL)
4596 break;
4597 STRCPY(newval, s);
4601 /* locate newval[] in origval[] when removing it
4602 * and when adding to avoid duplicates */
4603 i = 0; /* init for GCC */
4604 if (removing || (flags & P_NODUP))
4606 i = (int)STRLEN(newval);
4607 bs = 0;
4608 for (s = origval; *s; ++s)
4610 if ((!(flags & P_COMMA)
4611 || s == origval
4612 || (s[-1] == ',' && !(bs & 1)))
4613 && STRNCMP(s, newval, i) == 0
4614 && (!(flags & P_COMMA)
4615 || s[i] == ','
4616 || s[i] == NUL))
4617 break;
4618 /* Count backspaces. Only a comma with an
4619 * even number of backspaces before it is
4620 * recognized as a separator */
4621 if (s > origval && s[-1] == '\\')
4622 ++bs;
4623 else
4624 bs = 0;
4627 /* do not add if already there */
4628 if ((adding || prepending) && *s)
4630 prepending = FALSE;
4631 adding = FALSE;
4632 STRCPY(newval, origval);
4636 /* concatenate the two strings; add a ',' if
4637 * needed */
4638 if (adding || prepending)
4640 comma = ((flags & P_COMMA) && *origval != NUL
4641 && *newval != NUL);
4642 if (adding)
4644 i = (int)STRLEN(origval);
4645 mch_memmove(newval + i + comma, newval,
4646 STRLEN(newval) + 1);
4647 mch_memmove(newval, origval, (size_t)i);
4649 else
4651 i = (int)STRLEN(newval);
4652 STRMOVE(newval + i + comma, origval);
4654 if (comma)
4655 newval[i] = ',';
4658 /* Remove newval[] from origval[]. (Note: "i" has
4659 * been set above and is used here). */
4660 if (removing)
4662 STRCPY(newval, origval);
4663 if (*s)
4665 /* may need to remove a comma */
4666 if (flags & P_COMMA)
4668 if (s == origval)
4670 /* include comma after string */
4671 if (s[i] == ',')
4672 ++i;
4674 else
4676 /* include comma before string */
4677 --s;
4678 ++i;
4681 STRMOVE(newval + (s - origval), s + i);
4685 if (flags & P_FLAGLIST)
4687 /* Remove flags that appear twice. */
4688 for (s = newval; *s; ++s)
4689 if ((!(flags & P_COMMA) || *s != ',')
4690 && vim_strchr(s + 1, *s) != NULL)
4692 STRMOVE(s, s + 1);
4693 --s;
4697 if (save_arg != NULL) /* number for 'whichwrap' */
4698 arg = save_arg;
4699 new_value_alloced = TRUE;
4702 /* Set the new value. */
4703 *(char_u **)(varp) = newval;
4705 /* Handle side effects, and set the global value for
4706 * ":set" on local options. */
4707 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4708 new_value_alloced, oldval, errbuf, opt_flags);
4710 /* If error detected, print the error message. */
4711 if (errmsg != NULL)
4712 goto skip;
4714 else /* key code option */
4716 char_u *p;
4718 if (nextchar == '&')
4720 if (add_termcap_entry(key_name, TRUE) == FAIL)
4721 errmsg = (char_u *)N_("E522: Not found in termcap");
4723 else
4725 ++arg; /* jump to after the '=' or ':' */
4726 for (p = arg; *p && !vim_iswhite(*p); ++p)
4727 if (*p == '\\' && p[1] != NUL)
4728 ++p;
4729 nextchar = *p;
4730 *p = NUL;
4731 add_termcode(key_name, arg, FALSE);
4732 *p = nextchar;
4734 if (full_screen)
4735 ttest(FALSE);
4736 redraw_all_later(CLEAR);
4740 if (opt_idx >= 0)
4741 did_set_option(opt_idx, opt_flags,
4742 !prepending && !adding && !removing);
4745 skip:
4747 * Advance to next argument.
4748 * - skip until a blank found, taking care of backslashes
4749 * - skip blanks
4750 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4752 for (i = 0; i < 2 ; ++i)
4754 while (*arg != NUL && !vim_iswhite(*arg))
4755 if (*arg++ == '\\' && *arg != NUL)
4756 ++arg;
4757 arg = skipwhite(arg);
4758 if (*arg != '=')
4759 break;
4763 if (errmsg != NULL)
4765 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
4766 i = (int)STRLEN(IObuff) + 2;
4767 if (i + (arg - startarg) < IOSIZE)
4769 /* append the argument with the error */
4770 STRCAT(IObuff, ": ");
4771 mch_memmove(IObuff + i, startarg, (arg - startarg));
4772 IObuff[i + (arg - startarg)] = NUL;
4774 /* make sure all characters are printable */
4775 trans_characters(IObuff, IOSIZE);
4777 ++no_wait_return; /* wait_return done later */
4778 emsg(IObuff); /* show error highlighted */
4779 --no_wait_return;
4781 return FAIL;
4784 arg = skipwhite(arg);
4787 theend:
4788 if (silent_mode && did_show)
4790 /* After displaying option values in silent mode. */
4791 silent_mode = FALSE;
4792 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
4793 msg_putchar('\n');
4794 cursor_on(); /* msg_start() switches it off */
4795 out_flush();
4796 silent_mode = TRUE;
4797 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
4800 return OK;
4804 * Call this when an option has been given a new value through a user command.
4805 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4807 static void
4808 did_set_option(opt_idx, opt_flags, new_value)
4809 int opt_idx;
4810 int opt_flags; /* possibly with OPT_MODELINE */
4811 int new_value; /* value was replaced completely */
4813 long_u *p;
4815 options[opt_idx].flags |= P_WAS_SET;
4817 /* When an option is set in the sandbox, from a modeline or in secure mode
4818 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
4819 * flag. */
4820 p = insecure_flag(opt_idx, opt_flags);
4821 if (secure
4822 #ifdef HAVE_SANDBOX
4823 || sandbox != 0
4824 #endif
4825 || (opt_flags & OPT_MODELINE))
4826 *p = *p | P_INSECURE;
4827 else if (new_value)
4828 *p = *p & ~P_INSECURE;
4831 static char_u *
4832 illegal_char(errbuf, c)
4833 char_u *errbuf;
4834 int c;
4836 if (errbuf == NULL)
4837 return (char_u *)"";
4838 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
4839 (char *)transchar(c));
4840 return errbuf;
4844 * Convert a key name or string into a key value.
4845 * Used for 'wildchar' and 'cedit' options.
4847 static int
4848 string_to_key(arg)
4849 char_u *arg;
4851 if (*arg == '<')
4852 return find_key_option(arg + 1);
4853 if (*arg == '^')
4854 return Ctrl_chr(arg[1]);
4855 return *arg;
4858 #ifdef FEAT_CMDWIN
4860 * Check value of 'cedit' and set cedit_key.
4861 * Returns NULL if value is OK, error message otherwise.
4863 static char_u *
4864 check_cedit()
4866 int n;
4868 if (*p_cedit == NUL)
4869 cedit_key = -1;
4870 else
4872 n = string_to_key(p_cedit);
4873 if (vim_isprintc(n))
4874 return e_invarg;
4875 cedit_key = n;
4877 return NULL;
4879 #endif
4881 #ifdef FEAT_TITLE
4883 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
4884 * maketitle() to create and display it.
4885 * When switching the title or icon off, call mch_restore_title() to get
4886 * the old value back.
4888 static void
4889 did_set_title(icon)
4890 int icon; /* Did set icon instead of title */
4892 if (starting != NO_SCREEN
4893 #ifdef FEAT_GUI
4894 && !gui.starting
4895 #endif
4898 maketitle();
4899 if (icon)
4901 if (!p_icon)
4902 mch_restore_title(2);
4904 else
4906 if (!p_title)
4907 mch_restore_title(1);
4911 #endif
4914 * set_options_bin - called when 'bin' changes value.
4916 void
4917 set_options_bin(oldval, newval, opt_flags)
4918 int oldval;
4919 int newval;
4920 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
4923 * The option values that are changed when 'bin' changes are
4924 * copied when 'bin is set and restored when 'bin' is reset.
4926 if (newval)
4928 if (!oldval) /* switched on */
4930 if (!(opt_flags & OPT_GLOBAL))
4932 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
4933 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
4934 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
4935 curbuf->b_p_et_nobin = curbuf->b_p_et;
4937 if (!(opt_flags & OPT_LOCAL))
4939 p_tw_nobin = p_tw;
4940 p_wm_nobin = p_wm;
4941 p_ml_nobin = p_ml;
4942 p_et_nobin = p_et;
4946 if (!(opt_flags & OPT_GLOBAL))
4948 curbuf->b_p_tw = 0; /* no automatic line wrap */
4949 curbuf->b_p_wm = 0; /* no automatic line wrap */
4950 curbuf->b_p_ml = 0; /* no modelines */
4951 curbuf->b_p_et = 0; /* no expandtab */
4953 if (!(opt_flags & OPT_LOCAL))
4955 p_tw = 0;
4956 p_wm = 0;
4957 p_ml = FALSE;
4958 p_et = FALSE;
4959 p_bin = TRUE; /* needed when called for the "-b" argument */
4962 else if (oldval) /* switched off */
4964 if (!(opt_flags & OPT_GLOBAL))
4966 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
4967 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
4968 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
4969 curbuf->b_p_et = curbuf->b_p_et_nobin;
4971 if (!(opt_flags & OPT_LOCAL))
4973 p_tw = p_tw_nobin;
4974 p_wm = p_wm_nobin;
4975 p_ml = p_ml_nobin;
4976 p_et = p_et_nobin;
4981 #ifdef FEAT_VIMINFO
4983 * Find the parameter represented by the given character (eg ', :, ", or /),
4984 * and return its associated value in the 'viminfo' string.
4985 * Only works for number parameters, not for 'r' or 'n'.
4986 * If the parameter is not specified in the string or there is no following
4987 * number, return -1.
4990 get_viminfo_parameter(type)
4991 int type;
4993 char_u *p;
4995 p = find_viminfo_parameter(type);
4996 if (p != NULL && VIM_ISDIGIT(*p))
4997 return atoi((char *)p);
4998 return -1;
5002 * Find the parameter represented by the given character (eg ''', ':', '"', or
5003 * '/') in the 'viminfo' option and return a pointer to the string after it.
5004 * Return NULL if the parameter is not specified in the string.
5006 char_u *
5007 find_viminfo_parameter(type)
5008 int type;
5010 char_u *p;
5012 for (p = p_viminfo; *p; ++p)
5014 if (*p == type)
5015 return p + 1;
5016 if (*p == 'n') /* 'n' is always the last one */
5017 break;
5018 p = vim_strchr(p, ','); /* skip until next ',' */
5019 if (p == NULL) /* hit the end without finding parameter */
5020 break;
5022 return NULL;
5024 #endif
5027 * Expand environment variables for some string options.
5028 * These string options cannot be indirect!
5029 * If "val" is NULL expand the current value of the option.
5030 * Return pointer to NameBuff, or NULL when not expanded.
5032 static char_u *
5033 option_expand(opt_idx, val)
5034 int opt_idx;
5035 char_u *val;
5037 /* if option doesn't need expansion nothing to do */
5038 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5039 return NULL;
5041 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5042 * expand_env() would truncate the string. */
5043 if (val != NULL && STRLEN(val) > MAXPATHL)
5044 return NULL;
5046 if (val == NULL)
5047 val = *(char_u **)options[opt_idx].var;
5050 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5051 * Escape spaces when expanding 'tags', they are used to separate file
5052 * names.
5053 * For 'spellsuggest' expand after "file:".
5055 expand_env_esc(val, NameBuff, MAXPATHL,
5056 (char_u **)options[opt_idx].var == &p_tags, FALSE,
5057 #ifdef FEAT_SPELL
5058 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5059 #endif
5060 NULL);
5061 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5062 return NULL;
5064 return NameBuff;
5068 * After setting various option values: recompute variables that depend on
5069 * option values.
5071 static void
5072 didset_options()
5074 /* initialize the table for 'iskeyword' et.al. */
5075 (void)init_chartab();
5077 #ifdef FEAT_MBYTE
5078 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
5079 #endif
5080 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5081 #ifdef FEAT_SESSION
5082 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5083 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5084 #endif
5085 #ifdef FEAT_FOLDING
5086 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5087 #endif
5088 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5089 #ifdef FEAT_VIRTUALEDIT
5090 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5091 #endif
5092 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5093 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5094 #endif
5095 #ifdef FEAT_SPELL
5096 (void)spell_check_msm();
5097 (void)spell_check_sps();
5098 (void)compile_cap_prog(curbuf);
5099 #endif
5100 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5101 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5102 #endif
5103 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
5104 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5105 #endif
5106 #ifdef FEAT_CMDWIN
5107 /* set cedit_key */
5108 (void)check_cedit();
5109 #endif
5113 * Check for string options that are NULL (normally only termcap options).
5115 void
5116 check_options()
5118 int opt_idx;
5120 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5121 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5122 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5126 * Check string options in a buffer for NULL value.
5128 void
5129 check_buf_options(buf)
5130 buf_T *buf;
5132 #if defined(FEAT_QUICKFIX)
5133 check_string_option(&buf->b_p_bh);
5134 check_string_option(&buf->b_p_bt);
5135 #endif
5136 #ifdef FEAT_MBYTE
5137 check_string_option(&buf->b_p_fenc);
5138 #endif
5139 check_string_option(&buf->b_p_ff);
5140 #ifdef FEAT_FIND_ID
5141 check_string_option(&buf->b_p_def);
5142 check_string_option(&buf->b_p_inc);
5143 # ifdef FEAT_EVAL
5144 check_string_option(&buf->b_p_inex);
5145 # endif
5146 #endif
5147 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5148 check_string_option(&buf->b_p_inde);
5149 check_string_option(&buf->b_p_indk);
5150 #endif
5151 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5152 check_string_option(&buf->b_p_bexpr);
5153 #endif
5154 #if defined(FEAT_EVAL)
5155 check_string_option(&buf->b_p_fex);
5156 #endif
5157 #ifdef FEAT_CRYPT
5158 check_string_option(&buf->b_p_key);
5159 #endif
5160 check_string_option(&buf->b_p_kp);
5161 check_string_option(&buf->b_p_mps);
5162 check_string_option(&buf->b_p_fo);
5163 check_string_option(&buf->b_p_flp);
5164 check_string_option(&buf->b_p_isk);
5165 #ifdef FEAT_COMMENTS
5166 check_string_option(&buf->b_p_com);
5167 #endif
5168 #ifdef FEAT_FOLDING
5169 check_string_option(&buf->b_p_cms);
5170 #endif
5171 check_string_option(&buf->b_p_nf);
5172 #ifdef FEAT_TEXTOBJ
5173 check_string_option(&buf->b_p_qe);
5174 #endif
5175 #ifdef FEAT_SYN_HL
5176 check_string_option(&buf->b_p_syn);
5177 #endif
5178 #ifdef FEAT_SPELL
5179 check_string_option(&buf->b_p_spc);
5180 check_string_option(&buf->b_p_spf);
5181 check_string_option(&buf->b_p_spl);
5182 #endif
5183 #ifdef FEAT_SEARCHPATH
5184 check_string_option(&buf->b_p_sua);
5185 #endif
5186 #ifdef FEAT_CINDENT
5187 check_string_option(&buf->b_p_cink);
5188 check_string_option(&buf->b_p_cino);
5189 #endif
5190 #ifdef FEAT_AUTOCMD
5191 check_string_option(&buf->b_p_ft);
5192 #endif
5193 #ifdef FEAT_OSFILETYPE
5194 check_string_option(&buf->b_p_oft);
5195 #endif
5196 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5197 check_string_option(&buf->b_p_cinw);
5198 #endif
5199 #ifdef FEAT_INS_EXPAND
5200 check_string_option(&buf->b_p_cpt);
5201 #endif
5202 #ifdef FEAT_COMPL_FUNC
5203 check_string_option(&buf->b_p_cfu);
5204 check_string_option(&buf->b_p_ofu);
5205 #endif
5206 #ifdef FEAT_KEYMAP
5207 check_string_option(&buf->b_p_keymap);
5208 #endif
5209 #ifdef FEAT_QUICKFIX
5210 check_string_option(&buf->b_p_gp);
5211 check_string_option(&buf->b_p_mp);
5212 check_string_option(&buf->b_p_efm);
5213 #endif
5214 check_string_option(&buf->b_p_ep);
5215 check_string_option(&buf->b_p_path);
5216 check_string_option(&buf->b_p_tags);
5217 #ifdef FEAT_INS_EXPAND
5218 check_string_option(&buf->b_p_dict);
5219 check_string_option(&buf->b_p_tsr);
5220 #endif
5224 * Free the string allocated for an option.
5225 * Checks for the string being empty_option. This may happen if we're out of
5226 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5227 * check_options().
5228 * Does NOT check for P_ALLOCED flag!
5230 void
5231 free_string_option(p)
5232 char_u *p;
5234 if (p != empty_option)
5235 vim_free(p);
5238 void
5239 clear_string_option(pp)
5240 char_u **pp;
5242 if (*pp != empty_option)
5243 vim_free(*pp);
5244 *pp = empty_option;
5247 static void
5248 check_string_option(pp)
5249 char_u **pp;
5251 if (*pp == NULL)
5252 *pp = empty_option;
5256 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5258 void
5259 set_term_option_alloced(p)
5260 char_u **p;
5262 int opt_idx;
5264 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5265 if (options[opt_idx].var == (char_u *)p)
5267 options[opt_idx].flags |= P_ALLOCED;
5268 return;
5270 return; /* cannot happen: didn't find it! */
5273 #if defined(FEAT_EVAL) || defined(PROTO)
5275 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5276 * Return FALSE when it wasn't.
5277 * Return -1 for an unknown option.
5280 was_set_insecurely(opt, opt_flags)
5281 char_u *opt;
5282 int opt_flags;
5284 int idx = findoption(opt);
5285 long_u *flagp;
5287 if (idx >= 0)
5289 flagp = insecure_flag(idx, opt_flags);
5290 return (*flagp & P_INSECURE) != 0;
5292 EMSG2(_(e_intern2), "was_set_insecurely()");
5293 return -1;
5297 * Get a pointer to the flags used for the P_INSECURE flag of option
5298 * "opt_idx". For some local options a local flags field is used.
5300 static long_u *
5301 insecure_flag(opt_idx, opt_flags)
5302 int opt_idx;
5303 int opt_flags;
5305 if (opt_flags & OPT_LOCAL)
5306 switch ((int)options[opt_idx].indir)
5308 #ifdef FEAT_STL_OPT
5309 case PV_STL: return &curwin->w_p_stl_flags;
5310 #endif
5311 #ifdef FEAT_EVAL
5312 # ifdef FEAT_FOLDING
5313 case PV_FDE: return &curwin->w_p_fde_flags;
5314 case PV_FDT: return &curwin->w_p_fdt_flags;
5315 # endif
5316 # ifdef FEAT_BEVAL
5317 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5318 # endif
5319 # if defined(FEAT_CINDENT)
5320 case PV_INDE: return &curbuf->b_p_inde_flags;
5321 # endif
5322 case PV_FEX: return &curbuf->b_p_fex_flags;
5323 # ifdef FEAT_FIND_ID
5324 case PV_INEX: return &curbuf->b_p_inex_flags;
5325 # endif
5326 #endif
5329 /* Nothing special, return global flags field. */
5330 return &options[opt_idx].flags;
5332 #endif
5334 #ifdef FEAT_TITLE
5335 static void redraw_titles __ARGS((void));
5338 * Redraw the window title and/or tab page text later.
5340 static void redraw_titles()
5342 need_maketitle = TRUE;
5343 # ifdef FEAT_WINDOWS
5344 redraw_tabline = TRUE;
5345 # endif
5347 #endif
5350 * Set a string option to a new value (without checking the effect).
5351 * The string is copied into allocated memory.
5352 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
5353 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
5354 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
5356 void
5357 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
5358 char_u *name;
5359 int opt_idx;
5360 char_u *val;
5361 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5362 int set_sid UNUSED;
5364 char_u *s;
5365 char_u **varp;
5366 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
5367 int idx = opt_idx;
5369 if (idx == -1) /* use name */
5371 idx = findoption(name);
5372 if (idx < 0) /* not found (should not happen) */
5374 EMSG2(_(e_intern2), "set_string_option_direct()");
5375 return;
5379 if (options[idx].var == NULL) /* can't set hidden option */
5380 return;
5382 s = vim_strsave(val);
5383 if (s != NULL)
5385 varp = (char_u **)get_varp_scope(&(options[idx]),
5386 both ? OPT_LOCAL : opt_flags);
5387 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
5388 free_string_option(*varp);
5389 *varp = s;
5391 /* For buffer/window local option may also set the global value. */
5392 if (both)
5393 set_string_option_global(idx, varp);
5395 options[idx].flags |= P_ALLOCED;
5397 /* When setting both values of a global option with a local value,
5398 * make the local value empty, so that the global value is used. */
5399 if (((int)options[idx].indir & PV_BOTH) && both)
5401 free_string_option(*varp);
5402 *varp = empty_option;
5404 # ifdef FEAT_EVAL
5405 if (set_sid != SID_NONE)
5406 set_option_scriptID_idx(idx, opt_flags,
5407 set_sid == 0 ? current_SID : set_sid);
5408 # endif
5413 * Set global value for string option when it's a local option.
5415 static void
5416 set_string_option_global(opt_idx, varp)
5417 int opt_idx; /* option index */
5418 char_u **varp; /* pointer to option variable */
5420 char_u **p, *s;
5422 /* the global value is always allocated */
5423 if (options[opt_idx].var == VAR_WIN)
5424 p = (char_u **)GLOBAL_WO(varp);
5425 else
5426 p = (char_u **)options[opt_idx].var;
5427 if (options[opt_idx].indir != PV_NONE
5428 && p != varp
5429 && (s = vim_strsave(*varp)) != NULL)
5431 free_string_option(*p);
5432 *p = s;
5435 #ifdef USE_MIGEMO
5436 if (varp == &p_migdict)
5437 reset_migemo(FALSE);
5438 #endif
5442 * Set a string option to a new value, and handle the effects.
5444 static void
5445 set_string_option(opt_idx, value, opt_flags)
5446 int opt_idx;
5447 char_u *value;
5448 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5450 char_u *s;
5451 char_u **varp;
5452 char_u *oldval;
5454 if (options[opt_idx].var == NULL) /* don't set hidden option */
5455 return;
5457 s = vim_strsave(value);
5458 if (s != NULL)
5460 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5461 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
5462 ? (((int)options[opt_idx].indir & PV_BOTH)
5463 ? OPT_GLOBAL : OPT_LOCAL)
5464 : opt_flags);
5465 oldval = *varp;
5466 *varp = s;
5467 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5468 opt_flags) == NULL)
5469 did_set_option(opt_idx, opt_flags, TRUE);
5474 * Handle string options that need some action to perform when changed.
5475 * Returns NULL for success, or an error message for an error.
5477 static char_u *
5478 did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5479 opt_flags)
5480 int opt_idx; /* index in options[] table */
5481 char_u **varp; /* pointer to the option variable */
5482 int new_value_alloced; /* new value was allocated */
5483 char_u *oldval; /* previous value of the option */
5484 char_u *errbuf; /* buffer for errors, or NULL */
5485 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5487 char_u *errmsg = NULL;
5488 char_u *s, *p;
5489 int did_chartab = FALSE;
5490 char_u **gvarp;
5491 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
5492 #ifdef FEAT_GUI
5493 /* set when changing an option that only requires a redraw in the GUI */
5494 int redraw_gui_only = FALSE;
5495 #endif
5497 /* Get the global option to compare with, otherwise we would have to check
5498 * two values for all local options. */
5499 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5501 /* Disallow changing some options from secure mode */
5502 if ((secure
5503 #ifdef HAVE_SANDBOX
5504 || sandbox != 0
5505 #endif
5506 ) && (options[opt_idx].flags & P_SECURE))
5508 errmsg = e_secure;
5511 /* Check for a "normal" file name in some options. Disallow a path
5512 * separator (slash and/or backslash), wildcards and characters that are
5513 * often illegal in a file name. */
5514 else if ((options[opt_idx].flags & P_NFNAME)
5515 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
5517 errmsg = e_invarg;
5520 /* 'term' */
5521 else if (varp == &T_NAME)
5523 if (T_NAME[0] == NUL)
5524 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5525 #ifdef FEAT_GUI
5526 if (gui.in_use)
5527 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5528 else if (term_is_gui(T_NAME))
5529 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5530 #endif
5531 else if (set_termname(T_NAME) == FAIL)
5532 errmsg = (char_u *)N_("E522: Not found in termcap");
5533 else
5534 /* Screen colors may have changed. */
5535 redraw_later_clear();
5538 /* 'backupcopy' */
5539 else if (varp == &p_bkc)
5541 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
5542 errmsg = e_invarg;
5543 if (((bkc_flags & BKC_AUTO) != 0)
5544 + ((bkc_flags & BKC_YES) != 0)
5545 + ((bkc_flags & BKC_NO) != 0) != 1)
5547 /* Must have exactly one of "auto", "yes" and "no". */
5548 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
5549 errmsg = e_invarg;
5553 /* 'backupext' and 'patchmode' */
5554 else if (varp == &p_bex || varp == &p_pm)
5556 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5557 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5558 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5562 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5563 * If the new option is invalid, use old value. 'lisp' option: refill
5564 * chartab[] for '-' char
5566 else if ( varp == &p_isi
5567 || varp == &(curbuf->b_p_isk)
5568 || varp == &p_isp
5569 || varp == &p_isf)
5571 if (init_chartab() == FAIL)
5573 did_chartab = TRUE; /* need to restore it below */
5574 errmsg = e_invarg; /* error in value */
5578 /* 'helpfile' */
5579 else if (varp == &p_hf)
5581 /* May compute new values for $VIM and $VIMRUNTIME */
5582 if (didset_vim)
5584 vim_setenv((char_u *)"VIM", (char_u *)"");
5585 didset_vim = FALSE;
5587 if (didset_vimruntime)
5589 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5590 didset_vimruntime = FALSE;
5594 #ifdef FEAT_MULTI_LANG
5595 /* 'helplang' */
5596 else if (varp == &p_hlg)
5598 /* Check for "", "ab", "ab,cd", etc. */
5599 for (s = p_hlg; *s != NUL; s += 3)
5601 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5603 errmsg = e_invarg;
5604 break;
5606 if (s[2] == NUL)
5607 break;
5610 #endif
5612 /* 'highlight' */
5613 else if (varp == &p_hl)
5615 if (highlight_changed() == FAIL)
5616 errmsg = e_invarg; /* invalid flags */
5619 /* 'nrformats' */
5620 else if (gvarp == &p_nf)
5622 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5623 errmsg = e_invarg;
5626 #ifdef FEAT_SESSION
5627 /* 'sessionoptions' */
5628 else if (varp == &p_ssop)
5630 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5631 errmsg = e_invarg;
5632 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5634 /* Don't allow both "sesdir" and "curdir". */
5635 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5636 errmsg = e_invarg;
5639 /* 'viewoptions' */
5640 else if (varp == &p_vop)
5642 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5643 errmsg = e_invarg;
5645 #endif
5647 /* 'scrollopt' */
5648 #ifdef FEAT_SCROLLBIND
5649 else if (varp == &p_sbo)
5651 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5652 errmsg = e_invarg;
5654 #endif
5656 /* 'ambiwidth' */
5657 #ifdef FEAT_MBYTE
5658 else if (varp == &p_ambw)
5660 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5661 errmsg = e_invarg;
5663 #endif
5665 /* 'background' */
5666 else if (varp == &p_bg)
5668 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5670 #ifdef FEAT_EVAL
5671 int dark = (*p_bg == 'd');
5672 #endif
5674 init_highlight(FALSE, FALSE);
5676 #ifdef FEAT_EVAL
5677 if (dark != (*p_bg == 'd')
5678 && get_var_value((char_u *)"g:colors_name") != NULL)
5680 /* The color scheme must have set 'background' back to another
5681 * value, that's not what we want here. Disable the color
5682 * scheme and set the colors again. */
5683 do_unlet((char_u *)"g:colors_name", TRUE);
5684 free_string_option(p_bg);
5685 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5686 check_string_option(&p_bg);
5687 init_highlight(FALSE, FALSE);
5689 #endif
5691 else
5692 errmsg = e_invarg;
5695 /* 'wildmode' */
5696 else if (varp == &p_wim)
5698 if (check_opt_wim() == FAIL)
5699 errmsg = e_invarg;
5702 #ifdef FEAT_CMDL_COMPL
5703 /* 'wildoptions' */
5704 else if (varp == &p_wop)
5706 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
5707 errmsg = e_invarg;
5709 #endif
5711 #ifdef FEAT_WAK
5712 /* 'winaltkeys' */
5713 else if (varp == &p_wak)
5715 if (*p_wak == NUL
5716 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
5717 errmsg = e_invarg;
5718 # ifdef FEAT_MENU
5719 # ifdef FEAT_GUI_MOTIF
5720 else if (gui.in_use)
5721 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5722 # else
5723 # ifdef FEAT_GUI_GTK
5724 else if (gui.in_use)
5725 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5726 # endif
5727 # endif
5728 # endif
5730 #endif
5732 #ifdef FEAT_AUTOCMD
5733 /* 'eventignore' */
5734 else if (varp == &p_ei)
5736 if (check_ei() == FAIL)
5737 errmsg = e_invarg;
5739 #endif
5741 #ifdef FEAT_MBYTE
5742 /* 'encoding' and 'fileencoding' */
5743 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
5745 if (gvarp == &p_fenc)
5747 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
5748 errmsg = e_modifiable;
5749 else if (vim_strchr(*varp, ',') != NULL)
5750 /* No comma allowed in 'fileencoding'; catches confusing it
5751 * with 'fileencodings'. */
5752 errmsg = e_invarg;
5753 else
5755 # ifdef FEAT_TITLE
5756 /* May show a "+" in the title now. */
5757 redraw_titles();
5758 # endif
5759 /* Add 'fileencoding' to the swap file. */
5760 ml_setflags(curbuf);
5763 if (errmsg == NULL)
5765 /* canonize the value, so that STRCMP() can be used on it */
5766 p = enc_canonize(*varp);
5767 if (p != NULL)
5769 vim_free(*varp);
5770 *varp = p;
5772 if (varp == &p_enc)
5774 errmsg = mb_init();
5775 # ifdef FEAT_TITLE
5776 redraw_titles();
5777 # endif
5781 # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
5782 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
5784 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
5785 if (STRCMP(p_tenc, "utf-8") != 0)
5786 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
5788 # endif
5790 if (errmsg == NULL)
5792 # ifdef FEAT_KEYMAP
5793 /* When 'keymap' is used and 'encoding' changes, reload the keymap
5794 * (with another encoding). */
5795 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
5796 (void)keymap_init();
5797 # endif
5799 /* When 'termencoding' is not empty and 'encoding' changes or when
5800 * 'termencoding' changes, need to setup for keyboard input and
5801 * display output conversion. */
5802 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
5804 convert_setup(&input_conv, p_tenc, p_enc);
5805 convert_setup(&output_conv, p_enc, p_tenc);
5808 # if defined(WIN3264) && defined(FEAT_MBYTE)
5809 /* $HOME may have characters in active code page. */
5810 if (varp == &p_enc)
5811 init_homedir();
5812 # endif
5815 #endif
5817 #if defined(FEAT_POSTSCRIPT)
5818 else if (varp == &p_penc)
5820 /* Canonize printencoding if VIM standard one */
5821 p = enc_canonize(p_penc);
5822 if (p != NULL)
5824 vim_free(p_penc);
5825 p_penc = p;
5827 else
5829 /* Ensure lower case and '-' for '_' */
5830 for (s = p_penc; *s != NUL; s++)
5832 if (*s == '_')
5833 *s = '-';
5834 else
5835 *s = TOLOWER_ASC(*s);
5839 #endif
5841 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
5842 else if (varp == &p_imak)
5844 if (gui.in_use && !im_xim_isvalid_imactivate())
5845 errmsg = e_invarg;
5847 #endif
5849 #ifdef FEAT_KEYMAP
5850 else if (varp == &curbuf->b_p_keymap)
5852 /* load or unload key mapping tables */
5853 errmsg = keymap_init();
5855 if (errmsg == NULL)
5857 if (*curbuf->b_p_keymap != NUL)
5859 /* Installed a new keymap, switch on using it. */
5860 curbuf->b_p_iminsert = B_IMODE_LMAP;
5861 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
5862 curbuf->b_p_imsearch = B_IMODE_LMAP;
5864 else
5866 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
5867 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
5868 curbuf->b_p_iminsert = B_IMODE_NONE;
5869 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
5870 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
5872 if ((opt_flags & OPT_LOCAL) == 0)
5874 set_iminsert_global();
5875 set_imsearch_global();
5877 # ifdef FEAT_WINDOWS
5878 status_redraw_curbuf();
5879 # endif
5882 #endif
5884 /* 'fileformat' */
5885 else if (gvarp == &p_ff)
5887 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
5888 errmsg = e_modifiable;
5889 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
5890 errmsg = e_invarg;
5891 else
5893 /* may also change 'textmode' */
5894 if (get_fileformat(curbuf) == EOL_DOS)
5895 curbuf->b_p_tx = TRUE;
5896 else
5897 curbuf->b_p_tx = FALSE;
5898 #ifdef FEAT_TITLE
5899 redraw_titles();
5900 #endif
5901 /* update flag in swap file */
5902 ml_setflags(curbuf);
5903 /* Redraw needed when switching to/from "mac": a CR in the text
5904 * will be displayed differently. */
5905 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
5906 redraw_curbuf_later(NOT_VALID);
5910 /* 'fileformats' */
5911 else if (varp == &p_ffs)
5913 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
5914 errmsg = e_invarg;
5915 else
5917 /* also change 'textauto' */
5918 if (*p_ffs == NUL)
5919 p_ta = FALSE;
5920 else
5921 p_ta = TRUE;
5925 #if defined(FEAT_CRYPT) && defined(FEAT_CMDHIST)
5926 /* 'cryptkey' */
5927 else if (gvarp == &p_key)
5929 /* Make sure the ":set" command doesn't show the new value in the
5930 * history. */
5931 remove_key_from_history();
5933 #endif
5935 /* 'matchpairs' */
5936 else if (gvarp == &p_mps)
5938 /* Check for "x:y,x:y" */
5939 for (p = *varp; *p != NUL; p += 4)
5941 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
5943 errmsg = e_invarg;
5944 break;
5946 if (p[3] == NUL)
5947 break;
5951 #ifdef FEAT_COMMENTS
5952 /* 'comments' */
5953 else if (gvarp == &p_com)
5955 for (s = *varp; *s; )
5957 while (*s && *s != ':')
5959 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
5960 && !VIM_ISDIGIT(*s) && *s != '-')
5962 errmsg = illegal_char(errbuf, *s);
5963 break;
5965 ++s;
5967 if (*s++ == NUL)
5968 errmsg = (char_u *)N_("E524: Missing colon");
5969 else if (*s == ',' || *s == NUL)
5970 errmsg = (char_u *)N_("E525: Zero length string");
5971 if (errmsg != NULL)
5972 break;
5973 while (*s && *s != ',')
5975 if (*s == '\\' && s[1] != NUL)
5976 ++s;
5977 ++s;
5979 s = skip_to_option_part(s);
5982 #endif
5984 /* 'listchars' */
5985 else if (varp == &p_lcs)
5987 errmsg = set_chars_option(varp);
5990 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5991 /* 'fillchars' */
5992 else if (varp == &p_fcs)
5994 errmsg = set_chars_option(varp);
5996 #endif
5998 #ifdef FEAT_CMDWIN
5999 /* 'cedit' */
6000 else if (varp == &p_cedit)
6002 errmsg = check_cedit();
6004 #endif
6006 /* 'verbosefile' */
6007 else if (varp == &p_vfile)
6009 verbose_stop();
6010 if (*p_vfile != NUL && verbose_open() == FAIL)
6011 errmsg = e_invarg;
6014 #ifdef FEAT_VIMINFO
6015 /* 'viminfo' */
6016 else if (varp == &p_viminfo)
6018 for (s = p_viminfo; *s;)
6020 /* Check it's a valid character */
6021 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6023 errmsg = illegal_char(errbuf, *s);
6024 break;
6026 if (*s == 'n') /* name is always last one */
6028 break;
6030 else if (*s == 'r') /* skip until next ',' */
6032 while (*++s && *s != ',')
6035 else if (*s == '%')
6037 /* optional number */
6038 while (vim_isdigit(*++s))
6041 else if (*s == '!' || *s == 'h' || *s == 'c')
6042 ++s; /* no extra chars */
6043 else /* must have a number */
6045 while (vim_isdigit(*++s))
6048 if (!VIM_ISDIGIT(*(s - 1)))
6050 if (errbuf != NULL)
6052 sprintf((char *)errbuf,
6053 _("E526: Missing number after <%s>"),
6054 transchar_byte(*(s - 1)));
6055 errmsg = errbuf;
6057 else
6058 errmsg = (char_u *)"";
6059 break;
6062 if (*s == ',')
6063 ++s;
6064 else if (*s)
6066 if (errbuf != NULL)
6067 errmsg = (char_u *)N_("E527: Missing comma");
6068 else
6069 errmsg = (char_u *)"";
6070 break;
6073 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6074 errmsg = (char_u *)N_("E528: Must specify a ' value");
6076 #endif /* FEAT_VIMINFO */
6078 /* terminal options */
6079 else if (istermoption(&options[opt_idx]) && full_screen)
6081 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6082 if (varp == &T_CCO)
6084 int colors = atoi((char *)T_CCO);
6086 /* Only reinitialize colors if t_Co value has really changed to
6087 * avoid expensive reload of colorscheme if t_Co is set to the
6088 * same value multiple times. */
6089 if (colors != t_colors)
6091 t_colors = colors;
6092 if (t_colors <= 1)
6094 if (new_value_alloced)
6095 vim_free(T_CCO);
6096 T_CCO = empty_option;
6098 /* We now have a different color setup, initialize it again. */
6099 init_highlight(TRUE, FALSE);
6102 ttest(FALSE);
6103 if (varp == &T_ME)
6105 out_str(T_ME);
6106 redraw_later(CLEAR);
6107 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6108 /* Since t_me has been set, this probably means that the user
6109 * wants to use this as default colors. Need to reset default
6110 * background/foreground colors. */
6111 mch_set_normal_colors();
6112 #endif
6116 #ifdef FEAT_LINEBREAK
6117 /* 'showbreak' */
6118 else if (varp == &p_sbr)
6120 for (s = p_sbr; *s; )
6122 if (ptr2cells(s) != 1)
6123 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
6124 mb_ptr_adv(s);
6127 #endif
6129 #ifdef FEAT_GUI
6130 /* 'guifont' */
6131 else if (varp == &p_guifont)
6133 if (gui.in_use)
6135 p = p_guifont;
6136 # if defined(FEAT_GUI_GTK)
6138 * Put up a font dialog and let the user select a new value.
6139 * If this is cancelled go back to the old value but don't
6140 * give an error message.
6142 if (STRCMP(p, "*") == 0)
6144 p = gui_mch_font_dialog(oldval);
6146 if (new_value_alloced)
6147 free_string_option(p_guifont);
6149 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6150 new_value_alloced = TRUE;
6152 # endif
6153 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6155 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6156 if (STRCMP(p_guifont, "*") == 0)
6158 /* Dialog was cancelled: Keep the old value without giving
6159 * an error message. */
6160 if (new_value_alloced)
6161 free_string_option(p_guifont);
6162 p_guifont = vim_strsave(oldval);
6163 new_value_alloced = TRUE;
6165 else
6166 # endif
6167 errmsg = (char_u *)N_("E596: Invalid font(s)");
6170 redraw_gui_only = TRUE;
6172 # ifdef FEAT_XFONTSET
6173 else if (varp == &p_guifontset)
6175 if (STRCMP(p_guifontset, "*") == 0)
6176 errmsg = (char_u *)N_("E597: can't select fontset");
6177 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6178 errmsg = (char_u *)N_("E598: Invalid fontset");
6179 redraw_gui_only = TRUE;
6181 # endif
6182 # ifdef FEAT_MBYTE
6183 else if (varp == &p_guifontwide)
6185 if (STRCMP(p_guifontwide, "*") == 0)
6186 errmsg = (char_u *)N_("E533: can't select wide font");
6187 else if (gui_get_wide_font() == FAIL)
6188 errmsg = (char_u *)N_("E534: Invalid wide font");
6189 redraw_gui_only = TRUE;
6191 # endif
6192 #endif
6194 #ifdef CURSOR_SHAPE
6195 /* 'guicursor' */
6196 else if (varp == &p_guicursor)
6197 errmsg = parse_shape_opt(SHAPE_CURSOR);
6198 #endif
6200 #ifdef FEAT_MOUSESHAPE
6201 /* 'mouseshape' */
6202 else if (varp == &p_mouseshape)
6204 errmsg = parse_shape_opt(SHAPE_MOUSE);
6205 update_mouseshape(-1);
6207 #endif
6209 #ifdef FEAT_PRINTER
6210 else if (varp == &p_popt)
6211 errmsg = parse_printoptions();
6212 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
6213 else if (varp == &p_pmfn)
6214 errmsg = parse_printmbfont();
6215 # endif
6216 #endif
6218 #ifdef FEAT_LANGMAP
6219 /* 'langmap' */
6220 else if (varp == &p_langmap)
6221 langmap_set();
6222 #endif
6224 #ifdef FEAT_LINEBREAK
6225 /* 'breakat' */
6226 else if (varp == &p_breakat)
6227 fill_breakat_flags();
6228 #endif
6230 #ifdef FEAT_TITLE
6231 /* 'titlestring' and 'iconstring' */
6232 else if (varp == &p_titlestring || varp == &p_iconstring)
6234 # ifdef FEAT_STL_OPT
6235 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6237 /* NULL => statusline syntax */
6238 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6239 stl_syntax |= flagval;
6240 else
6241 stl_syntax &= ~flagval;
6242 # endif
6243 did_set_title(varp == &p_iconstring);
6246 #endif
6248 #ifdef FEAT_GUI
6249 /* 'guioptions' */
6250 else if (varp == &p_go)
6252 gui_init_which_components(oldval);
6253 redraw_gui_only = TRUE;
6255 #endif
6257 #if defined(FEAT_GUI_TABLINE)
6258 /* 'guitablabel' */
6259 else if (varp == &p_gtl)
6261 redraw_tabline = TRUE;
6262 redraw_gui_only = TRUE;
6264 /* 'guitabtooltip' */
6265 else if (varp == &p_gtt)
6267 redraw_gui_only = TRUE;
6269 #endif
6271 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6272 /* 'ttymouse' */
6273 else if (varp == &p_ttym)
6275 /* Switch the mouse off before changing the escape sequences used for
6276 * that. */
6277 mch_setmouse(FALSE);
6278 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6279 errmsg = e_invarg;
6280 else
6281 check_mouse_termcode();
6282 if (termcap_active)
6283 setmouse(); /* may switch it on again */
6285 #endif
6287 #ifdef FEAT_VISUAL
6288 /* 'selection' */
6289 else if (varp == &p_sel)
6291 if (*p_sel == NUL
6292 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6293 errmsg = e_invarg;
6296 /* 'selectmode' */
6297 else if (varp == &p_slm)
6299 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6300 errmsg = e_invarg;
6302 #endif
6304 #ifdef FEAT_BROWSE
6305 /* 'browsedir' */
6306 else if (varp == &p_bsdir)
6308 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6309 && !mch_isdir(p_bsdir))
6310 errmsg = e_invarg;
6312 #endif
6314 #ifdef FEAT_VISUAL
6315 /* 'keymodel' */
6316 else if (varp == &p_km)
6318 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6319 errmsg = e_invarg;
6320 else
6322 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6323 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6326 #endif
6328 /* 'mousemodel' */
6329 else if (varp == &p_mousem)
6331 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6332 errmsg = e_invarg;
6333 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6334 else if (*p_mousem != *oldval)
6335 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6336 * to create or delete the popup menus. */
6337 gui_motif_update_mousemodel(root_menu);
6338 #endif
6341 /* 'switchbuf' */
6342 else if (varp == &p_swb)
6344 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
6345 errmsg = e_invarg;
6348 /* 'debug' */
6349 else if (varp == &p_debug)
6351 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
6352 errmsg = e_invarg;
6355 /* 'display' */
6356 else if (varp == &p_dy)
6358 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6359 errmsg = e_invarg;
6360 else
6361 (void)init_chartab();
6365 #ifdef FEAT_VERTSPLIT
6366 /* 'eadirection' */
6367 else if (varp == &p_ead)
6369 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6370 errmsg = e_invarg;
6372 #endif
6374 #ifdef FEAT_CLIPBOARD
6375 /* 'clipboard' */
6376 else if (varp == &p_cb)
6377 errmsg = check_clipboard_option();
6378 #endif
6380 #ifdef FEAT_SPELL
6381 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6382 * buffer in which 'spell' is set load the wordlists. */
6383 else if (varp == &(curbuf->b_p_spl) || varp == &(curbuf->b_p_spf))
6385 win_T *wp;
6386 int l;
6388 if (varp == &(curbuf->b_p_spf))
6390 l = (int)STRLEN(curbuf->b_p_spf);
6391 if (l > 0 && (l < 4 || STRCMP(curbuf->b_p_spf + l - 4,
6392 ".add") != 0))
6393 errmsg = e_invarg;
6396 if (errmsg == NULL)
6398 FOR_ALL_WINDOWS(wp)
6399 if (wp->w_buffer == curbuf && wp->w_p_spell)
6401 errmsg = did_set_spelllang(curbuf);
6402 # ifdef FEAT_WINDOWS
6403 break;
6404 # endif
6408 /* When 'spellcapcheck' is set compile the regexp program. */
6409 else if (varp == &(curbuf->b_p_spc))
6411 errmsg = compile_cap_prog(curbuf);
6413 /* 'spellsuggest' */
6414 else if (varp == &p_sps)
6416 if (spell_check_sps() != OK)
6417 errmsg = e_invarg;
6419 /* 'mkspellmem' */
6420 else if (varp == &p_msm)
6422 if (spell_check_msm() != OK)
6423 errmsg = e_invarg;
6425 #endif
6427 #ifdef FEAT_QUICKFIX
6428 /* When 'bufhidden' is set, check for valid value. */
6429 else if (gvarp == &p_bh)
6431 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6432 errmsg = e_invarg;
6435 /* When 'buftype' is set, check for valid value. */
6436 else if (gvarp == &p_bt)
6438 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6439 errmsg = e_invarg;
6440 else
6442 # ifdef FEAT_WINDOWS
6443 if (curwin->w_status_height)
6445 curwin->w_redr_status = TRUE;
6446 redraw_later(VALID);
6448 # endif
6449 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
6450 # ifdef FEAT_TITLE
6451 redraw_titles();
6452 # endif
6455 #endif
6457 #ifdef FEAT_STL_OPT
6458 /* 'statusline' or 'rulerformat' */
6459 else if (gvarp == &p_stl || varp == &p_ruf)
6461 int wid;
6463 if (varp == &p_ruf) /* reset ru_wid first */
6464 ru_wid = 0;
6465 s = *varp;
6466 if (varp == &p_ruf && *s == '%')
6468 /* set ru_wid if 'ruf' starts with "%99(" */
6469 if (*++s == '-') /* ignore a '-' */
6470 s++;
6471 wid = getdigits(&s);
6472 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6473 ru_wid = wid;
6474 else
6475 errmsg = check_stl_option(p_ruf);
6477 /* check 'statusline' only if it doesn't start with "%!" */
6478 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
6479 errmsg = check_stl_option(s);
6480 if (varp == &p_ruf && errmsg == NULL)
6481 comp_col();
6483 #endif
6485 #ifdef FEAT_INS_EXPAND
6486 /* check if it is a valid value for 'complete' -- Acevedo */
6487 else if (gvarp == &p_cpt)
6489 for (s = *varp; *s;)
6491 while(*s == ',' || *s == ' ')
6492 s++;
6493 if (!*s)
6494 break;
6495 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6497 errmsg = illegal_char(errbuf, *s);
6498 break;
6500 if (*++s != NUL && *s != ',' && *s != ' ')
6502 if (s[-1] == 'k' || s[-1] == 's')
6504 /* skip optional filename after 'k' and 's' */
6505 while (*s && *s != ',' && *s != ' ')
6507 if (*s == '\\')
6508 ++s;
6509 ++s;
6512 else
6514 if (errbuf != NULL)
6516 sprintf((char *)errbuf,
6517 _("E535: Illegal character after <%c>"),
6518 *--s);
6519 errmsg = errbuf;
6521 else
6522 errmsg = (char_u *)"";
6523 break;
6529 /* 'completeopt' */
6530 else if (varp == &p_cot)
6532 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6533 errmsg = e_invarg;
6535 #endif /* FEAT_INS_EXPAND */
6538 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6539 else if (varp == &p_toolbar)
6541 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6542 &toolbar_flags, TRUE) != OK)
6543 errmsg = e_invarg;
6544 else
6546 out_flush();
6547 gui_mch_show_toolbar((toolbar_flags &
6548 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6551 #endif
6553 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
6554 /* 'toolbariconsize': GTK+ 2 only */
6555 else if (varp == &p_tbis)
6557 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6558 errmsg = e_invarg;
6559 else
6561 out_flush();
6562 gui_mch_show_toolbar((toolbar_flags &
6563 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6566 #endif
6568 /* 'pastetoggle': translate key codes like in a mapping */
6569 else if (varp == &p_pt)
6571 if (*p_pt)
6573 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
6574 if (p != NULL)
6576 if (new_value_alloced)
6577 free_string_option(p_pt);
6578 p_pt = p;
6579 new_value_alloced = TRUE;
6584 /* 'backspace' */
6585 else if (varp == &p_bs)
6587 if (VIM_ISDIGIT(*p_bs))
6589 if (*p_bs >'2' || p_bs[1] != NUL)
6590 errmsg = e_invarg;
6592 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6593 errmsg = e_invarg;
6596 #ifdef FEAT_MBYTE
6597 /* 'casemap' */
6598 else if (varp == &p_cmp)
6600 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6601 errmsg = e_invarg;
6603 #endif
6605 #ifdef FEAT_DIFF
6606 /* 'diffopt' */
6607 else if (varp == &p_dip)
6609 if (diffopt_changed() == FAIL)
6610 errmsg = e_invarg;
6612 #endif
6614 #ifdef FEAT_FOLDING
6615 /* 'foldmethod' */
6616 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
6618 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
6619 || *curwin->w_p_fdm == NUL)
6620 errmsg = e_invarg;
6621 else
6623 foldUpdateAll(curwin);
6624 if (foldmethodIsDiff(curwin))
6625 newFoldLevel();
6628 # ifdef FEAT_EVAL
6629 /* 'foldexpr' */
6630 else if (varp == &curwin->w_p_fde)
6632 if (foldmethodIsExpr(curwin))
6633 foldUpdateAll(curwin);
6635 # endif
6636 /* 'foldmarker' */
6637 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
6639 p = vim_strchr(*varp, ',');
6640 if (p == NULL)
6641 errmsg = (char_u *)N_("E536: comma required");
6642 else if (p == *varp || p[1] == NUL)
6643 errmsg = e_invarg;
6644 else if (foldmethodIsMarker(curwin))
6645 foldUpdateAll(curwin);
6647 /* 'commentstring' */
6648 else if (gvarp == &p_cms)
6650 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
6651 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
6653 /* 'foldopen' */
6654 else if (varp == &p_fdo)
6656 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
6657 errmsg = e_invarg;
6659 /* 'foldclose' */
6660 else if (varp == &p_fcl)
6662 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
6663 errmsg = e_invarg;
6665 /* 'foldignore' */
6666 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
6668 if (foldmethodIsIndent(curwin))
6669 foldUpdateAll(curwin);
6671 #endif
6673 #ifdef FEAT_VIRTUALEDIT
6674 /* 'virtualedit' */
6675 else if (varp == &p_ve)
6677 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
6678 errmsg = e_invarg;
6679 else if (STRCMP(p_ve, oldval) != 0)
6681 /* Recompute cursor position in case the new 've' setting
6682 * changes something. */
6683 validate_virtcol();
6684 coladvance(curwin->w_virtcol);
6687 #endif
6689 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
6690 else if (varp == &p_csqf)
6692 if (p_csqf != NULL)
6694 p = p_csqf;
6695 while (*p != NUL)
6697 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
6698 || p[1] == NUL
6699 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
6700 || (p[2] != NUL && p[2] != ','))
6702 errmsg = e_invarg;
6703 break;
6705 else if (p[2] == NUL)
6706 break;
6707 else
6708 p += 3;
6712 #endif
6714 /* Options that are a list of flags. */
6715 else
6717 p = NULL;
6718 if (varp == &p_ww)
6719 p = (char_u *)WW_ALL;
6720 if (varp == &p_shm)
6721 p = (char_u *)SHM_ALL;
6722 else if (varp == &(p_cpo))
6723 p = (char_u *)CPO_ALL;
6724 else if (varp == &(curbuf->b_p_fo))
6725 p = (char_u *)FO_ALL;
6726 else if (varp == &p_mouse)
6728 #ifdef FEAT_MOUSE
6729 p = (char_u *)MOUSE_ALL;
6730 #else
6731 if (*p_mouse != NUL)
6732 errmsg = (char_u *)N_("E538: No mouse support");
6733 #endif
6735 #if defined(FEAT_GUI)
6736 else if (varp == &p_go)
6737 p = (char_u *)GO_ALL;
6738 #endif
6739 if (p != NULL)
6741 for (s = *varp; *s; ++s)
6742 if (vim_strchr(p, *s) == NULL)
6744 errmsg = illegal_char(errbuf, *s);
6745 break;
6751 * If error detected, restore the previous value.
6753 if (errmsg != NULL)
6755 if (new_value_alloced)
6756 free_string_option(*varp);
6757 *varp = oldval;
6759 * When resetting some values, need to act on it.
6761 if (did_chartab)
6762 (void)init_chartab();
6763 if (varp == &p_hl)
6764 (void)highlight_changed();
6766 else
6768 #ifdef FEAT_EVAL
6769 /* Remember where the option was set. */
6770 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
6771 #endif
6773 * Free string options that are in allocated memory.
6774 * Use "free_oldval", because recursiveness may change the flags under
6775 * our fingers (esp. init_highlight()).
6777 if (free_oldval)
6778 free_string_option(oldval);
6779 if (new_value_alloced)
6780 options[opt_idx].flags |= P_ALLOCED;
6781 else
6782 options[opt_idx].flags &= ~P_ALLOCED;
6784 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
6785 && ((int)options[opt_idx].indir & PV_BOTH))
6787 /* global option with local value set to use global value; free
6788 * the local value and make it empty */
6789 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
6790 free_string_option(*(char_u **)p);
6791 *(char_u **)p = empty_option;
6794 /* May set global value for local option. */
6795 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
6796 set_string_option_global(opt_idx, varp);
6798 #ifdef FEAT_AUTOCMD
6800 * Trigger the autocommand only after setting the flags.
6802 # ifdef FEAT_SYN_HL
6803 /* When 'syntax' is set, load the syntax of that name */
6804 if (varp == &(curbuf->b_p_syn))
6806 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
6807 curbuf->b_fname, TRUE, curbuf);
6809 # endif
6810 else if (varp == &(curbuf->b_p_ft))
6812 /* 'filetype' is set, trigger the FileType autocommand */
6813 did_filetype = TRUE;
6814 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
6815 curbuf->b_fname, TRUE, curbuf);
6817 #endif
6818 #ifdef FEAT_SPELL
6819 if (varp == &(curbuf->b_p_spl))
6821 char_u fname[200];
6824 * Source the spell/LANG.vim in 'runtimepath'.
6825 * They could set 'spellcapcheck' depending on the language.
6826 * Use the first name in 'spelllang' up to '_region' or
6827 * '.encoding'.
6829 for (p = curbuf->b_p_spl; *p != NUL; ++p)
6830 if (vim_strchr((char_u *)"_.,", *p) != NULL)
6831 break;
6832 vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
6833 (int)(p - curbuf->b_p_spl), curbuf->b_p_spl);
6834 source_runtime(fname, TRUE);
6836 #endif
6839 #ifdef FEAT_MOUSE
6840 if (varp == &p_mouse)
6842 # ifdef FEAT_MOUSE_TTY
6843 if (*p_mouse == NUL)
6844 mch_setmouse(FALSE); /* switch mouse off */
6845 else
6846 # endif
6847 setmouse(); /* in case 'mouse' changed */
6849 #endif
6851 if (curwin->w_curswant != MAXCOL)
6852 curwin->w_set_curswant = TRUE; /* in case 'showbreak' changed */
6853 #ifdef FEAT_GUI
6854 /* check redraw when it's not a GUI option or the GUI is active. */
6855 if (!redraw_gui_only || gui.in_use)
6856 #endif
6857 check_redraw(options[opt_idx].flags);
6859 return errmsg;
6863 * Handle setting 'listchars' or 'fillchars'.
6864 * Returns error message, NULL if it's OK.
6866 static char_u *
6867 set_chars_option(varp)
6868 char_u **varp;
6870 int round, i, len, entries;
6871 char_u *p, *s;
6872 int c1, c2 = 0;
6873 struct charstab
6875 int *cp;
6876 char *name;
6878 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6879 static struct charstab filltab[] =
6881 {&fill_stl, "stl"},
6882 {&fill_stlnc, "stlnc"},
6883 {&fill_vert, "vert"},
6884 {&fill_fold, "fold"},
6885 {&fill_diff, "diff"},
6887 #endif
6888 static struct charstab lcstab[] =
6890 {&lcs_eol, "eol"},
6891 {&lcs_ext, "extends"},
6892 {&lcs_nbsp, "nbsp"},
6893 {&lcs_prec, "precedes"},
6894 {&lcs_tab2, "tab"},
6895 {&lcs_trail, "trail"},
6897 struct charstab *tab;
6899 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6900 if (varp == &p_lcs)
6901 #endif
6903 tab = lcstab;
6904 entries = sizeof(lcstab) / sizeof(struct charstab);
6906 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6907 else
6909 tab = filltab;
6910 entries = sizeof(filltab) / sizeof(struct charstab);
6912 #endif
6914 /* first round: check for valid value, second round: assign values */
6915 for (round = 0; round <= 1; ++round)
6917 if (round)
6919 /* After checking that the value is valid: set defaults: space for
6920 * 'fillchars', NUL for 'listchars' */
6921 for (i = 0; i < entries; ++i)
6922 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
6923 if (varp == &p_lcs)
6924 lcs_tab1 = NUL;
6925 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6926 else
6927 fill_diff = '-';
6928 #endif
6930 p = *varp;
6931 while (*p)
6933 for (i = 0; i < entries; ++i)
6935 len = (int)STRLEN(tab[i].name);
6936 if (STRNCMP(p, tab[i].name, len) == 0
6937 && p[len] == ':'
6938 && p[len + 1] != NUL)
6940 s = p + len + 1;
6941 #ifdef FEAT_MBYTE
6942 c1 = mb_ptr2char_adv(&s);
6943 if (mb_char2cells(c1) > 1)
6944 continue;
6945 #else
6946 c1 = *s++;
6947 #endif
6948 if (tab[i].cp == &lcs_tab2)
6950 if (*s == NUL)
6951 continue;
6952 #ifdef FEAT_MBYTE
6953 c2 = mb_ptr2char_adv(&s);
6954 if (mb_char2cells(c2) > 1)
6955 continue;
6956 #else
6957 c2 = *s++;
6958 #endif
6960 if (*s == ',' || *s == NUL)
6962 if (round)
6964 if (tab[i].cp == &lcs_tab2)
6966 lcs_tab1 = c1;
6967 lcs_tab2 = c2;
6969 else
6970 *(tab[i].cp) = c1;
6973 p = s;
6974 break;
6979 if (i == entries)
6980 return e_invarg;
6981 if (*p == ',')
6982 ++p;
6986 return NULL; /* no error */
6989 #ifdef FEAT_STL_OPT
6991 * Check validity of options with the 'statusline' format.
6992 * Return error message or NULL.
6994 char_u *
6995 check_stl_option(s)
6996 char_u *s;
6998 int itemcnt = 0;
6999 int groupdepth = 0;
7000 static char_u errbuf[80];
7002 while (*s && itemcnt < STL_MAX_ITEM)
7004 /* Check for valid keys after % sequences */
7005 while (*s && *s != '%')
7006 s++;
7007 if (!*s)
7008 break;
7009 s++;
7010 if (*s != '%' && *s != ')')
7011 ++itemcnt;
7012 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7014 s++;
7015 continue;
7017 if (*s == ')')
7019 s++;
7020 if (--groupdepth < 0)
7021 break;
7022 continue;
7024 if (*s == '-')
7025 s++;
7026 while (VIM_ISDIGIT(*s))
7027 s++;
7028 if (*s == STL_USER_HL)
7029 continue;
7030 if (*s == '.')
7032 s++;
7033 while (*s && VIM_ISDIGIT(*s))
7034 s++;
7036 if (*s == '(')
7038 groupdepth++;
7039 continue;
7041 if (vim_strchr(STL_ALL, *s) == NULL)
7043 return illegal_char(errbuf, *s);
7045 if (*s == '{')
7047 s++;
7048 while (*s != '}' && *s)
7049 s++;
7050 if (*s != '}')
7051 return (char_u *)N_("E540: Unclosed expression sequence");
7054 if (itemcnt >= STL_MAX_ITEM)
7055 return (char_u *)N_("E541: too many items");
7056 if (groupdepth != 0)
7057 return (char_u *)N_("E542: unbalanced groups");
7058 return NULL;
7060 #endif
7062 #ifdef FEAT_CLIPBOARD
7064 * Extract the items in the 'clipboard' option and set global values.
7066 static char_u *
7067 check_clipboard_option()
7069 int new_unnamed = FALSE;
7070 int new_autoselect = FALSE;
7071 int new_autoselectml = FALSE;
7072 int new_html = FALSE;
7073 regprog_T *new_exclude_prog = NULL;
7074 char_u *errmsg = NULL;
7075 char_u *p;
7077 for (p = p_cb; *p != NUL; )
7079 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7081 new_unnamed = TRUE;
7082 p += 7;
7084 else if (STRNCMP(p, "autoselect", 10) == 0
7085 && (p[10] == ',' || p[10] == NUL))
7087 new_autoselect = TRUE;
7088 p += 10;
7090 else if (STRNCMP(p, "autoselectml", 12) == 0
7091 && (p[12] == ',' || p[12] == NUL))
7093 new_autoselectml = TRUE;
7094 p += 12;
7096 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7098 new_html = TRUE;
7099 p += 4;
7101 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7103 p += 8;
7104 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7105 if (new_exclude_prog == NULL)
7106 errmsg = e_invarg;
7107 break;
7109 else
7111 errmsg = e_invarg;
7112 break;
7114 if (*p == ',')
7115 ++p;
7117 if (errmsg == NULL)
7119 clip_unnamed = new_unnamed;
7120 clip_autoselect = new_autoselect;
7121 clip_autoselectml = new_autoselectml;
7122 clip_html = new_html;
7123 vim_free(clip_exclude_prog);
7124 clip_exclude_prog = new_exclude_prog;
7126 else
7127 vim_free(new_exclude_prog);
7129 return errmsg;
7131 #endif
7133 #ifdef FEAT_SPELL
7135 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7136 * Return error message when failed, NULL when OK.
7138 static char_u *
7139 compile_cap_prog(buf)
7140 buf_T *buf;
7142 regprog_T *rp = buf->b_cap_prog;
7143 char_u *re;
7145 if (*buf->b_p_spc == NUL)
7146 buf->b_cap_prog = NULL;
7147 else
7149 /* Prepend a ^ so that we only match at one column */
7150 re = concat_str((char_u *)"^", buf->b_p_spc);
7151 if (re != NULL)
7153 buf->b_cap_prog = vim_regcomp(re, RE_MAGIC);
7154 if (buf->b_cap_prog == NULL)
7156 buf->b_cap_prog = rp; /* restore the previous program */
7157 return e_invarg;
7159 vim_free(re);
7163 vim_free(rp);
7164 return NULL;
7166 #endif
7168 #if defined(FEAT_EVAL) || defined(PROTO)
7170 * Set the scriptID for an option, taking care of setting the buffer- or
7171 * window-local value.
7173 static void
7174 set_option_scriptID_idx(opt_idx, opt_flags, id)
7175 int opt_idx;
7176 int opt_flags;
7177 int id;
7179 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7180 int indir = (int)options[opt_idx].indir;
7182 /* Remember where the option was set. For local options need to do that
7183 * in the buffer or window structure. */
7184 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
7185 options[opt_idx].scriptID = id;
7186 if (both || (opt_flags & OPT_LOCAL))
7188 if (indir & PV_BUF)
7189 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7190 else if (indir & PV_WIN)
7191 curwin->w_p_scriptID[indir & PV_MASK] = id;
7194 #endif
7197 * Set the value of a boolean option, and take care of side effects.
7198 * Returns NULL for success, or an error message for an error.
7200 static char_u *
7201 set_bool_option(opt_idx, varp, value, opt_flags)
7202 int opt_idx; /* index in options[] table */
7203 char_u *varp; /* pointer to the option variable */
7204 int value; /* new value */
7205 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7207 int old_value = *(int *)varp;
7209 /* Disallow changing some options from secure mode */
7210 if ((secure
7211 #ifdef HAVE_SANDBOX
7212 || sandbox != 0
7213 #endif
7214 ) && (options[opt_idx].flags & P_SECURE))
7215 return e_secure;
7217 *(int *)varp = value; /* set the new value */
7218 #ifdef FEAT_EVAL
7219 /* Remember where the option was set. */
7220 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
7221 #endif
7223 #ifdef FEAT_GUI
7224 need_mouse_correct = TRUE;
7225 #endif
7227 /* May set global value for local option. */
7228 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7229 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7232 * Handle side effects of changing a bool option.
7235 /* 'compatible' */
7236 if ((int *)varp == &p_cp)
7238 compatible_set();
7241 /* 'list', 'number' */
7242 else if ((int *)varp == &curwin->w_p_list
7243 || (int *)varp == &curwin->w_p_nu)
7245 if (curwin->w_curswant != MAXCOL)
7246 curwin->w_set_curswant = TRUE;
7249 else if ((int *)varp == &curbuf->b_p_ro)
7251 /* when 'readonly' is reset globally, also reset readonlymode */
7252 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7253 readonlymode = FALSE;
7255 /* when 'readonly' is set may give W10 again */
7256 if (curbuf->b_p_ro)
7257 curbuf->b_did_warn = FALSE;
7259 #ifdef FEAT_TITLE
7260 redraw_titles();
7261 #endif
7264 #ifdef FEAT_TITLE
7265 /* when 'modifiable' is changed, redraw the window title */
7266 else if ((int *)varp == &curbuf->b_p_ma)
7268 redraw_titles();
7270 /* when 'endofline' is changed, redraw the window title */
7271 else if ((int *)varp == &curbuf->b_p_eol)
7273 redraw_titles();
7275 # ifdef FEAT_MBYTE
7276 /* when 'bomb' is changed, redraw the window title and tab page text */
7277 else if ((int *)varp == &curbuf->b_p_bomb)
7279 redraw_titles();
7281 # endif
7282 #endif
7284 /* when 'bin' is set also set some other options */
7285 else if ((int *)varp == &curbuf->b_p_bin)
7287 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7288 #ifdef FEAT_TITLE
7289 redraw_titles();
7290 #endif
7293 #ifdef FEAT_AUTOCMD
7294 /* when 'buflisted' changes, trigger autocommands */
7295 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7297 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7298 NULL, NULL, TRUE, curbuf);
7300 #endif
7302 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7303 else if ((int *)varp == &curbuf->b_p_swf)
7305 if (curbuf->b_p_swf && p_uc)
7306 ml_open_file(curbuf); /* create the swap file */
7307 else
7308 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7309 * buf->b_p_swf */
7310 mf_close_file(curbuf, TRUE); /* remove the swap file */
7313 /* when 'terse' is set change 'shortmess' */
7314 else if ((int *)varp == &p_terse)
7316 char_u *p;
7318 p = vim_strchr(p_shm, SHM_SEARCH);
7320 /* insert 's' in p_shm */
7321 if (p_terse && p == NULL)
7323 STRCPY(IObuff, p_shm);
7324 STRCAT(IObuff, "s");
7325 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
7327 /* remove 's' from p_shm */
7328 else if (!p_terse && p != NULL)
7329 STRMOVE(p, p + 1);
7332 /* when 'paste' is set or reset also change other options */
7333 else if ((int *)varp == &p_paste)
7335 paste_option_changed();
7338 /* when 'insertmode' is set from an autocommand need to do work here */
7339 else if ((int *)varp == &p_im)
7341 if (p_im)
7343 if ((State & INSERT) == 0)
7344 need_start_insertmode = TRUE;
7345 stop_insert_mode = FALSE;
7347 else
7349 need_start_insertmode = FALSE;
7350 stop_insert_mode = TRUE;
7351 if (restart_edit != 0 && mode_displayed)
7352 clear_cmdline = TRUE; /* remove "(insert)" */
7353 restart_edit = 0;
7357 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7358 else if ((int *)varp == &p_ic && p_hls)
7360 redraw_all_later(SOME_VALID);
7363 #ifdef FEAT_SEARCH_EXTRA
7364 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7365 else if ((int *)varp == &p_hls)
7367 no_hlsearch = FALSE;
7369 #endif
7371 #ifdef FEAT_SCROLLBIND
7372 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7373 * at the end of normal_cmd() */
7374 else if ((int *)varp == &curwin->w_p_scb)
7376 if (curwin->w_p_scb)
7377 do_check_scrollbind(FALSE);
7379 #endif
7381 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7382 /* There can be only one window with 'previewwindow' set. */
7383 else if ((int *)varp == &curwin->w_p_pvw)
7385 if (curwin->w_p_pvw)
7387 win_T *win;
7389 for (win = firstwin; win != NULL; win = win->w_next)
7390 if (win->w_p_pvw && win != curwin)
7392 curwin->w_p_pvw = FALSE;
7393 return (char_u *)N_("E590: A preview window already exists");
7397 #endif
7399 /* when 'textmode' is set or reset also change 'fileformat' */
7400 else if ((int *)varp == &curbuf->b_p_tx)
7402 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7405 /* when 'textauto' is set or reset also change 'fileformats' */
7406 else if ((int *)varp == &p_ta)
7407 set_string_option_direct((char_u *)"ffs", -1,
7408 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
7409 OPT_FREE | opt_flags, 0);
7412 * When 'lisp' option changes include/exclude '-' in
7413 * keyword characters.
7415 #ifdef FEAT_LISP
7416 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7418 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7420 #endif
7422 #ifdef FEAT_TITLE
7423 /* when 'title' changed, may need to change the title; same for 'icon' */
7424 else if ((int *)varp == &p_title)
7426 did_set_title(FALSE);
7429 else if ((int *)varp == &p_icon)
7431 did_set_title(TRUE);
7433 #endif
7435 else if ((int *)varp == &curbuf->b_changed)
7437 if (!value)
7438 save_file_ff(curbuf); /* Buffer is unchanged */
7439 #ifdef FEAT_TITLE
7440 redraw_titles();
7441 #endif
7442 #ifdef FEAT_AUTOCMD
7443 modified_was_set = value;
7444 #endif
7447 #ifdef BACKSLASH_IN_FILENAME
7448 else if ((int *)varp == &p_ssl)
7450 if (p_ssl)
7452 psepc = '/';
7453 psepcN = '\\';
7454 pseps[0] = '/';
7456 else
7458 psepc = '\\';
7459 psepcN = '/';
7460 pseps[0] = '\\';
7463 /* need to adjust the file name arguments and buffer names. */
7464 buflist_slash_adjust();
7465 alist_slash_adjust();
7466 # ifdef FEAT_EVAL
7467 scriptnames_slash_adjust();
7468 # endif
7470 #endif
7472 /* If 'wrap' is set, set w_leftcol to zero. */
7473 else if ((int *)varp == &curwin->w_p_wrap)
7475 if (curwin->w_p_wrap)
7476 curwin->w_leftcol = 0;
7477 if (curwin->w_curswant != MAXCOL)
7478 curwin->w_set_curswant = TRUE;
7481 #ifdef FEAT_WINDOWS
7482 else if ((int *)varp == &p_ea)
7484 if (p_ea && !old_value)
7485 win_equal(curwin, FALSE, 0);
7487 #endif
7489 else if ((int *)varp == &p_wiv)
7492 * When 'weirdinvert' changed, set/reset 't_xs'.
7493 * Then set 'weirdinvert' according to value of 't_xs'.
7495 if (p_wiv && !old_value)
7496 T_XS = (char_u *)"y";
7497 else if (!p_wiv && old_value)
7498 T_XS = empty_option;
7499 p_wiv = (*T_XS != NUL);
7502 #ifdef FEAT_BEVAL
7503 else if ((int *)varp == &p_beval)
7505 if (p_beval == TRUE)
7506 gui_mch_enable_beval_area(balloonEval);
7507 else
7508 gui_mch_disable_beval_area(balloonEval);
7510 #endif
7512 #ifdef FEAT_AUTOCHDIR
7513 else if ((int *)varp == &p_acd)
7515 /* Change directories when the 'acd' option is set now. */
7516 DO_AUTOCHDIR
7518 #endif
7520 #ifdef FEAT_DIFF
7521 /* 'diff' */
7522 else if ((int *)varp == &curwin->w_p_diff)
7524 /* May add or remove the buffer from the list of diff buffers. */
7525 diff_buf_adjust(curwin);
7526 # ifdef FEAT_FOLDING
7527 if (foldmethodIsDiff(curwin))
7528 foldUpdateAll(curwin);
7529 # endif
7531 #endif
7533 #ifdef USE_IM_CONTROL
7534 /* 'imdisable' */
7535 else if ((int *)varp == &p_imdisable)
7537 /* Only de-activate it here, it will be enabled when changing mode. */
7538 if (p_imdisable)
7539 im_set_active(FALSE);
7541 #endif
7543 #ifdef FEAT_SPELL
7544 /* 'spell' */
7545 else if ((int *)varp == &curwin->w_p_spell)
7547 if (curwin->w_p_spell)
7549 char_u *errmsg = did_set_spelllang(curbuf);
7551 if (errmsg != NULL)
7552 EMSG(_(errmsg));
7555 #endif
7557 #ifdef FEAT_FKMAP
7558 else if ((int *)varp == &p_altkeymap)
7560 if (old_value != p_altkeymap)
7562 if (!p_altkeymap)
7564 p_hkmap = p_fkmap;
7565 p_fkmap = 0;
7567 else
7569 p_fkmap = p_hkmap;
7570 p_hkmap = 0;
7572 (void)init_chartab();
7577 * In case some second language keymapping options have changed, check
7578 * and correct the setting in a consistent way.
7582 * If hkmap or fkmap are set, reset Arabic keymapping.
7584 if ((p_hkmap || p_fkmap) && p_altkeymap)
7586 p_altkeymap = p_fkmap;
7587 # ifdef FEAT_ARABIC
7588 curwin->w_p_arab = FALSE;
7589 # endif
7590 (void)init_chartab();
7594 * If hkmap set, reset Farsi keymapping.
7596 if (p_hkmap && p_altkeymap)
7598 p_altkeymap = 0;
7599 p_fkmap = 0;
7600 # ifdef FEAT_ARABIC
7601 curwin->w_p_arab = FALSE;
7602 # endif
7603 (void)init_chartab();
7607 * If fkmap set, reset Hebrew keymapping.
7609 if (p_fkmap && !p_altkeymap)
7611 p_altkeymap = 1;
7612 p_hkmap = 0;
7613 # ifdef FEAT_ARABIC
7614 curwin->w_p_arab = FALSE;
7615 # endif
7616 (void)init_chartab();
7618 #endif
7620 #ifdef FEAT_ARABIC
7621 if ((int *)varp == &curwin->w_p_arab)
7623 if (curwin->w_p_arab)
7626 * 'arabic' is set, handle various sub-settings.
7628 if (!p_tbidi)
7630 /* set rightleft mode */
7631 if (!curwin->w_p_rl)
7633 curwin->w_p_rl = TRUE;
7634 changed_window_setting();
7637 /* Enable Arabic shaping (major part of what Arabic requires) */
7638 if (!p_arshape)
7640 p_arshape = TRUE;
7641 redraw_later_clear();
7645 /* Arabic requires a utf-8 encoding, inform the user if its not
7646 * set. */
7647 if (STRCMP(p_enc, "utf-8") != 0)
7649 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
7651 msg_source(hl_attr(HLF_W));
7652 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
7653 #ifdef FEAT_EVAL
7654 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
7655 #endif
7658 # ifdef FEAT_MBYTE
7659 /* set 'delcombine' */
7660 p_deco = TRUE;
7661 # endif
7663 # ifdef FEAT_KEYMAP
7664 /* Force-set the necessary keymap for arabic */
7665 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
7666 OPT_LOCAL);
7667 # endif
7668 # ifdef FEAT_FKMAP
7669 p_altkeymap = 0;
7670 p_hkmap = 0;
7671 p_fkmap = 0;
7672 (void)init_chartab();
7673 # endif
7675 else
7678 * 'arabic' is reset, handle various sub-settings.
7680 if (!p_tbidi)
7682 /* reset rightleft mode */
7683 if (curwin->w_p_rl)
7685 curwin->w_p_rl = FALSE;
7686 changed_window_setting();
7689 /* 'arabicshape' isn't reset, it is a global option and
7690 * another window may still need it "on". */
7693 /* 'delcombine' isn't reset, it is a global option and another
7694 * window may still want it "on". */
7696 # ifdef FEAT_KEYMAP
7697 /* Revert to the default keymap */
7698 curbuf->b_p_iminsert = B_IMODE_NONE;
7699 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
7700 # endif
7702 if (curwin->w_curswant != MAXCOL)
7703 curwin->w_set_curswant = TRUE;
7706 else if ((int *)varp == &p_arshape)
7708 if (curwin->w_curswant != MAXCOL)
7709 curwin->w_set_curswant = TRUE;
7711 #endif
7713 #ifdef FEAT_LINEBREAK
7714 if ((int *)varp == &curwin->w_p_lbr)
7716 if (curwin->w_curswant != MAXCOL)
7717 curwin->w_set_curswant = TRUE;
7719 #endif
7721 #ifdef FEAT_RIGHTLEFT
7722 if ((int *)varp == &curwin->w_p_rl)
7724 if (curwin->w_curswant != MAXCOL)
7725 curwin->w_set_curswant = TRUE;
7727 #endif
7730 * End of handling side effects for bool options.
7733 options[opt_idx].flags |= P_WAS_SET;
7735 comp_col(); /* in case 'ruler' or 'showcmd' changed */
7737 check_redraw(options[opt_idx].flags);
7739 return NULL;
7743 * Set the value of a number option, and take care of side effects.
7744 * Returns NULL for success, or an error message for an error.
7746 static char_u *
7747 set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
7748 int opt_idx; /* index in options[] table */
7749 char_u *varp; /* pointer to the option variable */
7750 long value; /* new value */
7751 char_u *errbuf; /* buffer for error messages */
7752 size_t errbuflen; /* length of "errbuf" */
7753 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
7754 OPT_MODELINE */
7756 char_u *errmsg = NULL;
7757 long old_value = *(long *)varp;
7758 long old_Rows = Rows; /* remember old Rows */
7759 long old_Columns = Columns; /* remember old Columns */
7760 long *pp = (long *)varp;
7762 /* Disallow changing some options from secure mode. */
7763 if ((secure
7764 #ifdef HAVE_SANDBOX
7765 || sandbox != 0
7766 #endif
7767 ) && (options[opt_idx].flags & P_SECURE))
7768 return e_secure;
7770 *pp = value;
7771 #ifdef FEAT_EVAL
7772 /* Remember where the option was set. */
7773 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
7774 #endif
7775 #ifdef FEAT_GUI
7776 need_mouse_correct = TRUE;
7777 #endif
7779 if (curbuf->b_p_sw <= 0)
7781 errmsg = e_positive;
7782 curbuf->b_p_sw = curbuf->b_p_ts;
7786 * Number options that need some action when changed
7788 #ifdef FEAT_WINDOWS
7789 if (pp == &p_wh || pp == &p_hh)
7791 if (p_wh < 1)
7793 errmsg = e_positive;
7794 p_wh = 1;
7796 if (p_wmh > p_wh)
7798 errmsg = e_winheight;
7799 p_wh = p_wmh;
7801 if (p_hh < 0)
7803 errmsg = e_positive;
7804 p_hh = 0;
7807 /* Change window height NOW */
7808 if (lastwin != firstwin)
7810 if (pp == &p_wh && curwin->w_height < p_wh)
7811 win_setheight((int)p_wh);
7812 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
7813 win_setheight((int)p_hh);
7817 /* 'winminheight' */
7818 else if (pp == &p_wmh)
7820 if (p_wmh < 0)
7822 errmsg = e_positive;
7823 p_wmh = 0;
7825 if (p_wmh > p_wh)
7827 errmsg = e_winheight;
7828 p_wmh = p_wh;
7830 win_setminheight();
7833 # ifdef FEAT_VERTSPLIT
7834 else if (pp == &p_wiw)
7836 if (p_wiw < 1)
7838 errmsg = e_positive;
7839 p_wiw = 1;
7841 if (p_wmw > p_wiw)
7843 errmsg = e_winwidth;
7844 p_wiw = p_wmw;
7847 /* Change window width NOW */
7848 if (lastwin != firstwin && curwin->w_width < p_wiw)
7849 win_setwidth((int)p_wiw);
7852 /* 'winminwidth' */
7853 else if (pp == &p_wmw)
7855 if (p_wmw < 0)
7857 errmsg = e_positive;
7858 p_wmw = 0;
7860 if (p_wmw > p_wiw)
7862 errmsg = e_winwidth;
7863 p_wmw = p_wiw;
7865 win_setminheight();
7867 # endif
7869 #endif
7871 #ifdef FEAT_WINDOWS
7872 /* (re)set last window status line */
7873 else if (pp == &p_ls)
7875 last_status(FALSE);
7878 /* (re)set tab page line */
7879 else if (pp == &p_stal)
7881 shell_new_rows(); /* recompute window positions and heights */
7883 #endif
7885 #ifdef FEAT_GUI
7886 else if (pp == &p_linespace || pp == &p_charspace)
7888 /* Recompute gui.char_height and resize the Vim window to keep the
7889 * same number of lines. */
7890 if (gui.in_use && gui_mch_adjust_charheight() == OK)
7891 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
7893 #endif
7895 #ifdef FEAT_FOLDING
7896 /* 'foldlevel' */
7897 else if (pp == &curwin->w_p_fdl)
7899 if (curwin->w_p_fdl < 0)
7900 curwin->w_p_fdl = 0;
7901 newFoldLevel();
7904 /* 'foldminlines' */
7905 else if (pp == &curwin->w_p_fml)
7907 foldUpdateAll(curwin);
7910 /* 'foldnestmax' */
7911 else if (pp == &curwin->w_p_fdn)
7913 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
7914 foldUpdateAll(curwin);
7917 /* 'foldcolumn' */
7918 else if (pp == &curwin->w_p_fdc)
7920 if (curwin->w_p_fdc < 0)
7922 errmsg = e_positive;
7923 curwin->w_p_fdc = 0;
7925 else if (curwin->w_p_fdc > 12)
7927 errmsg = e_invarg;
7928 curwin->w_p_fdc = 12;
7932 /* 'shiftwidth' or 'tabstop' */
7933 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
7935 if (foldmethodIsIndent(curwin))
7936 foldUpdateAll(curwin);
7938 #endif /* FEAT_FOLDING */
7940 #ifdef FEAT_MBYTE
7941 /* 'maxcombine' */
7942 else if (pp == &p_mco)
7944 if (p_mco > MAX_MCO)
7945 p_mco = MAX_MCO;
7946 else if (p_mco < 0)
7947 p_mco = 0;
7948 screenclear(); /* will re-allocate the screen */
7950 #endif
7952 #ifdef USE_TRANSPARENCY
7953 else if ((long *)varp == &p_transparency)
7955 if (p_transparency < 1 || p_transparency > 255)
7956 p_transparency = 255;
7957 gui_mch_set_transparency(p_transparency);
7959 #endif
7961 else if (pp == &curbuf->b_p_iminsert)
7963 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
7965 errmsg = e_invarg;
7966 curbuf->b_p_iminsert = B_IMODE_NONE;
7968 p_iminsert = curbuf->b_p_iminsert;
7969 if (termcap_active) /* don't do this in the alternate screen */
7970 showmode();
7971 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
7972 /* Show/unshow value of 'keymap' in status lines. */
7973 status_redraw_curbuf();
7974 #endif
7977 else if (pp == &p_window)
7979 if (p_window < 1)
7980 p_window = 1;
7981 else if (p_window >= Rows)
7982 p_window = Rows - 1;
7985 else if (pp == &curbuf->b_p_imsearch)
7987 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
7989 errmsg = e_invarg;
7990 curbuf->b_p_imsearch = B_IMODE_NONE;
7992 p_imsearch = curbuf->b_p_imsearch;
7995 #ifdef FEAT_TITLE
7996 /* if 'titlelen' has changed, redraw the title */
7997 else if (pp == &p_titlelen)
7999 if (p_titlelen < 0)
8001 errmsg = e_positive;
8002 p_titlelen = 85;
8004 if (starting != NO_SCREEN && old_value != p_titlelen)
8005 need_maketitle = TRUE;
8007 #endif
8009 /* if p_ch changed value, change the command line height */
8010 else if (pp == &p_ch)
8012 if (p_ch < 1)
8014 errmsg = e_positive;
8015 p_ch = 1;
8017 if (p_ch > Rows - min_rows() + 1)
8018 p_ch = Rows - min_rows() + 1;
8020 /* Only compute the new window layout when startup has been
8021 * completed. Otherwise the frame sizes may be wrong. */
8022 if (p_ch != old_value && full_screen
8023 #ifdef FEAT_GUI
8024 && !gui.starting
8025 #endif
8027 command_height();
8030 /* when 'updatecount' changes from zero to non-zero, open swap files */
8031 else if (pp == &p_uc)
8033 if (p_uc < 0)
8035 errmsg = e_positive;
8036 p_uc = 100;
8038 if (p_uc && !old_value)
8039 ml_open_files();
8041 #ifdef MZSCHEME_GUI_THREADS
8042 else if (pp == &p_mzq)
8043 mzvim_reset_timer();
8044 #endif
8046 /* sync undo before 'undolevels' changes */
8047 else if (pp == &p_ul)
8049 /* use the old value, otherwise u_sync() may not work properly */
8050 p_ul = old_value;
8051 u_sync(TRUE);
8052 p_ul = value;
8055 #ifdef FEAT_LINEBREAK
8056 /* 'numberwidth' must be positive */
8057 else if (pp == &curwin->w_p_nuw)
8059 if (curwin->w_p_nuw < 1)
8061 errmsg = e_positive;
8062 curwin->w_p_nuw = 1;
8064 if (curwin->w_p_nuw > 10)
8066 errmsg = e_invarg;
8067 curwin->w_p_nuw = 10;
8069 curwin->w_nrwidth_line_count = 0;
8071 #endif
8074 * Check the bounds for numeric options here
8076 if (Rows < min_rows() && full_screen)
8078 if (errbuf != NULL)
8080 vim_snprintf((char *)errbuf, errbuflen,
8081 _("E593: Need at least %d lines"), min_rows());
8082 errmsg = errbuf;
8084 Rows = min_rows();
8086 if (Columns < MIN_COLUMNS && full_screen)
8088 if (errbuf != NULL)
8090 vim_snprintf((char *)errbuf, errbuflen,
8091 _("E594: Need at least %d columns"), MIN_COLUMNS);
8092 errmsg = errbuf;
8094 Columns = MIN_COLUMNS;
8096 /* Limit the values to avoid an overflow in Rows * Columns. */
8097 if (Columns > 10000)
8098 Columns = 10000;
8099 if (Rows > 1000)
8100 Rows = 1000;
8102 #ifdef DJGPP
8103 /* avoid a crash by checking for a too large value of 'columns' */
8104 if (old_Columns != Columns && full_screen && term_console)
8105 mch_check_columns();
8106 #endif
8109 * If the screen (shell) height has been changed, assume it is the
8110 * physical screenheight.
8112 if (old_Rows != Rows || old_Columns != Columns)
8114 /* Changing the screen size is not allowed while updating the screen. */
8115 if (updating_screen)
8116 *pp = old_value;
8117 else if (full_screen
8118 #ifdef FEAT_GUI
8119 && !gui.starting
8120 #endif
8122 set_shellsize((int)Columns, (int)Rows, TRUE);
8123 else
8125 /* Postpone the resizing; check the size and cmdline position for
8126 * messages. */
8127 check_shellsize();
8128 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8129 cmdline_row = Rows - p_ch;
8131 if (p_window >= Rows || !option_was_set((char_u *)"window"))
8132 p_window = Rows - 1;
8135 if (curbuf->b_p_sts < 0)
8137 errmsg = e_positive;
8138 curbuf->b_p_sts = 0;
8140 if (curbuf->b_p_ts <= 0)
8142 errmsg = e_positive;
8143 curbuf->b_p_ts = 8;
8145 if (curbuf->b_p_tw < 0)
8147 errmsg = e_positive;
8148 curbuf->b_p_tw = 0;
8150 if (p_tm < 0)
8152 errmsg = e_positive;
8153 p_tm = 0;
8155 if ((curwin->w_p_scr <= 0
8156 || (curwin->w_p_scr > curwin->w_height
8157 && curwin->w_height > 0))
8158 && full_screen)
8160 if (pp == &(curwin->w_p_scr))
8162 if (curwin->w_p_scr != 0)
8163 errmsg = e_scroll;
8164 win_comp_scroll(curwin);
8166 /* If 'scroll' became invalid because of a side effect silently adjust
8167 * it. */
8168 else if (curwin->w_p_scr <= 0)
8169 curwin->w_p_scr = 1;
8170 else /* curwin->w_p_scr > curwin->w_height */
8171 curwin->w_p_scr = curwin->w_height;
8173 if (p_hi < 0)
8175 errmsg = e_positive;
8176 p_hi = 0;
8178 if (p_report < 0)
8180 errmsg = e_positive;
8181 p_report = 1;
8183 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
8185 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8186 p_sj = Rows / 2;
8187 else
8189 errmsg = e_scroll;
8190 p_sj = 1;
8193 if (p_so < 0 && full_screen)
8195 errmsg = e_scroll;
8196 p_so = 0;
8198 if (p_siso < 0 && full_screen)
8200 errmsg = e_positive;
8201 p_siso = 0;
8203 #ifdef FEAT_CMDWIN
8204 if (p_cwh < 1)
8206 errmsg = e_positive;
8207 p_cwh = 1;
8209 #endif
8210 if (p_ut < 0)
8212 errmsg = e_positive;
8213 p_ut = 2000;
8215 if (p_ss < 0)
8217 errmsg = e_positive;
8218 p_ss = 0;
8221 /* May set global value for local option. */
8222 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8223 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8225 options[opt_idx].flags |= P_WAS_SET;
8227 comp_col(); /* in case 'columns' or 'ls' changed */
8228 if (curwin->w_curswant != MAXCOL)
8229 curwin->w_set_curswant = TRUE; /* in case 'tabstop' changed */
8230 check_redraw(options[opt_idx].flags);
8232 return errmsg;
8236 * Called after an option changed: check if something needs to be redrawn.
8238 static void
8239 check_redraw(flags)
8240 long_u flags;
8242 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
8243 int clear = (flags & P_RCLR) == P_RCLR;
8244 int all = ((flags & P_RALL) == P_RALL || clear);
8246 #ifdef FEAT_WINDOWS
8247 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8248 status_redraw_all();
8249 #endif
8251 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8252 changed_window_setting();
8253 if (flags & P_RBUF)
8254 redraw_curbuf_later(NOT_VALID);
8255 if (clear)
8256 redraw_all_later(CLEAR);
8257 else if (all)
8258 redraw_all_later(NOT_VALID);
8262 * Find index for option 'arg'.
8263 * Return -1 if not found.
8265 static int
8266 findoption(arg)
8267 char_u *arg;
8269 int opt_idx;
8270 char *s, *p;
8271 static short quick_tab[27] = {0, 0}; /* quick access table */
8272 int is_term_opt;
8275 * For first call: Initialize the quick-access table.
8276 * It contains the index for the first option that starts with a certain
8277 * letter. There are 26 letters, plus the first "t_" option.
8279 if (quick_tab[1] == 0)
8281 p = options[0].fullname;
8282 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8284 if (s[0] != p[0])
8286 if (s[0] == 't' && s[1] == '_')
8287 quick_tab[26] = opt_idx;
8288 else
8289 quick_tab[CharOrdLow(s[0])] = opt_idx;
8291 p = s;
8296 * Check for name starting with an illegal character.
8298 #ifdef EBCDIC
8299 if (!islower(arg[0]))
8300 #else
8301 if (arg[0] < 'a' || arg[0] > 'z')
8302 #endif
8303 return -1;
8305 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8306 if (is_term_opt)
8307 opt_idx = quick_tab[26];
8308 else
8309 opt_idx = quick_tab[CharOrdLow(arg[0])];
8310 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8312 if (STRCMP(arg, s) == 0) /* match full name */
8313 break;
8315 if (s == NULL && !is_term_opt)
8317 opt_idx = quick_tab[CharOrdLow(arg[0])];
8318 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8320 s = options[opt_idx].shortname;
8321 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8322 break;
8323 s = NULL;
8326 if (s == NULL)
8327 opt_idx = -1;
8328 return opt_idx;
8331 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
8333 * Get the value for an option.
8335 * Returns:
8336 * Number or Toggle option: 1, *numval gets value.
8337 * String option: 0, *stringval gets allocated string.
8338 * Hidden Number or Toggle option: -1.
8339 * hidden String option: -2.
8340 * unknown option: -3.
8343 get_option_value(name, numval, stringval, opt_flags)
8344 char_u *name;
8345 long *numval;
8346 char_u **stringval; /* NULL when only checking existance */
8347 int opt_flags;
8349 int opt_idx;
8350 char_u *varp;
8352 opt_idx = findoption(name);
8353 if (opt_idx < 0) /* unknown option */
8354 return -3;
8356 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8358 if (options[opt_idx].flags & P_STRING)
8360 if (varp == NULL) /* hidden option */
8361 return -2;
8362 if (stringval != NULL)
8364 #ifdef FEAT_CRYPT
8365 /* never return the value of the crypt key */
8366 if ((char_u **)varp == &curbuf->b_p_key
8367 && **(char_u **)(varp) != NUL)
8368 *stringval = vim_strsave((char_u *)"*****");
8369 else
8370 #endif
8371 *stringval = vim_strsave(*(char_u **)(varp));
8373 return 0;
8376 if (varp == NULL) /* hidden option */
8377 return -1;
8378 if (options[opt_idx].flags & P_NUM)
8379 *numval = *(long *)varp;
8380 else
8382 /* Special case: 'modified' is b_changed, but we also want to consider
8383 * it set when 'ff' or 'fenc' changed. */
8384 if ((int *)varp == &curbuf->b_changed)
8385 *numval = curbufIsChanged();
8386 else
8387 *numval = *(int *)varp;
8389 return 1;
8391 #endif
8394 * Set the value of option "name".
8395 * Use "string" for string options, use "number" for other options.
8397 void
8398 set_option_value(name, number, string, opt_flags)
8399 char_u *name;
8400 long number;
8401 char_u *string;
8402 int opt_flags; /* OPT_LOCAL or 0 (both) */
8404 int opt_idx;
8405 char_u *varp;
8406 long_u flags;
8408 opt_idx = findoption(name);
8409 if (opt_idx < 0)
8410 EMSG2(_("E355: Unknown option: %s"), name);
8411 else
8413 flags = options[opt_idx].flags;
8414 #ifdef HAVE_SANDBOX
8415 /* Disallow changing some options in the sandbox */
8416 if (sandbox > 0 && (flags & P_SECURE))
8418 EMSG(_(e_sandbox));
8419 return;
8421 #endif
8422 if (flags & P_STRING)
8423 set_string_option(opt_idx, string, opt_flags);
8424 else
8426 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8427 if (varp != NULL) /* hidden option is not changed */
8429 if (number == 0 && string != NULL)
8431 int idx;
8433 /* Either we are given a string or we are setting option
8434 * to zero. */
8435 for (idx = 0; string[idx] == '0'; ++idx)
8437 if (string[idx] != NUL || idx == 0)
8439 /* There's another character after zeros or the string
8440 * is empty. In both cases, we are trying to set a
8441 * num option using a string. */
8442 EMSG3(_("E521: Number required: &%s = '%s'"),
8443 name, string);
8444 return; /* do nothing as we hit an error */
8448 if (flags & P_NUM)
8449 (void)set_num_option(opt_idx, varp, number,
8450 NULL, 0, opt_flags);
8451 else
8452 (void)set_bool_option(opt_idx, varp, (int)number,
8453 opt_flags);
8460 * Get the terminal code for a terminal option.
8461 * Returns NULL when not found.
8463 char_u *
8464 get_term_code(tname)
8465 char_u *tname;
8467 int opt_idx;
8468 char_u *varp;
8470 if (tname[0] != 't' || tname[1] != '_' ||
8471 tname[2] == NUL || tname[3] == NUL)
8472 return NULL;
8473 if ((opt_idx = findoption(tname)) >= 0)
8475 varp = get_varp(&(options[opt_idx]));
8476 if (varp != NULL)
8477 varp = *(char_u **)(varp);
8478 return varp;
8480 return find_termcode(tname + 2);
8483 char_u *
8484 get_highlight_default()
8486 int i;
8488 i = findoption((char_u *)"hl");
8489 if (i >= 0)
8490 return options[i].def_val[VI_DEFAULT];
8491 return (char_u *)NULL;
8494 #if defined(FEAT_MBYTE) || defined(PROTO)
8495 char_u *
8496 get_encoding_default()
8498 int i;
8500 i = findoption((char_u *)"enc");
8501 if (i >= 0)
8502 return options[i].def_val[VI_DEFAULT];
8503 return (char_u *)NULL;
8505 #endif
8508 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
8510 static int
8511 find_key_option(arg)
8512 char_u *arg;
8514 int key;
8515 int modifiers;
8518 * Don't use get_special_key_code() for t_xx, we don't want it to call
8519 * add_termcap_entry().
8521 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
8522 key = TERMCAP2KEY(arg[2], arg[3]);
8523 else
8525 --arg; /* put arg at the '<' */
8526 modifiers = 0;
8527 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
8528 if (modifiers) /* can't handle modifiers here */
8529 key = 0;
8531 return key;
8535 * if 'all' == 0: show changed options
8536 * if 'all' == 1: show all normal options
8537 * if 'all' == 2: show all terminal options
8539 static void
8540 showoptions(all, opt_flags)
8541 int all;
8542 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
8544 struct vimoption *p;
8545 int col;
8546 int isterm;
8547 char_u *varp;
8548 struct vimoption **items;
8549 int item_count;
8550 int run;
8551 int row, rows;
8552 int cols;
8553 int i;
8554 int len;
8556 #define INC 20
8557 #define GAP 3
8559 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
8560 PARAM_COUNT));
8561 if (items == NULL)
8562 return;
8564 /* Highlight title */
8565 if (all == 2)
8566 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
8567 else if (opt_flags & OPT_GLOBAL)
8568 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
8569 else if (opt_flags & OPT_LOCAL)
8570 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
8571 else
8572 MSG_PUTS_TITLE(_("\n--- Options ---"));
8575 * do the loop two times:
8576 * 1. display the short items
8577 * 2. display the long items (only strings and numbers)
8579 for (run = 1; run <= 2 && !got_int; ++run)
8582 * collect the items in items[]
8584 item_count = 0;
8585 for (p = &options[0]; p->fullname != NULL; p++)
8587 varp = NULL;
8588 isterm = istermoption(p);
8589 if (opt_flags != 0)
8591 if (p->indir != PV_NONE && !isterm)
8592 varp = get_varp_scope(p, opt_flags);
8594 else
8595 varp = get_varp(p);
8596 if (varp != NULL
8597 && ((all == 2 && isterm)
8598 || (all == 1 && !isterm)
8599 || (all == 0 && !optval_default(p, varp))))
8601 if (p->flags & P_BOOL)
8602 len = 1; /* a toggle option fits always */
8603 else
8605 option_value2string(p, opt_flags);
8606 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
8608 if ((len <= INC - GAP && run == 1) ||
8609 (len > INC - GAP && run == 2))
8610 items[item_count++] = p;
8615 * display the items
8617 if (run == 1)
8619 cols = (Columns + GAP - 3) / INC;
8620 if (cols == 0)
8621 cols = 1;
8622 rows = (item_count + cols - 1) / cols;
8624 else /* run == 2 */
8625 rows = item_count;
8626 for (row = 0; row < rows && !got_int; ++row)
8628 msg_putchar('\n'); /* go to next line */
8629 if (got_int) /* 'q' typed in more */
8630 break;
8631 col = 0;
8632 for (i = row; i < item_count; i += rows)
8634 msg_col = col; /* make columns */
8635 showoneopt(items[i], opt_flags);
8636 col += INC;
8638 out_flush();
8639 ui_breakcheck();
8642 vim_free(items);
8646 * Return TRUE if option "p" has its default value.
8648 static int
8649 optval_default(p, varp)
8650 struct vimoption *p;
8651 char_u *varp;
8653 int dvi;
8655 if (varp == NULL)
8656 return TRUE; /* hidden option is always at default */
8657 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
8658 if (p->flags & P_NUM)
8659 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
8660 if (p->flags & P_BOOL)
8661 /* the cast to long is required for Manx C, long_i is
8662 * needed for MSVC */
8663 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
8664 /* P_STRING */
8665 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
8669 * showoneopt: show the value of one option
8670 * must not be called with a hidden option!
8672 static void
8673 showoneopt(p, opt_flags)
8674 struct vimoption *p;
8675 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
8677 char_u *varp;
8678 int save_silent = silent_mode;
8680 silent_mode = FALSE;
8681 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
8683 varp = get_varp_scope(p, opt_flags);
8685 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
8686 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
8687 ? !curbufIsChanged() : !*(int *)varp))
8688 MSG_PUTS("no");
8689 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
8690 MSG_PUTS("--");
8691 else
8692 MSG_PUTS(" ");
8693 MSG_PUTS(p->fullname);
8694 if (!(p->flags & P_BOOL))
8696 msg_putchar('=');
8697 /* put value string in NameBuff */
8698 option_value2string(p, opt_flags);
8699 msg_outtrans(NameBuff);
8702 silent_mode = save_silent;
8703 info_message = FALSE;
8707 * Write modified options as ":set" commands to a file.
8709 * There are three values for "opt_flags":
8710 * OPT_GLOBAL: Write global option values and fresh values of
8711 * buffer-local options (used for start of a session
8712 * file).
8713 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
8714 * curwin (used for a vimrc file).
8715 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
8716 * and local values for window-local options of
8717 * curwin. Local values are also written when at the
8718 * default value, because a modeline or autocommand
8719 * may have set them when doing ":edit file" and the
8720 * user has set them back at the default or fresh
8721 * value.
8722 * When "local_only" is TRUE, don't write fresh
8723 * values, only local values (for ":mkview").
8724 * (fresh value = value used for a new buffer or window for a local option).
8726 * Return FAIL on error, OK otherwise.
8729 makeset(fd, opt_flags, local_only)
8730 FILE *fd;
8731 int opt_flags;
8732 int local_only;
8734 struct vimoption *p;
8735 char_u *varp; /* currently used value */
8736 char_u *varp_fresh; /* local value */
8737 char_u *varp_local = NULL; /* fresh value */
8738 char *cmd;
8739 int round;
8740 int pri;
8743 * The options that don't have a default (terminal name, columns, lines)
8744 * are never written. Terminal options are also not written.
8745 * Do the loop over "options[]" twice: once for options with the
8746 * P_PRI_MKRC flag and once without.
8748 for (pri = 1; pri >= 0; --pri)
8750 for (p = &options[0]; !istermoption(p); p++)
8751 if (!(p->flags & P_NO_MKRC)
8752 && !istermoption(p)
8753 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
8755 /* skip global option when only doing locals */
8756 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
8757 continue;
8759 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
8760 * file, they are always buffer-specific. */
8761 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
8762 continue;
8764 /* Global values are only written when not at the default value. */
8765 varp = get_varp_scope(p, opt_flags);
8766 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
8767 continue;
8769 round = 2;
8770 if (p->indir != PV_NONE)
8772 if (p->var == VAR_WIN)
8774 /* skip window-local option when only doing globals */
8775 if (!(opt_flags & OPT_LOCAL))
8776 continue;
8777 /* When fresh value of window-local option is not at the
8778 * default, need to write it too. */
8779 if (!(opt_flags & OPT_GLOBAL) && !local_only)
8781 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
8782 if (!optval_default(p, varp_fresh))
8784 round = 1;
8785 varp_local = varp;
8786 varp = varp_fresh;
8792 /* Round 1: fresh value for window-local options.
8793 * Round 2: other values */
8794 for ( ; round <= 2; varp = varp_local, ++round)
8796 if (round == 1 || (opt_flags & OPT_GLOBAL))
8797 cmd = "set";
8798 else
8799 cmd = "setlocal";
8801 if (p->flags & P_BOOL)
8803 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
8804 return FAIL;
8806 else if (p->flags & P_NUM)
8808 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
8809 return FAIL;
8811 else /* P_STRING */
8813 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
8814 int do_endif = FALSE;
8816 /* Don't set 'syntax' and 'filetype' again if the value is
8817 * already right, avoids reloading the syntax file. */
8818 if (
8819 # if defined(FEAT_SYN_HL)
8820 p->indir == PV_SYN
8821 # if defined(FEAT_AUTOCMD)
8823 # endif
8824 # endif
8825 # if defined(FEAT_AUTOCMD)
8826 p->indir == PV_FT
8827 # endif
8830 if (fprintf(fd, "if &%s != '%s'", p->fullname,
8831 *(char_u **)(varp)) < 0
8832 || put_eol(fd) < 0)
8833 return FAIL;
8834 do_endif = TRUE;
8836 #endif
8837 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
8838 (p->flags & P_EXPAND) != 0) == FAIL)
8839 return FAIL;
8840 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
8841 if (do_endif)
8843 if (put_line(fd, "endif") == FAIL)
8844 return FAIL;
8846 #endif
8851 return OK;
8854 #if defined(FEAT_FOLDING) || defined(PROTO)
8856 * Generate set commands for the local fold options only. Used when
8857 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
8860 makefoldset(fd)
8861 FILE *fd;
8863 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
8864 # ifdef FEAT_EVAL
8865 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
8866 == FAIL
8867 # endif
8868 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
8869 == FAIL
8870 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
8871 == FAIL
8872 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
8873 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
8874 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
8875 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
8877 return FAIL;
8879 return OK;
8881 #endif
8883 static int
8884 put_setstring(fd, cmd, name, valuep, expand)
8885 FILE *fd;
8886 char *cmd;
8887 char *name;
8888 char_u **valuep;
8889 int expand;
8891 char_u *s;
8892 char_u buf[MAXPATHL];
8894 if (fprintf(fd, "%s %s=", cmd, name) < 0)
8895 return FAIL;
8896 if (*valuep != NULL)
8898 /* Output 'pastetoggle' as key names. For other
8899 * options some characters have to be escaped with
8900 * CTRL-V or backslash */
8901 if (valuep == &p_pt)
8903 s = *valuep;
8904 while (*s != NUL)
8905 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
8906 return FAIL;
8908 else if (expand)
8910 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
8911 if (put_escstr(fd, buf, 2) == FAIL)
8912 return FAIL;
8914 else if (put_escstr(fd, *valuep, 2) == FAIL)
8915 return FAIL;
8917 if (put_eol(fd) < 0)
8918 return FAIL;
8919 return OK;
8922 static int
8923 put_setnum(fd, cmd, name, valuep)
8924 FILE *fd;
8925 char *cmd;
8926 char *name;
8927 long *valuep;
8929 long wc;
8931 if (fprintf(fd, "%s %s=", cmd, name) < 0)
8932 return FAIL;
8933 if (wc_use_keyname((char_u *)valuep, &wc))
8935 /* print 'wildchar' and 'wildcharm' as a key name */
8936 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
8937 return FAIL;
8939 else if (fprintf(fd, "%ld", *valuep) < 0)
8940 return FAIL;
8941 if (put_eol(fd) < 0)
8942 return FAIL;
8943 return OK;
8946 static int
8947 put_setbool(fd, cmd, name, value)
8948 FILE *fd;
8949 char *cmd;
8950 char *name;
8951 int value;
8953 if (value < 0) /* global/local option using global value */
8954 return OK;
8955 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
8956 || put_eol(fd) < 0)
8957 return FAIL;
8958 return OK;
8962 * Clear all the terminal options.
8963 * If the option has been allocated, free the memory.
8964 * Terminal options are never hidden or indirect.
8966 void
8967 clear_termoptions()
8970 * Reset a few things before clearing the old options. This may cause
8971 * outputting a few things that the terminal doesn't understand, but the
8972 * screen will be cleared later, so this is OK.
8974 #ifdef FEAT_MOUSE_TTY
8975 mch_setmouse(FALSE); /* switch mouse off */
8976 #endif
8977 #ifdef FEAT_TITLE
8978 mch_restore_title(3); /* restore window titles */
8979 #endif
8980 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
8981 /* When starting the GUI close the display opened for the clipboard.
8982 * After restoring the title, because that will need the display. */
8983 if (gui.starting)
8984 clear_xterm_clip();
8985 #endif
8986 #ifdef WIN3264
8988 * Check if this is allowed now.
8990 if (can_end_termcap_mode(FALSE) == TRUE)
8991 #endif
8992 stoptermcap(); /* stop termcap mode */
8994 free_termoptions();
8997 void
8998 free_termoptions()
9000 struct vimoption *p;
9002 for (p = &options[0]; p->fullname != NULL; p++)
9003 if (istermoption(p))
9005 if (p->flags & P_ALLOCED)
9006 free_string_option(*(char_u **)(p->var));
9007 if (p->flags & P_DEF_ALLOCED)
9008 free_string_option(p->def_val[VI_DEFAULT]);
9009 *(char_u **)(p->var) = empty_option;
9010 p->def_val[VI_DEFAULT] = empty_option;
9011 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9013 clear_termcodes();
9017 * Free the string for one term option, if it was allocated.
9018 * Set the string to empty_option and clear allocated flag.
9019 * "var" points to the option value.
9021 void
9022 free_one_termoption(var)
9023 char_u *var;
9025 struct vimoption *p;
9027 for (p = &options[0]; p->fullname != NULL; p++)
9028 if (p->var == var)
9030 if (p->flags & P_ALLOCED)
9031 free_string_option(*(char_u **)(p->var));
9032 *(char_u **)(p->var) = empty_option;
9033 p->flags &= ~P_ALLOCED;
9034 break;
9039 * Set the terminal option defaults to the current value.
9040 * Used after setting the terminal name.
9042 void
9043 set_term_defaults()
9045 struct vimoption *p;
9047 for (p = &options[0]; p->fullname != NULL; p++)
9049 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9051 if (p->flags & P_DEF_ALLOCED)
9053 free_string_option(p->def_val[VI_DEFAULT]);
9054 p->flags &= ~P_DEF_ALLOCED;
9056 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9057 if (p->flags & P_ALLOCED)
9059 p->flags |= P_DEF_ALLOCED;
9060 p->flags &= ~P_ALLOCED; /* don't free the value now */
9067 * return TRUE if 'p' starts with 't_'
9069 static int
9070 istermoption(p)
9071 struct vimoption *p;
9073 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9077 * Compute columns for ruler and shown command. 'sc_col' is also used to
9078 * decide what the maximum length of a message on the status line can be.
9079 * If there is a status line for the last window, 'sc_col' is independent
9080 * of 'ru_col'.
9083 #define COL_RULER 17 /* columns needed by standard ruler */
9085 void
9086 comp_col()
9088 #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9089 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9091 sc_col = 0;
9092 ru_col = 0;
9093 if (p_ru)
9095 #ifdef FEAT_STL_OPT
9096 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9097 #else
9098 ru_col = COL_RULER + 1;
9099 #endif
9100 /* no last status line, adjust sc_col */
9101 if (!last_has_status)
9102 sc_col = ru_col;
9104 if (p_sc)
9106 sc_col += SHOWCMD_COLS;
9107 if (!p_ru || last_has_status) /* no need for separating space */
9108 ++sc_col;
9110 sc_col = Columns - sc_col;
9111 ru_col = Columns - ru_col;
9112 if (sc_col <= 0) /* screen too narrow, will become a mess */
9113 sc_col = 1;
9114 if (ru_col <= 0)
9115 ru_col = 1;
9116 #else
9117 sc_col = Columns;
9118 ru_col = Columns;
9119 #endif
9123 * Get pointer to option variable, depending on local or global scope.
9125 static char_u *
9126 get_varp_scope(p, opt_flags)
9127 struct vimoption *p;
9128 int opt_flags;
9130 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9132 if (p->var == VAR_WIN)
9133 return (char_u *)GLOBAL_WO(get_varp(p));
9134 return p->var;
9136 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
9138 switch ((int)p->indir)
9140 #ifdef FEAT_QUICKFIX
9141 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9142 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9143 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
9144 #endif
9145 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9146 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9147 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
9148 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
9149 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
9150 #ifdef FEAT_FIND_ID
9151 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9152 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
9153 #endif
9154 #ifdef FEAT_INS_EXPAND
9155 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9156 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
9157 #endif
9158 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9159 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9160 #endif
9161 #ifdef FEAT_STL_OPT
9162 case PV_STL: return (char_u *)&(curwin->w_p_stl);
9163 #endif
9165 return NULL; /* "cannot happen" */
9167 return get_varp(p);
9171 * Get pointer to option variable.
9173 static char_u *
9174 get_varp(p)
9175 struct vimoption *p;
9177 /* hidden option, always return NULL */
9178 if (p->var == NULL)
9179 return NULL;
9181 switch ((int)p->indir)
9183 case PV_NONE: return p->var;
9185 /* global option with local value: use local value if it's been set */
9186 case PV_EP: return *curbuf->b_p_ep != NUL
9187 ? (char_u *)&curbuf->b_p_ep : p->var;
9188 case PV_KP: return *curbuf->b_p_kp != NUL
9189 ? (char_u *)&curbuf->b_p_kp : p->var;
9190 case PV_PATH: return *curbuf->b_p_path != NUL
9191 ? (char_u *)&(curbuf->b_p_path) : p->var;
9192 case PV_AR: return curbuf->b_p_ar >= 0
9193 ? (char_u *)&(curbuf->b_p_ar) : p->var;
9194 case PV_TAGS: return *curbuf->b_p_tags != NUL
9195 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9196 #ifdef FEAT_FIND_ID
9197 case PV_DEF: return *curbuf->b_p_def != NUL
9198 ? (char_u *)&(curbuf->b_p_def) : p->var;
9199 case PV_INC: return *curbuf->b_p_inc != NUL
9200 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9201 #endif
9202 #ifdef FEAT_INS_EXPAND
9203 case PV_DICT: return *curbuf->b_p_dict != NUL
9204 ? (char_u *)&(curbuf->b_p_dict) : p->var;
9205 case PV_TSR: return *curbuf->b_p_tsr != NUL
9206 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9207 #endif
9208 #ifdef FEAT_QUICKFIX
9209 case PV_EFM: return *curbuf->b_p_efm != NUL
9210 ? (char_u *)&(curbuf->b_p_efm) : p->var;
9211 case PV_GP: return *curbuf->b_p_gp != NUL
9212 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9213 case PV_MP: return *curbuf->b_p_mp != NUL
9214 ? (char_u *)&(curbuf->b_p_mp) : p->var;
9215 #endif
9216 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9217 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9218 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9219 #endif
9220 #ifdef FEAT_STL_OPT
9221 case PV_STL: return *curwin->w_p_stl != NUL
9222 ? (char_u *)&(curwin->w_p_stl) : p->var;
9223 #endif
9225 #ifdef FEAT_ARABIC
9226 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9227 #endif
9228 case PV_LIST: return (char_u *)&(curwin->w_p_list);
9229 #ifdef FEAT_SPELL
9230 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
9231 #endif
9232 #ifdef FEAT_SYN_HL
9233 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
9234 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
9235 #endif
9236 #ifdef FEAT_DIFF
9237 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
9238 #endif
9239 #ifdef FEAT_FOLDING
9240 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
9241 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
9242 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
9243 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
9244 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
9245 case PV_FML: return (char_u *)&(curwin->w_p_fml);
9246 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
9247 # ifdef FEAT_EVAL
9248 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
9249 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
9250 # endif
9251 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
9252 #endif
9253 case PV_NU: return (char_u *)&(curwin->w_p_nu);
9254 #ifdef FEAT_LINEBREAK
9255 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
9256 #endif
9257 #ifdef FEAT_WINDOWS
9258 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
9259 #endif
9260 #ifdef FEAT_VERTSPLIT
9261 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
9262 #endif
9263 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
9264 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
9265 #endif
9266 #ifdef FEAT_RIGHTLEFT
9267 case PV_RL: return (char_u *)&(curwin->w_p_rl);
9268 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
9269 #endif
9270 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
9271 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
9272 #ifdef FEAT_LINEBREAK
9273 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
9274 #endif
9275 #ifdef FEAT_SCROLLBIND
9276 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
9277 #endif
9279 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
9280 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
9281 #ifdef FEAT_MBYTE
9282 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
9283 #endif
9284 #if defined(FEAT_QUICKFIX)
9285 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
9286 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
9287 #endif
9288 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
9289 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
9290 #ifdef FEAT_CINDENT
9291 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
9292 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
9293 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
9294 #endif
9295 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9296 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
9297 #endif
9298 #ifdef FEAT_COMMENTS
9299 case PV_COM: return (char_u *)&(curbuf->b_p_com);
9300 #endif
9301 #ifdef FEAT_FOLDING
9302 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
9303 #endif
9304 #ifdef FEAT_INS_EXPAND
9305 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
9306 #endif
9307 #ifdef FEAT_COMPL_FUNC
9308 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
9309 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
9310 #endif
9311 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
9312 case PV_ET: return (char_u *)&(curbuf->b_p_et);
9313 #ifdef FEAT_MBYTE
9314 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
9315 #endif
9316 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
9317 #ifdef FEAT_AUTOCMD
9318 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
9319 #endif
9320 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
9321 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
9322 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
9323 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
9324 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
9325 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
9326 #ifdef FEAT_FIND_ID
9327 # ifdef FEAT_EVAL
9328 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
9329 # endif
9330 #endif
9331 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9332 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
9333 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
9334 #endif
9335 #ifdef FEAT_EVAL
9336 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
9337 #endif
9338 #ifdef FEAT_CRYPT
9339 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
9340 #endif
9341 #ifdef FEAT_LISP
9342 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
9343 #endif
9344 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
9345 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
9346 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
9347 #ifdef USE_MIGEMO
9348 case PV_MIG: return (char_u *)&(curbuf->b_p_migemo);
9349 #endif
9350 case PV_MOD: return (char_u *)&(curbuf->b_changed);
9351 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
9352 #ifdef FEAT_OSFILETYPE
9353 case PV_OFT: return (char_u *)&(curbuf->b_p_oft);
9354 #endif
9355 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
9356 #ifdef FEAT_TEXTOBJ
9357 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
9358 #endif
9359 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
9360 #ifdef FEAT_SMARTINDENT
9361 case PV_SI: return (char_u *)&(curbuf->b_p_si);
9362 #endif
9363 #ifndef SHORT_FNAME
9364 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
9365 #endif
9366 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
9367 #ifdef FEAT_SEARCHPATH
9368 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
9369 #endif
9370 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
9371 #ifdef FEAT_SYN_HL
9372 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
9373 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
9374 #endif
9375 #ifdef FEAT_SPELL
9376 case PV_SPC: return (char_u *)&(curbuf->b_p_spc);
9377 case PV_SPF: return (char_u *)&(curbuf->b_p_spf);
9378 case PV_SPL: return (char_u *)&(curbuf->b_p_spl);
9379 #endif
9380 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
9381 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
9382 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
9383 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
9384 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
9385 #ifdef FEAT_KEYMAP
9386 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
9387 #endif
9388 default: EMSG(_("E356: get_varp ERROR"));
9390 /* always return a valid pointer to avoid a crash! */
9391 return (char_u *)&(curbuf->b_p_wm);
9395 * Get the value of 'equalprg', either the buffer-local one or the global one.
9397 char_u *
9398 get_equalprg()
9400 if (*curbuf->b_p_ep == NUL)
9401 return p_ep;
9402 return curbuf->b_p_ep;
9405 #if defined(FEAT_WINDOWS) || defined(PROTO)
9407 * Copy options from one window to another.
9408 * Used when splitting a window.
9410 void
9411 win_copy_options(wp_from, wp_to)
9412 win_T *wp_from;
9413 win_T *wp_to;
9415 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
9416 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
9417 # ifdef FEAT_RIGHTLEFT
9418 # ifdef FEAT_FKMAP
9419 /* Is this right? */
9420 wp_to->w_farsi = wp_from->w_farsi;
9421 # endif
9422 # endif
9424 #endif
9427 * Copy the options from one winopt_T to another.
9428 * Doesn't free the old option values in "to", use clear_winopt() for that.
9429 * The 'scroll' option is not copied, because it depends on the window height.
9430 * The 'previewwindow' option is reset, there can be only one preview window.
9432 void
9433 copy_winopt(from, to)
9434 winopt_T *from;
9435 winopt_T *to;
9437 #ifdef FEAT_ARABIC
9438 to->wo_arab = from->wo_arab;
9439 #endif
9440 to->wo_list = from->wo_list;
9441 to->wo_nu = from->wo_nu;
9442 #ifdef FEAT_LINEBREAK
9443 to->wo_nuw = from->wo_nuw;
9444 #endif
9445 #ifdef FEAT_RIGHTLEFT
9446 to->wo_rl = from->wo_rl;
9447 to->wo_rlc = vim_strsave(from->wo_rlc);
9448 #endif
9449 #ifdef FEAT_STL_OPT
9450 to->wo_stl = vim_strsave(from->wo_stl);
9451 #endif
9452 to->wo_wrap = from->wo_wrap;
9453 #ifdef FEAT_LINEBREAK
9454 to->wo_lbr = from->wo_lbr;
9455 #endif
9456 #ifdef FEAT_SCROLLBIND
9457 to->wo_scb = from->wo_scb;
9458 #endif
9459 #ifdef FEAT_SPELL
9460 to->wo_spell = from->wo_spell;
9461 #endif
9462 #ifdef FEAT_SYN_HL
9463 to->wo_cuc = from->wo_cuc;
9464 to->wo_cul = from->wo_cul;
9465 #endif
9466 #ifdef FEAT_DIFF
9467 to->wo_diff = from->wo_diff;
9468 #endif
9469 #ifdef FEAT_FOLDING
9470 to->wo_fdc = from->wo_fdc;
9471 to->wo_fen = from->wo_fen;
9472 to->wo_fdi = vim_strsave(from->wo_fdi);
9473 to->wo_fml = from->wo_fml;
9474 to->wo_fdl = from->wo_fdl;
9475 to->wo_fdm = vim_strsave(from->wo_fdm);
9476 to->wo_fdn = from->wo_fdn;
9477 # ifdef FEAT_EVAL
9478 to->wo_fde = vim_strsave(from->wo_fde);
9479 to->wo_fdt = vim_strsave(from->wo_fdt);
9480 # endif
9481 to->wo_fmr = vim_strsave(from->wo_fmr);
9482 #endif
9483 check_winopt(to); /* don't want NULL pointers */
9487 * Check string options in a window for a NULL value.
9489 void
9490 check_win_options(win)
9491 win_T *win;
9493 check_winopt(&win->w_onebuf_opt);
9494 check_winopt(&win->w_allbuf_opt);
9498 * Check for NULL pointers in a winopt_T and replace them with empty_option.
9500 void
9501 check_winopt(wop)
9502 winopt_T *wop UNUSED;
9504 #ifdef FEAT_FOLDING
9505 check_string_option(&wop->wo_fdi);
9506 check_string_option(&wop->wo_fdm);
9507 # ifdef FEAT_EVAL
9508 check_string_option(&wop->wo_fde);
9509 check_string_option(&wop->wo_fdt);
9510 # endif
9511 check_string_option(&wop->wo_fmr);
9512 #endif
9513 #ifdef FEAT_RIGHTLEFT
9514 check_string_option(&wop->wo_rlc);
9515 #endif
9516 #ifdef FEAT_STL_OPT
9517 check_string_option(&wop->wo_stl);
9518 #endif
9522 * Free the allocated memory inside a winopt_T.
9524 void
9525 clear_winopt(wop)
9526 winopt_T *wop UNUSED;
9528 #ifdef FEAT_FOLDING
9529 clear_string_option(&wop->wo_fdi);
9530 clear_string_option(&wop->wo_fdm);
9531 # ifdef FEAT_EVAL
9532 clear_string_option(&wop->wo_fde);
9533 clear_string_option(&wop->wo_fdt);
9534 # endif
9535 clear_string_option(&wop->wo_fmr);
9536 #endif
9537 #ifdef FEAT_RIGHTLEFT
9538 clear_string_option(&wop->wo_rlc);
9539 #endif
9540 #ifdef FEAT_STL_OPT
9541 clear_string_option(&wop->wo_stl);
9542 #endif
9546 * Copy global option values to local options for one buffer.
9547 * Used when creating a new buffer and sometimes when entering a buffer.
9548 * flags:
9549 * BCO_ENTER We will enter the buf buffer.
9550 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
9551 * appropriate.
9552 * BCO_NOHELP Don't copy the values to a help buffer.
9554 void
9555 buf_copy_options(buf, flags)
9556 buf_T *buf;
9557 int flags;
9559 int should_copy = TRUE;
9560 char_u *save_p_isk = NULL; /* init for GCC */
9561 int dont_do_help;
9562 int did_isk = FALSE;
9565 * Don't do anything of the buffer is invalid.
9567 if (buf == NULL || !buf_valid(buf))
9568 return;
9571 * Skip this when the option defaults have not been set yet. Happens when
9572 * main() allocates the first buffer.
9574 if (p_cpo != NULL)
9577 * Always copy when entering and 'cpo' contains 'S'.
9578 * Don't copy when already initialized.
9579 * Don't copy when 'cpo' contains 's' and not entering.
9580 * 'S' BCO_ENTER initialized 's' should_copy
9581 * yes yes X X TRUE
9582 * yes no yes X FALSE
9583 * no X yes X FALSE
9584 * X no no yes FALSE
9585 * X no no no TRUE
9586 * no yes no X TRUE
9588 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
9589 && (buf->b_p_initialized
9590 || (!(flags & BCO_ENTER)
9591 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
9592 should_copy = FALSE;
9594 if (should_copy || (flags & BCO_ALWAYS))
9596 /* Don't copy the options specific to a help buffer when
9597 * BCO_NOHELP is given or the options were initialized already
9598 * (jumping back to a help file with CTRL-T or CTRL-O) */
9599 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
9600 || buf->b_p_initialized;
9601 if (dont_do_help) /* don't free b_p_isk */
9603 save_p_isk = buf->b_p_isk;
9604 buf->b_p_isk = NULL;
9607 * Always free the allocated strings.
9608 * If not already initialized, set 'readonly' and copy 'fileformat'.
9610 if (!buf->b_p_initialized)
9612 free_buf_options(buf, TRUE);
9613 buf->b_p_ro = FALSE; /* don't copy readonly */
9614 buf->b_p_tx = p_tx;
9615 #ifdef FEAT_MBYTE
9616 buf->b_p_fenc = vim_strsave(p_fenc);
9617 #endif
9618 buf->b_p_ff = vim_strsave(p_ff);
9619 #if defined(FEAT_QUICKFIX)
9620 buf->b_p_bh = empty_option;
9621 buf->b_p_bt = empty_option;
9622 #endif
9624 else
9625 free_buf_options(buf, FALSE);
9627 buf->b_p_ai = p_ai;
9628 buf->b_p_ai_nopaste = p_ai_nopaste;
9629 buf->b_p_sw = p_sw;
9630 buf->b_p_tw = p_tw;
9631 buf->b_p_tw_nopaste = p_tw_nopaste;
9632 buf->b_p_tw_nobin = p_tw_nobin;
9633 buf->b_p_wm = p_wm;
9634 buf->b_p_wm_nopaste = p_wm_nopaste;
9635 buf->b_p_wm_nobin = p_wm_nobin;
9636 buf->b_p_bin = p_bin;
9637 #ifdef FEAT_MBYTE
9638 buf->b_p_bomb = p_bomb;
9639 #endif
9640 buf->b_p_et = p_et;
9641 buf->b_p_et_nobin = p_et_nobin;
9642 buf->b_p_ml = p_ml;
9643 buf->b_p_ml_nobin = p_ml_nobin;
9644 buf->b_p_inf = p_inf;
9645 buf->b_p_swf = p_swf;
9646 #ifdef FEAT_INS_EXPAND
9647 buf->b_p_cpt = vim_strsave(p_cpt);
9648 #endif
9649 #ifdef FEAT_COMPL_FUNC
9650 buf->b_p_cfu = vim_strsave(p_cfu);
9651 buf->b_p_ofu = vim_strsave(p_ofu);
9652 #endif
9653 buf->b_p_sts = p_sts;
9654 buf->b_p_sts_nopaste = p_sts_nopaste;
9655 #ifndef SHORT_FNAME
9656 buf->b_p_sn = p_sn;
9657 #endif
9658 #ifdef FEAT_COMMENTS
9659 buf->b_p_com = vim_strsave(p_com);
9660 #endif
9661 #ifdef FEAT_FOLDING
9662 buf->b_p_cms = vim_strsave(p_cms);
9663 #endif
9664 buf->b_p_fo = vim_strsave(p_fo);
9665 buf->b_p_flp = vim_strsave(p_flp);
9666 buf->b_p_nf = vim_strsave(p_nf);
9667 buf->b_p_mps = vim_strsave(p_mps);
9668 #ifdef FEAT_SMARTINDENT
9669 buf->b_p_si = p_si;
9670 #endif
9671 buf->b_p_ci = p_ci;
9672 #ifdef FEAT_CINDENT
9673 buf->b_p_cin = p_cin;
9674 buf->b_p_cink = vim_strsave(p_cink);
9675 buf->b_p_cino = vim_strsave(p_cino);
9676 #endif
9677 #ifdef FEAT_AUTOCMD
9678 /* Don't copy 'filetype', it must be detected */
9679 buf->b_p_ft = empty_option;
9680 #endif
9681 #ifdef FEAT_OSFILETYPE
9682 buf->b_p_oft = vim_strsave(p_oft);
9683 #endif
9684 buf->b_p_pi = p_pi;
9685 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9686 buf->b_p_cinw = vim_strsave(p_cinw);
9687 #endif
9688 #ifdef FEAT_LISP
9689 buf->b_p_lisp = p_lisp;
9690 #endif
9691 #ifdef FEAT_SYN_HL
9692 /* Don't copy 'syntax', it must be set */
9693 buf->b_p_syn = empty_option;
9694 buf->b_p_smc = p_smc;
9695 #endif
9696 #ifdef FEAT_SPELL
9697 buf->b_p_spc = vim_strsave(p_spc);
9698 (void)compile_cap_prog(buf);
9699 buf->b_p_spf = vim_strsave(p_spf);
9700 buf->b_p_spl = vim_strsave(p_spl);
9701 #endif
9702 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9703 buf->b_p_inde = vim_strsave(p_inde);
9704 buf->b_p_indk = vim_strsave(p_indk);
9705 #endif
9706 #if defined(FEAT_EVAL)
9707 buf->b_p_fex = vim_strsave(p_fex);
9708 #endif
9709 #ifdef FEAT_CRYPT
9710 buf->b_p_key = vim_strsave(p_key);
9711 #endif
9712 #ifdef FEAT_SEARCHPATH
9713 buf->b_p_sua = vim_strsave(p_sua);
9714 #endif
9715 #ifdef FEAT_KEYMAP
9716 buf->b_p_keymap = vim_strsave(p_keymap);
9717 buf->b_kmap_state |= KEYMAP_INIT;
9718 #endif
9719 /* This isn't really an option, but copying the langmap and IME
9720 * state from the current buffer is better than resetting it. */
9721 buf->b_p_iminsert = p_iminsert;
9722 buf->b_p_imsearch = p_imsearch;
9724 #ifdef USE_MIGEMO
9725 /* This is migemo extension */
9726 buf->b_p_migemo = p_migemo;
9727 #endif
9729 /* options that are normally global but also have a local value
9730 * are not copied, start using the global value */
9731 buf->b_p_ar = -1;
9732 #ifdef FEAT_QUICKFIX
9733 buf->b_p_gp = empty_option;
9734 buf->b_p_mp = empty_option;
9735 buf->b_p_efm = empty_option;
9736 #endif
9737 buf->b_p_ep = empty_option;
9738 buf->b_p_kp = empty_option;
9739 buf->b_p_path = empty_option;
9740 buf->b_p_tags = empty_option;
9741 #ifdef FEAT_FIND_ID
9742 buf->b_p_def = empty_option;
9743 buf->b_p_inc = empty_option;
9744 # ifdef FEAT_EVAL
9745 buf->b_p_inex = vim_strsave(p_inex);
9746 # endif
9747 #endif
9748 #ifdef FEAT_INS_EXPAND
9749 buf->b_p_dict = empty_option;
9750 buf->b_p_tsr = empty_option;
9751 #endif
9752 #ifdef FEAT_TEXTOBJ
9753 buf->b_p_qe = vim_strsave(p_qe);
9754 #endif
9755 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9756 buf->b_p_bexpr = empty_option;
9757 #endif
9760 * Don't copy the options set by ex_help(), use the saved values,
9761 * when going from a help buffer to a non-help buffer.
9762 * Don't touch these at all when BCO_NOHELP is used and going from
9763 * or to a help buffer.
9765 if (dont_do_help)
9766 buf->b_p_isk = save_p_isk;
9767 else
9769 buf->b_p_isk = vim_strsave(p_isk);
9770 did_isk = TRUE;
9771 buf->b_p_ts = p_ts;
9772 buf->b_help = FALSE;
9773 #ifdef FEAT_QUICKFIX
9774 if (buf->b_p_bt[0] == 'h')
9775 clear_string_option(&buf->b_p_bt);
9776 #endif
9777 buf->b_p_ma = p_ma;
9782 * When the options should be copied (ignoring BCO_ALWAYS), set the
9783 * flag that indicates that the options have been initialized.
9785 if (should_copy)
9786 buf->b_p_initialized = TRUE;
9789 check_buf_options(buf); /* make sure we don't have NULLs */
9790 if (did_isk)
9791 (void)buf_init_chartab(buf, FALSE);
9795 * Reset the 'modifiable' option and its default value.
9797 void
9798 reset_modifiable()
9800 int opt_idx;
9802 curbuf->b_p_ma = FALSE;
9803 p_ma = FALSE;
9804 opt_idx = findoption((char_u *)"ma");
9805 if (opt_idx >= 0)
9806 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
9810 * Set the global value for 'iminsert' to the local value.
9812 void
9813 set_iminsert_global()
9815 p_iminsert = curbuf->b_p_iminsert;
9819 * Set the global value for 'imsearch' to the local value.
9821 void
9822 set_imsearch_global()
9824 p_imsearch = curbuf->b_p_imsearch;
9827 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
9828 static int expand_option_idx = -1;
9829 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
9830 static int expand_option_flags = 0;
9832 void
9833 set_context_in_set_cmd(xp, arg, opt_flags)
9834 expand_T *xp;
9835 char_u *arg;
9836 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
9838 int nextchar;
9839 long_u flags = 0; /* init for GCC */
9840 int opt_idx = 0; /* init for GCC */
9841 char_u *p;
9842 char_u *s;
9843 int is_term_option = FALSE;
9844 int key;
9846 expand_option_flags = opt_flags;
9848 xp->xp_context = EXPAND_SETTINGS;
9849 if (*arg == NUL)
9851 xp->xp_pattern = arg;
9852 return;
9854 p = arg + STRLEN(arg) - 1;
9855 if (*p == ' ' && *(p - 1) != '\\')
9857 xp->xp_pattern = p + 1;
9858 return;
9860 while (p > arg)
9862 s = p;
9863 /* count number of backslashes before ' ' or ',' */
9864 if (*p == ' ' || *p == ',')
9866 while (s > arg && *(s - 1) == '\\')
9867 --s;
9869 /* break at a space with an even number of backslashes */
9870 if (*p == ' ' && ((p - s) & 1) == 0)
9872 ++p;
9873 break;
9875 --p;
9877 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
9879 xp->xp_context = EXPAND_BOOL_SETTINGS;
9880 p += 2;
9882 if (STRNCMP(p, "inv", 3) == 0)
9884 xp->xp_context = EXPAND_BOOL_SETTINGS;
9885 p += 3;
9887 xp->xp_pattern = arg = p;
9888 if (*arg == '<')
9890 while (*p != '>')
9891 if (*p++ == NUL) /* expand terminal option name */
9892 return;
9893 key = get_special_key_code(arg + 1);
9894 if (key == 0) /* unknown name */
9896 xp->xp_context = EXPAND_NOTHING;
9897 return;
9899 nextchar = *++p;
9900 is_term_option = TRUE;
9901 expand_option_name[2] = KEY2TERMCAP0(key);
9902 expand_option_name[3] = KEY2TERMCAP1(key);
9904 else
9906 if (p[0] == 't' && p[1] == '_')
9908 p += 2;
9909 if (*p != NUL)
9910 ++p;
9911 if (*p == NUL)
9912 return; /* expand option name */
9913 nextchar = *++p;
9914 is_term_option = TRUE;
9915 expand_option_name[2] = p[-2];
9916 expand_option_name[3] = p[-1];
9918 else
9920 /* Allow * wildcard */
9921 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
9922 p++;
9923 if (*p == NUL)
9924 return;
9925 nextchar = *p;
9926 *p = NUL;
9927 opt_idx = findoption(arg);
9928 *p = nextchar;
9929 if (opt_idx == -1 || options[opt_idx].var == NULL)
9931 xp->xp_context = EXPAND_NOTHING;
9932 return;
9934 flags = options[opt_idx].flags;
9935 if (flags & P_BOOL)
9937 xp->xp_context = EXPAND_NOTHING;
9938 return;
9942 /* handle "-=" and "+=" */
9943 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
9945 ++p;
9946 nextchar = '=';
9948 if ((nextchar != '=' && nextchar != ':')
9949 || xp->xp_context == EXPAND_BOOL_SETTINGS)
9951 xp->xp_context = EXPAND_UNSUCCESSFUL;
9952 return;
9954 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
9956 xp->xp_context = EXPAND_OLD_SETTING;
9957 if (is_term_option)
9958 expand_option_idx = -1;
9959 else
9960 expand_option_idx = opt_idx;
9961 xp->xp_pattern = p + 1;
9962 return;
9964 xp->xp_context = EXPAND_NOTHING;
9965 if (is_term_option || (flags & P_NUM))
9966 return;
9968 xp->xp_pattern = p + 1;
9970 if (flags & P_EXPAND)
9972 p = options[opt_idx].var;
9973 if (p == (char_u *)&p_bdir
9974 || p == (char_u *)&p_dir
9975 || p == (char_u *)&p_path
9976 || p == (char_u *)&p_rtp
9977 #ifdef FEAT_SEARCHPATH
9978 || p == (char_u *)&p_cdpath
9979 #endif
9980 #ifdef FEAT_SESSION
9981 || p == (char_u *)&p_vdir
9982 #endif
9985 xp->xp_context = EXPAND_DIRECTORIES;
9986 if (p == (char_u *)&p_path
9987 #ifdef FEAT_SEARCHPATH
9988 || p == (char_u *)&p_cdpath
9989 #endif
9991 xp->xp_backslash = XP_BS_THREE;
9992 else
9993 xp->xp_backslash = XP_BS_ONE;
9995 else
9997 xp->xp_context = EXPAND_FILES;
9998 /* for 'tags' need three backslashes for a space */
9999 if (p == (char_u *)&p_tags)
10000 xp->xp_backslash = XP_BS_THREE;
10001 else
10002 xp->xp_backslash = XP_BS_ONE;
10006 /* For an option that is a list of file names, find the start of the
10007 * last file name. */
10008 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
10010 /* count number of backslashes before ' ' or ',' */
10011 if (*p == ' ' || *p == ',')
10013 s = p;
10014 while (s > xp->xp_pattern && *(s - 1) == '\\')
10015 --s;
10016 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10017 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10019 xp->xp_pattern = p + 1;
10020 break;
10024 #ifdef FEAT_SPELL
10025 /* for 'spellsuggest' start at "file:" */
10026 if (options[opt_idx].var == (char_u *)&p_sps
10027 && STRNCMP(p, "file:", 5) == 0)
10029 xp->xp_pattern = p + 5;
10030 break;
10032 #endif
10035 return;
10039 ExpandSettings(xp, regmatch, num_file, file)
10040 expand_T *xp;
10041 regmatch_T *regmatch;
10042 int *num_file;
10043 char_u ***file;
10045 int num_normal = 0; /* Nr of matching non-term-code settings */
10046 int num_term = 0; /* Nr of matching terminal code settings */
10047 int opt_idx;
10048 int match;
10049 int count = 0;
10050 char_u *str;
10051 int loop;
10052 int is_term_opt;
10053 char_u name_buf[MAX_KEY_NAME_LEN];
10054 static char *(names[]) = {"all", "termcap"};
10055 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10057 /* do this loop twice:
10058 * loop == 0: count the number of matching options
10059 * loop == 1: copy the matching options into allocated memory
10061 for (loop = 0; loop <= 1; ++loop)
10063 regmatch->rm_ic = ic;
10064 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10066 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10067 ++match)
10068 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10070 if (loop == 0)
10071 num_normal++;
10072 else
10073 (*file)[count++] = vim_strsave((char_u *)names[match]);
10076 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10077 opt_idx++)
10079 if (options[opt_idx].var == NULL)
10080 continue;
10081 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10082 && !(options[opt_idx].flags & P_BOOL))
10083 continue;
10084 is_term_opt = istermoption(&options[opt_idx]);
10085 if (is_term_opt && num_normal > 0)
10086 continue;
10087 match = FALSE;
10088 if (vim_regexec(regmatch, str, (colnr_T)0)
10089 || (options[opt_idx].shortname != NULL
10090 && vim_regexec(regmatch,
10091 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10092 match = TRUE;
10093 else if (is_term_opt)
10095 name_buf[0] = '<';
10096 name_buf[1] = 't';
10097 name_buf[2] = '_';
10098 name_buf[3] = str[2];
10099 name_buf[4] = str[3];
10100 name_buf[5] = '>';
10101 name_buf[6] = NUL;
10102 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10104 match = TRUE;
10105 str = name_buf;
10108 if (match)
10110 if (loop == 0)
10112 if (is_term_opt)
10113 num_term++;
10114 else
10115 num_normal++;
10117 else
10118 (*file)[count++] = vim_strsave(str);
10122 * Check terminal key codes, these are not in the option table
10124 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10126 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10128 if (!isprint(str[0]) || !isprint(str[1]))
10129 continue;
10131 name_buf[0] = 't';
10132 name_buf[1] = '_';
10133 name_buf[2] = str[0];
10134 name_buf[3] = str[1];
10135 name_buf[4] = NUL;
10137 match = FALSE;
10138 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10139 match = TRUE;
10140 else
10142 name_buf[0] = '<';
10143 name_buf[1] = 't';
10144 name_buf[2] = '_';
10145 name_buf[3] = str[0];
10146 name_buf[4] = str[1];
10147 name_buf[5] = '>';
10148 name_buf[6] = NUL;
10150 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10151 match = TRUE;
10153 if (match)
10155 if (loop == 0)
10156 num_term++;
10157 else
10158 (*file)[count++] = vim_strsave(name_buf);
10163 * Check special key names.
10165 regmatch->rm_ic = TRUE; /* ignore case here */
10166 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10168 name_buf[0] = '<';
10169 STRCPY(name_buf + 1, str);
10170 STRCAT(name_buf, ">");
10172 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10174 if (loop == 0)
10175 num_term++;
10176 else
10177 (*file)[count++] = vim_strsave(name_buf);
10181 if (loop == 0)
10183 if (num_normal > 0)
10184 *num_file = num_normal;
10185 else if (num_term > 0)
10186 *num_file = num_term;
10187 else
10188 return OK;
10189 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
10190 if (*file == NULL)
10192 *file = (char_u **)"";
10193 return FAIL;
10197 return OK;
10201 ExpandOldSetting(num_file, file)
10202 int *num_file;
10203 char_u ***file;
10205 char_u *var = NULL; /* init for GCC */
10206 char_u *buf;
10208 *num_file = 0;
10209 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
10210 if (*file == NULL)
10211 return FAIL;
10214 * For a terminal key code expand_option_idx is < 0.
10216 if (expand_option_idx < 0)
10218 var = find_termcode(expand_option_name + 2);
10219 if (var == NULL)
10220 expand_option_idx = findoption(expand_option_name);
10223 if (expand_option_idx >= 0)
10225 /* put string of option value in NameBuff */
10226 option_value2string(&options[expand_option_idx], expand_option_flags);
10227 var = NameBuff;
10229 else if (var == NULL)
10230 var = (char_u *)"";
10232 /* A backslash is required before some characters. This is the reverse of
10233 * what happens in do_set(). */
10234 buf = vim_strsave_escaped(var, escape_chars);
10236 if (buf == NULL)
10238 vim_free(*file);
10239 *file = NULL;
10240 return FAIL;
10243 #ifdef BACKSLASH_IN_FILENAME
10244 /* For MS-Windows et al. we don't double backslashes at the start and
10245 * before a file name character. */
10246 for (var = buf; *var != NUL; mb_ptr_adv(var))
10247 if (var[0] == '\\' && var[1] == '\\'
10248 && expand_option_idx >= 0
10249 && (options[expand_option_idx].flags & P_EXPAND)
10250 && vim_isfilec(var[2])
10251 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
10252 STRMOVE(var, var + 1);
10253 #endif
10255 *file[0] = buf;
10256 *num_file = 1;
10257 return OK;
10259 #endif
10262 * Get the value for the numeric or string option *opp in a nice format into
10263 * NameBuff[]. Must not be called with a hidden option!
10265 static void
10266 option_value2string(opp, opt_flags)
10267 struct vimoption *opp;
10268 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10270 char_u *varp;
10272 varp = get_varp_scope(opp, opt_flags);
10274 if (opp->flags & P_NUM)
10276 long wc = 0;
10278 if (wc_use_keyname(varp, &wc))
10279 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
10280 else if (wc != 0)
10281 STRCPY(NameBuff, transchar((int)wc));
10282 else
10283 sprintf((char *)NameBuff, "%ld", *(long *)varp);
10285 else /* P_STRING */
10287 varp = *(char_u **)(varp);
10288 if (varp == NULL) /* just in case */
10289 NameBuff[0] = NUL;
10290 #ifdef FEAT_CRYPT
10291 /* don't show the actual value of 'key', only that it's set */
10292 else if (opp->var == (char_u *)&p_key && *varp)
10293 STRCPY(NameBuff, "*****");
10294 #endif
10295 else if (opp->flags & P_EXPAND)
10296 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
10297 /* Translate 'pastetoggle' into special key names */
10298 else if ((char_u **)opp->var == &p_pt)
10299 str2specialbuf(p_pt, NameBuff, MAXPATHL);
10300 else
10301 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
10306 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
10307 * printed as a keyname.
10308 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
10310 static int
10311 wc_use_keyname(varp, wcp)
10312 char_u *varp;
10313 long *wcp;
10315 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
10317 *wcp = *(long *)varp;
10318 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
10319 return TRUE;
10321 return FALSE;
10324 #ifdef FEAT_LANGMAP
10326 * Any character has an equivalent 'langmap' character. This is used for
10327 * keyboards that have a special language mode that sends characters above
10328 * 128 (although other characters can be translated too). The "to" field is a
10329 * Vim command character. This avoids having to switch the keyboard back to
10330 * ASCII mode when leaving Insert mode.
10332 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
10333 * commands.
10334 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
10335 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
10336 * 256.
10338 # ifdef FEAT_MBYTE
10340 * With multi-byte support use growarray for 'langmap' chars >= 256
10342 typedef struct
10344 int from;
10345 int to;
10346 } langmap_entry_T;
10348 static garray_T langmap_mapga;
10349 static void langmap_set_entry __ARGS((int from, int to));
10352 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
10353 * field. If not found insert a new entry at the appropriate location.
10355 static void
10356 langmap_set_entry(from, to)
10357 int from;
10358 int to;
10360 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
10361 int a = 0;
10362 int b = langmap_mapga.ga_len;
10364 /* Do a binary search for an existing entry. */
10365 while (a != b)
10367 int i = (a + b) / 2;
10368 int d = entries[i].from - from;
10370 if (d == 0)
10372 entries[i].to = to;
10373 return;
10375 if (d < 0)
10376 a = i + 1;
10377 else
10378 b = i;
10381 if (ga_grow(&langmap_mapga, 1) != OK)
10382 return; /* out of memory */
10384 /* insert new entry at position "a" */
10385 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
10386 mch_memmove(entries + 1, entries,
10387 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
10388 ++langmap_mapga.ga_len;
10389 entries[0].from = from;
10390 entries[0].to = to;
10394 * Apply 'langmap' to multi-byte character "c" and return the result.
10397 langmap_adjust_mb(c)
10398 int c;
10400 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
10401 int a = 0;
10402 int b = langmap_mapga.ga_len;
10404 while (a != b)
10406 int i = (a + b) / 2;
10407 int d = entries[i].from - c;
10409 if (d == 0)
10410 return entries[i].to; /* found matching entry */
10411 if (d < 0)
10412 a = i + 1;
10413 else
10414 b = i;
10416 return c; /* no entry found, return "c" unmodified */
10418 # endif
10420 static void
10421 langmap_init()
10423 int i;
10425 for (i = 0; i < 256; i++)
10426 langmap_mapchar[i] = i; /* we init with a one-to-one map */
10427 # ifdef FEAT_MBYTE
10428 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
10429 # endif
10433 * Called when langmap option is set; the language map can be
10434 * changed at any time!
10436 static void
10437 langmap_set()
10439 char_u *p;
10440 char_u *p2;
10441 int from, to;
10443 #ifdef FEAT_MBYTE
10444 ga_clear(&langmap_mapga); /* clear the previous map first */
10445 #endif
10446 langmap_init(); /* back to one-to-one map */
10448 for (p = p_langmap; p[0] != NUL; )
10450 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
10451 mb_ptr_adv(p2))
10453 if (p2[0] == '\\' && p2[1] != NUL)
10454 ++p2;
10456 if (p2[0] == ';')
10457 ++p2; /* abcd;ABCD form, p2 points to A */
10458 else
10459 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
10460 while (p[0])
10462 if (p[0] == '\\' && p[1] != NUL)
10463 ++p;
10464 #ifdef FEAT_MBYTE
10465 from = (*mb_ptr2char)(p);
10466 #else
10467 from = p[0];
10468 #endif
10469 if (p2 == NULL)
10471 mb_ptr_adv(p);
10472 if (p[0] == '\\')
10473 ++p;
10474 #ifdef FEAT_MBYTE
10475 to = (*mb_ptr2char)(p);
10476 #else
10477 to = p[0];
10478 #endif
10480 else
10482 if (p2[0] == '\\')
10483 ++p2;
10484 #ifdef FEAT_MBYTE
10485 to = (*mb_ptr2char)(p2);
10486 #else
10487 to = p2[0];
10488 #endif
10490 if (to == NUL)
10492 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
10493 transchar(from));
10494 return;
10497 #ifdef FEAT_MBYTE
10498 if (from >= 256)
10499 langmap_set_entry(from, to);
10500 else
10501 #endif
10502 langmap_mapchar[from & 255] = to;
10504 /* Advance to next pair */
10505 mb_ptr_adv(p);
10506 if (p2 == NULL)
10508 if (p[0] == ',')
10510 ++p;
10511 break;
10514 else
10516 mb_ptr_adv(p2);
10517 if (*p == ';')
10519 p = p2;
10520 if (p[0] != NUL)
10522 if (p[0] != ',')
10524 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
10525 return;
10527 ++p;
10529 break;
10535 #endif
10538 * Return TRUE if format option 'x' is in effect.
10539 * Take care of no formatting when 'paste' is set.
10542 has_format_option(x)
10543 int x;
10545 if (p_paste)
10546 return FALSE;
10547 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
10551 * Return TRUE if "x" is present in 'shortmess' option, or
10552 * 'shortmess' contains 'a' and "x" is present in SHM_A.
10555 shortmess(x)
10556 int x;
10558 return ( vim_strchr(p_shm, x) != NULL
10559 || (vim_strchr(p_shm, 'a') != NULL
10560 && vim_strchr((char_u *)SHM_A, x) != NULL));
10564 * paste_option_changed() - Called after p_paste was set or reset.
10566 static void
10567 paste_option_changed()
10569 static int old_p_paste = FALSE;
10570 static int save_sm = 0;
10571 #ifdef FEAT_CMDL_INFO
10572 static int save_ru = 0;
10573 #endif
10574 #ifdef FEAT_RIGHTLEFT
10575 static int save_ri = 0;
10576 static int save_hkmap = 0;
10577 #endif
10578 buf_T *buf;
10580 if (p_paste)
10583 * Paste switched from off to on.
10584 * Save the current values, so they can be restored later.
10586 if (!old_p_paste)
10588 /* save options for each buffer */
10589 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10591 buf->b_p_tw_nopaste = buf->b_p_tw;
10592 buf->b_p_wm_nopaste = buf->b_p_wm;
10593 buf->b_p_sts_nopaste = buf->b_p_sts;
10594 buf->b_p_ai_nopaste = buf->b_p_ai;
10597 /* save global options */
10598 save_sm = p_sm;
10599 #ifdef FEAT_CMDL_INFO
10600 save_ru = p_ru;
10601 #endif
10602 #ifdef FEAT_RIGHTLEFT
10603 save_ri = p_ri;
10604 save_hkmap = p_hkmap;
10605 #endif
10606 /* save global values for local buffer options */
10607 p_tw_nopaste = p_tw;
10608 p_wm_nopaste = p_wm;
10609 p_sts_nopaste = p_sts;
10610 p_ai_nopaste = p_ai;
10614 * Always set the option values, also when 'paste' is set when it is
10615 * already on.
10617 /* set options for each buffer */
10618 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10620 buf->b_p_tw = 0; /* textwidth is 0 */
10621 buf->b_p_wm = 0; /* wrapmargin is 0 */
10622 buf->b_p_sts = 0; /* softtabstop is 0 */
10623 buf->b_p_ai = 0; /* no auto-indent */
10626 /* set global options */
10627 p_sm = 0; /* no showmatch */
10628 #ifdef FEAT_CMDL_INFO
10629 # ifdef FEAT_WINDOWS
10630 if (p_ru)
10631 status_redraw_all(); /* redraw to remove the ruler */
10632 # endif
10633 p_ru = 0; /* no ruler */
10634 #endif
10635 #ifdef FEAT_RIGHTLEFT
10636 p_ri = 0; /* no reverse insert */
10637 p_hkmap = 0; /* no Hebrew keyboard */
10638 #endif
10639 /* set global values for local buffer options */
10640 p_tw = 0;
10641 p_wm = 0;
10642 p_sts = 0;
10643 p_ai = 0;
10647 * Paste switched from on to off: Restore saved values.
10649 else if (old_p_paste)
10651 /* restore options for each buffer */
10652 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
10654 buf->b_p_tw = buf->b_p_tw_nopaste;
10655 buf->b_p_wm = buf->b_p_wm_nopaste;
10656 buf->b_p_sts = buf->b_p_sts_nopaste;
10657 buf->b_p_ai = buf->b_p_ai_nopaste;
10660 /* restore global options */
10661 p_sm = save_sm;
10662 #ifdef FEAT_CMDL_INFO
10663 # ifdef FEAT_WINDOWS
10664 if (p_ru != save_ru)
10665 status_redraw_all(); /* redraw to draw the ruler */
10666 # endif
10667 p_ru = save_ru;
10668 #endif
10669 #ifdef FEAT_RIGHTLEFT
10670 p_ri = save_ri;
10671 p_hkmap = save_hkmap;
10672 #endif
10673 /* set global values for local buffer options */
10674 p_tw = p_tw_nopaste;
10675 p_wm = p_wm_nopaste;
10676 p_sts = p_sts_nopaste;
10677 p_ai = p_ai_nopaste;
10680 old_p_paste = p_paste;
10684 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
10686 * Reset 'compatible' and set the values for options that didn't get set yet
10687 * to the Vim defaults.
10688 * Don't do this if the 'compatible' option has been set or reset before.
10689 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
10691 void
10692 vimrc_found(fname, envname)
10693 char_u *fname;
10694 char_u *envname;
10696 int opt_idx;
10697 int dofree = FALSE;
10698 char_u *p;
10700 if (!option_was_set((char_u *)"cp"))
10702 p_cp = FALSE;
10703 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
10704 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
10705 set_option_default(opt_idx, OPT_FREE, FALSE);
10706 didset_options();
10709 if (fname != NULL)
10711 p = vim_getenv(envname, &dofree);
10712 if (p == NULL)
10714 /* Set $MYVIMRC to the first vimrc file found. */
10715 p = FullName_save(fname, FALSE);
10716 if (p != NULL)
10718 vim_setenv(envname, p);
10719 vim_free(p);
10722 else if (dofree)
10723 vim_free(p);
10728 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
10730 void
10731 change_compatible(on)
10732 int on;
10734 int opt_idx;
10736 if (p_cp != on)
10738 p_cp = on;
10739 compatible_set();
10741 opt_idx = findoption((char_u *)"cp");
10742 if (opt_idx >= 0)
10743 options[opt_idx].flags |= P_WAS_SET;
10747 * Return TRUE when option "name" has been set.
10750 option_was_set(name)
10751 char_u *name;
10753 int idx;
10755 idx = findoption(name);
10756 if (idx < 0) /* unknown option */
10757 return FALSE;
10758 if (options[idx].flags & P_WAS_SET)
10759 return TRUE;
10760 return FALSE;
10764 * compatible_set() - Called when 'compatible' has been set or unset.
10766 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
10767 * flag) to a Vi compatible value.
10768 * When 'compatible' is unset: Set all options that have a different default
10769 * for Vim (without the P_VI_DEF flag) to that default.
10771 static void
10772 compatible_set()
10774 int opt_idx;
10776 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
10777 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
10778 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
10779 set_option_default(opt_idx, OPT_FREE, p_cp);
10780 didset_options();
10783 #ifdef FEAT_LINEBREAK
10785 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
10786 /* Borland C++ screws up loop optimisation here (negri) */
10787 #pragma option -O-l
10788 # endif
10791 * fill_breakat_flags() -- called when 'breakat' changes value.
10793 static void
10794 fill_breakat_flags()
10796 char_u *p;
10797 int i;
10799 for (i = 0; i < 256; i++)
10800 breakat_flags[i] = FALSE;
10802 if (p_breakat != NULL)
10803 for (p = p_breakat; *p; p++)
10804 breakat_flags[*p] = TRUE;
10807 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
10808 #pragma option -O.l
10809 # endif
10811 #endif
10814 * Check an option that can be a range of string values.
10816 * Return OK for correct value, FAIL otherwise.
10817 * Empty is always OK.
10819 static int
10820 check_opt_strings(val, values, list)
10821 char_u *val;
10822 char **values;
10823 int list; /* when TRUE: accept a list of values */
10825 return opt_strings_flags(val, values, NULL, list);
10829 * Handle an option that can be a range of string values.
10830 * Set a flag in "*flagp" for each string present.
10832 * Return OK for correct value, FAIL otherwise.
10833 * Empty is always OK.
10835 static int
10836 opt_strings_flags(val, values, flagp, list)
10837 char_u *val; /* new value */
10838 char **values; /* array of valid string values */
10839 unsigned *flagp;
10840 int list; /* when TRUE: accept a list of values */
10842 int i;
10843 int len;
10844 unsigned new_flags = 0;
10846 while (*val)
10848 for (i = 0; ; ++i)
10850 if (values[i] == NULL) /* val not found in values[] */
10851 return FAIL;
10853 len = (int)STRLEN(values[i]);
10854 if (STRNCMP(values[i], val, len) == 0
10855 && ((list && val[len] == ',') || val[len] == NUL))
10857 val += len + (val[len] == ',');
10858 new_flags |= (1 << i);
10859 break; /* check next item in val list */
10863 if (flagp != NULL)
10864 *flagp = new_flags;
10866 return OK;
10870 * Read the 'wildmode' option, fill wim_flags[].
10872 static int
10873 check_opt_wim()
10875 char_u new_wim_flags[4];
10876 char_u *p;
10877 int i;
10878 int idx = 0;
10880 for (i = 0; i < 4; ++i)
10881 new_wim_flags[i] = 0;
10883 for (p = p_wim; *p; ++p)
10885 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
10887 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
10888 return FAIL;
10889 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
10890 new_wim_flags[idx] |= WIM_LONGEST;
10891 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
10892 new_wim_flags[idx] |= WIM_FULL;
10893 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
10894 new_wim_flags[idx] |= WIM_LIST;
10895 else
10896 return FAIL;
10897 p += i;
10898 if (*p == NUL)
10899 break;
10900 if (*p == ',')
10902 if (idx == 3)
10903 return FAIL;
10904 ++idx;
10908 /* fill remaining entries with last flag */
10909 while (idx < 3)
10911 new_wim_flags[idx + 1] = new_wim_flags[idx];
10912 ++idx;
10915 /* only when there are no errors, wim_flags[] is changed */
10916 for (i = 0; i < 4; ++i)
10917 wim_flags[i] = new_wim_flags[i];
10918 return OK;
10922 * Check if backspacing over something is allowed.
10925 can_bs(what)
10926 int what; /* BS_INDENT, BS_EOL or BS_START */
10928 switch (*p_bs)
10930 case '2': return TRUE;
10931 case '1': return (what != BS_START);
10932 case '0': return FALSE;
10934 return vim_strchr(p_bs, what) != NULL;
10938 * Save the current values of 'fileformat' and 'fileencoding', so that we know
10939 * the file must be considered changed when the value is different.
10941 void
10942 save_file_ff(buf)
10943 buf_T *buf;
10945 buf->b_start_ffc = *buf->b_p_ff;
10946 buf->b_start_eol = buf->b_p_eol;
10947 #ifdef FEAT_MBYTE
10948 buf->b_start_bomb = buf->b_p_bomb;
10950 /* Only use free/alloc when necessary, they take time. */
10951 if (buf->b_start_fenc == NULL
10952 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
10954 vim_free(buf->b_start_fenc);
10955 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
10957 #endif
10961 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
10962 * from when editing started (save_file_ff() called).
10963 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
10964 * changed and 'binary' is not set.
10965 * Don't consider a new, empty buffer to be changed.
10968 file_ff_differs(buf)
10969 buf_T *buf;
10971 /* In a buffer that was never loaded the options are not valid. */
10972 if (buf->b_flags & BF_NEVERLOADED)
10973 return FALSE;
10974 if ((buf->b_flags & BF_NEW)
10975 && buf->b_ml.ml_line_count == 1
10976 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
10977 return FALSE;
10978 if (buf->b_start_ffc != *buf->b_p_ff)
10979 return TRUE;
10980 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
10981 return TRUE;
10982 #ifdef FEAT_MBYTE
10983 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
10984 return TRUE;
10985 if (buf->b_start_fenc == NULL)
10986 return (*buf->b_p_fenc != NUL);
10987 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
10988 #else
10989 return FALSE;
10990 #endif
10994 * return OK if "p" is a valid fileformat name, FAIL otherwise.
10997 check_ff_value(p)
10998 char_u *p;
11000 return check_opt_strings(p, p_ff_values, FALSE);