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