1 /* vi:set ts=8 sts=4 sw=4: 2 * 3 * VIM - Vi IMproved by Bram Moolenaar 4 * 5 * Do ":help uganda" in Vim to read copying and usage conditions. 6 * Do ":help credits" in Vim to see a list of people who contributed. 7 * See README.txt for an overview of the Vim source code. 8 */ 9 10 /* 11 * Code to handle user-settable options. This is all pretty much table- 12 * driven. Checklist for adding a new option: 13 * - Put it in the options array below (copy an existing entry). 14 * - For a global option: Add a variable for it in option.h. 15 * - For a buffer or window local option: 16 * - Add a PV_XX entry to the enum below. 17 * - Add a variable to the window or buffer struct in structs.h. 18 * - For a window option, add some code to copy_winopt(). 19 * - For a buffer option, add some code to buf_copy_options(). 20 * - For a buffer string option, add code to check_buf_options(). 21 * - If it's a numeric option, add any necessary bounds checks to do_set(). 22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL. 23 * - When adding an option with expansion (P_EXPAND), but with a different 24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP. 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. 32 */ 33 34 #define IN_OPTION_C 35 #include "vim.h" 36 37 /* 38 * The options that are local to a window or buffer have "indir" set to one of 39 * these values. Special values: 40 * PV_NONE: global option. 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. 44 */ 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)) 52 53 /* 54 * Definition of the PV_ values for buffer-local options. 55 * The BV_ values are defined in option.h. 56 */ 57 #define PV_AI OPT_BUF(BV_AI) 58 #define PV_AR OPT_BOTH(OPT_BUF(BV_AR)) 59 #define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC)) 60 #ifdef FEAT_QUICKFIX 61 # define PV_BH OPT_BUF(BV_BH) 62 # define PV_BT OPT_BUF(BV_BT) 63 # define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM)) 64 # define PV_GP OPT_BOTH(OPT_BUF(BV_GP)) 65 # define PV_MP OPT_BOTH(OPT_BUF(BV_MP)) 66 #endif 67 #define PV_BIN OPT_BUF(BV_BIN) 68 #define PV_BL OPT_BUF(BV_BL) 69 #ifdef FEAT_MBYTE 70 # define PV_BOMB OPT_BUF(BV_BOMB) 71 #endif 72 #define PV_CI OPT_BUF(BV_CI) 73 #ifdef FEAT_CINDENT 74 # define PV_CIN OPT_BUF(BV_CIN) 75 # define PV_CINK OPT_BUF(BV_CINK) 76 # define PV_CINO OPT_BUF(BV_CINO) 77 #endif 78 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 79 # define PV_CINW OPT_BUF(BV_CINW) 80 #endif 81 #define PV_CM OPT_BOTH(OPT_BUF(BV_CM)) 82 #ifdef FEAT_FOLDING 83 # define PV_CMS OPT_BUF(BV_CMS) 84 #endif 85 #ifdef FEAT_COMMENTS 86 # define PV_COM OPT_BUF(BV_COM) 87 #endif 88 #ifdef FEAT_INS_EXPAND 89 # define PV_CPT OPT_BUF(BV_CPT) 90 # define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT)) 91 # define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR)) 92 #endif 93 #ifdef FEAT_COMPL_FUNC 94 # define PV_CFU OPT_BUF(BV_CFU) 95 #endif 96 #ifdef FEAT_FIND_ID 97 # define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF)) 98 # define PV_INC OPT_BOTH(OPT_BUF(BV_INC)) 99 #endif 100 #define PV_EOL OPT_BUF(BV_EOL) 101 #define PV_FIXEOL OPT_BUF(BV_FIXEOL) 102 #define PV_EP OPT_BOTH(OPT_BUF(BV_EP)) 103 #define PV_ET OPT_BUF(BV_ET) 104 #ifdef FEAT_MBYTE 105 # define PV_FENC OPT_BUF(BV_FENC) 106 #endif 107 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 108 # define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR)) 109 #endif 110 #ifdef FEAT_EVAL 111 # define PV_FEX OPT_BUF(BV_FEX) 112 #endif 113 #define PV_FF OPT_BUF(BV_FF) 114 #define PV_FLP OPT_BUF(BV_FLP) 115 #define PV_FO OPT_BUF(BV_FO) 116 #ifdef FEAT_AUTOCMD 117 # define PV_FT OPT_BUF(BV_FT) 118 #endif 119 #define PV_IMI OPT_BUF(BV_IMI) 120 #define PV_IMS OPT_BUF(BV_IMS) 121 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 122 # define PV_INDE OPT_BUF(BV_INDE) 123 # define PV_INDK OPT_BUF(BV_INDK) 124 #endif 125 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 126 # define PV_INEX OPT_BUF(BV_INEX) 127 #endif 128 #define PV_INF OPT_BUF(BV_INF) 129 #define PV_ISK OPT_BUF(BV_ISK) 130 #ifdef FEAT_CRYPT 131 # define PV_KEY OPT_BUF(BV_KEY) 132 #endif 133 #ifdef FEAT_KEYMAP 134 # define PV_KMAP OPT_BUF(BV_KMAP) 135 #endif 136 #define PV_KP OPT_BOTH(OPT_BUF(BV_KP)) 137 #ifdef FEAT_LISP 138 # define PV_LISP OPT_BUF(BV_LISP) 139 # define PV_LW OPT_BOTH(OPT_BUF(BV_LW)) 140 #endif 141 #define PV_MA OPT_BUF(BV_MA) 142 #define PV_ML OPT_BUF(BV_ML) 143 #define PV_MOD OPT_BUF(BV_MOD) 144 #define PV_MPS OPT_BUF(BV_MPS) 145 #define PV_NF OPT_BUF(BV_NF) 146 #ifdef FEAT_COMPL_FUNC 147 # define PV_OFU OPT_BUF(BV_OFU) 148 #endif 149 #define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH)) 150 #define PV_PI OPT_BUF(BV_PI) 151 #ifdef FEAT_TEXTOBJ 152 # define PV_QE OPT_BUF(BV_QE) 153 #endif 154 #define PV_RO OPT_BUF(BV_RO) 155 #ifdef FEAT_SMARTINDENT 156 # define PV_SI OPT_BUF(BV_SI) 157 #endif 158 #ifndef SHORT_FNAME 159 # define PV_SN OPT_BUF(BV_SN) 160 #endif 161 #ifdef FEAT_SYN_HL 162 # define PV_SMC OPT_BUF(BV_SMC) 163 # define PV_SYN OPT_BUF(BV_SYN) 164 #endif 165 #ifdef FEAT_SPELL 166 # define PV_SPC OPT_BUF(BV_SPC) 167 # define PV_SPF OPT_BUF(BV_SPF) 168 # define PV_SPL OPT_BUF(BV_SPL) 169 #endif 170 #define PV_STS OPT_BUF(BV_STS) 171 #ifdef FEAT_SEARCHPATH 172 # define PV_SUA OPT_BUF(BV_SUA) 173 #endif 174 #define PV_SW OPT_BUF(BV_SW) 175 #define PV_SWF OPT_BUF(BV_SWF) 176 #define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS)) 177 #define PV_TC OPT_BOTH(OPT_BUF(BV_TC)) 178 #define PV_TS OPT_BUF(BV_TS) 179 #define PV_TW OPT_BUF(BV_TW) 180 #define PV_TX OPT_BUF(BV_TX) 181 #ifdef FEAT_PERSISTENT_UNDO 182 # define PV_UDF OPT_BUF(BV_UDF) 183 #endif 184 #define PV_WM OPT_BUF(BV_WM) 185 186 /* 187 * Definition of the PV_ values for window-local options. 188 * The WV_ values are defined in option.h. 189 */ 190 #define PV_LIST OPT_WIN(WV_LIST) 191 #ifdef FEAT_ARABIC 192 # define PV_ARAB OPT_WIN(WV_ARAB) 193 #endif 194 #ifdef FEAT_LINEBREAK 195 # define PV_BRI OPT_WIN(WV_BRI) 196 # define PV_BRIOPT OPT_WIN(WV_BRIOPT) 197 #endif 198 #ifdef FEAT_DIFF 199 # define PV_DIFF OPT_WIN(WV_DIFF) 200 #endif 201 #ifdef FEAT_FOLDING 202 # define PV_FDC OPT_WIN(WV_FDC) 203 # define PV_FEN OPT_WIN(WV_FEN) 204 # define PV_FDI OPT_WIN(WV_FDI) 205 # define PV_FDL OPT_WIN(WV_FDL) 206 # define PV_FDM OPT_WIN(WV_FDM) 207 # define PV_FML OPT_WIN(WV_FML) 208 # define PV_FDN OPT_WIN(WV_FDN) 209 # ifdef FEAT_EVAL 210 # define PV_FDE OPT_WIN(WV_FDE) 211 # define PV_FDT OPT_WIN(WV_FDT) 212 # endif 213 # define PV_FMR OPT_WIN(WV_FMR) 214 #endif 215 #ifdef FEAT_LINEBREAK 216 # define PV_LBR OPT_WIN(WV_LBR) 217 #endif 218 #define PV_NU OPT_WIN(WV_NU) 219 #define PV_RNU OPT_WIN(WV_RNU) 220 #ifdef FEAT_LINEBREAK 221 # define PV_NUW OPT_WIN(WV_NUW) 222 #endif 223 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 224 # define PV_PVW OPT_WIN(WV_PVW) 225 #endif 226 #ifdef FEAT_RIGHTLEFT 227 # define PV_RL OPT_WIN(WV_RL) 228 # define PV_RLC OPT_WIN(WV_RLC) 229 #endif 230 #ifdef FEAT_SCROLLBIND 231 # define PV_SCBIND OPT_WIN(WV_SCBIND) 232 #endif 233 #define PV_SCROLL OPT_WIN(WV_SCROLL) 234 #ifdef FEAT_SPELL 235 # define PV_SPELL OPT_WIN(WV_SPELL) 236 #endif 237 #ifdef FEAT_SYN_HL 238 # define PV_CUC OPT_WIN(WV_CUC) 239 # define PV_CUL OPT_WIN(WV_CUL) 240 # define PV_CC OPT_WIN(WV_CC) 241 #endif 242 #ifdef FEAT_STL_OPT 243 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL)) 244 #endif 245 #define PV_UL OPT_BOTH(OPT_BUF(BV_UL)) 246 #ifdef FEAT_WINDOWS 247 # define PV_WFH OPT_WIN(WV_WFH) 248 #endif 249 #ifdef FEAT_VERTSPLIT 250 # define PV_WFW OPT_WIN(WV_WFW) 251 #endif 252 #define PV_WRAP OPT_WIN(WV_WRAP) 253 #ifdef FEAT_CURSORBIND 254 # define PV_CRBIND OPT_WIN(WV_CRBIND) 255 #endif 256 #ifdef FEAT_CONCEAL 257 # define PV_COCU OPT_WIN(WV_COCU) 258 # define PV_COLE OPT_WIN(WV_COLE) 259 #endif 260 261 /* WV_ and BV_ values get typecasted to this for the "indir" field */ 262 typedef enum 263 { 264 PV_NONE = 0, 265 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */ 266 } idopt_T; 267 268 /* 269 * Options local to a window have a value local to a buffer and global to all 270 * buffers. Indicate this by setting "var" to VAR_WIN. 271 */ 272 #define VAR_WIN ((char_u *)-1) 273 274 /* 275 * These are the global values for options which are also local to a buffer. 276 * Only to be used in option.c! 277 */ 278 static int p_ai; 279 static int p_bin; 280 #ifdef FEAT_MBYTE 281 static int p_bomb; 282 #endif 283 #if defined(FEAT_QUICKFIX) 284 static char_u *p_bh; 285 static char_u *p_bt; 286 #endif 287 static int p_bl; 288 static int p_ci; 289 #ifdef FEAT_CINDENT 290 static int p_cin; 291 static char_u *p_cink; 292 static char_u *p_cino; 293 #endif 294 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 295 static char_u *p_cinw; 296 #endif 297 #ifdef FEAT_COMMENTS 298 static char_u *p_com; 299 #endif 300 #ifdef FEAT_FOLDING 301 static char_u *p_cms; 302 #endif 303 #ifdef FEAT_INS_EXPAND 304 static char_u *p_cpt; 305 #endif 306 #ifdef FEAT_COMPL_FUNC 307 static char_u *p_cfu; 308 static char_u *p_ofu; 309 #endif 310 static int p_eol; 311 static int p_fixeol; 312 static int p_et; 313 #ifdef FEAT_MBYTE 314 static char_u *p_fenc; 315 #endif 316 static char_u *p_ff; 317 static char_u *p_fo; 318 static char_u *p_flp; 319 #ifdef FEAT_AUTOCMD 320 static char_u *p_ft; 321 #endif 322 static long p_iminsert; 323 static long p_imsearch; 324 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 325 static char_u *p_inex; 326 #endif 327 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 328 static char_u *p_inde; 329 static char_u *p_indk; 330 #endif 331 #if defined(FEAT_EVAL) 332 static char_u *p_fex; 333 #endif 334 static int p_inf; 335 static char_u *p_isk; 336 #ifdef FEAT_CRYPT 337 static char_u *p_key; 338 #endif 339 #ifdef FEAT_LISP 340 static int p_lisp; 341 #endif 342 static int p_ml; 343 static int p_ma; 344 static int p_mod; 345 static char_u *p_mps; 346 static char_u *p_nf; 347 static int p_pi; 348 #ifdef FEAT_TEXTOBJ 349 static char_u *p_qe; 350 #endif 351 static int p_ro; 352 #ifdef FEAT_SMARTINDENT 353 static int p_si; 354 #endif 355 #ifndef SHORT_FNAME 356 static int p_sn; 357 #endif 358 static long p_sts; 359 #if defined(FEAT_SEARCHPATH) 360 static char_u *p_sua; 361 #endif 362 static long p_sw; 363 static int p_swf; 364 #ifdef FEAT_SYN_HL 365 static long p_smc; 366 static char_u *p_syn; 367 #endif 368 #ifdef FEAT_SPELL 369 static char_u *p_spc; 370 static char_u *p_spf; 371 static char_u *p_spl; 372 #endif 373 static long p_ts; 374 static long p_tw; 375 static int p_tx; 376 #ifdef FEAT_PERSISTENT_UNDO 377 static int p_udf; 378 #endif 379 static long p_wm; 380 #ifdef FEAT_KEYMAP 381 static char_u *p_keymap; 382 #endif 383 384 /* Saved values for when 'bin' is set. */ 385 static int p_et_nobin; 386 static int p_ml_nobin; 387 static long p_tw_nobin; 388 static long p_wm_nobin; 389 390 /* Saved values for when 'paste' is set */ 391 static int p_ai_nopaste; 392 static int p_et_nopaste; 393 static long p_sts_nopaste; 394 static long p_tw_nopaste; 395 static long p_wm_nopaste; 396 397 struct vimoption 398 { 399 char *fullname; /* full option name */ 400 char *shortname; /* permissible abbreviation */ 401 long_u flags; /* see below */ 402 char_u *var; /* global option: pointer to variable; 403 * window-local option: VAR_WIN; 404 * buffer-local option: global value */ 405 idopt_T indir; /* global option: PV_NONE; 406 * local option: indirect option index */ 407 char_u *def_val[2]; /* default values for variable (vi and vim) */ 408 #ifdef FEAT_EVAL 409 scid_T scriptID; /* script in which the option was last set */ 410 # define SCRIPTID_INIT , 0 411 #else 412 # define SCRIPTID_INIT 413 #endif 414 }; 415 416 #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */ 417 #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */ 418 419 /* 420 * Flags 421 */ 422 #define P_BOOL 0x01 /* the option is boolean */ 423 #define P_NUM 0x02 /* the option is numeric */ 424 #define P_STRING 0x04 /* the option is a string */ 425 #define P_ALLOCED 0x08 /* the string option is in allocated memory, 426 must use free_string_option() when 427 assigning new value. Not set if default is 428 the same. */ 429 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can 430 never be used for local or hidden options! */ 431 #define P_NODEFAULT 0x40 /* don't set to default value */ 432 #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must 433 use vim_free() when assigning new value */ 434 #define P_WAS_SET 0x100 /* option has been set/reset */ 435 #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */ 436 #define P_VI_DEF 0x400 /* Use Vi default for Vim */ 437 #define P_VIM 0x800 /* Vim option, reset when 'cp' set */ 438 439 /* when option changed, what to display: */ 440 #define P_RSTAT 0x1000 /* redraw status lines */ 441 #define P_RWIN 0x2000 /* redraw current window */ 442 #define P_RBUF 0x4000 /* redraw current buffer */ 443 #define P_RALL 0x6000 /* redraw all windows */ 444 #define P_RCLR 0x7000 /* clear and redraw all */ 445 446 #define P_COMMA 0x8000 /* comma separated list */ 447 #define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive 448 * commas */ 449 #define P_NODUP 0x20000L /* don't allow duplicate strings */ 450 #define P_FLAGLIST 0x40000L /* list of single-char flags */ 451 452 #define P_SECURE 0x80000L /* cannot change in modeline or secure mode */ 453 #define P_GETTEXT 0x100000L /* expand default value with _() */ 454 #define P_NOGLOB 0x200000L /* do not use local value for global vimrc */ 455 #define P_NFNAME 0x400000L /* only normal file name chars allowed */ 456 #define P_INSECURE 0x800000L /* option was set from a modeline */ 457 #define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has 458 side effects) */ 459 #define P_NO_ML 0x2000000L /* not allowed in modeline */ 460 #define P_CURSWANT 0x4000000L /* update curswant required; not needed when 461 * there is a redraw flag */ 462 463 #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" 464 465 /* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used 466 * for the currency sign. */ 467 #if defined(MSDOS) || defined(MSWIN) 468 # define ISP_LATIN1 (char_u *)"@,~-255" 469 #else 470 # define ISP_LATIN1 (char_u *)"@,161-255" 471 #endif 472 473 /* The 16 bit MS-DOS version is low on space, make the string as short as 474 * possible when compiling with few features. */ 475 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \ 476 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \ 477 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL) 478 # define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn" 479 #else 480 # define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill" 481 #endif 482 483 /* 484 * options[] is initialized here. 485 * The order of the options MUST be alphabetic for ":set all" and findoption(). 486 * All option names MUST start with a lowercase letter (for findoption()). 487 * Exception: "t_" options are at the end. 488 * The options with a NULL variable are 'hidden': a set command for them is 489 * ignored and they are not printed. 490 */ 491 static struct vimoption 492 #ifdef FEAT_GUI_W16 493 _far 494 #endif 495 options[] = 496 { 497 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT, 498 #ifdef FEAT_RIGHTLEFT 499 (char_u *)&p_aleph, PV_NONE, 500 #else 501 (char_u *)NULL, PV_NONE, 502 #endif 503 { 504 #if (defined(MSDOS) || defined(WIN3264)) && !defined(FEAT_GUI_W32) 505 (char_u *)128L, 506 #else 507 (char_u *)224L, 508 #endif 509 (char_u *)0L} SCRIPTID_INIT}, 510 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, 511 #if defined(FEAT_GUI) && defined(MACOS_X) 512 (char_u *)&p_antialias, PV_NONE, 513 {(char_u *)FALSE, (char_u *)FALSE} 514 #else 515 (char_u *)NULL, PV_NONE, 516 {(char_u *)FALSE, (char_u *)FALSE} 517 #endif 518 SCRIPTID_INIT}, 519 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT, 520 #ifdef FEAT_ARABIC 521 (char_u *)VAR_WIN, PV_ARAB, 522 #else 523 (char_u *)NULL, PV_NONE, 524 #endif 525 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 526 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, 527 #ifdef FEAT_ARABIC 528 (char_u *)&p_arshape, PV_NONE, 529 #else 530 (char_u *)NULL, PV_NONE, 531 #endif 532 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 533 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM, 534 #ifdef FEAT_RIGHTLEFT 535 (char_u *)&p_ari, PV_NONE, 536 #else 537 (char_u *)NULL, PV_NONE, 538 #endif 539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 540 {"altkeymap", "akm", P_BOOL|P_VI_DEF, 541 #ifdef FEAT_FKMAP 542 (char_u *)&p_altkeymap, PV_NONE, 543 #else 544 (char_u *)NULL, PV_NONE, 545 #endif 546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 547 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR, 548 #if defined(FEAT_MBYTE) 549 (char_u *)&p_ambw, PV_NONE, 550 {(char_u *)"single", (char_u *)0L} 551 #else 552 (char_u *)NULL, PV_NONE, 553 {(char_u *)0L, (char_u *)0L} 554 #endif 555 SCRIPTID_INIT}, 556 #ifdef FEAT_AUTOCHDIR 557 {"autochdir", "acd", P_BOOL|P_VI_DEF, 558 (char_u *)&p_acd, PV_NONE, 559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 560 #endif 561 {"autoindent", "ai", P_BOOL|P_VI_DEF, 562 (char_u *)&p_ai, PV_AI, 563 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 564 {"autoprint", "ap", P_BOOL|P_VI_DEF, 565 (char_u *)NULL, PV_NONE, 566 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 567 {"autoread", "ar", P_BOOL|P_VI_DEF, 568 (char_u *)&p_ar, PV_AR, 569 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 570 {"autowrite", "aw", P_BOOL|P_VI_DEF, 571 (char_u *)&p_aw, PV_NONE, 572 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 573 {"autowriteall","awa", P_BOOL|P_VI_DEF, 574 (char_u *)&p_awa, PV_NONE, 575 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 576 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR, 577 (char_u *)&p_bg, PV_NONE, 578 { 579 #if (defined(MSDOS) || defined(WIN3264)) && !defined(FEAT_GUI) 580 (char_u *)"dark", 581 #else 582 (char_u *)"light", 583 #endif 584 (char_u *)0L} SCRIPTID_INIT}, 585 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP, 586 (char_u *)&p_bs, PV_NONE, 587 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 588 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, 589 (char_u *)&p_bk, PV_NONE, 590 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 591 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP, 592 (char_u *)&p_bkc, PV_BKC, 593 #ifdef UNIX 594 {(char_u *)"yes", (char_u *)"auto"} 595 #else 596 {(char_u *)"auto", (char_u *)"auto"} 597 #endif 598 SCRIPTID_INIT}, 599 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA 600 |P_NODUP|P_SECURE, 601 (char_u *)&p_bdir, PV_NONE, 602 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT}, 603 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME, 604 (char_u *)&p_bex, PV_NONE, 605 { 606 #ifdef VMS 607 (char_u *)"_", 608 #else 609 (char_u *)"~", 610 #endif 611 (char_u *)0L} SCRIPTID_INIT}, 612 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA, 613 #ifdef FEAT_WILDIGN 614 (char_u *)&p_bsk, PV_NONE, 615 {(char_u *)"", (char_u *)0L} 616 #else 617 (char_u *)NULL, PV_NONE, 618 {(char_u *)0L, (char_u *)0L} 619 #endif 620 SCRIPTID_INIT}, 621 #ifdef FEAT_BEVAL 622 {"balloondelay","bdlay",P_NUM|P_VI_DEF, 623 (char_u *)&p_bdlay, PV_NONE, 624 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT}, 625 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC, 626 (char_u *)&p_beval, PV_NONE, 627 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 628 # ifdef FEAT_EVAL 629 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, 630 (char_u *)&p_bexpr, PV_BEXPR, 631 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 632 # endif 633 #endif 634 {"beautify", "bf", P_BOOL|P_VI_DEF, 635 (char_u *)NULL, PV_NONE, 636 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 637 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, 638 (char_u *)&p_bo, PV_NONE, 639 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 640 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, 641 (char_u *)&p_bin, PV_BIN, 642 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 643 {"bioskey", "biosk",P_BOOL|P_VI_DEF, 644 #ifdef MSDOS 645 (char_u *)&p_biosk, PV_NONE, 646 #else 647 (char_u *)NULL, PV_NONE, 648 #endif 649 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 650 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, 651 #ifdef FEAT_MBYTE 652 (char_u *)&p_bomb, PV_BOMB, 653 #else 654 (char_u *)NULL, PV_NONE, 655 #endif 656 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 657 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, 658 #ifdef FEAT_LINEBREAK 659 (char_u *)&p_breakat, PV_NONE, 660 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L} 661 #else 662 (char_u *)NULL, PV_NONE, 663 {(char_u *)0L, (char_u *)0L} 664 #endif 665 SCRIPTID_INIT}, 666 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN, 667 #ifdef FEAT_LINEBREAK 668 (char_u *)VAR_WIN, PV_BRI, 669 {(char_u *)FALSE, (char_u *)0L} 670 #else 671 (char_u *)NULL, PV_NONE, 672 {(char_u *)0L, (char_u *)0L} 673 #endif 674 SCRIPTID_INIT}, 675 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF 676 |P_ONECOMMA|P_NODUP, 677 #ifdef FEAT_LINEBREAK 678 (char_u *)VAR_WIN, PV_BRIOPT, 679 {(char_u *)"", (char_u *)NULL} 680 #else 681 (char_u *)NULL, PV_NONE, 682 {(char_u *)"", (char_u *)NULL} 683 #endif 684 SCRIPTID_INIT}, 685 {"browsedir", "bsdir",P_STRING|P_VI_DEF, 686 #ifdef FEAT_BROWSE 687 (char_u *)&p_bsdir, PV_NONE, 688 {(char_u *)"last", (char_u *)0L} 689 #else 690 (char_u *)NULL, PV_NONE, 691 {(char_u *)0L, (char_u *)0L} 692 #endif 693 SCRIPTID_INIT}, 694 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, 695 #if defined(FEAT_QUICKFIX) 696 (char_u *)&p_bh, PV_BH, 697 {(char_u *)"", (char_u *)0L} 698 #else 699 (char_u *)NULL, PV_NONE, 700 {(char_u *)0L, (char_u *)0L} 701 #endif 702 SCRIPTID_INIT}, 703 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, 704 (char_u *)&p_bl, PV_BL, 705 {(char_u *)1L, (char_u *)0L} 706 SCRIPTID_INIT}, 707 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, 708 #if defined(FEAT_QUICKFIX) 709 (char_u *)&p_bt, PV_BT, 710 {(char_u *)"", (char_u *)0L} 711 #else 712 (char_u *)NULL, PV_NONE, 713 {(char_u *)0L, (char_u *)0L} 714 #endif 715 SCRIPTID_INIT}, 716 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 717 #ifdef FEAT_MBYTE 718 (char_u *)&p_cmp, PV_NONE, 719 {(char_u *)"internal,keepascii", (char_u *)0L} 720 #else 721 (char_u *)NULL, PV_NONE, 722 {(char_u *)0L, (char_u *)0L} 723 #endif 724 SCRIPTID_INIT}, 725 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, 726 #ifdef FEAT_SEARCHPATH 727 (char_u *)&p_cdpath, PV_NONE, 728 {(char_u *)",,", (char_u *)0L} 729 #else 730 (char_u *)NULL, PV_NONE, 731 {(char_u *)0L, (char_u *)0L} 732 #endif 733 SCRIPTID_INIT}, 734 {"cedit", NULL, P_STRING, 735 #ifdef FEAT_CMDWIN 736 (char_u *)&p_cedit, PV_NONE, 737 {(char_u *)"", (char_u *)CTRL_F_STR} 738 #else 739 (char_u *)NULL, PV_NONE, 740 {(char_u *)0L, (char_u *)0L} 741 #endif 742 SCRIPTID_INIT}, 743 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE, 744 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL) 745 (char_u *)&p_ccv, PV_NONE, 746 {(char_u *)"", (char_u *)0L} 747 #else 748 (char_u *)NULL, PV_NONE, 749 {(char_u *)0L, (char_u *)0L} 750 #endif 751 SCRIPTID_INIT}, 752 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM, 753 #ifdef FEAT_CINDENT 754 (char_u *)&p_cin, PV_CIN, 755 #else 756 (char_u *)NULL, PV_NONE, 757 #endif 758 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 759 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 760 #ifdef FEAT_CINDENT 761 (char_u *)&p_cink, PV_CINK, 762 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L} 763 #else 764 (char_u *)NULL, PV_NONE, 765 {(char_u *)0L, (char_u *)0L} 766 #endif 767 SCRIPTID_INIT}, 768 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 769 #ifdef FEAT_CINDENT 770 (char_u *)&p_cino, PV_CINO, 771 #else 772 (char_u *)NULL, PV_NONE, 773 #endif 774 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 775 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 776 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 777 (char_u *)&p_cinw, PV_CINW, 778 {(char_u *)"if,else,while,do,for,switch", 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 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 786 #ifdef FEAT_CLIPBOARD 787 (char_u *)&p_cb, PV_NONE, 788 # ifdef FEAT_XCLIPBOARD 789 {(char_u *)"autoselect,exclude:cons\\|linux", 790 (char_u *)0L} 791 # else 792 {(char_u *)"", (char_u *)0L} 793 # endif 794 #else 795 (char_u *)NULL, PV_NONE, 796 {(char_u *)"", (char_u *)0L} 797 #endif 798 SCRIPTID_INIT}, 799 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL, 800 (char_u *)&p_ch, PV_NONE, 801 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 802 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF, 803 #ifdef FEAT_CMDWIN 804 (char_u *)&p_cwh, PV_NONE, 805 #else 806 (char_u *)NULL, PV_NONE, 807 #endif 808 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT}, 809 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, 810 #ifdef FEAT_SYN_HL 811 (char_u *)VAR_WIN, PV_CC, 812 #else 813 (char_u *)NULL, PV_NONE, 814 #endif 815 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 816 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, 817 (char_u *)&Columns, PV_NONE, 818 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT}, 819 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA 820 |P_NODUP|P_CURSWANT, 821 #ifdef FEAT_COMMENTS 822 (char_u *)&p_com, PV_COM, 823 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", 824 (char_u *)0L} 825 #else 826 (char_u *)NULL, PV_NONE, 827 {(char_u *)0L, (char_u *)0L} 828 #endif 829 SCRIPTID_INIT}, 830 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, 831 #ifdef FEAT_FOLDING 832 (char_u *)&p_cms, PV_CMS, 833 {(char_u *)"/*%s*/", (char_u *)0L} 834 #else 835 (char_u *)NULL, PV_NONE, 836 {(char_u *)0L, (char_u *)0L} 837 #endif 838 SCRIPTID_INIT}, 839 /* P_PRI_MKRC isn't needed here, optval_default() 840 * always returns TRUE for 'compatible' */ 841 {"compatible", "cp", P_BOOL|P_RALL, 842 (char_u *)&p_cp, PV_NONE, 843 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT}, 844 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 845 #ifdef FEAT_INS_EXPAND 846 (char_u *)&p_cpt, PV_CPT, 847 {(char_u *)".,w,b,u,t,i", (char_u *)0L} 848 #else 849 (char_u *)NULL, PV_NONE, 850 {(char_u *)0L, (char_u *)0L} 851 #endif 852 SCRIPTID_INIT}, 853 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, 854 #ifdef FEAT_CONCEAL 855 (char_u *)VAR_WIN, PV_COCU, 856 {(char_u *)"", (char_u *)NULL} 857 #else 858 (char_u *)NULL, PV_NONE, 859 {(char_u *)NULL, (char_u *)0L} 860 #endif 861 SCRIPTID_INIT}, 862 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF, 863 #ifdef FEAT_CONCEAL 864 (char_u *)VAR_WIN, PV_COLE, 865 #else 866 (char_u *)NULL, PV_NONE, 867 #endif 868 {(char_u *)0L, (char_u *)0L} 869 SCRIPTID_INIT}, 870 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, 871 #ifdef FEAT_COMPL_FUNC 872 (char_u *)&p_cfu, PV_CFU, 873 {(char_u *)"", (char_u *)0L} 874 #else 875 (char_u *)NULL, PV_NONE, 876 {(char_u *)0L, (char_u *)0L} 877 #endif 878 SCRIPTID_INIT}, 879 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 880 #ifdef FEAT_INS_EXPAND 881 (char_u *)&p_cot, PV_NONE, 882 {(char_u *)"menu,preview", (char_u *)0L} 883 #else 884 (char_u *)NULL, PV_NONE, 885 {(char_u *)0L, (char_u *)0L} 886 #endif 887 SCRIPTID_INIT}, 888 {"confirm", "cf", P_BOOL|P_VI_DEF, 889 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) 890 (char_u *)&p_confirm, PV_NONE, 891 #else 892 (char_u *)NULL, PV_NONE, 893 #endif 894 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 895 {"conskey", "consk",P_BOOL|P_VI_DEF, 896 #ifdef MSDOS 897 (char_u *)&p_consk, PV_NONE, 898 #else 899 (char_u *)NULL, PV_NONE, 900 #endif 901 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 902 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM, 903 (char_u *)&p_ci, PV_CI, 904 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 905 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST, 906 (char_u *)&p_cpo, PV_NONE, 907 {(char_u *)CPO_VI, (char_u *)CPO_VIM} 908 SCRIPTID_INIT}, 909 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF, 910 #ifdef FEAT_CRYPT 911 (char_u *)&p_cm, PV_CM, 912 {(char_u *)"zip", (char_u *)0L} 913 #else 914 (char_u *)NULL, PV_NONE, 915 {(char_u *)0L, (char_u *)0L} 916 #endif 917 SCRIPTID_INIT}, 918 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM, 919 #ifdef FEAT_CSCOPE 920 (char_u *)&p_cspc, PV_NONE, 921 #else 922 (char_u *)NULL, PV_NONE, 923 #endif 924 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 925 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 926 #ifdef FEAT_CSCOPE 927 (char_u *)&p_csprg, PV_NONE, 928 {(char_u *)"cscope", (char_u *)0L} 929 #else 930 (char_u *)NULL, PV_NONE, 931 {(char_u *)0L, (char_u *)0L} 932 #endif 933 SCRIPTID_INIT}, 934 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 935 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) 936 (char_u *)&p_csqf, PV_NONE, 937 {(char_u *)"", (char_u *)0L} 938 #else 939 (char_u *)NULL, PV_NONE, 940 {(char_u *)0L, (char_u *)0L} 941 #endif 942 SCRIPTID_INIT}, 943 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM, 944 #ifdef FEAT_CSCOPE 945 (char_u *)&p_csre, PV_NONE, 946 #else 947 (char_u *)NULL, PV_NONE, 948 #endif 949 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 950 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM, 951 #ifdef FEAT_CSCOPE 952 (char_u *)&p_cst, PV_NONE, 953 #else 954 (char_u *)NULL, PV_NONE, 955 #endif 956 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 957 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM, 958 #ifdef FEAT_CSCOPE 959 (char_u *)&p_csto, PV_NONE, 960 #else 961 (char_u *)NULL, PV_NONE, 962 #endif 963 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 964 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM, 965 #ifdef FEAT_CSCOPE 966 (char_u *)&p_csverbose, PV_NONE, 967 #else 968 (char_u *)NULL, PV_NONE, 969 #endif 970 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 971 {"cursorbind", "crb", P_BOOL|P_VI_DEF, 972 #ifdef FEAT_CURSORBIND 973 (char_u *)VAR_WIN, PV_CRBIND, 974 #else 975 (char_u *)NULL, PV_NONE, 976 #endif 977 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 978 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN, 979 #ifdef FEAT_SYN_HL 980 (char_u *)VAR_WIN, PV_CUC, 981 #else 982 (char_u *)NULL, PV_NONE, 983 #endif 984 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 985 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN, 986 #ifdef FEAT_SYN_HL 987 (char_u *)VAR_WIN, PV_CUL, 988 #else 989 (char_u *)NULL, PV_NONE, 990 #endif 991 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 992 {"debug", NULL, P_STRING|P_VI_DEF, 993 (char_u *)&p_debug, PV_NONE, 994 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 995 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, 996 #ifdef FEAT_FIND_ID 997 (char_u *)&p_def, PV_DEF, 998 {(char_u *)"^\\s*#\\s*define", (char_u *)0L} 999 #else 1000 (char_u *)NULL, PV_NONE, 1001 {(char_u *)NULL, (char_u *)0L} 1002 #endif 1003 SCRIPTID_INIT}, 1004 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM, 1005 #ifdef FEAT_MBYTE 1006 (char_u *)&p_deco, PV_NONE, 1007 #else 1008 (char_u *)NULL, PV_NONE, 1009 #endif 1010 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1011 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, 1012 #ifdef FEAT_INS_EXPAND 1013 (char_u *)&p_dict, PV_DICT, 1014 #else 1015 (char_u *)NULL, PV_NONE, 1016 #endif 1017 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1018 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB, 1019 #ifdef FEAT_DIFF 1020 (char_u *)VAR_WIN, PV_DIFF, 1021 #else 1022 (char_u *)NULL, PV_NONE, 1023 #endif 1024 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1025 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT, 1026 #if defined(FEAT_DIFF) && defined(FEAT_EVAL) 1027 (char_u *)&p_dex, PV_NONE, 1028 {(char_u *)"", (char_u *)0L} 1029 #else 1030 (char_u *)NULL, PV_NONE, 1031 {(char_u *)0L, (char_u *)0L} 1032 #endif 1033 SCRIPTID_INIT}, 1034 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA 1035 |P_NODUP, 1036 #ifdef FEAT_DIFF 1037 (char_u *)&p_dip, PV_NONE, 1038 {(char_u *)"filler", (char_u *)NULL} 1039 #else 1040 (char_u *)NULL, PV_NONE, 1041 {(char_u *)"", (char_u *)NULL} 1042 #endif 1043 SCRIPTID_INIT}, 1044 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM, 1045 #ifdef FEAT_DIGRAPHS 1046 (char_u *)&p_dg, PV_NONE, 1047 #else 1048 (char_u *)NULL, PV_NONE, 1049 #endif 1050 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1051 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA 1052 |P_NODUP|P_SECURE, 1053 (char_u *)&p_dir, PV_NONE, 1054 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT}, 1055 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP, 1056 (char_u *)&p_dy, PV_NONE, 1057 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1058 {"eadirection", "ead", P_STRING|P_VI_DEF, 1059 #ifdef FEAT_VERTSPLIT 1060 (char_u *)&p_ead, PV_NONE, 1061 {(char_u *)"both", (char_u *)0L} 1062 #else 1063 (char_u *)NULL, PV_NONE, 1064 {(char_u *)NULL, (char_u *)0L} 1065 #endif 1066 SCRIPTID_INIT}, 1067 {"edcompatible","ed", P_BOOL|P_VI_DEF, 1068 (char_u *)&p_ed, PV_NONE, 1069 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1070 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML, 1071 #ifdef FEAT_MBYTE 1072 (char_u *)&p_enc, PV_NONE, 1073 {(char_u *)ENC_DFLT, (char_u *)0L} 1074 #else 1075 (char_u *)NULL, PV_NONE, 1076 {(char_u *)0L, (char_u *)0L} 1077 #endif 1078 SCRIPTID_INIT}, 1079 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, 1080 (char_u *)&p_eol, PV_EOL, 1081 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1082 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL, 1083 (char_u *)&p_ea, PV_NONE, 1084 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1085 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1086 (char_u *)&p_ep, PV_EP, 1087 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1088 {"errorbells", "eb", P_BOOL|P_VI_DEF, 1089 (char_u *)&p_eb, PV_NONE, 1090 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1091 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1092 #ifdef FEAT_QUICKFIX 1093 (char_u *)&p_ef, PV_NONE, 1094 {(char_u *)DFLT_ERRORFILE, (char_u *)0L} 1095 #else 1096 (char_u *)NULL, PV_NONE, 1097 {(char_u *)NULL, (char_u *)0L} 1098 #endif 1099 SCRIPTID_INIT}, 1100 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1101 #ifdef FEAT_QUICKFIX 1102 (char_u *)&p_efm, PV_EFM, 1103 {(char_u *)DFLT_EFM, (char_u *)0L} 1104 #else 1105 (char_u *)NULL, PV_NONE, 1106 {(char_u *)NULL, (char_u *)0L} 1107 #endif 1108 SCRIPTID_INIT}, 1109 {"esckeys", "ek", P_BOOL|P_VIM, 1110 (char_u *)&p_ek, PV_NONE, 1111 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 1112 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1113 #ifdef FEAT_AUTOCMD 1114 (char_u *)&p_ei, PV_NONE, 1115 #else 1116 (char_u *)NULL, PV_NONE, 1117 #endif 1118 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1119 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM, 1120 (char_u *)&p_et, PV_ET, 1121 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1122 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE, 1123 (char_u *)&p_exrc, PV_NONE, 1124 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1125 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF 1126 |P_NO_MKRC, 1127 #ifdef FEAT_MBYTE 1128 (char_u *)&p_fenc, PV_FENC, 1129 {(char_u *)"", (char_u *)0L} 1130 #else 1131 (char_u *)NULL, PV_NONE, 1132 {(char_u *)0L, (char_u *)0L} 1133 #endif 1134 SCRIPTID_INIT}, 1135 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA, 1136 #ifdef FEAT_MBYTE 1137 (char_u *)&p_fencs, PV_NONE, 1138 {(char_u *)"ucs-bom", (char_u *)0L} 1139 #else 1140 (char_u *)NULL, PV_NONE, 1141 {(char_u *)0L, (char_u *)0L} 1142 #endif 1143 SCRIPTID_INIT}, 1144 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC 1145 |P_CURSWANT, 1146 (char_u *)&p_ff, PV_FF, 1147 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT}, 1148 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP, 1149 (char_u *)&p_ffs, PV_NONE, 1150 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM} 1151 SCRIPTID_INIT}, 1152 {"fileignorecase", "fic", P_BOOL|P_VI_DEF, 1153 (char_u *)&p_fic, PV_NONE, 1154 { 1155 #ifdef CASE_INSENSITIVE_FILENAME 1156 (char_u *)TRUE, 1157 #else 1158 (char_u *)FALSE, 1159 #endif 1160 (char_u *)0L} SCRIPTID_INIT}, 1161 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, 1162 #ifdef FEAT_AUTOCMD 1163 (char_u *)&p_ft, PV_FT, 1164 {(char_u *)"", (char_u *)0L} 1165 #else 1166 (char_u *)NULL, PV_NONE, 1167 {(char_u *)0L, (char_u *)0L} 1168 #endif 1169 SCRIPTID_INIT}, 1170 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP, 1171 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 1172 (char_u *)&p_fcs, PV_NONE, 1173 {(char_u *)"vert:|,fold:-", (char_u *)0L} 1174 #else 1175 (char_u *)NULL, PV_NONE, 1176 {(char_u *)"", (char_u *)0L} 1177 #endif 1178 SCRIPTID_INIT}, 1179 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT, 1180 (char_u *)&p_fixeol, PV_FIXEOL, 1181 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1182 {"fkmap", "fk", P_BOOL|P_VI_DEF, 1183 #ifdef FEAT_FKMAP 1184 (char_u *)&p_fkmap, PV_NONE, 1185 #else 1186 (char_u *)NULL, PV_NONE, 1187 #endif 1188 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1189 {"flash", "fl", P_BOOL|P_VI_DEF, 1190 (char_u *)NULL, PV_NONE, 1191 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1192 #ifdef FEAT_FOLDING 1193 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, 1194 (char_u *)&p_fcl, PV_NONE, 1195 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1196 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN, 1197 (char_u *)VAR_WIN, PV_FDC, 1198 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1199 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN, 1200 (char_u *)VAR_WIN, PV_FEN, 1201 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1202 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1203 # ifdef FEAT_EVAL 1204 (char_u *)VAR_WIN, PV_FDE, 1205 {(char_u *)"0", (char_u *)NULL} 1206 # else 1207 (char_u *)NULL, PV_NONE, 1208 {(char_u *)NULL, (char_u *)0L} 1209 # endif 1210 SCRIPTID_INIT}, 1211 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1212 (char_u *)VAR_WIN, PV_FDI, 1213 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT}, 1214 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN, 1215 (char_u *)VAR_WIN, PV_FDL, 1216 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 1217 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT, 1218 (char_u *)&p_fdls, PV_NONE, 1219 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT}, 1220 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF| 1221 P_RWIN|P_ONECOMMA|P_NODUP, 1222 (char_u *)VAR_WIN, PV_FMR, 1223 {(char_u *)"{{{,}}}", (char_u *)NULL} 1224 SCRIPTID_INIT}, 1225 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1226 (char_u *)VAR_WIN, PV_FDM, 1227 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT}, 1228 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN, 1229 (char_u *)VAR_WIN, PV_FML, 1230 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 1231 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN, 1232 (char_u *)VAR_WIN, PV_FDN, 1233 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, 1234 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT, 1235 (char_u *)&p_fdo, PV_NONE, 1236 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", 1237 (char_u *)0L} SCRIPTID_INIT}, 1238 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1239 # ifdef FEAT_EVAL 1240 (char_u *)VAR_WIN, PV_FDT, 1241 {(char_u *)"foldtext()", (char_u *)NULL} 1242 # else 1243 (char_u *)NULL, PV_NONE, 1244 {(char_u *)NULL, (char_u *)0L} 1245 # endif 1246 SCRIPTID_INIT}, 1247 #endif 1248 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, 1249 #ifdef FEAT_EVAL 1250 (char_u *)&p_fex, PV_FEX, 1251 {(char_u *)"", (char_u *)0L} 1252 #else 1253 (char_u *)NULL, PV_NONE, 1254 {(char_u *)0L, (char_u *)0L} 1255 #endif 1256 SCRIPTID_INIT}, 1257 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST, 1258 (char_u *)&p_fo, PV_FO, 1259 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM} 1260 SCRIPTID_INIT}, 1261 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF, 1262 (char_u *)&p_flp, PV_FLP, 1263 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", 1264 (char_u *)0L} SCRIPTID_INIT}, 1265 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1266 (char_u *)&p_fp, PV_NONE, 1267 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1268 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, 1269 #ifdef HAVE_FSYNC 1270 (char_u *)&p_fs, PV_NONE, 1271 {(char_u *)TRUE, (char_u *)0L} 1272 #else 1273 (char_u *)NULL, PV_NONE, 1274 {(char_u *)FALSE, (char_u *)0L} 1275 #endif 1276 SCRIPTID_INIT}, 1277 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM, 1278 (char_u *)&p_gd, PV_NONE, 1279 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1280 {"graphic", "gr", P_BOOL|P_VI_DEF, 1281 (char_u *)NULL, PV_NONE, 1282 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1283 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1284 #ifdef FEAT_QUICKFIX 1285 (char_u *)&p_gefm, PV_NONE, 1286 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L} 1287 #else 1288 (char_u *)NULL, PV_NONE, 1289 {(char_u *)NULL, (char_u *)0L} 1290 #endif 1291 SCRIPTID_INIT}, 1292 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1293 #ifdef FEAT_QUICKFIX 1294 (char_u *)&p_gp, PV_GP, 1295 { 1296 # ifdef WIN3264 1297 /* may be changed to "grep -n" in os_win32.c */ 1298 (char_u *)"findstr /n", 1299 # else 1300 # ifdef UNIX 1301 /* Add an extra file name so that grep will always 1302 * insert a file name in the match line. */ 1303 (char_u *)"grep -n $* /dev/null", 1304 # else 1305 # ifdef VMS 1306 (char_u *)"SEARCH/NUMBERS ", 1307 # else 1308 (char_u *)"grep -n ", 1309 # endif 1310 # endif 1311 # endif 1312 (char_u *)0L} 1313 #else 1314 (char_u *)NULL, PV_NONE, 1315 {(char_u *)NULL, (char_u *)0L} 1316 #endif 1317 SCRIPTID_INIT}, 1318 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1319 #ifdef CURSOR_SHAPE 1320 (char_u *)&p_guicursor, PV_NONE, 1321 { 1322 # ifdef FEAT_GUI 1323 (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", 1324 # else /* MSDOS or Win32 console */ 1325 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block", 1326 # endif 1327 (char_u *)0L} 1328 #else 1329 (char_u *)NULL, PV_NONE, 1330 {(char_u *)NULL, (char_u *)0L} 1331 #endif 1332 SCRIPTID_INIT}, 1333 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP, 1334 #ifdef FEAT_GUI 1335 (char_u *)&p_guifont, PV_NONE, 1336 {(char_u *)"", (char_u *)0L} 1337 #else 1338 (char_u *)NULL, PV_NONE, 1339 {(char_u *)NULL, (char_u *)0L} 1340 #endif 1341 SCRIPTID_INIT}, 1342 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA, 1343 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET) 1344 (char_u *)&p_guifontset, PV_NONE, 1345 {(char_u *)"", (char_u *)0L} 1346 #else 1347 (char_u *)NULL, PV_NONE, 1348 {(char_u *)NULL, (char_u *)0L} 1349 #endif 1350 SCRIPTID_INIT}, 1351 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP, 1352 #if defined(FEAT_GUI) && defined(FEAT_MBYTE) 1353 (char_u *)&p_guifontwide, PV_NONE, 1354 {(char_u *)"", (char_u *)0L} 1355 #else 1356 (char_u *)NULL, PV_NONE, 1357 {(char_u *)NULL, (char_u *)0L} 1358 #endif 1359 SCRIPTID_INIT}, 1360 {"guiheadroom", "ghr", P_NUM|P_VI_DEF, 1361 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) 1362 (char_u *)&p_ghr, PV_NONE, 1363 #else 1364 (char_u *)NULL, PV_NONE, 1365 #endif 1366 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT}, 1367 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, 1368 #if defined(FEAT_GUI) 1369 (char_u *)&p_go, PV_NONE, 1370 # if defined(UNIX) && !defined(MACOS) 1371 {(char_u *)"aegimrLtT", (char_u *)0L} 1372 # else 1373 {(char_u *)"egmrLtT", (char_u *)0L} 1374 # endif 1375 #else 1376 (char_u *)NULL, PV_NONE, 1377 {(char_u *)NULL, (char_u *)0L} 1378 #endif 1379 SCRIPTID_INIT}, 1380 {"guipty", NULL, P_BOOL|P_VI_DEF, 1381 #if defined(FEAT_GUI) 1382 (char_u *)&p_guipty, PV_NONE, 1383 #else 1384 (char_u *)NULL, PV_NONE, 1385 #endif 1386 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1387 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN, 1388 #if defined(FEAT_GUI_TABLINE) 1389 (char_u *)&p_gtl, PV_NONE, 1390 {(char_u *)"", (char_u *)0L} 1391 #else 1392 (char_u *)NULL, PV_NONE, 1393 {(char_u *)NULL, (char_u *)0L} 1394 #endif 1395 SCRIPTID_INIT}, 1396 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN, 1397 #if defined(FEAT_GUI_TABLINE) 1398 (char_u *)&p_gtt, PV_NONE, 1399 {(char_u *)"", (char_u *)0L} 1400 #else 1401 (char_u *)NULL, PV_NONE, 1402 {(char_u *)NULL, (char_u *)0L} 1403 #endif 1404 SCRIPTID_INIT}, 1405 {"hardtabs", "ht", P_NUM|P_VI_DEF, 1406 (char_u *)NULL, PV_NONE, 1407 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 1408 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1409 (char_u *)&p_hf, PV_NONE, 1410 {(char_u *)DFLT_HELPFILE, (char_u *)0L} 1411 SCRIPTID_INIT}, 1412 {"helpheight", "hh", P_NUM|P_VI_DEF, 1413 #ifdef FEAT_WINDOWS 1414 (char_u *)&p_hh, PV_NONE, 1415 #else 1416 (char_u *)NULL, PV_NONE, 1417 #endif 1418 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, 1419 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA, 1420 #ifdef FEAT_MULTI_LANG 1421 (char_u *)&p_hlg, PV_NONE, 1422 {(char_u *)"", (char_u *)0L} 1423 #else 1424 (char_u *)NULL, PV_NONE, 1425 {(char_u *)0L, (char_u *)0L} 1426 #endif 1427 SCRIPTID_INIT}, 1428 {"hidden", "hid", P_BOOL|P_VI_DEF, 1429 (char_u *)&p_hid, PV_NONE, 1430 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1431 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP, 1432 (char_u *)&p_hl, PV_NONE, 1433 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L} 1434 SCRIPTID_INIT}, 1435 {"history", "hi", P_NUM|P_VIM, 1436 (char_u *)&p_hi, PV_NONE, 1437 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT}, 1438 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM, 1439 #ifdef FEAT_RIGHTLEFT 1440 (char_u *)&p_hkmap, PV_NONE, 1441 #else 1442 (char_u *)NULL, PV_NONE, 1443 #endif 1444 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1445 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM, 1446 #ifdef FEAT_RIGHTLEFT 1447 (char_u *)&p_hkmapp, PV_NONE, 1448 #else 1449 (char_u *)NULL, PV_NONE, 1450 #endif 1451 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1452 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL, 1453 (char_u *)&p_hls, PV_NONE, 1454 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1455 {"icon", NULL, P_BOOL|P_VI_DEF, 1456 #ifdef FEAT_TITLE 1457 (char_u *)&p_icon, PV_NONE, 1458 #else 1459 (char_u *)NULL, PV_NONE, 1460 #endif 1461 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1462 {"iconstring", NULL, P_STRING|P_VI_DEF, 1463 #ifdef FEAT_TITLE 1464 (char_u *)&p_iconstring, PV_NONE, 1465 #else 1466 (char_u *)NULL, PV_NONE, 1467 #endif 1468 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1469 {"ignorecase", "ic", P_BOOL|P_VI_DEF, 1470 (char_u *)&p_ic, PV_NONE, 1471 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1472 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE, 1473 # if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 1474 (char_u *)&p_imaf, PV_NONE, 1475 {(char_u *)"", (char_u *)NULL} 1476 # else 1477 (char_u *)NULL, PV_NONE, 1478 {(char_u *)NULL, (char_u *)0L} 1479 # endif 1480 SCRIPTID_INIT}, 1481 {"imactivatekey","imak",P_STRING|P_VI_DEF, 1482 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 1483 (char_u *)&p_imak, PV_NONE, 1484 #else 1485 (char_u *)NULL, PV_NONE, 1486 #endif 1487 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1488 {"imcmdline", "imc", P_BOOL|P_VI_DEF, 1489 #ifdef USE_IM_CONTROL 1490 (char_u *)&p_imcmdline, PV_NONE, 1491 #else 1492 (char_u *)NULL, PV_NONE, 1493 #endif 1494 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1495 {"imdisable", "imd", P_BOOL|P_VI_DEF, 1496 #ifdef USE_IM_CONTROL 1497 (char_u *)&p_imdisable, PV_NONE, 1498 #else 1499 (char_u *)NULL, PV_NONE, 1500 #endif 1501 #ifdef __sgi 1502 {(char_u *)TRUE, (char_u *)0L} 1503 #else 1504 {(char_u *)FALSE, (char_u *)0L} 1505 #endif 1506 SCRIPTID_INIT}, 1507 {"iminsert", "imi", P_NUM|P_VI_DEF, 1508 (char_u *)&p_iminsert, PV_IMI, 1509 #ifdef B_IMODE_IM 1510 {(char_u *)B_IMODE_IM, (char_u *)0L} 1511 #else 1512 {(char_u *)B_IMODE_NONE, (char_u *)0L} 1513 #endif 1514 SCRIPTID_INIT}, 1515 {"imsearch", "ims", P_NUM|P_VI_DEF, 1516 (char_u *)&p_imsearch, PV_IMS, 1517 #ifdef B_IMODE_IM 1518 {(char_u *)B_IMODE_IM, (char_u *)0L} 1519 #else 1520 {(char_u *)B_IMODE_NONE, (char_u *)0L} 1521 #endif 1522 SCRIPTID_INIT}, 1523 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE, 1524 # if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 1525 (char_u *)&p_imsf, PV_NONE, 1526 {(char_u *)"", (char_u *)NULL} 1527 # else 1528 (char_u *)NULL, PV_NONE, 1529 {(char_u *)NULL, (char_u *)0L} 1530 # endif 1531 SCRIPTID_INIT}, 1532 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF, 1533 #ifdef FEAT_FIND_ID 1534 (char_u *)&p_inc, PV_INC, 1535 {(char_u *)"^\\s*#\\s*include", (char_u *)0L} 1536 #else 1537 (char_u *)NULL, PV_NONE, 1538 {(char_u *)0L, (char_u *)0L} 1539 #endif 1540 SCRIPTID_INIT}, 1541 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF, 1542 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 1543 (char_u *)&p_inex, PV_INEX, 1544 {(char_u *)"", (char_u *)0L} 1545 #else 1546 (char_u *)NULL, PV_NONE, 1547 {(char_u *)0L, (char_u *)0L} 1548 #endif 1549 SCRIPTID_INIT}, 1550 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM, 1551 (char_u *)&p_is, PV_NONE, 1552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1553 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, 1554 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 1555 (char_u *)&p_inde, PV_INDE, 1556 {(char_u *)"", (char_u *)0L} 1557 #else 1558 (char_u *)NULL, PV_NONE, 1559 {(char_u *)0L, (char_u *)0L} 1560 #endif 1561 SCRIPTID_INIT}, 1562 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 1563 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 1564 (char_u *)&p_indk, PV_INDK, 1565 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L} 1566 #else 1567 (char_u *)NULL, PV_NONE, 1568 {(char_u *)0L, (char_u *)0L} 1569 #endif 1570 SCRIPTID_INIT}, 1571 {"infercase", "inf", P_BOOL|P_VI_DEF, 1572 (char_u *)&p_inf, PV_INF, 1573 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1574 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM, 1575 (char_u *)&p_im, PV_NONE, 1576 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1577 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, 1578 (char_u *)&p_isf, PV_NONE, 1579 { 1580 #ifdef BACKSLASH_IN_FILENAME 1581 /* Excluded are: & and ^ are special in cmd.exe 1582 * ( and ) are used in text separating fnames */ 1583 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=", 1584 #else 1585 # ifdef AMIGA 1586 (char_u *)"@,48-57,/,.,-,_,+,,,$,:", 1587 # else 1588 # ifdef VMS 1589 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~", 1590 # else /* UNIX et al. */ 1591 # ifdef EBCDIC 1592 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=", 1593 # else 1594 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=", 1595 # endif 1596 # endif 1597 # endif 1598 #endif 1599 (char_u *)0L} SCRIPTID_INIT}, 1600 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, 1601 (char_u *)&p_isi, PV_NONE, 1602 { 1603 #if defined(MSDOS) || defined(MSWIN) 1604 (char_u *)"@,48-57,_,128-167,224-235", 1605 #else 1606 # ifdef EBCDIC 1607 /* TODO: EBCDIC Check this! @ == isalpha()*/ 1608 (char_u *)"@,240-249,_,66-73,81-89,98-105," 1609 "112-120,128,140-142,156,158,172," 1610 "174,186,191,203-207,219-225,235-239," 1611 "251-254", 1612 # else 1613 (char_u *)"@,48-57,_,192-255", 1614 # endif 1615 #endif 1616 (char_u *)0L} SCRIPTID_INIT}, 1617 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP, 1618 (char_u *)&p_isk, PV_ISK, 1619 { 1620 #ifdef EBCDIC 1621 (char_u *)"@,240-249,_", 1622 /* TODO: EBCDIC Check this! @ == isalpha()*/ 1623 (char_u *)"@,240-249,_,66-73,81-89,98-105," 1624 "112-120,128,140-142,156,158,172," 1625 "174,186,191,203-207,219-225,235-239," 1626 "251-254", 1627 #else 1628 (char_u *)"@,48-57,_", 1629 # if defined(MSDOS) || defined(MSWIN) 1630 (char_u *)"@,48-57,_,128-167,224-235" 1631 # else 1632 ISK_LATIN1 1633 # endif 1634 #endif 1635 } SCRIPTID_INIT}, 1636 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, 1637 (char_u *)&p_isp, PV_NONE, 1638 { 1639 #if defined(MSDOS) || defined(MSWIN) \ 1640 || (defined(MACOS) && !defined(MACOS_X)) \ 1641 || defined(VMS) 1642 (char_u *)"@,~-255", 1643 #else 1644 # ifdef EBCDIC 1645 /* all chars above 63 are printable */ 1646 (char_u *)"63-255", 1647 # else 1648 ISP_LATIN1, 1649 # endif 1650 #endif 1651 (char_u *)0L} SCRIPTID_INIT}, 1652 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM, 1653 (char_u *)&p_js, PV_NONE, 1654 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1655 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC, 1656 #ifdef FEAT_CRYPT 1657 (char_u *)&p_key, PV_KEY, 1658 {(char_u *)"", (char_u *)0L} 1659 #else 1660 (char_u *)NULL, PV_NONE, 1661 {(char_u *)0L, (char_u *)0L} 1662 #endif 1663 SCRIPTID_INIT}, 1664 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC, 1665 #ifdef FEAT_KEYMAP 1666 (char_u *)&p_keymap, PV_KMAP, 1667 {(char_u *)"", (char_u *)0L} 1668 #else 1669 (char_u *)NULL, PV_NONE, 1670 {(char_u *)"", (char_u *)0L} 1671 #endif 1672 SCRIPTID_INIT}, 1673 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1674 (char_u *)&p_km, PV_NONE, 1675 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1676 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1677 (char_u *)&p_kp, PV_KP, 1678 { 1679 #if defined(MSDOS) || defined(MSWIN) 1680 (char_u *)":help", 1681 #else 1682 #ifdef VMS 1683 (char_u *)"help", 1684 #else 1685 # ifdef USEMAN_S 1686 (char_u *)"man -s", 1687 # else 1688 (char_u *)"man", 1689 # endif 1690 #endif 1691 #endif 1692 (char_u *)0L} SCRIPTID_INIT}, 1693 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE, 1694 #ifdef FEAT_LANGMAP 1695 (char_u *)&p_langmap, PV_NONE, 1696 {(char_u *)"", /* unmatched } */ 1697 #else 1698 (char_u *)NULL, PV_NONE, 1699 {(char_u *)NULL, 1700 #endif 1701 (char_u *)0L} SCRIPTID_INIT}, 1702 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, 1703 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) 1704 (char_u *)&p_lm, PV_NONE, 1705 #else 1706 (char_u *)NULL, PV_NONE, 1707 #endif 1708 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1709 {"langnoremap", "lnr", P_BOOL|P_VI_DEF, 1710 #ifdef FEAT_LANGMAP 1711 (char_u *)&p_lnr, PV_NONE, 1712 #else 1713 (char_u *)NULL, PV_NONE, 1714 #endif 1715 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1716 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, 1717 #ifdef FEAT_WINDOWS 1718 (char_u *)&p_ls, PV_NONE, 1719 #else 1720 (char_u *)NULL, PV_NONE, 1721 #endif 1722 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 1723 {"lazyredraw", "lz", P_BOOL|P_VI_DEF, 1724 (char_u *)&p_lz, PV_NONE, 1725 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1726 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN, 1727 #ifdef FEAT_LINEBREAK 1728 (char_u *)VAR_WIN, PV_LBR, 1729 #else 1730 (char_u *)NULL, PV_NONE, 1731 #endif 1732 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1733 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, 1734 (char_u *)&Rows, PV_NONE, 1735 { 1736 #if defined(MSDOS) || defined(WIN3264) 1737 (char_u *)25L, 1738 #else 1739 (char_u *)24L, 1740 #endif 1741 (char_u *)0L} SCRIPTID_INIT}, 1742 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR, 1743 #ifdef FEAT_GUI 1744 (char_u *)&p_linespace, PV_NONE, 1745 #else 1746 (char_u *)NULL, PV_NONE, 1747 #endif 1748 #ifdef FEAT_GUI_W32 1749 {(char_u *)1L, (char_u *)0L} 1750 #else 1751 {(char_u *)0L, (char_u *)0L} 1752 #endif 1753 SCRIPTID_INIT}, 1754 {"lisp", NULL, P_BOOL|P_VI_DEF, 1755 #ifdef FEAT_LISP 1756 (char_u *)&p_lisp, PV_LISP, 1757 #else 1758 (char_u *)NULL, PV_NONE, 1759 #endif 1760 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1761 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1762 #ifdef FEAT_LISP 1763 (char_u *)&p_lispwords, PV_LW, 1764 {(char_u *)LISPWORD_VALUE, (char_u *)0L} 1765 #else 1766 (char_u *)NULL, PV_NONE, 1767 {(char_u *)"", (char_u *)0L} 1768 #endif 1769 SCRIPTID_INIT}, 1770 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, 1771 (char_u *)VAR_WIN, PV_LIST, 1772 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1773 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP, 1774 (char_u *)&p_lcs, PV_NONE, 1775 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT}, 1776 {"loadplugins", "lpl", P_BOOL|P_VI_DEF, 1777 (char_u *)&p_lpl, PV_NONE, 1778 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1779 #if defined(DYNAMIC_LUA) && !defined(WIN3264) 1780 {"luadll", NULL, P_STRING|P_VI_DEF|P_SECURE, 1781 (char_u *)&p_luadll, PV_NONE, 1782 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1783 #endif 1784 #ifdef FEAT_GUI_MAC 1785 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR, 1786 (char_u *)&p_macatsui, PV_NONE, 1787 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1788 #endif 1789 {"magic", NULL, P_BOOL|P_VI_DEF, 1790 (char_u *)&p_magic, PV_NONE, 1791 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1792 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1793 #ifdef FEAT_QUICKFIX 1794 (char_u *)&p_mef, PV_NONE, 1795 {(char_u *)"", (char_u *)0L} 1796 #else 1797 (char_u *)NULL, PV_NONE, 1798 {(char_u *)NULL, (char_u *)0L} 1799 #endif 1800 SCRIPTID_INIT}, 1801 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1802 #ifdef FEAT_QUICKFIX 1803 (char_u *)&p_mp, PV_MP, 1804 # ifdef VMS 1805 {(char_u *)"MMS", (char_u *)0L} 1806 # else 1807 {(char_u *)"make", (char_u *)0L} 1808 # endif 1809 #else 1810 (char_u *)NULL, PV_NONE, 1811 {(char_u *)NULL, (char_u *)0L} 1812 #endif 1813 SCRIPTID_INIT}, 1814 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 1815 (char_u *)&p_mps, PV_MPS, 1816 {(char_u *)"(:),{:},[:]", (char_u *)0L} 1817 SCRIPTID_INIT}, 1818 {"matchtime", "mat", P_NUM|P_VI_DEF, 1819 (char_u *)&p_mat, PV_NONE, 1820 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT}, 1821 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT, 1822 #ifdef FEAT_MBYTE 1823 (char_u *)&p_mco, PV_NONE, 1824 #else 1825 (char_u *)NULL, PV_NONE, 1826 #endif 1827 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT}, 1828 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF, 1829 #ifdef FEAT_EVAL 1830 (char_u *)&p_mfd, PV_NONE, 1831 #else 1832 (char_u *)NULL, PV_NONE, 1833 #endif 1834 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT}, 1835 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF, 1836 (char_u *)&p_mmd, PV_NONE, 1837 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, 1838 {"maxmem", "mm", P_NUM|P_VI_DEF, 1839 (char_u *)&p_mm, PV_NONE, 1840 {(char_u *)DFLT_MAXMEM, (char_u *)0L} 1841 SCRIPTID_INIT}, 1842 {"maxmempattern","mmp", P_NUM|P_VI_DEF, 1843 (char_u *)&p_mmp, PV_NONE, 1844 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, 1845 {"maxmemtot", "mmt", P_NUM|P_VI_DEF, 1846 (char_u *)&p_mmt, PV_NONE, 1847 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L} 1848 SCRIPTID_INIT}, 1849 {"menuitems", "mis", P_NUM|P_VI_DEF, 1850 #ifdef FEAT_MENU 1851 (char_u *)&p_mis, PV_NONE, 1852 #else 1853 (char_u *)NULL, PV_NONE, 1854 #endif 1855 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT}, 1856 {"mesg", NULL, P_BOOL|P_VI_DEF, 1857 (char_u *)NULL, PV_NONE, 1858 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1859 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE, 1860 #ifdef FEAT_SPELL 1861 (char_u *)&p_msm, PV_NONE, 1862 {(char_u *)"460000,2000,500", (char_u *)0L} 1863 #else 1864 (char_u *)NULL, PV_NONE, 1865 {(char_u *)0L, (char_u *)0L} 1866 #endif 1867 SCRIPTID_INIT}, 1868 {"modeline", "ml", P_BOOL|P_VIM, 1869 (char_u *)&p_ml, PV_ML, 1870 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 1871 {"modelines", "mls", P_NUM|P_VI_DEF, 1872 (char_u *)&p_mls, PV_NONE, 1873 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT}, 1874 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB, 1875 (char_u *)&p_ma, PV_MA, 1876 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1877 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, 1878 (char_u *)&p_mod, PV_MOD, 1879 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1880 {"more", NULL, P_BOOL|P_VIM, 1881 (char_u *)&p_more, PV_NONE, 1882 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 1883 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST, 1884 (char_u *)&p_mouse, PV_NONE, 1885 { 1886 #if defined(MSDOS) || defined(WIN3264) 1887 (char_u *)"a", 1888 #else 1889 (char_u *)"", 1890 #endif 1891 (char_u *)0L} SCRIPTID_INIT}, 1892 {"mousefocus", "mousef", P_BOOL|P_VI_DEF, 1893 #ifdef FEAT_GUI 1894 (char_u *)&p_mousef, PV_NONE, 1895 #else 1896 (char_u *)NULL, PV_NONE, 1897 #endif 1898 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1899 {"mousehide", "mh", P_BOOL|P_VI_DEF, 1900 #ifdef FEAT_GUI 1901 (char_u *)&p_mh, PV_NONE, 1902 #else 1903 (char_u *)NULL, PV_NONE, 1904 #endif 1905 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1906 {"mousemodel", "mousem", P_STRING|P_VI_DEF, 1907 (char_u *)&p_mousem, PV_NONE, 1908 { 1909 #if defined(MSDOS) || defined(MSWIN) 1910 (char_u *)"popup", 1911 #else 1912 # if defined(MACOS) 1913 (char_u *)"popup_setpos", 1914 # else 1915 (char_u *)"extend", 1916 # endif 1917 #endif 1918 (char_u *)0L} SCRIPTID_INIT}, 1919 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1920 #ifdef FEAT_MOUSESHAPE 1921 (char_u *)&p_mouseshape, PV_NONE, 1922 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L} 1923 #else 1924 (char_u *)NULL, PV_NONE, 1925 {(char_u *)NULL, (char_u *)0L} 1926 #endif 1927 SCRIPTID_INIT}, 1928 {"mousetime", "mouset", P_NUM|P_VI_DEF, 1929 (char_u *)&p_mouset, PV_NONE, 1930 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT}, 1931 {"mzquantum", "mzq", P_NUM, 1932 #ifdef FEAT_MZSCHEME 1933 (char_u *)&p_mzq, PV_NONE, 1934 #else 1935 (char_u *)NULL, PV_NONE, 1936 #endif 1937 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT}, 1938 {"novice", NULL, P_BOOL|P_VI_DEF, 1939 (char_u *)NULL, PV_NONE, 1940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1941 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 1942 (char_u *)&p_nf, PV_NF, 1943 {(char_u *)"octal,hex", (char_u *)0L} 1944 SCRIPTID_INIT}, 1945 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, 1946 (char_u *)VAR_WIN, PV_NU, 1947 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1948 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM, 1949 #ifdef FEAT_LINEBREAK 1950 (char_u *)VAR_WIN, PV_NUW, 1951 #else 1952 (char_u *)NULL, PV_NONE, 1953 #endif 1954 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT}, 1955 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, 1956 #ifdef FEAT_COMPL_FUNC 1957 (char_u *)&p_ofu, PV_OFU, 1958 {(char_u *)"", (char_u *)0L} 1959 #else 1960 (char_u *)NULL, PV_NONE, 1961 {(char_u *)0L, (char_u *)0L} 1962 #endif 1963 SCRIPTID_INIT}, 1964 {"open", NULL, P_BOOL|P_VI_DEF, 1965 (char_u *)NULL, PV_NONE, 1966 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1967 {"opendevice", "odev", P_BOOL|P_VI_DEF, 1968 #if defined(MSDOS) || defined(MSWIN) 1969 (char_u *)&p_odev, PV_NONE, 1970 #else 1971 (char_u *)NULL, PV_NONE, 1972 #endif 1973 {(char_u *)FALSE, (char_u *)FALSE} 1974 SCRIPTID_INIT}, 1975 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE, 1976 (char_u *)&p_opfunc, PV_NONE, 1977 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1978 {"optimize", "opt", P_BOOL|P_VI_DEF, 1979 (char_u *)NULL, PV_NONE, 1980 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1981 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF, 1982 (char_u *)NULL, PV_NONE, 1983 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 1984 {"paragraphs", "para", P_STRING|P_VI_DEF, 1985 (char_u *)&p_para, PV_NONE, 1986 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp", 1987 (char_u *)0L} SCRIPTID_INIT}, 1988 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC, 1989 (char_u *)&p_paste, PV_NONE, 1990 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1991 {"pastetoggle", "pt", P_STRING|P_VI_DEF, 1992 (char_u *)&p_pt, PV_NONE, 1993 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1994 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE, 1995 #if defined(FEAT_DIFF) && defined(FEAT_EVAL) 1996 (char_u *)&p_pex, PV_NONE, 1997 {(char_u *)"", (char_u *)0L} 1998 #else 1999 (char_u *)NULL, PV_NONE, 2000 {(char_u *)0L, (char_u *)0L} 2001 #endif 2002 SCRIPTID_INIT}, 2003 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME, 2004 (char_u *)&p_pm, PV_NONE, 2005 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2006 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, 2007 (char_u *)&p_path, PV_PATH, 2008 { 2009 #if defined AMIGA || defined MSDOS || defined MSWIN 2010 (char_u *)".,,", 2011 #else 2012 # if defined(__EMX__) 2013 (char_u *)".,/emx/include,,", 2014 # else /* Unix, probably */ 2015 (char_u *)".,/usr/include,,", 2016 # endif 2017 #endif 2018 (char_u *)0L} SCRIPTID_INIT}, 2019 #if defined(DYNAMIC_PERL) && !defined(WIN3264) 2020 {"perldll", NULL, P_STRING|P_VI_DEF|P_SECURE, 2021 (char_u *)&p_perldll, PV_NONE, 2022 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2023 #endif 2024 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM, 2025 (char_u *)&p_pi, PV_PI, 2026 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2027 {"previewheight", "pvh", P_NUM|P_VI_DEF, 2028 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 2029 (char_u *)&p_pvh, PV_NONE, 2030 #else 2031 (char_u *)NULL, PV_NONE, 2032 #endif 2033 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, 2034 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, 2035 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 2036 (char_u *)VAR_WIN, PV_PVW, 2037 #else 2038 (char_u *)NULL, PV_NONE, 2039 #endif 2040 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2041 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE, 2042 #ifdef FEAT_PRINTER 2043 (char_u *)&p_pdev, PV_NONE, 2044 {(char_u *)"", (char_u *)0L} 2045 #else 2046 (char_u *)NULL, PV_NONE, 2047 {(char_u *)NULL, (char_u *)0L} 2048 #endif 2049 SCRIPTID_INIT}, 2050 {"printencoding", "penc", P_STRING|P_VI_DEF, 2051 #ifdef FEAT_POSTSCRIPT 2052 (char_u *)&p_penc, PV_NONE, 2053 {(char_u *)"", (char_u *)0L} 2054 #else 2055 (char_u *)NULL, PV_NONE, 2056 {(char_u *)NULL, (char_u *)0L} 2057 #endif 2058 SCRIPTID_INIT}, 2059 {"printexpr", "pexpr", P_STRING|P_VI_DEF, 2060 #ifdef FEAT_POSTSCRIPT 2061 (char_u *)&p_pexpr, PV_NONE, 2062 {(char_u *)"", (char_u *)0L} 2063 #else 2064 (char_u *)NULL, PV_NONE, 2065 {(char_u *)NULL, (char_u *)0L} 2066 #endif 2067 SCRIPTID_INIT}, 2068 {"printfont", "pfn", P_STRING|P_VI_DEF, 2069 #ifdef FEAT_PRINTER 2070 (char_u *)&p_pfn, PV_NONE, 2071 { 2072 # ifdef MSWIN 2073 (char_u *)"Courier_New:h10", 2074 # else 2075 (char_u *)"courier", 2076 # endif 2077 (char_u *)0L} 2078 #else 2079 (char_u *)NULL, PV_NONE, 2080 {(char_u *)NULL, (char_u *)0L} 2081 #endif 2082 SCRIPTID_INIT}, 2083 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT, 2084 #ifdef FEAT_PRINTER 2085 (char_u *)&p_header, PV_NONE, 2086 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L} 2087 #else 2088 (char_u *)NULL, PV_NONE, 2089 {(char_u *)NULL, (char_u *)0L} 2090 #endif 2091 SCRIPTID_INIT}, 2092 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF, 2093 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) 2094 (char_u *)&p_pmcs, PV_NONE, 2095 {(char_u *)"", (char_u *)0L} 2096 #else 2097 (char_u *)NULL, PV_NONE, 2098 {(char_u *)NULL, (char_u *)0L} 2099 #endif 2100 SCRIPTID_INIT}, 2101 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF, 2102 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) 2103 (char_u *)&p_pmfn, PV_NONE, 2104 {(char_u *)"", (char_u *)0L} 2105 #else 2106 (char_u *)NULL, PV_NONE, 2107 {(char_u *)NULL, (char_u *)0L} 2108 #endif 2109 SCRIPTID_INIT}, 2110 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2111 #ifdef FEAT_PRINTER 2112 (char_u *)&p_popt, PV_NONE, 2113 {(char_u *)"", (char_u *)0L} 2114 #else 2115 (char_u *)NULL, PV_NONE, 2116 {(char_u *)NULL, (char_u *)0L} 2117 #endif 2118 SCRIPTID_INIT}, 2119 {"prompt", NULL, P_BOOL|P_VI_DEF, 2120 (char_u *)&p_prompt, PV_NONE, 2121 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2122 {"pumheight", "ph", P_NUM|P_VI_DEF, 2123 #ifdef FEAT_INS_EXPAND 2124 (char_u *)&p_ph, PV_NONE, 2125 #else 2126 (char_u *)NULL, PV_NONE, 2127 #endif 2128 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2129 #if defined(DYNAMIC_PYTHON3) && !defined(WIN3264) 2130 {"pythonthreedll", NULL, P_STRING|P_VI_DEF|P_SECURE, 2131 (char_u *)&p_py3dll, PV_NONE, 2132 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2133 #endif 2134 #if defined(DYNAMIC_PYTHON) && !defined(WIN3264) 2135 {"pythondll", NULL, P_STRING|P_VI_DEF|P_SECURE, 2136 (char_u *)&p_pydll, PV_NONE, 2137 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2138 #endif 2139 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF, 2140 #ifdef FEAT_TEXTOBJ 2141 (char_u *)&p_qe, PV_QE, 2142 {(char_u *)"\\", (char_u *)0L} 2143 #else 2144 (char_u *)NULL, PV_NONE, 2145 {(char_u *)NULL, (char_u *)0L} 2146 #endif 2147 SCRIPTID_INIT}, 2148 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, 2149 (char_u *)&p_ro, PV_RO, 2150 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2151 {"redraw", NULL, P_BOOL|P_VI_DEF, 2152 (char_u *)NULL, PV_NONE, 2153 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2154 {"redrawtime", "rdt", P_NUM|P_VI_DEF, 2155 #ifdef FEAT_RELTIME 2156 (char_u *)&p_rdt, PV_NONE, 2157 #else 2158 (char_u *)NULL, PV_NONE, 2159 #endif 2160 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT}, 2161 {"regexpengine", "re", P_NUM|P_VI_DEF, 2162 (char_u *)&p_re, PV_NONE, 2163 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2164 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN, 2165 (char_u *)VAR_WIN, PV_RNU, 2166 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2167 {"remap", NULL, P_BOOL|P_VI_DEF, 2168 (char_u *)&p_remap, PV_NONE, 2169 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2170 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF, 2171 #ifdef FEAT_RENDER_OPTIONS 2172 (char_u *)&p_rop, PV_NONE, 2173 {(char_u *)"", (char_u *)0L} 2174 #else 2175 (char_u *)NULL, PV_NONE, 2176 {(char_u *)NULL, (char_u *)0L} 2177 #endif 2178 SCRIPTID_INIT}, 2179 {"report", NULL, P_NUM|P_VI_DEF, 2180 (char_u *)&p_report, PV_NONE, 2181 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT}, 2182 {"restorescreen", "rs", P_BOOL|P_VI_DEF, 2183 #ifdef WIN3264 2184 (char_u *)&p_rs, PV_NONE, 2185 #else 2186 (char_u *)NULL, PV_NONE, 2187 #endif 2188 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2189 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM, 2190 #ifdef FEAT_RIGHTLEFT 2191 (char_u *)&p_ri, PV_NONE, 2192 #else 2193 (char_u *)NULL, PV_NONE, 2194 #endif 2195 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2196 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN, 2197 #ifdef FEAT_RIGHTLEFT 2198 (char_u *)VAR_WIN, PV_RL, 2199 #else 2200 (char_u *)NULL, PV_NONE, 2201 #endif 2202 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2203 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, 2204 #ifdef FEAT_RIGHTLEFT 2205 (char_u *)VAR_WIN, PV_RLC, 2206 {(char_u *)"search", (char_u *)NULL} 2207 #else 2208 (char_u *)NULL, PV_NONE, 2209 {(char_u *)NULL, (char_u *)0L} 2210 #endif 2211 SCRIPTID_INIT}, 2212 #if defined(DYNAMIC_RUBY) && !defined(WIN3264) 2213 {"rubydll", NULL, P_STRING|P_VI_DEF|P_SECURE, 2214 (char_u *)&p_rubydll, PV_NONE, 2215 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2216 #endif 2217 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT, 2218 #ifdef FEAT_CMDL_INFO 2219 (char_u *)&p_ru, PV_NONE, 2220 #else 2221 (char_u *)NULL, PV_NONE, 2222 #endif 2223 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2224 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, 2225 #ifdef FEAT_STL_OPT 2226 (char_u *)&p_ruf, PV_NONE, 2227 #else 2228 (char_u *)NULL, PV_NONE, 2229 #endif 2230 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2231 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP 2232 |P_SECURE, 2233 (char_u *)&p_rtp, PV_NONE, 2234 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L} 2235 SCRIPTID_INIT}, 2236 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF, 2237 (char_u *)VAR_WIN, PV_SCROLL, 2238 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, 2239 {"scrollbind", "scb", P_BOOL|P_VI_DEF, 2240 #ifdef FEAT_SCROLLBIND 2241 (char_u *)VAR_WIN, PV_SCBIND, 2242 #else 2243 (char_u *)NULL, PV_NONE, 2244 #endif 2245 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2246 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, 2247 (char_u *)&p_sj, PV_NONE, 2248 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2249 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, 2250 (char_u *)&p_so, PV_NONE, 2251 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2252 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2253 #ifdef FEAT_SCROLLBIND 2254 (char_u *)&p_sbo, PV_NONE, 2255 {(char_u *)"ver,jump", (char_u *)0L} 2256 #else 2257 (char_u *)NULL, PV_NONE, 2258 {(char_u *)0L, (char_u *)0L} 2259 #endif 2260 SCRIPTID_INIT}, 2261 {"sections", "sect", P_STRING|P_VI_DEF, 2262 (char_u *)&p_sections, PV_NONE, 2263 {(char_u *)"SHNHH HUnhsh", (char_u *)0L} 2264 SCRIPTID_INIT}, 2265 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE, 2266 (char_u *)&p_secure, PV_NONE, 2267 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2268 {"selection", "sel", P_STRING|P_VI_DEF, 2269 (char_u *)&p_sel, PV_NONE, 2270 {(char_u *)"inclusive", (char_u *)0L} 2271 SCRIPTID_INIT}, 2272 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2273 (char_u *)&p_slm, PV_NONE, 2274 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2275 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2276 #ifdef FEAT_SESSION 2277 (char_u *)&p_ssop, PV_NONE, 2278 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize", 2279 (char_u *)0L} 2280 #else 2281 (char_u *)NULL, PV_NONE, 2282 {(char_u *)0L, (char_u *)0L} 2283 #endif 2284 SCRIPTID_INIT}, 2285 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2286 (char_u *)&p_sh, PV_NONE, 2287 { 2288 #ifdef VMS 2289 (char_u *)"-", 2290 #else 2291 # if defined(MSDOS) 2292 (char_u *)"command", 2293 # else 2294 # if defined(WIN16) 2295 (char_u *)"command.com", 2296 # else 2297 # if defined(WIN3264) 2298 (char_u *)"", /* set in set_init_1() */ 2299 # else 2300 (char_u *)"sh", 2301 # endif 2302 # endif 2303 # endif 2304 #endif /* VMS */ 2305 (char_u *)0L} SCRIPTID_INIT}, 2306 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE, 2307 (char_u *)&p_shcf, PV_NONE, 2308 { 2309 #if defined(MSDOS) || defined(MSWIN) 2310 (char_u *)"/c", 2311 #else 2312 (char_u *)"-c", 2313 #endif 2314 (char_u *)0L} SCRIPTID_INIT}, 2315 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE, 2316 #ifdef FEAT_QUICKFIX 2317 (char_u *)&p_sp, PV_NONE, 2318 { 2319 #if defined(UNIX) 2320 (char_u *)"| tee", 2321 #else 2322 (char_u *)">", 2323 #endif 2324 (char_u *)0L} 2325 #else 2326 (char_u *)NULL, PV_NONE, 2327 {(char_u *)0L, (char_u *)0L} 2328 #endif 2329 SCRIPTID_INIT}, 2330 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE, 2331 (char_u *)&p_shq, PV_NONE, 2332 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2333 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE, 2334 (char_u *)&p_srr, PV_NONE, 2335 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT}, 2336 {"shellslash", "ssl", P_BOOL|P_VI_DEF, 2337 #ifdef BACKSLASH_IN_FILENAME 2338 (char_u *)&p_ssl, PV_NONE, 2339 #else 2340 (char_u *)NULL, PV_NONE, 2341 #endif 2342 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2343 {"shelltemp", "stmp", P_BOOL, 2344 (char_u *)&p_stmp, PV_NONE, 2345 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 2346 {"shelltype", "st", P_NUM|P_VI_DEF, 2347 #ifdef AMIGA 2348 (char_u *)&p_st, PV_NONE, 2349 #else 2350 (char_u *)NULL, PV_NONE, 2351 #endif 2352 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2353 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE, 2354 (char_u *)&p_sxq, PV_NONE, 2355 { 2356 #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__) 2357 (char_u *)"\"", 2358 #else 2359 (char_u *)"", 2360 #endif 2361 (char_u *)0L} SCRIPTID_INIT}, 2362 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE, 2363 (char_u *)&p_sxe, PV_NONE, 2364 { 2365 #if defined(MSDOS) || defined(WIN16) || defined(WIN3264) 2366 (char_u *)"\"&|<>()@^", 2367 #else 2368 (char_u *)"", 2369 #endif 2370 (char_u *)0L} SCRIPTID_INIT}, 2371 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM, 2372 (char_u *)&p_sr, PV_NONE, 2373 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2374 {"shiftwidth", "sw", P_NUM|P_VI_DEF, 2375 (char_u *)&p_sw, PV_SW, 2376 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT}, 2377 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST, 2378 (char_u *)&p_shm, PV_NONE, 2379 {(char_u *)"", (char_u *)"filnxtToO"} 2380 SCRIPTID_INIT}, 2381 {"shortname", "sn", P_BOOL|P_VI_DEF, 2382 #ifdef SHORT_FNAME 2383 (char_u *)NULL, PV_NONE, 2384 #else 2385 (char_u *)&p_sn, PV_SN, 2386 #endif 2387 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2388 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL, 2389 #ifdef FEAT_LINEBREAK 2390 (char_u *)&p_sbr, PV_NONE, 2391 #else 2392 (char_u *)NULL, PV_NONE, 2393 #endif 2394 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2395 {"showcmd", "sc", P_BOOL|P_VIM, 2396 #ifdef FEAT_CMDL_INFO 2397 (char_u *)&p_sc, PV_NONE, 2398 #else 2399 (char_u *)NULL, PV_NONE, 2400 #endif 2401 {(char_u *)FALSE, 2402 #ifdef UNIX 2403 (char_u *)FALSE 2404 #else 2405 (char_u *)TRUE 2406 #endif 2407 } SCRIPTID_INIT}, 2408 {"showfulltag", "sft", P_BOOL|P_VI_DEF, 2409 (char_u *)&p_sft, PV_NONE, 2410 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2411 {"showmatch", "sm", P_BOOL|P_VI_DEF, 2412 (char_u *)&p_sm, PV_NONE, 2413 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2414 {"showmode", "smd", P_BOOL|P_VIM, 2415 (char_u *)&p_smd, PV_NONE, 2416 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 2417 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL, 2418 #ifdef FEAT_WINDOWS 2419 (char_u *)&p_stal, PV_NONE, 2420 #else 2421 (char_u *)NULL, PV_NONE, 2422 #endif 2423 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2424 {"sidescroll", "ss", P_NUM|P_VI_DEF, 2425 (char_u *)&p_ss, PV_NONE, 2426 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2427 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, 2428 (char_u *)&p_siso, PV_NONE, 2429 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2430 {"slowopen", "slow", P_BOOL|P_VI_DEF, 2431 (char_u *)NULL, PV_NONE, 2432 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2433 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM, 2434 (char_u *)&p_scs, PV_NONE, 2435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2436 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM, 2437 #ifdef FEAT_SMARTINDENT 2438 (char_u *)&p_si, PV_SI, 2439 #else 2440 (char_u *)NULL, PV_NONE, 2441 #endif 2442 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2443 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM, 2444 (char_u *)&p_sta, PV_NONE, 2445 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2446 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM, 2447 (char_u *)&p_sts, PV_STS, 2448 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2449 {"sourceany", NULL, P_BOOL|P_VI_DEF, 2450 (char_u *)NULL, PV_NONE, 2451 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2452 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN, 2453 #ifdef FEAT_SPELL 2454 (char_u *)VAR_WIN, PV_SPELL, 2455 #else 2456 (char_u *)NULL, PV_NONE, 2457 #endif 2458 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2459 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF, 2460 #ifdef FEAT_SPELL 2461 (char_u *)&p_spc, PV_SPC, 2462 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L} 2463 #else 2464 (char_u *)NULL, PV_NONE, 2465 {(char_u *)0L, (char_u *)0L} 2466 #endif 2467 SCRIPTID_INIT}, 2468 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE 2469 |P_ONECOMMA, 2470 #ifdef FEAT_SPELL 2471 (char_u *)&p_spf, PV_SPF, 2472 {(char_u *)"", (char_u *)0L} 2473 #else 2474 (char_u *)NULL, PV_NONE, 2475 {(char_u *)0L, (char_u *)0L} 2476 #endif 2477 SCRIPTID_INIT}, 2478 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA 2479 |P_RBUF|P_EXPAND, 2480 #ifdef FEAT_SPELL 2481 (char_u *)&p_spl, PV_SPL, 2482 {(char_u *)"en", (char_u *)0L} 2483 #else 2484 (char_u *)NULL, PV_NONE, 2485 {(char_u *)0L, (char_u *)0L} 2486 #endif 2487 SCRIPTID_INIT}, 2488 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA, 2489 #ifdef FEAT_SPELL 2490 (char_u *)&p_sps, PV_NONE, 2491 {(char_u *)"best", (char_u *)0L} 2492 #else 2493 (char_u *)NULL, PV_NONE, 2494 {(char_u *)0L, (char_u *)0L} 2495 #endif 2496 SCRIPTID_INIT}, 2497 {"splitbelow", "sb", P_BOOL|P_VI_DEF, 2498 #ifdef FEAT_WINDOWS 2499 (char_u *)&p_sb, PV_NONE, 2500 #else 2501 (char_u *)NULL, PV_NONE, 2502 #endif 2503 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2504 {"splitright", "spr", P_BOOL|P_VI_DEF, 2505 #ifdef FEAT_VERTSPLIT 2506 (char_u *)&p_spr, PV_NONE, 2507 #else 2508 (char_u *)NULL, PV_NONE, 2509 #endif 2510 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2511 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM, 2512 (char_u *)&p_sol, PV_NONE, 2513 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2514 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, 2515 #ifdef FEAT_STL_OPT 2516 (char_u *)&p_stl, PV_STL, 2517 #else 2518 (char_u *)NULL, PV_NONE, 2519 #endif 2520 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2521 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2522 (char_u *)&p_su, PV_NONE, 2523 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj", 2524 (char_u *)0L} SCRIPTID_INIT}, 2525 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP, 2526 #ifdef FEAT_SEARCHPATH 2527 (char_u *)&p_sua, PV_SUA, 2528 {(char_u *)"", (char_u *)0L} 2529 #else 2530 (char_u *)NULL, PV_NONE, 2531 {(char_u *)0L, (char_u *)0L} 2532 #endif 2533 SCRIPTID_INIT}, 2534 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT, 2535 (char_u *)&p_swf, PV_SWF, 2536 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2537 {"swapsync", "sws", P_STRING|P_VI_DEF, 2538 (char_u *)&p_sws, PV_NONE, 2539 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT}, 2540 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2541 (char_u *)&p_swb, PV_NONE, 2542 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2543 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF, 2544 #ifdef FEAT_SYN_HL 2545 (char_u *)&p_smc, PV_SMC, 2546 {(char_u *)3000L, (char_u *)0L} 2547 #else 2548 (char_u *)NULL, PV_NONE, 2549 {(char_u *)0L, (char_u *)0L} 2550 #endif 2551 SCRIPTID_INIT}, 2552 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, 2553 #ifdef FEAT_SYN_HL 2554 (char_u *)&p_syn, PV_SYN, 2555 {(char_u *)"", (char_u *)0L} 2556 #else 2557 (char_u *)NULL, PV_NONE, 2558 {(char_u *)0L, (char_u *)0L} 2559 #endif 2560 SCRIPTID_INIT}, 2561 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL, 2562 #ifdef FEAT_STL_OPT 2563 (char_u *)&p_tal, PV_NONE, 2564 #else 2565 (char_u *)NULL, PV_NONE, 2566 #endif 2567 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2568 {"tabpagemax", "tpm", P_NUM|P_VI_DEF, 2569 #ifdef FEAT_WINDOWS 2570 (char_u *)&p_tpm, PV_NONE, 2571 #else 2572 (char_u *)NULL, PV_NONE, 2573 #endif 2574 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT}, 2575 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF, 2576 (char_u *)&p_ts, PV_TS, 2577 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT}, 2578 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF, 2579 (char_u *)&p_tbs, PV_NONE, 2580 #ifdef VMS /* binary searching doesn't appear to work on VMS */ 2581 {(char_u *)0L, (char_u *)0L} 2582 #else 2583 {(char_u *)TRUE, (char_u *)0L} 2584 #endif 2585 SCRIPTID_INIT}, 2586 {"tagcase", "tc", P_STRING|P_VIM, 2587 (char_u *)&p_tc, PV_TC, 2588 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT}, 2589 {"taglength", "tl", P_NUM|P_VI_DEF, 2590 (char_u *)&p_tl, PV_NONE, 2591 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2592 {"tagrelative", "tr", P_BOOL|P_VIM, 2593 (char_u *)&p_tr, PV_NONE, 2594 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 2595 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, 2596 (char_u *)&p_tags, PV_TAGS, 2597 { 2598 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME) 2599 (char_u *)"./tags,./TAGS,tags,TAGS", 2600 #else 2601 (char_u *)"./tags,tags", 2602 #endif 2603 (char_u *)0L} SCRIPTID_INIT}, 2604 {"tagstack", "tgst", P_BOOL|P_VI_DEF, 2605 (char_u *)&p_tgst, PV_NONE, 2606 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2607 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, 2608 (char_u *)&T_NAME, PV_NONE, 2609 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2610 {"termbidi", "tbidi", P_BOOL|P_VI_DEF, 2611 #ifdef FEAT_ARABIC 2612 (char_u *)&p_tbidi, PV_NONE, 2613 #else 2614 (char_u *)NULL, PV_NONE, 2615 #endif 2616 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2617 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR, 2618 #ifdef FEAT_MBYTE 2619 (char_u *)&p_tenc, PV_NONE, 2620 {(char_u *)"", (char_u *)0L} 2621 #else 2622 (char_u *)NULL, PV_NONE, 2623 {(char_u *)0L, (char_u *)0L} 2624 #endif 2625 SCRIPTID_INIT}, 2626 {"terse", NULL, P_BOOL|P_VI_DEF, 2627 (char_u *)&p_terse, PV_NONE, 2628 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2629 {"textauto", "ta", P_BOOL|P_VIM, 2630 (char_u *)&p_ta, PV_NONE, 2631 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE} 2632 SCRIPTID_INIT}, 2633 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC, 2634 (char_u *)&p_tx, PV_TX, 2635 { 2636 #ifdef USE_CRNL 2637 (char_u *)TRUE, 2638 #else 2639 (char_u *)FALSE, 2640 #endif 2641 (char_u *)0L} SCRIPTID_INIT}, 2642 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF, 2643 (char_u *)&p_tw, PV_TW, 2644 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2645 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, 2646 #ifdef FEAT_INS_EXPAND 2647 (char_u *)&p_tsr, PV_TSR, 2648 #else 2649 (char_u *)NULL, PV_NONE, 2650 #endif 2651 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2652 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM, 2653 (char_u *)&p_to, PV_NONE, 2654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2655 {"timeout", "to", P_BOOL|P_VI_DEF, 2656 (char_u *)&p_timeout, PV_NONE, 2657 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2658 {"timeoutlen", "tm", P_NUM|P_VI_DEF, 2659 (char_u *)&p_tm, PV_NONE, 2660 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, 2661 {"title", NULL, P_BOOL|P_VI_DEF, 2662 #ifdef FEAT_TITLE 2663 (char_u *)&p_title, PV_NONE, 2664 #else 2665 (char_u *)NULL, PV_NONE, 2666 #endif 2667 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2668 {"titlelen", NULL, P_NUM|P_VI_DEF, 2669 #ifdef FEAT_TITLE 2670 (char_u *)&p_titlelen, PV_NONE, 2671 #else 2672 (char_u *)NULL, PV_NONE, 2673 #endif 2674 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT}, 2675 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC, 2676 #ifdef FEAT_TITLE 2677 (char_u *)&p_titleold, PV_NONE, 2678 {(char_u *)N_("Thanks for flying Vim"), 2679 (char_u *)0L} 2680 #else 2681 (char_u *)NULL, PV_NONE, 2682 {(char_u *)0L, (char_u *)0L} 2683 #endif 2684 SCRIPTID_INIT}, 2685 {"titlestring", NULL, P_STRING|P_VI_DEF, 2686 #ifdef FEAT_TITLE 2687 (char_u *)&p_titlestring, PV_NONE, 2688 #else 2689 (char_u *)NULL, PV_NONE, 2690 #endif 2691 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2692 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 2693 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP, 2694 (char_u *)&p_toolbar, PV_NONE, 2695 {(char_u *)"icons,tooltips", (char_u *)0L} 2696 SCRIPTID_INIT}, 2697 #endif 2698 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) 2699 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF, 2700 (char_u *)&p_tbis, PV_NONE, 2701 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT}, 2702 #endif 2703 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM, 2704 (char_u *)&p_ttimeout, PV_NONE, 2705 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2706 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF, 2707 (char_u *)&p_ttm, PV_NONE, 2708 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT}, 2709 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF, 2710 (char_u *)&p_tbi, PV_NONE, 2711 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2712 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF, 2713 (char_u *)&p_tf, PV_NONE, 2714 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2715 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, 2716 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) 2717 (char_u *)&p_ttym, PV_NONE, 2718 #else 2719 (char_u *)NULL, PV_NONE, 2720 #endif 2721 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2722 {"ttyscroll", "tsl", P_NUM|P_VI_DEF, 2723 (char_u *)&p_ttyscroll, PV_NONE, 2724 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT}, 2725 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, 2726 (char_u *)&T_NAME, PV_NONE, 2727 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2728 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE 2729 |P_VI_DEF, 2730 #ifdef FEAT_PERSISTENT_UNDO 2731 (char_u *)&p_udir, PV_NONE, 2732 {(char_u *)".", (char_u *)0L} 2733 #else 2734 (char_u *)NULL, PV_NONE, 2735 {(char_u *)0L, (char_u *)0L} 2736 #endif 2737 SCRIPTID_INIT}, 2738 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM, 2739 #ifdef FEAT_PERSISTENT_UNDO 2740 (char_u *)&p_udf, PV_UDF, 2741 #else 2742 (char_u *)NULL, PV_NONE, 2743 #endif 2744 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2745 {"undolevels", "ul", P_NUM|P_VI_DEF, 2746 (char_u *)&p_ul, PV_UL, 2747 { 2748 #if defined(UNIX) || defined(WIN3264) || defined(VMS) 2749 (char_u *)1000L, 2750 #else 2751 (char_u *)100L, 2752 #endif 2753 (char_u *)0L} SCRIPTID_INIT}, 2754 {"undoreload", "ur", P_NUM|P_VI_DEF, 2755 (char_u *)&p_ur, PV_NONE, 2756 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT}, 2757 {"updatecount", "uc", P_NUM|P_VI_DEF, 2758 (char_u *)&p_uc, PV_NONE, 2759 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT}, 2760 {"updatetime", "ut", P_NUM|P_VI_DEF, 2761 (char_u *)&p_ut, PV_NONE, 2762 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT}, 2763 {"verbose", "vbs", P_NUM|P_VI_DEF, 2764 (char_u *)&p_verbose, PV_NONE, 2765 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2766 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2767 (char_u *)&p_vfile, PV_NONE, 2768 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2769 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2770 #ifdef FEAT_SESSION 2771 (char_u *)&p_vdir, PV_NONE, 2772 {(char_u *)DFLT_VDIR, (char_u *)0L} 2773 #else 2774 (char_u *)NULL, PV_NONE, 2775 {(char_u *)0L, (char_u *)0L} 2776 #endif 2777 SCRIPTID_INIT}, 2778 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2779 #ifdef FEAT_SESSION 2780 (char_u *)&p_vop, PV_NONE, 2781 {(char_u *)"folds,options,cursor", (char_u *)0L} 2782 #else 2783 (char_u *)NULL, PV_NONE, 2784 {(char_u *)0L, (char_u *)0L} 2785 #endif 2786 SCRIPTID_INIT}, 2787 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE, 2788 #ifdef FEAT_VIMINFO 2789 (char_u *)&p_viminfo, PV_NONE, 2790 #if defined(MSDOS) || defined(MSWIN) 2791 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"} 2792 #else 2793 # ifdef AMIGA 2794 {(char_u *)"", 2795 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"} 2796 # else 2797 {(char_u *)"", (char_u *)"'100,<50,s10,h"} 2798 # endif 2799 #endif 2800 #else 2801 (char_u *)NULL, PV_NONE, 2802 {(char_u *)0L, (char_u *)0L} 2803 #endif 2804 SCRIPTID_INIT}, 2805 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF 2806 |P_VIM|P_CURSWANT, 2807 #ifdef FEAT_VIRTUALEDIT 2808 (char_u *)&p_ve, PV_NONE, 2809 {(char_u *)"", (char_u *)""} 2810 #else 2811 (char_u *)NULL, PV_NONE, 2812 {(char_u *)0L, (char_u *)0L} 2813 #endif 2814 SCRIPTID_INIT}, 2815 {"visualbell", "vb", P_BOOL|P_VI_DEF, 2816 (char_u *)&p_vb, PV_NONE, 2817 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2818 {"w300", NULL, P_NUM|P_VI_DEF, 2819 (char_u *)NULL, PV_NONE, 2820 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2821 {"w1200", NULL, P_NUM|P_VI_DEF, 2822 (char_u *)NULL, PV_NONE, 2823 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2824 {"w9600", NULL, P_NUM|P_VI_DEF, 2825 (char_u *)NULL, PV_NONE, 2826 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2827 {"warn", NULL, P_BOOL|P_VI_DEF, 2828 (char_u *)&p_warn, PV_NONE, 2829 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2830 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR, 2831 (char_u *)&p_wiv, PV_NONE, 2832 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2833 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST, 2834 (char_u *)&p_ww, PV_NONE, 2835 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT}, 2836 {"wildchar", "wc", P_NUM|P_VIM, 2837 (char_u *)&p_wc, PV_NONE, 2838 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB} 2839 SCRIPTID_INIT}, 2840 {"wildcharm", "wcm", P_NUM|P_VI_DEF, 2841 (char_u *)&p_wcm, PV_NONE, 2842 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2843 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2844 #ifdef FEAT_WILDIGN 2845 (char_u *)&p_wig, PV_NONE, 2846 #else 2847 (char_u *)NULL, PV_NONE, 2848 #endif 2849 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2850 {"wildignorecase", "wic", P_BOOL|P_VI_DEF, 2851 (char_u *)&p_wic, PV_NONE, 2852 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2853 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF, 2854 #ifdef FEAT_WILDMENU 2855 (char_u *)&p_wmnu, PV_NONE, 2856 #else 2857 (char_u *)NULL, PV_NONE, 2858 #endif 2859 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2860 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2861 (char_u *)&p_wim, PV_NONE, 2862 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT}, 2863 {"wildoptions", "wop", P_STRING|P_VI_DEF, 2864 #ifdef FEAT_CMDL_COMPL 2865 (char_u *)&p_wop, PV_NONE, 2866 {(char_u *)"", (char_u *)0L} 2867 #else 2868 (char_u *)NULL, PV_NONE, 2869 {(char_u *)NULL, (char_u *)0L} 2870 #endif 2871 SCRIPTID_INIT}, 2872 {"winaltkeys", "wak", P_STRING|P_VI_DEF, 2873 #ifdef FEAT_WAK 2874 (char_u *)&p_wak, PV_NONE, 2875 {(char_u *)"menu", (char_u *)0L} 2876 #else 2877 (char_u *)NULL, PV_NONE, 2878 {(char_u *)NULL, (char_u *)0L} 2879 #endif 2880 SCRIPTID_INIT}, 2881 {"window", "wi", P_NUM|P_VI_DEF, 2882 (char_u *)&p_window, PV_NONE, 2883 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2884 {"winheight", "wh", P_NUM|P_VI_DEF, 2885 #ifdef FEAT_WINDOWS 2886 (char_u *)&p_wh, PV_NONE, 2887 #else 2888 (char_u *)NULL, PV_NONE, 2889 #endif 2890 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2891 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, 2892 #ifdef FEAT_WINDOWS 2893 (char_u *)VAR_WIN, PV_WFH, 2894 #else 2895 (char_u *)NULL, PV_NONE, 2896 #endif 2897 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2898 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT, 2899 #ifdef FEAT_VERTSPLIT 2900 (char_u *)VAR_WIN, PV_WFW, 2901 #else 2902 (char_u *)NULL, PV_NONE, 2903 #endif 2904 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2905 {"winminheight", "wmh", P_NUM|P_VI_DEF, 2906 #ifdef FEAT_WINDOWS 2907 (char_u *)&p_wmh, PV_NONE, 2908 #else 2909 (char_u *)NULL, PV_NONE, 2910 #endif 2911 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2912 {"winminwidth", "wmw", P_NUM|P_VI_DEF, 2913 #ifdef FEAT_VERTSPLIT 2914 (char_u *)&p_wmw, PV_NONE, 2915 #else 2916 (char_u *)NULL, PV_NONE, 2917 #endif 2918 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2919 {"winwidth", "wiw", P_NUM|P_VI_DEF, 2920 #ifdef FEAT_VERTSPLIT 2921 (char_u *)&p_wiw, PV_NONE, 2922 #else 2923 (char_u *)NULL, PV_NONE, 2924 #endif 2925 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, 2926 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN, 2927 (char_u *)VAR_WIN, PV_WRAP, 2928 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2929 {"wrapmargin", "wm", P_NUM|P_VI_DEF, 2930 (char_u *)&p_wm, PV_WM, 2931 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2932 {"wrapscan", "ws", P_BOOL|P_VI_DEF, 2933 (char_u *)&p_ws, PV_NONE, 2934 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2935 {"write", NULL, P_BOOL|P_VI_DEF, 2936 (char_u *)&p_write, PV_NONE, 2937 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2938 {"writeany", "wa", P_BOOL|P_VI_DEF, 2939 (char_u *)&p_wa, PV_NONE, 2940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2941 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM, 2942 (char_u *)&p_wb, PV_NONE, 2943 { 2944 #ifdef FEAT_WRITEBACKUP 2945 (char_u *)TRUE, 2946 #else 2947 (char_u *)FALSE, 2948 #endif 2949 (char_u *)0L} SCRIPTID_INIT}, 2950 {"writedelay", "wd", P_NUM|P_VI_DEF, 2951 (char_u *)&p_wd, PV_NONE, 2952 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2953 2954 /* terminal output codes */ 2955 #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \ 2956 (char_u *)&vvv, PV_NONE, \ 2957 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2958 2959 p_term("t_AB", T_CAB) 2960 p_term("t_AF", T_CAF) 2961 p_term("t_AL", T_CAL) 2962 p_term("t_al", T_AL) 2963 p_term("t_bc", T_BC) 2964 p_term("t_cd", T_CD) 2965 p_term("t_ce", T_CE) 2966 p_term("t_cl", T_CL) 2967 p_term("t_cm", T_CM) 2968 p_term("t_Ce", T_UCE) 2969 p_term("t_Co", T_CCO) 2970 p_term("t_CS", T_CCS) 2971 p_term("t_Cs", T_UCS) 2972 p_term("t_cs", T_CS) 2973 #ifdef FEAT_VERTSPLIT 2974 p_term("t_CV", T_CSV) 2975 #endif 2976 p_term("t_da", T_DA) 2977 p_term("t_db", T_DB) 2978 p_term("t_DL", T_CDL) 2979 p_term("t_dl", T_DL) 2980 p_term("t_EI", T_CEI) 2981 p_term("t_fs", T_FS) 2982 p_term("t_IE", T_CIE) 2983 p_term("t_IS", T_CIS) 2984 p_term("t_ke", T_KE) 2985 p_term("t_ks", T_KS) 2986 p_term("t_le", T_LE) 2987 p_term("t_mb", T_MB) 2988 p_term("t_md", T_MD) 2989 p_term("t_me", T_ME) 2990 p_term("t_mr", T_MR) 2991 p_term("t_ms", T_MS) 2992 p_term("t_nd", T_ND) 2993 p_term("t_op", T_OP) 2994 p_term("t_RB", T_RBG) 2995 p_term("t_RI", T_CRI) 2996 p_term("t_RV", T_CRV) 2997 p_term("t_Sb", T_CSB) 2998 p_term("t_se", T_SE) 2999 p_term("t_Sf", T_CSF) 3000 p_term("t_SI", T_CSI) 3001 p_term("t_so", T_SO) 3002 p_term("t_SR", T_CSR) 3003 p_term("t_sr", T_SR) 3004 p_term("t_te", T_TE) 3005 p_term("t_ti", T_TI) 3006 p_term("t_ts", T_TS) 3007 p_term("t_u7", T_U7) 3008 p_term("t_ue", T_UE) 3009 p_term("t_us", T_US) 3010 p_term("t_ut", T_UT) 3011 p_term("t_vb", T_VB) 3012 p_term("t_ve", T_VE) 3013 p_term("t_vi", T_VI) 3014 p_term("t_vs", T_VS) 3015 p_term("t_WP", T_CWP) 3016 p_term("t_WS", T_CWS) 3017 p_term("t_xn", T_XN) 3018 p_term("t_xs", T_XS) 3019 p_term("t_ZH", T_CZH) 3020 p_term("t_ZR", T_CZR) 3021 3022 /* terminal key codes are not in here */ 3023 3024 /* end marker */ 3025 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT} 3026 }; 3027 3028 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption)) 3029 3030 #ifdef FEAT_MBYTE 3031 static char *(p_ambw_values[]) = {"single", "double", NULL}; 3032 #endif 3033 static char *(p_bg_values[]) = {"light", "dark", NULL}; 3034 static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL}; 3035 static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL}; 3036 #ifdef FEAT_CRYPT 3037 static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL}; 3038 #endif 3039 #ifdef FEAT_CMDL_COMPL 3040 static char *(p_wop_values[]) = {"tagfile", NULL}; 3041 #endif 3042 #ifdef FEAT_WAK 3043 static char *(p_wak_values[]) = {"yes", "menu", "no", NULL}; 3044 #endif 3045 static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL}; 3046 static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL}; 3047 static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL}; 3048 static char *(p_km_values[]) = {"startsel", "stopsel", NULL}; 3049 #ifdef FEAT_BROWSE 3050 static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL}; 3051 #endif 3052 #ifdef FEAT_SCROLLBIND 3053 static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; 3054 #endif 3055 static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL}; 3056 #ifdef FEAT_VERTSPLIT 3057 static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; 3058 #endif 3059 #if defined(FEAT_QUICKFIX) 3060 # ifdef FEAT_AUTOCMD 3061 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL}; 3062 # else 3063 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL}; 3064 # endif 3065 static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; 3066 #endif 3067 static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; 3068 #ifdef FEAT_FOLDING 3069 static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", 3070 # ifdef FEAT_DIFF 3071 "diff", 3072 # endif 3073 NULL}; 3074 static char *(p_fcl_values[]) = {"all", NULL}; 3075 #endif 3076 #ifdef FEAT_INS_EXPAND 3077 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL}; 3078 #endif 3079 3080 static void set_option_default __ARGS((int, int opt_flags, int compatible)); 3081 static void set_options_default __ARGS((int opt_flags)); 3082 static char_u *term_bg_default __ARGS((void)); 3083 static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value)); 3084 static char_u *illegal_char __ARGS((char_u *, int)); 3085 static int string_to_key __ARGS((char_u *arg)); 3086 #ifdef FEAT_CMDWIN 3087 static char_u *check_cedit __ARGS((void)); 3088 #endif 3089 #ifdef FEAT_TITLE 3090 static void did_set_title __ARGS((int icon)); 3091 #endif 3092 static char_u *option_expand __ARGS((int opt_idx, char_u *val)); 3093 static void didset_options __ARGS((void)); 3094 static void didset_options2 __ARGS((void)); 3095 static void check_string_option __ARGS((char_u **pp)); 3096 #if defined(FEAT_EVAL) || defined(PROTO) 3097 static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags)); 3098 #else 3099 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) 3100 #endif 3101 static void set_string_option_global __ARGS((int opt_idx, char_u **varp)); 3102 static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags)); 3103 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)); 3104 static char_u *set_chars_option __ARGS((char_u **varp)); 3105 #ifdef FEAT_SYN_HL 3106 static int int_cmp __ARGS((const void *a, const void *b)); 3107 #endif 3108 #ifdef FEAT_CLIPBOARD 3109 static char_u *check_clipboard_option __ARGS((void)); 3110 #endif 3111 #ifdef FEAT_SPELL 3112 static char_u *did_set_spell_option __ARGS((int is_spellfile)); 3113 static char_u *compile_cap_prog __ARGS((synblock_T *synblock)); 3114 #endif 3115 #ifdef FEAT_EVAL 3116 static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id)); 3117 #endif 3118 static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags)); 3119 static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags)); 3120 static void check_redraw __ARGS((long_u flags)); 3121 static int findoption __ARGS((char_u *)); 3122 static int find_key_option __ARGS((char_u *)); 3123 static void showoptions __ARGS((int all, int opt_flags)); 3124 static int optval_default __ARGS((struct vimoption *, char_u *varp)); 3125 static void showoneopt __ARGS((struct vimoption *, int opt_flags)); 3126 static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand)); 3127 static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep)); 3128 static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value)); 3129 static int istermoption __ARGS((struct vimoption *)); 3130 static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags)); 3131 static char_u *get_varp __ARGS((struct vimoption *)); 3132 static void option_value2string __ARGS((struct vimoption *, int opt_flags)); 3133 static void check_winopt __ARGS((winopt_T *wop)); 3134 static int wc_use_keyname __ARGS((char_u *varp, long *wcp)); 3135 #ifdef FEAT_LANGMAP 3136 static void langmap_init __ARGS((void)); 3137 static void langmap_set __ARGS((void)); 3138 #endif 3139 static void paste_option_changed __ARGS((void)); 3140 static void compatible_set __ARGS((void)); 3141 #ifdef FEAT_LINEBREAK 3142 static void fill_breakat_flags __ARGS((void)); 3143 #endif 3144 static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list)); 3145 static int check_opt_strings __ARGS((char_u *val, char **values, int)); 3146 static int check_opt_wim __ARGS((void)); 3147 #ifdef FEAT_LINEBREAK 3148 static int briopt_check __ARGS((win_T *wp)); 3149 #endif 3150 3151 /* 3152 * Initialize the options, first part. 3153 * 3154 * Called only once from main(), just after creating the first buffer. 3155 */ 3156 void 3157 set_init_1() 3158 { 3159 char_u *p; 3160 int opt_idx; 3161 long_u n; 3162 3163 #ifdef FEAT_LANGMAP 3164 langmap_init(); 3165 #endif 3166 3167 /* Be Vi compatible by default */ 3168 p_cp = TRUE; 3169 3170 /* Use POSIX compatibility when $VIM_POSIX is set. */ 3171 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) 3172 { 3173 set_string_default("cpo", (char_u *)CPO_ALL); 3174 set_string_default("shm", (char_u *)"A"); 3175 } 3176 3177 /* 3178 * Find default value for 'shell' option. 3179 * Don't use it if it is empty. 3180 */ 3181 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) 3182 #if defined(MSDOS) || defined(MSWIN) 3183 # ifdef __EMX__ 3184 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL) 3185 # endif 3186 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) 3187 # ifdef WIN3264 3188 || ((p = default_shell()) != NULL && *p != NUL) 3189 # endif 3190 #endif 3191 ) 3192 set_string_default("sh", p); 3193 3194 #ifdef FEAT_WILDIGN 3195 /* 3196 * Set the default for 'backupskip' to include environment variables for 3197 * temp files. 3198 */ 3199 { 3200 # ifdef UNIX 3201 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; 3202 # else 3203 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; 3204 # endif 3205 int len; 3206 garray_T ga; 3207 int mustfree; 3208 3209 ga_init2(&ga, 1, 100); 3210 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) 3211 { 3212 mustfree = FALSE; 3213 # ifdef UNIX 3214 if (*names[n] == NUL) 3215 p = (char_u *)"/tmp"; 3216 else 3217 # endif 3218 p = vim_getenv((char_u *)names[n], &mustfree); 3219 if (p != NULL && *p != NUL) 3220 { 3221 /* First time count the NUL, otherwise count the ','. */ 3222 len = (int)STRLEN(p) + 3; 3223 if (ga_grow(&ga, len) == OK) 3224 { 3225 if (ga.ga_len > 0) 3226 STRCAT(ga.ga_data, ","); 3227 STRCAT(ga.ga_data, p); 3228 add_pathsep(ga.ga_data); 3229 STRCAT(ga.ga_data, "*"); 3230 ga.ga_len += len; 3231 } 3232 } 3233 if (mustfree) 3234 vim_free(p); 3235 } 3236 if (ga.ga_data != NULL) 3237 { 3238 set_string_default("bsk", ga.ga_data); 3239 vim_free(ga.ga_data); 3240 } 3241 } 3242 #endif 3243 3244 /* 3245 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory 3246 */ 3247 opt_idx = findoption((char_u *)"maxmemtot"); 3248 if (opt_idx >= 0) 3249 { 3250 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) 3251 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) 3252 #endif 3253 { 3254 #ifdef HAVE_AVAIL_MEM 3255 /* Use amount of memory available at this moment. */ 3256 n = (mch_avail_mem(FALSE) >> 1); 3257 #else 3258 # ifdef HAVE_TOTAL_MEM 3259 /* Use amount of memory available to Vim. */ 3260 n = (mch_total_mem(FALSE) >> 1); 3261 # else 3262 n = (0x7fffffff >> 11); 3263 # endif 3264 #endif 3265 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; 3266 opt_idx = findoption((char_u *)"maxmem"); 3267 if (opt_idx >= 0) 3268 { 3269 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) 3270 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n 3271 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) 3272 #endif 3273 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; 3274 } 3275 } 3276 } 3277 3278 #ifdef FEAT_GUI_W32 3279 /* force 'shortname' for Win32s */ 3280 if (gui_is_win32s()) 3281 { 3282 opt_idx = findoption((char_u *)"shortname"); 3283 if (opt_idx >= 0) 3284 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE; 3285 } 3286 #endif 3287 3288 #ifdef FEAT_SEARCHPATH 3289 { 3290 char_u *cdpath; 3291 char_u *buf; 3292 int i; 3293 int j; 3294 int mustfree = FALSE; 3295 3296 /* Initialize the 'cdpath' option's default value. */ 3297 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); 3298 if (cdpath != NULL) 3299 { 3300 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2)); 3301 if (buf != NULL) 3302 { 3303 buf[0] = ','; /* start with ",", current dir first */ 3304 j = 1; 3305 for (i = 0; cdpath[i] != NUL; ++i) 3306 { 3307 if (vim_ispathlistsep(cdpath[i])) 3308 buf[j++] = ','; 3309 else 3310 { 3311 if (cdpath[i] == ' ' || cdpath[i] == ',') 3312 buf[j++] = '\\'; 3313 buf[j++] = cdpath[i]; 3314 } 3315 } 3316 buf[j] = NUL; 3317 opt_idx = findoption((char_u *)"cdpath"); 3318 if (opt_idx >= 0) 3319 { 3320 options[opt_idx].def_val[VI_DEFAULT] = buf; 3321 options[opt_idx].flags |= P_DEF_ALLOCED; 3322 } 3323 else 3324 vim_free(buf); /* cannot happen */ 3325 } 3326 if (mustfree) 3327 vim_free(cdpath); 3328 } 3329 } 3330 #endif 3331 3332 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) 3333 /* Set print encoding on platforms that don't default to latin1 */ 3334 set_string_default("penc", 3335 # if defined(MSWIN) 3336 (char_u *)"cp1252" 3337 # else 3338 # ifdef VMS 3339 (char_u *)"dec-mcs" 3340 # else 3341 # ifdef EBCDIC 3342 (char_u *)"ebcdic-uk" 3343 # else 3344 # ifdef MAC 3345 (char_u *)"mac-roman" 3346 # else /* HPUX */ 3347 (char_u *)"hp-roman8" 3348 # endif 3349 # endif 3350 # endif 3351 # endif 3352 ); 3353 #endif 3354 3355 #ifdef FEAT_POSTSCRIPT 3356 /* 'printexpr' must be allocated to be able to evaluate it. */ 3357 set_string_default("pexpr", 3358 # if defined(MSWIN) || defined(MSDOS) 3359 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" 3360 # else 3361 # ifdef VMS 3362 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" 3363 3364 # else 3365 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" 3366 # endif 3367 # endif 3368 ); 3369 #endif 3370 3371 /* 3372 * Set all the options (except the terminal options) to their default 3373 * value. Also set the global value for local options. 3374 */ 3375 set_options_default(0); 3376 3377 #ifdef FEAT_GUI 3378 if (found_reverse_arg) 3379 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); 3380 #endif 3381 3382 curbuf->b_p_initialized = TRUE; 3383 curbuf->b_p_ar = -1; /* no local 'autoread' value */ 3384 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; 3385 check_buf_options(curbuf); 3386 check_win_options(curwin); 3387 check_options(); 3388 3389 /* Must be before option_expand(), because that one needs vim_isIDc() */ 3390 didset_options(); 3391 3392 #ifdef FEAT_SPELL 3393 /* Use the current chartab for the generic chartab. This is not in 3394 * didset_options() because it only depends on 'encoding'. */ 3395 init_spell_chartab(); 3396 #endif 3397 3398 /* 3399 * Expand environment variables and things like "~" for the defaults. 3400 * If option_expand() returns non-NULL the variable is expanded. This can 3401 * only happen for non-indirect options. 3402 * Also set the default to the expanded value, so ":set" does not list 3403 * them. 3404 * Don't set the P_ALLOCED flag, because we don't want to free the 3405 * default. 3406 */ 3407 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 3408 { 3409 if ((options[opt_idx].flags & P_GETTEXT) 3410 && options[opt_idx].var != NULL) 3411 p = (char_u *)_(*(char **)options[opt_idx].var); 3412 else 3413 p = option_expand(opt_idx, NULL); 3414 if (p != NULL && (p = vim_strsave(p)) != NULL) 3415 { 3416 *(char_u **)options[opt_idx].var = p; 3417 /* VIMEXP 3418 * Defaults for all expanded options are currently the same for Vi 3419 * and Vim. When this changes, add some code here! Also need to 3420 * split P_DEF_ALLOCED in two. 3421 */ 3422 if (options[opt_idx].flags & P_DEF_ALLOCED) 3423 vim_free(options[opt_idx].def_val[VI_DEFAULT]); 3424 options[opt_idx].def_val[VI_DEFAULT] = p; 3425 options[opt_idx].flags |= P_DEF_ALLOCED; 3426 } 3427 } 3428 3429 save_file_ff(curbuf); /* Buffer is unchanged */ 3430 3431 #if defined(FEAT_ARABIC) 3432 /* Detect use of mlterm. 3433 * Mlterm is a terminal emulator akin to xterm that has some special 3434 * abilities (bidi namely). 3435 * NOTE: mlterm's author is being asked to 'set' a variable 3436 * instead of an environment variable due to inheritance. 3437 */ 3438 if (mch_getenv((char_u *)"MLTERM") != NULL) 3439 set_option_value((char_u *)"tbidi", 1L, NULL, 0); 3440 #endif 3441 3442 didset_options2(); 3443 3444 #ifdef FEAT_MBYTE 3445 # if defined(WIN3264) && defined(FEAT_GETTEXT) 3446 /* 3447 * If $LANG isn't set, try to get a good value for it. This makes the 3448 * right language be used automatically. Don't do this for English. 3449 */ 3450 if (mch_getenv((char_u *)"LANG") == NULL) 3451 { 3452 char buf[20]; 3453 3454 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. 3455 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use 3456 * only the first two. */ 3457 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, 3458 (LPTSTR)buf, 20); 3459 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) 3460 { 3461 /* There are a few exceptions (probably more) */ 3462 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) 3463 STRCPY(buf, "zh_TW"); 3464 else if (STRNICMP(buf, "chs", 3) == 0 3465 || STRNICMP(buf, "zhc", 3) == 0) 3466 STRCPY(buf, "zh_CN"); 3467 else if (STRNICMP(buf, "jp", 2) == 0) 3468 STRCPY(buf, "ja"); 3469 else 3470 buf[2] = NUL; /* truncate to two-letter code */ 3471 vim_setenv("LANG", buf); 3472 } 3473 } 3474 # else 3475 # ifdef MACOS_CONVERT 3476 /* Moved to os_mac_conv.c to avoid dependency problems. */ 3477 mac_lang_init(); 3478 # endif 3479 # endif 3480 3481 /* enc_locale() will try to find the encoding of the current locale. */ 3482 p = enc_locale(); 3483 if (p != NULL) 3484 { 3485 char_u *save_enc; 3486 3487 /* Try setting 'encoding' and check if the value is valid. 3488 * If not, go back to the default "latin1". */ 3489 save_enc = p_enc; 3490 p_enc = p; 3491 if (STRCMP(p_enc, "gb18030") == 0) 3492 { 3493 /* We don't support "gb18030", but "cp936" is a good substitute 3494 * for practical purposes, thus use that. It's not an alias to 3495 * still support conversion between gb18030 and utf-8. */ 3496 p_enc = vim_strsave((char_u *)"cp936"); 3497 vim_free(p); 3498 } 3499 if (mb_init() == NULL) 3500 { 3501 opt_idx = findoption((char_u *)"encoding"); 3502 if (opt_idx >= 0) 3503 { 3504 options[opt_idx].def_val[VI_DEFAULT] = p_enc; 3505 options[opt_idx].flags |= P_DEF_ALLOCED; 3506 } 3507 3508 #if defined(MSDOS) || defined(MSWIN) || defined(MACOS) \ 3509 || defined(VMS) 3510 if (STRCMP(p_enc, "latin1") == 0 3511 # ifdef FEAT_MBYTE 3512 || enc_utf8 3513 # endif 3514 ) 3515 { 3516 /* Adjust the default for 'isprint' and 'iskeyword' to match 3517 * latin1. Also set the defaults for when 'nocompatible' is 3518 * set. */ 3519 set_string_option_direct((char_u *)"isp", -1, 3520 ISP_LATIN1, OPT_FREE, SID_NONE); 3521 set_string_option_direct((char_u *)"isk", -1, 3522 ISK_LATIN1, OPT_FREE, SID_NONE); 3523 opt_idx = findoption((char_u *)"isp"); 3524 if (opt_idx >= 0) 3525 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; 3526 opt_idx = findoption((char_u *)"isk"); 3527 if (opt_idx >= 0) 3528 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; 3529 (void)init_chartab(); 3530 } 3531 #endif 3532 3533 # if defined(WIN3264) && !defined(FEAT_GUI) 3534 /* Win32 console: When GetACP() returns a different value from 3535 * GetConsoleCP() set 'termencoding'. */ 3536 if (GetACP() != GetConsoleCP()) 3537 { 3538 char buf[50]; 3539 3540 sprintf(buf, "cp%ld", (long)GetConsoleCP()); 3541 p_tenc = vim_strsave((char_u *)buf); 3542 if (p_tenc != NULL) 3543 { 3544 opt_idx = findoption((char_u *)"termencoding"); 3545 if (opt_idx >= 0) 3546 { 3547 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; 3548 options[opt_idx].flags |= P_DEF_ALLOCED; 3549 } 3550 convert_setup(&input_conv, p_tenc, p_enc); 3551 convert_setup(&output_conv, p_enc, p_tenc); 3552 } 3553 else 3554 p_tenc = empty_option; 3555 } 3556 # endif 3557 # if defined(WIN3264) && defined(FEAT_MBYTE) 3558 /* $HOME may have characters in active code page. */ 3559 init_homedir(); 3560 # endif 3561 } 3562 else 3563 { 3564 vim_free(p_enc); 3565 p_enc = save_enc; 3566 } 3567 } 3568 #endif 3569 3570 #ifdef FEAT_MULTI_LANG 3571 /* Set the default for 'helplang'. */ 3572 set_helplang_default(get_mess_lang()); 3573 #endif 3574 } 3575 3576 /* 3577 * Set an option to its default value. 3578 * This does not take care of side effects! 3579 */ 3580 static void 3581 set_option_default(opt_idx, opt_flags, compatible) 3582 int opt_idx; 3583 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ 3584 int compatible; /* use Vi default value */ 3585 { 3586 char_u *varp; /* pointer to variable for current option */ 3587 int dvi; /* index in def_val[] */ 3588 long_u flags; 3589 long_u *flagsp; 3590 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; 3591 3592 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); 3593 flags = options[opt_idx].flags; 3594 if (varp != NULL) /* skip hidden option, nothing to do for it */ 3595 { 3596 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; 3597 if (flags & P_STRING) 3598 { 3599 /* Use set_string_option_direct() for local options to handle 3600 * freeing and allocating the value. */ 3601 if (options[opt_idx].indir != PV_NONE) 3602 set_string_option_direct(NULL, opt_idx, 3603 options[opt_idx].def_val[dvi], opt_flags, 0); 3604 else 3605 { 3606 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) 3607 free_string_option(*(char_u **)(varp)); 3608 *(char_u **)varp = options[opt_idx].def_val[dvi]; 3609 options[opt_idx].flags &= ~P_ALLOCED; 3610 } 3611 } 3612 else if (flags & P_NUM) 3613 { 3614 if (options[opt_idx].indir == PV_SCROLL) 3615 win_comp_scroll(curwin); 3616 else 3617 { 3618 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi]; 3619 /* May also set global value for local option. */ 3620 if (both) 3621 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = 3622 *(long *)varp; 3623 } 3624 } 3625 else /* P_BOOL */ 3626 { 3627 /* the cast to long is required for Manx C, long_i is needed for 3628 * MSVC */ 3629 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; 3630 #ifdef UNIX 3631 /* 'modeline' defaults to off for root */ 3632 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) 3633 *(int *)varp = FALSE; 3634 #endif 3635 /* May also set global value for local option. */ 3636 if (both) 3637 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = 3638 *(int *)varp; 3639 } 3640 3641 /* The default value is not insecure. */ 3642 flagsp = insecure_flag(opt_idx, opt_flags); 3643 *flagsp = *flagsp & ~P_INSECURE; 3644 } 3645 3646 #ifdef FEAT_EVAL 3647 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 3648 #endif 3649 } 3650 3651 /* 3652 * Set all options (except terminal options) to their default value. 3653 * When "opt_flags" is non-zero skip 'encoding'. 3654 */ 3655 static void 3656 set_options_default(opt_flags) 3657 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ 3658 { 3659 int i; 3660 #ifdef FEAT_WINDOWS 3661 win_T *wp; 3662 tabpage_T *tp; 3663 #endif 3664 3665 for (i = 0; !istermoption(&options[i]); i++) 3666 if (!(options[i].flags & P_NODEFAULT) 3667 #if defined(FEAT_MBYTE) || defined(FEAT_CRYPT) 3668 && (opt_flags == 0 3669 || (TRUE 3670 # if defined(FEAT_MBYTE) 3671 && options[i].var != (char_u *)&p_enc 3672 # endif 3673 # if defined(FEAT_CRYPT) 3674 && options[i].var != (char_u *)&p_cm 3675 && options[i].var != (char_u *)&p_key 3676 # endif 3677 )) 3678 #endif 3679 ) 3680 set_option_default(i, opt_flags, p_cp); 3681 3682 #ifdef FEAT_WINDOWS 3683 /* The 'scroll' option must be computed for all windows. */ 3684 FOR_ALL_TAB_WINDOWS(tp, wp) 3685 win_comp_scroll(wp); 3686 #else 3687 win_comp_scroll(curwin); 3688 #endif 3689 #ifdef FEAT_CINDENT 3690 parse_cino(curbuf); 3691 #endif 3692 } 3693 3694 /* 3695 * Set the Vi-default value of a string option. 3696 * Used for 'sh', 'backupskip' and 'term'. 3697 */ 3698 void 3699 set_string_default(name, val) 3700 char *name; 3701 char_u *val; 3702 { 3703 char_u *p; 3704 int opt_idx; 3705 3706 p = vim_strsave(val); 3707 if (p != NULL) /* we don't want a NULL */ 3708 { 3709 opt_idx = findoption((char_u *)name); 3710 if (opt_idx >= 0) 3711 { 3712 if (options[opt_idx].flags & P_DEF_ALLOCED) 3713 vim_free(options[opt_idx].def_val[VI_DEFAULT]); 3714 options[opt_idx].def_val[VI_DEFAULT] = p; 3715 options[opt_idx].flags |= P_DEF_ALLOCED; 3716 } 3717 } 3718 } 3719 3720 /* 3721 * Set the Vi-default value of a number option. 3722 * Used for 'lines' and 'columns'. 3723 */ 3724 void 3725 set_number_default(name, val) 3726 char *name; 3727 long val; 3728 { 3729 int opt_idx; 3730 3731 opt_idx = findoption((char_u *)name); 3732 if (opt_idx >= 0) 3733 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 3734 } 3735 3736 #if defined(EXITFREE) || defined(PROTO) 3737 /* 3738 * Free all options. 3739 */ 3740 void 3741 free_all_options() 3742 { 3743 int i; 3744 3745 for (i = 0; !istermoption(&options[i]); i++) 3746 { 3747 if (options[i].indir == PV_NONE) 3748 { 3749 /* global option: free value and default value. */ 3750 if (options[i].flags & P_ALLOCED && options[i].var != NULL) 3751 free_string_option(*(char_u **)options[i].var); 3752 if (options[i].flags & P_DEF_ALLOCED) 3753 free_string_option(options[i].def_val[VI_DEFAULT]); 3754 } 3755 else if (options[i].var != VAR_WIN 3756 && (options[i].flags & P_STRING)) 3757 /* buffer-local option: free global value */ 3758 free_string_option(*(char_u **)options[i].var); 3759 } 3760 } 3761 #endif 3762 3763 3764 /* 3765 * Initialize the options, part two: After getting Rows and Columns and 3766 * setting 'term'. 3767 */ 3768 void 3769 set_init_2() 3770 { 3771 int idx; 3772 3773 /* 3774 * 'scroll' defaults to half the window height. Note that this default is 3775 * wrong when the window height changes. 3776 */ 3777 set_number_default("scroll", (long)((long_u)Rows >> 1)); 3778 idx = findoption((char_u *)"scroll"); 3779 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) 3780 set_option_default(idx, OPT_LOCAL, p_cp); 3781 comp_col(); 3782 3783 /* 3784 * 'window' is only for backwards compatibility with Vi. 3785 * Default is Rows - 1. 3786 */ 3787 if (!option_was_set((char_u *)"window")) 3788 p_window = Rows - 1; 3789 set_number_default("window", Rows - 1); 3790 3791 /* For DOS console the default is always black. */ 3792 #if !((defined(MSDOS) || defined(WIN3264)) && !defined(FEAT_GUI)) 3793 /* 3794 * If 'background' wasn't set by the user, try guessing the value, 3795 * depending on the terminal name. Only need to check for terminals 3796 * with a dark background, that can handle color. 3797 */ 3798 idx = findoption((char_u *)"bg"); 3799 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) 3800 && *term_bg_default() == 'd') 3801 { 3802 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); 3803 /* don't mark it as set, when starting the GUI it may be 3804 * changed again */ 3805 options[idx].flags &= ~P_WAS_SET; 3806 } 3807 #endif 3808 3809 #ifdef CURSOR_SHAPE 3810 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ 3811 #endif 3812 #ifdef FEAT_MOUSESHAPE 3813 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ 3814 #endif 3815 #ifdef FEAT_PRINTER 3816 (void)parse_printoptions(); /* parse 'printoptions' default value */ 3817 #endif 3818 } 3819 3820 /* 3821 * Return "dark" or "light" depending on the kind of terminal. 3822 * This is just guessing! Recognized are: 3823 * "linux" Linux console 3824 * "screen.linux" Linux console with screen 3825 * "cygwin" Cygwin shell 3826 * "putty" Putty program 3827 * We also check the COLORFGBG environment variable, which is set by 3828 * rxvt and derivatives. This variable contains either two or three 3829 * values separated by semicolons; we want the last value in either 3830 * case. If this value is 0-6 or 8, our background is dark. 3831 */ 3832 static char_u * 3833 term_bg_default() 3834 { 3835 #if defined(MSDOS) || defined(WIN3264) 3836 /* DOS console nearly always black */ 3837 return (char_u *)"dark"; 3838 #else 3839 char_u *p; 3840 3841 if (STRCMP(T_NAME, "linux") == 0 3842 || STRCMP(T_NAME, "screen.linux") == 0 3843 || STRCMP(T_NAME, "cygwin") == 0 3844 || STRCMP(T_NAME, "putty") == 0 3845 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL 3846 && (p = vim_strrchr(p, ';')) != NULL 3847 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') 3848 && p[2] == NUL)) 3849 return (char_u *)"dark"; 3850 return (char_u *)"light"; 3851 #endif 3852 } 3853 3854 /* 3855 * Initialize the options, part three: After reading the .vimrc 3856 */ 3857 void 3858 set_init_3() 3859 { 3860 #if defined(UNIX) || defined(WIN3264) 3861 /* 3862 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. 3863 * This is done after other initializations, where 'shell' might have been 3864 * set, but only if they have not been set before. 3865 */ 3866 char_u *p; 3867 int idx_srr; 3868 int do_srr; 3869 # ifdef FEAT_QUICKFIX 3870 int idx_sp; 3871 int do_sp; 3872 # endif 3873 3874 idx_srr = findoption((char_u *)"srr"); 3875 if (idx_srr < 0) 3876 do_srr = FALSE; 3877 else 3878 do_srr = !(options[idx_srr].flags & P_WAS_SET); 3879 # ifdef FEAT_QUICKFIX 3880 idx_sp = findoption((char_u *)"sp"); 3881 if (idx_sp < 0) 3882 do_sp = FALSE; 3883 else 3884 do_sp = !(options[idx_sp].flags & P_WAS_SET); 3885 # endif 3886 p = get_isolated_shell_name(); 3887 if (p != NULL) 3888 { 3889 /* 3890 * Default for p_sp is "| tee", for p_srr is ">". 3891 * For known shells it is changed here to include stderr. 3892 */ 3893 if ( fnamecmp(p, "csh") == 0 3894 || fnamecmp(p, "tcsh") == 0 3895 # if defined(WIN3264) /* also check with .exe extension */ 3896 || fnamecmp(p, "csh.exe") == 0 3897 || fnamecmp(p, "tcsh.exe") == 0 3898 # endif 3899 ) 3900 { 3901 # if defined(FEAT_QUICKFIX) 3902 if (do_sp) 3903 { 3904 # ifdef WIN3264 3905 p_sp = (char_u *)">&"; 3906 # else 3907 p_sp = (char_u *)"|& tee"; 3908 # endif 3909 options[idx_sp].def_val[VI_DEFAULT] = p_sp; 3910 } 3911 # endif 3912 if (do_srr) 3913 { 3914 p_srr = (char_u *)">&"; 3915 options[idx_srr].def_val[VI_DEFAULT] = p_srr; 3916 } 3917 } 3918 else 3919 /* Always use bourne shell style redirection if we reach this */ 3920 if ( fnamecmp(p, "sh") == 0 3921 || fnamecmp(p, "ksh") == 0 3922 || fnamecmp(p, "mksh") == 0 3923 || fnamecmp(p, "pdksh") == 0 3924 || fnamecmp(p, "zsh") == 0 3925 || fnamecmp(p, "zsh-beta") == 0 3926 || fnamecmp(p, "bash") == 0 3927 || fnamecmp(p, "fish") == 0 3928 # ifdef WIN3264 3929 || fnamecmp(p, "cmd") == 0 3930 || fnamecmp(p, "sh.exe") == 0 3931 || fnamecmp(p, "ksh.exe") == 0 3932 || fnamecmp(p, "mksh.exe") == 0 3933 || fnamecmp(p, "pdksh.exe") == 0 3934 || fnamecmp(p, "zsh.exe") == 0 3935 || fnamecmp(p, "zsh-beta.exe") == 0 3936 || fnamecmp(p, "bash.exe") == 0 3937 || fnamecmp(p, "cmd.exe") == 0 3938 # endif 3939 ) 3940 { 3941 # if defined(FEAT_QUICKFIX) 3942 if (do_sp) 3943 { 3944 # ifdef WIN3264 3945 p_sp = (char_u *)">%s 2>&1"; 3946 # else 3947 p_sp = (char_u *)"2>&1| tee"; 3948 # endif 3949 options[idx_sp].def_val[VI_DEFAULT] = p_sp; 3950 } 3951 # endif 3952 if (do_srr) 3953 { 3954 p_srr = (char_u *)">%s 2>&1"; 3955 options[idx_srr].def_val[VI_DEFAULT] = p_srr; 3956 } 3957 } 3958 vim_free(p); 3959 } 3960 #endif 3961 3962 #if defined(MSDOS) || defined(WIN3264) 3963 /* 3964 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the 3965 * 'shell' option. 3966 * This is done after other initializations, where 'shell' might have been 3967 * set, but only if they have not been set before. Default for p_shcf is 3968 * "/c", for p_shq is "". For "sh" like shells it is changed here to 3969 * "-c" and "\"", but not for DJGPP, because it starts the shell without 3970 * command.com. And for Win32 we need to set p_sxq instead. 3971 */ 3972 if (strstr((char *)gettail(p_sh), "sh") != NULL) 3973 { 3974 int idx3; 3975 3976 idx3 = findoption((char_u *)"shcf"); 3977 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 3978 { 3979 p_shcf = (char_u *)"-c"; 3980 options[idx3].def_val[VI_DEFAULT] = p_shcf; 3981 } 3982 3983 # ifndef DJGPP 3984 # ifdef WIN3264 3985 /* Somehow Win32 requires the quotes around the redirection too */ 3986 idx3 = findoption((char_u *)"sxq"); 3987 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 3988 { 3989 p_sxq = (char_u *)"\""; 3990 options[idx3].def_val[VI_DEFAULT] = p_sxq; 3991 } 3992 # else 3993 idx3 = findoption((char_u *)"shq"); 3994 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 3995 { 3996 p_shq = (char_u *)"\""; 3997 options[idx3].def_val[VI_DEFAULT] = p_shq; 3998 } 3999 # endif 4000 # endif 4001 } 4002 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) 4003 { 4004 int idx3; 4005 4006 /* 4007 * cmd.exe on Windows will strip the first and last double quote given 4008 * on the command line, e.g. most of the time things like: 4009 * cmd /c "my path/to/echo" "my args to echo" 4010 * become: 4011 * my path/to/echo" "my args to echo 4012 * when executed. 4013 * 4014 * To avoid this, set shellxquote to surround the command in 4015 * parenthesis. This appears to make most commands work, without 4016 * breaking commands that worked previously, such as 4017 * '"path with spaces/cmd" "a&b"'. 4018 */ 4019 idx3 = findoption((char_u *)"sxq"); 4020 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 4021 { 4022 p_sxq = (char_u *)"("; 4023 options[idx3].def_val[VI_DEFAULT] = p_sxq; 4024 } 4025 4026 idx3 = findoption((char_u *)"shcf"); 4027 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 4028 { 4029 p_shcf = (char_u *)"/c"; 4030 options[idx3].def_val[VI_DEFAULT] = p_shcf; 4031 } 4032 } 4033 #endif 4034 4035 #ifdef FEAT_TITLE 4036 set_title_defaults(); 4037 #endif 4038 } 4039 4040 #if defined(FEAT_MULTI_LANG) || defined(PROTO) 4041 /* 4042 * When 'helplang' is still at its default value, set it to "lang". 4043 * Only the first two characters of "lang" are used. 4044 */ 4045 void 4046 set_helplang_default(lang) 4047 char_u *lang; 4048 { 4049 int idx; 4050 4051 if (lang == NULL || STRLEN(lang) < 2) /* safety check */ 4052 return; 4053 idx = findoption((char_u *)"hlg"); 4054 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) 4055 { 4056 if (options[idx].flags & P_ALLOCED) 4057 free_string_option(p_hlg); 4058 p_hlg = vim_strsave(lang); 4059 if (p_hlg == NULL) 4060 p_hlg = empty_option; 4061 else 4062 { 4063 /* zh_CN becomes "cn", zh_TW becomes "tw". */ 4064 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) 4065 { 4066 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); 4067 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); 4068 } 4069 p_hlg[2] = NUL; 4070 } 4071 options[idx].flags |= P_ALLOCED; 4072 } 4073 } 4074 #endif 4075 4076 #ifdef FEAT_GUI 4077 static char_u *gui_bg_default __ARGS((void)); 4078 4079 static char_u * 4080 gui_bg_default() 4081 { 4082 if (gui_get_lightness(gui.back_pixel) < 127) 4083 return (char_u *)"dark"; 4084 return (char_u *)"light"; 4085 } 4086 4087 /* 4088 * Option initializations that can only be done after opening the GUI window. 4089 */ 4090 void 4091 init_gui_options() 4092 { 4093 /* Set the 'background' option according to the lightness of the 4094 * background color, unless the user has set it already. */ 4095 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) 4096 { 4097 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); 4098 highlight_changed(); 4099 } 4100 } 4101 #endif 4102 4103 #ifdef FEAT_TITLE 4104 /* 4105 * 'title' and 'icon' only default to true if they have not been set or reset 4106 * in .vimrc and we can read the old value. 4107 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if 4108 * they can be reset. This reduces startup time when using X on a remote 4109 * machine. 4110 */ 4111 void 4112 set_title_defaults() 4113 { 4114 int idx1; 4115 long val; 4116 4117 /* 4118 * If GUI is (going to be) used, we can always set the window title and 4119 * icon name. Saves a bit of time, because the X11 display server does 4120 * not need to be contacted. 4121 */ 4122 idx1 = findoption((char_u *)"title"); 4123 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) 4124 { 4125 #ifdef FEAT_GUI 4126 if (gui.starting || gui.in_use) 4127 val = TRUE; 4128 else 4129 #endif 4130 val = mch_can_restore_title(); 4131 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 4132 p_title = val; 4133 } 4134 idx1 = findoption((char_u *)"icon"); 4135 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) 4136 { 4137 #ifdef FEAT_GUI 4138 if (gui.starting || gui.in_use) 4139 val = TRUE; 4140 else 4141 #endif 4142 val = mch_can_restore_icon(); 4143 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 4144 p_icon = val; 4145 } 4146 } 4147 #endif 4148 4149 /* 4150 * Parse 'arg' for option settings. 4151 * 4152 * 'arg' may be IObuff, but only when no errors can be present and option 4153 * does not need to be expanded with option_expand(). 4154 * "opt_flags": 4155 * 0 for ":set" 4156 * OPT_GLOBAL for ":setglobal" 4157 * OPT_LOCAL for ":setlocal" and a modeline 4158 * OPT_MODELINE for a modeline 4159 * OPT_WINONLY to only set window-local options 4160 * OPT_NOWIN to skip setting window-local options 4161 * 4162 * returns FAIL if an error is detected, OK otherwise 4163 */ 4164 int 4165 do_set(arg, opt_flags) 4166 char_u *arg; /* option string (may be written to!) */ 4167 int opt_flags; 4168 { 4169 int opt_idx; 4170 char_u *errmsg; 4171 char_u errbuf[80]; 4172 char_u *startarg; 4173 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ 4174 int nextchar; /* next non-white char after option name */ 4175 int afterchar; /* character just after option name */ 4176 int len; 4177 int i; 4178 long value; 4179 int key; 4180 long_u flags; /* flags for current option */ 4181 char_u *varp = NULL; /* pointer to variable for current option */ 4182 int did_show = FALSE; /* already showed one value */ 4183 int adding; /* "opt+=arg" */ 4184 int prepending; /* "opt^=arg" */ 4185 int removing; /* "opt-=arg" */ 4186 int cp_val = 0; 4187 char_u key_name[2]; 4188 4189 if (*arg == NUL) 4190 { 4191 showoptions(0, opt_flags); 4192 did_show = TRUE; 4193 goto theend; 4194 } 4195 4196 while (*arg != NUL) /* loop to process all options */ 4197 { 4198 errmsg = NULL; 4199 startarg = arg; /* remember for error message */ 4200 4201 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) 4202 && !(opt_flags & OPT_MODELINE)) 4203 { 4204 /* 4205 * ":set all" show all options. 4206 * ":set all&" set all options to their default value. 4207 */ 4208 arg += 3; 4209 if (*arg == '&') 4210 { 4211 ++arg; 4212 /* Only for :set command set global value of local options. */ 4213 set_options_default(OPT_FREE | opt_flags); 4214 didset_options(); 4215 didset_options2(); 4216 redraw_all_later(CLEAR); 4217 } 4218 else 4219 { 4220 showoptions(1, opt_flags); 4221 did_show = TRUE; 4222 } 4223 } 4224 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) 4225 { 4226 showoptions(2, opt_flags); 4227 show_termcodes(); 4228 did_show = TRUE; 4229 arg += 7; 4230 } 4231 else 4232 { 4233 prefix = 1; 4234 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) 4235 { 4236 prefix = 0; 4237 arg += 2; 4238 } 4239 else if (STRNCMP(arg, "inv", 3) == 0) 4240 { 4241 prefix = 2; 4242 arg += 3; 4243 } 4244 4245 /* find end of name */ 4246 key = 0; 4247 if (*arg == '<') 4248 { 4249 nextchar = 0; 4250 opt_idx = -1; 4251 /* look out for <t_>;> */ 4252 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) 4253 len = 5; 4254 else 4255 { 4256 len = 1; 4257 while (arg[len] != NUL && arg[len] != '>') 4258 ++len; 4259 } 4260 if (arg[len] != '>') 4261 { 4262 errmsg = e_invarg; 4263 goto skip; 4264 } 4265 arg[len] = NUL; /* put NUL after name */ 4266 if (arg[1] == 't' && arg[2] == '_') /* could be term code */ 4267 opt_idx = findoption(arg + 1); 4268 arg[len++] = '>'; /* restore '>' */ 4269 if (opt_idx == -1) 4270 key = find_key_option(arg + 1); 4271 } 4272 else 4273 { 4274 len = 0; 4275 /* 4276 * The two characters after "t_" may not be alphanumeric. 4277 */ 4278 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) 4279 len = 4; 4280 else 4281 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') 4282 ++len; 4283 nextchar = arg[len]; 4284 arg[len] = NUL; /* put NUL after name */ 4285 opt_idx = findoption(arg); 4286 arg[len] = nextchar; /* restore nextchar */ 4287 if (opt_idx == -1) 4288 key = find_key_option(arg); 4289 } 4290 4291 /* remember character after option name */ 4292 afterchar = arg[len]; 4293 4294 /* skip white space, allow ":set ai ?" */ 4295 while (vim_iswhite(arg[len])) 4296 ++len; 4297 4298 adding = FALSE; 4299 prepending = FALSE; 4300 removing = FALSE; 4301 if (arg[len] != NUL && arg[len + 1] == '=') 4302 { 4303 if (arg[len] == '+') 4304 { 4305 adding = TRUE; /* "+=" */ 4306 ++len; 4307 } 4308 else if (arg[len] == '^') 4309 { 4310 prepending = TRUE; /* "^=" */ 4311 ++len; 4312 } 4313 else if (arg[len] == '-') 4314 { 4315 removing = TRUE; /* "-=" */ 4316 ++len; 4317 } 4318 } 4319 nextchar = arg[len]; 4320 4321 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ 4322 { 4323 errmsg = (char_u *)N_("E518: Unknown option"); 4324 goto skip; 4325 } 4326 4327 if (opt_idx >= 0) 4328 { 4329 if (options[opt_idx].var == NULL) /* hidden option: skip */ 4330 { 4331 /* Only give an error message when requesting the value of 4332 * a hidden option, ignore setting it. */ 4333 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL 4334 && (!(options[opt_idx].flags & P_BOOL) 4335 || nextchar == '?')) 4336 errmsg = (char_u *)N_("E519: Option not supported"); 4337 goto skip; 4338 } 4339 4340 flags = options[opt_idx].flags; 4341 varp = get_varp_scope(&(options[opt_idx]), opt_flags); 4342 } 4343 else 4344 { 4345 flags = P_STRING; 4346 if (key < 0) 4347 { 4348 key_name[0] = KEY2TERMCAP0(key); 4349 key_name[1] = KEY2TERMCAP1(key); 4350 } 4351 else 4352 { 4353 key_name[0] = KS_KEY; 4354 key_name[1] = (key & 0xff); 4355 } 4356 } 4357 4358 /* Skip all options that are not window-local (used when showing 4359 * an already loaded buffer in a window). */ 4360 if ((opt_flags & OPT_WINONLY) 4361 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) 4362 goto skip; 4363 4364 /* Skip all options that are window-local (used for :vimgrep). */ 4365 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 4366 && options[opt_idx].var == VAR_WIN) 4367 goto skip; 4368 4369 /* Disallow changing some options from modelines. */ 4370 if (opt_flags & OPT_MODELINE) 4371 { 4372 if (flags & (P_SECURE | P_NO_ML)) 4373 { 4374 errmsg = (char_u *)_("E520: Not allowed in a modeline"); 4375 goto skip; 4376 } 4377 #ifdef FEAT_DIFF 4378 /* In diff mode some options are overruled. This avoids that 4379 * 'foldmethod' becomes "marker" instead of "diff" and that 4380 * "wrap" gets set. */ 4381 if (curwin->w_p_diff 4382 && opt_idx >= 0 /* shut up coverity warning */ 4383 && (options[opt_idx].indir == PV_FDM 4384 || options[opt_idx].indir == PV_WRAP)) 4385 goto skip; 4386 #endif 4387 } 4388 4389 #ifdef HAVE_SANDBOX 4390 /* Disallow changing some options in the sandbox */ 4391 if (sandbox != 0 && (flags & P_SECURE)) 4392 { 4393 errmsg = (char_u *)_(e_sandbox); 4394 goto skip; 4395 } 4396 #endif 4397 4398 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) 4399 { 4400 arg += len; 4401 cp_val = p_cp; 4402 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') 4403 { 4404 if (arg[3] == 'm') /* "opt&vim": set to Vim default */ 4405 { 4406 cp_val = FALSE; 4407 arg += 3; 4408 } 4409 else /* "opt&vi": set to Vi default */ 4410 { 4411 cp_val = TRUE; 4412 arg += 2; 4413 } 4414 } 4415 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL 4416 && arg[1] != NUL && !vim_iswhite(arg[1])) 4417 { 4418 errmsg = e_trailing; 4419 goto skip; 4420 } 4421 } 4422 4423 /* 4424 * allow '=' and ':' as MSDOS command.com allows only one 4425 * '=' character per "set" command line. grrr. (jw) 4426 */ 4427 if (nextchar == '?' 4428 || (prefix == 1 4429 && vim_strchr((char_u *)"=:&<", nextchar) == NULL 4430 && !(flags & P_BOOL))) 4431 { 4432 /* 4433 * print value 4434 */ 4435 if (did_show) 4436 msg_putchar('\n'); /* cursor below last one */ 4437 else 4438 { 4439 gotocmdline(TRUE); /* cursor at status line */ 4440 did_show = TRUE; /* remember that we did a line */ 4441 } 4442 if (opt_idx >= 0) 4443 { 4444 showoneopt(&options[opt_idx], opt_flags); 4445 #ifdef FEAT_EVAL 4446 if (p_verbose > 0) 4447 { 4448 /* Mention where the option was last set. */ 4449 if (varp == options[opt_idx].var) 4450 last_set_msg(options[opt_idx].scriptID); 4451 else if ((int)options[opt_idx].indir & PV_WIN) 4452 last_set_msg(curwin->w_p_scriptID[ 4453 (int)options[opt_idx].indir & PV_MASK]); 4454 else if ((int)options[opt_idx].indir & PV_BUF) 4455 last_set_msg(curbuf->b_p_scriptID[ 4456 (int)options[opt_idx].indir & PV_MASK]); 4457 } 4458 #endif 4459 } 4460 else 4461 { 4462 char_u *p; 4463 4464 p = find_termcode(key_name); 4465 if (p == NULL) 4466 { 4467 errmsg = (char_u *)N_("E846: Key code not set"); 4468 goto skip; 4469 } 4470 else 4471 (void)show_one_termcode(key_name, p, TRUE); 4472 } 4473 if (nextchar != '?' 4474 && nextchar != NUL && !vim_iswhite(afterchar)) 4475 errmsg = e_trailing; 4476 } 4477 else 4478 { 4479 if (flags & P_BOOL) /* boolean */ 4480 { 4481 if (nextchar == '=' || nextchar == ':') 4482 { 4483 errmsg = e_invarg; 4484 goto skip; 4485 } 4486 4487 /* 4488 * ":set opt!": invert 4489 * ":set opt&": reset to default value 4490 * ":set opt<": reset to global value 4491 */ 4492 if (nextchar == '!') 4493 value = *(int *)(varp) ^ 1; 4494 else if (nextchar == '&') 4495 value = (int)(long)(long_i)options[opt_idx].def_val[ 4496 ((flags & P_VI_DEF) || cp_val) 4497 ? VI_DEFAULT : VIM_DEFAULT]; 4498 else if (nextchar == '<') 4499 { 4500 /* For 'autoread' -1 means to use global value. */ 4501 if ((int *)varp == &curbuf->b_p_ar 4502 && opt_flags == OPT_LOCAL) 4503 value = -1; 4504 else 4505 value = *(int *)get_varp_scope(&(options[opt_idx]), 4506 OPT_GLOBAL); 4507 } 4508 else 4509 { 4510 /* 4511 * ":set invopt": invert 4512 * ":set opt" or ":set noopt": set or reset 4513 */ 4514 if (nextchar != NUL && !vim_iswhite(afterchar)) 4515 { 4516 errmsg = e_trailing; 4517 goto skip; 4518 } 4519 if (prefix == 2) /* inv */ 4520 value = *(int *)(varp) ^ 1; 4521 else 4522 value = prefix; 4523 } 4524 4525 errmsg = set_bool_option(opt_idx, varp, (int)value, 4526 opt_flags); 4527 } 4528 else /* numeric or string */ 4529 { 4530 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL 4531 || prefix != 1) 4532 { 4533 errmsg = e_invarg; 4534 goto skip; 4535 } 4536 4537 if (flags & P_NUM) /* numeric */ 4538 { 4539 /* 4540 * Different ways to set a number option: 4541 * & set to default value 4542 * < set to global value 4543 * <xx> accept special key codes for 'wildchar' 4544 * c accept any non-digit for 'wildchar' 4545 * [-]0-9 set number 4546 * other error 4547 */ 4548 ++arg; 4549 if (nextchar == '&') 4550 value = (long)(long_i)options[opt_idx].def_val[ 4551 ((flags & P_VI_DEF) || cp_val) 4552 ? VI_DEFAULT : VIM_DEFAULT]; 4553 else if (nextchar == '<') 4554 { 4555 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to 4556 * use the global value. */ 4557 if ((long *)varp == &curbuf->b_p_ul 4558 && opt_flags == OPT_LOCAL) 4559 value = NO_LOCAL_UNDOLEVEL; 4560 else 4561 value = *(long *)get_varp_scope( 4562 &(options[opt_idx]), OPT_GLOBAL); 4563 } 4564 else if (((long *)varp == &p_wc 4565 || (long *)varp == &p_wcm) 4566 && (*arg == '<' 4567 || *arg == '^' 4568 || ((!arg[1] || vim_iswhite(arg[1])) 4569 && !VIM_ISDIGIT(*arg)))) 4570 { 4571 value = string_to_key(arg); 4572 if (value == 0 && (long *)varp != &p_wcm) 4573 { 4574 errmsg = e_invarg; 4575 goto skip; 4576 } 4577 } 4578 else if (*arg == '-' || VIM_ISDIGIT(*arg)) 4579 { 4580 /* Allow negative (for 'undolevels'), octal and 4581 * hex numbers. */ 4582 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0); 4583 if (arg[i] != NUL && !vim_iswhite(arg[i])) 4584 { 4585 errmsg = e_invarg; 4586 goto skip; 4587 } 4588 } 4589 else 4590 { 4591 errmsg = (char_u *)N_("E521: Number required after ="); 4592 goto skip; 4593 } 4594 4595 if (adding) 4596 value = *(long *)varp + value; 4597 if (prepending) 4598 value = *(long *)varp * value; 4599 if (removing) 4600 value = *(long *)varp - value; 4601 errmsg = set_num_option(opt_idx, varp, value, 4602 errbuf, sizeof(errbuf), opt_flags); 4603 } 4604 else if (opt_idx >= 0) /* string */ 4605 { 4606 char_u *save_arg = NULL; 4607 char_u *s = NULL; 4608 char_u *oldval = NULL; /* previous value if *varp */ 4609 char_u *newval; 4610 char_u *origval = NULL; 4611 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4612 char_u *saved_origval = NULL; 4613 #endif 4614 unsigned newlen; 4615 int comma; 4616 int bs; 4617 int new_value_alloced; /* new string option 4618 was allocated */ 4619 4620 /* When using ":set opt=val" for a global option 4621 * with a local value the local value will be 4622 * reset, use the global value here. */ 4623 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 4624 && ((int)options[opt_idx].indir & PV_BOTH)) 4625 varp = options[opt_idx].var; 4626 4627 /* The old value is kept until we are sure that the 4628 * new value is valid. */ 4629 oldval = *(char_u **)varp; 4630 if (nextchar == '&') /* set to default val */ 4631 { 4632 newval = options[opt_idx].def_val[ 4633 ((flags & P_VI_DEF) || cp_val) 4634 ? VI_DEFAULT : VIM_DEFAULT]; 4635 if ((char_u **)varp == &p_bg) 4636 { 4637 /* guess the value of 'background' */ 4638 #ifdef FEAT_GUI 4639 if (gui.in_use) 4640 newval = gui_bg_default(); 4641 else 4642 #endif 4643 newval = term_bg_default(); 4644 } 4645 4646 /* expand environment variables and ~ (since the 4647 * default value was already expanded, only 4648 * required when an environment variable was set 4649 * later */ 4650 if (newval == NULL) 4651 newval = empty_option; 4652 else 4653 { 4654 s = option_expand(opt_idx, newval); 4655 if (s == NULL) 4656 s = newval; 4657 newval = vim_strsave(s); 4658 } 4659 new_value_alloced = TRUE; 4660 } 4661 else if (nextchar == '<') /* set to global val */ 4662 { 4663 newval = vim_strsave(*(char_u **)get_varp_scope( 4664 &(options[opt_idx]), OPT_GLOBAL)); 4665 new_value_alloced = TRUE; 4666 } 4667 else 4668 { 4669 ++arg; /* jump to after the '=' or ':' */ 4670 4671 /* 4672 * Set 'keywordprg' to ":help" if an empty 4673 * value was passed to :set by the user. 4674 * Misuse errbuf[] for the resulting string. 4675 */ 4676 if (varp == (char_u *)&p_kp 4677 && (*arg == NUL || *arg == ' ')) 4678 { 4679 STRCPY(errbuf, ":help"); 4680 save_arg = arg; 4681 arg = errbuf; 4682 } 4683 /* 4684 * Convert 'backspace' number to string, for 4685 * adding, prepending and removing string. 4686 */ 4687 else if (varp == (char_u *)&p_bs 4688 && VIM_ISDIGIT(**(char_u **)varp)) 4689 { 4690 i = getdigits((char_u **)varp); 4691 switch (i) 4692 { 4693 case 0: 4694 *(char_u **)varp = empty_option; 4695 break; 4696 case 1: 4697 *(char_u **)varp = vim_strsave( 4698 (char_u *)"indent,eol"); 4699 break; 4700 case 2: 4701 *(char_u **)varp = vim_strsave( 4702 (char_u *)"indent,eol,start"); 4703 break; 4704 } 4705 vim_free(oldval); 4706 oldval = *(char_u **)varp; 4707 } 4708 /* 4709 * Convert 'whichwrap' number to string, for 4710 * backwards compatibility with Vim 3.0. 4711 * Misuse errbuf[] for the resulting string. 4712 */ 4713 else if (varp == (char_u *)&p_ww 4714 && VIM_ISDIGIT(*arg)) 4715 { 4716 *errbuf = NUL; 4717 i = getdigits(&arg); 4718 if (i & 1) 4719 STRCAT(errbuf, "b,"); 4720 if (i & 2) 4721 STRCAT(errbuf, "s,"); 4722 if (i & 4) 4723 STRCAT(errbuf, "h,l,"); 4724 if (i & 8) 4725 STRCAT(errbuf, "<,>,"); 4726 if (i & 16) 4727 STRCAT(errbuf, "[,],"); 4728 if (*errbuf != NUL) /* remove trailing , */ 4729 errbuf[STRLEN(errbuf) - 1] = NUL; 4730 save_arg = arg; 4731 arg = errbuf; 4732 } 4733 /* 4734 * Remove '>' before 'dir' and 'bdir', for 4735 * backwards compatibility with version 3.0 4736 */ 4737 else if ( *arg == '>' 4738 && (varp == (char_u *)&p_dir 4739 || varp == (char_u *)&p_bdir)) 4740 { 4741 ++arg; 4742 } 4743 4744 /* When setting the local value of a global 4745 * option, the old value may be the global value. */ 4746 if (((int)options[opt_idx].indir & PV_BOTH) 4747 && (opt_flags & OPT_LOCAL)) 4748 origval = *(char_u **)get_varp( 4749 &options[opt_idx]); 4750 else 4751 origval = oldval; 4752 4753 /* 4754 * Copy the new string into allocated memory. 4755 * Can't use set_string_option_direct(), because 4756 * we need to remove the backslashes. 4757 */ 4758 /* get a bit too much */ 4759 newlen = (unsigned)STRLEN(arg) + 1; 4760 if (adding || prepending || removing) 4761 newlen += (unsigned)STRLEN(origval) + 1; 4762 newval = alloc(newlen); 4763 if (newval == NULL) /* out of mem, don't change */ 4764 break; 4765 s = newval; 4766 4767 /* 4768 * Copy the string, skip over escaped chars. 4769 * For MS-DOS and WIN32 backslashes before normal 4770 * file name characters are not removed, and keep 4771 * backslash at start, for "\\machine\path", but 4772 * do remove it for "\\\\machine\\path". 4773 * The reverse is found in ExpandOldSetting(). 4774 */ 4775 while (*arg && !vim_iswhite(*arg)) 4776 { 4777 if (*arg == '\\' && arg[1] != NUL 4778 #ifdef BACKSLASH_IN_FILENAME 4779 && !((flags & P_EXPAND) 4780 && vim_isfilec(arg[1]) 4781 && (arg[1] != '\\' 4782 || (s == newval 4783 && arg[2] != '\\'))) 4784 #endif 4785 ) 4786 ++arg; /* remove backslash */ 4787 #ifdef FEAT_MBYTE 4788 if (has_mbyte 4789 && (i = (*mb_ptr2len)(arg)) > 1) 4790 { 4791 /* copy multibyte char */ 4792 mch_memmove(s, arg, (size_t)i); 4793 arg += i; 4794 s += i; 4795 } 4796 else 4797 #endif 4798 *s++ = *arg++; 4799 } 4800 *s = NUL; 4801 4802 /* 4803 * Expand environment variables and ~. 4804 * Don't do it when adding without inserting a 4805 * comma. 4806 */ 4807 if (!(adding || prepending || removing) 4808 || (flags & P_COMMA)) 4809 { 4810 s = option_expand(opt_idx, newval); 4811 if (s != NULL) 4812 { 4813 vim_free(newval); 4814 newlen = (unsigned)STRLEN(s) + 1; 4815 if (adding || prepending || removing) 4816 newlen += (unsigned)STRLEN(origval) + 1; 4817 newval = alloc(newlen); 4818 if (newval == NULL) 4819 break; 4820 STRCPY(newval, s); 4821 } 4822 } 4823 4824 /* locate newval[] in origval[] when removing it 4825 * and when adding to avoid duplicates */ 4826 i = 0; /* init for GCC */ 4827 if (removing || (flags & P_NODUP)) 4828 { 4829 i = (int)STRLEN(newval); 4830 bs = 0; 4831 for (s = origval; *s; ++s) 4832 { 4833 if ((!(flags & P_COMMA) 4834 || s == origval 4835 || (s[-1] == ',' && !(bs & 1))) 4836 && STRNCMP(s, newval, i) == 0 4837 && (!(flags & P_COMMA) 4838 || s[i] == ',' 4839 || s[i] == NUL)) 4840 break; 4841 /* Count backslashes. Only a comma with an 4842 * even number of backslashes before it is 4843 * recognized as a separator */ 4844 if (s > origval && s[-1] == '\\') 4845 ++bs; 4846 else 4847 bs = 0; 4848 } 4849 4850 /* do not add if already there */ 4851 if ((adding || prepending) && *s) 4852 { 4853 prepending = FALSE; 4854 adding = FALSE; 4855 STRCPY(newval, origval); 4856 } 4857 } 4858 4859 /* concatenate the two strings; add a ',' if 4860 * needed */ 4861 if (adding || prepending) 4862 { 4863 comma = ((flags & P_COMMA) && *origval != NUL 4864 && *newval != NUL); 4865 if (adding) 4866 { 4867 i = (int)STRLEN(origval); 4868 /* strip a trailing comma, would get 2 */ 4869 if (comma && i > 1 4870 && (flags & P_ONECOMMA) == P_ONECOMMA 4871 && origval[i - 1] == ',' 4872 && origval[i - 2] != '\\') 4873 i--; 4874 mch_memmove(newval + i + comma, newval, 4875 STRLEN(newval) + 1); 4876 mch_memmove(newval, origval, (size_t)i); 4877 } 4878 else 4879 { 4880 i = (int)STRLEN(newval); 4881 STRMOVE(newval + i + comma, origval); 4882 } 4883 if (comma) 4884 newval[i] = ','; 4885 } 4886 4887 /* Remove newval[] from origval[]. (Note: "i" has 4888 * been set above and is used here). */ 4889 if (removing) 4890 { 4891 STRCPY(newval, origval); 4892 if (*s) 4893 { 4894 /* may need to remove a comma */ 4895 if (flags & P_COMMA) 4896 { 4897 if (s == origval) 4898 { 4899 /* include comma after string */ 4900 if (s[i] == ',') 4901 ++i; 4902 } 4903 else 4904 { 4905 /* include comma before string */ 4906 --s; 4907 ++i; 4908 } 4909 } 4910 STRMOVE(newval + (s - origval), s + i); 4911 } 4912 } 4913 4914 if (flags & P_FLAGLIST) 4915 { 4916 /* Remove flags that appear twice. */ 4917 for (s = newval; *s; ++s) 4918 if ((!(flags & P_COMMA) || *s != ',') 4919 && vim_strchr(s + 1, *s) != NULL) 4920 { 4921 STRMOVE(s, s + 1); 4922 --s; 4923 } 4924 } 4925 4926 if (save_arg != NULL) /* number for 'whichwrap' */ 4927 arg = save_arg; 4928 new_value_alloced = TRUE; 4929 } 4930 4931 /* Set the new value. */ 4932 *(char_u **)(varp) = newval; 4933 4934 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4935 if (!starting 4936 # ifdef FEAT_CRYPT 4937 && options[opt_idx].indir != PV_KEY 4938 # endif 4939 && origval != NULL) 4940 /* origval may be freed by 4941 * did_set_string_option(), make a copy. */ 4942 saved_origval = vim_strsave(origval); 4943 #endif 4944 4945 /* Handle side effects, and set the global value for 4946 * ":set" on local options. */ 4947 errmsg = did_set_string_option(opt_idx, (char_u **)varp, 4948 new_value_alloced, oldval, errbuf, opt_flags); 4949 4950 /* If error detected, print the error message. */ 4951 if (errmsg != NULL) 4952 { 4953 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4954 vim_free(saved_origval); 4955 #endif 4956 goto skip; 4957 } 4958 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4959 if (saved_origval != NULL) 4960 { 4961 char_u buf_type[7]; 4962 4963 sprintf((char *)buf_type, "%s", 4964 (opt_flags & OPT_LOCAL) ? "local" : "global"); 4965 set_vim_var_string(VV_OPTION_NEW, 4966 *(char_u **)varp, -1); 4967 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1); 4968 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 4969 apply_autocmds(EVENT_OPTIONSET, 4970 (char_u *)options[opt_idx].fullname, 4971 NULL, FALSE, NULL); 4972 reset_v_option_vars(); 4973 vim_free(saved_origval); 4974 } 4975 #endif 4976 4977 } 4978 else /* key code option */ 4979 { 4980 char_u *p; 4981 4982 if (nextchar == '&') 4983 { 4984 if (add_termcap_entry(key_name, TRUE) == FAIL) 4985 errmsg = (char_u *)N_("E522: Not found in termcap"); 4986 } 4987 else 4988 { 4989 ++arg; /* jump to after the '=' or ':' */ 4990 for (p = arg; *p && !vim_iswhite(*p); ++p) 4991 if (*p == '\\' && p[1] != NUL) 4992 ++p; 4993 nextchar = *p; 4994 *p = NUL; 4995 add_termcode(key_name, arg, FALSE); 4996 *p = nextchar; 4997 } 4998 if (full_screen) 4999 ttest(FALSE); 5000 redraw_all_later(CLEAR); 5001 } 5002 } 5003 5004 if (opt_idx >= 0) 5005 did_set_option(opt_idx, opt_flags, 5006 !prepending && !adding && !removing); 5007 } 5008 5009 skip: 5010 /* 5011 * Advance to next argument. 5012 * - skip until a blank found, taking care of backslashes 5013 * - skip blanks 5014 * - skip one "=val" argument (for hidden options ":set gfn =xx") 5015 */ 5016 for (i = 0; i < 2 ; ++i) 5017 { 5018 while (*arg != NUL && !vim_iswhite(*arg)) 5019 if (*arg++ == '\\' && *arg != NUL) 5020 ++arg; 5021 arg = skipwhite(arg); 5022 if (*arg != '=') 5023 break; 5024 } 5025 } 5026 5027 if (errmsg != NULL) 5028 { 5029 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); 5030 i = (int)STRLEN(IObuff) + 2; 5031 if (i + (arg - startarg) < IOSIZE) 5032 { 5033 /* append the argument with the error */ 5034 STRCAT(IObuff, ": "); 5035 mch_memmove(IObuff + i, startarg, (arg - startarg)); 5036 IObuff[i + (arg - startarg)] = NUL; 5037 } 5038 /* make sure all characters are printable */ 5039 trans_characters(IObuff, IOSIZE); 5040 5041 ++no_wait_return; /* wait_return done later */ 5042 emsg(IObuff); /* show error highlighted */ 5043 --no_wait_return; 5044 5045 return FAIL; 5046 } 5047 5048 arg = skipwhite(arg); 5049 } 5050 5051 theend: 5052 if (silent_mode && did_show) 5053 { 5054 /* After displaying option values in silent mode. */ 5055 silent_mode = FALSE; 5056 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ 5057 msg_putchar('\n'); 5058 cursor_on(); /* msg_start() switches it off */ 5059 out_flush(); 5060 silent_mode = TRUE; 5061 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ 5062 } 5063 5064 return OK; 5065 } 5066 5067 /* 5068 * Call this when an option has been given a new value through a user command. 5069 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. 5070 */ 5071 static void 5072 did_set_option(opt_idx, opt_flags, new_value) 5073 int opt_idx; 5074 int opt_flags; /* possibly with OPT_MODELINE */ 5075 int new_value; /* value was replaced completely */ 5076 { 5077 long_u *p; 5078 5079 options[opt_idx].flags |= P_WAS_SET; 5080 5081 /* When an option is set in the sandbox, from a modeline or in secure mode 5082 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the 5083 * flag. */ 5084 p = insecure_flag(opt_idx, opt_flags); 5085 if (secure 5086 #ifdef HAVE_SANDBOX 5087 || sandbox != 0 5088 #endif 5089 || (opt_flags & OPT_MODELINE)) 5090 *p = *p | P_INSECURE; 5091 else if (new_value) 5092 *p = *p & ~P_INSECURE; 5093 } 5094 5095 static char_u * 5096 illegal_char(errbuf, c) 5097 char_u *errbuf; 5098 int c; 5099 { 5100 if (errbuf == NULL) 5101 return (char_u *)""; 5102 sprintf((char *)errbuf, _("E539: Illegal character <%s>"), 5103 (char *)transchar(c)); 5104 return errbuf; 5105 } 5106 5107 /* 5108 * Convert a key name or string into a key value. 5109 * Used for 'wildchar' and 'cedit' options. 5110 */ 5111 static int 5112 string_to_key(arg) 5113 char_u *arg; 5114 { 5115 if (*arg == '<') 5116 return find_key_option(arg + 1); 5117 if (*arg == '^') 5118 return Ctrl_chr(arg[1]); 5119 return *arg; 5120 } 5121 5122 #ifdef FEAT_CMDWIN 5123 /* 5124 * Check value of 'cedit' and set cedit_key. 5125 * Returns NULL if value is OK, error message otherwise. 5126 */ 5127 static char_u * 5128 check_cedit() 5129 { 5130 int n; 5131 5132 if (*p_cedit == NUL) 5133 cedit_key = -1; 5134 else 5135 { 5136 n = string_to_key(p_cedit); 5137 if (vim_isprintc(n)) 5138 return e_invarg; 5139 cedit_key = n; 5140 } 5141 return NULL; 5142 } 5143 #endif 5144 5145 #ifdef FEAT_TITLE 5146 /* 5147 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call 5148 * maketitle() to create and display it. 5149 * When switching the title or icon off, call mch_restore_title() to get 5150 * the old value back. 5151 */ 5152 static void 5153 did_set_title(icon) 5154 int icon; /* Did set icon instead of title */ 5155 { 5156 if (starting != NO_SCREEN 5157 #ifdef FEAT_GUI 5158 && !gui.starting 5159 #endif 5160 ) 5161 { 5162 maketitle(); 5163 if (icon) 5164 { 5165 if (!p_icon) 5166 mch_restore_title(2); 5167 } 5168 else 5169 { 5170 if (!p_title) 5171 mch_restore_title(1); 5172 } 5173 } 5174 } 5175 #endif 5176 5177 /* 5178 * set_options_bin - called when 'bin' changes value. 5179 */ 5180 void 5181 set_options_bin(oldval, newval, opt_flags) 5182 int oldval; 5183 int newval; 5184 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ 5185 { 5186 /* 5187 * The option values that are changed when 'bin' changes are 5188 * copied when 'bin is set and restored when 'bin' is reset. 5189 */ 5190 if (newval) 5191 { 5192 if (!oldval) /* switched on */ 5193 { 5194 if (!(opt_flags & OPT_GLOBAL)) 5195 { 5196 curbuf->b_p_tw_nobin = curbuf->b_p_tw; 5197 curbuf->b_p_wm_nobin = curbuf->b_p_wm; 5198 curbuf->b_p_ml_nobin = curbuf->b_p_ml; 5199 curbuf->b_p_et_nobin = curbuf->b_p_et; 5200 } 5201 if (!(opt_flags & OPT_LOCAL)) 5202 { 5203 p_tw_nobin = p_tw; 5204 p_wm_nobin = p_wm; 5205 p_ml_nobin = p_ml; 5206 p_et_nobin = p_et; 5207 } 5208 } 5209 5210 if (!(opt_flags & OPT_GLOBAL)) 5211 { 5212 curbuf->b_p_tw = 0; /* no automatic line wrap */ 5213 curbuf->b_p_wm = 0; /* no automatic line wrap */ 5214 curbuf->b_p_ml = 0; /* no modelines */ 5215 curbuf->b_p_et = 0; /* no expandtab */ 5216 } 5217 if (!(opt_flags & OPT_LOCAL)) 5218 { 5219 p_tw = 0; 5220 p_wm = 0; 5221 p_ml = FALSE; 5222 p_et = FALSE; 5223 p_bin = TRUE; /* needed when called for the "-b" argument */ 5224 } 5225 } 5226 else if (oldval) /* switched off */ 5227 { 5228 if (!(opt_flags & OPT_GLOBAL)) 5229 { 5230 curbuf->b_p_tw = curbuf->b_p_tw_nobin; 5231 curbuf->b_p_wm = curbuf->b_p_wm_nobin; 5232 curbuf->b_p_ml = curbuf->b_p_ml_nobin; 5233 curbuf->b_p_et = curbuf->b_p_et_nobin; 5234 } 5235 if (!(opt_flags & OPT_LOCAL)) 5236 { 5237 p_tw = p_tw_nobin; 5238 p_wm = p_wm_nobin; 5239 p_ml = p_ml_nobin; 5240 p_et = p_et_nobin; 5241 } 5242 } 5243 } 5244 5245 #ifdef FEAT_VIMINFO 5246 /* 5247 * Find the parameter represented by the given character (eg ', :, ", or /), 5248 * and return its associated value in the 'viminfo' string. 5249 * Only works for number parameters, not for 'r' or 'n'. 5250 * If the parameter is not specified in the string or there is no following 5251 * number, return -1. 5252 */ 5253 int 5254 get_viminfo_parameter(type) 5255 int type; 5256 { 5257 char_u *p; 5258 5259 p = find_viminfo_parameter(type); 5260 if (p != NULL && VIM_ISDIGIT(*p)) 5261 return atoi((char *)p); 5262 return -1; 5263 } 5264 5265 /* 5266 * Find the parameter represented by the given character (eg ''', ':', '"', or 5267 * '/') in the 'viminfo' option and return a pointer to the string after it. 5268 * Return NULL if the parameter is not specified in the string. 5269 */ 5270 char_u * 5271 find_viminfo_parameter(type) 5272 int type; 5273 { 5274 char_u *p; 5275 5276 for (p = p_viminfo; *p; ++p) 5277 { 5278 if (*p == type) 5279 return p + 1; 5280 if (*p == 'n') /* 'n' is always the last one */ 5281 break; 5282 p = vim_strchr(p, ','); /* skip until next ',' */ 5283 if (p == NULL) /* hit the end without finding parameter */ 5284 break; 5285 } 5286 return NULL; 5287 } 5288 #endif 5289 5290 /* 5291 * Expand environment variables for some string options. 5292 * These string options cannot be indirect! 5293 * If "val" is NULL expand the current value of the option. 5294 * Return pointer to NameBuff, or NULL when not expanded. 5295 */ 5296 static char_u * 5297 option_expand(opt_idx, val) 5298 int opt_idx; 5299 char_u *val; 5300 { 5301 /* if option doesn't need expansion nothing to do */ 5302 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) 5303 return NULL; 5304 5305 /* If val is longer than MAXPATHL no meaningful expansion can be done, 5306 * expand_env() would truncate the string. */ 5307 if (val != NULL && STRLEN(val) > MAXPATHL) 5308 return NULL; 5309 5310 if (val == NULL) 5311 val = *(char_u **)options[opt_idx].var; 5312 5313 /* 5314 * Expanding this with NameBuff, expand_env() must not be passed IObuff. 5315 * Escape spaces when expanding 'tags', they are used to separate file 5316 * names. 5317 * For 'spellsuggest' expand after "file:". 5318 */ 5319 expand_env_esc(val, NameBuff, MAXPATHL, 5320 (char_u **)options[opt_idx].var == &p_tags, FALSE, 5321 #ifdef FEAT_SPELL 5322 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : 5323 #endif 5324 NULL); 5325 if (STRCMP(NameBuff, val) == 0) /* they are the same */ 5326 return NULL; 5327 5328 return NameBuff; 5329 } 5330 5331 /* 5332 * After setting various option values: recompute variables that depend on 5333 * option values. 5334 */ 5335 static void 5336 didset_options() 5337 { 5338 /* initialize the table for 'iskeyword' et.al. */ 5339 (void)init_chartab(); 5340 5341 #ifdef FEAT_MBYTE 5342 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); 5343 #endif 5344 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE); 5345 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE); 5346 #ifdef FEAT_SESSION 5347 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE); 5348 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE); 5349 #endif 5350 #ifdef FEAT_FOLDING 5351 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); 5352 #endif 5353 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); 5354 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE); 5355 #ifdef FEAT_VIRTUALEDIT 5356 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); 5357 #endif 5358 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) 5359 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); 5360 #endif 5361 #ifdef FEAT_SPELL 5362 (void)spell_check_msm(); 5363 (void)spell_check_sps(); 5364 (void)compile_cap_prog(curwin->w_s); 5365 (void)did_set_spell_option(TRUE); 5366 #endif 5367 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 5368 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); 5369 #endif 5370 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) 5371 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE); 5372 #endif 5373 #ifdef FEAT_CMDWIN 5374 /* set cedit_key */ 5375 (void)check_cedit(); 5376 #endif 5377 #ifdef FEAT_LINEBREAK 5378 briopt_check(curwin); 5379 #endif 5380 #ifdef FEAT_LINEBREAK 5381 /* initialize the table for 'breakat'. */ 5382 fill_breakat_flags(); 5383 #endif 5384 5385 } 5386 5387 /* 5388 * More side effects of setting options. 5389 */ 5390 static void 5391 didset_options2() 5392 { 5393 /* Initialize the highlight_attr[] table. */ 5394 (void)highlight_changed(); 5395 5396 /* Parse default for 'wildmode' */ 5397 check_opt_wim(); 5398 5399 (void)set_chars_option(&p_lcs); 5400 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 5401 /* Parse default for 'fillchars'. */ 5402 (void)set_chars_option(&p_fcs); 5403 #endif 5404 5405 #ifdef FEAT_CLIPBOARD 5406 /* Parse default for 'clipboard' */ 5407 (void)check_clipboard_option(); 5408 #endif 5409 } 5410 5411 /* 5412 * Check for string options that are NULL (normally only termcap options). 5413 */ 5414 void 5415 check_options() 5416 { 5417 int opt_idx; 5418 5419 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) 5420 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) 5421 check_string_option((char_u **)get_varp(&(options[opt_idx]))); 5422 } 5423 5424 /* 5425 * Check string options in a buffer for NULL value. 5426 */ 5427 void 5428 check_buf_options(buf) 5429 buf_T *buf; 5430 { 5431 #if defined(FEAT_QUICKFIX) 5432 check_string_option(&buf->b_p_bh); 5433 check_string_option(&buf->b_p_bt); 5434 #endif 5435 #ifdef FEAT_MBYTE 5436 check_string_option(&buf->b_p_fenc); 5437 #endif 5438 check_string_option(&buf->b_p_ff); 5439 #ifdef FEAT_FIND_ID 5440 check_string_option(&buf->b_p_def); 5441 check_string_option(&buf->b_p_inc); 5442 # ifdef FEAT_EVAL 5443 check_string_option(&buf->b_p_inex); 5444 # endif 5445 #endif 5446 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 5447 check_string_option(&buf->b_p_inde); 5448 check_string_option(&buf->b_p_indk); 5449 #endif 5450 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 5451 check_string_option(&buf->b_p_bexpr); 5452 #endif 5453 #if defined(FEAT_CRYPT) 5454 check_string_option(&buf->b_p_cm); 5455 #endif 5456 #if defined(FEAT_EVAL) 5457 check_string_option(&buf->b_p_fex); 5458 #endif 5459 #ifdef FEAT_CRYPT 5460 check_string_option(&buf->b_p_key); 5461 #endif 5462 check_string_option(&buf->b_p_kp); 5463 check_string_option(&buf->b_p_mps); 5464 check_string_option(&buf->b_p_fo); 5465 check_string_option(&buf->b_p_flp); 5466 check_string_option(&buf->b_p_isk); 5467 #ifdef FEAT_COMMENTS 5468 check_string_option(&buf->b_p_com); 5469 #endif 5470 #ifdef FEAT_FOLDING 5471 check_string_option(&buf->b_p_cms); 5472 #endif 5473 check_string_option(&buf->b_p_nf); 5474 #ifdef FEAT_TEXTOBJ 5475 check_string_option(&buf->b_p_qe); 5476 #endif 5477 #ifdef FEAT_SYN_HL 5478 check_string_option(&buf->b_p_syn); 5479 #endif 5480 #ifdef FEAT_SPELL 5481 check_string_option(&buf->b_s.b_p_spc); 5482 check_string_option(&buf->b_s.b_p_spf); 5483 check_string_option(&buf->b_s.b_p_spl); 5484 #endif 5485 #ifdef FEAT_SEARCHPATH 5486 check_string_option(&buf->b_p_sua); 5487 #endif 5488 #ifdef FEAT_CINDENT 5489 check_string_option(&buf->b_p_cink); 5490 check_string_option(&buf->b_p_cino); 5491 parse_cino(buf); 5492 #endif 5493 #ifdef FEAT_AUTOCMD 5494 check_string_option(&buf->b_p_ft); 5495 #endif 5496 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 5497 check_string_option(&buf->b_p_cinw); 5498 #endif 5499 #ifdef FEAT_INS_EXPAND 5500 check_string_option(&buf->b_p_cpt); 5501 #endif 5502 #ifdef FEAT_COMPL_FUNC 5503 check_string_option(&buf->b_p_cfu); 5504 check_string_option(&buf->b_p_ofu); 5505 #endif 5506 #ifdef FEAT_KEYMAP 5507 check_string_option(&buf->b_p_keymap); 5508 #endif 5509 #ifdef FEAT_QUICKFIX 5510 check_string_option(&buf->b_p_gp); 5511 check_string_option(&buf->b_p_mp); 5512 check_string_option(&buf->b_p_efm); 5513 #endif 5514 check_string_option(&buf->b_p_ep); 5515 check_string_option(&buf->b_p_path); 5516 check_string_option(&buf->b_p_tags); 5517 check_string_option(&buf->b_p_tc); 5518 #ifdef FEAT_INS_EXPAND 5519 check_string_option(&buf->b_p_dict); 5520 check_string_option(&buf->b_p_tsr); 5521 #endif 5522 #ifdef FEAT_LISP 5523 check_string_option(&buf->b_p_lw); 5524 #endif 5525 check_string_option(&buf->b_p_bkc); 5526 } 5527 5528 /* 5529 * Free the string allocated for an option. 5530 * Checks for the string being empty_option. This may happen if we're out of 5531 * memory, vim_strsave() returned NULL, which was replaced by empty_option by 5532 * check_options(). 5533 * Does NOT check for P_ALLOCED flag! 5534 */ 5535 void 5536 free_string_option(p) 5537 char_u *p; 5538 { 5539 if (p != empty_option) 5540 vim_free(p); 5541 } 5542 5543 void 5544 clear_string_option(pp) 5545 char_u **pp; 5546 { 5547 if (*pp != empty_option) 5548 vim_free(*pp); 5549 *pp = empty_option; 5550 } 5551 5552 static void 5553 check_string_option(pp) 5554 char_u **pp; 5555 { 5556 if (*pp == NULL) 5557 *pp = empty_option; 5558 } 5559 5560 /* 5561 * Mark a terminal option as allocated, found by a pointer into term_strings[]. 5562 */ 5563 void 5564 set_term_option_alloced(p) 5565 char_u **p; 5566 { 5567 int opt_idx; 5568 5569 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) 5570 if (options[opt_idx].var == (char_u *)p) 5571 { 5572 options[opt_idx].flags |= P_ALLOCED; 5573 return; 5574 } 5575 return; /* cannot happen: didn't find it! */ 5576 } 5577 5578 #if defined(FEAT_EVAL) || defined(PROTO) 5579 /* 5580 * Return TRUE when option "opt" was set from a modeline or in secure mode. 5581 * Return FALSE when it wasn't. 5582 * Return -1 for an unknown option. 5583 */ 5584 int 5585 was_set_insecurely(opt, opt_flags) 5586 char_u *opt; 5587 int opt_flags; 5588 { 5589 int idx = findoption(opt); 5590 long_u *flagp; 5591 5592 if (idx >= 0) 5593 { 5594 flagp = insecure_flag(idx, opt_flags); 5595 return (*flagp & P_INSECURE) != 0; 5596 } 5597 EMSG2(_(e_intern2), "was_set_insecurely()"); 5598 return -1; 5599 } 5600 5601 /* 5602 * Get a pointer to the flags used for the P_INSECURE flag of option 5603 * "opt_idx". For some local options a local flags field is used. 5604 */ 5605 static long_u * 5606 insecure_flag(opt_idx, opt_flags) 5607 int opt_idx; 5608 int opt_flags; 5609 { 5610 if (opt_flags & OPT_LOCAL) 5611 switch ((int)options[opt_idx].indir) 5612 { 5613 #ifdef FEAT_STL_OPT 5614 case PV_STL: return &curwin->w_p_stl_flags; 5615 #endif 5616 #ifdef FEAT_EVAL 5617 # ifdef FEAT_FOLDING 5618 case PV_FDE: return &curwin->w_p_fde_flags; 5619 case PV_FDT: return &curwin->w_p_fdt_flags; 5620 # endif 5621 # ifdef FEAT_BEVAL 5622 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; 5623 # endif 5624 # if defined(FEAT_CINDENT) 5625 case PV_INDE: return &curbuf->b_p_inde_flags; 5626 # endif 5627 case PV_FEX: return &curbuf->b_p_fex_flags; 5628 # ifdef FEAT_FIND_ID 5629 case PV_INEX: return &curbuf->b_p_inex_flags; 5630 # endif 5631 #endif 5632 } 5633 5634 /* Nothing special, return global flags field. */ 5635 return &options[opt_idx].flags; 5636 } 5637 #endif 5638 5639 #ifdef FEAT_TITLE 5640 static void redraw_titles __ARGS((void)); 5641 5642 /* 5643 * Redraw the window title and/or tab page text later. 5644 */ 5645 static void redraw_titles() 5646 { 5647 need_maketitle = TRUE; 5648 # ifdef FEAT_WINDOWS 5649 redraw_tabline = TRUE; 5650 # endif 5651 } 5652 #endif 5653 5654 /* 5655 * Set a string option to a new value (without checking the effect). 5656 * The string is copied into allocated memory. 5657 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. 5658 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is 5659 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid". 5660 */ 5661 void 5662 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid) 5663 char_u *name; 5664 int opt_idx; 5665 char_u *val; 5666 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ 5667 int set_sid UNUSED; 5668 { 5669 char_u *s; 5670 char_u **varp; 5671 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; 5672 int idx = opt_idx; 5673 5674 if (idx == -1) /* use name */ 5675 { 5676 idx = findoption(name); 5677 if (idx < 0) /* not found (should not happen) */ 5678 { 5679 EMSG2(_(e_intern2), "set_string_option_direct()"); 5680 EMSG2(_("For option %s"), name); 5681 return; 5682 } 5683 } 5684 5685 if (options[idx].var == NULL) /* can't set hidden option */ 5686 return; 5687 5688 s = vim_strsave(val); 5689 if (s != NULL) 5690 { 5691 varp = (char_u **)get_varp_scope(&(options[idx]), 5692 both ? OPT_LOCAL : opt_flags); 5693 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED)) 5694 free_string_option(*varp); 5695 *varp = s; 5696 5697 /* For buffer/window local option may also set the global value. */ 5698 if (both) 5699 set_string_option_global(idx, varp); 5700 5701 options[idx].flags |= P_ALLOCED; 5702 5703 /* When setting both values of a global option with a local value, 5704 * make the local value empty, so that the global value is used. */ 5705 if (((int)options[idx].indir & PV_BOTH) && both) 5706 { 5707 free_string_option(*varp); 5708 *varp = empty_option; 5709 } 5710 # ifdef FEAT_EVAL 5711 if (set_sid != SID_NONE) 5712 set_option_scriptID_idx(idx, opt_flags, 5713 set_sid == 0 ? current_SID : set_sid); 5714 # endif 5715 } 5716 } 5717 5718 /* 5719 * Set global value for string option when it's a local option. 5720 */ 5721 static void 5722 set_string_option_global(opt_idx, varp) 5723 int opt_idx; /* option index */ 5724 char_u **varp; /* pointer to option variable */ 5725 { 5726 char_u **p, *s; 5727 5728 /* the global value is always allocated */ 5729 if (options[opt_idx].var == VAR_WIN) 5730 p = (char_u **)GLOBAL_WO(varp); 5731 else 5732 p = (char_u **)options[opt_idx].var; 5733 if (options[opt_idx].indir != PV_NONE 5734 && p != varp 5735 && (s = vim_strsave(*varp)) != NULL) 5736 { 5737 free_string_option(*p); 5738 *p = s; 5739 } 5740 } 5741 5742 /* 5743 * Set a string option to a new value, and handle the effects. 5744 * 5745 * Returns NULL on success or error message on error. 5746 */ 5747 static char_u * 5748 set_string_option(opt_idx, value, opt_flags) 5749 int opt_idx; 5750 char_u *value; 5751 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ 5752 { 5753 char_u *s; 5754 char_u **varp; 5755 char_u *oldval; 5756 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5757 char_u *saved_oldval = NULL; 5758 #endif 5759 char_u *r = NULL; 5760 5761 if (options[opt_idx].var == NULL) /* don't set hidden option */ 5762 return NULL; 5763 5764 s = vim_strsave(value); 5765 if (s != NULL) 5766 { 5767 varp = (char_u **)get_varp_scope(&(options[opt_idx]), 5768 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 5769 ? (((int)options[opt_idx].indir & PV_BOTH) 5770 ? OPT_GLOBAL : OPT_LOCAL) 5771 : opt_flags); 5772 oldval = *varp; 5773 *varp = s; 5774 5775 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5776 if (!starting 5777 # ifdef FEAT_CRYPT 5778 && options[opt_idx].indir != PV_KEY 5779 # endif 5780 ) 5781 saved_oldval = vim_strsave(oldval); 5782 #endif 5783 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, 5784 opt_flags)) == NULL) 5785 did_set_option(opt_idx, opt_flags, TRUE); 5786 5787 /* call autocomamnd after handling side effects */ 5788 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5789 if (saved_oldval != NULL) 5790 { 5791 char_u buf_type[7]; 5792 sprintf((char *)buf_type, "%s", 5793 (opt_flags & OPT_LOCAL) ? "local" : "global"); 5794 set_vim_var_string(VV_OPTION_NEW, *varp, -1); 5795 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1); 5796 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 5797 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL); 5798 reset_v_option_vars(); 5799 vim_free(saved_oldval); 5800 } 5801 #endif 5802 } 5803 return r; 5804 } 5805 5806 /* 5807 * Handle string options that need some action to perform when changed. 5808 * Returns NULL for success, or an error message for an error. 5809 */ 5810 static char_u * 5811 did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf, 5812 opt_flags) 5813 int opt_idx; /* index in options[] table */ 5814 char_u **varp; /* pointer to the option variable */ 5815 int new_value_alloced; /* new value was allocated */ 5816 char_u *oldval; /* previous value of the option */ 5817 char_u *errbuf; /* buffer for errors, or NULL */ 5818 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ 5819 { 5820 char_u *errmsg = NULL; 5821 char_u *s, *p; 5822 int did_chartab = FALSE; 5823 char_u **gvarp; 5824 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED); 5825 #ifdef FEAT_GUI 5826 /* set when changing an option that only requires a redraw in the GUI */ 5827 int redraw_gui_only = FALSE; 5828 #endif 5829 5830 /* Get the global option to compare with, otherwise we would have to check 5831 * two values for all local options. */ 5832 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); 5833 5834 /* Disallow changing some options from secure mode */ 5835 if ((secure 5836 #ifdef HAVE_SANDBOX 5837 || sandbox != 0 5838 #endif 5839 ) && (options[opt_idx].flags & P_SECURE)) 5840 { 5841 errmsg = e_secure; 5842 } 5843 5844 /* Check for a "normal" file name in some options. Disallow a path 5845 * separator (slash and/or backslash), wildcards and characters that are 5846 * often illegal in a file name. */ 5847 else if ((options[opt_idx].flags & P_NFNAME) 5848 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) 5849 { 5850 errmsg = e_invarg; 5851 } 5852 5853 /* 'term' */ 5854 else if (varp == &T_NAME) 5855 { 5856 if (T_NAME[0] == NUL) 5857 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); 5858 #ifdef FEAT_GUI 5859 if (gui.in_use) 5860 errmsg = (char_u *)N_("E530: Cannot change term in GUI"); 5861 else if (term_is_gui(T_NAME)) 5862 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI"); 5863 #endif 5864 else if (set_termname(T_NAME) == FAIL) 5865 errmsg = (char_u *)N_("E522: Not found in termcap"); 5866 else 5867 /* Screen colors may have changed. */ 5868 redraw_later_clear(); 5869 } 5870 5871 /* 'backupcopy' */ 5872 else if (gvarp == &p_bkc) 5873 { 5874 char_u *bkc = p_bkc; 5875 unsigned int *flags = &bkc_flags; 5876 5877 if (opt_flags & OPT_LOCAL) 5878 { 5879 bkc = curbuf->b_p_bkc; 5880 flags = &curbuf->b_bkc_flags; 5881 } 5882 5883 if ((opt_flags & OPT_LOCAL) && *bkc == NUL) 5884 /* make the local value empty: use the global value */ 5885 *flags = 0; 5886 else 5887 { 5888 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK) 5889 errmsg = e_invarg; 5890 if ((((int)*flags & BKC_AUTO) != 0) 5891 + (((int)*flags & BKC_YES) != 0) 5892 + (((int)*flags & BKC_NO) != 0) != 1) 5893 { 5894 /* Must have exactly one of "auto", "yes" and "no". */ 5895 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE); 5896 errmsg = e_invarg; 5897 } 5898 } 5899 } 5900 5901 /* 'backupext' and 'patchmode' */ 5902 else if (varp == &p_bex || varp == &p_pm) 5903 { 5904 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, 5905 *p_pm == '.' ? p_pm + 1 : p_pm) == 0) 5906 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal"); 5907 } 5908 #ifdef FEAT_LINEBREAK 5909 /* 'breakindentopt' */ 5910 else if (varp == &curwin->w_p_briopt) 5911 { 5912 if (briopt_check(curwin) == FAIL) 5913 errmsg = e_invarg; 5914 } 5915 #endif 5916 5917 /* 5918 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[] 5919 * If the new option is invalid, use old value. 'lisp' option: refill 5920 * chartab[] for '-' char 5921 */ 5922 else if ( varp == &p_isi 5923 || varp == &(curbuf->b_p_isk) 5924 || varp == &p_isp 5925 || varp == &p_isf) 5926 { 5927 if (init_chartab() == FAIL) 5928 { 5929 did_chartab = TRUE; /* need to restore it below */ 5930 errmsg = e_invarg; /* error in value */ 5931 } 5932 } 5933 5934 /* 'helpfile' */ 5935 else if (varp == &p_hf) 5936 { 5937 /* May compute new values for $VIM and $VIMRUNTIME */ 5938 if (didset_vim) 5939 { 5940 vim_setenv((char_u *)"VIM", (char_u *)""); 5941 didset_vim = FALSE; 5942 } 5943 if (didset_vimruntime) 5944 { 5945 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); 5946 didset_vimruntime = FALSE; 5947 } 5948 } 5949 5950 #ifdef FEAT_SYN_HL 5951 /* 'colorcolumn' */ 5952 else if (varp == &curwin->w_p_cc) 5953 errmsg = check_colorcolumn(curwin); 5954 #endif 5955 5956 #ifdef FEAT_MULTI_LANG 5957 /* 'helplang' */ 5958 else if (varp == &p_hlg) 5959 { 5960 /* Check for "", "ab", "ab,cd", etc. */ 5961 for (s = p_hlg; *s != NUL; s += 3) 5962 { 5963 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) 5964 { 5965 errmsg = e_invarg; 5966 break; 5967 } 5968 if (s[2] == NUL) 5969 break; 5970 } 5971 } 5972 #endif 5973 5974 /* 'highlight' */ 5975 else if (varp == &p_hl) 5976 { 5977 if (highlight_changed() == FAIL) 5978 errmsg = e_invarg; /* invalid flags */ 5979 } 5980 5981 /* 'nrformats' */ 5982 else if (gvarp == &p_nf) 5983 { 5984 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) 5985 errmsg = e_invarg; 5986 } 5987 5988 #ifdef FEAT_SESSION 5989 /* 'sessionoptions' */ 5990 else if (varp == &p_ssop) 5991 { 5992 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) 5993 errmsg = e_invarg; 5994 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) 5995 { 5996 /* Don't allow both "sesdir" and "curdir". */ 5997 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); 5998 errmsg = e_invarg; 5999 } 6000 } 6001 /* 'viewoptions' */ 6002 else if (varp == &p_vop) 6003 { 6004 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) 6005 errmsg = e_invarg; 6006 } 6007 #endif 6008 6009 /* 'scrollopt' */ 6010 #ifdef FEAT_SCROLLBIND 6011 else if (varp == &p_sbo) 6012 { 6013 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) 6014 errmsg = e_invarg; 6015 } 6016 #endif 6017 6018 /* 'ambiwidth' */ 6019 #ifdef FEAT_MBYTE 6020 else if (varp == &p_ambw) 6021 { 6022 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) 6023 errmsg = e_invarg; 6024 else if (set_chars_option(&p_lcs) != NULL) 6025 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'"); 6026 # if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 6027 else if (set_chars_option(&p_fcs) != NULL) 6028 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'"); 6029 # endif 6030 } 6031 #endif 6032 6033 /* 'background' */ 6034 else if (varp == &p_bg) 6035 { 6036 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) 6037 { 6038 #ifdef FEAT_EVAL 6039 int dark = (*p_bg == 'd'); 6040 #endif 6041 6042 init_highlight(FALSE, FALSE); 6043 6044 #ifdef FEAT_EVAL 6045 if (dark != (*p_bg == 'd') 6046 && get_var_value((char_u *)"g:colors_name") != NULL) 6047 { 6048 /* The color scheme must have set 'background' back to another 6049 * value, that's not what we want here. Disable the color 6050 * scheme and set the colors again. */ 6051 do_unlet((char_u *)"g:colors_name", TRUE); 6052 free_string_option(p_bg); 6053 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); 6054 check_string_option(&p_bg); 6055 init_highlight(FALSE, FALSE); 6056 } 6057 #endif 6058 } 6059 else 6060 errmsg = e_invarg; 6061 } 6062 6063 /* 'wildmode' */ 6064 else if (varp == &p_wim) 6065 { 6066 if (check_opt_wim() == FAIL) 6067 errmsg = e_invarg; 6068 } 6069 6070 #ifdef FEAT_CMDL_COMPL 6071 /* 'wildoptions' */ 6072 else if (varp == &p_wop) 6073 { 6074 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK) 6075 errmsg = e_invarg; 6076 } 6077 #endif 6078 6079 #ifdef FEAT_WAK 6080 /* 'winaltkeys' */ 6081 else if (varp == &p_wak) 6082 { 6083 if (*p_wak == NUL 6084 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) 6085 errmsg = e_invarg; 6086 # ifdef FEAT_MENU 6087 # ifdef FEAT_GUI_MOTIF 6088 else if (gui.in_use) 6089 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); 6090 # else 6091 # ifdef FEAT_GUI_GTK 6092 else if (gui.in_use) 6093 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); 6094 # endif 6095 # endif 6096 # endif 6097 } 6098 #endif 6099 6100 #ifdef FEAT_AUTOCMD 6101 /* 'eventignore' */ 6102 else if (varp == &p_ei) 6103 { 6104 if (check_ei() == FAIL) 6105 errmsg = e_invarg; 6106 } 6107 #endif 6108 6109 #ifdef FEAT_MBYTE 6110 /* 'encoding' and 'fileencoding' */ 6111 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc) 6112 { 6113 if (gvarp == &p_fenc) 6114 { 6115 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL) 6116 errmsg = e_modifiable; 6117 else if (vim_strchr(*varp, ',') != NULL) 6118 /* No comma allowed in 'fileencoding'; catches confusing it 6119 * with 'fileencodings'. */ 6120 errmsg = e_invarg; 6121 else 6122 { 6123 # ifdef FEAT_TITLE 6124 /* May show a "+" in the title now. */ 6125 redraw_titles(); 6126 # endif 6127 /* Add 'fileencoding' to the swap file. */ 6128 ml_setflags(curbuf); 6129 } 6130 } 6131 if (errmsg == NULL) 6132 { 6133 /* canonize the value, so that STRCMP() can be used on it */ 6134 p = enc_canonize(*varp); 6135 if (p != NULL) 6136 { 6137 vim_free(*varp); 6138 *varp = p; 6139 } 6140 if (varp == &p_enc) 6141 { 6142 errmsg = mb_init(); 6143 # ifdef FEAT_TITLE 6144 redraw_titles(); 6145 # endif 6146 } 6147 } 6148 6149 # if defined(FEAT_GUI_GTK) 6150 if (errmsg == NULL && varp == &p_tenc && gui.in_use) 6151 { 6152 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */ 6153 if (STRCMP(p_tenc, "utf-8") != 0) 6154 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI"); 6155 } 6156 # endif 6157 6158 if (errmsg == NULL) 6159 { 6160 # ifdef FEAT_KEYMAP 6161 /* When 'keymap' is used and 'encoding' changes, reload the keymap 6162 * (with another encoding). */ 6163 if (varp == &p_enc && *curbuf->b_p_keymap != NUL) 6164 (void)keymap_init(); 6165 # endif 6166 6167 /* When 'termencoding' is not empty and 'encoding' changes or when 6168 * 'termencoding' changes, need to setup for keyboard input and 6169 * display output conversion. */ 6170 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) 6171 { 6172 convert_setup(&input_conv, p_tenc, p_enc); 6173 convert_setup(&output_conv, p_enc, p_tenc); 6174 } 6175 6176 # if defined(WIN3264) && defined(FEAT_MBYTE) 6177 /* $HOME may have characters in active code page. */ 6178 if (varp == &p_enc) 6179 init_homedir(); 6180 # endif 6181 } 6182 } 6183 #endif 6184 6185 #if defined(FEAT_POSTSCRIPT) 6186 else if (varp == &p_penc) 6187 { 6188 /* Canonize printencoding if VIM standard one */ 6189 p = enc_canonize(p_penc); 6190 if (p != NULL) 6191 { 6192 vim_free(p_penc); 6193 p_penc = p; 6194 } 6195 else 6196 { 6197 /* Ensure lower case and '-' for '_' */ 6198 for (s = p_penc; *s != NUL; s++) 6199 { 6200 if (*s == '_') 6201 *s = '-'; 6202 else 6203 *s = TOLOWER_ASC(*s); 6204 } 6205 } 6206 } 6207 #endif 6208 6209 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 6210 else if (varp == &p_imak) 6211 { 6212 if (gui.in_use && !im_xim_isvalid_imactivate()) 6213 errmsg = e_invarg; 6214 } 6215 #endif 6216 6217 #ifdef FEAT_KEYMAP 6218 else if (varp == &curbuf->b_p_keymap) 6219 { 6220 /* load or unload key mapping tables */ 6221 errmsg = keymap_init(); 6222 6223 if (errmsg == NULL) 6224 { 6225 if (*curbuf->b_p_keymap != NUL) 6226 { 6227 /* Installed a new keymap, switch on using it. */ 6228 curbuf->b_p_iminsert = B_IMODE_LMAP; 6229 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) 6230 curbuf->b_p_imsearch = B_IMODE_LMAP; 6231 } 6232 else 6233 { 6234 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */ 6235 if (curbuf->b_p_iminsert == B_IMODE_LMAP) 6236 curbuf->b_p_iminsert = B_IMODE_NONE; 6237 if (curbuf->b_p_imsearch == B_IMODE_LMAP) 6238 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; 6239 } 6240 if ((opt_flags & OPT_LOCAL) == 0) 6241 { 6242 set_iminsert_global(); 6243 set_imsearch_global(); 6244 } 6245 # ifdef FEAT_WINDOWS 6246 status_redraw_curbuf(); 6247 # endif 6248 } 6249 } 6250 #endif 6251 6252 /* 'fileformat' */ 6253 else if (gvarp == &p_ff) 6254 { 6255 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) 6256 errmsg = e_modifiable; 6257 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) 6258 errmsg = e_invarg; 6259 else 6260 { 6261 /* may also change 'textmode' */ 6262 if (get_fileformat(curbuf) == EOL_DOS) 6263 curbuf->b_p_tx = TRUE; 6264 else 6265 curbuf->b_p_tx = FALSE; 6266 #ifdef FEAT_TITLE 6267 redraw_titles(); 6268 #endif 6269 /* update flag in swap file */ 6270 ml_setflags(curbuf); 6271 /* Redraw needed when switching to/from "mac": a CR in the text 6272 * will be displayed differently. */ 6273 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm') 6274 redraw_curbuf_later(NOT_VALID); 6275 } 6276 } 6277 6278 /* 'fileformats' */ 6279 else if (varp == &p_ffs) 6280 { 6281 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) 6282 errmsg = e_invarg; 6283 else 6284 { 6285 /* also change 'textauto' */ 6286 if (*p_ffs == NUL) 6287 p_ta = FALSE; 6288 else 6289 p_ta = TRUE; 6290 } 6291 } 6292 6293 #if defined(FEAT_CRYPT) 6294 /* 'cryptkey' */ 6295 else if (gvarp == &p_key) 6296 { 6297 # if defined(FEAT_CMDHIST) 6298 /* Make sure the ":set" command doesn't show the new value in the 6299 * history. */ 6300 remove_key_from_history(); 6301 # endif 6302 if (STRCMP(curbuf->b_p_key, oldval) != 0) 6303 /* Need to update the swapfile. */ 6304 ml_set_crypt_key(curbuf, oldval, 6305 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm); 6306 } 6307 6308 else if (gvarp == &p_cm) 6309 { 6310 if (opt_flags & OPT_LOCAL) 6311 p = curbuf->b_p_cm; 6312 else 6313 p = p_cm; 6314 if (check_opt_strings(p, p_cm_values, TRUE) != OK) 6315 errmsg = e_invarg; 6316 else if (crypt_self_test() == FAIL) 6317 errmsg = e_invarg; 6318 else 6319 { 6320 /* When setting the global value to empty, make it "zip". */ 6321 if (*p_cm == NUL) 6322 { 6323 if (new_value_alloced) 6324 free_string_option(p_cm); 6325 p_cm = vim_strsave((char_u *)"zip"); 6326 new_value_alloced = TRUE; 6327 } 6328 /* When using ":set cm=name" the local value is going to be empty. 6329 * Do that here, otherwise the crypt functions will still use the 6330 * local value. */ 6331 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) 6332 { 6333 free_string_option(curbuf->b_p_cm); 6334 curbuf->b_p_cm = empty_option; 6335 } 6336 6337 /* Need to update the swapfile when the effective method changed. 6338 * Set "s" to the effective old value, "p" to the effective new 6339 * method and compare. */ 6340 if ((opt_flags & OPT_LOCAL) && *oldval == NUL) 6341 s = p_cm; /* was previously using the global value */ 6342 else 6343 s = oldval; 6344 if (*curbuf->b_p_cm == NUL) 6345 p = p_cm; /* is now using the global value */ 6346 else 6347 p = curbuf->b_p_cm; 6348 if (STRCMP(s, p) != 0) 6349 ml_set_crypt_key(curbuf, curbuf->b_p_key, s); 6350 6351 /* If the global value changes need to update the swapfile for all 6352 * buffers using that value. */ 6353 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0) 6354 { 6355 buf_T *buf; 6356 6357 for (buf = firstbuf; buf != NULL; buf = buf->b_next) 6358 if (buf != curbuf && *buf->b_p_cm == NUL) 6359 ml_set_crypt_key(buf, buf->b_p_key, oldval); 6360 } 6361 } 6362 } 6363 #endif 6364 6365 /* 'matchpairs' */ 6366 else if (gvarp == &p_mps) 6367 { 6368 #ifdef FEAT_MBYTE 6369 if (has_mbyte) 6370 { 6371 for (p = *varp; *p != NUL; ++p) 6372 { 6373 int x2 = -1; 6374 int x3 = -1; 6375 6376 if (*p != NUL) 6377 p += mb_ptr2len(p); 6378 if (*p != NUL) 6379 x2 = *p++; 6380 if (*p != NUL) 6381 { 6382 x3 = mb_ptr2char(p); 6383 p += mb_ptr2len(p); 6384 } 6385 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) 6386 { 6387 errmsg = e_invarg; 6388 break; 6389 } 6390 if (*p == NUL) 6391 break; 6392 } 6393 } 6394 else 6395 #endif 6396 { 6397 /* Check for "x:y,x:y" */ 6398 for (p = *varp; *p != NUL; p += 4) 6399 { 6400 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) 6401 { 6402 errmsg = e_invarg; 6403 break; 6404 } 6405 if (p[3] == NUL) 6406 break; 6407 } 6408 } 6409 } 6410 6411 #ifdef FEAT_COMMENTS 6412 /* 'comments' */ 6413 else if (gvarp == &p_com) 6414 { 6415 for (s = *varp; *s; ) 6416 { 6417 while (*s && *s != ':') 6418 { 6419 if (vim_strchr((char_u *)COM_ALL, *s) == NULL 6420 && !VIM_ISDIGIT(*s) && *s != '-') 6421 { 6422 errmsg = illegal_char(errbuf, *s); 6423 break; 6424 } 6425 ++s; 6426 } 6427 if (*s++ == NUL) 6428 errmsg = (char_u *)N_("E524: Missing colon"); 6429 else if (*s == ',' || *s == NUL) 6430 errmsg = (char_u *)N_("E525: Zero length string"); 6431 if (errmsg != NULL) 6432 break; 6433 while (*s && *s != ',') 6434 { 6435 if (*s == '\\' && s[1] != NUL) 6436 ++s; 6437 ++s; 6438 } 6439 s = skip_to_option_part(s); 6440 } 6441 } 6442 #endif 6443 6444 /* 'listchars' */ 6445 else if (varp == &p_lcs) 6446 { 6447 errmsg = set_chars_option(varp); 6448 } 6449 6450 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 6451 /* 'fillchars' */ 6452 else if (varp == &p_fcs) 6453 { 6454 errmsg = set_chars_option(varp); 6455 } 6456 #endif 6457 6458 #ifdef FEAT_CMDWIN 6459 /* 'cedit' */ 6460 else if (varp == &p_cedit) 6461 { 6462 errmsg = check_cedit(); 6463 } 6464 #endif 6465 6466 /* 'verbosefile' */ 6467 else if (varp == &p_vfile) 6468 { 6469 verbose_stop(); 6470 if (*p_vfile != NUL && verbose_open() == FAIL) 6471 errmsg = e_invarg; 6472 } 6473 6474 #ifdef FEAT_VIMINFO 6475 /* 'viminfo' */ 6476 else if (varp == &p_viminfo) 6477 { 6478 for (s = p_viminfo; *s;) 6479 { 6480 /* Check it's a valid character */ 6481 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) 6482 { 6483 errmsg = illegal_char(errbuf, *s); 6484 break; 6485 } 6486 if (*s == 'n') /* name is always last one */ 6487 { 6488 break; 6489 } 6490 else if (*s == 'r') /* skip until next ',' */ 6491 { 6492 while (*++s && *s != ',') 6493 ; 6494 } 6495 else if (*s == '%') 6496 { 6497 /* optional number */ 6498 while (vim_isdigit(*++s)) 6499 ; 6500 } 6501 else if (*s == '!' || *s == 'h' || *s == 'c') 6502 ++s; /* no extra chars */ 6503 else /* must have a number */ 6504 { 6505 while (vim_isdigit(*++s)) 6506 ; 6507 6508 if (!VIM_ISDIGIT(*(s - 1))) 6509 { 6510 if (errbuf != NULL) 6511 { 6512 sprintf((char *)errbuf, 6513 _("E526: Missing number after <%s>"), 6514 transchar_byte(*(s - 1))); 6515 errmsg = errbuf; 6516 } 6517 else 6518 errmsg = (char_u *)""; 6519 break; 6520 } 6521 } 6522 if (*s == ',') 6523 ++s; 6524 else if (*s) 6525 { 6526 if (errbuf != NULL) 6527 errmsg = (char_u *)N_("E527: Missing comma"); 6528 else 6529 errmsg = (char_u *)""; 6530 break; 6531 } 6532 } 6533 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) 6534 errmsg = (char_u *)N_("E528: Must specify a ' value"); 6535 } 6536 #endif /* FEAT_VIMINFO */ 6537 6538 /* terminal options */ 6539 else if (istermoption(&options[opt_idx]) && full_screen) 6540 { 6541 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ 6542 if (varp == &T_CCO) 6543 { 6544 int colors = atoi((char *)T_CCO); 6545 6546 /* Only reinitialize colors if t_Co value has really changed to 6547 * avoid expensive reload of colorscheme if t_Co is set to the 6548 * same value multiple times. */ 6549 if (colors != t_colors) 6550 { 6551 t_colors = colors; 6552 if (t_colors <= 1) 6553 { 6554 if (new_value_alloced) 6555 vim_free(T_CCO); 6556 T_CCO = empty_option; 6557 } 6558 /* We now have a different color setup, initialize it again. */ 6559 init_highlight(TRUE, FALSE); 6560 } 6561 } 6562 ttest(FALSE); 6563 if (varp == &T_ME) 6564 { 6565 out_str(T_ME); 6566 redraw_later(CLEAR); 6567 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32)) 6568 /* Since t_me has been set, this probably means that the user 6569 * wants to use this as default colors. Need to reset default 6570 * background/foreground colors. */ 6571 mch_set_normal_colors(); 6572 #endif 6573 } 6574 } 6575 6576 #ifdef FEAT_LINEBREAK 6577 /* 'showbreak' */ 6578 else if (varp == &p_sbr) 6579 { 6580 for (s = p_sbr; *s; ) 6581 { 6582 if (ptr2cells(s) != 1) 6583 errmsg = (char_u *)N_("E595: contains unprintable or wide character"); 6584 mb_ptr_adv(s); 6585 } 6586 } 6587 #endif 6588 6589 #ifdef FEAT_GUI 6590 /* 'guifont' */ 6591 else if (varp == &p_guifont) 6592 { 6593 if (gui.in_use) 6594 { 6595 p = p_guifont; 6596 # if defined(FEAT_GUI_GTK) 6597 /* 6598 * Put up a font dialog and let the user select a new value. 6599 * If this is cancelled go back to the old value but don't 6600 * give an error message. 6601 */ 6602 if (STRCMP(p, "*") == 0) 6603 { 6604 p = gui_mch_font_dialog(oldval); 6605 6606 if (new_value_alloced) 6607 free_string_option(p_guifont); 6608 6609 p_guifont = (p != NULL) ? p : vim_strsave(oldval); 6610 new_value_alloced = TRUE; 6611 } 6612 # endif 6613 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) 6614 { 6615 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) 6616 if (STRCMP(p_guifont, "*") == 0) 6617 { 6618 /* Dialog was cancelled: Keep the old value without giving 6619 * an error message. */ 6620 if (new_value_alloced) 6621 free_string_option(p_guifont); 6622 p_guifont = vim_strsave(oldval); 6623 new_value_alloced = TRUE; 6624 } 6625 else 6626 # endif 6627 errmsg = (char_u *)N_("E596: Invalid font(s)"); 6628 } 6629 } 6630 redraw_gui_only = TRUE; 6631 } 6632 # ifdef FEAT_XFONTSET 6633 else if (varp == &p_guifontset) 6634 { 6635 if (STRCMP(p_guifontset, "*") == 0) 6636 errmsg = (char_u *)N_("E597: can't select fontset"); 6637 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) 6638 errmsg = (char_u *)N_("E598: Invalid fontset"); 6639 redraw_gui_only = TRUE; 6640 } 6641 # endif 6642 # ifdef FEAT_MBYTE 6643 else if (varp == &p_guifontwide) 6644 { 6645 if (STRCMP(p_guifontwide, "*") == 0) 6646 errmsg = (char_u *)N_("E533: can't select wide font"); 6647 else if (gui_get_wide_font() == FAIL) 6648 errmsg = (char_u *)N_("E534: Invalid wide font"); 6649 redraw_gui_only = TRUE; 6650 } 6651 # endif 6652 #endif 6653 6654 #ifdef CURSOR_SHAPE 6655 /* 'guicursor' */ 6656 else if (varp == &p_guicursor) 6657 errmsg = parse_shape_opt(SHAPE_CURSOR); 6658 #endif 6659 6660 #ifdef FEAT_MOUSESHAPE 6661 /* 'mouseshape' */ 6662 else if (varp == &p_mouseshape) 6663 { 6664 errmsg = parse_shape_opt(SHAPE_MOUSE); 6665 update_mouseshape(-1); 6666 } 6667 #endif 6668 6669 #ifdef FEAT_PRINTER 6670 else if (varp == &p_popt) 6671 errmsg = parse_printoptions(); 6672 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT) 6673 else if (varp == &p_pmfn) 6674 errmsg = parse_printmbfont(); 6675 # endif 6676 #endif 6677 6678 #ifdef FEAT_LANGMAP 6679 /* 'langmap' */ 6680 else if (varp == &p_langmap) 6681 langmap_set(); 6682 #endif 6683 6684 #ifdef FEAT_LINEBREAK 6685 /* 'breakat' */ 6686 else if (varp == &p_breakat) 6687 fill_breakat_flags(); 6688 #endif 6689 6690 #ifdef FEAT_TITLE 6691 /* 'titlestring' and 'iconstring' */ 6692 else if (varp == &p_titlestring || varp == &p_iconstring) 6693 { 6694 # ifdef FEAT_STL_OPT 6695 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; 6696 6697 /* NULL => statusline syntax */ 6698 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) 6699 stl_syntax |= flagval; 6700 else 6701 stl_syntax &= ~flagval; 6702 # endif 6703 did_set_title(varp == &p_iconstring); 6704 6705 } 6706 #endif 6707 6708 #ifdef FEAT_GUI 6709 /* 'guioptions' */ 6710 else if (varp == &p_go) 6711 { 6712 gui_init_which_components(oldval); 6713 redraw_gui_only = TRUE; 6714 } 6715 #endif 6716 6717 #if defined(FEAT_GUI_TABLINE) 6718 /* 'guitablabel' */ 6719 else if (varp == &p_gtl) 6720 { 6721 redraw_tabline = TRUE; 6722 redraw_gui_only = TRUE; 6723 } 6724 /* 'guitabtooltip' */ 6725 else if (varp == &p_gtt) 6726 { 6727 redraw_gui_only = TRUE; 6728 } 6729 #endif 6730 6731 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) 6732 /* 'ttymouse' */ 6733 else if (varp == &p_ttym) 6734 { 6735 /* Switch the mouse off before changing the escape sequences used for 6736 * that. */ 6737 mch_setmouse(FALSE); 6738 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) 6739 errmsg = e_invarg; 6740 else 6741 check_mouse_termcode(); 6742 if (termcap_active) 6743 setmouse(); /* may switch it on again */ 6744 } 6745 #endif 6746 6747 /* 'selection' */ 6748 else if (varp == &p_sel) 6749 { 6750 if (*p_sel == NUL 6751 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) 6752 errmsg = e_invarg; 6753 } 6754 6755 /* 'selectmode' */ 6756 else if (varp == &p_slm) 6757 { 6758 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) 6759 errmsg = e_invarg; 6760 } 6761 6762 #ifdef FEAT_BROWSE 6763 /* 'browsedir' */ 6764 else if (varp == &p_bsdir) 6765 { 6766 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK 6767 && !mch_isdir(p_bsdir)) 6768 errmsg = e_invarg; 6769 } 6770 #endif 6771 6772 /* 'keymodel' */ 6773 else if (varp == &p_km) 6774 { 6775 if (check_opt_strings(p_km, p_km_values, TRUE) != OK) 6776 errmsg = e_invarg; 6777 else 6778 { 6779 km_stopsel = (vim_strchr(p_km, 'o') != NULL); 6780 km_startsel = (vim_strchr(p_km, 'a') != NULL); 6781 } 6782 } 6783 6784 /* 'mousemodel' */ 6785 else if (varp == &p_mousem) 6786 { 6787 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) 6788 errmsg = e_invarg; 6789 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) 6790 else if (*p_mousem != *oldval) 6791 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need 6792 * to create or delete the popup menus. */ 6793 gui_motif_update_mousemodel(root_menu); 6794 #endif 6795 } 6796 6797 /* 'switchbuf' */ 6798 else if (varp == &p_swb) 6799 { 6800 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK) 6801 errmsg = e_invarg; 6802 } 6803 6804 /* 'debug' */ 6805 else if (varp == &p_debug) 6806 { 6807 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK) 6808 errmsg = e_invarg; 6809 } 6810 6811 /* 'display' */ 6812 else if (varp == &p_dy) 6813 { 6814 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) 6815 errmsg = e_invarg; 6816 else 6817 (void)init_chartab(); 6818 6819 } 6820 6821 #ifdef FEAT_VERTSPLIT 6822 /* 'eadirection' */ 6823 else if (varp == &p_ead) 6824 { 6825 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) 6826 errmsg = e_invarg; 6827 } 6828 #endif 6829 6830 #ifdef FEAT_CLIPBOARD 6831 /* 'clipboard' */ 6832 else if (varp == &p_cb) 6833 errmsg = check_clipboard_option(); 6834 #endif 6835 6836 #ifdef FEAT_SPELL 6837 /* When 'spelllang' or 'spellfile' is set and there is a window for this 6838 * buffer in which 'spell' is set load the wordlists. */ 6839 else if (varp == &(curwin->w_s->b_p_spl) 6840 || varp == &(curwin->w_s->b_p_spf)) 6841 { 6842 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf)); 6843 } 6844 /* When 'spellcapcheck' is set compile the regexp program. */ 6845 else if (varp == &(curwin->w_s->b_p_spc)) 6846 { 6847 errmsg = compile_cap_prog(curwin->w_s); 6848 } 6849 /* 'spellsuggest' */ 6850 else if (varp == &p_sps) 6851 { 6852 if (spell_check_sps() != OK) 6853 errmsg = e_invarg; 6854 } 6855 /* 'mkspellmem' */ 6856 else if (varp == &p_msm) 6857 { 6858 if (spell_check_msm() != OK) 6859 errmsg = e_invarg; 6860 } 6861 #endif 6862 6863 #ifdef FEAT_QUICKFIX 6864 /* When 'bufhidden' is set, check for valid value. */ 6865 else if (gvarp == &p_bh) 6866 { 6867 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) 6868 errmsg = e_invarg; 6869 } 6870 6871 /* When 'buftype' is set, check for valid value. */ 6872 else if (gvarp == &p_bt) 6873 { 6874 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) 6875 errmsg = e_invarg; 6876 else 6877 { 6878 # ifdef FEAT_WINDOWS 6879 if (curwin->w_status_height) 6880 { 6881 curwin->w_redr_status = TRUE; 6882 redraw_later(VALID); 6883 } 6884 # endif 6885 curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); 6886 # ifdef FEAT_TITLE 6887 redraw_titles(); 6888 # endif 6889 } 6890 } 6891 #endif 6892 6893 #ifdef FEAT_STL_OPT 6894 /* 'statusline' or 'rulerformat' */ 6895 else if (gvarp == &p_stl || varp == &p_ruf) 6896 { 6897 int wid; 6898 6899 if (varp == &p_ruf) /* reset ru_wid first */ 6900 ru_wid = 0; 6901 s = *varp; 6902 if (varp == &p_ruf && *s == '%') 6903 { 6904 /* set ru_wid if 'ruf' starts with "%99(" */ 6905 if (*++s == '-') /* ignore a '-' */ 6906 s++; 6907 wid = getdigits(&s); 6908 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) 6909 ru_wid = wid; 6910 else 6911 errmsg = check_stl_option(p_ruf); 6912 } 6913 /* check 'statusline' only if it doesn't start with "%!" */ 6914 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') 6915 errmsg = check_stl_option(s); 6916 if (varp == &p_ruf && errmsg == NULL) 6917 comp_col(); 6918 } 6919 #endif 6920 6921 #ifdef FEAT_INS_EXPAND 6922 /* check if it is a valid value for 'complete' -- Acevedo */ 6923 else if (gvarp == &p_cpt) 6924 { 6925 for (s = *varp; *s;) 6926 { 6927 while (*s == ',' || *s == ' ') 6928 s++; 6929 if (!*s) 6930 break; 6931 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) 6932 { 6933 errmsg = illegal_char(errbuf, *s); 6934 break; 6935 } 6936 if (*++s != NUL && *s != ',' && *s != ' ') 6937 { 6938 if (s[-1] == 'k' || s[-1] == 's') 6939 { 6940 /* skip optional filename after 'k' and 's' */ 6941 while (*s && *s != ',' && *s != ' ') 6942 { 6943 if (*s == '\\') 6944 ++s; 6945 ++s; 6946 } 6947 } 6948 else 6949 { 6950 if (errbuf != NULL) 6951 { 6952 sprintf((char *)errbuf, 6953 _("E535: Illegal character after <%c>"), 6954 *--s); 6955 errmsg = errbuf; 6956 } 6957 else 6958 errmsg = (char_u *)""; 6959 break; 6960 } 6961 } 6962 } 6963 } 6964 6965 /* 'completeopt' */ 6966 else if (varp == &p_cot) 6967 { 6968 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK) 6969 errmsg = e_invarg; 6970 } 6971 #endif /* FEAT_INS_EXPAND */ 6972 6973 6974 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 6975 else if (varp == &p_toolbar) 6976 { 6977 if (opt_strings_flags(p_toolbar, p_toolbar_values, 6978 &toolbar_flags, TRUE) != OK) 6979 errmsg = e_invarg; 6980 else 6981 { 6982 out_flush(); 6983 gui_mch_show_toolbar((toolbar_flags & 6984 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); 6985 } 6986 } 6987 #endif 6988 6989 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) 6990 /* 'toolbariconsize': GTK+ 2 only */ 6991 else if (varp == &p_tbis) 6992 { 6993 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) 6994 errmsg = e_invarg; 6995 else 6996 { 6997 out_flush(); 6998 gui_mch_show_toolbar((toolbar_flags & 6999 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); 7000 } 7001 } 7002 #endif 7003 7004 /* 'pastetoggle': translate key codes like in a mapping */ 7005 else if (varp == &p_pt) 7006 { 7007 if (*p_pt) 7008 { 7009 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE); 7010 if (p != NULL) 7011 { 7012 if (new_value_alloced) 7013 free_string_option(p_pt); 7014 p_pt = p; 7015 new_value_alloced = TRUE; 7016 } 7017 } 7018 } 7019 7020 /* 'backspace' */ 7021 else if (varp == &p_bs) 7022 { 7023 if (VIM_ISDIGIT(*p_bs)) 7024 { 7025 if (*p_bs > '2' || p_bs[1] != NUL) 7026 errmsg = e_invarg; 7027 } 7028 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) 7029 errmsg = e_invarg; 7030 } 7031 else if (varp == &p_bo) 7032 { 7033 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK) 7034 errmsg = e_invarg; 7035 } 7036 7037 /* 'tagcase' */ 7038 else if (gvarp == &p_tc) 7039 { 7040 unsigned int *flags; 7041 7042 if (opt_flags & OPT_LOCAL) 7043 { 7044 p = curbuf->b_p_tc; 7045 flags = &curbuf->b_tc_flags; 7046 } 7047 else 7048 { 7049 p = p_tc; 7050 flags = &tc_flags; 7051 } 7052 7053 if ((opt_flags & OPT_LOCAL) && *p == NUL) 7054 /* make the local value empty: use the global value */ 7055 *flags = 0; 7056 else if (*p == NUL 7057 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK) 7058 errmsg = e_invarg; 7059 } 7060 7061 #ifdef FEAT_MBYTE 7062 /* 'casemap' */ 7063 else if (varp == &p_cmp) 7064 { 7065 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) 7066 errmsg = e_invarg; 7067 } 7068 #endif 7069 7070 #ifdef FEAT_DIFF 7071 /* 'diffopt' */ 7072 else if (varp == &p_dip) 7073 { 7074 if (diffopt_changed() == FAIL) 7075 errmsg = e_invarg; 7076 } 7077 #endif 7078 7079 #ifdef FEAT_FOLDING 7080 /* 'foldmethod' */ 7081 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) 7082 { 7083 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK 7084 || *curwin->w_p_fdm == NUL) 7085 errmsg = e_invarg; 7086 else 7087 { 7088 foldUpdateAll(curwin); 7089 if (foldmethodIsDiff(curwin)) 7090 newFoldLevel(); 7091 } 7092 } 7093 # ifdef FEAT_EVAL 7094 /* 'foldexpr' */ 7095 else if (varp == &curwin->w_p_fde) 7096 { 7097 if (foldmethodIsExpr(curwin)) 7098 foldUpdateAll(curwin); 7099 } 7100 # endif 7101 /* 'foldmarker' */ 7102 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) 7103 { 7104 p = vim_strchr(*varp, ','); 7105 if (p == NULL) 7106 errmsg = (char_u *)N_("E536: comma required"); 7107 else if (p == *varp || p[1] == NUL) 7108 errmsg = e_invarg; 7109 else if (foldmethodIsMarker(curwin)) 7110 foldUpdateAll(curwin); 7111 } 7112 /* 'commentstring' */ 7113 else if (gvarp == &p_cms) 7114 { 7115 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) 7116 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s"); 7117 } 7118 /* 'foldopen' */ 7119 else if (varp == &p_fdo) 7120 { 7121 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) 7122 errmsg = e_invarg; 7123 } 7124 /* 'foldclose' */ 7125 else if (varp == &p_fcl) 7126 { 7127 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) 7128 errmsg = e_invarg; 7129 } 7130 /* 'foldignore' */ 7131 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi) 7132 { 7133 if (foldmethodIsIndent(curwin)) 7134 foldUpdateAll(curwin); 7135 } 7136 #endif 7137 7138 #ifdef FEAT_VIRTUALEDIT 7139 /* 'virtualedit' */ 7140 else if (varp == &p_ve) 7141 { 7142 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK) 7143 errmsg = e_invarg; 7144 else if (STRCMP(p_ve, oldval) != 0) 7145 { 7146 /* Recompute cursor position in case the new 've' setting 7147 * changes something. */ 7148 validate_virtcol(); 7149 coladvance(curwin->w_virtcol); 7150 } 7151 } 7152 #endif 7153 7154 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) 7155 else if (varp == &p_csqf) 7156 { 7157 if (p_csqf != NULL) 7158 { 7159 p = p_csqf; 7160 while (*p != NUL) 7161 { 7162 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL 7163 || p[1] == NUL 7164 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL 7165 || (p[2] != NUL && p[2] != ',')) 7166 { 7167 errmsg = e_invarg; 7168 break; 7169 } 7170 else if (p[2] == NUL) 7171 break; 7172 else 7173 p += 3; 7174 } 7175 } 7176 } 7177 #endif 7178 7179 #ifdef FEAT_CINDENT 7180 /* 'cinoptions' */ 7181 else if (gvarp == &p_cino) 7182 { 7183 /* TODO: recognize errors */ 7184 parse_cino(curbuf); 7185 } 7186 #endif 7187 7188 #if defined(FEAT_RENDER_OPTIONS) 7189 else if (varp == &p_rop && gui.in_use) 7190 { 7191 if (!gui_mch_set_rendering_options(p_rop)) 7192 errmsg = e_invarg; 7193 } 7194 #endif 7195 7196 /* Options that are a list of flags. */ 7197 else 7198 { 7199 p = NULL; 7200 if (varp == &p_ww) 7201 p = (char_u *)WW_ALL; 7202 if (varp == &p_shm) 7203 p = (char_u *)SHM_ALL; 7204 else if (varp == &(p_cpo)) 7205 p = (char_u *)CPO_ALL; 7206 else if (varp == &(curbuf->b_p_fo)) 7207 p = (char_u *)FO_ALL; 7208 #ifdef FEAT_CONCEAL 7209 else if (varp == &curwin->w_p_cocu) 7210 p = (char_u *)COCU_ALL; 7211 #endif 7212 else if (varp == &p_mouse) 7213 { 7214 #ifdef FEAT_MOUSE 7215 p = (char_u *)MOUSE_ALL; 7216 #else 7217 if (*p_mouse != NUL) 7218 errmsg = (char_u *)N_("E538: No mouse support"); 7219 #endif 7220 } 7221 #if defined(FEAT_GUI) 7222 else if (varp == &p_go) 7223 p = (char_u *)GO_ALL; 7224 #endif 7225 if (p != NULL) 7226 { 7227 for (s = *varp; *s; ++s) 7228 if (vim_strchr(p, *s) == NULL) 7229 { 7230 errmsg = illegal_char(errbuf, *s); 7231 break; 7232 } 7233 } 7234 } 7235 7236 /* 7237 * If error detected, restore the previous value. 7238 */ 7239 if (errmsg != NULL) 7240 { 7241 if (new_value_alloced) 7242 free_string_option(*varp); 7243 *varp = oldval; 7244 /* 7245 * When resetting some values, need to act on it. 7246 */ 7247 if (did_chartab) 7248 (void)init_chartab(); 7249 if (varp == &p_hl) 7250 (void)highlight_changed(); 7251 } 7252 else 7253 { 7254 #ifdef FEAT_EVAL 7255 /* Remember where the option was set. */ 7256 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 7257 #endif 7258 /* 7259 * Free string options that are in allocated memory. 7260 * Use "free_oldval", because recursiveness may change the flags under 7261 * our fingers (esp. init_highlight()). 7262 */ 7263 if (free_oldval) 7264 free_string_option(oldval); 7265 if (new_value_alloced) 7266 options[opt_idx].flags |= P_ALLOCED; 7267 else 7268 options[opt_idx].flags &= ~P_ALLOCED; 7269 7270 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 7271 && ((int)options[opt_idx].indir & PV_BOTH)) 7272 { 7273 /* global option with local value set to use global value; free 7274 * the local value and make it empty */ 7275 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); 7276 free_string_option(*(char_u **)p); 7277 *(char_u **)p = empty_option; 7278 } 7279 7280 /* May set global value for local option. */ 7281 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) 7282 set_string_option_global(opt_idx, varp); 7283 7284 #ifdef FEAT_AUTOCMD 7285 /* 7286 * Trigger the autocommand only after setting the flags. 7287 */ 7288 # ifdef FEAT_SYN_HL 7289 /* When 'syntax' is set, load the syntax of that name */ 7290 if (varp == &(curbuf->b_p_syn)) 7291 { 7292 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, 7293 curbuf->b_fname, TRUE, curbuf); 7294 } 7295 # endif 7296 else if (varp == &(curbuf->b_p_ft)) 7297 { 7298 /* 'filetype' is set, trigger the FileType autocommand */ 7299 did_filetype = TRUE; 7300 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, 7301 curbuf->b_fname, TRUE, curbuf); 7302 } 7303 #endif 7304 #ifdef FEAT_SPELL 7305 if (varp == &(curwin->w_s->b_p_spl)) 7306 { 7307 char_u fname[200]; 7308 char_u *q = curwin->w_s->b_p_spl; 7309 7310 /* Skip the first name if it is "cjk". */ 7311 if (STRNCMP(q, "cjk,", 4) == 0) 7312 q += 4; 7313 7314 /* 7315 * Source the spell/LANG.vim in 'runtimepath'. 7316 * They could set 'spellcapcheck' depending on the language. 7317 * Use the first name in 'spelllang' up to '_region' or 7318 * '.encoding'. 7319 */ 7320 for (p = q; *p != NUL; ++p) 7321 if (vim_strchr((char_u *)"_.,", *p) != NULL) 7322 break; 7323 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); 7324 source_runtime(fname, TRUE); 7325 } 7326 #endif 7327 } 7328 7329 #ifdef FEAT_MOUSE 7330 if (varp == &p_mouse) 7331 { 7332 # ifdef FEAT_MOUSE_TTY 7333 if (*p_mouse == NUL) 7334 mch_setmouse(FALSE); /* switch mouse off */ 7335 else 7336 # endif 7337 setmouse(); /* in case 'mouse' changed */ 7338 } 7339 #endif 7340 7341 if (curwin->w_curswant != MAXCOL 7342 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) 7343 curwin->w_set_curswant = TRUE; 7344 7345 #ifdef FEAT_GUI 7346 /* check redraw when it's not a GUI option or the GUI is active. */ 7347 if (!redraw_gui_only || gui.in_use) 7348 #endif 7349 check_redraw(options[opt_idx].flags); 7350 7351 return errmsg; 7352 } 7353 7354 #if defined(FEAT_SYN_HL) || defined(PROTO) 7355 /* 7356 * Simple int comparison function for use with qsort() 7357 */ 7358 static int 7359 int_cmp(a, b) 7360 const void *a; 7361 const void *b; 7362 { 7363 return *(const int *)a - *(const int *)b; 7364 } 7365 7366 /* 7367 * Handle setting 'colorcolumn' or 'textwidth' in window "wp". 7368 * Returns error message, NULL if it's OK. 7369 */ 7370 char_u * 7371 check_colorcolumn(wp) 7372 win_T *wp; 7373 { 7374 char_u *s; 7375 int col; 7376 int count = 0; 7377 int color_cols[256]; 7378 int i; 7379 int j = 0; 7380 7381 if (wp->w_buffer == NULL) 7382 return NULL; /* buffer was closed */ 7383 7384 for (s = wp->w_p_cc; *s != NUL && count < 255;) 7385 { 7386 if (*s == '-' || *s == '+') 7387 { 7388 /* -N and +N: add to 'textwidth' */ 7389 col = (*s == '-') ? -1 : 1; 7390 ++s; 7391 if (!VIM_ISDIGIT(*s)) 7392 return e_invarg; 7393 col = col * getdigits(&s); 7394 if (wp->w_buffer->b_p_tw == 0) 7395 goto skip; /* 'textwidth' not set, skip this item */ 7396 col += wp->w_buffer->b_p_tw; 7397 if (col < 0) 7398 goto skip; 7399 } 7400 else if (VIM_ISDIGIT(*s)) 7401 col = getdigits(&s); 7402 else 7403 return e_invarg; 7404 color_cols[count++] = col - 1; /* 1-based to 0-based */ 7405 skip: 7406 if (*s == NUL) 7407 break; 7408 if (*s != ',') 7409 return e_invarg; 7410 if (*++s == NUL) 7411 return e_invarg; /* illegal trailing comma as in "set cc=80," */ 7412 } 7413 7414 vim_free(wp->w_p_cc_cols); 7415 if (count == 0) 7416 wp->w_p_cc_cols = NULL; 7417 else 7418 { 7419 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1)); 7420 if (wp->w_p_cc_cols != NULL) 7421 { 7422 /* sort the columns for faster usage on screen redraw inside 7423 * win_line() */ 7424 qsort(color_cols, count, sizeof(int), int_cmp); 7425 7426 for (i = 0; i < count; ++i) 7427 /* skip duplicates */ 7428 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) 7429 wp->w_p_cc_cols[j++] = color_cols[i]; 7430 wp->w_p_cc_cols[j] = -1; /* end marker */ 7431 } 7432 } 7433 7434 return NULL; /* no error */ 7435 } 7436 #endif 7437 7438 /* 7439 * Handle setting 'listchars' or 'fillchars'. 7440 * Returns error message, NULL if it's OK. 7441 */ 7442 static char_u * 7443 set_chars_option(varp) 7444 char_u **varp; 7445 { 7446 int round, i, len, entries; 7447 char_u *p, *s; 7448 int c1, c2 = 0; 7449 struct charstab 7450 { 7451 int *cp; 7452 char *name; 7453 }; 7454 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 7455 static struct charstab filltab[] = 7456 { 7457 {&fill_stl, "stl"}, 7458 {&fill_stlnc, "stlnc"}, 7459 {&fill_vert, "vert"}, 7460 {&fill_fold, "fold"}, 7461 {&fill_diff, "diff"}, 7462 }; 7463 #endif 7464 static struct charstab lcstab[] = 7465 { 7466 {&lcs_eol, "eol"}, 7467 {&lcs_ext, "extends"}, 7468 {&lcs_nbsp, "nbsp"}, 7469 {&lcs_prec, "precedes"}, 7470 {&lcs_space, "space"}, 7471 {&lcs_tab2, "tab"}, 7472 {&lcs_trail, "trail"}, 7473 #ifdef FEAT_CONCEAL 7474 {&lcs_conceal, "conceal"}, 7475 #else 7476 {NULL, "conceal"}, 7477 #endif 7478 }; 7479 struct charstab *tab; 7480 7481 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 7482 if (varp == &p_lcs) 7483 #endif 7484 { 7485 tab = lcstab; 7486 entries = sizeof(lcstab) / sizeof(struct charstab); 7487 } 7488 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 7489 else 7490 { 7491 tab = filltab; 7492 entries = sizeof(filltab) / sizeof(struct charstab); 7493 } 7494 #endif 7495 7496 /* first round: check for valid value, second round: assign values */ 7497 for (round = 0; round <= 1; ++round) 7498 { 7499 if (round > 0) 7500 { 7501 /* After checking that the value is valid: set defaults: space for 7502 * 'fillchars', NUL for 'listchars' */ 7503 for (i = 0; i < entries; ++i) 7504 if (tab[i].cp != NULL) 7505 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); 7506 if (varp == &p_lcs) 7507 lcs_tab1 = NUL; 7508 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING) 7509 else 7510 fill_diff = '-'; 7511 #endif 7512 } 7513 p = *varp; 7514 while (*p) 7515 { 7516 for (i = 0; i < entries; ++i) 7517 { 7518 len = (int)STRLEN(tab[i].name); 7519 if (STRNCMP(p, tab[i].name, len) == 0 7520 && p[len] == ':' 7521 && p[len + 1] != NUL) 7522 { 7523 s = p + len + 1; 7524 #ifdef FEAT_MBYTE 7525 c1 = mb_ptr2char_adv(&s); 7526 if (mb_char2cells(c1) > 1) 7527 continue; 7528 #else 7529 c1 = *s++; 7530 #endif 7531 if (tab[i].cp == &lcs_tab2) 7532 { 7533 if (*s == NUL) 7534 continue; 7535 #ifdef FEAT_MBYTE 7536 c2 = mb_ptr2char_adv(&s); 7537 if (mb_char2cells(c2) > 1) 7538 continue; 7539 #else 7540 c2 = *s++; 7541 #endif 7542 } 7543 if (*s == ',' || *s == NUL) 7544 { 7545 if (round) 7546 { 7547 if (tab[i].cp == &lcs_tab2) 7548 { 7549 lcs_tab1 = c1; 7550 lcs_tab2 = c2; 7551 } 7552 else if (tab[i].cp != NULL) 7553 *(tab[i].cp) = c1; 7554 7555 } 7556 p = s; 7557 break; 7558 } 7559 } 7560 } 7561 7562 if (i == entries) 7563 return e_invarg; 7564 if (*p == ',') 7565 ++p; 7566 } 7567 } 7568 7569 return NULL; /* no error */ 7570 } 7571 7572 #ifdef FEAT_STL_OPT 7573 /* 7574 * Check validity of options with the 'statusline' format. 7575 * Return error message or NULL. 7576 */ 7577 char_u * 7578 check_stl_option(s) 7579 char_u *s; 7580 { 7581 int itemcnt = 0; 7582 int groupdepth = 0; 7583 static char_u errbuf[80]; 7584 7585 while (*s && itemcnt < STL_MAX_ITEM) 7586 { 7587 /* Check for valid keys after % sequences */ 7588 while (*s && *s != '%') 7589 s++; 7590 if (!*s) 7591 break; 7592 s++; 7593 if (*s != '%' && *s != ')') 7594 ++itemcnt; 7595 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK) 7596 { 7597 s++; 7598 continue; 7599 } 7600 if (*s == ')') 7601 { 7602 s++; 7603 if (--groupdepth < 0) 7604 break; 7605 continue; 7606 } 7607 if (*s == '-') 7608 s++; 7609 while (VIM_ISDIGIT(*s)) 7610 s++; 7611 if (*s == STL_USER_HL) 7612 continue; 7613 if (*s == '.') 7614 { 7615 s++; 7616 while (*s && VIM_ISDIGIT(*s)) 7617 s++; 7618 } 7619 if (*s == '(') 7620 { 7621 groupdepth++; 7622 continue; 7623 } 7624 if (vim_strchr(STL_ALL, *s) == NULL) 7625 { 7626 return illegal_char(errbuf, *s); 7627 } 7628 if (*s == '{') 7629 { 7630 s++; 7631 while (*s != '}' && *s) 7632 s++; 7633 if (*s != '}') 7634 return (char_u *)N_("E540: Unclosed expression sequence"); 7635 } 7636 } 7637 if (itemcnt >= STL_MAX_ITEM) 7638 return (char_u *)N_("E541: too many items"); 7639 if (groupdepth != 0) 7640 return (char_u *)N_("E542: unbalanced groups"); 7641 return NULL; 7642 } 7643 #endif 7644 7645 #ifdef FEAT_CLIPBOARD 7646 /* 7647 * Extract the items in the 'clipboard' option and set global values. 7648 */ 7649 static char_u * 7650 check_clipboard_option() 7651 { 7652 int new_unnamed = 0; 7653 int new_autoselect_star = FALSE; 7654 int new_autoselect_plus = FALSE; 7655 int new_autoselectml = FALSE; 7656 int new_html = FALSE; 7657 regprog_T *new_exclude_prog = NULL; 7658 char_u *errmsg = NULL; 7659 char_u *p; 7660 7661 for (p = p_cb; *p != NUL; ) 7662 { 7663 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) 7664 { 7665 new_unnamed |= CLIP_UNNAMED; 7666 p += 7; 7667 } 7668 else if (STRNCMP(p, "unnamedplus", 11) == 0 7669 && (p[11] == ',' || p[11] == NUL)) 7670 { 7671 new_unnamed |= CLIP_UNNAMED_PLUS; 7672 p += 11; 7673 } 7674 else if (STRNCMP(p, "autoselect", 10) == 0 7675 && (p[10] == ',' || p[10] == NUL)) 7676 { 7677 new_autoselect_star = TRUE; 7678 p += 10; 7679 } 7680 else if (STRNCMP(p, "autoselectplus", 14) == 0 7681 && (p[14] == ',' || p[14] == NUL)) 7682 { 7683 new_autoselect_plus = TRUE; 7684 p += 14; 7685 } 7686 else if (STRNCMP(p, "autoselectml", 12) == 0 7687 && (p[12] == ',' || p[12] == NUL)) 7688 { 7689 new_autoselectml = TRUE; 7690 p += 12; 7691 } 7692 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL)) 7693 { 7694 new_html = TRUE; 7695 p += 4; 7696 } 7697 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) 7698 { 7699 p += 8; 7700 new_exclude_prog = vim_regcomp(p, RE_MAGIC); 7701 if (new_exclude_prog == NULL) 7702 errmsg = e_invarg; 7703 break; 7704 } 7705 else 7706 { 7707 errmsg = e_invarg; 7708 break; 7709 } 7710 if (*p == ',') 7711 ++p; 7712 } 7713 if (errmsg == NULL) 7714 { 7715 clip_unnamed = new_unnamed; 7716 clip_autoselect_star = new_autoselect_star; 7717 clip_autoselect_plus = new_autoselect_plus; 7718 clip_autoselectml = new_autoselectml; 7719 clip_html = new_html; 7720 vim_regfree(clip_exclude_prog); 7721 clip_exclude_prog = new_exclude_prog; 7722 #ifdef FEAT_GUI_GTK 7723 if (gui.in_use) 7724 { 7725 gui_gtk_set_selection_targets(); 7726 gui_gtk_set_dnd_targets(); 7727 } 7728 #endif 7729 } 7730 else 7731 vim_regfree(new_exclude_prog); 7732 7733 return errmsg; 7734 } 7735 #endif 7736 7737 #ifdef FEAT_SPELL 7738 static char_u * 7739 did_set_spell_option(is_spellfile) 7740 int is_spellfile; 7741 { 7742 char_u *errmsg = NULL; 7743 win_T *wp; 7744 int l; 7745 7746 if (is_spellfile) 7747 { 7748 l = (int)STRLEN(curwin->w_s->b_p_spf); 7749 if (l > 0 && (l < 4 7750 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0)) 7751 errmsg = e_invarg; 7752 } 7753 7754 if (errmsg == NULL) 7755 { 7756 FOR_ALL_WINDOWS(wp) 7757 if (wp->w_buffer == curbuf && wp->w_p_spell) 7758 { 7759 errmsg = did_set_spelllang(wp); 7760 # ifdef FEAT_WINDOWS 7761 break; 7762 # endif 7763 } 7764 } 7765 return errmsg; 7766 } 7767 7768 /* 7769 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'. 7770 * Return error message when failed, NULL when OK. 7771 */ 7772 static char_u * 7773 compile_cap_prog(synblock) 7774 synblock_T *synblock; 7775 { 7776 regprog_T *rp = synblock->b_cap_prog; 7777 char_u *re; 7778 7779 if (*synblock->b_p_spc == NUL) 7780 synblock->b_cap_prog = NULL; 7781 else 7782 { 7783 /* Prepend a ^ so that we only match at one column */ 7784 re = concat_str((char_u *)"^", synblock->b_p_spc); 7785 if (re != NULL) 7786 { 7787 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC); 7788 vim_free(re); 7789 if (synblock->b_cap_prog == NULL) 7790 { 7791 synblock->b_cap_prog = rp; /* restore the previous program */ 7792 return e_invarg; 7793 } 7794 } 7795 } 7796 7797 vim_regfree(rp); 7798 return NULL; 7799 } 7800 #endif 7801 7802 #if defined(FEAT_EVAL) || defined(PROTO) 7803 /* 7804 * Set the scriptID for an option, taking care of setting the buffer- or 7805 * window-local value. 7806 */ 7807 static void 7808 set_option_scriptID_idx(opt_idx, opt_flags, id) 7809 int opt_idx; 7810 int opt_flags; 7811 int id; 7812 { 7813 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; 7814 int indir = (int)options[opt_idx].indir; 7815 7816 /* Remember where the option was set. For local options need to do that 7817 * in the buffer or window structure. */ 7818 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) 7819 options[opt_idx].scriptID = id; 7820 if (both || (opt_flags & OPT_LOCAL)) 7821 { 7822 if (indir & PV_BUF) 7823 curbuf->b_p_scriptID[indir & PV_MASK] = id; 7824 else if (indir & PV_WIN) 7825 curwin->w_p_scriptID[indir & PV_MASK] = id; 7826 } 7827 } 7828 #endif 7829 7830 /* 7831 * Set the value of a boolean option, and take care of side effects. 7832 * Returns NULL for success, or an error message for an error. 7833 */ 7834 static char_u * 7835 set_bool_option(opt_idx, varp, value, opt_flags) 7836 int opt_idx; /* index in options[] table */ 7837 char_u *varp; /* pointer to the option variable */ 7838 int value; /* new value */ 7839 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ 7840 { 7841 int old_value = *(int *)varp; 7842 7843 /* Disallow changing some options from secure mode */ 7844 if ((secure 7845 #ifdef HAVE_SANDBOX 7846 || sandbox != 0 7847 #endif 7848 ) && (options[opt_idx].flags & P_SECURE)) 7849 return e_secure; 7850 7851 *(int *)varp = value; /* set the new value */ 7852 #ifdef FEAT_EVAL 7853 /* Remember where the option was set. */ 7854 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 7855 #endif 7856 7857 #ifdef FEAT_GUI 7858 need_mouse_correct = TRUE; 7859 #endif 7860 7861 /* May set global value for local option. */ 7862 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) 7863 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; 7864 7865 /* 7866 * Handle side effects of changing a bool option. 7867 */ 7868 7869 /* 'compatible' */ 7870 if ((int *)varp == &p_cp) 7871 { 7872 compatible_set(); 7873 } 7874 7875 #ifdef FEAT_PERSISTENT_UNDO 7876 /* 'undofile' */ 7877 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) 7878 { 7879 /* Only take action when the option was set. When reset we do not 7880 * delete the undo file, the option may be set again without making 7881 * any changes in between. */ 7882 if (curbuf->b_p_udf || p_udf) 7883 { 7884 char_u hash[UNDO_HASH_SIZE]; 7885 buf_T *save_curbuf = curbuf; 7886 7887 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next) 7888 { 7889 /* When 'undofile' is set globally: for every buffer, otherwise 7890 * only for the current buffer: Try to read in the undofile, 7891 * if one exists, the buffer wasn't changed and the buffer was 7892 * loaded */ 7893 if ((curbuf == save_curbuf 7894 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) 7895 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) 7896 { 7897 u_compute_hash(hash); 7898 u_read_undo(NULL, hash, curbuf->b_fname); 7899 } 7900 } 7901 curbuf = save_curbuf; 7902 } 7903 } 7904 #endif 7905 7906 else if ((int *)varp == &curbuf->b_p_ro) 7907 { 7908 /* when 'readonly' is reset globally, also reset readonlymode */ 7909 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) 7910 readonlymode = FALSE; 7911 7912 /* when 'readonly' is set may give W10 again */ 7913 if (curbuf->b_p_ro) 7914 curbuf->b_did_warn = FALSE; 7915 7916 #ifdef FEAT_TITLE 7917 redraw_titles(); 7918 #endif 7919 } 7920 7921 #ifdef FEAT_GUI 7922 else if ((int *)varp == &p_mh) 7923 { 7924 if (!p_mh) 7925 gui_mch_mousehide(FALSE); 7926 } 7927 #endif 7928 7929 #ifdef FEAT_TITLE 7930 /* when 'modifiable' is changed, redraw the window title */ 7931 else if ((int *)varp == &curbuf->b_p_ma) 7932 { 7933 redraw_titles(); 7934 } 7935 /* when 'endofline' is changed, redraw the window title */ 7936 else if ((int *)varp == &curbuf->b_p_eol) 7937 { 7938 redraw_titles(); 7939 } 7940 /* when 'fixeol' is changed, redraw the window title */ 7941 else if ((int *)varp == &curbuf->b_p_fixeol) 7942 { 7943 redraw_titles(); 7944 } 7945 # ifdef FEAT_MBYTE 7946 /* when 'bomb' is changed, redraw the window title and tab page text */ 7947 else if ((int *)varp == &curbuf->b_p_bomb) 7948 { 7949 redraw_titles(); 7950 } 7951 # endif 7952 #endif 7953 7954 /* when 'bin' is set also set some other options */ 7955 else if ((int *)varp == &curbuf->b_p_bin) 7956 { 7957 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); 7958 #ifdef FEAT_TITLE 7959 redraw_titles(); 7960 #endif 7961 } 7962 7963 #ifdef FEAT_AUTOCMD 7964 /* when 'buflisted' changes, trigger autocommands */ 7965 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) 7966 { 7967 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, 7968 NULL, NULL, TRUE, curbuf); 7969 } 7970 #endif 7971 7972 /* when 'swf' is set, create swapfile, when reset remove swapfile */ 7973 else if ((int *)varp == &curbuf->b_p_swf) 7974 { 7975 if (curbuf->b_p_swf && p_uc) 7976 ml_open_file(curbuf); /* create the swap file */ 7977 else 7978 /* no need to reset curbuf->b_may_swap, ml_open_file() will check 7979 * buf->b_p_swf */ 7980 mf_close_file(curbuf, TRUE); /* remove the swap file */ 7981 } 7982 7983 /* when 'terse' is set change 'shortmess' */ 7984 else if ((int *)varp == &p_terse) 7985 { 7986 char_u *p; 7987 7988 p = vim_strchr(p_shm, SHM_SEARCH); 7989 7990 /* insert 's' in p_shm */ 7991 if (p_terse && p == NULL) 7992 { 7993 STRCPY(IObuff, p_shm); 7994 STRCAT(IObuff, "s"); 7995 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); 7996 } 7997 /* remove 's' from p_shm */ 7998 else if (!p_terse && p != NULL) 7999 STRMOVE(p, p + 1); 8000 } 8001 8002 /* when 'paste' is set or reset also change other options */ 8003 else if ((int *)varp == &p_paste) 8004 { 8005 paste_option_changed(); 8006 } 8007 8008 /* when 'insertmode' is set from an autocommand need to do work here */ 8009 else if ((int *)varp == &p_im) 8010 { 8011 if (p_im) 8012 { 8013 if ((State & INSERT) == 0) 8014 need_start_insertmode = TRUE; 8015 stop_insert_mode = FALSE; 8016 } 8017 else 8018 { 8019 need_start_insertmode = FALSE; 8020 stop_insert_mode = TRUE; 8021 if (restart_edit != 0 && mode_displayed) 8022 clear_cmdline = TRUE; /* remove "(insert)" */ 8023 restart_edit = 0; 8024 } 8025 } 8026 8027 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ 8028 else if ((int *)varp == &p_ic && p_hls) 8029 { 8030 redraw_all_later(SOME_VALID); 8031 } 8032 8033 #ifdef FEAT_SEARCH_EXTRA 8034 /* when 'hlsearch' is set or reset: reset no_hlsearch */ 8035 else if ((int *)varp == &p_hls) 8036 { 8037 SET_NO_HLSEARCH(FALSE); 8038 } 8039 #endif 8040 8041 #ifdef FEAT_SCROLLBIND 8042 /* when 'scrollbind' is set: snapshot the current position to avoid a jump 8043 * at the end of normal_cmd() */ 8044 else if ((int *)varp == &curwin->w_p_scb) 8045 { 8046 if (curwin->w_p_scb) 8047 { 8048 do_check_scrollbind(FALSE); 8049 curwin->w_scbind_pos = curwin->w_topline; 8050 } 8051 } 8052 #endif 8053 8054 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 8055 /* There can be only one window with 'previewwindow' set. */ 8056 else if ((int *)varp == &curwin->w_p_pvw) 8057 { 8058 if (curwin->w_p_pvw) 8059 { 8060 win_T *win; 8061 8062 for (win = firstwin; win != NULL; win = win->w_next) 8063 if (win->w_p_pvw && win != curwin) 8064 { 8065 curwin->w_p_pvw = FALSE; 8066 return (char_u *)N_("E590: A preview window already exists"); 8067 } 8068 } 8069 } 8070 #endif 8071 8072 /* when 'textmode' is set or reset also change 'fileformat' */ 8073 else if ((int *)varp == &curbuf->b_p_tx) 8074 { 8075 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); 8076 } 8077 8078 /* when 'textauto' is set or reset also change 'fileformats' */ 8079 else if ((int *)varp == &p_ta) 8080 set_string_option_direct((char_u *)"ffs", -1, 8081 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", 8082 OPT_FREE | opt_flags, 0); 8083 8084 /* 8085 * When 'lisp' option changes include/exclude '-' in 8086 * keyword characters. 8087 */ 8088 #ifdef FEAT_LISP 8089 else if (varp == (char_u *)&(curbuf->b_p_lisp)) 8090 { 8091 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ 8092 } 8093 #endif 8094 8095 #ifdef FEAT_TITLE 8096 /* when 'title' changed, may need to change the title; same for 'icon' */ 8097 else if ((int *)varp == &p_title) 8098 { 8099 did_set_title(FALSE); 8100 } 8101 8102 else if ((int *)varp == &p_icon) 8103 { 8104 did_set_title(TRUE); 8105 } 8106 #endif 8107 8108 else if ((int *)varp == &curbuf->b_changed) 8109 { 8110 if (!value) 8111 save_file_ff(curbuf); /* Buffer is unchanged */ 8112 #ifdef FEAT_TITLE 8113 redraw_titles(); 8114 #endif 8115 #ifdef FEAT_AUTOCMD 8116 modified_was_set = value; 8117 #endif 8118 } 8119 8120 #ifdef BACKSLASH_IN_FILENAME 8121 else if ((int *)varp == &p_ssl) 8122 { 8123 if (p_ssl) 8124 { 8125 psepc = '/'; 8126 psepcN = '\\'; 8127 pseps[0] = '/'; 8128 } 8129 else 8130 { 8131 psepc = '\\'; 8132 psepcN = '/'; 8133 pseps[0] = '\\'; 8134 } 8135 8136 /* need to adjust the file name arguments and buffer names. */ 8137 buflist_slash_adjust(); 8138 alist_slash_adjust(); 8139 # ifdef FEAT_EVAL 8140 scriptnames_slash_adjust(); 8141 # endif 8142 } 8143 #endif 8144 8145 /* If 'wrap' is set, set w_leftcol to zero. */ 8146 else if ((int *)varp == &curwin->w_p_wrap) 8147 { 8148 if (curwin->w_p_wrap) 8149 curwin->w_leftcol = 0; 8150 } 8151 8152 #ifdef FEAT_WINDOWS 8153 else if ((int *)varp == &p_ea) 8154 { 8155 if (p_ea && !old_value) 8156 win_equal(curwin, FALSE, 0); 8157 } 8158 #endif 8159 8160 else if ((int *)varp == &p_wiv) 8161 { 8162 /* 8163 * When 'weirdinvert' changed, set/reset 't_xs'. 8164 * Then set 'weirdinvert' according to value of 't_xs'. 8165 */ 8166 if (p_wiv && !old_value) 8167 T_XS = (char_u *)"y"; 8168 else if (!p_wiv && old_value) 8169 T_XS = empty_option; 8170 p_wiv = (*T_XS != NUL); 8171 } 8172 8173 #ifdef FEAT_BEVAL 8174 else if ((int *)varp == &p_beval) 8175 { 8176 if (p_beval && !old_value) 8177 gui_mch_enable_beval_area(balloonEval); 8178 else if (!p_beval && old_value) 8179 gui_mch_disable_beval_area(balloonEval); 8180 } 8181 #endif 8182 8183 #ifdef FEAT_AUTOCHDIR 8184 else if ((int *)varp == &p_acd) 8185 { 8186 /* Change directories when the 'acd' option is set now. */ 8187 DO_AUTOCHDIR 8188 } 8189 #endif 8190 8191 #ifdef FEAT_DIFF 8192 /* 'diff' */ 8193 else if ((int *)varp == &curwin->w_p_diff) 8194 { 8195 /* May add or remove the buffer from the list of diff buffers. */ 8196 diff_buf_adjust(curwin); 8197 # ifdef FEAT_FOLDING 8198 if (foldmethodIsDiff(curwin)) 8199 foldUpdateAll(curwin); 8200 # endif 8201 } 8202 #endif 8203 8204 #ifdef USE_IM_CONTROL 8205 /* 'imdisable' */ 8206 else if ((int *)varp == &p_imdisable) 8207 { 8208 /* Only de-activate it here, it will be enabled when changing mode. */ 8209 if (p_imdisable) 8210 im_set_active(FALSE); 8211 else if (State & INSERT) 8212 /* When the option is set from an autocommand, it may need to take 8213 * effect right away. */ 8214 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); 8215 } 8216 #endif 8217 8218 #ifdef FEAT_SPELL 8219 /* 'spell' */ 8220 else if ((int *)varp == &curwin->w_p_spell) 8221 { 8222 if (curwin->w_p_spell) 8223 { 8224 char_u *errmsg = did_set_spelllang(curwin); 8225 if (errmsg != NULL) 8226 EMSG(_(errmsg)); 8227 } 8228 } 8229 #endif 8230 8231 #ifdef FEAT_FKMAP 8232 else if ((int *)varp == &p_altkeymap) 8233 { 8234 if (old_value != p_altkeymap) 8235 { 8236 if (!p_altkeymap) 8237 { 8238 p_hkmap = p_fkmap; 8239 p_fkmap = 0; 8240 } 8241 else 8242 { 8243 p_fkmap = p_hkmap; 8244 p_hkmap = 0; 8245 } 8246 (void)init_chartab(); 8247 } 8248 } 8249 8250 /* 8251 * In case some second language keymapping options have changed, check 8252 * and correct the setting in a consistent way. 8253 */ 8254 8255 /* 8256 * If hkmap or fkmap are set, reset Arabic keymapping. 8257 */ 8258 if ((p_hkmap || p_fkmap) && p_altkeymap) 8259 { 8260 p_altkeymap = p_fkmap; 8261 # ifdef FEAT_ARABIC 8262 curwin->w_p_arab = FALSE; 8263 # endif 8264 (void)init_chartab(); 8265 } 8266 8267 /* 8268 * If hkmap set, reset Farsi keymapping. 8269 */ 8270 if (p_hkmap && p_altkeymap) 8271 { 8272 p_altkeymap = 0; 8273 p_fkmap = 0; 8274 # ifdef FEAT_ARABIC 8275 curwin->w_p_arab = FALSE; 8276 # endif 8277 (void)init_chartab(); 8278 } 8279 8280 /* 8281 * If fkmap set, reset Hebrew keymapping. 8282 */ 8283 if (p_fkmap && !p_altkeymap) 8284 { 8285 p_altkeymap = 1; 8286 p_hkmap = 0; 8287 # ifdef FEAT_ARABIC 8288 curwin->w_p_arab = FALSE; 8289 # endif 8290 (void)init_chartab(); 8291 } 8292 #endif 8293 8294 #ifdef FEAT_ARABIC 8295 if ((int *)varp == &curwin->w_p_arab) 8296 { 8297 if (curwin->w_p_arab) 8298 { 8299 /* 8300 * 'arabic' is set, handle various sub-settings. 8301 */ 8302 if (!p_tbidi) 8303 { 8304 /* set rightleft mode */ 8305 if (!curwin->w_p_rl) 8306 { 8307 curwin->w_p_rl = TRUE; 8308 changed_window_setting(); 8309 } 8310 8311 /* Enable Arabic shaping (major part of what Arabic requires) */ 8312 if (!p_arshape) 8313 { 8314 p_arshape = TRUE; 8315 redraw_later_clear(); 8316 } 8317 } 8318 8319 /* Arabic requires a utf-8 encoding, inform the user if its not 8320 * set. */ 8321 if (STRCMP(p_enc, "utf-8") != 0) 8322 { 8323 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); 8324 8325 msg_source(hl_attr(HLF_W)); 8326 MSG_ATTR(_(w_arabic), hl_attr(HLF_W)); 8327 #ifdef FEAT_EVAL 8328 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); 8329 #endif 8330 } 8331 8332 # ifdef FEAT_MBYTE 8333 /* set 'delcombine' */ 8334 p_deco = TRUE; 8335 # endif 8336 8337 # ifdef FEAT_KEYMAP 8338 /* Force-set the necessary keymap for arabic */ 8339 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", 8340 OPT_LOCAL); 8341 # endif 8342 # ifdef FEAT_FKMAP 8343 p_altkeymap = 0; 8344 p_hkmap = 0; 8345 p_fkmap = 0; 8346 (void)init_chartab(); 8347 # endif 8348 } 8349 else 8350 { 8351 /* 8352 * 'arabic' is reset, handle various sub-settings. 8353 */ 8354 if (!p_tbidi) 8355 { 8356 /* reset rightleft mode */ 8357 if (curwin->w_p_rl) 8358 { 8359 curwin->w_p_rl = FALSE; 8360 changed_window_setting(); 8361 } 8362 8363 /* 'arabicshape' isn't reset, it is a global option and 8364 * another window may still need it "on". */ 8365 } 8366 8367 /* 'delcombine' isn't reset, it is a global option and another 8368 * window may still want it "on". */ 8369 8370 # ifdef FEAT_KEYMAP 8371 /* Revert to the default keymap */ 8372 curbuf->b_p_iminsert = B_IMODE_NONE; 8373 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; 8374 # endif 8375 } 8376 } 8377 8378 #endif 8379 8380 /* 8381 * End of handling side effects for bool options. 8382 */ 8383 8384 /* after handling side effects, call autocommand */ 8385 8386 options[opt_idx].flags |= P_WAS_SET; 8387 8388 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 8389 if (!starting) 8390 { 8391 char_u buf_old[2], buf_new[2], buf_type[7]; 8392 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); 8393 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); 8394 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); 8395 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); 8396 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); 8397 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 8398 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL); 8399 reset_v_option_vars(); 8400 } 8401 #endif 8402 8403 comp_col(); /* in case 'ruler' or 'showcmd' changed */ 8404 if (curwin->w_curswant != MAXCOL 8405 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) 8406 curwin->w_set_curswant = TRUE; 8407 check_redraw(options[opt_idx].flags); 8408 8409 return NULL; 8410 } 8411 8412 /* 8413 * Set the value of a number option, and take care of side effects. 8414 * Returns NULL for success, or an error message for an error. 8415 */ 8416 static char_u * 8417 set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags) 8418 int opt_idx; /* index in options[] table */ 8419 char_u *varp; /* pointer to the option variable */ 8420 long value; /* new value */ 8421 char_u *errbuf; /* buffer for error messages */ 8422 size_t errbuflen; /* length of "errbuf" */ 8423 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and 8424 OPT_MODELINE */ 8425 { 8426 char_u *errmsg = NULL; 8427 long old_value = *(long *)varp; 8428 long old_Rows = Rows; /* remember old Rows */ 8429 long old_Columns = Columns; /* remember old Columns */ 8430 long *pp = (long *)varp; 8431 8432 /* Disallow changing some options from secure mode. */ 8433 if ((secure 8434 #ifdef HAVE_SANDBOX 8435 || sandbox != 0 8436 #endif 8437 ) && (options[opt_idx].flags & P_SECURE)) 8438 return e_secure; 8439 8440 *pp = value; 8441 #ifdef FEAT_EVAL 8442 /* Remember where the option was set. */ 8443 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 8444 #endif 8445 #ifdef FEAT_GUI 8446 need_mouse_correct = TRUE; 8447 #endif 8448 8449 if (curbuf->b_p_sw < 0) 8450 { 8451 errmsg = e_positive; 8452 curbuf->b_p_sw = curbuf->b_p_ts; 8453 } 8454 8455 /* 8456 * Number options that need some action when changed 8457 */ 8458 #ifdef FEAT_WINDOWS 8459 if (pp == &p_wh || pp == &p_hh) 8460 { 8461 if (p_wh < 1) 8462 { 8463 errmsg = e_positive; 8464 p_wh = 1; 8465 } 8466 if (p_wmh > p_wh) 8467 { 8468 errmsg = e_winheight; 8469 p_wh = p_wmh; 8470 } 8471 if (p_hh < 0) 8472 { 8473 errmsg = e_positive; 8474 p_hh = 0; 8475 } 8476 8477 /* Change window height NOW */ 8478 if (lastwin != firstwin) 8479 { 8480 if (pp == &p_wh && curwin->w_height < p_wh) 8481 win_setheight((int)p_wh); 8482 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) 8483 win_setheight((int)p_hh); 8484 } 8485 } 8486 8487 /* 'winminheight' */ 8488 else if (pp == &p_wmh) 8489 { 8490 if (p_wmh < 0) 8491 { 8492 errmsg = e_positive; 8493 p_wmh = 0; 8494 } 8495 if (p_wmh > p_wh) 8496 { 8497 errmsg = e_winheight; 8498 p_wmh = p_wh; 8499 } 8500 win_setminheight(); 8501 } 8502 8503 # ifdef FEAT_VERTSPLIT 8504 else if (pp == &p_wiw) 8505 { 8506 if (p_wiw < 1) 8507 { 8508 errmsg = e_positive; 8509 p_wiw = 1; 8510 } 8511 if (p_wmw > p_wiw) 8512 { 8513 errmsg = e_winwidth; 8514 p_wiw = p_wmw; 8515 } 8516 8517 /* Change window width NOW */ 8518 if (lastwin != firstwin && curwin->w_width < p_wiw) 8519 win_setwidth((int)p_wiw); 8520 } 8521 8522 /* 'winminwidth' */ 8523 else if (pp == &p_wmw) 8524 { 8525 if (p_wmw < 0) 8526 { 8527 errmsg = e_positive; 8528 p_wmw = 0; 8529 } 8530 if (p_wmw > p_wiw) 8531 { 8532 errmsg = e_winwidth; 8533 p_wmw = p_wiw; 8534 } 8535 win_setminheight(); 8536 } 8537 # endif 8538 8539 #endif 8540 8541 #ifdef FEAT_WINDOWS 8542 /* (re)set last window status line */ 8543 else if (pp == &p_ls) 8544 { 8545 last_status(FALSE); 8546 } 8547 8548 /* (re)set tab page line */ 8549 else if (pp == &p_stal) 8550 { 8551 shell_new_rows(); /* recompute window positions and heights */ 8552 } 8553 #endif 8554 8555 #ifdef FEAT_GUI 8556 else if (pp == &p_linespace) 8557 { 8558 /* Recompute gui.char_height and resize the Vim window to keep the 8559 * same number of lines. */ 8560 if (gui.in_use && gui_mch_adjust_charheight() == OK) 8561 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); 8562 } 8563 #endif 8564 8565 #ifdef FEAT_FOLDING 8566 /* 'foldlevel' */ 8567 else if (pp == &curwin->w_p_fdl) 8568 { 8569 if (curwin->w_p_fdl < 0) 8570 curwin->w_p_fdl = 0; 8571 newFoldLevel(); 8572 } 8573 8574 /* 'foldminlines' */ 8575 else if (pp == &curwin->w_p_fml) 8576 { 8577 foldUpdateAll(curwin); 8578 } 8579 8580 /* 'foldnestmax' */ 8581 else if (pp == &curwin->w_p_fdn) 8582 { 8583 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) 8584 foldUpdateAll(curwin); 8585 } 8586 8587 /* 'foldcolumn' */ 8588 else if (pp == &curwin->w_p_fdc) 8589 { 8590 if (curwin->w_p_fdc < 0) 8591 { 8592 errmsg = e_positive; 8593 curwin->w_p_fdc = 0; 8594 } 8595 else if (curwin->w_p_fdc > 12) 8596 { 8597 errmsg = e_invarg; 8598 curwin->w_p_fdc = 12; 8599 } 8600 } 8601 #endif /* FEAT_FOLDING */ 8602 8603 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) 8604 /* 'shiftwidth' or 'tabstop' */ 8605 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) 8606 { 8607 # ifdef FEAT_FOLDING 8608 if (foldmethodIsIndent(curwin)) 8609 foldUpdateAll(curwin); 8610 # endif 8611 # ifdef FEAT_CINDENT 8612 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes: 8613 * parse 'cinoptions'. */ 8614 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) 8615 parse_cino(curbuf); 8616 # endif 8617 } 8618 #endif 8619 8620 #ifdef FEAT_MBYTE 8621 /* 'maxcombine' */ 8622 else if (pp == &p_mco) 8623 { 8624 if (p_mco > MAX_MCO) 8625 p_mco = MAX_MCO; 8626 else if (p_mco < 0) 8627 p_mco = 0; 8628 screenclear(); /* will re-allocate the screen */ 8629 } 8630 #endif 8631 8632 else if (pp == &curbuf->b_p_iminsert) 8633 { 8634 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) 8635 { 8636 errmsg = e_invarg; 8637 curbuf->b_p_iminsert = B_IMODE_NONE; 8638 } 8639 p_iminsert = curbuf->b_p_iminsert; 8640 if (termcap_active) /* don't do this in the alternate screen */ 8641 showmode(); 8642 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP) 8643 /* Show/unshow value of 'keymap' in status lines. */ 8644 status_redraw_curbuf(); 8645 #endif 8646 } 8647 8648 else if (pp == &p_window) 8649 { 8650 if (p_window < 1) 8651 p_window = 1; 8652 else if (p_window >= Rows) 8653 p_window = Rows - 1; 8654 } 8655 8656 else if (pp == &curbuf->b_p_imsearch) 8657 { 8658 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) 8659 { 8660 errmsg = e_invarg; 8661 curbuf->b_p_imsearch = B_IMODE_NONE; 8662 } 8663 p_imsearch = curbuf->b_p_imsearch; 8664 } 8665 8666 #ifdef FEAT_TITLE 8667 /* if 'titlelen' has changed, redraw the title */ 8668 else if (pp == &p_titlelen) 8669 { 8670 if (p_titlelen < 0) 8671 { 8672 errmsg = e_positive; 8673 p_titlelen = 85; 8674 } 8675 if (starting != NO_SCREEN && old_value != p_titlelen) 8676 need_maketitle = TRUE; 8677 } 8678 #endif 8679 8680 /* if p_ch changed value, change the command line height */ 8681 else if (pp == &p_ch) 8682 { 8683 if (p_ch < 1) 8684 { 8685 errmsg = e_positive; 8686 p_ch = 1; 8687 } 8688 if (p_ch > Rows - min_rows() + 1) 8689 p_ch = Rows - min_rows() + 1; 8690 8691 /* Only compute the new window layout when startup has been 8692 * completed. Otherwise the frame sizes may be wrong. */ 8693 if (p_ch != old_value && full_screen 8694 #ifdef FEAT_GUI 8695 && !gui.starting 8696 #endif 8697 ) 8698 command_height(); 8699 } 8700 8701 /* when 'updatecount' changes from zero to non-zero, open swap files */ 8702 else if (pp == &p_uc) 8703 { 8704 if (p_uc < 0) 8705 { 8706 errmsg = e_positive; 8707 p_uc = 100; 8708 } 8709 if (p_uc && !old_value) 8710 ml_open_files(); 8711 } 8712 #ifdef FEAT_CONCEAL 8713 else if (pp == &curwin->w_p_cole) 8714 { 8715 if (curwin->w_p_cole < 0) 8716 { 8717 errmsg = e_positive; 8718 curwin->w_p_cole = 0; 8719 } 8720 else if (curwin->w_p_cole > 3) 8721 { 8722 errmsg = e_invarg; 8723 curwin->w_p_cole = 3; 8724 } 8725 } 8726 #endif 8727 #ifdef MZSCHEME_GUI_THREADS 8728 else if (pp == &p_mzq) 8729 mzvim_reset_timer(); 8730 #endif 8731 8732 /* sync undo before 'undolevels' changes */ 8733 else if (pp == &p_ul) 8734 { 8735 /* use the old value, otherwise u_sync() may not work properly */ 8736 p_ul = old_value; 8737 u_sync(TRUE); 8738 p_ul = value; 8739 } 8740 else if (pp == &curbuf->b_p_ul) 8741 { 8742 /* use the old value, otherwise u_sync() may not work properly */ 8743 curbuf->b_p_ul = old_value; 8744 u_sync(TRUE); 8745 curbuf->b_p_ul = value; 8746 } 8747 8748 #ifdef FEAT_LINEBREAK 8749 /* 'numberwidth' must be positive */ 8750 else if (pp == &curwin->w_p_nuw) 8751 { 8752 if (curwin->w_p_nuw < 1) 8753 { 8754 errmsg = e_positive; 8755 curwin->w_p_nuw = 1; 8756 } 8757 if (curwin->w_p_nuw > 10) 8758 { 8759 errmsg = e_invarg; 8760 curwin->w_p_nuw = 10; 8761 } 8762 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */ 8763 } 8764 #endif 8765 8766 else if (pp == &curbuf->b_p_tw) 8767 { 8768 if (curbuf->b_p_tw < 0) 8769 { 8770 errmsg = e_positive; 8771 curbuf->b_p_tw = 0; 8772 } 8773 #ifdef FEAT_SYN_HL 8774 # ifdef FEAT_WINDOWS 8775 { 8776 win_T *wp; 8777 tabpage_T *tp; 8778 8779 FOR_ALL_TAB_WINDOWS(tp, wp) 8780 check_colorcolumn(wp); 8781 } 8782 # else 8783 check_colorcolumn(curwin); 8784 # endif 8785 #endif 8786 } 8787 8788 /* 8789 * Check the bounds for numeric options here 8790 */ 8791 if (Rows < min_rows() && full_screen) 8792 { 8793 if (errbuf != NULL) 8794 { 8795 vim_snprintf((char *)errbuf, errbuflen, 8796 _("E593: Need at least %d lines"), min_rows()); 8797 errmsg = errbuf; 8798 } 8799 Rows = min_rows(); 8800 } 8801 if (Columns < MIN_COLUMNS && full_screen) 8802 { 8803 if (errbuf != NULL) 8804 { 8805 vim_snprintf((char *)errbuf, errbuflen, 8806 _("E594: Need at least %d columns"), MIN_COLUMNS); 8807 errmsg = errbuf; 8808 } 8809 Columns = MIN_COLUMNS; 8810 } 8811 limit_screen_size(); 8812 8813 #ifdef DJGPP 8814 /* avoid a crash by checking for a too large value of 'columns' */ 8815 if (old_Columns != Columns && full_screen && term_console) 8816 mch_check_columns(); 8817 #endif 8818 8819 /* 8820 * If the screen (shell) height has been changed, assume it is the 8821 * physical screenheight. 8822 */ 8823 if (old_Rows != Rows || old_Columns != Columns) 8824 { 8825 /* Changing the screen size is not allowed while updating the screen. */ 8826 if (updating_screen) 8827 *pp = old_value; 8828 else if (full_screen 8829 #ifdef FEAT_GUI 8830 && !gui.starting 8831 #endif 8832 ) 8833 set_shellsize((int)Columns, (int)Rows, TRUE); 8834 else 8835 { 8836 /* Postpone the resizing; check the size and cmdline position for 8837 * messages. */ 8838 check_shellsize(); 8839 if (cmdline_row > Rows - p_ch && Rows > p_ch) 8840 cmdline_row = Rows - p_ch; 8841 } 8842 if (p_window >= Rows || !option_was_set((char_u *)"window")) 8843 p_window = Rows - 1; 8844 } 8845 8846 if (curbuf->b_p_ts <= 0) 8847 { 8848 errmsg = e_positive; 8849 curbuf->b_p_ts = 8; 8850 } 8851 if (p_tm < 0) 8852 { 8853 errmsg = e_positive; 8854 p_tm = 0; 8855 } 8856 if ((curwin->w_p_scr <= 0 8857 || (curwin->w_p_scr > curwin->w_height 8858 && curwin->w_height > 0)) 8859 && full_screen) 8860 { 8861 if (pp == &(curwin->w_p_scr)) 8862 { 8863 if (curwin->w_p_scr != 0) 8864 errmsg = e_scroll; 8865 win_comp_scroll(curwin); 8866 } 8867 /* If 'scroll' became invalid because of a side effect silently adjust 8868 * it. */ 8869 else if (curwin->w_p_scr <= 0) 8870 curwin->w_p_scr = 1; 8871 else /* curwin->w_p_scr > curwin->w_height */ 8872 curwin->w_p_scr = curwin->w_height; 8873 } 8874 if (p_hi < 0) 8875 { 8876 errmsg = e_positive; 8877 p_hi = 0; 8878 } 8879 else if (p_hi > 10000) 8880 { 8881 errmsg = e_invarg; 8882 p_hi = 10000; 8883 } 8884 if (p_re < 0 || p_re > 2) 8885 { 8886 errmsg = e_invarg; 8887 p_re = 0; 8888 } 8889 if (p_report < 0) 8890 { 8891 errmsg = e_positive; 8892 p_report = 1; 8893 } 8894 if ((p_sj < -100 || p_sj >= Rows) && full_screen) 8895 { 8896 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ 8897 p_sj = Rows / 2; 8898 else 8899 { 8900 errmsg = e_scroll; 8901 p_sj = 1; 8902 } 8903 } 8904 if (p_so < 0 && full_screen) 8905 { 8906 errmsg = e_scroll; 8907 p_so = 0; 8908 } 8909 if (p_siso < 0 && full_screen) 8910 { 8911 errmsg = e_positive; 8912 p_siso = 0; 8913 } 8914 #ifdef FEAT_CMDWIN 8915 if (p_cwh < 1) 8916 { 8917 errmsg = e_positive; 8918 p_cwh = 1; 8919 } 8920 #endif 8921 if (p_ut < 0) 8922 { 8923 errmsg = e_positive; 8924 p_ut = 2000; 8925 } 8926 if (p_ss < 0) 8927 { 8928 errmsg = e_positive; 8929 p_ss = 0; 8930 } 8931 8932 /* May set global value for local option. */ 8933 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) 8934 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; 8935 8936 options[opt_idx].flags |= P_WAS_SET; 8937 8938 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 8939 if (!starting && errmsg == NULL) 8940 { 8941 char_u buf_old[11], buf_new[11], buf_type[7]; 8942 vim_snprintf((char *)buf_old, 10, "%ld", old_value); 8943 vim_snprintf((char *)buf_new, 10, "%ld", value); 8944 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); 8945 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); 8946 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); 8947 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 8948 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL); 8949 reset_v_option_vars(); 8950 } 8951 #endif 8952 8953 comp_col(); /* in case 'columns' or 'ls' changed */ 8954 if (curwin->w_curswant != MAXCOL 8955 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) 8956 curwin->w_set_curswant = TRUE; 8957 check_redraw(options[opt_idx].flags); 8958 8959 return errmsg; 8960 } 8961 8962 /* 8963 * Called after an option changed: check if something needs to be redrawn. 8964 */ 8965 static void 8966 check_redraw(flags) 8967 long_u flags; 8968 { 8969 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ 8970 int doclear = (flags & P_RCLR) == P_RCLR; 8971 int all = ((flags & P_RALL) == P_RALL || doclear); 8972 8973 #ifdef FEAT_WINDOWS 8974 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ 8975 status_redraw_all(); 8976 #endif 8977 8978 if ((flags & P_RBUF) || (flags & P_RWIN) || all) 8979 changed_window_setting(); 8980 if (flags & P_RBUF) 8981 redraw_curbuf_later(NOT_VALID); 8982 if (doclear) 8983 redraw_all_later(CLEAR); 8984 else if (all) 8985 redraw_all_later(NOT_VALID); 8986 } 8987 8988 /* 8989 * Find index for option 'arg'. 8990 * Return -1 if not found. 8991 */ 8992 static int 8993 findoption(arg) 8994 char_u *arg; 8995 { 8996 int opt_idx; 8997 char *s, *p; 8998 static short quick_tab[27] = {0, 0}; /* quick access table */ 8999 int is_term_opt; 9000 9001 /* 9002 * For first call: Initialize the quick-access table. 9003 * It contains the index for the first option that starts with a certain 9004 * letter. There are 26 letters, plus the first "t_" option. 9005 */ 9006 if (quick_tab[1] == 0) 9007 { 9008 p = options[0].fullname; 9009 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) 9010 { 9011 if (s[0] != p[0]) 9012 { 9013 if (s[0] == 't' && s[1] == '_') 9014 quick_tab[26] = opt_idx; 9015 else 9016 quick_tab[CharOrdLow(s[0])] = opt_idx; 9017 } 9018 p = s; 9019 } 9020 } 9021 9022 /* 9023 * Check for name starting with an illegal character. 9024 */ 9025 #ifdef EBCDIC 9026 if (!islower(arg[0])) 9027 #else 9028 if (arg[0] < 'a' || arg[0] > 'z') 9029 #endif 9030 return -1; 9031 9032 is_term_opt = (arg[0] == 't' && arg[1] == '_'); 9033 if (is_term_opt) 9034 opt_idx = quick_tab[26]; 9035 else 9036 opt_idx = quick_tab[CharOrdLow(arg[0])]; 9037 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) 9038 { 9039 if (STRCMP(arg, s) == 0) /* match full name */ 9040 break; 9041 } 9042 if (s == NULL && !is_term_opt) 9043 { 9044 opt_idx = quick_tab[CharOrdLow(arg[0])]; 9045 for ( ; options[opt_idx].fullname != NULL; opt_idx++) 9046 { 9047 s = options[opt_idx].shortname; 9048 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ 9049 break; 9050 s = NULL; 9051 } 9052 } 9053 if (s == NULL) 9054 opt_idx = -1; 9055 return opt_idx; 9056 } 9057 9058 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) 9059 /* 9060 * Get the value for an option. 9061 * 9062 * Returns: 9063 * Number or Toggle option: 1, *numval gets value. 9064 * String option: 0, *stringval gets allocated string. 9065 * Hidden Number or Toggle option: -1. 9066 * hidden String option: -2. 9067 * unknown option: -3. 9068 */ 9069 int 9070 get_option_value(name, numval, stringval, opt_flags) 9071 char_u *name; 9072 long *numval; 9073 char_u **stringval; /* NULL when only checking existence */ 9074 int opt_flags; 9075 { 9076 int opt_idx; 9077 char_u *varp; 9078 9079 opt_idx = findoption(name); 9080 if (opt_idx < 0) /* unknown option */ 9081 return -3; 9082 9083 varp = get_varp_scope(&(options[opt_idx]), opt_flags); 9084 9085 if (options[opt_idx].flags & P_STRING) 9086 { 9087 if (varp == NULL) /* hidden option */ 9088 return -2; 9089 if (stringval != NULL) 9090 { 9091 #ifdef FEAT_CRYPT 9092 /* never return the value of the crypt key */ 9093 if ((char_u **)varp == &curbuf->b_p_key 9094 && **(char_u **)(varp) != NUL) 9095 *stringval = vim_strsave((char_u *)"*****"); 9096 else 9097 #endif 9098 *stringval = vim_strsave(*(char_u **)(varp)); 9099 } 9100 return 0; 9101 } 9102 9103 if (varp == NULL) /* hidden option */ 9104 return -1; 9105 if (options[opt_idx].flags & P_NUM) 9106 *numval = *(long *)varp; 9107 else 9108 { 9109 /* Special case: 'modified' is b_changed, but we also want to consider 9110 * it set when 'ff' or 'fenc' changed. */ 9111 if ((int *)varp == &curbuf->b_changed) 9112 *numval = curbufIsChanged(); 9113 else 9114 *numval = *(int *)varp; 9115 } 9116 return 1; 9117 } 9118 #endif 9119 9120 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) 9121 /* 9122 * Returns the option attributes and its value. Unlike the above function it 9123 * will return either global value or local value of the option depending on 9124 * what was requested, but it will never return global value if it was 9125 * requested to return local one and vice versa. Neither it will return 9126 * buffer-local value if it was requested to return window-local one. 9127 * 9128 * Pretends that option is absent if it is not present in the requested scope 9129 * (i.e. has no global, window-local or buffer-local value depending on 9130 * opt_type). Uses 9131 * 9132 * Returned flags: 9133 * 0 hidden or unknown option, also option that does not have requested 9134 * type (see SREQ_* in vim.h) 9135 * see SOPT_* in vim.h for other flags 9136 * 9137 * Possible opt_type values: see SREQ_* in vim.h 9138 */ 9139 int 9140 get_option_value_strict(name, numval, stringval, opt_type, from) 9141 char_u *name; 9142 long *numval; 9143 char_u **stringval; /* NULL when only obtaining attributes */ 9144 int opt_type; 9145 void *from; 9146 { 9147 int opt_idx; 9148 char_u *varp = NULL; 9149 struct vimoption *p; 9150 int r = 0; 9151 9152 opt_idx = findoption(name); 9153 if (opt_idx < 0) 9154 return 0; 9155 9156 p = &(options[opt_idx]); 9157 9158 /* Hidden option */ 9159 if (p->var == NULL) 9160 return 0; 9161 9162 if (p->flags & P_BOOL) 9163 r |= SOPT_BOOL; 9164 else if (p->flags & P_NUM) 9165 r |= SOPT_NUM; 9166 else if (p->flags & P_STRING) 9167 r |= SOPT_STRING; 9168 9169 if (p->indir == PV_NONE) 9170 { 9171 if (opt_type == SREQ_GLOBAL) 9172 r |= SOPT_GLOBAL; 9173 else 9174 return 0; /* Did not request global-only option */ 9175 } 9176 else 9177 { 9178 if (p->indir & PV_BOTH) 9179 r |= SOPT_GLOBAL; 9180 else if (opt_type == SREQ_GLOBAL) 9181 return 0; /* Requested global option */ 9182 9183 if (p->indir & PV_WIN) 9184 { 9185 if (opt_type == SREQ_BUF) 9186 return 0; /* Did not request window-local option */ 9187 else 9188 r |= SOPT_WIN; 9189 } 9190 else if (p->indir & PV_BUF) 9191 { 9192 if (opt_type == SREQ_WIN) 9193 return 0; /* Did not request buffer-local option */ 9194 else 9195 r |= SOPT_BUF; 9196 } 9197 } 9198 9199 if (stringval == NULL) 9200 return r; 9201 9202 if (opt_type == SREQ_GLOBAL) 9203 varp = p->var; 9204 else 9205 { 9206 if (opt_type == SREQ_BUF) 9207 { 9208 /* Special case: 'modified' is b_changed, but we also want to 9209 * consider it set when 'ff' or 'fenc' changed. */ 9210 if (p->indir == PV_MOD) 9211 { 9212 *numval = bufIsChanged((buf_T *) from); 9213 varp = NULL; 9214 } 9215 #ifdef FEAT_CRYPT 9216 else if (p->indir == PV_KEY) 9217 { 9218 /* never return the value of the crypt key */ 9219 *stringval = NULL; 9220 varp = NULL; 9221 } 9222 #endif 9223 else 9224 { 9225 aco_save_T aco; 9226 aucmd_prepbuf(&aco, (buf_T *) from); 9227 varp = get_varp(p); 9228 aucmd_restbuf(&aco); 9229 } 9230 } 9231 else if (opt_type == SREQ_WIN) 9232 { 9233 win_T *save_curwin; 9234 save_curwin = curwin; 9235 curwin = (win_T *) from; 9236 curbuf = curwin->w_buffer; 9237 varp = get_varp(p); 9238 curwin = save_curwin; 9239 curbuf = curwin->w_buffer; 9240 } 9241 if (varp == p->var) 9242 return (r | SOPT_UNSET); 9243 } 9244 9245 if (varp != NULL) 9246 { 9247 if (p->flags & P_STRING) 9248 *stringval = vim_strsave(*(char_u **)(varp)); 9249 else if (p->flags & P_NUM) 9250 *numval = *(long *) varp; 9251 else 9252 *numval = *(int *)varp; 9253 } 9254 9255 return r; 9256 } 9257 9258 /* 9259 * Iterate over options. First argument is a pointer to a pointer to a 9260 * structure inside options[] array, second is option type like in the above 9261 * function. 9262 * 9263 * If first argument points to NULL it is assumed that iteration just started 9264 * and caller needs the very first value. 9265 * If first argument points to the end marker function returns NULL and sets 9266 * first argument to NULL. 9267 * 9268 * Returns full option name for current option on each call. 9269 */ 9270 char_u * 9271 option_iter_next(option, opt_type) 9272 void **option; 9273 int opt_type; 9274 { 9275 struct vimoption *ret = NULL; 9276 do 9277 { 9278 if (*option == NULL) 9279 *option = (void *) options; 9280 else if (((struct vimoption *) (*option))->fullname == NULL) 9281 { 9282 *option = NULL; 9283 return NULL; 9284 } 9285 else 9286 *option = (void *) (((struct vimoption *) (*option)) + 1); 9287 9288 ret = ((struct vimoption *) (*option)); 9289 9290 /* Hidden option */ 9291 if (ret->var == NULL) 9292 { 9293 ret = NULL; 9294 continue; 9295 } 9296 9297 switch (opt_type) 9298 { 9299 case SREQ_GLOBAL: 9300 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) 9301 ret = NULL; 9302 break; 9303 case SREQ_BUF: 9304 if (!(ret->indir & PV_BUF)) 9305 ret = NULL; 9306 break; 9307 case SREQ_WIN: 9308 if (!(ret->indir & PV_WIN)) 9309 ret = NULL; 9310 break; 9311 default: 9312 EMSG2(_(e_intern2), "option_iter_next()"); 9313 return NULL; 9314 } 9315 } 9316 while (ret == NULL); 9317 9318 return (char_u *)ret->fullname; 9319 } 9320 #endif 9321 9322 /* 9323 * Set the value of option "name". 9324 * Use "string" for string options, use "number" for other options. 9325 * 9326 * Returns NULL on success or error message on error. 9327 */ 9328 char_u * 9329 set_option_value(name, number, string, opt_flags) 9330 char_u *name; 9331 long number; 9332 char_u *string; 9333 int opt_flags; /* OPT_LOCAL or 0 (both) */ 9334 { 9335 int opt_idx; 9336 char_u *varp; 9337 long_u flags; 9338 9339 opt_idx = findoption(name); 9340 if (opt_idx < 0) 9341 EMSG2(_("E355: Unknown option: %s"), name); 9342 else 9343 { 9344 flags = options[opt_idx].flags; 9345 #ifdef HAVE_SANDBOX 9346 /* Disallow changing some options in the sandbox */ 9347 if (sandbox > 0 && (flags & P_SECURE)) 9348 { 9349 EMSG(_(e_sandbox)); 9350 return NULL; 9351 } 9352 #endif 9353 if (flags & P_STRING) 9354 return set_string_option(opt_idx, string, opt_flags); 9355 else 9356 { 9357 varp = get_varp_scope(&(options[opt_idx]), opt_flags); 9358 if (varp != NULL) /* hidden option is not changed */ 9359 { 9360 if (number == 0 && string != NULL) 9361 { 9362 int idx; 9363 9364 /* Either we are given a string or we are setting option 9365 * to zero. */ 9366 for (idx = 0; string[idx] == '0'; ++idx) 9367 ; 9368 if (string[idx] != NUL || idx == 0) 9369 { 9370 /* There's another character after zeros or the string 9371 * is empty. In both cases, we are trying to set a 9372 * num option using a string. */ 9373 EMSG3(_("E521: Number required: &%s = '%s'"), 9374 name, string); 9375 return NULL; /* do nothing as we hit an error */ 9376 9377 } 9378 } 9379 if (flags & P_NUM) 9380 return set_num_option(opt_idx, varp, number, 9381 NULL, 0, opt_flags); 9382 else 9383 return set_bool_option(opt_idx, varp, (int)number, 9384 opt_flags); 9385 } 9386 } 9387 } 9388 return NULL; 9389 } 9390 9391 /* 9392 * Get the terminal code for a terminal option. 9393 * Returns NULL when not found. 9394 */ 9395 char_u * 9396 get_term_code(tname) 9397 char_u *tname; 9398 { 9399 int opt_idx; 9400 char_u *varp; 9401 9402 if (tname[0] != 't' || tname[1] != '_' || 9403 tname[2] == NUL || tname[3] == NUL) 9404 return NULL; 9405 if ((opt_idx = findoption(tname)) >= 0) 9406 { 9407 varp = get_varp(&(options[opt_idx])); 9408 if (varp != NULL) 9409 varp = *(char_u **)(varp); 9410 return varp; 9411 } 9412 return find_termcode(tname + 2); 9413 } 9414 9415 char_u * 9416 get_highlight_default() 9417 { 9418 int i; 9419 9420 i = findoption((char_u *)"hl"); 9421 if (i >= 0) 9422 return options[i].def_val[VI_DEFAULT]; 9423 return (char_u *)NULL; 9424 } 9425 9426 #if defined(FEAT_MBYTE) || defined(PROTO) 9427 char_u * 9428 get_encoding_default() 9429 { 9430 int i; 9431 9432 i = findoption((char_u *)"enc"); 9433 if (i >= 0) 9434 return options[i].def_val[VI_DEFAULT]; 9435 return (char_u *)NULL; 9436 } 9437 #endif 9438 9439 /* 9440 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. 9441 */ 9442 static int 9443 find_key_option(arg) 9444 char_u *arg; 9445 { 9446 int key; 9447 int modifiers; 9448 9449 /* 9450 * Don't use get_special_key_code() for t_xx, we don't want it to call 9451 * add_termcap_entry(). 9452 */ 9453 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) 9454 key = TERMCAP2KEY(arg[2], arg[3]); 9455 else 9456 { 9457 --arg; /* put arg at the '<' */ 9458 modifiers = 0; 9459 key = find_special_key(&arg, &modifiers, TRUE, TRUE); 9460 if (modifiers) /* can't handle modifiers here */ 9461 key = 0; 9462 } 9463 return key; 9464 } 9465 9466 /* 9467 * if 'all' == 0: show changed options 9468 * if 'all' == 1: show all normal options 9469 * if 'all' == 2: show all terminal options 9470 */ 9471 static void 9472 showoptions(all, opt_flags) 9473 int all; 9474 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */ 9475 { 9476 struct vimoption *p; 9477 int col; 9478 int isterm; 9479 char_u *varp; 9480 struct vimoption **items; 9481 int item_count; 9482 int run; 9483 int row, rows; 9484 int cols; 9485 int i; 9486 int len; 9487 9488 #define INC 20 9489 #define GAP 3 9490 9491 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) * 9492 PARAM_COUNT)); 9493 if (items == NULL) 9494 return; 9495 9496 /* Highlight title */ 9497 if (all == 2) 9498 MSG_PUTS_TITLE(_("\n--- Terminal codes ---")); 9499 else if (opt_flags & OPT_GLOBAL) 9500 MSG_PUTS_TITLE(_("\n--- Global option values ---")); 9501 else if (opt_flags & OPT_LOCAL) 9502 MSG_PUTS_TITLE(_("\n--- Local option values ---")); 9503 else 9504 MSG_PUTS_TITLE(_("\n--- Options ---")); 9505 9506 /* 9507 * do the loop two times: 9508 * 1. display the short items 9509 * 2. display the long items (only strings and numbers) 9510 */ 9511 for (run = 1; run <= 2 && !got_int; ++run) 9512 { 9513 /* 9514 * collect the items in items[] 9515 */ 9516 item_count = 0; 9517 for (p = &options[0]; p->fullname != NULL; p++) 9518 { 9519 varp = NULL; 9520 isterm = istermoption(p); 9521 if (opt_flags != 0) 9522 { 9523 if (p->indir != PV_NONE && !isterm) 9524 varp = get_varp_scope(p, opt_flags); 9525 } 9526 else 9527 varp = get_varp(p); 9528 if (varp != NULL 9529 && ((all == 2 && isterm) 9530 || (all == 1 && !isterm) 9531 || (all == 0 && !optval_default(p, varp)))) 9532 { 9533 if (p->flags & P_BOOL) 9534 len = 1; /* a toggle option fits always */ 9535 else 9536 { 9537 option_value2string(p, opt_flags); 9538 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; 9539 } 9540 if ((len <= INC - GAP && run == 1) || 9541 (len > INC - GAP && run == 2)) 9542 items[item_count++] = p; 9543 } 9544 } 9545 9546 /* 9547 * display the items 9548 */ 9549 if (run == 1) 9550 { 9551 cols = (Columns + GAP - 3) / INC; 9552 if (cols == 0) 9553 cols = 1; 9554 rows = (item_count + cols - 1) / cols; 9555 } 9556 else /* run == 2 */ 9557 rows = item_count; 9558 for (row = 0; row < rows && !got_int; ++row) 9559 { 9560 msg_putchar('\n'); /* go to next line */ 9561 if (got_int) /* 'q' typed in more */ 9562 break; 9563 col = 0; 9564 for (i = row; i < item_count; i += rows) 9565 { 9566 msg_col = col; /* make columns */ 9567 showoneopt(items[i], opt_flags); 9568 col += INC; 9569 } 9570 out_flush(); 9571 ui_breakcheck(); 9572 } 9573 } 9574 vim_free(items); 9575 } 9576 9577 /* 9578 * Return TRUE if option "p" has its default value. 9579 */ 9580 static int 9581 optval_default(p, varp) 9582 struct vimoption *p; 9583 char_u *varp; 9584 { 9585 int dvi; 9586 9587 if (varp == NULL) 9588 return TRUE; /* hidden option is always at default */ 9589 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT; 9590 if (p->flags & P_NUM) 9591 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); 9592 if (p->flags & P_BOOL) 9593 /* the cast to long is required for Manx C, long_i is 9594 * needed for MSVC */ 9595 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); 9596 /* P_STRING */ 9597 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); 9598 } 9599 9600 /* 9601 * showoneopt: show the value of one option 9602 * must not be called with a hidden option! 9603 */ 9604 static void 9605 showoneopt(p, opt_flags) 9606 struct vimoption *p; 9607 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */ 9608 { 9609 char_u *varp; 9610 int save_silent = silent_mode; 9611 9612 silent_mode = FALSE; 9613 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ 9614 9615 varp = get_varp_scope(p, opt_flags); 9616 9617 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ 9618 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed 9619 ? !curbufIsChanged() : !*(int *)varp)) 9620 MSG_PUTS("no"); 9621 else if ((p->flags & P_BOOL) && *(int *)varp < 0) 9622 MSG_PUTS("--"); 9623 else 9624 MSG_PUTS(" "); 9625 MSG_PUTS(p->fullname); 9626 if (!(p->flags & P_BOOL)) 9627 { 9628 msg_putchar('='); 9629 /* put value string in NameBuff */ 9630 option_value2string(p, opt_flags); 9631 msg_outtrans(NameBuff); 9632 } 9633 9634 silent_mode = save_silent; 9635 info_message = FALSE; 9636 } 9637 9638 /* 9639 * Write modified options as ":set" commands to a file. 9640 * 9641 * There are three values for "opt_flags": 9642 * OPT_GLOBAL: Write global option values and fresh values of 9643 * buffer-local options (used for start of a session 9644 * file). 9645 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for 9646 * curwin (used for a vimrc file). 9647 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh 9648 * and local values for window-local options of 9649 * curwin. Local values are also written when at the 9650 * default value, because a modeline or autocommand 9651 * may have set them when doing ":edit file" and the 9652 * user has set them back at the default or fresh 9653 * value. 9654 * When "local_only" is TRUE, don't write fresh 9655 * values, only local values (for ":mkview"). 9656 * (fresh value = value used for a new buffer or window for a local option). 9657 * 9658 * Return FAIL on error, OK otherwise. 9659 */ 9660 int 9661 makeset(fd, opt_flags, local_only) 9662 FILE *fd; 9663 int opt_flags; 9664 int local_only; 9665 { 9666 struct vimoption *p; 9667 char_u *varp; /* currently used value */ 9668 char_u *varp_fresh; /* local value */ 9669 char_u *varp_local = NULL; /* fresh value */ 9670 char *cmd; 9671 int round; 9672 int pri; 9673 9674 /* 9675 * The options that don't have a default (terminal name, columns, lines) 9676 * are never written. Terminal options are also not written. 9677 * Do the loop over "options[]" twice: once for options with the 9678 * P_PRI_MKRC flag and once without. 9679 */ 9680 for (pri = 1; pri >= 0; --pri) 9681 { 9682 for (p = &options[0]; !istermoption(p); p++) 9683 if (!(p->flags & P_NO_MKRC) 9684 && !istermoption(p) 9685 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) 9686 { 9687 /* skip global option when only doing locals */ 9688 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) 9689 continue; 9690 9691 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc 9692 * file, they are always buffer-specific. */ 9693 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) 9694 continue; 9695 9696 /* Global values are only written when not at the default value. */ 9697 varp = get_varp_scope(p, opt_flags); 9698 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp)) 9699 continue; 9700 9701 round = 2; 9702 if (p->indir != PV_NONE) 9703 { 9704 if (p->var == VAR_WIN) 9705 { 9706 /* skip window-local option when only doing globals */ 9707 if (!(opt_flags & OPT_LOCAL)) 9708 continue; 9709 /* When fresh value of window-local option is not at the 9710 * default, need to write it too. */ 9711 if (!(opt_flags & OPT_GLOBAL) && !local_only) 9712 { 9713 varp_fresh = get_varp_scope(p, OPT_GLOBAL); 9714 if (!optval_default(p, varp_fresh)) 9715 { 9716 round = 1; 9717 varp_local = varp; 9718 varp = varp_fresh; 9719 } 9720 } 9721 } 9722 } 9723 9724 /* Round 1: fresh value for window-local options. 9725 * Round 2: other values */ 9726 for ( ; round <= 2; varp = varp_local, ++round) 9727 { 9728 if (round == 1 || (opt_flags & OPT_GLOBAL)) 9729 cmd = "set"; 9730 else 9731 cmd = "setlocal"; 9732 9733 if (p->flags & P_BOOL) 9734 { 9735 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) 9736 return FAIL; 9737 } 9738 else if (p->flags & P_NUM) 9739 { 9740 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) 9741 return FAIL; 9742 } 9743 else /* P_STRING */ 9744 { 9745 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) 9746 int do_endif = FALSE; 9747 9748 /* Don't set 'syntax' and 'filetype' again if the value is 9749 * already right, avoids reloading the syntax file. */ 9750 if ( 9751 # if defined(FEAT_SYN_HL) 9752 p->indir == PV_SYN 9753 # if defined(FEAT_AUTOCMD) 9754 || 9755 # endif 9756 # endif 9757 # if defined(FEAT_AUTOCMD) 9758 p->indir == PV_FT 9759 # endif 9760 ) 9761 { 9762 if (fprintf(fd, "if &%s != '%s'", p->fullname, 9763 *(char_u **)(varp)) < 0 9764 || put_eol(fd) < 0) 9765 return FAIL; 9766 do_endif = TRUE; 9767 } 9768 #endif 9769 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, 9770 (p->flags & P_EXPAND) != 0) == FAIL) 9771 return FAIL; 9772 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) 9773 if (do_endif) 9774 { 9775 if (put_line(fd, "endif") == FAIL) 9776 return FAIL; 9777 } 9778 #endif 9779 } 9780 } 9781 } 9782 } 9783 return OK; 9784 } 9785 9786 #if defined(FEAT_FOLDING) || defined(PROTO) 9787 /* 9788 * Generate set commands for the local fold options only. Used when 9789 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". 9790 */ 9791 int 9792 makefoldset(fd) 9793 FILE *fd; 9794 { 9795 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL 9796 # ifdef FEAT_EVAL 9797 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE) 9798 == FAIL 9799 # endif 9800 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE) 9801 == FAIL 9802 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE) 9803 == FAIL 9804 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL 9805 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL 9806 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL 9807 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL 9808 ) 9809 return FAIL; 9810 9811 return OK; 9812 } 9813 #endif 9814 9815 static int 9816 put_setstring(fd, cmd, name, valuep, expand) 9817 FILE *fd; 9818 char *cmd; 9819 char *name; 9820 char_u **valuep; 9821 int expand; 9822 { 9823 char_u *s; 9824 char_u *buf; 9825 9826 if (fprintf(fd, "%s %s=", cmd, name) < 0) 9827 return FAIL; 9828 if (*valuep != NULL) 9829 { 9830 /* Output 'pastetoggle' as key names. For other 9831 * options some characters have to be escaped with 9832 * CTRL-V or backslash */ 9833 if (valuep == &p_pt) 9834 { 9835 s = *valuep; 9836 while (*s != NUL) 9837 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) 9838 return FAIL; 9839 } 9840 else if (expand) 9841 { 9842 buf = alloc(MAXPATHL); 9843 if (buf == NULL) 9844 return FAIL; 9845 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); 9846 if (put_escstr(fd, buf, 2) == FAIL) 9847 { 9848 vim_free(buf); 9849 return FAIL; 9850 } 9851 vim_free(buf); 9852 } 9853 else if (put_escstr(fd, *valuep, 2) == FAIL) 9854 return FAIL; 9855 } 9856 if (put_eol(fd) < 0) 9857 return FAIL; 9858 return OK; 9859 } 9860 9861 static int 9862 put_setnum(fd, cmd, name, valuep) 9863 FILE *fd; 9864 char *cmd; 9865 char *name; 9866 long *valuep; 9867 { 9868 long wc; 9869 9870 if (fprintf(fd, "%s %s=", cmd, name) < 0) 9871 return FAIL; 9872 if (wc_use_keyname((char_u *)valuep, &wc)) 9873 { 9874 /* print 'wildchar' and 'wildcharm' as a key name */ 9875 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) 9876 return FAIL; 9877 } 9878 else if (fprintf(fd, "%ld", *valuep) < 0) 9879 return FAIL; 9880 if (put_eol(fd) < 0) 9881 return FAIL; 9882 return OK; 9883 } 9884 9885 static int 9886 put_setbool(fd, cmd, name, value) 9887 FILE *fd; 9888 char *cmd; 9889 char *name; 9890 int value; 9891 { 9892 if (value < 0) /* global/local option using global value */ 9893 return OK; 9894 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 9895 || put_eol(fd) < 0) 9896 return FAIL; 9897 return OK; 9898 } 9899 9900 /* 9901 * Clear all the terminal options. 9902 * If the option has been allocated, free the memory. 9903 * Terminal options are never hidden or indirect. 9904 */ 9905 void 9906 clear_termoptions() 9907 { 9908 /* 9909 * Reset a few things before clearing the old options. This may cause 9910 * outputting a few things that the terminal doesn't understand, but the 9911 * screen will be cleared later, so this is OK. 9912 */ 9913 #ifdef FEAT_MOUSE_TTY 9914 mch_setmouse(FALSE); /* switch mouse off */ 9915 #endif 9916 #ifdef FEAT_TITLE 9917 mch_restore_title(3); /* restore window titles */ 9918 #endif 9919 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) 9920 /* When starting the GUI close the display opened for the clipboard. 9921 * After restoring the title, because that will need the display. */ 9922 if (gui.starting) 9923 clear_xterm_clip(); 9924 #endif 9925 #ifdef WIN3264 9926 /* 9927 * Check if this is allowed now. 9928 */ 9929 if (can_end_termcap_mode(FALSE) == TRUE) 9930 #endif 9931 stoptermcap(); /* stop termcap mode */ 9932 9933 free_termoptions(); 9934 } 9935 9936 void 9937 free_termoptions() 9938 { 9939 struct vimoption *p; 9940 9941 for (p = &options[0]; p->fullname != NULL; p++) 9942 if (istermoption(p)) 9943 { 9944 if (p->flags & P_ALLOCED) 9945 free_string_option(*(char_u **)(p->var)); 9946 if (p->flags & P_DEF_ALLOCED) 9947 free_string_option(p->def_val[VI_DEFAULT]); 9948 *(char_u **)(p->var) = empty_option; 9949 p->def_val[VI_DEFAULT] = empty_option; 9950 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); 9951 } 9952 clear_termcodes(); 9953 } 9954 9955 /* 9956 * Free the string for one term option, if it was allocated. 9957 * Set the string to empty_option and clear allocated flag. 9958 * "var" points to the option value. 9959 */ 9960 void 9961 free_one_termoption(var) 9962 char_u *var; 9963 { 9964 struct vimoption *p; 9965 9966 for (p = &options[0]; p->fullname != NULL; p++) 9967 if (p->var == var) 9968 { 9969 if (p->flags & P_ALLOCED) 9970 free_string_option(*(char_u **)(p->var)); 9971 *(char_u **)(p->var) = empty_option; 9972 p->flags &= ~P_ALLOCED; 9973 break; 9974 } 9975 } 9976 9977 /* 9978 * Set the terminal option defaults to the current value. 9979 * Used after setting the terminal name. 9980 */ 9981 void 9982 set_term_defaults() 9983 { 9984 struct vimoption *p; 9985 9986 for (p = &options[0]; p->fullname != NULL; p++) 9987 { 9988 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) 9989 { 9990 if (p->flags & P_DEF_ALLOCED) 9991 { 9992 free_string_option(p->def_val[VI_DEFAULT]); 9993 p->flags &= ~P_DEF_ALLOCED; 9994 } 9995 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); 9996 if (p->flags & P_ALLOCED) 9997 { 9998 p->flags |= P_DEF_ALLOCED; 9999 p->flags &= ~P_ALLOCED; /* don't free the value now */ 10000 } 10001 } 10002 } 10003 } 10004 10005 /* 10006 * return TRUE if 'p' starts with 't_' 10007 */ 10008 static int 10009 istermoption(p) 10010 struct vimoption *p; 10011 { 10012 return (p->fullname[0] == 't' && p->fullname[1] == '_'); 10013 } 10014 10015 /* 10016 * Compute columns for ruler and shown command. 'sc_col' is also used to 10017 * decide what the maximum length of a message on the status line can be. 10018 * If there is a status line for the last window, 'sc_col' is independent 10019 * of 'ru_col'. 10020 */ 10021 10022 #define COL_RULER 17 /* columns needed by standard ruler */ 10023 10024 void 10025 comp_col() 10026 { 10027 #if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS) 10028 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); 10029 10030 sc_col = 0; 10031 ru_col = 0; 10032 if (p_ru) 10033 { 10034 #ifdef FEAT_STL_OPT 10035 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; 10036 #else 10037 ru_col = COL_RULER + 1; 10038 #endif 10039 /* no last status line, adjust sc_col */ 10040 if (!last_has_status) 10041 sc_col = ru_col; 10042 } 10043 if (p_sc) 10044 { 10045 sc_col += SHOWCMD_COLS; 10046 if (!p_ru || last_has_status) /* no need for separating space */ 10047 ++sc_col; 10048 } 10049 sc_col = Columns - sc_col; 10050 ru_col = Columns - ru_col; 10051 if (sc_col <= 0) /* screen too narrow, will become a mess */ 10052 sc_col = 1; 10053 if (ru_col <= 0) 10054 ru_col = 1; 10055 #else 10056 sc_col = Columns; 10057 ru_col = Columns; 10058 #endif 10059 } 10060 10061 /* 10062 * Unset local option value, similar to ":set opt<". 10063 */ 10064 void 10065 unset_global_local_option(name, from) 10066 char_u *name; 10067 void *from; 10068 { 10069 struct vimoption *p; 10070 int opt_idx; 10071 buf_T *buf = (buf_T *)from; 10072 10073 opt_idx = findoption(name); 10074 if (opt_idx < 0) 10075 return; 10076 p = &(options[opt_idx]); 10077 10078 switch ((int)p->indir) 10079 { 10080 /* global option with local value: use local value if it's been set */ 10081 case PV_EP: 10082 clear_string_option(&buf->b_p_ep); 10083 break; 10084 case PV_KP: 10085 clear_string_option(&buf->b_p_kp); 10086 break; 10087 case PV_PATH: 10088 clear_string_option(&buf->b_p_path); 10089 break; 10090 case PV_AR: 10091 buf->b_p_ar = -1; 10092 break; 10093 case PV_BKC: 10094 clear_string_option(&buf->b_p_bkc); 10095 buf->b_bkc_flags = 0; 10096 break; 10097 case PV_TAGS: 10098 clear_string_option(&buf->b_p_tags); 10099 break; 10100 case PV_TC: 10101 clear_string_option(&buf->b_p_tc); 10102 buf->b_tc_flags = 0; 10103 break; 10104 #ifdef FEAT_FIND_ID 10105 case PV_DEF: 10106 clear_string_option(&buf->b_p_def); 10107 break; 10108 case PV_INC: 10109 clear_string_option(&buf->b_p_inc); 10110 break; 10111 #endif 10112 #ifdef FEAT_INS_EXPAND 10113 case PV_DICT: 10114 clear_string_option(&buf->b_p_dict); 10115 break; 10116 case PV_TSR: 10117 clear_string_option(&buf->b_p_tsr); 10118 break; 10119 #endif 10120 #ifdef FEAT_QUICKFIX 10121 case PV_EFM: 10122 clear_string_option(&buf->b_p_efm); 10123 break; 10124 case PV_GP: 10125 clear_string_option(&buf->b_p_gp); 10126 break; 10127 case PV_MP: 10128 clear_string_option(&buf->b_p_mp); 10129 break; 10130 #endif 10131 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10132 case PV_BEXPR: 10133 clear_string_option(&buf->b_p_bexpr); 10134 break; 10135 #endif 10136 #if defined(FEAT_CRYPT) 10137 case PV_CM: 10138 clear_string_option(&buf->b_p_cm); 10139 break; 10140 #endif 10141 #ifdef FEAT_STL_OPT 10142 case PV_STL: 10143 clear_string_option(&((win_T *)from)->w_p_stl); 10144 break; 10145 #endif 10146 case PV_UL: 10147 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; 10148 break; 10149 #ifdef FEAT_LISP 10150 case PV_LW: 10151 clear_string_option(&buf->b_p_lw); 10152 break; 10153 #endif 10154 } 10155 } 10156 10157 /* 10158 * Get pointer to option variable, depending on local or global scope. 10159 */ 10160 static char_u * 10161 get_varp_scope(p, opt_flags) 10162 struct vimoption *p; 10163 int opt_flags; 10164 { 10165 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) 10166 { 10167 if (p->var == VAR_WIN) 10168 return (char_u *)GLOBAL_WO(get_varp(p)); 10169 return p->var; 10170 } 10171 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) 10172 { 10173 switch ((int)p->indir) 10174 { 10175 #ifdef FEAT_QUICKFIX 10176 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); 10177 case PV_GP: return (char_u *)&(curbuf->b_p_gp); 10178 case PV_MP: return (char_u *)&(curbuf->b_p_mp); 10179 #endif 10180 case PV_EP: return (char_u *)&(curbuf->b_p_ep); 10181 case PV_KP: return (char_u *)&(curbuf->b_p_kp); 10182 case PV_PATH: return (char_u *)&(curbuf->b_p_path); 10183 case PV_AR: return (char_u *)&(curbuf->b_p_ar); 10184 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); 10185 case PV_TC: return (char_u *)&(curbuf->b_p_tc); 10186 #ifdef FEAT_FIND_ID 10187 case PV_DEF: return (char_u *)&(curbuf->b_p_def); 10188 case PV_INC: return (char_u *)&(curbuf->b_p_inc); 10189 #endif 10190 #ifdef FEAT_INS_EXPAND 10191 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); 10192 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); 10193 #endif 10194 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10195 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); 10196 #endif 10197 #if defined(FEAT_CRYPT) 10198 case PV_CM: return (char_u *)&(curbuf->b_p_cm); 10199 #endif 10200 #ifdef FEAT_STL_OPT 10201 case PV_STL: return (char_u *)&(curwin->w_p_stl); 10202 #endif 10203 case PV_UL: return (char_u *)&(curbuf->b_p_ul); 10204 #ifdef FEAT_LISP 10205 case PV_LW: return (char_u *)&(curbuf->b_p_lw); 10206 #endif 10207 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); 10208 } 10209 return NULL; /* "cannot happen" */ 10210 } 10211 return get_varp(p); 10212 } 10213 10214 /* 10215 * Get pointer to option variable. 10216 */ 10217 static char_u * 10218 get_varp(p) 10219 struct vimoption *p; 10220 { 10221 /* hidden option, always return NULL */ 10222 if (p->var == NULL) 10223 return NULL; 10224 10225 switch ((int)p->indir) 10226 { 10227 case PV_NONE: return p->var; 10228 10229 /* global option with local value: use local value if it's been set */ 10230 case PV_EP: return *curbuf->b_p_ep != NUL 10231 ? (char_u *)&curbuf->b_p_ep : p->var; 10232 case PV_KP: return *curbuf->b_p_kp != NUL 10233 ? (char_u *)&curbuf->b_p_kp : p->var; 10234 case PV_PATH: return *curbuf->b_p_path != NUL 10235 ? (char_u *)&(curbuf->b_p_path) : p->var; 10236 case PV_AR: return curbuf->b_p_ar >= 0 10237 ? (char_u *)&(curbuf->b_p_ar) : p->var; 10238 case PV_TAGS: return *curbuf->b_p_tags != NUL 10239 ? (char_u *)&(curbuf->b_p_tags) : p->var; 10240 case PV_TC: return *curbuf->b_p_tc != NUL 10241 ? (char_u *)&(curbuf->b_p_tc) : p->var; 10242 case PV_BKC: return *curbuf->b_p_bkc != NUL 10243 ? (char_u *)&(curbuf->b_p_bkc) : p->var; 10244 #ifdef FEAT_FIND_ID 10245 case PV_DEF: return *curbuf->b_p_def != NUL 10246 ? (char_u *)&(curbuf->b_p_def) : p->var; 10247 case PV_INC: return *curbuf->b_p_inc != NUL 10248 ? (char_u *)&(curbuf->b_p_inc) : p->var; 10249 #endif 10250 #ifdef FEAT_INS_EXPAND 10251 case PV_DICT: return *curbuf->b_p_dict != NUL 10252 ? (char_u *)&(curbuf->b_p_dict) : p->var; 10253 case PV_TSR: return *curbuf->b_p_tsr != NUL 10254 ? (char_u *)&(curbuf->b_p_tsr) : p->var; 10255 #endif 10256 #ifdef FEAT_QUICKFIX 10257 case PV_EFM: return *curbuf->b_p_efm != NUL 10258 ? (char_u *)&(curbuf->b_p_efm) : p->var; 10259 case PV_GP: return *curbuf->b_p_gp != NUL 10260 ? (char_u *)&(curbuf->b_p_gp) : p->var; 10261 case PV_MP: return *curbuf->b_p_mp != NUL 10262 ? (char_u *)&(curbuf->b_p_mp) : p->var; 10263 #endif 10264 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10265 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL 10266 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; 10267 #endif 10268 #if defined(FEAT_CRYPT) 10269 case PV_CM: return *curbuf->b_p_cm != NUL 10270 ? (char_u *)&(curbuf->b_p_cm) : p->var; 10271 #endif 10272 #ifdef FEAT_STL_OPT 10273 case PV_STL: return *curwin->w_p_stl != NUL 10274 ? (char_u *)&(curwin->w_p_stl) : p->var; 10275 #endif 10276 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL 10277 ? (char_u *)&(curbuf->b_p_ul) : p->var; 10278 #ifdef FEAT_LISP 10279 case PV_LW: return *curbuf->b_p_lw != NUL 10280 ? (char_u *)&(curbuf->b_p_lw) : p->var; 10281 #endif 10282 10283 #ifdef FEAT_ARABIC 10284 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); 10285 #endif 10286 case PV_LIST: return (char_u *)&(curwin->w_p_list); 10287 #ifdef FEAT_SPELL 10288 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); 10289 #endif 10290 #ifdef FEAT_SYN_HL 10291 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); 10292 case PV_CUL: return (char_u *)&(curwin->w_p_cul); 10293 case PV_CC: return (char_u *)&(curwin->w_p_cc); 10294 #endif 10295 #ifdef FEAT_DIFF 10296 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); 10297 #endif 10298 #ifdef FEAT_FOLDING 10299 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); 10300 case PV_FEN: return (char_u *)&(curwin->w_p_fen); 10301 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); 10302 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); 10303 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); 10304 case PV_FML: return (char_u *)&(curwin->w_p_fml); 10305 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); 10306 # ifdef FEAT_EVAL 10307 case PV_FDE: return (char_u *)&(curwin->w_p_fde); 10308 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); 10309 # endif 10310 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); 10311 #endif 10312 case PV_NU: return (char_u *)&(curwin->w_p_nu); 10313 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); 10314 #ifdef FEAT_LINEBREAK 10315 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); 10316 #endif 10317 #ifdef FEAT_WINDOWS 10318 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); 10319 #endif 10320 #ifdef FEAT_VERTSPLIT 10321 case PV_WFW: return (char_u *)&(curwin->w_p_wfw); 10322 #endif 10323 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 10324 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); 10325 #endif 10326 #ifdef FEAT_RIGHTLEFT 10327 case PV_RL: return (char_u *)&(curwin->w_p_rl); 10328 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); 10329 #endif 10330 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); 10331 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); 10332 #ifdef FEAT_LINEBREAK 10333 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); 10334 case PV_BRI: return (char_u *)&(curwin->w_p_bri); 10335 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); 10336 #endif 10337 #ifdef FEAT_SCROLLBIND 10338 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); 10339 #endif 10340 #ifdef FEAT_CURSORBIND 10341 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb); 10342 #endif 10343 #ifdef FEAT_CONCEAL 10344 case PV_COCU: return (char_u *)&(curwin->w_p_cocu); 10345 case PV_COLE: return (char_u *)&(curwin->w_p_cole); 10346 #endif 10347 10348 case PV_AI: return (char_u *)&(curbuf->b_p_ai); 10349 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); 10350 #ifdef FEAT_MBYTE 10351 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); 10352 #endif 10353 #if defined(FEAT_QUICKFIX) 10354 case PV_BH: return (char_u *)&(curbuf->b_p_bh); 10355 case PV_BT: return (char_u *)&(curbuf->b_p_bt); 10356 #endif 10357 case PV_BL: return (char_u *)&(curbuf->b_p_bl); 10358 case PV_CI: return (char_u *)&(curbuf->b_p_ci); 10359 #ifdef FEAT_CINDENT 10360 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); 10361 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); 10362 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); 10363 #endif 10364 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 10365 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); 10366 #endif 10367 #ifdef FEAT_COMMENTS 10368 case PV_COM: return (char_u *)&(curbuf->b_p_com); 10369 #endif 10370 #ifdef FEAT_FOLDING 10371 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); 10372 #endif 10373 #ifdef FEAT_INS_EXPAND 10374 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); 10375 #endif 10376 #ifdef FEAT_COMPL_FUNC 10377 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); 10378 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); 10379 #endif 10380 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); 10381 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); 10382 case PV_ET: return (char_u *)&(curbuf->b_p_et); 10383 #ifdef FEAT_MBYTE 10384 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); 10385 #endif 10386 case PV_FF: return (char_u *)&(curbuf->b_p_ff); 10387 #ifdef FEAT_AUTOCMD 10388 case PV_FT: return (char_u *)&(curbuf->b_p_ft); 10389 #endif 10390 case PV_FO: return (char_u *)&(curbuf->b_p_fo); 10391 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); 10392 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); 10393 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); 10394 case PV_INF: return (char_u *)&(curbuf->b_p_inf); 10395 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); 10396 #ifdef FEAT_FIND_ID 10397 # ifdef FEAT_EVAL 10398 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); 10399 # endif 10400 #endif 10401 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 10402 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); 10403 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); 10404 #endif 10405 #ifdef FEAT_EVAL 10406 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); 10407 #endif 10408 #ifdef FEAT_CRYPT 10409 case PV_KEY: return (char_u *)&(curbuf->b_p_key); 10410 #endif 10411 #ifdef FEAT_LISP 10412 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); 10413 #endif 10414 case PV_ML: return (char_u *)&(curbuf->b_p_ml); 10415 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); 10416 case PV_MA: return (char_u *)&(curbuf->b_p_ma); 10417 case PV_MOD: return (char_u *)&(curbuf->b_changed); 10418 case PV_NF: return (char_u *)&(curbuf->b_p_nf); 10419 case PV_PI: return (char_u *)&(curbuf->b_p_pi); 10420 #ifdef FEAT_TEXTOBJ 10421 case PV_QE: return (char_u *)&(curbuf->b_p_qe); 10422 #endif 10423 case PV_RO: return (char_u *)&(curbuf->b_p_ro); 10424 #ifdef FEAT_SMARTINDENT 10425 case PV_SI: return (char_u *)&(curbuf->b_p_si); 10426 #endif 10427 #ifndef SHORT_FNAME 10428 case PV_SN: return (char_u *)&(curbuf->b_p_sn); 10429 #endif 10430 case PV_STS: return (char_u *)&(curbuf->b_p_sts); 10431 #ifdef FEAT_SEARCHPATH 10432 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); 10433 #endif 10434 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); 10435 #ifdef FEAT_SYN_HL 10436 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); 10437 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); 10438 #endif 10439 #ifdef FEAT_SPELL 10440 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc); 10441 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf); 10442 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); 10443 #endif 10444 case PV_SW: return (char_u *)&(curbuf->b_p_sw); 10445 case PV_TS: return (char_u *)&(curbuf->b_p_ts); 10446 case PV_TW: return (char_u *)&(curbuf->b_p_tw); 10447 case PV_TX: return (char_u *)&(curbuf->b_p_tx); 10448 #ifdef FEAT_PERSISTENT_UNDO 10449 case PV_UDF: return (char_u *)&(curbuf->b_p_udf); 10450 #endif 10451 case PV_WM: return (char_u *)&(curbuf->b_p_wm); 10452 #ifdef FEAT_KEYMAP 10453 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); 10454 #endif 10455 default: EMSG(_("E356: get_varp ERROR")); 10456 } 10457 /* always return a valid pointer to avoid a crash! */ 10458 return (char_u *)&(curbuf->b_p_wm); 10459 } 10460 10461 /* 10462 * Get the value of 'equalprg', either the buffer-local one or the global one. 10463 */ 10464 char_u * 10465 get_equalprg() 10466 { 10467 if (*curbuf->b_p_ep == NUL) 10468 return p_ep; 10469 return curbuf->b_p_ep; 10470 } 10471 10472 #if defined(FEAT_WINDOWS) || defined(PROTO) 10473 /* 10474 * Copy options from one window to another. 10475 * Used when splitting a window. 10476 */ 10477 void 10478 win_copy_options(wp_from, wp_to) 10479 win_T *wp_from; 10480 win_T *wp_to; 10481 { 10482 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); 10483 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); 10484 # ifdef FEAT_RIGHTLEFT 10485 # ifdef FEAT_FKMAP 10486 /* Is this right? */ 10487 wp_to->w_farsi = wp_from->w_farsi; 10488 # endif 10489 # endif 10490 #if defined(FEAT_LINEBREAK) 10491 briopt_check(wp_to); 10492 #endif 10493 } 10494 #endif 10495 10496 /* 10497 * Copy the options from one winopt_T to another. 10498 * Doesn't free the old option values in "to", use clear_winopt() for that. 10499 * The 'scroll' option is not copied, because it depends on the window height. 10500 * The 'previewwindow' option is reset, there can be only one preview window. 10501 */ 10502 void 10503 copy_winopt(from, to) 10504 winopt_T *from; 10505 winopt_T *to; 10506 { 10507 #ifdef FEAT_ARABIC 10508 to->wo_arab = from->wo_arab; 10509 #endif 10510 to->wo_list = from->wo_list; 10511 to->wo_nu = from->wo_nu; 10512 to->wo_rnu = from->wo_rnu; 10513 #ifdef FEAT_LINEBREAK 10514 to->wo_nuw = from->wo_nuw; 10515 #endif 10516 #ifdef FEAT_RIGHTLEFT 10517 to->wo_rl = from->wo_rl; 10518 to->wo_rlc = vim_strsave(from->wo_rlc); 10519 #endif 10520 #ifdef FEAT_STL_OPT 10521 to->wo_stl = vim_strsave(from->wo_stl); 10522 #endif 10523 to->wo_wrap = from->wo_wrap; 10524 #ifdef FEAT_DIFF 10525 to->wo_wrap_save = from->wo_wrap_save; 10526 #endif 10527 #ifdef FEAT_LINEBREAK 10528 to->wo_lbr = from->wo_lbr; 10529 to->wo_bri = from->wo_bri; 10530 to->wo_briopt = vim_strsave(from->wo_briopt); 10531 #endif 10532 #ifdef FEAT_SCROLLBIND 10533 to->wo_scb = from->wo_scb; 10534 to->wo_scb_save = from->wo_scb_save; 10535 #endif 10536 #ifdef FEAT_CURSORBIND 10537 to->wo_crb = from->wo_crb; 10538 to->wo_crb_save = from->wo_crb_save; 10539 #endif 10540 #ifdef FEAT_SPELL 10541 to->wo_spell = from->wo_spell; 10542 #endif 10543 #ifdef FEAT_SYN_HL 10544 to->wo_cuc = from->wo_cuc; 10545 to->wo_cul = from->wo_cul; 10546 to->wo_cc = vim_strsave(from->wo_cc); 10547 #endif 10548 #ifdef FEAT_DIFF 10549 to->wo_diff = from->wo_diff; 10550 to->wo_diff_saved = from->wo_diff_saved; 10551 #endif 10552 #ifdef FEAT_CONCEAL 10553 to->wo_cocu = vim_strsave(from->wo_cocu); 10554 to->wo_cole = from->wo_cole; 10555 #endif 10556 #ifdef FEAT_FOLDING 10557 to->wo_fdc = from->wo_fdc; 10558 to->wo_fdc_save = from->wo_fdc_save; 10559 to->wo_fen = from->wo_fen; 10560 to->wo_fen_save = from->wo_fen_save; 10561 to->wo_fdi = vim_strsave(from->wo_fdi); 10562 to->wo_fml = from->wo_fml; 10563 to->wo_fdl = from->wo_fdl; 10564 to->wo_fdl_save = from->wo_fdl_save; 10565 to->wo_fdm = vim_strsave(from->wo_fdm); 10566 to->wo_fdm_save = from->wo_diff_saved 10567 ? vim_strsave(from->wo_fdm_save) : empty_option; 10568 to->wo_fdn = from->wo_fdn; 10569 # ifdef FEAT_EVAL 10570 to->wo_fde = vim_strsave(from->wo_fde); 10571 to->wo_fdt = vim_strsave(from->wo_fdt); 10572 # endif 10573 to->wo_fmr = vim_strsave(from->wo_fmr); 10574 #endif 10575 check_winopt(to); /* don't want NULL pointers */ 10576 } 10577 10578 /* 10579 * Check string options in a window for a NULL value. 10580 */ 10581 void 10582 check_win_options(win) 10583 win_T *win; 10584 { 10585 check_winopt(&win->w_onebuf_opt); 10586 check_winopt(&win->w_allbuf_opt); 10587 } 10588 10589 /* 10590 * Check for NULL pointers in a winopt_T and replace them with empty_option. 10591 */ 10592 static void 10593 check_winopt(wop) 10594 winopt_T *wop UNUSED; 10595 { 10596 #ifdef FEAT_FOLDING 10597 check_string_option(&wop->wo_fdi); 10598 check_string_option(&wop->wo_fdm); 10599 check_string_option(&wop->wo_fdm_save); 10600 # ifdef FEAT_EVAL 10601 check_string_option(&wop->wo_fde); 10602 check_string_option(&wop->wo_fdt); 10603 # endif 10604 check_string_option(&wop->wo_fmr); 10605 #endif 10606 #ifdef FEAT_RIGHTLEFT 10607 check_string_option(&wop->wo_rlc); 10608 #endif 10609 #ifdef FEAT_STL_OPT 10610 check_string_option(&wop->wo_stl); 10611 #endif 10612 #ifdef FEAT_SYN_HL 10613 check_string_option(&wop->wo_cc); 10614 #endif 10615 #ifdef FEAT_CONCEAL 10616 check_string_option(&wop->wo_cocu); 10617 #endif 10618 #ifdef FEAT_LINEBREAK 10619 check_string_option(&wop->wo_briopt); 10620 #endif 10621 } 10622 10623 /* 10624 * Free the allocated memory inside a winopt_T. 10625 */ 10626 void 10627 clear_winopt(wop) 10628 winopt_T *wop UNUSED; 10629 { 10630 #ifdef FEAT_FOLDING 10631 clear_string_option(&wop->wo_fdi); 10632 clear_string_option(&wop->wo_fdm); 10633 clear_string_option(&wop->wo_fdm_save); 10634 # ifdef FEAT_EVAL 10635 clear_string_option(&wop->wo_fde); 10636 clear_string_option(&wop->wo_fdt); 10637 # endif 10638 clear_string_option(&wop->wo_fmr); 10639 #endif 10640 #ifdef FEAT_LINEBREAK 10641 clear_string_option(&wop->wo_briopt); 10642 #endif 10643 #ifdef FEAT_RIGHTLEFT 10644 clear_string_option(&wop->wo_rlc); 10645 #endif 10646 #ifdef FEAT_STL_OPT 10647 clear_string_option(&wop->wo_stl); 10648 #endif 10649 #ifdef FEAT_SYN_HL 10650 clear_string_option(&wop->wo_cc); 10651 #endif 10652 #ifdef FEAT_CONCEAL 10653 clear_string_option(&wop->wo_cocu); 10654 #endif 10655 } 10656 10657 /* 10658 * Copy global option values to local options for one buffer. 10659 * Used when creating a new buffer and sometimes when entering a buffer. 10660 * flags: 10661 * BCO_ENTER We will enter the buf buffer. 10662 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when 10663 * appropriate. 10664 * BCO_NOHELP Don't copy the values to a help buffer. 10665 */ 10666 void 10667 buf_copy_options(buf, flags) 10668 buf_T *buf; 10669 int flags; 10670 { 10671 int should_copy = TRUE; 10672 char_u *save_p_isk = NULL; /* init for GCC */ 10673 int dont_do_help; 10674 int did_isk = FALSE; 10675 10676 /* 10677 * Don't do anything if the buffer is invalid. 10678 */ 10679 if (buf == NULL || !buf_valid(buf)) 10680 return; 10681 10682 /* 10683 * Skip this when the option defaults have not been set yet. Happens when 10684 * main() allocates the first buffer. 10685 */ 10686 if (p_cpo != NULL) 10687 { 10688 /* 10689 * Always copy when entering and 'cpo' contains 'S'. 10690 * Don't copy when already initialized. 10691 * Don't copy when 'cpo' contains 's' and not entering. 10692 * 'S' BCO_ENTER initialized 's' should_copy 10693 * yes yes X X TRUE 10694 * yes no yes X FALSE 10695 * no X yes X FALSE 10696 * X no no yes FALSE 10697 * X no no no TRUE 10698 * no yes no X TRUE 10699 */ 10700 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) 10701 && (buf->b_p_initialized 10702 || (!(flags & BCO_ENTER) 10703 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) 10704 should_copy = FALSE; 10705 10706 if (should_copy || (flags & BCO_ALWAYS)) 10707 { 10708 /* Don't copy the options specific to a help buffer when 10709 * BCO_NOHELP is given or the options were initialized already 10710 * (jumping back to a help file with CTRL-T or CTRL-O) */ 10711 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) 10712 || buf->b_p_initialized; 10713 if (dont_do_help) /* don't free b_p_isk */ 10714 { 10715 save_p_isk = buf->b_p_isk; 10716 buf->b_p_isk = NULL; 10717 } 10718 /* 10719 * Always free the allocated strings. 10720 * If not already initialized, set 'readonly' and copy 'fileformat'. 10721 */ 10722 if (!buf->b_p_initialized) 10723 { 10724 free_buf_options(buf, TRUE); 10725 buf->b_p_ro = FALSE; /* don't copy readonly */ 10726 buf->b_p_tx = p_tx; 10727 #ifdef FEAT_MBYTE 10728 buf->b_p_fenc = vim_strsave(p_fenc); 10729 #endif 10730 buf->b_p_ff = vim_strsave(p_ff); 10731 #if defined(FEAT_QUICKFIX) 10732 buf->b_p_bh = empty_option; 10733 buf->b_p_bt = empty_option; 10734 #endif 10735 } 10736 else 10737 free_buf_options(buf, FALSE); 10738 10739 buf->b_p_ai = p_ai; 10740 buf->b_p_ai_nopaste = p_ai_nopaste; 10741 buf->b_p_sw = p_sw; 10742 buf->b_p_tw = p_tw; 10743 buf->b_p_tw_nopaste = p_tw_nopaste; 10744 buf->b_p_tw_nobin = p_tw_nobin; 10745 buf->b_p_wm = p_wm; 10746 buf->b_p_wm_nopaste = p_wm_nopaste; 10747 buf->b_p_wm_nobin = p_wm_nobin; 10748 buf->b_p_bin = p_bin; 10749 #ifdef FEAT_MBYTE 10750 buf->b_p_bomb = p_bomb; 10751 #endif 10752 buf->b_p_fixeol = p_fixeol; 10753 buf->b_p_et = p_et; 10754 buf->b_p_et_nobin = p_et_nobin; 10755 buf->b_p_et_nopaste = p_et_nopaste; 10756 buf->b_p_ml = p_ml; 10757 buf->b_p_ml_nobin = p_ml_nobin; 10758 buf->b_p_inf = p_inf; 10759 buf->b_p_swf = p_swf; 10760 #ifdef FEAT_INS_EXPAND 10761 buf->b_p_cpt = vim_strsave(p_cpt); 10762 #endif 10763 #ifdef FEAT_COMPL_FUNC 10764 buf->b_p_cfu = vim_strsave(p_cfu); 10765 buf->b_p_ofu = vim_strsave(p_ofu); 10766 #endif 10767 buf->b_p_sts = p_sts; 10768 buf->b_p_sts_nopaste = p_sts_nopaste; 10769 #ifndef SHORT_FNAME 10770 buf->b_p_sn = p_sn; 10771 #endif 10772 #ifdef FEAT_COMMENTS 10773 buf->b_p_com = vim_strsave(p_com); 10774 #endif 10775 #ifdef FEAT_FOLDING 10776 buf->b_p_cms = vim_strsave(p_cms); 10777 #endif 10778 buf->b_p_fo = vim_strsave(p_fo); 10779 buf->b_p_flp = vim_strsave(p_flp); 10780 buf->b_p_nf = vim_strsave(p_nf); 10781 buf->b_p_mps = vim_strsave(p_mps); 10782 #ifdef FEAT_SMARTINDENT 10783 buf->b_p_si = p_si; 10784 #endif 10785 buf->b_p_ci = p_ci; 10786 #ifdef FEAT_CINDENT 10787 buf->b_p_cin = p_cin; 10788 buf->b_p_cink = vim_strsave(p_cink); 10789 buf->b_p_cino = vim_strsave(p_cino); 10790 #endif 10791 #ifdef FEAT_AUTOCMD 10792 /* Don't copy 'filetype', it must be detected */ 10793 buf->b_p_ft = empty_option; 10794 #endif 10795 buf->b_p_pi = p_pi; 10796 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 10797 buf->b_p_cinw = vim_strsave(p_cinw); 10798 #endif 10799 #ifdef FEAT_LISP 10800 buf->b_p_lisp = p_lisp; 10801 #endif 10802 #ifdef FEAT_SYN_HL 10803 /* Don't copy 'syntax', it must be set */ 10804 buf->b_p_syn = empty_option; 10805 buf->b_p_smc = p_smc; 10806 #endif 10807 #ifdef FEAT_SPELL 10808 buf->b_s.b_p_spc = vim_strsave(p_spc); 10809 (void)compile_cap_prog(&buf->b_s); 10810 buf->b_s.b_p_spf = vim_strsave(p_spf); 10811 buf->b_s.b_p_spl = vim_strsave(p_spl); 10812 #endif 10813 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 10814 buf->b_p_inde = vim_strsave(p_inde); 10815 buf->b_p_indk = vim_strsave(p_indk); 10816 #endif 10817 #if defined(FEAT_EVAL) 10818 buf->b_p_fex = vim_strsave(p_fex); 10819 #endif 10820 #ifdef FEAT_CRYPT 10821 buf->b_p_key = vim_strsave(p_key); 10822 #endif 10823 #ifdef FEAT_SEARCHPATH 10824 buf->b_p_sua = vim_strsave(p_sua); 10825 #endif 10826 #ifdef FEAT_KEYMAP 10827 buf->b_p_keymap = vim_strsave(p_keymap); 10828 buf->b_kmap_state |= KEYMAP_INIT; 10829 #endif 10830 /* This isn't really an option, but copying the langmap and IME 10831 * state from the current buffer is better than resetting it. */ 10832 buf->b_p_iminsert = p_iminsert; 10833 buf->b_p_imsearch = p_imsearch; 10834 10835 /* options that are normally global but also have a local value 10836 * are not copied, start using the global value */ 10837 buf->b_p_ar = -1; 10838 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; 10839 buf->b_p_bkc = empty_option; 10840 buf->b_bkc_flags = 0; 10841 #ifdef FEAT_QUICKFIX 10842 buf->b_p_gp = empty_option; 10843 buf->b_p_mp = empty_option; 10844 buf->b_p_efm = empty_option; 10845 #endif 10846 buf->b_p_ep = empty_option; 10847 buf->b_p_kp = empty_option; 10848 buf->b_p_path = empty_option; 10849 buf->b_p_tags = empty_option; 10850 buf->b_p_tc = empty_option; 10851 buf->b_tc_flags = 0; 10852 #ifdef FEAT_FIND_ID 10853 buf->b_p_def = empty_option; 10854 buf->b_p_inc = empty_option; 10855 # ifdef FEAT_EVAL 10856 buf->b_p_inex = vim_strsave(p_inex); 10857 # endif 10858 #endif 10859 #ifdef FEAT_INS_EXPAND 10860 buf->b_p_dict = empty_option; 10861 buf->b_p_tsr = empty_option; 10862 #endif 10863 #ifdef FEAT_TEXTOBJ 10864 buf->b_p_qe = vim_strsave(p_qe); 10865 #endif 10866 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10867 buf->b_p_bexpr = empty_option; 10868 #endif 10869 #if defined(FEAT_CRYPT) 10870 buf->b_p_cm = empty_option; 10871 #endif 10872 #ifdef FEAT_PERSISTENT_UNDO 10873 buf->b_p_udf = p_udf; 10874 #endif 10875 #ifdef FEAT_LISP 10876 buf->b_p_lw = empty_option; 10877 #endif 10878 10879 /* 10880 * Don't copy the options set by ex_help(), use the saved values, 10881 * when going from a help buffer to a non-help buffer. 10882 * Don't touch these at all when BCO_NOHELP is used and going from 10883 * or to a help buffer. 10884 */ 10885 if (dont_do_help) 10886 buf->b_p_isk = save_p_isk; 10887 else 10888 { 10889 buf->b_p_isk = vim_strsave(p_isk); 10890 did_isk = TRUE; 10891 buf->b_p_ts = p_ts; 10892 buf->b_help = FALSE; 10893 #ifdef FEAT_QUICKFIX 10894 if (buf->b_p_bt[0] == 'h') 10895 clear_string_option(&buf->b_p_bt); 10896 #endif 10897 buf->b_p_ma = p_ma; 10898 } 10899 } 10900 10901 /* 10902 * When the options should be copied (ignoring BCO_ALWAYS), set the 10903 * flag that indicates that the options have been initialized. 10904 */ 10905 if (should_copy) 10906 buf->b_p_initialized = TRUE; 10907 } 10908 10909 check_buf_options(buf); /* make sure we don't have NULLs */ 10910 if (did_isk) 10911 (void)buf_init_chartab(buf, FALSE); 10912 } 10913 10914 /* 10915 * Reset the 'modifiable' option and its default value. 10916 */ 10917 void 10918 reset_modifiable() 10919 { 10920 int opt_idx; 10921 10922 curbuf->b_p_ma = FALSE; 10923 p_ma = FALSE; 10924 opt_idx = findoption((char_u *)"ma"); 10925 if (opt_idx >= 0) 10926 options[opt_idx].def_val[VI_DEFAULT] = FALSE; 10927 } 10928 10929 /* 10930 * Set the global value for 'iminsert' to the local value. 10931 */ 10932 void 10933 set_iminsert_global() 10934 { 10935 p_iminsert = curbuf->b_p_iminsert; 10936 } 10937 10938 /* 10939 * Set the global value for 'imsearch' to the local value. 10940 */ 10941 void 10942 set_imsearch_global() 10943 { 10944 p_imsearch = curbuf->b_p_imsearch; 10945 } 10946 10947 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 10948 static int expand_option_idx = -1; 10949 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; 10950 static int expand_option_flags = 0; 10951 10952 void 10953 set_context_in_set_cmd(xp, arg, opt_flags) 10954 expand_T *xp; 10955 char_u *arg; 10956 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ 10957 { 10958 int nextchar; 10959 long_u flags = 0; /* init for GCC */ 10960 int opt_idx = 0; /* init for GCC */ 10961 char_u *p; 10962 char_u *s; 10963 int is_term_option = FALSE; 10964 int key; 10965 10966 expand_option_flags = opt_flags; 10967 10968 xp->xp_context = EXPAND_SETTINGS; 10969 if (*arg == NUL) 10970 { 10971 xp->xp_pattern = arg; 10972 return; 10973 } 10974 p = arg + STRLEN(arg) - 1; 10975 if (*p == ' ' && *(p - 1) != '\\') 10976 { 10977 xp->xp_pattern = p + 1; 10978 return; 10979 } 10980 while (p > arg) 10981 { 10982 s = p; 10983 /* count number of backslashes before ' ' or ',' */ 10984 if (*p == ' ' || *p == ',') 10985 { 10986 while (s > arg && *(s - 1) == '\\') 10987 --s; 10988 } 10989 /* break at a space with an even number of backslashes */ 10990 if (*p == ' ' && ((p - s) & 1) == 0) 10991 { 10992 ++p; 10993 break; 10994 } 10995 --p; 10996 } 10997 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) 10998 { 10999 xp->xp_context = EXPAND_BOOL_SETTINGS; 11000 p += 2; 11001 } 11002 if (STRNCMP(p, "inv", 3) == 0) 11003 { 11004 xp->xp_context = EXPAND_BOOL_SETTINGS; 11005 p += 3; 11006 } 11007 xp->xp_pattern = arg = p; 11008 if (*arg == '<') 11009 { 11010 while (*p != '>') 11011 if (*p++ == NUL) /* expand terminal option name */ 11012 return; 11013 key = get_special_key_code(arg + 1); 11014 if (key == 0) /* unknown name */ 11015 { 11016 xp->xp_context = EXPAND_NOTHING; 11017 return; 11018 } 11019 nextchar = *++p; 11020 is_term_option = TRUE; 11021 expand_option_name[2] = KEY2TERMCAP0(key); 11022 expand_option_name[3] = KEY2TERMCAP1(key); 11023 } 11024 else 11025 { 11026 if (p[0] == 't' && p[1] == '_') 11027 { 11028 p += 2; 11029 if (*p != NUL) 11030 ++p; 11031 if (*p == NUL) 11032 return; /* expand option name */ 11033 nextchar = *++p; 11034 is_term_option = TRUE; 11035 expand_option_name[2] = p[-2]; 11036 expand_option_name[3] = p[-1]; 11037 } 11038 else 11039 { 11040 /* Allow * wildcard */ 11041 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') 11042 p++; 11043 if (*p == NUL) 11044 return; 11045 nextchar = *p; 11046 *p = NUL; 11047 opt_idx = findoption(arg); 11048 *p = nextchar; 11049 if (opt_idx == -1 || options[opt_idx].var == NULL) 11050 { 11051 xp->xp_context = EXPAND_NOTHING; 11052 return; 11053 } 11054 flags = options[opt_idx].flags; 11055 if (flags & P_BOOL) 11056 { 11057 xp->xp_context = EXPAND_NOTHING; 11058 return; 11059 } 11060 } 11061 } 11062 /* handle "-=" and "+=" */ 11063 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') 11064 { 11065 ++p; 11066 nextchar = '='; 11067 } 11068 if ((nextchar != '=' && nextchar != ':') 11069 || xp->xp_context == EXPAND_BOOL_SETTINGS) 11070 { 11071 xp->xp_context = EXPAND_UNSUCCESSFUL; 11072 return; 11073 } 11074 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) 11075 { 11076 xp->xp_context = EXPAND_OLD_SETTING; 11077 if (is_term_option) 11078 expand_option_idx = -1; 11079 else 11080 expand_option_idx = opt_idx; 11081 xp->xp_pattern = p + 1; 11082 return; 11083 } 11084 xp->xp_context = EXPAND_NOTHING; 11085 if (is_term_option || (flags & P_NUM)) 11086 return; 11087 11088 xp->xp_pattern = p + 1; 11089 11090 if (flags & P_EXPAND) 11091 { 11092 p = options[opt_idx].var; 11093 if (p == (char_u *)&p_bdir 11094 || p == (char_u *)&p_dir 11095 || p == (char_u *)&p_path 11096 || p == (char_u *)&p_rtp 11097 #ifdef FEAT_SEARCHPATH 11098 || p == (char_u *)&p_cdpath 11099 #endif 11100 #ifdef FEAT_SESSION 11101 || p == (char_u *)&p_vdir 11102 #endif 11103 ) 11104 { 11105 xp->xp_context = EXPAND_DIRECTORIES; 11106 if (p == (char_u *)&p_path 11107 #ifdef FEAT_SEARCHPATH 11108 || p == (char_u *)&p_cdpath 11109 #endif 11110 ) 11111 xp->xp_backslash = XP_BS_THREE; 11112 else 11113 xp->xp_backslash = XP_BS_ONE; 11114 } 11115 else 11116 { 11117 xp->xp_context = EXPAND_FILES; 11118 /* for 'tags' need three backslashes for a space */ 11119 if (p == (char_u *)&p_tags) 11120 xp->xp_backslash = XP_BS_THREE; 11121 else 11122 xp->xp_backslash = XP_BS_ONE; 11123 } 11124 } 11125 11126 /* For an option that is a list of file names, find the start of the 11127 * last file name. */ 11128 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) 11129 { 11130 /* count number of backslashes before ' ' or ',' */ 11131 if (*p == ' ' || *p == ',') 11132 { 11133 s = p; 11134 while (s > xp->xp_pattern && *(s - 1) == '\\') 11135 --s; 11136 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) 11137 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) 11138 { 11139 xp->xp_pattern = p + 1; 11140 break; 11141 } 11142 } 11143 11144 #ifdef FEAT_SPELL 11145 /* for 'spellsuggest' start at "file:" */ 11146 if (options[opt_idx].var == (char_u *)&p_sps 11147 && STRNCMP(p, "file:", 5) == 0) 11148 { 11149 xp->xp_pattern = p + 5; 11150 break; 11151 } 11152 #endif 11153 } 11154 11155 return; 11156 } 11157 11158 int 11159 ExpandSettings(xp, regmatch, num_file, file) 11160 expand_T *xp; 11161 regmatch_T *regmatch; 11162 int *num_file; 11163 char_u ***file; 11164 { 11165 int num_normal = 0; /* Nr of matching non-term-code settings */ 11166 int num_term = 0; /* Nr of matching terminal code settings */ 11167 int opt_idx; 11168 int match; 11169 int count = 0; 11170 char_u *str; 11171 int loop; 11172 int is_term_opt; 11173 char_u name_buf[MAX_KEY_NAME_LEN]; 11174 static char *(names[]) = {"all", "termcap"}; 11175 int ic = regmatch->rm_ic; /* remember the ignore-case flag */ 11176 11177 /* do this loop twice: 11178 * loop == 0: count the number of matching options 11179 * loop == 1: copy the matching options into allocated memory 11180 */ 11181 for (loop = 0; loop <= 1; ++loop) 11182 { 11183 regmatch->rm_ic = ic; 11184 if (xp->xp_context != EXPAND_BOOL_SETTINGS) 11185 { 11186 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); 11187 ++match) 11188 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) 11189 { 11190 if (loop == 0) 11191 num_normal++; 11192 else 11193 (*file)[count++] = vim_strsave((char_u *)names[match]); 11194 } 11195 } 11196 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; 11197 opt_idx++) 11198 { 11199 if (options[opt_idx].var == NULL) 11200 continue; 11201 if (xp->xp_context == EXPAND_BOOL_SETTINGS 11202 && !(options[opt_idx].flags & P_BOOL)) 11203 continue; 11204 is_term_opt = istermoption(&options[opt_idx]); 11205 if (is_term_opt && num_normal > 0) 11206 continue; 11207 match = FALSE; 11208 if (vim_regexec(regmatch, str, (colnr_T)0) 11209 || (options[opt_idx].shortname != NULL 11210 && vim_regexec(regmatch, 11211 (char_u *)options[opt_idx].shortname, (colnr_T)0))) 11212 match = TRUE; 11213 else if (is_term_opt) 11214 { 11215 name_buf[0] = '<'; 11216 name_buf[1] = 't'; 11217 name_buf[2] = '_'; 11218 name_buf[3] = str[2]; 11219 name_buf[4] = str[3]; 11220 name_buf[5] = '>'; 11221 name_buf[6] = NUL; 11222 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11223 { 11224 match = TRUE; 11225 str = name_buf; 11226 } 11227 } 11228 if (match) 11229 { 11230 if (loop == 0) 11231 { 11232 if (is_term_opt) 11233 num_term++; 11234 else 11235 num_normal++; 11236 } 11237 else 11238 (*file)[count++] = vim_strsave(str); 11239 } 11240 } 11241 /* 11242 * Check terminal key codes, these are not in the option table 11243 */ 11244 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) 11245 { 11246 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) 11247 { 11248 if (!isprint(str[0]) || !isprint(str[1])) 11249 continue; 11250 11251 name_buf[0] = 't'; 11252 name_buf[1] = '_'; 11253 name_buf[2] = str[0]; 11254 name_buf[3] = str[1]; 11255 name_buf[4] = NUL; 11256 11257 match = FALSE; 11258 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11259 match = TRUE; 11260 else 11261 { 11262 name_buf[0] = '<'; 11263 name_buf[1] = 't'; 11264 name_buf[2] = '_'; 11265 name_buf[3] = str[0]; 11266 name_buf[4] = str[1]; 11267 name_buf[5] = '>'; 11268 name_buf[6] = NUL; 11269 11270 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11271 match = TRUE; 11272 } 11273 if (match) 11274 { 11275 if (loop == 0) 11276 num_term++; 11277 else 11278 (*file)[count++] = vim_strsave(name_buf); 11279 } 11280 } 11281 11282 /* 11283 * Check special key names. 11284 */ 11285 regmatch->rm_ic = TRUE; /* ignore case here */ 11286 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) 11287 { 11288 name_buf[0] = '<'; 11289 STRCPY(name_buf + 1, str); 11290 STRCAT(name_buf, ">"); 11291 11292 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11293 { 11294 if (loop == 0) 11295 num_term++; 11296 else 11297 (*file)[count++] = vim_strsave(name_buf); 11298 } 11299 } 11300 } 11301 if (loop == 0) 11302 { 11303 if (num_normal > 0) 11304 *num_file = num_normal; 11305 else if (num_term > 0) 11306 *num_file = num_term; 11307 else 11308 return OK; 11309 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *))); 11310 if (*file == NULL) 11311 { 11312 *file = (char_u **)""; 11313 return FAIL; 11314 } 11315 } 11316 } 11317 return OK; 11318 } 11319 11320 int 11321 ExpandOldSetting(num_file, file) 11322 int *num_file; 11323 char_u ***file; 11324 { 11325 char_u *var = NULL; /* init for GCC */ 11326 char_u *buf; 11327 11328 *num_file = 0; 11329 *file = (char_u **)alloc((unsigned)sizeof(char_u *)); 11330 if (*file == NULL) 11331 return FAIL; 11332 11333 /* 11334 * For a terminal key code expand_option_idx is < 0. 11335 */ 11336 if (expand_option_idx < 0) 11337 { 11338 var = find_termcode(expand_option_name + 2); 11339 if (var == NULL) 11340 expand_option_idx = findoption(expand_option_name); 11341 } 11342 11343 if (expand_option_idx >= 0) 11344 { 11345 /* put string of option value in NameBuff */ 11346 option_value2string(&options[expand_option_idx], expand_option_flags); 11347 var = NameBuff; 11348 } 11349 else if (var == NULL) 11350 var = (char_u *)""; 11351 11352 /* A backslash is required before some characters. This is the reverse of 11353 * what happens in do_set(). */ 11354 buf = vim_strsave_escaped(var, escape_chars); 11355 11356 if (buf == NULL) 11357 { 11358 vim_free(*file); 11359 *file = NULL; 11360 return FAIL; 11361 } 11362 11363 #ifdef BACKSLASH_IN_FILENAME 11364 /* For MS-Windows et al. we don't double backslashes at the start and 11365 * before a file name character. */ 11366 for (var = buf; *var != NUL; mb_ptr_adv(var)) 11367 if (var[0] == '\\' && var[1] == '\\' 11368 && expand_option_idx >= 0 11369 && (options[expand_option_idx].flags & P_EXPAND) 11370 && vim_isfilec(var[2]) 11371 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) 11372 STRMOVE(var, var + 1); 11373 #endif 11374 11375 *file[0] = buf; 11376 *num_file = 1; 11377 return OK; 11378 } 11379 #endif 11380 11381 /* 11382 * Get the value for the numeric or string option *opp in a nice format into 11383 * NameBuff[]. Must not be called with a hidden option! 11384 */ 11385 static void 11386 option_value2string(opp, opt_flags) 11387 struct vimoption *opp; 11388 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */ 11389 { 11390 char_u *varp; 11391 11392 varp = get_varp_scope(opp, opt_flags); 11393 11394 if (opp->flags & P_NUM) 11395 { 11396 long wc = 0; 11397 11398 if (wc_use_keyname(varp, &wc)) 11399 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); 11400 else if (wc != 0) 11401 STRCPY(NameBuff, transchar((int)wc)); 11402 else 11403 sprintf((char *)NameBuff, "%ld", *(long *)varp); 11404 } 11405 else /* P_STRING */ 11406 { 11407 varp = *(char_u **)(varp); 11408 if (varp == NULL) /* just in case */ 11409 NameBuff[0] = NUL; 11410 #ifdef FEAT_CRYPT 11411 /* don't show the actual value of 'key', only that it's set */ 11412 else if (opp->var == (char_u *)&p_key && *varp) 11413 STRCPY(NameBuff, "*****"); 11414 #endif 11415 else if (opp->flags & P_EXPAND) 11416 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); 11417 /* Translate 'pastetoggle' into special key names */ 11418 else if ((char_u **)opp->var == &p_pt) 11419 str2specialbuf(p_pt, NameBuff, MAXPATHL); 11420 else 11421 vim_strncpy(NameBuff, varp, MAXPATHL - 1); 11422 } 11423 } 11424 11425 /* 11426 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be 11427 * printed as a keyname. 11428 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. 11429 */ 11430 static int 11431 wc_use_keyname(varp, wcp) 11432 char_u *varp; 11433 long *wcp; 11434 { 11435 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) 11436 { 11437 *wcp = *(long *)varp; 11438 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) 11439 return TRUE; 11440 } 11441 return FALSE; 11442 } 11443 11444 #if defined(FEAT_LANGMAP) || defined(PROTO) 11445 /* 11446 * Any character has an equivalent 'langmap' character. This is used for 11447 * keyboards that have a special language mode that sends characters above 11448 * 128 (although other characters can be translated too). The "to" field is a 11449 * Vim command character. This avoids having to switch the keyboard back to 11450 * ASCII mode when leaving Insert mode. 11451 * 11452 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim 11453 * commands. 11454 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of 11455 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >= 11456 * 256. 11457 */ 11458 # if defined(FEAT_MBYTE) || defined(PROTO) 11459 /* 11460 * With multi-byte support use growarray for 'langmap' chars >= 256 11461 */ 11462 typedef struct 11463 { 11464 int from; 11465 int to; 11466 } langmap_entry_T; 11467 11468 static garray_T langmap_mapga; 11469 static void langmap_set_entry __ARGS((int from, int to)); 11470 11471 /* 11472 * Search for an entry in "langmap_mapga" for "from". If found set the "to" 11473 * field. If not found insert a new entry at the appropriate location. 11474 */ 11475 static void 11476 langmap_set_entry(from, to) 11477 int from; 11478 int to; 11479 { 11480 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); 11481 int a = 0; 11482 int b = langmap_mapga.ga_len; 11483 11484 /* Do a binary search for an existing entry. */ 11485 while (a != b) 11486 { 11487 int i = (a + b) / 2; 11488 int d = entries[i].from - from; 11489 11490 if (d == 0) 11491 { 11492 entries[i].to = to; 11493 return; 11494 } 11495 if (d < 0) 11496 a = i + 1; 11497 else 11498 b = i; 11499 } 11500 11501 if (ga_grow(&langmap_mapga, 1) != OK) 11502 return; /* out of memory */ 11503 11504 /* insert new entry at position "a" */ 11505 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a; 11506 mch_memmove(entries + 1, entries, 11507 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); 11508 ++langmap_mapga.ga_len; 11509 entries[0].from = from; 11510 entries[0].to = to; 11511 } 11512 11513 /* 11514 * Apply 'langmap' to multi-byte character "c" and return the result. 11515 */ 11516 int 11517 langmap_adjust_mb(c) 11518 int c; 11519 { 11520 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); 11521 int a = 0; 11522 int b = langmap_mapga.ga_len; 11523 11524 while (a != b) 11525 { 11526 int i = (a + b) / 2; 11527 int d = entries[i].from - c; 11528 11529 if (d == 0) 11530 return entries[i].to; /* found matching entry */ 11531 if (d < 0) 11532 a = i + 1; 11533 else 11534 b = i; 11535 } 11536 return c; /* no entry found, return "c" unmodified */ 11537 } 11538 # endif 11539 11540 static void 11541 langmap_init() 11542 { 11543 int i; 11544 11545 for (i = 0; i < 256; i++) 11546 langmap_mapchar[i] = i; /* we init with a one-to-one map */ 11547 # ifdef FEAT_MBYTE 11548 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8); 11549 # endif 11550 } 11551 11552 /* 11553 * Called when langmap option is set; the language map can be 11554 * changed at any time! 11555 */ 11556 static void 11557 langmap_set() 11558 { 11559 char_u *p; 11560 char_u *p2; 11561 int from, to; 11562 11563 #ifdef FEAT_MBYTE 11564 ga_clear(&langmap_mapga); /* clear the previous map first */ 11565 #endif 11566 langmap_init(); /* back to one-to-one map */ 11567 11568 for (p = p_langmap; p[0] != NUL; ) 11569 { 11570 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; 11571 mb_ptr_adv(p2)) 11572 { 11573 if (p2[0] == '\\' && p2[1] != NUL) 11574 ++p2; 11575 } 11576 if (p2[0] == ';') 11577 ++p2; /* abcd;ABCD form, p2 points to A */ 11578 else 11579 p2 = NULL; /* aAbBcCdD form, p2 is NULL */ 11580 while (p[0]) 11581 { 11582 if (p[0] == ',') 11583 { 11584 ++p; 11585 break; 11586 } 11587 if (p[0] == '\\' && p[1] != NUL) 11588 ++p; 11589 #ifdef FEAT_MBYTE 11590 from = (*mb_ptr2char)(p); 11591 #else 11592 from = p[0]; 11593 #endif 11594 to = NUL; 11595 if (p2 == NULL) 11596 { 11597 mb_ptr_adv(p); 11598 if (p[0] != ',') 11599 { 11600 if (p[0] == '\\') 11601 ++p; 11602 #ifdef FEAT_MBYTE 11603 to = (*mb_ptr2char)(p); 11604 #else 11605 to = p[0]; 11606 #endif 11607 } 11608 } 11609 else 11610 { 11611 if (p2[0] != ',') 11612 { 11613 if (p2[0] == '\\') 11614 ++p2; 11615 #ifdef FEAT_MBYTE 11616 to = (*mb_ptr2char)(p2); 11617 #else 11618 to = p2[0]; 11619 #endif 11620 } 11621 } 11622 if (to == NUL) 11623 { 11624 EMSG2(_("E357: 'langmap': Matching character missing for %s"), 11625 transchar(from)); 11626 return; 11627 } 11628 11629 #ifdef FEAT_MBYTE 11630 if (from >= 256) 11631 langmap_set_entry(from, to); 11632 else 11633 #endif 11634 langmap_mapchar[from & 255] = to; 11635 11636 /* Advance to next pair */ 11637 mb_ptr_adv(p); 11638 if (p2 != NULL) 11639 { 11640 mb_ptr_adv(p2); 11641 if (*p == ';') 11642 { 11643 p = p2; 11644 if (p[0] != NUL) 11645 { 11646 if (p[0] != ',') 11647 { 11648 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p); 11649 return; 11650 } 11651 ++p; 11652 } 11653 break; 11654 } 11655 } 11656 } 11657 } 11658 } 11659 #endif 11660 11661 /* 11662 * Return TRUE if format option 'x' is in effect. 11663 * Take care of no formatting when 'paste' is set. 11664 */ 11665 int 11666 has_format_option(x) 11667 int x; 11668 { 11669 if (p_paste) 11670 return FALSE; 11671 return (vim_strchr(curbuf->b_p_fo, x) != NULL); 11672 } 11673 11674 /* 11675 * Return TRUE if "x" is present in 'shortmess' option, or 11676 * 'shortmess' contains 'a' and "x" is present in SHM_A. 11677 */ 11678 int 11679 shortmess(x) 11680 int x; 11681 { 11682 return p_shm != NULL && 11683 ( vim_strchr(p_shm, x) != NULL 11684 || (vim_strchr(p_shm, 'a') != NULL 11685 && vim_strchr((char_u *)SHM_A, x) != NULL)); 11686 } 11687 11688 /* 11689 * paste_option_changed() - Called after p_paste was set or reset. 11690 */ 11691 static void 11692 paste_option_changed() 11693 { 11694 static int old_p_paste = FALSE; 11695 static int save_sm = 0; 11696 static int save_sta = 0; 11697 #ifdef FEAT_CMDL_INFO 11698 static int save_ru = 0; 11699 #endif 11700 #ifdef FEAT_RIGHTLEFT 11701 static int save_ri = 0; 11702 static int save_hkmap = 0; 11703 #endif 11704 buf_T *buf; 11705 11706 if (p_paste) 11707 { 11708 /* 11709 * Paste switched from off to on. 11710 * Save the current values, so they can be restored later. 11711 */ 11712 if (!old_p_paste) 11713 { 11714 /* save options for each buffer */ 11715 for (buf = firstbuf; buf != NULL; buf = buf->b_next) 11716 { 11717 buf->b_p_tw_nopaste = buf->b_p_tw; 11718 buf->b_p_wm_nopaste = buf->b_p_wm; 11719 buf->b_p_sts_nopaste = buf->b_p_sts; 11720 buf->b_p_ai_nopaste = buf->b_p_ai; 11721 buf->b_p_et_nopaste = buf->b_p_et; 11722 } 11723 11724 /* save global options */ 11725 save_sm = p_sm; 11726 save_sta = p_sta; 11727 #ifdef FEAT_CMDL_INFO 11728 save_ru = p_ru; 11729 #endif 11730 #ifdef FEAT_RIGHTLEFT 11731 save_ri = p_ri; 11732 save_hkmap = p_hkmap; 11733 #endif 11734 /* save global values for local buffer options */ 11735 p_ai_nopaste = p_ai; 11736 p_et_nopaste = p_et; 11737 p_sts_nopaste = p_sts; 11738 p_tw_nopaste = p_tw; 11739 p_wm_nopaste = p_wm; 11740 } 11741 11742 /* 11743 * Always set the option values, also when 'paste' is set when it is 11744 * already on. 11745 */ 11746 /* set options for each buffer */ 11747 for (buf = firstbuf; buf != NULL; buf = buf->b_next) 11748 { 11749 buf->b_p_tw = 0; /* textwidth is 0 */ 11750 buf->b_p_wm = 0; /* wrapmargin is 0 */ 11751 buf->b_p_sts = 0; /* softtabstop is 0 */ 11752 buf->b_p_ai = 0; /* no auto-indent */ 11753 buf->b_p_et = 0; /* no expandtab */ 11754 } 11755 11756 /* set global options */ 11757 p_sm = 0; /* no showmatch */ 11758 p_sta = 0; /* no smarttab */ 11759 #ifdef FEAT_CMDL_INFO 11760 # ifdef FEAT_WINDOWS 11761 if (p_ru) 11762 status_redraw_all(); /* redraw to remove the ruler */ 11763 # endif 11764 p_ru = 0; /* no ruler */ 11765 #endif 11766 #ifdef FEAT_RIGHTLEFT 11767 p_ri = 0; /* no reverse insert */ 11768 p_hkmap = 0; /* no Hebrew keyboard */ 11769 #endif 11770 /* set global values for local buffer options */ 11771 p_tw = 0; 11772 p_wm = 0; 11773 p_sts = 0; 11774 p_ai = 0; 11775 } 11776 11777 /* 11778 * Paste switched from on to off: Restore saved values. 11779 */ 11780 else if (old_p_paste) 11781 { 11782 /* restore options for each buffer */ 11783 for (buf = firstbuf; buf != NULL; buf = buf->b_next) 11784 { 11785 buf->b_p_tw = buf->b_p_tw_nopaste; 11786 buf->b_p_wm = buf->b_p_wm_nopaste; 11787 buf->b_p_sts = buf->b_p_sts_nopaste; 11788 buf->b_p_ai = buf->b_p_ai_nopaste; 11789 buf->b_p_et = buf->b_p_et_nopaste; 11790 } 11791 11792 /* restore global options */ 11793 p_sm = save_sm; 11794 p_sta = save_sta; 11795 #ifdef FEAT_CMDL_INFO 11796 # ifdef FEAT_WINDOWS 11797 if (p_ru != save_ru) 11798 status_redraw_all(); /* redraw to draw the ruler */ 11799 # endif 11800 p_ru = save_ru; 11801 #endif 11802 #ifdef FEAT_RIGHTLEFT 11803 p_ri = save_ri; 11804 p_hkmap = save_hkmap; 11805 #endif 11806 /* set global values for local buffer options */ 11807 p_ai = p_ai_nopaste; 11808 p_et = p_et_nopaste; 11809 p_sts = p_sts_nopaste; 11810 p_tw = p_tw_nopaste; 11811 p_wm = p_wm_nopaste; 11812 } 11813 11814 old_p_paste = p_paste; 11815 } 11816 11817 /* 11818 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. 11819 * 11820 * Reset 'compatible' and set the values for options that didn't get set yet 11821 * to the Vim defaults. 11822 * Don't do this if the 'compatible' option has been set or reset before. 11823 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. 11824 */ 11825 void 11826 vimrc_found(fname, envname) 11827 char_u *fname; 11828 char_u *envname; 11829 { 11830 int opt_idx; 11831 int dofree = FALSE; 11832 char_u *p; 11833 11834 if (!option_was_set((char_u *)"cp")) 11835 { 11836 p_cp = FALSE; 11837 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 11838 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) 11839 set_option_default(opt_idx, OPT_FREE, FALSE); 11840 didset_options(); 11841 didset_options2(); 11842 } 11843 11844 if (fname != NULL) 11845 { 11846 p = vim_getenv(envname, &dofree); 11847 if (p == NULL) 11848 { 11849 /* Set $MYVIMRC to the first vimrc file found. */ 11850 p = FullName_save(fname, FALSE); 11851 if (p != NULL) 11852 { 11853 vim_setenv(envname, p); 11854 vim_free(p); 11855 } 11856 } 11857 else if (dofree) 11858 vim_free(p); 11859 } 11860 } 11861 11862 /* 11863 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. 11864 */ 11865 void 11866 change_compatible(on) 11867 int on; 11868 { 11869 int opt_idx; 11870 11871 if (p_cp != on) 11872 { 11873 p_cp = on; 11874 compatible_set(); 11875 } 11876 opt_idx = findoption((char_u *)"cp"); 11877 if (opt_idx >= 0) 11878 options[opt_idx].flags |= P_WAS_SET; 11879 } 11880 11881 /* 11882 * Return TRUE when option "name" has been set. 11883 * Only works correctly for global options. 11884 */ 11885 int 11886 option_was_set(name) 11887 char_u *name; 11888 { 11889 int idx; 11890 11891 idx = findoption(name); 11892 if (idx < 0) /* unknown option */ 11893 return FALSE; 11894 if (options[idx].flags & P_WAS_SET) 11895 return TRUE; 11896 return FALSE; 11897 } 11898 11899 /* 11900 * Reset the flag indicating option "name" was set. 11901 */ 11902 void 11903 reset_option_was_set(name) 11904 char_u *name; 11905 { 11906 int idx = findoption(name); 11907 11908 if (idx >= 0) 11909 options[idx].flags &= ~P_WAS_SET; 11910 } 11911 11912 /* 11913 * compatible_set() - Called when 'compatible' has been set or unset. 11914 * 11915 * When 'compatible' set: Set all relevant options (those that have the P_VIM) 11916 * flag) to a Vi compatible value. 11917 * When 'compatible' is unset: Set all options that have a different default 11918 * for Vim (without the P_VI_DEF flag) to that default. 11919 */ 11920 static void 11921 compatible_set() 11922 { 11923 int opt_idx; 11924 11925 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 11926 if ( ((options[opt_idx].flags & P_VIM) && p_cp) 11927 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) 11928 set_option_default(opt_idx, OPT_FREE, p_cp); 11929 didset_options(); 11930 didset_options2(); 11931 } 11932 11933 #ifdef FEAT_LINEBREAK 11934 11935 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) 11936 /* Borland C++ screws up loop optimisation here (negri) */ 11937 #pragma option -O-l 11938 # endif 11939 11940 /* 11941 * fill_breakat_flags() -- called when 'breakat' changes value. 11942 */ 11943 static void 11944 fill_breakat_flags() 11945 { 11946 char_u *p; 11947 int i; 11948 11949 for (i = 0; i < 256; i++) 11950 breakat_flags[i] = FALSE; 11951 11952 if (p_breakat != NULL) 11953 for (p = p_breakat; *p; p++) 11954 breakat_flags[*p] = TRUE; 11955 } 11956 11957 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) 11958 #pragma option -O.l 11959 # endif 11960 11961 #endif 11962 11963 /* 11964 * Check an option that can be a range of string values. 11965 * 11966 * Return OK for correct value, FAIL otherwise. 11967 * Empty is always OK. 11968 */ 11969 static int 11970 check_opt_strings(val, values, list) 11971 char_u *val; 11972 char **values; 11973 int list; /* when TRUE: accept a list of values */ 11974 { 11975 return opt_strings_flags(val, values, NULL, list); 11976 } 11977 11978 /* 11979 * Handle an option that can be a range of string values. 11980 * Set a flag in "*flagp" for each string present. 11981 * 11982 * Return OK for correct value, FAIL otherwise. 11983 * Empty is always OK. 11984 */ 11985 static int 11986 opt_strings_flags(val, values, flagp, list) 11987 char_u *val; /* new value */ 11988 char **values; /* array of valid string values */ 11989 unsigned *flagp; 11990 int list; /* when TRUE: accept a list of values */ 11991 { 11992 int i; 11993 int len; 11994 unsigned new_flags = 0; 11995 11996 while (*val) 11997 { 11998 for (i = 0; ; ++i) 11999 { 12000 if (values[i] == NULL) /* val not found in values[] */ 12001 return FAIL; 12002 12003 len = (int)STRLEN(values[i]); 12004 if (STRNCMP(values[i], val, len) == 0 12005 && ((list && val[len] == ',') || val[len] == NUL)) 12006 { 12007 val += len + (val[len] == ','); 12008 new_flags |= (1 << i); 12009 break; /* check next item in val list */ 12010 } 12011 } 12012 } 12013 if (flagp != NULL) 12014 *flagp = new_flags; 12015 12016 return OK; 12017 } 12018 12019 /* 12020 * Read the 'wildmode' option, fill wim_flags[]. 12021 */ 12022 static int 12023 check_opt_wim() 12024 { 12025 char_u new_wim_flags[4]; 12026 char_u *p; 12027 int i; 12028 int idx = 0; 12029 12030 for (i = 0; i < 4; ++i) 12031 new_wim_flags[i] = 0; 12032 12033 for (p = p_wim; *p; ++p) 12034 { 12035 for (i = 0; ASCII_ISALPHA(p[i]); ++i) 12036 ; 12037 if (p[i] != NUL && p[i] != ',' && p[i] != ':') 12038 return FAIL; 12039 if (i == 7 && STRNCMP(p, "longest", 7) == 0) 12040 new_wim_flags[idx] |= WIM_LONGEST; 12041 else if (i == 4 && STRNCMP(p, "full", 4) == 0) 12042 new_wim_flags[idx] |= WIM_FULL; 12043 else if (i == 4 && STRNCMP(p, "list", 4) == 0) 12044 new_wim_flags[idx] |= WIM_LIST; 12045 else 12046 return FAIL; 12047 p += i; 12048 if (*p == NUL) 12049 break; 12050 if (*p == ',') 12051 { 12052 if (idx == 3) 12053 return FAIL; 12054 ++idx; 12055 } 12056 } 12057 12058 /* fill remaining entries with last flag */ 12059 while (idx < 3) 12060 { 12061 new_wim_flags[idx + 1] = new_wim_flags[idx]; 12062 ++idx; 12063 } 12064 12065 /* only when there are no errors, wim_flags[] is changed */ 12066 for (i = 0; i < 4; ++i) 12067 wim_flags[i] = new_wim_flags[i]; 12068 return OK; 12069 } 12070 12071 /* 12072 * Check if backspacing over something is allowed. 12073 */ 12074 int 12075 can_bs(what) 12076 int what; /* BS_INDENT, BS_EOL or BS_START */ 12077 { 12078 switch (*p_bs) 12079 { 12080 case '2': return TRUE; 12081 case '1': return (what != BS_START); 12082 case '0': return FALSE; 12083 } 12084 return vim_strchr(p_bs, what) != NULL; 12085 } 12086 12087 /* 12088 * Save the current values of 'fileformat' and 'fileencoding', so that we know 12089 * the file must be considered changed when the value is different. 12090 */ 12091 void 12092 save_file_ff(buf) 12093 buf_T *buf; 12094 { 12095 buf->b_start_ffc = *buf->b_p_ff; 12096 buf->b_start_eol = buf->b_p_eol; 12097 #ifdef FEAT_MBYTE 12098 buf->b_start_bomb = buf->b_p_bomb; 12099 12100 /* Only use free/alloc when necessary, they take time. */ 12101 if (buf->b_start_fenc == NULL 12102 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) 12103 { 12104 vim_free(buf->b_start_fenc); 12105 buf->b_start_fenc = vim_strsave(buf->b_p_fenc); 12106 } 12107 #endif 12108 } 12109 12110 /* 12111 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value 12112 * from when editing started (save_file_ff() called). 12113 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was 12114 * changed and 'binary' is not set. 12115 * Also when 'endofline' was changed and 'fixeol' is not set. 12116 * When "ignore_empty" is true don't consider a new, empty buffer to be 12117 * changed. 12118 */ 12119 int 12120 file_ff_differs(buf, ignore_empty) 12121 buf_T *buf; 12122 int ignore_empty; 12123 { 12124 /* In a buffer that was never loaded the options are not valid. */ 12125 if (buf->b_flags & BF_NEVERLOADED) 12126 return FALSE; 12127 if (ignore_empty 12128 && (buf->b_flags & BF_NEW) 12129 && buf->b_ml.ml_line_count == 1 12130 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) 12131 return FALSE; 12132 if (buf->b_start_ffc != *buf->b_p_ff) 12133 return TRUE; 12134 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol) 12135 return TRUE; 12136 #ifdef FEAT_MBYTE 12137 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) 12138 return TRUE; 12139 if (buf->b_start_fenc == NULL) 12140 return (*buf->b_p_fenc != NUL); 12141 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); 12142 #else 12143 return FALSE; 12144 #endif 12145 } 12146 12147 /* 12148 * return OK if "p" is a valid fileformat name, FAIL otherwise. 12149 */ 12150 int 12151 check_ff_value(p) 12152 char_u *p; 12153 { 12154 return check_opt_strings(p, p_ff_values, FALSE); 12155 } 12156 12157 /* 12158 * Return the effective shiftwidth value for current buffer, using the 12159 * 'tabstop' value when 'shiftwidth' is zero. 12160 */ 12161 long 12162 get_sw_value(buf) 12163 buf_T *buf; 12164 { 12165 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts; 12166 } 12167 12168 /* 12169 * Return the effective softtabstop value for the current buffer, using the 12170 * 'tabstop' value when 'softtabstop' is negative. 12171 */ 12172 long 12173 get_sts_value() 12174 { 12175 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; 12176 } 12177 12178 /* 12179 * Check matchpairs option for "*initc". 12180 * If there is a match set "*initc" to the matching character and "*findc" to 12181 * the opposite character. Set "*backwards" to the direction. 12182 * When "switchit" is TRUE swap the direction. 12183 */ 12184 void 12185 find_mps_values(initc, findc, backwards, switchit) 12186 int *initc; 12187 int *findc; 12188 int *backwards; 12189 int switchit; 12190 { 12191 char_u *ptr; 12192 12193 ptr = curbuf->b_p_mps; 12194 while (*ptr != NUL) 12195 { 12196 #ifdef FEAT_MBYTE 12197 if (has_mbyte) 12198 { 12199 char_u *prev; 12200 12201 if (mb_ptr2char(ptr) == *initc) 12202 { 12203 if (switchit) 12204 { 12205 *findc = *initc; 12206 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); 12207 *backwards = TRUE; 12208 } 12209 else 12210 { 12211 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); 12212 *backwards = FALSE; 12213 } 12214 return; 12215 } 12216 prev = ptr; 12217 ptr += mb_ptr2len(ptr) + 1; 12218 if (mb_ptr2char(ptr) == *initc) 12219 { 12220 if (switchit) 12221 { 12222 *findc = *initc; 12223 *initc = mb_ptr2char(prev); 12224 *backwards = FALSE; 12225 } 12226 else 12227 { 12228 *findc = mb_ptr2char(prev); 12229 *backwards = TRUE; 12230 } 12231 return; 12232 } 12233 ptr += mb_ptr2len(ptr); 12234 } 12235 else 12236 #endif 12237 { 12238 if (*ptr == *initc) 12239 { 12240 if (switchit) 12241 { 12242 *backwards = TRUE; 12243 *findc = *initc; 12244 *initc = ptr[2]; 12245 } 12246 else 12247 { 12248 *backwards = FALSE; 12249 *findc = ptr[2]; 12250 } 12251 return; 12252 } 12253 ptr += 2; 12254 if (*ptr == *initc) 12255 { 12256 if (switchit) 12257 { 12258 *backwards = FALSE; 12259 *findc = *initc; 12260 *initc = ptr[-2]; 12261 } 12262 else 12263 { 12264 *backwards = TRUE; 12265 *findc = ptr[-2]; 12266 } 12267 return; 12268 } 12269 ++ptr; 12270 } 12271 if (*ptr == ',') 12272 ++ptr; 12273 } 12274 } 12275 12276 #if defined(FEAT_LINEBREAK) || defined(PROTO) 12277 /* 12278 * This is called when 'breakindentopt' is changed and when a window is 12279 * initialized. 12280 */ 12281 static int 12282 briopt_check(wp) 12283 win_T *wp; 12284 { 12285 char_u *p; 12286 int bri_shift = 0; 12287 long bri_min = 20; 12288 int bri_sbr = FALSE; 12289 12290 p = wp->w_p_briopt; 12291 while (*p != NUL) 12292 { 12293 if (STRNCMP(p, "shift:", 6) == 0 12294 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6]))) 12295 { 12296 p += 6; 12297 bri_shift = getdigits(&p); 12298 } 12299 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4])) 12300 { 12301 p += 4; 12302 bri_min = getdigits(&p); 12303 } 12304 else if (STRNCMP(p, "sbr", 3) == 0) 12305 { 12306 p += 3; 12307 bri_sbr = TRUE; 12308 } 12309 if (*p != ',' && *p != NUL) 12310 return FAIL; 12311 if (*p == ',') 12312 ++p; 12313 } 12314 12315 wp->w_p_brishift = bri_shift; 12316 wp->w_p_brimin = bri_min; 12317 wp->w_p_brisbr = bri_sbr; 12318 12319 return OK; 12320 } 12321 #endif 12322 12323 /* 12324 * Get the local or global value of 'backupcopy'. 12325 */ 12326 unsigned int 12327 get_bkc_value(buf) 12328 buf_T *buf; 12329 { 12330 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; 12331 } 12332