1 /* vi:set ts=8 sts=4 sw=4 noet: 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/quickref.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 #define PV_BH OPT_BUF(BV_BH) 61 #define PV_BT OPT_BUF(BV_BT) 62 #ifdef FEAT_QUICKFIX 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 #define PV_FP OPT_BOTH(OPT_BUF(BV_FP)) 111 #ifdef FEAT_EVAL 112 # define PV_FEX OPT_BUF(BV_FEX) 113 #endif 114 #define PV_FF OPT_BUF(BV_FF) 115 #define PV_FLP OPT_BUF(BV_FLP) 116 #define PV_FO OPT_BUF(BV_FO) 117 #ifdef FEAT_AUTOCMD 118 # define PV_FT OPT_BUF(BV_FT) 119 #endif 120 #define PV_IMI OPT_BUF(BV_IMI) 121 #define PV_IMS OPT_BUF(BV_IMS) 122 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 123 # define PV_INDE OPT_BUF(BV_INDE) 124 # define PV_INDK OPT_BUF(BV_INDK) 125 #endif 126 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 127 # define PV_INEX OPT_BUF(BV_INEX) 128 #endif 129 #define PV_INF OPT_BUF(BV_INF) 130 #define PV_ISK OPT_BUF(BV_ISK) 131 #ifdef FEAT_CRYPT 132 # define PV_KEY OPT_BUF(BV_KEY) 133 #endif 134 #ifdef FEAT_KEYMAP 135 # define PV_KMAP OPT_BUF(BV_KMAP) 136 #endif 137 #define PV_KP OPT_BOTH(OPT_BUF(BV_KP)) 138 #ifdef FEAT_LISP 139 # define PV_LISP OPT_BUF(BV_LISP) 140 # define PV_LW OPT_BOTH(OPT_BUF(BV_LW)) 141 #endif 142 #ifdef FEAT_MBYTE 143 # define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC)) 144 #endif 145 #define PV_MA OPT_BUF(BV_MA) 146 #define PV_ML OPT_BUF(BV_ML) 147 #define PV_MOD OPT_BUF(BV_MOD) 148 #define PV_MPS OPT_BUF(BV_MPS) 149 #define PV_NF OPT_BUF(BV_NF) 150 #ifdef FEAT_COMPL_FUNC 151 # define PV_OFU OPT_BUF(BV_OFU) 152 #endif 153 #define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH)) 154 #define PV_PI OPT_BUF(BV_PI) 155 #ifdef FEAT_TEXTOBJ 156 # define PV_QE OPT_BUF(BV_QE) 157 #endif 158 #define PV_RO OPT_BUF(BV_RO) 159 #ifdef FEAT_SMARTINDENT 160 # define PV_SI OPT_BUF(BV_SI) 161 #endif 162 #define PV_SN OPT_BUF(BV_SN) 163 #ifdef FEAT_SYN_HL 164 # define PV_SMC OPT_BUF(BV_SMC) 165 # define PV_SYN OPT_BUF(BV_SYN) 166 #endif 167 #ifdef FEAT_SPELL 168 # define PV_SPC OPT_BUF(BV_SPC) 169 # define PV_SPF OPT_BUF(BV_SPF) 170 # define PV_SPL OPT_BUF(BV_SPL) 171 #endif 172 #define PV_STS OPT_BUF(BV_STS) 173 #ifdef FEAT_SEARCHPATH 174 # define PV_SUA OPT_BUF(BV_SUA) 175 #endif 176 #define PV_SW OPT_BUF(BV_SW) 177 #define PV_SWF OPT_BUF(BV_SWF) 178 #define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS)) 179 #define PV_TC OPT_BOTH(OPT_BUF(BV_TC)) 180 #define PV_TS OPT_BUF(BV_TS) 181 #define PV_TW OPT_BUF(BV_TW) 182 #define PV_TX OPT_BUF(BV_TX) 183 #ifdef FEAT_PERSISTENT_UNDO 184 # define PV_UDF OPT_BUF(BV_UDF) 185 #endif 186 #define PV_WM OPT_BUF(BV_WM) 187 188 /* 189 * Definition of the PV_ values for window-local options. 190 * The WV_ values are defined in option.h. 191 */ 192 #define PV_LIST OPT_WIN(WV_LIST) 193 #ifdef FEAT_ARABIC 194 # define PV_ARAB OPT_WIN(WV_ARAB) 195 #endif 196 #ifdef FEAT_LINEBREAK 197 # define PV_BRI OPT_WIN(WV_BRI) 198 # define PV_BRIOPT OPT_WIN(WV_BRIOPT) 199 #endif 200 #ifdef FEAT_DIFF 201 # define PV_DIFF OPT_WIN(WV_DIFF) 202 #endif 203 #ifdef FEAT_FOLDING 204 # define PV_FDC OPT_WIN(WV_FDC) 205 # define PV_FEN OPT_WIN(WV_FEN) 206 # define PV_FDI OPT_WIN(WV_FDI) 207 # define PV_FDL OPT_WIN(WV_FDL) 208 # define PV_FDM OPT_WIN(WV_FDM) 209 # define PV_FML OPT_WIN(WV_FML) 210 # define PV_FDN OPT_WIN(WV_FDN) 211 # ifdef FEAT_EVAL 212 # define PV_FDE OPT_WIN(WV_FDE) 213 # define PV_FDT OPT_WIN(WV_FDT) 214 # endif 215 # define PV_FMR OPT_WIN(WV_FMR) 216 #endif 217 #ifdef FEAT_LINEBREAK 218 # define PV_LBR OPT_WIN(WV_LBR) 219 #endif 220 #define PV_NU OPT_WIN(WV_NU) 221 #define PV_RNU OPT_WIN(WV_RNU) 222 #ifdef FEAT_LINEBREAK 223 # define PV_NUW OPT_WIN(WV_NUW) 224 #endif 225 #if defined(FEAT_QUICKFIX) 226 # define PV_PVW OPT_WIN(WV_PVW) 227 #endif 228 #ifdef FEAT_RIGHTLEFT 229 # define PV_RL OPT_WIN(WV_RL) 230 # define PV_RLC OPT_WIN(WV_RLC) 231 #endif 232 #ifdef FEAT_SCROLLBIND 233 # define PV_SCBIND OPT_WIN(WV_SCBIND) 234 #endif 235 #define PV_SCROLL OPT_WIN(WV_SCROLL) 236 #ifdef FEAT_SPELL 237 # define PV_SPELL OPT_WIN(WV_SPELL) 238 #endif 239 #ifdef FEAT_SYN_HL 240 # define PV_CUC OPT_WIN(WV_CUC) 241 # define PV_CUL OPT_WIN(WV_CUL) 242 # define PV_CC OPT_WIN(WV_CC) 243 #endif 244 #ifdef FEAT_STL_OPT 245 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL)) 246 #endif 247 #define PV_UL OPT_BOTH(OPT_BUF(BV_UL)) 248 # define PV_WFH OPT_WIN(WV_WFH) 249 # define PV_WFW OPT_WIN(WV_WFW) 250 #define PV_WRAP OPT_WIN(WV_WRAP) 251 #ifdef FEAT_CURSORBIND 252 # define PV_CRBIND OPT_WIN(WV_CRBIND) 253 #endif 254 #ifdef FEAT_CONCEAL 255 # define PV_COCU OPT_WIN(WV_COCU) 256 # define PV_COLE OPT_WIN(WV_COLE) 257 #endif 258 #ifdef FEAT_TERMINAL 259 # define PV_TK OPT_WIN(WV_TK) 260 # define PV_TMS OPT_WIN(WV_TMS) 261 #endif 262 #ifdef FEAT_SIGNS 263 # define PV_SCL OPT_WIN(WV_SCL) 264 #endif 265 266 /* WV_ and BV_ values get typecasted to this for the "indir" field */ 267 typedef enum 268 { 269 PV_NONE = 0, 270 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */ 271 } idopt_T; 272 273 /* 274 * Options local to a window have a value local to a buffer and global to all 275 * buffers. Indicate this by setting "var" to VAR_WIN. 276 */ 277 #define VAR_WIN ((char_u *)-1) 278 279 /* 280 * These are the global values for options which are also local to a buffer. 281 * Only to be used in option.c! 282 */ 283 static int p_ai; 284 static int p_bin; 285 #ifdef FEAT_MBYTE 286 static int p_bomb; 287 #endif 288 static char_u *p_bh; 289 static char_u *p_bt; 290 static int p_bl; 291 static int p_ci; 292 #ifdef FEAT_CINDENT 293 static int p_cin; 294 static char_u *p_cink; 295 static char_u *p_cino; 296 #endif 297 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 298 static char_u *p_cinw; 299 #endif 300 #ifdef FEAT_COMMENTS 301 static char_u *p_com; 302 #endif 303 #ifdef FEAT_FOLDING 304 static char_u *p_cms; 305 #endif 306 #ifdef FEAT_INS_EXPAND 307 static char_u *p_cpt; 308 #endif 309 #ifdef FEAT_COMPL_FUNC 310 static char_u *p_cfu; 311 static char_u *p_ofu; 312 #endif 313 static int p_eol; 314 static int p_fixeol; 315 static int p_et; 316 #ifdef FEAT_MBYTE 317 static char_u *p_fenc; 318 #endif 319 static char_u *p_ff; 320 static char_u *p_fo; 321 static char_u *p_flp; 322 #ifdef FEAT_AUTOCMD 323 static char_u *p_ft; 324 #endif 325 static long p_iminsert; 326 static long p_imsearch; 327 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 328 static char_u *p_inex; 329 #endif 330 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 331 static char_u *p_inde; 332 static char_u *p_indk; 333 #endif 334 #if defined(FEAT_EVAL) 335 static char_u *p_fex; 336 #endif 337 static int p_inf; 338 static char_u *p_isk; 339 #ifdef FEAT_CRYPT 340 static char_u *p_key; 341 #endif 342 #ifdef FEAT_LISP 343 static int p_lisp; 344 #endif 345 static int p_ml; 346 static int p_ma; 347 static int p_mod; 348 static char_u *p_mps; 349 static char_u *p_nf; 350 static int p_pi; 351 #ifdef FEAT_TEXTOBJ 352 static char_u *p_qe; 353 #endif 354 static int p_ro; 355 #ifdef FEAT_SMARTINDENT 356 static int p_si; 357 #endif 358 static int p_sn; 359 static long p_sts; 360 #if defined(FEAT_SEARCHPATH) 361 static char_u *p_sua; 362 #endif 363 static long p_sw; 364 static int p_swf; 365 #ifdef FEAT_SYN_HL 366 static long p_smc; 367 static char_u *p_syn; 368 #endif 369 #ifdef FEAT_SPELL 370 static char_u *p_spc; 371 static char_u *p_spf; 372 static char_u *p_spl; 373 #endif 374 static long p_ts; 375 static long p_tw; 376 static int p_tx; 377 #ifdef FEAT_PERSISTENT_UNDO 378 static int p_udf; 379 #endif 380 static long p_wm; 381 #ifdef FEAT_KEYMAP 382 static char_u *p_keymap; 383 #endif 384 385 /* Saved values for when 'bin' is set. */ 386 static int p_et_nobin; 387 static int p_ml_nobin; 388 static long p_tw_nobin; 389 static long p_wm_nobin; 390 391 /* Saved values for when 'paste' is set */ 392 static int p_ai_nopaste; 393 static int p_et_nopaste; 394 static long p_sts_nopaste; 395 static long p_tw_nopaste; 396 static long p_wm_nopaste; 397 398 struct vimoption 399 { 400 char *fullname; /* full option name */ 401 char *shortname; /* permissible abbreviation */ 402 long_u flags; /* see below */ 403 char_u *var; /* global option: pointer to variable; 404 * window-local option: VAR_WIN; 405 * buffer-local option: global value */ 406 idopt_T indir; /* global option: PV_NONE; 407 * local option: indirect option index */ 408 char_u *def_val[2]; /* default values for variable (vi and vim) */ 409 #ifdef FEAT_EVAL 410 scid_T scriptID; /* script in which the option was last set */ 411 # define SCRIPTID_INIT , 0 412 #else 413 # define SCRIPTID_INIT 414 #endif 415 }; 416 417 #define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */ 418 #define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */ 419 420 /* 421 * Flags 422 */ 423 #define P_BOOL 0x01 /* the option is boolean */ 424 #define P_NUM 0x02 /* the option is numeric */ 425 #define P_STRING 0x04 /* the option is a string */ 426 #define P_ALLOCED 0x08 /* the string option is in allocated memory, 427 must use free_string_option() when 428 assigning new value. Not set if default is 429 the same. */ 430 #define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can 431 never be used for local or hidden options! */ 432 #define P_NODEFAULT 0x40 /* don't set to default value */ 433 #define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must 434 use vim_free() when assigning new value */ 435 #define P_WAS_SET 0x100 /* option has been set/reset */ 436 #define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */ 437 #define P_VI_DEF 0x400 /* Use Vi default for Vim */ 438 #define P_VIM 0x800 /* Vim option, reset when 'cp' set */ 439 440 /* when option changed, what to display: */ 441 #define P_RSTAT 0x1000 /* redraw status lines */ 442 #define P_RWIN 0x2000 /* redraw current window and recompute text */ 443 #define P_RBUF 0x4000 /* redraw current buffer and recompute text */ 444 #define P_RALL 0x6000 /* redraw all windows */ 445 #define P_RCLR 0x7000 /* clear and redraw all */ 446 447 #define P_COMMA 0x8000 /* comma separated list */ 448 #define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive 449 * commas */ 450 #define P_NODUP 0x20000L /* don't allow duplicate strings */ 451 #define P_FLAGLIST 0x40000L /* list of single-char flags */ 452 453 #define P_SECURE 0x80000L /* cannot change in modeline or secure mode */ 454 #define P_GETTEXT 0x100000L /* expand default value with _() */ 455 #define P_NOGLOB 0x200000L /* do not use local value for global vimrc */ 456 #define P_NFNAME 0x400000L /* only normal file name chars allowed */ 457 #define P_INSECURE 0x800000L /* option was set from a modeline */ 458 #define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has 459 side effects) */ 460 #define P_NO_ML 0x2000000L /* not allowed in modeline */ 461 #define P_CURSWANT 0x4000000L /* update curswant required; not needed when 462 * there is a redraw flag */ 463 #define P_NDNAME 0x8000000L /* only normal dir name chars allowed */ 464 #define P_RWINONLY 0x10000000L /* only redraw current window */ 465 466 #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" 467 468 /* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used 469 * for the currency sign. */ 470 #if defined(MSWIN) 471 # define ISP_LATIN1 (char_u *)"@,~-255" 472 #else 473 # define ISP_LATIN1 (char_u *)"@,161-255" 474 #endif 475 476 # define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC" 477 478 /* Default python version for pyx* commands */ 479 #if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) 480 # define DEFAULT_PYTHON_VER 0 481 #elif defined(FEAT_PYTHON3) 482 # define DEFAULT_PYTHON_VER 3 483 #elif defined(FEAT_PYTHON) 484 # define DEFAULT_PYTHON_VER 2 485 #else 486 # define DEFAULT_PYTHON_VER 0 487 #endif 488 489 /* 490 * options[] is initialized here. 491 * The order of the options MUST be alphabetic for ":set all" and findoption(). 492 * All option names MUST start with a lowercase letter (for findoption()). 493 * Exception: "t_" options are at the end. 494 * The options with a NULL variable are 'hidden': a set command for them is 495 * ignored and they are not printed. 496 */ 497 static struct vimoption options[] = 498 { 499 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT, 500 #ifdef FEAT_RIGHTLEFT 501 (char_u *)&p_aleph, PV_NONE, 502 #else 503 (char_u *)NULL, PV_NONE, 504 #endif 505 { 506 #if (defined(WIN3264)) && !defined(FEAT_GUI_W32) 507 (char_u *)128L, 508 #else 509 (char_u *)224L, 510 #endif 511 (char_u *)0L} SCRIPTID_INIT}, 512 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, 513 #if defined(FEAT_GUI_MAC) 514 (char_u *)&p_antialias, PV_NONE, 515 {(char_u *)FALSE, (char_u *)FALSE} 516 #else 517 (char_u *)NULL, PV_NONE, 518 {(char_u *)FALSE, (char_u *)FALSE} 519 #endif 520 SCRIPTID_INIT}, 521 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT, 522 #ifdef FEAT_ARABIC 523 (char_u *)VAR_WIN, PV_ARAB, 524 #else 525 (char_u *)NULL, PV_NONE, 526 #endif 527 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 528 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, 529 #ifdef FEAT_ARABIC 530 (char_u *)&p_arshape, PV_NONE, 531 #else 532 (char_u *)NULL, PV_NONE, 533 #endif 534 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 535 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM, 536 #ifdef FEAT_RIGHTLEFT 537 (char_u *)&p_ari, PV_NONE, 538 #else 539 (char_u *)NULL, PV_NONE, 540 #endif 541 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 542 {"altkeymap", "akm", P_BOOL|P_VI_DEF, 543 #ifdef FEAT_FKMAP 544 (char_u *)&p_altkeymap, PV_NONE, 545 #else 546 (char_u *)NULL, PV_NONE, 547 #endif 548 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 549 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR, 550 #if defined(FEAT_MBYTE) 551 (char_u *)&p_ambw, PV_NONE, 552 {(char_u *)"single", (char_u *)0L} 553 #else 554 (char_u *)NULL, PV_NONE, 555 {(char_u *)0L, (char_u *)0L} 556 #endif 557 SCRIPTID_INIT}, 558 {"autochdir", "acd", P_BOOL|P_VI_DEF, 559 #ifdef FEAT_AUTOCHDIR 560 (char_u *)&p_acd, PV_NONE, 561 {(char_u *)FALSE, (char_u *)0L} 562 #else 563 (char_u *)NULL, PV_NONE, 564 {(char_u *)0L, (char_u *)0L} 565 #endif 566 SCRIPTID_INIT}, 567 {"autoindent", "ai", P_BOOL|P_VI_DEF, 568 (char_u *)&p_ai, PV_AI, 569 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 570 {"autoprint", "ap", P_BOOL|P_VI_DEF, 571 (char_u *)NULL, PV_NONE, 572 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 573 {"autoread", "ar", P_BOOL|P_VI_DEF, 574 (char_u *)&p_ar, PV_AR, 575 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 576 {"autowrite", "aw", P_BOOL|P_VI_DEF, 577 (char_u *)&p_aw, PV_NONE, 578 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 579 {"autowriteall","awa", P_BOOL|P_VI_DEF, 580 (char_u *)&p_awa, PV_NONE, 581 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 582 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR, 583 (char_u *)&p_bg, PV_NONE, 584 { 585 #if (defined(WIN3264)) && !defined(FEAT_GUI) 586 (char_u *)"dark", 587 #else 588 (char_u *)"light", 589 #endif 590 (char_u *)0L} SCRIPTID_INIT}, 591 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP, 592 (char_u *)&p_bs, PV_NONE, 593 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 594 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM, 595 (char_u *)&p_bk, PV_NONE, 596 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 597 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP, 598 (char_u *)&p_bkc, PV_BKC, 599 #ifdef UNIX 600 {(char_u *)"yes", (char_u *)"auto"} 601 #else 602 {(char_u *)"auto", (char_u *)"auto"} 603 #endif 604 SCRIPTID_INIT}, 605 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA 606 |P_NODUP|P_SECURE, 607 (char_u *)&p_bdir, PV_NONE, 608 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT}, 609 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME, 610 (char_u *)&p_bex, PV_NONE, 611 { 612 #ifdef VMS 613 (char_u *)"_", 614 #else 615 (char_u *)"~", 616 #endif 617 (char_u *)0L} SCRIPTID_INIT}, 618 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA, 619 #ifdef FEAT_WILDIGN 620 (char_u *)&p_bsk, PV_NONE, 621 {(char_u *)"", (char_u *)0L} 622 #else 623 (char_u *)NULL, PV_NONE, 624 {(char_u *)0L, (char_u *)0L} 625 #endif 626 SCRIPTID_INIT}, 627 {"balloondelay","bdlay",P_NUM|P_VI_DEF, 628 #ifdef FEAT_BEVAL 629 (char_u *)&p_bdlay, PV_NONE, 630 {(char_u *)600L, (char_u *)0L} 631 #else 632 (char_u *)NULL, PV_NONE, 633 {(char_u *)0L, (char_u *)0L} 634 #endif 635 SCRIPTID_INIT}, 636 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC, 637 #ifdef FEAT_BEVAL_GUI 638 (char_u *)&p_beval, PV_NONE, 639 {(char_u *)FALSE, (char_u *)0L} 640 #else 641 (char_u *)NULL, PV_NONE, 642 {(char_u *)0L, (char_u *)0L} 643 #endif 644 SCRIPTID_INIT}, 645 {"balloonevalterm", "bevalterm",P_BOOL|P_VI_DEF|P_NO_MKRC, 646 #ifdef FEAT_BEVAL_TERM 647 (char_u *)&p_bevalterm, PV_NONE, 648 {(char_u *)FALSE, (char_u *)0L} 649 #else 650 (char_u *)NULL, PV_NONE, 651 {(char_u *)0L, (char_u *)0L} 652 #endif 653 SCRIPTID_INIT}, 654 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, 655 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 656 (char_u *)&p_bexpr, PV_BEXPR, 657 {(char_u *)"", (char_u *)0L} 658 #else 659 (char_u *)NULL, PV_NONE, 660 {(char_u *)0L, (char_u *)0L} 661 #endif 662 SCRIPTID_INIT}, 663 {"beautify", "bf", P_BOOL|P_VI_DEF, 664 (char_u *)NULL, PV_NONE, 665 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 666 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, 667 (char_u *)&p_bo, PV_NONE, 668 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 669 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT, 670 (char_u *)&p_bin, PV_BIN, 671 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 672 {"bioskey", "biosk",P_BOOL|P_VI_DEF, 673 (char_u *)NULL, PV_NONE, 674 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 675 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, 676 #ifdef FEAT_MBYTE 677 (char_u *)&p_bomb, PV_BOMB, 678 #else 679 (char_u *)NULL, PV_NONE, 680 #endif 681 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 682 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, 683 #ifdef FEAT_LINEBREAK 684 (char_u *)&p_breakat, PV_NONE, 685 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L} 686 #else 687 (char_u *)NULL, PV_NONE, 688 {(char_u *)0L, (char_u *)0L} 689 #endif 690 SCRIPTID_INIT}, 691 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN, 692 #ifdef FEAT_LINEBREAK 693 (char_u *)VAR_WIN, PV_BRI, 694 {(char_u *)FALSE, (char_u *)0L} 695 #else 696 (char_u *)NULL, PV_NONE, 697 {(char_u *)0L, (char_u *)0L} 698 #endif 699 SCRIPTID_INIT}, 700 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF 701 |P_ONECOMMA|P_NODUP, 702 #ifdef FEAT_LINEBREAK 703 (char_u *)VAR_WIN, PV_BRIOPT, 704 {(char_u *)"", (char_u *)NULL} 705 #else 706 (char_u *)NULL, PV_NONE, 707 {(char_u *)"", (char_u *)NULL} 708 #endif 709 SCRIPTID_INIT}, 710 {"browsedir", "bsdir",P_STRING|P_VI_DEF, 711 #ifdef FEAT_BROWSE 712 (char_u *)&p_bsdir, PV_NONE, 713 {(char_u *)"last", (char_u *)0L} 714 #else 715 (char_u *)NULL, PV_NONE, 716 {(char_u *)0L, (char_u *)0L} 717 #endif 718 SCRIPTID_INIT}, 719 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, 720 (char_u *)&p_bh, PV_BH, 721 {(char_u *)"", (char_u *)0L} 722 SCRIPTID_INIT}, 723 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB, 724 (char_u *)&p_bl, PV_BL, 725 {(char_u *)1L, (char_u *)0L} 726 SCRIPTID_INIT}, 727 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB, 728 (char_u *)&p_bt, PV_BT, 729 {(char_u *)"", (char_u *)0L} 730 SCRIPTID_INIT}, 731 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 732 #ifdef FEAT_MBYTE 733 (char_u *)&p_cmp, PV_NONE, 734 {(char_u *)"internal,keepascii", (char_u *)0L} 735 #else 736 (char_u *)NULL, PV_NONE, 737 {(char_u *)0L, (char_u *)0L} 738 #endif 739 SCRIPTID_INIT}, 740 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, 741 #ifdef FEAT_SEARCHPATH 742 (char_u *)&p_cdpath, PV_NONE, 743 {(char_u *)",,", (char_u *)0L} 744 #else 745 (char_u *)NULL, PV_NONE, 746 {(char_u *)0L, (char_u *)0L} 747 #endif 748 SCRIPTID_INIT}, 749 {"cedit", NULL, P_STRING, 750 #ifdef FEAT_CMDWIN 751 (char_u *)&p_cedit, PV_NONE, 752 {(char_u *)"", (char_u *)CTRL_F_STR} 753 #else 754 (char_u *)NULL, PV_NONE, 755 {(char_u *)0L, (char_u *)0L} 756 #endif 757 SCRIPTID_INIT}, 758 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE, 759 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL) 760 (char_u *)&p_ccv, PV_NONE, 761 {(char_u *)"", (char_u *)0L} 762 #else 763 (char_u *)NULL, PV_NONE, 764 {(char_u *)0L, (char_u *)0L} 765 #endif 766 SCRIPTID_INIT}, 767 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM, 768 #ifdef FEAT_CINDENT 769 (char_u *)&p_cin, PV_CIN, 770 #else 771 (char_u *)NULL, PV_NONE, 772 #endif 773 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 774 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 775 #ifdef FEAT_CINDENT 776 (char_u *)&p_cink, PV_CINK, 777 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L} 778 #else 779 (char_u *)NULL, PV_NONE, 780 {(char_u *)0L, (char_u *)0L} 781 #endif 782 SCRIPTID_INIT}, 783 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 784 #ifdef FEAT_CINDENT 785 (char_u *)&p_cino, PV_CINO, 786 #else 787 (char_u *)NULL, PV_NONE, 788 #endif 789 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 790 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 791 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 792 (char_u *)&p_cinw, PV_CINW, 793 {(char_u *)"if,else,while,do,for,switch", 794 (char_u *)0L} 795 #else 796 (char_u *)NULL, PV_NONE, 797 {(char_u *)0L, (char_u *)0L} 798 #endif 799 SCRIPTID_INIT}, 800 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 801 #ifdef FEAT_CLIPBOARD 802 (char_u *)&p_cb, PV_NONE, 803 # ifdef FEAT_XCLIPBOARD 804 {(char_u *)"autoselect,exclude:cons\\|linux", 805 (char_u *)0L} 806 # else 807 {(char_u *)"", (char_u *)0L} 808 # endif 809 #else 810 (char_u *)NULL, PV_NONE, 811 {(char_u *)"", (char_u *)0L} 812 #endif 813 SCRIPTID_INIT}, 814 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL, 815 (char_u *)&p_ch, PV_NONE, 816 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 817 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF, 818 #ifdef FEAT_CMDWIN 819 (char_u *)&p_cwh, PV_NONE, 820 #else 821 (char_u *)NULL, PV_NONE, 822 #endif 823 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT}, 824 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, 825 #ifdef FEAT_SYN_HL 826 (char_u *)VAR_WIN, PV_CC, 827 #else 828 (char_u *)NULL, PV_NONE, 829 #endif 830 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 831 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, 832 (char_u *)&Columns, PV_NONE, 833 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT}, 834 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA 835 |P_NODUP|P_CURSWANT, 836 #ifdef FEAT_COMMENTS 837 (char_u *)&p_com, PV_COM, 838 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-", 839 (char_u *)0L} 840 #else 841 (char_u *)NULL, PV_NONE, 842 {(char_u *)0L, (char_u *)0L} 843 #endif 844 SCRIPTID_INIT}, 845 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, 846 #ifdef FEAT_FOLDING 847 (char_u *)&p_cms, PV_CMS, 848 {(char_u *)"/*%s*/", (char_u *)0L} 849 #else 850 (char_u *)NULL, PV_NONE, 851 {(char_u *)0L, (char_u *)0L} 852 #endif 853 SCRIPTID_INIT}, 854 /* P_PRI_MKRC isn't needed here, optval_default() 855 * always returns TRUE for 'compatible' */ 856 {"compatible", "cp", P_BOOL|P_RALL, 857 (char_u *)&p_cp, PV_NONE, 858 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT}, 859 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 860 #ifdef FEAT_INS_EXPAND 861 (char_u *)&p_cpt, PV_CPT, 862 {(char_u *)".,w,b,u,t,i", (char_u *)0L} 863 #else 864 (char_u *)NULL, PV_NONE, 865 {(char_u *)0L, (char_u *)0L} 866 #endif 867 SCRIPTID_INIT}, 868 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, 869 #ifdef FEAT_CONCEAL 870 (char_u *)VAR_WIN, PV_COCU, 871 {(char_u *)"", (char_u *)NULL} 872 #else 873 (char_u *)NULL, PV_NONE, 874 {(char_u *)NULL, (char_u *)0L} 875 #endif 876 SCRIPTID_INIT}, 877 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF, 878 #ifdef FEAT_CONCEAL 879 (char_u *)VAR_WIN, PV_COLE, 880 #else 881 (char_u *)NULL, PV_NONE, 882 #endif 883 {(char_u *)0L, (char_u *)0L} 884 SCRIPTID_INIT}, 885 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, 886 #ifdef FEAT_COMPL_FUNC 887 (char_u *)&p_cfu, PV_CFU, 888 {(char_u *)"", (char_u *)0L} 889 #else 890 (char_u *)NULL, PV_NONE, 891 {(char_u *)0L, (char_u *)0L} 892 #endif 893 SCRIPTID_INIT}, 894 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 895 #ifdef FEAT_INS_EXPAND 896 (char_u *)&p_cot, PV_NONE, 897 {(char_u *)"menu,preview", (char_u *)0L} 898 #else 899 (char_u *)NULL, PV_NONE, 900 {(char_u *)0L, (char_u *)0L} 901 #endif 902 SCRIPTID_INIT}, 903 {"confirm", "cf", P_BOOL|P_VI_DEF, 904 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) 905 (char_u *)&p_confirm, PV_NONE, 906 #else 907 (char_u *)NULL, PV_NONE, 908 #endif 909 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 910 {"conskey", "consk",P_BOOL|P_VI_DEF, 911 (char_u *)NULL, PV_NONE, 912 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 913 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM, 914 (char_u *)&p_ci, PV_CI, 915 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 916 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST, 917 (char_u *)&p_cpo, PV_NONE, 918 {(char_u *)CPO_VI, (char_u *)CPO_VIM} 919 SCRIPTID_INIT}, 920 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF, 921 #ifdef FEAT_CRYPT 922 (char_u *)&p_cm, PV_CM, 923 {(char_u *)"zip", (char_u *)0L} 924 #else 925 (char_u *)NULL, PV_NONE, 926 {(char_u *)0L, (char_u *)0L} 927 #endif 928 SCRIPTID_INIT}, 929 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM, 930 #ifdef FEAT_CSCOPE 931 (char_u *)&p_cspc, PV_NONE, 932 #else 933 (char_u *)NULL, PV_NONE, 934 #endif 935 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 936 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 937 #ifdef FEAT_CSCOPE 938 (char_u *)&p_csprg, PV_NONE, 939 {(char_u *)"cscope", (char_u *)0L} 940 #else 941 (char_u *)NULL, PV_NONE, 942 {(char_u *)0L, (char_u *)0L} 943 #endif 944 SCRIPTID_INIT}, 945 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 946 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) 947 (char_u *)&p_csqf, PV_NONE, 948 {(char_u *)"", (char_u *)0L} 949 #else 950 (char_u *)NULL, PV_NONE, 951 {(char_u *)0L, (char_u *)0L} 952 #endif 953 SCRIPTID_INIT}, 954 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM, 955 #ifdef FEAT_CSCOPE 956 (char_u *)&p_csre, PV_NONE, 957 #else 958 (char_u *)NULL, PV_NONE, 959 #endif 960 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 961 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM, 962 #ifdef FEAT_CSCOPE 963 (char_u *)&p_cst, PV_NONE, 964 #else 965 (char_u *)NULL, PV_NONE, 966 #endif 967 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 968 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM, 969 #ifdef FEAT_CSCOPE 970 (char_u *)&p_csto, PV_NONE, 971 #else 972 (char_u *)NULL, PV_NONE, 973 #endif 974 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 975 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM, 976 #ifdef FEAT_CSCOPE 977 (char_u *)&p_csverbose, PV_NONE, 978 #else 979 (char_u *)NULL, PV_NONE, 980 #endif 981 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 982 {"cursorbind", "crb", P_BOOL|P_VI_DEF, 983 #ifdef FEAT_CURSORBIND 984 (char_u *)VAR_WIN, PV_CRBIND, 985 #else 986 (char_u *)NULL, PV_NONE, 987 #endif 988 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 989 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN, 990 #ifdef FEAT_SYN_HL 991 (char_u *)VAR_WIN, PV_CUC, 992 #else 993 (char_u *)NULL, PV_NONE, 994 #endif 995 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 996 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY, 997 #ifdef FEAT_SYN_HL 998 (char_u *)VAR_WIN, PV_CUL, 999 #else 1000 (char_u *)NULL, PV_NONE, 1001 #endif 1002 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1003 {"debug", NULL, P_STRING|P_VI_DEF, 1004 (char_u *)&p_debug, PV_NONE, 1005 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1006 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT, 1007 #ifdef FEAT_FIND_ID 1008 (char_u *)&p_def, PV_DEF, 1009 {(char_u *)"^\\s*#\\s*define", (char_u *)0L} 1010 #else 1011 (char_u *)NULL, PV_NONE, 1012 {(char_u *)NULL, (char_u *)0L} 1013 #endif 1014 SCRIPTID_INIT}, 1015 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM, 1016 #ifdef FEAT_MBYTE 1017 (char_u *)&p_deco, PV_NONE, 1018 #else 1019 (char_u *)NULL, PV_NONE, 1020 #endif 1021 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1022 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME, 1023 #ifdef FEAT_INS_EXPAND 1024 (char_u *)&p_dict, PV_DICT, 1025 #else 1026 (char_u *)NULL, PV_NONE, 1027 #endif 1028 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1029 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB, 1030 #ifdef FEAT_DIFF 1031 (char_u *)VAR_WIN, PV_DIFF, 1032 #else 1033 (char_u *)NULL, PV_NONE, 1034 #endif 1035 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1036 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT, 1037 #if defined(FEAT_DIFF) && defined(FEAT_EVAL) 1038 (char_u *)&p_dex, PV_NONE, 1039 {(char_u *)"", (char_u *)0L} 1040 #else 1041 (char_u *)NULL, PV_NONE, 1042 {(char_u *)0L, (char_u *)0L} 1043 #endif 1044 SCRIPTID_INIT}, 1045 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA 1046 |P_NODUP, 1047 #ifdef FEAT_DIFF 1048 (char_u *)&p_dip, PV_NONE, 1049 {(char_u *)"filler", (char_u *)NULL} 1050 #else 1051 (char_u *)NULL, PV_NONE, 1052 {(char_u *)"", (char_u *)NULL} 1053 #endif 1054 SCRIPTID_INIT}, 1055 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM, 1056 #ifdef FEAT_DIGRAPHS 1057 (char_u *)&p_dg, PV_NONE, 1058 #else 1059 (char_u *)NULL, PV_NONE, 1060 #endif 1061 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1062 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA 1063 |P_NODUP|P_SECURE, 1064 (char_u *)&p_dir, PV_NONE, 1065 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT}, 1066 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP, 1067 (char_u *)&p_dy, PV_NONE, 1068 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1069 {"eadirection", "ead", P_STRING|P_VI_DEF, 1070 (char_u *)&p_ead, PV_NONE, 1071 {(char_u *)"both", (char_u *)0L} 1072 SCRIPTID_INIT}, 1073 {"edcompatible","ed", P_BOOL|P_VI_DEF, 1074 (char_u *)&p_ed, PV_NONE, 1075 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1076 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR, 1077 #if defined(FEAT_MBYTE) 1078 (char_u *)&p_emoji, PV_NONE, 1079 {(char_u *)TRUE, (char_u *)0L} 1080 #else 1081 (char_u *)NULL, PV_NONE, 1082 {(char_u *)0L, (char_u *)0L} 1083 #endif 1084 SCRIPTID_INIT}, 1085 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML, 1086 #ifdef FEAT_MBYTE 1087 (char_u *)&p_enc, PV_NONE, 1088 {(char_u *)ENC_DFLT, (char_u *)0L} 1089 #else 1090 (char_u *)NULL, PV_NONE, 1091 {(char_u *)0L, (char_u *)0L} 1092 #endif 1093 SCRIPTID_INIT}, 1094 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, 1095 (char_u *)&p_eol, PV_EOL, 1096 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1097 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL, 1098 (char_u *)&p_ea, PV_NONE, 1099 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1100 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1101 (char_u *)&p_ep, PV_EP, 1102 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1103 {"errorbells", "eb", P_BOOL|P_VI_DEF, 1104 (char_u *)&p_eb, PV_NONE, 1105 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1106 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1107 #ifdef FEAT_QUICKFIX 1108 (char_u *)&p_ef, PV_NONE, 1109 {(char_u *)DFLT_ERRORFILE, (char_u *)0L} 1110 #else 1111 (char_u *)NULL, PV_NONE, 1112 {(char_u *)NULL, (char_u *)0L} 1113 #endif 1114 SCRIPTID_INIT}, 1115 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1116 #ifdef FEAT_QUICKFIX 1117 (char_u *)&p_efm, PV_EFM, 1118 {(char_u *)DFLT_EFM, (char_u *)0L} 1119 #else 1120 (char_u *)NULL, PV_NONE, 1121 {(char_u *)NULL, (char_u *)0L} 1122 #endif 1123 SCRIPTID_INIT}, 1124 {"esckeys", "ek", P_BOOL|P_VIM, 1125 (char_u *)&p_ek, PV_NONE, 1126 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 1127 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1128 #ifdef FEAT_AUTOCMD 1129 (char_u *)&p_ei, PV_NONE, 1130 #else 1131 (char_u *)NULL, PV_NONE, 1132 #endif 1133 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1134 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM, 1135 (char_u *)&p_et, PV_ET, 1136 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1137 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE, 1138 (char_u *)&p_exrc, PV_NONE, 1139 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1140 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF 1141 |P_NO_MKRC, 1142 #ifdef FEAT_MBYTE 1143 (char_u *)&p_fenc, PV_FENC, 1144 {(char_u *)"", (char_u *)0L} 1145 #else 1146 (char_u *)NULL, PV_NONE, 1147 {(char_u *)0L, (char_u *)0L} 1148 #endif 1149 SCRIPTID_INIT}, 1150 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA, 1151 #ifdef FEAT_MBYTE 1152 (char_u *)&p_fencs, PV_NONE, 1153 {(char_u *)"ucs-bom", (char_u *)0L} 1154 #else 1155 (char_u *)NULL, PV_NONE, 1156 {(char_u *)0L, (char_u *)0L} 1157 #endif 1158 SCRIPTID_INIT}, 1159 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC 1160 |P_CURSWANT, 1161 (char_u *)&p_ff, PV_FF, 1162 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT}, 1163 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP, 1164 (char_u *)&p_ffs, PV_NONE, 1165 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM} 1166 SCRIPTID_INIT}, 1167 {"fileignorecase", "fic", P_BOOL|P_VI_DEF, 1168 (char_u *)&p_fic, PV_NONE, 1169 { 1170 #ifdef CASE_INSENSITIVE_FILENAME 1171 (char_u *)TRUE, 1172 #else 1173 (char_u *)FALSE, 1174 #endif 1175 (char_u *)0L} SCRIPTID_INIT}, 1176 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, 1177 #ifdef FEAT_AUTOCMD 1178 (char_u *)&p_ft, PV_FT, 1179 {(char_u *)"", (char_u *)0L} 1180 #else 1181 (char_u *)NULL, PV_NONE, 1182 {(char_u *)0L, (char_u *)0L} 1183 #endif 1184 SCRIPTID_INIT}, 1185 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP, 1186 (char_u *)&p_fcs, PV_NONE, 1187 {(char_u *)"vert:|,fold:-", (char_u *)0L} 1188 SCRIPTID_INIT}, 1189 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT, 1190 (char_u *)&p_fixeol, PV_FIXEOL, 1191 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1192 {"fkmap", "fk", P_BOOL|P_VI_DEF, 1193 #ifdef FEAT_FKMAP 1194 (char_u *)&p_fkmap, PV_NONE, 1195 #else 1196 (char_u *)NULL, PV_NONE, 1197 #endif 1198 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1199 {"flash", "fl", P_BOOL|P_VI_DEF, 1200 (char_u *)NULL, PV_NONE, 1201 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1202 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN, 1203 #ifdef FEAT_FOLDING 1204 (char_u *)&p_fcl, PV_NONE, 1205 {(char_u *)"", (char_u *)0L} 1206 #else 1207 (char_u *)NULL, PV_NONE, 1208 {(char_u *)NULL, (char_u *)0L} 1209 #endif 1210 SCRIPTID_INIT}, 1211 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN, 1212 #ifdef FEAT_FOLDING 1213 (char_u *)VAR_WIN, PV_FDC, 1214 {(char_u *)FALSE, (char_u *)0L} 1215 #else 1216 (char_u *)NULL, PV_NONE, 1217 {(char_u *)NULL, (char_u *)0L} 1218 #endif 1219 SCRIPTID_INIT}, 1220 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN, 1221 #ifdef FEAT_FOLDING 1222 (char_u *)VAR_WIN, PV_FEN, 1223 {(char_u *)TRUE, (char_u *)0L} 1224 #else 1225 (char_u *)NULL, PV_NONE, 1226 {(char_u *)NULL, (char_u *)0L} 1227 #endif 1228 SCRIPTID_INIT}, 1229 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1230 #if defined(FEAT_FOLDING) && defined(FEAT_EVAL) 1231 (char_u *)VAR_WIN, PV_FDE, 1232 {(char_u *)"0", (char_u *)NULL} 1233 #else 1234 (char_u *)NULL, PV_NONE, 1235 {(char_u *)NULL, (char_u *)0L} 1236 #endif 1237 SCRIPTID_INIT}, 1238 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1239 #ifdef FEAT_FOLDING 1240 (char_u *)VAR_WIN, PV_FDI, 1241 {(char_u *)"#", (char_u *)NULL} 1242 #else 1243 (char_u *)NULL, PV_NONE, 1244 {(char_u *)NULL, (char_u *)0L} 1245 #endif 1246 SCRIPTID_INIT}, 1247 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN, 1248 #ifdef FEAT_FOLDING 1249 (char_u *)VAR_WIN, PV_FDL, 1250 {(char_u *)0L, (char_u *)0L} 1251 #else 1252 (char_u *)NULL, PV_NONE, 1253 {(char_u *)NULL, (char_u *)0L} 1254 #endif 1255 SCRIPTID_INIT}, 1256 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT, 1257 #ifdef FEAT_FOLDING 1258 (char_u *)&p_fdls, PV_NONE, 1259 {(char_u *)-1L, (char_u *)0L} 1260 #else 1261 (char_u *)NULL, PV_NONE, 1262 {(char_u *)NULL, (char_u *)0L} 1263 #endif 1264 SCRIPTID_INIT}, 1265 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF| 1266 P_RWIN|P_ONECOMMA|P_NODUP, 1267 #ifdef FEAT_FOLDING 1268 (char_u *)VAR_WIN, PV_FMR, 1269 {(char_u *)"{{{,}}}", (char_u *)NULL} 1270 #else 1271 (char_u *)NULL, PV_NONE, 1272 {(char_u *)NULL, (char_u *)0L} 1273 #endif 1274 SCRIPTID_INIT}, 1275 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1276 #ifdef FEAT_FOLDING 1277 (char_u *)VAR_WIN, PV_FDM, 1278 {(char_u *)"manual", (char_u *)NULL} 1279 #else 1280 (char_u *)NULL, PV_NONE, 1281 {(char_u *)NULL, (char_u *)0L} 1282 #endif 1283 SCRIPTID_INIT}, 1284 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN, 1285 #ifdef FEAT_FOLDING 1286 (char_u *)VAR_WIN, PV_FML, 1287 {(char_u *)1L, (char_u *)0L} 1288 #else 1289 (char_u *)NULL, PV_NONE, 1290 {(char_u *)NULL, (char_u *)0L} 1291 #endif 1292 SCRIPTID_INIT}, 1293 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN, 1294 #ifdef FEAT_FOLDING 1295 (char_u *)VAR_WIN, PV_FDN, 1296 {(char_u *)20L, (char_u *)0L} 1297 #else 1298 (char_u *)NULL, PV_NONE, 1299 {(char_u *)NULL, (char_u *)0L} 1300 #endif 1301 SCRIPTID_INIT}, 1302 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT, 1303 #ifdef FEAT_FOLDING 1304 (char_u *)&p_fdo, PV_NONE, 1305 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo", 1306 (char_u *)0L} 1307 #else 1308 (char_u *)NULL, PV_NONE, 1309 {(char_u *)NULL, (char_u *)0L} 1310 #endif 1311 SCRIPTID_INIT}, 1312 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN, 1313 #if defined(FEAT_FOLDING) && defined(FEAT_EVAL) 1314 (char_u *)VAR_WIN, PV_FDT, 1315 {(char_u *)"foldtext()", (char_u *)NULL} 1316 #else 1317 (char_u *)NULL, PV_NONE, 1318 {(char_u *)NULL, (char_u *)0L} 1319 #endif 1320 SCRIPTID_INIT}, 1321 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, 1322 #ifdef FEAT_EVAL 1323 (char_u *)&p_fex, PV_FEX, 1324 {(char_u *)"", (char_u *)0L} 1325 #else 1326 (char_u *)NULL, PV_NONE, 1327 {(char_u *)0L, (char_u *)0L} 1328 #endif 1329 SCRIPTID_INIT}, 1330 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST, 1331 (char_u *)&p_fo, PV_FO, 1332 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM} 1333 SCRIPTID_INIT}, 1334 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF, 1335 (char_u *)&p_flp, PV_FLP, 1336 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", 1337 (char_u *)0L} SCRIPTID_INIT}, 1338 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1339 (char_u *)&p_fp, PV_FP, 1340 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1341 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, 1342 #ifdef HAVE_FSYNC 1343 (char_u *)&p_fs, PV_NONE, 1344 {(char_u *)TRUE, (char_u *)0L} 1345 #else 1346 (char_u *)NULL, PV_NONE, 1347 {(char_u *)FALSE, (char_u *)0L} 1348 #endif 1349 SCRIPTID_INIT}, 1350 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM, 1351 (char_u *)&p_gd, PV_NONE, 1352 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1353 {"graphic", "gr", P_BOOL|P_VI_DEF, 1354 (char_u *)NULL, PV_NONE, 1355 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1356 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1357 #ifdef FEAT_QUICKFIX 1358 (char_u *)&p_gefm, PV_NONE, 1359 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L} 1360 #else 1361 (char_u *)NULL, PV_NONE, 1362 {(char_u *)NULL, (char_u *)0L} 1363 #endif 1364 SCRIPTID_INIT}, 1365 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1366 #ifdef FEAT_QUICKFIX 1367 (char_u *)&p_gp, PV_GP, 1368 { 1369 # ifdef WIN3264 1370 /* may be changed to "grep -n" in os_win32.c */ 1371 (char_u *)"findstr /n", 1372 # else 1373 # ifdef UNIX 1374 /* Add an extra file name so that grep will always 1375 * insert a file name in the match line. */ 1376 (char_u *)"grep -n $* /dev/null", 1377 # else 1378 # ifdef VMS 1379 (char_u *)"SEARCH/NUMBERS ", 1380 # else 1381 (char_u *)"grep -n ", 1382 # endif 1383 # endif 1384 # endif 1385 (char_u *)0L} 1386 #else 1387 (char_u *)NULL, PV_NONE, 1388 {(char_u *)NULL, (char_u *)0L} 1389 #endif 1390 SCRIPTID_INIT}, 1391 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1392 #ifdef CURSOR_SHAPE 1393 (char_u *)&p_guicursor, PV_NONE, 1394 { 1395 # ifdef FEAT_GUI 1396 (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", 1397 # else /* Win32 console */ 1398 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block", 1399 # endif 1400 (char_u *)0L} 1401 #else 1402 (char_u *)NULL, PV_NONE, 1403 {(char_u *)NULL, (char_u *)0L} 1404 #endif 1405 SCRIPTID_INIT}, 1406 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP, 1407 #ifdef FEAT_GUI 1408 (char_u *)&p_guifont, PV_NONE, 1409 {(char_u *)"", (char_u *)0L} 1410 #else 1411 (char_u *)NULL, PV_NONE, 1412 {(char_u *)NULL, (char_u *)0L} 1413 #endif 1414 SCRIPTID_INIT}, 1415 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA, 1416 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET) 1417 (char_u *)&p_guifontset, PV_NONE, 1418 {(char_u *)"", (char_u *)0L} 1419 #else 1420 (char_u *)NULL, PV_NONE, 1421 {(char_u *)NULL, (char_u *)0L} 1422 #endif 1423 SCRIPTID_INIT}, 1424 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP, 1425 #if defined(FEAT_GUI) && defined(FEAT_MBYTE) 1426 (char_u *)&p_guifontwide, PV_NONE, 1427 {(char_u *)"", (char_u *)0L} 1428 #else 1429 (char_u *)NULL, PV_NONE, 1430 {(char_u *)NULL, (char_u *)0L} 1431 #endif 1432 SCRIPTID_INIT}, 1433 {"guiheadroom", "ghr", P_NUM|P_VI_DEF, 1434 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) 1435 (char_u *)&p_ghr, PV_NONE, 1436 #else 1437 (char_u *)NULL, PV_NONE, 1438 #endif 1439 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT}, 1440 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST, 1441 #if defined(FEAT_GUI) 1442 (char_u *)&p_go, PV_NONE, 1443 # if defined(UNIX) && !defined(FEAT_GUI_MAC) 1444 {(char_u *)"aegimrLtT", (char_u *)0L} 1445 # else 1446 {(char_u *)"egmrLtT", (char_u *)0L} 1447 # endif 1448 #else 1449 (char_u *)NULL, PV_NONE, 1450 {(char_u *)NULL, (char_u *)0L} 1451 #endif 1452 SCRIPTID_INIT}, 1453 {"guipty", NULL, P_BOOL|P_VI_DEF, 1454 #if defined(FEAT_GUI) 1455 (char_u *)&p_guipty, PV_NONE, 1456 #else 1457 (char_u *)NULL, PV_NONE, 1458 #endif 1459 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1460 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN, 1461 #if defined(FEAT_GUI_TABLINE) 1462 (char_u *)&p_gtl, PV_NONE, 1463 {(char_u *)"", (char_u *)0L} 1464 #else 1465 (char_u *)NULL, PV_NONE, 1466 {(char_u *)NULL, (char_u *)0L} 1467 #endif 1468 SCRIPTID_INIT}, 1469 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN, 1470 #if defined(FEAT_GUI_TABLINE) 1471 (char_u *)&p_gtt, PV_NONE, 1472 {(char_u *)"", (char_u *)0L} 1473 #else 1474 (char_u *)NULL, PV_NONE, 1475 {(char_u *)NULL, (char_u *)0L} 1476 #endif 1477 SCRIPTID_INIT}, 1478 {"hardtabs", "ht", P_NUM|P_VI_DEF, 1479 (char_u *)NULL, PV_NONE, 1480 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 1481 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1482 (char_u *)&p_hf, PV_NONE, 1483 {(char_u *)DFLT_HELPFILE, (char_u *)0L} 1484 SCRIPTID_INIT}, 1485 {"helpheight", "hh", P_NUM|P_VI_DEF, 1486 (char_u *)&p_hh, PV_NONE, 1487 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, 1488 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA, 1489 #ifdef FEAT_MULTI_LANG 1490 (char_u *)&p_hlg, PV_NONE, 1491 {(char_u *)"", (char_u *)0L} 1492 #else 1493 (char_u *)NULL, PV_NONE, 1494 {(char_u *)0L, (char_u *)0L} 1495 #endif 1496 SCRIPTID_INIT}, 1497 {"hidden", "hid", P_BOOL|P_VI_DEF, 1498 (char_u *)&p_hid, PV_NONE, 1499 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1500 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP, 1501 (char_u *)&p_hl, PV_NONE, 1502 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L} 1503 SCRIPTID_INIT}, 1504 {"history", "hi", P_NUM|P_VIM, 1505 (char_u *)&p_hi, PV_NONE, 1506 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT}, 1507 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM, 1508 #ifdef FEAT_RIGHTLEFT 1509 (char_u *)&p_hkmap, PV_NONE, 1510 #else 1511 (char_u *)NULL, PV_NONE, 1512 #endif 1513 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1514 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM, 1515 #ifdef FEAT_RIGHTLEFT 1516 (char_u *)&p_hkmapp, PV_NONE, 1517 #else 1518 (char_u *)NULL, PV_NONE, 1519 #endif 1520 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1521 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL, 1522 (char_u *)&p_hls, PV_NONE, 1523 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1524 {"icon", NULL, P_BOOL|P_VI_DEF, 1525 #ifdef FEAT_TITLE 1526 (char_u *)&p_icon, PV_NONE, 1527 #else 1528 (char_u *)NULL, PV_NONE, 1529 #endif 1530 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1531 {"iconstring", NULL, P_STRING|P_VI_DEF, 1532 #ifdef FEAT_TITLE 1533 (char_u *)&p_iconstring, PV_NONE, 1534 #else 1535 (char_u *)NULL, PV_NONE, 1536 #endif 1537 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1538 {"ignorecase", "ic", P_BOOL|P_VI_DEF, 1539 (char_u *)&p_ic, PV_NONE, 1540 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1541 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE, 1542 #if defined(FEAT_EVAL) && defined(FEAT_MBYTE) 1543 (char_u *)&p_imaf, PV_NONE, 1544 {(char_u *)"", (char_u *)NULL} 1545 # else 1546 (char_u *)NULL, PV_NONE, 1547 {(char_u *)NULL, (char_u *)0L} 1548 # endif 1549 SCRIPTID_INIT}, 1550 {"imactivatekey","imak",P_STRING|P_VI_DEF, 1551 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 1552 (char_u *)&p_imak, PV_NONE, 1553 #else 1554 (char_u *)NULL, PV_NONE, 1555 #endif 1556 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1557 {"imcmdline", "imc", P_BOOL|P_VI_DEF, 1558 #ifdef FEAT_MBYTE 1559 (char_u *)&p_imcmdline, PV_NONE, 1560 #else 1561 (char_u *)NULL, PV_NONE, 1562 #endif 1563 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1564 {"imdisable", "imd", P_BOOL|P_VI_DEF, 1565 #ifdef FEAT_MBYTE 1566 (char_u *)&p_imdisable, PV_NONE, 1567 #else 1568 (char_u *)NULL, PV_NONE, 1569 #endif 1570 #ifdef __sgi 1571 {(char_u *)TRUE, (char_u *)0L} 1572 #else 1573 {(char_u *)FALSE, (char_u *)0L} 1574 #endif 1575 SCRIPTID_INIT}, 1576 {"iminsert", "imi", P_NUM|P_VI_DEF, 1577 (char_u *)&p_iminsert, PV_IMI, 1578 {(char_u *)B_IMODE_NONE, (char_u *)0L} 1579 SCRIPTID_INIT}, 1580 {"imsearch", "ims", P_NUM|P_VI_DEF, 1581 (char_u *)&p_imsearch, PV_IMS, 1582 {(char_u *)B_IMODE_USE_INSERT, (char_u *)0L} 1583 SCRIPTID_INIT}, 1584 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE, 1585 #if defined(FEAT_EVAL) && defined(FEAT_MBYTE) 1586 (char_u *)&p_imsf, PV_NONE, 1587 {(char_u *)"", (char_u *)NULL} 1588 #else 1589 (char_u *)NULL, PV_NONE, 1590 {(char_u *)NULL, (char_u *)0L} 1591 #endif 1592 SCRIPTID_INIT}, 1593 {"imstyle", "imst", P_NUM|P_VI_DEF|P_SECURE, 1594 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 1595 (char_u *)&p_imst, PV_NONE, 1596 {(char_u *)IM_OVER_THE_SPOT, (char_u *)0L} 1597 #else 1598 (char_u *)NULL, PV_NONE, 1599 {(char_u *)0L, (char_u *)0L} 1600 #endif 1601 SCRIPTID_INIT}, 1602 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF, 1603 #ifdef FEAT_FIND_ID 1604 (char_u *)&p_inc, PV_INC, 1605 {(char_u *)"^\\s*#\\s*include", (char_u *)0L} 1606 #else 1607 (char_u *)NULL, PV_NONE, 1608 {(char_u *)0L, (char_u *)0L} 1609 #endif 1610 SCRIPTID_INIT}, 1611 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF, 1612 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 1613 (char_u *)&p_inex, PV_INEX, 1614 {(char_u *)"", (char_u *)0L} 1615 #else 1616 (char_u *)NULL, PV_NONE, 1617 {(char_u *)0L, (char_u *)0L} 1618 #endif 1619 SCRIPTID_INIT}, 1620 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM, 1621 (char_u *)&p_is, PV_NONE, 1622 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1623 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM, 1624 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 1625 (char_u *)&p_inde, PV_INDE, 1626 {(char_u *)"", (char_u *)0L} 1627 #else 1628 (char_u *)NULL, PV_NONE, 1629 {(char_u *)0L, (char_u *)0L} 1630 #endif 1631 SCRIPTID_INIT}, 1632 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 1633 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 1634 (char_u *)&p_indk, PV_INDK, 1635 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L} 1636 #else 1637 (char_u *)NULL, PV_NONE, 1638 {(char_u *)0L, (char_u *)0L} 1639 #endif 1640 SCRIPTID_INIT}, 1641 {"infercase", "inf", P_BOOL|P_VI_DEF, 1642 (char_u *)&p_inf, PV_INF, 1643 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1644 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM, 1645 (char_u *)&p_im, PV_NONE, 1646 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1647 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, 1648 (char_u *)&p_isf, PV_NONE, 1649 { 1650 #ifdef BACKSLASH_IN_FILENAME 1651 /* Excluded are: & and ^ are special in cmd.exe 1652 * ( and ) are used in text separating fnames */ 1653 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=", 1654 #else 1655 # ifdef AMIGA 1656 (char_u *)"@,48-57,/,.,-,_,+,,,$,:", 1657 # else 1658 # ifdef VMS 1659 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~", 1660 # else /* UNIX et al. */ 1661 # ifdef EBCDIC 1662 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=", 1663 # else 1664 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=", 1665 # endif 1666 # endif 1667 # endif 1668 #endif 1669 (char_u *)0L} SCRIPTID_INIT}, 1670 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, 1671 (char_u *)&p_isi, PV_NONE, 1672 { 1673 #if defined(MSWIN) 1674 (char_u *)"@,48-57,_,128-167,224-235", 1675 #else 1676 # ifdef EBCDIC 1677 /* TODO: EBCDIC Check this! @ == isalpha()*/ 1678 (char_u *)"@,240-249,_,66-73,81-89,98-105," 1679 "112-120,128,140-142,156,158,172," 1680 "174,186,191,203-207,219-225,235-239," 1681 "251-254", 1682 # else 1683 (char_u *)"@,48-57,_,192-255", 1684 # endif 1685 #endif 1686 (char_u *)0L} SCRIPTID_INIT}, 1687 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP, 1688 (char_u *)&p_isk, PV_ISK, 1689 { 1690 #ifdef EBCDIC 1691 (char_u *)"@,240-249,_", 1692 /* TODO: EBCDIC Check this! @ == isalpha()*/ 1693 (char_u *)"@,240-249,_,66-73,81-89,98-105," 1694 "112-120,128,140-142,156,158,172," 1695 "174,186,191,203-207,219-225,235-239," 1696 "251-254", 1697 #else 1698 (char_u *)"@,48-57,_", 1699 # if defined(MSWIN) 1700 (char_u *)"@,48-57,_,128-167,224-235" 1701 # else 1702 ISK_LATIN1 1703 # endif 1704 #endif 1705 } SCRIPTID_INIT}, 1706 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, 1707 (char_u *)&p_isp, PV_NONE, 1708 { 1709 #if defined(MSWIN) || defined(VMS) 1710 (char_u *)"@,~-255", 1711 #else 1712 # ifdef EBCDIC 1713 /* all chars above 63 are printable */ 1714 (char_u *)"63-255", 1715 # else 1716 ISP_LATIN1, 1717 # endif 1718 #endif 1719 (char_u *)0L} SCRIPTID_INIT}, 1720 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM, 1721 (char_u *)&p_js, PV_NONE, 1722 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1723 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC, 1724 #ifdef FEAT_CRYPT 1725 (char_u *)&p_key, PV_KEY, 1726 {(char_u *)"", (char_u *)0L} 1727 #else 1728 (char_u *)NULL, PV_NONE, 1729 {(char_u *)0L, (char_u *)0L} 1730 #endif 1731 SCRIPTID_INIT}, 1732 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC, 1733 #ifdef FEAT_KEYMAP 1734 (char_u *)&p_keymap, PV_KMAP, 1735 {(char_u *)"", (char_u *)0L} 1736 #else 1737 (char_u *)NULL, PV_NONE, 1738 {(char_u *)"", (char_u *)0L} 1739 #endif 1740 SCRIPTID_INIT}, 1741 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1742 (char_u *)&p_km, PV_NONE, 1743 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1744 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1745 (char_u *)&p_kp, PV_KP, 1746 { 1747 #ifdef MSWIN 1748 (char_u *)":help", 1749 #else 1750 # ifdef VMS 1751 (char_u *)"help", 1752 # else 1753 # ifdef USEMAN_S 1754 (char_u *)"man -s", 1755 # else 1756 (char_u *)"man", 1757 # endif 1758 # endif 1759 #endif 1760 (char_u *)0L} SCRIPTID_INIT}, 1761 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE, 1762 #ifdef FEAT_LANGMAP 1763 (char_u *)&p_langmap, PV_NONE, 1764 {(char_u *)"", /* unmatched } */ 1765 #else 1766 (char_u *)NULL, PV_NONE, 1767 {(char_u *)NULL, 1768 #endif 1769 (char_u *)0L} SCRIPTID_INIT}, 1770 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME, 1771 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG) 1772 (char_u *)&p_lm, PV_NONE, 1773 #else 1774 (char_u *)NULL, PV_NONE, 1775 #endif 1776 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 1777 {"langnoremap", "lnr", P_BOOL|P_VI_DEF, 1778 #ifdef FEAT_LANGMAP 1779 (char_u *)&p_lnr, PV_NONE, 1780 #else 1781 (char_u *)NULL, PV_NONE, 1782 #endif 1783 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1784 {"langremap", "lrm", P_BOOL|P_VI_DEF, 1785 #ifdef FEAT_LANGMAP 1786 (char_u *)&p_lrm, PV_NONE, 1787 #else 1788 (char_u *)NULL, PV_NONE, 1789 #endif 1790 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1791 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL, 1792 (char_u *)&p_ls, PV_NONE, 1793 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 1794 {"lazyredraw", "lz", P_BOOL|P_VI_DEF, 1795 (char_u *)&p_lz, PV_NONE, 1796 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1797 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN, 1798 #ifdef FEAT_LINEBREAK 1799 (char_u *)VAR_WIN, PV_LBR, 1800 #else 1801 (char_u *)NULL, PV_NONE, 1802 #endif 1803 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1804 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR, 1805 (char_u *)&Rows, PV_NONE, 1806 { 1807 #if defined(WIN3264) 1808 (char_u *)25L, 1809 #else 1810 (char_u *)24L, 1811 #endif 1812 (char_u *)0L} SCRIPTID_INIT}, 1813 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR, 1814 #ifdef FEAT_GUI 1815 (char_u *)&p_linespace, PV_NONE, 1816 #else 1817 (char_u *)NULL, PV_NONE, 1818 #endif 1819 #ifdef FEAT_GUI_W32 1820 {(char_u *)1L, (char_u *)0L} 1821 #else 1822 {(char_u *)0L, (char_u *)0L} 1823 #endif 1824 SCRIPTID_INIT}, 1825 {"lisp", NULL, P_BOOL|P_VI_DEF, 1826 #ifdef FEAT_LISP 1827 (char_u *)&p_lisp, PV_LISP, 1828 #else 1829 (char_u *)NULL, PV_NONE, 1830 #endif 1831 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1832 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 1833 #ifdef FEAT_LISP 1834 (char_u *)&p_lispwords, PV_LW, 1835 {(char_u *)LISPWORD_VALUE, (char_u *)0L} 1836 #else 1837 (char_u *)NULL, PV_NONE, 1838 {(char_u *)"", (char_u *)0L} 1839 #endif 1840 SCRIPTID_INIT}, 1841 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN, 1842 (char_u *)VAR_WIN, PV_LIST, 1843 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1844 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP, 1845 (char_u *)&p_lcs, PV_NONE, 1846 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT}, 1847 {"loadplugins", "lpl", P_BOOL|P_VI_DEF, 1848 (char_u *)&p_lpl, PV_NONE, 1849 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1850 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1851 #if defined(DYNAMIC_LUA) 1852 (char_u *)&p_luadll, PV_NONE, 1853 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L} 1854 #else 1855 (char_u *)NULL, PV_NONE, 1856 {(char_u *)"", (char_u *)0L} 1857 #endif 1858 SCRIPTID_INIT}, 1859 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR, 1860 #ifdef FEAT_GUI_MAC 1861 (char_u *)&p_macatsui, PV_NONE, 1862 {(char_u *)TRUE, (char_u *)0L} 1863 #else 1864 (char_u *)NULL, PV_NONE, 1865 {(char_u *)"", (char_u *)0L} 1866 #endif 1867 SCRIPTID_INIT}, 1868 {"magic", NULL, P_BOOL|P_VI_DEF, 1869 (char_u *)&p_magic, PV_NONE, 1870 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1871 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1872 #ifdef FEAT_QUICKFIX 1873 (char_u *)&p_mef, PV_NONE, 1874 {(char_u *)"", (char_u *)0L} 1875 #else 1876 (char_u *)NULL, PV_NONE, 1877 {(char_u *)NULL, (char_u *)0L} 1878 #endif 1879 SCRIPTID_INIT}, 1880 {"makeencoding","menc", P_STRING|P_VI_DEF, 1881 #ifdef FEAT_MBYTE 1882 (char_u *)&p_menc, PV_MENC, 1883 {(char_u *)"", (char_u *)0L} 1884 #else 1885 (char_u *)NULL, PV_NONE, 1886 {(char_u *)0L, (char_u *)0L} 1887 #endif 1888 SCRIPTID_INIT}, 1889 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 1890 #ifdef FEAT_QUICKFIX 1891 (char_u *)&p_mp, PV_MP, 1892 # ifdef VMS 1893 {(char_u *)"MMS", (char_u *)0L} 1894 # else 1895 {(char_u *)"make", (char_u *)0L} 1896 # endif 1897 #else 1898 (char_u *)NULL, PV_NONE, 1899 {(char_u *)NULL, (char_u *)0L} 1900 #endif 1901 SCRIPTID_INIT}, 1902 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 1903 (char_u *)&p_mps, PV_MPS, 1904 {(char_u *)"(:),{:},[:]", (char_u *)0L} 1905 SCRIPTID_INIT}, 1906 {"matchtime", "mat", P_NUM|P_VI_DEF, 1907 (char_u *)&p_mat, PV_NONE, 1908 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT}, 1909 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT, 1910 #ifdef FEAT_MBYTE 1911 (char_u *)&p_mco, PV_NONE, 1912 #else 1913 (char_u *)NULL, PV_NONE, 1914 #endif 1915 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT}, 1916 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF, 1917 #ifdef FEAT_EVAL 1918 (char_u *)&p_mfd, PV_NONE, 1919 #else 1920 (char_u *)NULL, PV_NONE, 1921 #endif 1922 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT}, 1923 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF, 1924 (char_u *)&p_mmd, PV_NONE, 1925 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, 1926 {"maxmem", "mm", P_NUM|P_VI_DEF, 1927 (char_u *)&p_mm, PV_NONE, 1928 {(char_u *)DFLT_MAXMEM, (char_u *)0L} 1929 SCRIPTID_INIT}, 1930 {"maxmempattern","mmp", P_NUM|P_VI_DEF, 1931 (char_u *)&p_mmp, PV_NONE, 1932 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, 1933 {"maxmemtot", "mmt", P_NUM|P_VI_DEF, 1934 (char_u *)&p_mmt, PV_NONE, 1935 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L} 1936 SCRIPTID_INIT}, 1937 {"menuitems", "mis", P_NUM|P_VI_DEF, 1938 #ifdef FEAT_MENU 1939 (char_u *)&p_mis, PV_NONE, 1940 #else 1941 (char_u *)NULL, PV_NONE, 1942 #endif 1943 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT}, 1944 {"mesg", NULL, P_BOOL|P_VI_DEF, 1945 (char_u *)NULL, PV_NONE, 1946 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1947 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE, 1948 #ifdef FEAT_SPELL 1949 (char_u *)&p_msm, PV_NONE, 1950 {(char_u *)"460000,2000,500", (char_u *)0L} 1951 #else 1952 (char_u *)NULL, PV_NONE, 1953 {(char_u *)0L, (char_u *)0L} 1954 #endif 1955 SCRIPTID_INIT}, 1956 {"modeline", "ml", P_BOOL|P_VIM, 1957 (char_u *)&p_ml, PV_ML, 1958 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 1959 {"modelines", "mls", P_NUM|P_VI_DEF, 1960 (char_u *)&p_mls, PV_NONE, 1961 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT}, 1962 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB, 1963 (char_u *)&p_ma, PV_MA, 1964 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1965 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT, 1966 (char_u *)&p_mod, PV_MOD, 1967 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1968 {"more", NULL, P_BOOL|P_VIM, 1969 (char_u *)&p_more, PV_NONE, 1970 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 1971 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST, 1972 (char_u *)&p_mouse, PV_NONE, 1973 { 1974 #if defined(WIN3264) 1975 (char_u *)"a", 1976 #else 1977 (char_u *)"", 1978 #endif 1979 (char_u *)0L} SCRIPTID_INIT}, 1980 {"mousefocus", "mousef", P_BOOL|P_VI_DEF, 1981 #ifdef FEAT_GUI 1982 (char_u *)&p_mousef, PV_NONE, 1983 #else 1984 (char_u *)NULL, PV_NONE, 1985 #endif 1986 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 1987 {"mousehide", "mh", P_BOOL|P_VI_DEF, 1988 #ifdef FEAT_GUI 1989 (char_u *)&p_mh, PV_NONE, 1990 #else 1991 (char_u *)NULL, PV_NONE, 1992 #endif 1993 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 1994 {"mousemodel", "mousem", P_STRING|P_VI_DEF, 1995 (char_u *)&p_mousem, PV_NONE, 1996 { 1997 #if defined(MSWIN) 1998 (char_u *)"popup", 1999 #else 2000 # if defined(MACOS_X) 2001 (char_u *)"popup_setpos", 2002 # else 2003 (char_u *)"extend", 2004 # endif 2005 #endif 2006 (char_u *)0L} SCRIPTID_INIT}, 2007 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2008 #ifdef FEAT_MOUSESHAPE 2009 (char_u *)&p_mouseshape, PV_NONE, 2010 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L} 2011 #else 2012 (char_u *)NULL, PV_NONE, 2013 {(char_u *)NULL, (char_u *)0L} 2014 #endif 2015 SCRIPTID_INIT}, 2016 {"mousetime", "mouset", P_NUM|P_VI_DEF, 2017 (char_u *)&p_mouset, PV_NONE, 2018 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT}, 2019 {"mzschemedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2020 #if defined(DYNAMIC_MZSCHEME) 2021 (char_u *)&p_mzschemedll, PV_NONE, 2022 {(char_u *)DYNAMIC_MZSCH_DLL, (char_u *)0L} 2023 #else 2024 (char_u *)NULL, PV_NONE, 2025 {(char_u *)"", (char_u *)0L} 2026 #endif 2027 SCRIPTID_INIT}, 2028 {"mzschemegcdll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2029 #if defined(DYNAMIC_MZSCHEME) 2030 (char_u *)&p_mzschemegcdll, PV_NONE, 2031 {(char_u *)DYNAMIC_MZGC_DLL, (char_u *)0L} 2032 #else 2033 (char_u *)NULL, PV_NONE, 2034 {(char_u *)"", (char_u *)0L} 2035 #endif 2036 SCRIPTID_INIT}, 2037 {"mzquantum", "mzq", P_NUM, 2038 #ifdef FEAT_MZSCHEME 2039 (char_u *)&p_mzq, PV_NONE, 2040 #else 2041 (char_u *)NULL, PV_NONE, 2042 #endif 2043 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT}, 2044 {"novice", NULL, P_BOOL|P_VI_DEF, 2045 (char_u *)NULL, PV_NONE, 2046 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2047 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP, 2048 (char_u *)&p_nf, PV_NF, 2049 {(char_u *)"bin,octal,hex", (char_u *)0L} 2050 SCRIPTID_INIT}, 2051 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN, 2052 (char_u *)VAR_WIN, PV_NU, 2053 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2054 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM, 2055 #ifdef FEAT_LINEBREAK 2056 (char_u *)VAR_WIN, PV_NUW, 2057 #else 2058 (char_u *)NULL, PV_NONE, 2059 #endif 2060 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT}, 2061 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE, 2062 #ifdef FEAT_COMPL_FUNC 2063 (char_u *)&p_ofu, PV_OFU, 2064 {(char_u *)"", (char_u *)0L} 2065 #else 2066 (char_u *)NULL, PV_NONE, 2067 {(char_u *)0L, (char_u *)0L} 2068 #endif 2069 SCRIPTID_INIT}, 2070 {"open", NULL, P_BOOL|P_VI_DEF, 2071 (char_u *)NULL, PV_NONE, 2072 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2073 {"opendevice", "odev", P_BOOL|P_VI_DEF, 2074 #if defined(MSWIN) 2075 (char_u *)&p_odev, PV_NONE, 2076 #else 2077 (char_u *)NULL, PV_NONE, 2078 #endif 2079 {(char_u *)FALSE, (char_u *)FALSE} 2080 SCRIPTID_INIT}, 2081 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE, 2082 (char_u *)&p_opfunc, PV_NONE, 2083 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2084 {"optimize", "opt", P_BOOL|P_VI_DEF, 2085 (char_u *)NULL, PV_NONE, 2086 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2087 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF, 2088 (char_u *)NULL, PV_NONE, 2089 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2090 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP 2091 |P_SECURE, 2092 (char_u *)&p_pp, PV_NONE, 2093 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L} 2094 SCRIPTID_INIT}, 2095 {"paragraphs", "para", P_STRING|P_VI_DEF, 2096 (char_u *)&p_para, PV_NONE, 2097 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp", 2098 (char_u *)0L} SCRIPTID_INIT}, 2099 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC, 2100 (char_u *)&p_paste, PV_NONE, 2101 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2102 {"pastetoggle", "pt", P_STRING|P_VI_DEF, 2103 (char_u *)&p_pt, PV_NONE, 2104 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2105 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE, 2106 #if defined(FEAT_DIFF) && defined(FEAT_EVAL) 2107 (char_u *)&p_pex, PV_NONE, 2108 {(char_u *)"", (char_u *)0L} 2109 #else 2110 (char_u *)NULL, PV_NONE, 2111 {(char_u *)0L, (char_u *)0L} 2112 #endif 2113 SCRIPTID_INIT}, 2114 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME, 2115 (char_u *)&p_pm, PV_NONE, 2116 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2117 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP, 2118 (char_u *)&p_path, PV_PATH, 2119 { 2120 #if defined(AMIGA) || defined(MSWIN) 2121 (char_u *)".,,", 2122 #else 2123 (char_u *)".,/usr/include,,", 2124 #endif 2125 (char_u *)0L} SCRIPTID_INIT}, 2126 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2127 #if defined(DYNAMIC_PERL) 2128 (char_u *)&p_perldll, PV_NONE, 2129 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L} 2130 #else 2131 (char_u *)NULL, PV_NONE, 2132 {(char_u *)0L, (char_u *)0L} 2133 #endif 2134 SCRIPTID_INIT}, 2135 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM, 2136 (char_u *)&p_pi, PV_PI, 2137 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2138 {"previewheight", "pvh", P_NUM|P_VI_DEF, 2139 #if defined(FEAT_QUICKFIX) 2140 (char_u *)&p_pvh, PV_NONE, 2141 #else 2142 (char_u *)NULL, PV_NONE, 2143 #endif 2144 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, 2145 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, 2146 #if defined(FEAT_QUICKFIX) 2147 (char_u *)VAR_WIN, PV_PVW, 2148 #else 2149 (char_u *)NULL, PV_NONE, 2150 #endif 2151 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2152 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE, 2153 #ifdef FEAT_PRINTER 2154 (char_u *)&p_pdev, PV_NONE, 2155 {(char_u *)"", (char_u *)0L} 2156 #else 2157 (char_u *)NULL, PV_NONE, 2158 {(char_u *)NULL, (char_u *)0L} 2159 #endif 2160 SCRIPTID_INIT}, 2161 {"printencoding", "penc", P_STRING|P_VI_DEF, 2162 #ifdef FEAT_POSTSCRIPT 2163 (char_u *)&p_penc, PV_NONE, 2164 {(char_u *)"", (char_u *)0L} 2165 #else 2166 (char_u *)NULL, PV_NONE, 2167 {(char_u *)NULL, (char_u *)0L} 2168 #endif 2169 SCRIPTID_INIT}, 2170 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE, 2171 #ifdef FEAT_POSTSCRIPT 2172 (char_u *)&p_pexpr, PV_NONE, 2173 {(char_u *)"", (char_u *)0L} 2174 #else 2175 (char_u *)NULL, PV_NONE, 2176 {(char_u *)NULL, (char_u *)0L} 2177 #endif 2178 SCRIPTID_INIT}, 2179 {"printfont", "pfn", P_STRING|P_VI_DEF, 2180 #ifdef FEAT_PRINTER 2181 (char_u *)&p_pfn, PV_NONE, 2182 { 2183 # ifdef MSWIN 2184 (char_u *)"Courier_New:h10", 2185 # else 2186 (char_u *)"courier", 2187 # endif 2188 (char_u *)0L} 2189 #else 2190 (char_u *)NULL, PV_NONE, 2191 {(char_u *)NULL, (char_u *)0L} 2192 #endif 2193 SCRIPTID_INIT}, 2194 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT, 2195 #ifdef FEAT_PRINTER 2196 (char_u *)&p_header, PV_NONE, 2197 /* untranslated to avoid problems when 'encoding' 2198 * is changed */ 2199 {(char_u *)"%<%f%h%m%=Page %N", (char_u *)0L} 2200 #else 2201 (char_u *)NULL, PV_NONE, 2202 {(char_u *)NULL, (char_u *)0L} 2203 #endif 2204 SCRIPTID_INIT}, 2205 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF, 2206 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) 2207 (char_u *)&p_pmcs, PV_NONE, 2208 {(char_u *)"", (char_u *)0L} 2209 #else 2210 (char_u *)NULL, PV_NONE, 2211 {(char_u *)NULL, (char_u *)0L} 2212 #endif 2213 SCRIPTID_INIT}, 2214 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF, 2215 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) 2216 (char_u *)&p_pmfn, PV_NONE, 2217 {(char_u *)"", (char_u *)0L} 2218 #else 2219 (char_u *)NULL, PV_NONE, 2220 {(char_u *)NULL, (char_u *)0L} 2221 #endif 2222 SCRIPTID_INIT}, 2223 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2224 #ifdef FEAT_PRINTER 2225 (char_u *)&p_popt, PV_NONE, 2226 {(char_u *)"", (char_u *)0L} 2227 #else 2228 (char_u *)NULL, PV_NONE, 2229 {(char_u *)NULL, (char_u *)0L} 2230 #endif 2231 SCRIPTID_INIT}, 2232 {"prompt", NULL, P_BOOL|P_VI_DEF, 2233 (char_u *)&p_prompt, PV_NONE, 2234 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2235 {"pumheight", "ph", P_NUM|P_VI_DEF, 2236 #ifdef FEAT_INS_EXPAND 2237 (char_u *)&p_ph, PV_NONE, 2238 #else 2239 (char_u *)NULL, PV_NONE, 2240 #endif 2241 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2242 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2243 #if defined(DYNAMIC_PYTHON3) 2244 (char_u *)&p_py3dll, PV_NONE, 2245 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L} 2246 #else 2247 (char_u *)NULL, PV_NONE, 2248 {(char_u *)NULL, (char_u *)0L} 2249 #endif 2250 SCRIPTID_INIT}, 2251 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2252 #if defined(DYNAMIC_PYTHON) 2253 (char_u *)&p_pydll, PV_NONE, 2254 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L} 2255 #else 2256 (char_u *)NULL, PV_NONE, 2257 {(char_u *)NULL, (char_u *)0L} 2258 #endif 2259 SCRIPTID_INIT}, 2260 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE, 2261 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) 2262 (char_u *)&p_pyx, PV_NONE, 2263 #else 2264 (char_u *)NULL, PV_NONE, 2265 #endif 2266 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L} 2267 SCRIPTID_INIT}, 2268 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF, 2269 #ifdef FEAT_TEXTOBJ 2270 (char_u *)&p_qe, PV_QE, 2271 {(char_u *)"\\", (char_u *)0L} 2272 #else 2273 (char_u *)NULL, PV_NONE, 2274 {(char_u *)NULL, (char_u *)0L} 2275 #endif 2276 SCRIPTID_INIT}, 2277 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB, 2278 (char_u *)&p_ro, PV_RO, 2279 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2280 {"redraw", NULL, P_BOOL|P_VI_DEF, 2281 (char_u *)NULL, PV_NONE, 2282 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2283 {"redrawtime", "rdt", P_NUM|P_VI_DEF, 2284 #ifdef FEAT_RELTIME 2285 (char_u *)&p_rdt, PV_NONE, 2286 #else 2287 (char_u *)NULL, PV_NONE, 2288 #endif 2289 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT}, 2290 {"regexpengine", "re", P_NUM|P_VI_DEF, 2291 (char_u *)&p_re, PV_NONE, 2292 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2293 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN, 2294 (char_u *)VAR_WIN, PV_RNU, 2295 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2296 {"remap", NULL, P_BOOL|P_VI_DEF, 2297 (char_u *)&p_remap, PV_NONE, 2298 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2299 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF, 2300 #ifdef FEAT_RENDER_OPTIONS 2301 (char_u *)&p_rop, PV_NONE, 2302 {(char_u *)"", (char_u *)0L} 2303 #else 2304 (char_u *)NULL, PV_NONE, 2305 {(char_u *)NULL, (char_u *)0L} 2306 #endif 2307 SCRIPTID_INIT}, 2308 {"report", NULL, P_NUM|P_VI_DEF, 2309 (char_u *)&p_report, PV_NONE, 2310 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT}, 2311 {"restorescreen", "rs", P_BOOL|P_VI_DEF, 2312 #ifdef WIN3264 2313 (char_u *)&p_rs, PV_NONE, 2314 #else 2315 (char_u *)NULL, PV_NONE, 2316 #endif 2317 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2318 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM, 2319 #ifdef FEAT_RIGHTLEFT 2320 (char_u *)&p_ri, PV_NONE, 2321 #else 2322 (char_u *)NULL, PV_NONE, 2323 #endif 2324 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2325 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN, 2326 #ifdef FEAT_RIGHTLEFT 2327 (char_u *)VAR_WIN, PV_RL, 2328 #else 2329 (char_u *)NULL, PV_NONE, 2330 #endif 2331 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2332 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, 2333 #ifdef FEAT_RIGHTLEFT 2334 (char_u *)VAR_WIN, PV_RLC, 2335 {(char_u *)"search", (char_u *)NULL} 2336 #else 2337 (char_u *)NULL, PV_NONE, 2338 {(char_u *)NULL, (char_u *)0L} 2339 #endif 2340 SCRIPTID_INIT}, 2341 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2342 #if defined(DYNAMIC_RUBY) 2343 (char_u *)&p_rubydll, PV_NONE, 2344 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L} 2345 #else 2346 (char_u *)NULL, PV_NONE, 2347 {(char_u *)NULL, (char_u *)0L} 2348 #endif 2349 SCRIPTID_INIT}, 2350 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT, 2351 #ifdef FEAT_CMDL_INFO 2352 (char_u *)&p_ru, PV_NONE, 2353 #else 2354 (char_u *)NULL, PV_NONE, 2355 #endif 2356 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2357 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, 2358 #ifdef FEAT_STL_OPT 2359 (char_u *)&p_ruf, PV_NONE, 2360 #else 2361 (char_u *)NULL, PV_NONE, 2362 #endif 2363 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2364 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP 2365 |P_SECURE, 2366 (char_u *)&p_rtp, PV_NONE, 2367 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L} 2368 SCRIPTID_INIT}, 2369 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF, 2370 (char_u *)VAR_WIN, PV_SCROLL, 2371 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2372 {"scrollbind", "scb", P_BOOL|P_VI_DEF, 2373 #ifdef FEAT_SCROLLBIND 2374 (char_u *)VAR_WIN, PV_SCBIND, 2375 #else 2376 (char_u *)NULL, PV_NONE, 2377 #endif 2378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2379 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM, 2380 (char_u *)&p_sj, PV_NONE, 2381 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2382 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL, 2383 (char_u *)&p_so, PV_NONE, 2384 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2385 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2386 #ifdef FEAT_SCROLLBIND 2387 (char_u *)&p_sbo, PV_NONE, 2388 {(char_u *)"ver,jump", (char_u *)0L} 2389 #else 2390 (char_u *)NULL, PV_NONE, 2391 {(char_u *)0L, (char_u *)0L} 2392 #endif 2393 SCRIPTID_INIT}, 2394 {"sections", "sect", P_STRING|P_VI_DEF, 2395 (char_u *)&p_sections, PV_NONE, 2396 {(char_u *)"SHNHH HUnhsh", (char_u *)0L} 2397 SCRIPTID_INIT}, 2398 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE, 2399 (char_u *)&p_secure, PV_NONE, 2400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2401 {"selection", "sel", P_STRING|P_VI_DEF, 2402 (char_u *)&p_sel, PV_NONE, 2403 {(char_u *)"inclusive", (char_u *)0L} 2404 SCRIPTID_INIT}, 2405 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2406 (char_u *)&p_slm, PV_NONE, 2407 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2408 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2409 #ifdef FEAT_SESSION 2410 (char_u *)&p_ssop, PV_NONE, 2411 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize", 2412 (char_u *)0L} 2413 #else 2414 (char_u *)NULL, PV_NONE, 2415 {(char_u *)0L, (char_u *)0L} 2416 #endif 2417 SCRIPTID_INIT}, 2418 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2419 (char_u *)&p_sh, PV_NONE, 2420 { 2421 #ifdef VMS 2422 (char_u *)"-", 2423 #else 2424 # if defined(WIN3264) 2425 (char_u *)"", /* set in set_init_1() */ 2426 # else 2427 (char_u *)"sh", 2428 # endif 2429 #endif /* VMS */ 2430 (char_u *)0L} SCRIPTID_INIT}, 2431 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE, 2432 (char_u *)&p_shcf, PV_NONE, 2433 { 2434 #if defined(MSWIN) 2435 (char_u *)"/c", 2436 #else 2437 (char_u *)"-c", 2438 #endif 2439 (char_u *)0L} SCRIPTID_INIT}, 2440 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE, 2441 #ifdef FEAT_QUICKFIX 2442 (char_u *)&p_sp, PV_NONE, 2443 { 2444 #if defined(UNIX) 2445 (char_u *)"| tee", 2446 #else 2447 (char_u *)">", 2448 #endif 2449 (char_u *)0L} 2450 #else 2451 (char_u *)NULL, PV_NONE, 2452 {(char_u *)0L, (char_u *)0L} 2453 #endif 2454 SCRIPTID_INIT}, 2455 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE, 2456 (char_u *)&p_shq, PV_NONE, 2457 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2458 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE, 2459 (char_u *)&p_srr, PV_NONE, 2460 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT}, 2461 {"shellslash", "ssl", P_BOOL|P_VI_DEF, 2462 #ifdef BACKSLASH_IN_FILENAME 2463 (char_u *)&p_ssl, PV_NONE, 2464 #else 2465 (char_u *)NULL, PV_NONE, 2466 #endif 2467 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2468 {"shelltemp", "stmp", P_BOOL, 2469 (char_u *)&p_stmp, PV_NONE, 2470 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 2471 {"shelltype", "st", P_NUM|P_VI_DEF, 2472 #ifdef AMIGA 2473 (char_u *)&p_st, PV_NONE, 2474 #else 2475 (char_u *)NULL, PV_NONE, 2476 #endif 2477 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2478 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE, 2479 (char_u *)&p_sxq, PV_NONE, 2480 { 2481 #if defined(UNIX) && defined(USE_SYSTEM) 2482 (char_u *)"\"", 2483 #else 2484 (char_u *)"", 2485 #endif 2486 (char_u *)0L} SCRIPTID_INIT}, 2487 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE, 2488 (char_u *)&p_sxe, PV_NONE, 2489 { 2490 #if defined(WIN3264) 2491 (char_u *)"\"&|<>()@^", 2492 #else 2493 (char_u *)"", 2494 #endif 2495 (char_u *)0L} SCRIPTID_INIT}, 2496 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM, 2497 (char_u *)&p_sr, PV_NONE, 2498 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2499 {"shiftwidth", "sw", P_NUM|P_VI_DEF, 2500 (char_u *)&p_sw, PV_SW, 2501 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT}, 2502 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST, 2503 (char_u *)&p_shm, PV_NONE, 2504 {(char_u *)"", (char_u *)"filnxtToO"} 2505 SCRIPTID_INIT}, 2506 {"shortname", "sn", P_BOOL|P_VI_DEF, 2507 (char_u *)&p_sn, PV_SN, 2508 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2509 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL, 2510 #ifdef FEAT_LINEBREAK 2511 (char_u *)&p_sbr, PV_NONE, 2512 #else 2513 (char_u *)NULL, PV_NONE, 2514 #endif 2515 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2516 {"showcmd", "sc", P_BOOL|P_VIM, 2517 #ifdef FEAT_CMDL_INFO 2518 (char_u *)&p_sc, PV_NONE, 2519 #else 2520 (char_u *)NULL, PV_NONE, 2521 #endif 2522 {(char_u *)FALSE, 2523 #ifdef UNIX 2524 (char_u *)FALSE 2525 #else 2526 (char_u *)TRUE 2527 #endif 2528 } SCRIPTID_INIT}, 2529 {"showfulltag", "sft", P_BOOL|P_VI_DEF, 2530 (char_u *)&p_sft, PV_NONE, 2531 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2532 {"showmatch", "sm", P_BOOL|P_VI_DEF, 2533 (char_u *)&p_sm, PV_NONE, 2534 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2535 {"showmode", "smd", P_BOOL|P_VIM, 2536 (char_u *)&p_smd, PV_NONE, 2537 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 2538 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL, 2539 (char_u *)&p_stal, PV_NONE, 2540 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 2541 {"sidescroll", "ss", P_NUM|P_VI_DEF, 2542 (char_u *)&p_ss, PV_NONE, 2543 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2544 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF, 2545 (char_u *)&p_siso, PV_NONE, 2546 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2547 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN, 2548 #ifdef FEAT_SIGNS 2549 (char_u *)VAR_WIN, PV_SCL, 2550 {(char_u *)"auto", (char_u *)0L} 2551 #else 2552 (char_u *)NULL, PV_NONE, 2553 {(char_u *)NULL, (char_u *)0L} 2554 #endif 2555 SCRIPTID_INIT}, 2556 {"slowopen", "slow", P_BOOL|P_VI_DEF, 2557 (char_u *)NULL, PV_NONE, 2558 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2559 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM, 2560 (char_u *)&p_scs, PV_NONE, 2561 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2562 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM, 2563 #ifdef FEAT_SMARTINDENT 2564 (char_u *)&p_si, PV_SI, 2565 #else 2566 (char_u *)NULL, PV_NONE, 2567 #endif 2568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2569 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM, 2570 (char_u *)&p_sta, PV_NONE, 2571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2572 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM, 2573 (char_u *)&p_sts, PV_STS, 2574 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2575 {"sourceany", NULL, P_BOOL|P_VI_DEF, 2576 (char_u *)NULL, PV_NONE, 2577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2578 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN, 2579 #ifdef FEAT_SPELL 2580 (char_u *)VAR_WIN, PV_SPELL, 2581 #else 2582 (char_u *)NULL, PV_NONE, 2583 #endif 2584 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2585 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF, 2586 #ifdef FEAT_SPELL 2587 (char_u *)&p_spc, PV_SPC, 2588 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L} 2589 #else 2590 (char_u *)NULL, PV_NONE, 2591 {(char_u *)0L, (char_u *)0L} 2592 #endif 2593 SCRIPTID_INIT}, 2594 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE 2595 |P_ONECOMMA, 2596 #ifdef FEAT_SPELL 2597 (char_u *)&p_spf, PV_SPF, 2598 {(char_u *)"", (char_u *)0L} 2599 #else 2600 (char_u *)NULL, PV_NONE, 2601 {(char_u *)0L, (char_u *)0L} 2602 #endif 2603 SCRIPTID_INIT}, 2604 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA 2605 |P_RBUF|P_EXPAND, 2606 #ifdef FEAT_SPELL 2607 (char_u *)&p_spl, PV_SPL, 2608 {(char_u *)"en", (char_u *)0L} 2609 #else 2610 (char_u *)NULL, PV_NONE, 2611 {(char_u *)0L, (char_u *)0L} 2612 #endif 2613 SCRIPTID_INIT}, 2614 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA, 2615 #ifdef FEAT_SPELL 2616 (char_u *)&p_sps, PV_NONE, 2617 {(char_u *)"best", (char_u *)0L} 2618 #else 2619 (char_u *)NULL, PV_NONE, 2620 {(char_u *)0L, (char_u *)0L} 2621 #endif 2622 SCRIPTID_INIT}, 2623 {"splitbelow", "sb", P_BOOL|P_VI_DEF, 2624 (char_u *)&p_sb, PV_NONE, 2625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2626 {"splitright", "spr", P_BOOL|P_VI_DEF, 2627 (char_u *)&p_spr, PV_NONE, 2628 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2629 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM, 2630 (char_u *)&p_sol, PV_NONE, 2631 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2632 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT, 2633 #ifdef FEAT_STL_OPT 2634 (char_u *)&p_stl, PV_STL, 2635 #else 2636 (char_u *)NULL, PV_NONE, 2637 #endif 2638 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2639 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2640 (char_u *)&p_su, PV_NONE, 2641 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj", 2642 (char_u *)0L} SCRIPTID_INIT}, 2643 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP, 2644 #ifdef FEAT_SEARCHPATH 2645 (char_u *)&p_sua, PV_SUA, 2646 {(char_u *)"", (char_u *)0L} 2647 #else 2648 (char_u *)NULL, PV_NONE, 2649 {(char_u *)0L, (char_u *)0L} 2650 #endif 2651 SCRIPTID_INIT}, 2652 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT, 2653 (char_u *)&p_swf, PV_SWF, 2654 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2655 {"swapsync", "sws", P_STRING|P_VI_DEF, 2656 (char_u *)&p_sws, PV_NONE, 2657 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT}, 2658 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2659 (char_u *)&p_swb, PV_NONE, 2660 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2661 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF, 2662 #ifdef FEAT_SYN_HL 2663 (char_u *)&p_smc, PV_SMC, 2664 {(char_u *)3000L, (char_u *)0L} 2665 #else 2666 (char_u *)NULL, PV_NONE, 2667 {(char_u *)0L, (char_u *)0L} 2668 #endif 2669 SCRIPTID_INIT}, 2670 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, 2671 #ifdef FEAT_SYN_HL 2672 (char_u *)&p_syn, PV_SYN, 2673 {(char_u *)"", (char_u *)0L} 2674 #else 2675 (char_u *)NULL, PV_NONE, 2676 {(char_u *)0L, (char_u *)0L} 2677 #endif 2678 SCRIPTID_INIT}, 2679 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL, 2680 #ifdef FEAT_STL_OPT 2681 (char_u *)&p_tal, PV_NONE, 2682 #else 2683 (char_u *)NULL, PV_NONE, 2684 #endif 2685 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2686 {"tabpagemax", "tpm", P_NUM|P_VI_DEF, 2687 (char_u *)&p_tpm, PV_NONE, 2688 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT}, 2689 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF, 2690 (char_u *)&p_ts, PV_TS, 2691 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT}, 2692 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF, 2693 (char_u *)&p_tbs, PV_NONE, 2694 #ifdef VMS /* binary searching doesn't appear to work on VMS */ 2695 {(char_u *)0L, (char_u *)0L} 2696 #else 2697 {(char_u *)TRUE, (char_u *)0L} 2698 #endif 2699 SCRIPTID_INIT}, 2700 {"tagcase", "tc", P_STRING|P_VIM, 2701 (char_u *)&p_tc, PV_TC, 2702 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT}, 2703 {"taglength", "tl", P_NUM|P_VI_DEF, 2704 (char_u *)&p_tl, PV_NONE, 2705 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2706 {"tagrelative", "tr", P_BOOL|P_VIM, 2707 (char_u *)&p_tr, PV_NONE, 2708 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT}, 2709 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, 2710 (char_u *)&p_tags, PV_TAGS, 2711 { 2712 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME) 2713 (char_u *)"./tags,./TAGS,tags,TAGS", 2714 #else 2715 (char_u *)"./tags,tags", 2716 #endif 2717 (char_u *)0L} SCRIPTID_INIT}, 2718 {"tagstack", "tgst", P_BOOL|P_VI_DEF, 2719 (char_u *)&p_tgst, PV_NONE, 2720 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2721 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2722 #if defined(DYNAMIC_TCL) 2723 (char_u *)&p_tcldll, PV_NONE, 2724 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L} 2725 #else 2726 (char_u *)NULL, PV_NONE, 2727 {(char_u *)0L, (char_u *)0L} 2728 #endif 2729 SCRIPTID_INIT}, 2730 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, 2731 (char_u *)&T_NAME, PV_NONE, 2732 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2733 {"termbidi", "tbidi", P_BOOL|P_VI_DEF, 2734 #ifdef FEAT_ARABIC 2735 (char_u *)&p_tbidi, PV_NONE, 2736 #else 2737 (char_u *)NULL, PV_NONE, 2738 #endif 2739 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2740 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR, 2741 #ifdef FEAT_MBYTE 2742 (char_u *)&p_tenc, PV_NONE, 2743 {(char_u *)"", (char_u *)0L} 2744 #else 2745 (char_u *)NULL, PV_NONE, 2746 {(char_u *)0L, (char_u *)0L} 2747 #endif 2748 SCRIPTID_INIT}, 2749 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR, 2750 #ifdef FEAT_TERMGUICOLORS 2751 (char_u *)&p_tgc, PV_NONE, 2752 {(char_u *)FALSE, (char_u *)FALSE} 2753 #else 2754 (char_u*)NULL, PV_NONE, 2755 {(char_u *)FALSE, (char_u *)FALSE} 2756 #endif 2757 SCRIPTID_INIT}, 2758 {"termkey", "tk", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, 2759 #ifdef FEAT_TERMINAL 2760 (char_u *)VAR_WIN, PV_TK, 2761 {(char_u *)"", (char_u *)NULL} 2762 #else 2763 (char_u *)NULL, PV_NONE, 2764 {(char_u *)NULL, (char_u *)0L} 2765 #endif 2766 SCRIPTID_INIT}, 2767 {"termsize", "tms", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF, 2768 #ifdef FEAT_TERMINAL 2769 (char_u *)VAR_WIN, PV_TMS, 2770 {(char_u *)"", (char_u *)NULL} 2771 #else 2772 (char_u *)NULL, PV_NONE, 2773 {(char_u *)NULL, (char_u *)0L} 2774 #endif 2775 SCRIPTID_INIT}, 2776 {"terse", NULL, P_BOOL|P_VI_DEF, 2777 (char_u *)&p_terse, PV_NONE, 2778 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2779 {"textauto", "ta", P_BOOL|P_VIM, 2780 (char_u *)&p_ta, PV_NONE, 2781 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE} 2782 SCRIPTID_INIT}, 2783 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC, 2784 (char_u *)&p_tx, PV_TX, 2785 { 2786 #ifdef USE_CRNL 2787 (char_u *)TRUE, 2788 #else 2789 (char_u *)FALSE, 2790 #endif 2791 (char_u *)0L} SCRIPTID_INIT}, 2792 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF, 2793 (char_u *)&p_tw, PV_TW, 2794 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2795 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME, 2796 #ifdef FEAT_INS_EXPAND 2797 (char_u *)&p_tsr, PV_TSR, 2798 #else 2799 (char_u *)NULL, PV_NONE, 2800 #endif 2801 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2802 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM, 2803 (char_u *)&p_to, PV_NONE, 2804 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2805 {"timeout", "to", P_BOOL|P_VI_DEF, 2806 (char_u *)&p_timeout, PV_NONE, 2807 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2808 {"timeoutlen", "tm", P_NUM|P_VI_DEF, 2809 (char_u *)&p_tm, PV_NONE, 2810 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT}, 2811 {"title", NULL, P_BOOL|P_VI_DEF, 2812 #ifdef FEAT_TITLE 2813 (char_u *)&p_title, PV_NONE, 2814 #else 2815 (char_u *)NULL, PV_NONE, 2816 #endif 2817 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2818 {"titlelen", NULL, P_NUM|P_VI_DEF, 2819 #ifdef FEAT_TITLE 2820 (char_u *)&p_titlelen, PV_NONE, 2821 #else 2822 (char_u *)NULL, PV_NONE, 2823 #endif 2824 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT}, 2825 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC, 2826 #ifdef FEAT_TITLE 2827 (char_u *)&p_titleold, PV_NONE, 2828 {(char_u *)N_("Thanks for flying Vim"), 2829 (char_u *)0L} 2830 #else 2831 (char_u *)NULL, PV_NONE, 2832 {(char_u *)0L, (char_u *)0L} 2833 #endif 2834 SCRIPTID_INIT}, 2835 {"titlestring", NULL, P_STRING|P_VI_DEF, 2836 #ifdef FEAT_TITLE 2837 (char_u *)&p_titlestring, PV_NONE, 2838 #else 2839 (char_u *)NULL, PV_NONE, 2840 #endif 2841 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2842 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP, 2843 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 2844 (char_u *)&p_toolbar, PV_NONE, 2845 {(char_u *)"icons,tooltips", (char_u *)0L} 2846 #else 2847 (char_u *)NULL, PV_NONE, 2848 {(char_u *)0L, (char_u *)0L} 2849 #endif 2850 SCRIPTID_INIT}, 2851 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF, 2852 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) 2853 (char_u *)&p_tbis, PV_NONE, 2854 {(char_u *)"small", (char_u *)0L} 2855 #else 2856 (char_u *)NULL, PV_NONE, 2857 {(char_u *)0L, (char_u *)0L} 2858 #endif 2859 SCRIPTID_INIT}, 2860 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM, 2861 (char_u *)&p_ttimeout, PV_NONE, 2862 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2863 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF, 2864 (char_u *)&p_ttm, PV_NONE, 2865 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT}, 2866 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF, 2867 (char_u *)&p_tbi, PV_NONE, 2868 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2869 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF, 2870 (char_u *)&p_tf, PV_NONE, 2871 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2872 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF, 2873 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) 2874 (char_u *)&p_ttym, PV_NONE, 2875 #else 2876 (char_u *)NULL, PV_NONE, 2877 #endif 2878 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2879 {"ttyscroll", "tsl", P_NUM|P_VI_DEF, 2880 (char_u *)&p_ttyscroll, PV_NONE, 2881 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT}, 2882 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL, 2883 (char_u *)&T_NAME, PV_NONE, 2884 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2885 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE 2886 |P_VI_DEF, 2887 #ifdef FEAT_PERSISTENT_UNDO 2888 (char_u *)&p_udir, PV_NONE, 2889 {(char_u *)".", (char_u *)0L} 2890 #else 2891 (char_u *)NULL, PV_NONE, 2892 {(char_u *)0L, (char_u *)0L} 2893 #endif 2894 SCRIPTID_INIT}, 2895 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM, 2896 #ifdef FEAT_PERSISTENT_UNDO 2897 (char_u *)&p_udf, PV_UDF, 2898 #else 2899 (char_u *)NULL, PV_NONE, 2900 #endif 2901 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2902 {"undolevels", "ul", P_NUM|P_VI_DEF, 2903 (char_u *)&p_ul, PV_UL, 2904 { 2905 #if defined(UNIX) || defined(WIN3264) || defined(VMS) 2906 (char_u *)1000L, 2907 #else 2908 (char_u *)100L, 2909 #endif 2910 (char_u *)0L} SCRIPTID_INIT}, 2911 {"undoreload", "ur", P_NUM|P_VI_DEF, 2912 (char_u *)&p_ur, PV_NONE, 2913 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT}, 2914 {"updatecount", "uc", P_NUM|P_VI_DEF, 2915 (char_u *)&p_uc, PV_NONE, 2916 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT}, 2917 {"updatetime", "ut", P_NUM|P_VI_DEF, 2918 (char_u *)&p_ut, PV_NONE, 2919 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT}, 2920 {"verbose", "vbs", P_NUM|P_VI_DEF, 2921 (char_u *)&p_verbose, PV_NONE, 2922 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2923 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2924 (char_u *)&p_vfile, PV_NONE, 2925 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 2926 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 2927 #ifdef FEAT_SESSION 2928 (char_u *)&p_vdir, PV_NONE, 2929 {(char_u *)DFLT_VDIR, (char_u *)0L} 2930 #else 2931 (char_u *)NULL, PV_NONE, 2932 {(char_u *)0L, (char_u *)0L} 2933 #endif 2934 SCRIPTID_INIT}, 2935 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 2936 #ifdef FEAT_SESSION 2937 (char_u *)&p_vop, PV_NONE, 2938 {(char_u *)"folds,options,cursor,curdir", 2939 (char_u *)0L} 2940 #else 2941 (char_u *)NULL, PV_NONE, 2942 {(char_u *)0L, (char_u *)0L} 2943 #endif 2944 SCRIPTID_INIT}, 2945 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE, 2946 #ifdef FEAT_VIMINFO 2947 (char_u *)&p_viminfo, PV_NONE, 2948 #if defined(MSWIN) 2949 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"} 2950 #else 2951 # ifdef AMIGA 2952 {(char_u *)"", 2953 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"} 2954 # else 2955 {(char_u *)"", (char_u *)"'100,<50,s10,h"} 2956 # endif 2957 #endif 2958 #else 2959 (char_u *)NULL, PV_NONE, 2960 {(char_u *)0L, (char_u *)0L} 2961 #endif 2962 SCRIPTID_INIT}, 2963 {"viminfofile", "vif", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE|P_VI_DEF, 2964 #ifdef FEAT_VIMINFO 2965 (char_u *)&p_viminfofile, PV_NONE, 2966 {(char_u *)"", (char_u *)0L} 2967 #else 2968 (char_u *)NULL, PV_NONE, 2969 {(char_u *)0L, (char_u *)0L} 2970 #endif 2971 SCRIPTID_INIT}, 2972 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF 2973 |P_VIM|P_CURSWANT, 2974 #ifdef FEAT_VIRTUALEDIT 2975 (char_u *)&p_ve, PV_NONE, 2976 {(char_u *)"", (char_u *)""} 2977 #else 2978 (char_u *)NULL, PV_NONE, 2979 {(char_u *)0L, (char_u *)0L} 2980 #endif 2981 SCRIPTID_INIT}, 2982 {"visualbell", "vb", P_BOOL|P_VI_DEF, 2983 (char_u *)&p_vb, PV_NONE, 2984 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2985 {"w300", NULL, P_NUM|P_VI_DEF, 2986 (char_u *)NULL, PV_NONE, 2987 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2988 {"w1200", NULL, P_NUM|P_VI_DEF, 2989 (char_u *)NULL, PV_NONE, 2990 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2991 {"w9600", NULL, P_NUM|P_VI_DEF, 2992 (char_u *)NULL, PV_NONE, 2993 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 2994 {"warn", NULL, P_BOOL|P_VI_DEF, 2995 (char_u *)&p_warn, PV_NONE, 2996 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 2997 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR, 2998 (char_u *)&p_wiv, PV_NONE, 2999 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 3000 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST, 3001 (char_u *)&p_ww, PV_NONE, 3002 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT}, 3003 {"wildchar", "wc", P_NUM|P_VIM, 3004 (char_u *)&p_wc, PV_NONE, 3005 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB} 3006 SCRIPTID_INIT}, 3007 {"wildcharm", "wcm", P_NUM|P_VI_DEF, 3008 (char_u *)&p_wcm, PV_NONE, 3009 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 3010 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 3011 #ifdef FEAT_WILDIGN 3012 (char_u *)&p_wig, PV_NONE, 3013 #else 3014 (char_u *)NULL, PV_NONE, 3015 #endif 3016 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 3017 {"wildignorecase", "wic", P_BOOL|P_VI_DEF, 3018 (char_u *)&p_wic, PV_NONE, 3019 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 3020 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF, 3021 #ifdef FEAT_WILDMENU 3022 (char_u *)&p_wmnu, PV_NONE, 3023 #else 3024 (char_u *)NULL, PV_NONE, 3025 #endif 3026 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 3027 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP, 3028 (char_u *)&p_wim, PV_NONE, 3029 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT}, 3030 {"wildoptions", "wop", P_STRING|P_VI_DEF, 3031 #ifdef FEAT_CMDL_COMPL 3032 (char_u *)&p_wop, PV_NONE, 3033 {(char_u *)"", (char_u *)0L} 3034 #else 3035 (char_u *)NULL, PV_NONE, 3036 {(char_u *)NULL, (char_u *)0L} 3037 #endif 3038 SCRIPTID_INIT}, 3039 {"winaltkeys", "wak", P_STRING|P_VI_DEF, 3040 #ifdef FEAT_WAK 3041 (char_u *)&p_wak, PV_NONE, 3042 {(char_u *)"menu", (char_u *)0L} 3043 #else 3044 (char_u *)NULL, PV_NONE, 3045 {(char_u *)NULL, (char_u *)0L} 3046 #endif 3047 SCRIPTID_INIT}, 3048 {"window", "wi", P_NUM|P_VI_DEF, 3049 (char_u *)&p_window, PV_NONE, 3050 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 3051 {"winheight", "wh", P_NUM|P_VI_DEF, 3052 (char_u *)&p_wh, PV_NONE, 3053 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 3054 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT, 3055 (char_u *)VAR_WIN, PV_WFH, 3056 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 3057 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT, 3058 (char_u *)VAR_WIN, PV_WFW, 3059 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 3060 {"winminheight", "wmh", P_NUM|P_VI_DEF, 3061 (char_u *)&p_wmh, PV_NONE, 3062 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 3063 {"winminwidth", "wmw", P_NUM|P_VI_DEF, 3064 (char_u *)&p_wmw, PV_NONE, 3065 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT}, 3066 {"winptydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, 3067 #if defined(WIN3264) && defined(FEAT_TERMINAL) 3068 (char_u *)&p_winptydll, PV_NONE, { 3069 # ifdef _WIN64 3070 (char_u *)"winpty64.dll", 3071 # else 3072 (char_u *)"winpty32.dll", 3073 # endif 3074 (char_u *)0L} 3075 #else 3076 (char_u *)NULL, PV_NONE, 3077 {(char_u *)0L, (char_u *)0L} 3078 #endif 3079 SCRIPTID_INIT}, 3080 {"winwidth", "wiw", P_NUM|P_VI_DEF, 3081 (char_u *)&p_wiw, PV_NONE, 3082 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT}, 3083 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN, 3084 (char_u *)VAR_WIN, PV_WRAP, 3085 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 3086 {"wrapmargin", "wm", P_NUM|P_VI_DEF, 3087 (char_u *)&p_wm, PV_WM, 3088 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 3089 {"wrapscan", "ws", P_BOOL|P_VI_DEF, 3090 (char_u *)&p_ws, PV_NONE, 3091 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 3092 {"write", NULL, P_BOOL|P_VI_DEF, 3093 (char_u *)&p_write, PV_NONE, 3094 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT}, 3095 {"writeany", "wa", P_BOOL|P_VI_DEF, 3096 (char_u *)&p_wa, PV_NONE, 3097 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 3098 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM, 3099 (char_u *)&p_wb, PV_NONE, 3100 { 3101 #ifdef FEAT_WRITEBACKUP 3102 (char_u *)TRUE, 3103 #else 3104 (char_u *)FALSE, 3105 #endif 3106 (char_u *)0L} SCRIPTID_INIT}, 3107 {"writedelay", "wd", P_NUM|P_VI_DEF, 3108 (char_u *)&p_wd, PV_NONE, 3109 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, 3110 3111 /* terminal output codes */ 3112 #define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \ 3113 (char_u *)&vvv, PV_NONE, \ 3114 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, 3115 3116 p_term("t_AB", T_CAB) 3117 p_term("t_AF", T_CAF) 3118 p_term("t_AL", T_CAL) 3119 p_term("t_al", T_AL) 3120 p_term("t_bc", T_BC) 3121 p_term("t_BE", T_BE) 3122 p_term("t_BD", T_BD) 3123 p_term("t_cd", T_CD) 3124 p_term("t_ce", T_CE) 3125 p_term("t_cl", T_CL) 3126 p_term("t_cm", T_CM) 3127 p_term("t_Ce", T_UCE) 3128 p_term("t_Co", T_CCO) 3129 p_term("t_CS", T_CCS) 3130 p_term("t_Cs", T_UCS) 3131 p_term("t_cs", T_CS) 3132 p_term("t_CV", T_CSV) 3133 p_term("t_da", T_DA) 3134 p_term("t_db", T_DB) 3135 p_term("t_DL", T_CDL) 3136 p_term("t_dl", T_DL) 3137 p_term("t_EC", T_CEC) 3138 p_term("t_EI", T_CEI) 3139 p_term("t_fs", T_FS) 3140 p_term("t_GP", T_CGP) 3141 p_term("t_IE", T_CIE) 3142 p_term("t_IS", T_CIS) 3143 p_term("t_ke", T_KE) 3144 p_term("t_ks", T_KS) 3145 p_term("t_le", T_LE) 3146 p_term("t_mb", T_MB) 3147 p_term("t_md", T_MD) 3148 p_term("t_me", T_ME) 3149 p_term("t_mr", T_MR) 3150 p_term("t_ms", T_MS) 3151 p_term("t_nd", T_ND) 3152 p_term("t_op", T_OP) 3153 p_term("t_RF", T_RFG) 3154 p_term("t_RB", T_RBG) 3155 p_term("t_RC", T_CRC) 3156 p_term("t_RI", T_CRI) 3157 p_term("t_RS", T_CRS) 3158 p_term("t_RV", T_CRV) 3159 p_term("t_Sb", T_CSB) 3160 p_term("t_SC", T_CSC) 3161 p_term("t_se", T_SE) 3162 p_term("t_Sf", T_CSF) 3163 p_term("t_SH", T_CSH) 3164 p_term("t_SI", T_CSI) 3165 p_term("t_so", T_SO) 3166 p_term("t_SR", T_CSR) 3167 p_term("t_sr", T_SR) 3168 p_term("t_Te", T_STE) 3169 p_term("t_te", T_TE) 3170 p_term("t_ti", T_TI) 3171 p_term("t_Ts", T_STS) 3172 p_term("t_ts", T_TS) 3173 p_term("t_u7", T_U7) 3174 p_term("t_ue", T_UE) 3175 p_term("t_us", T_US) 3176 p_term("t_ut", T_UT) 3177 p_term("t_vb", T_VB) 3178 p_term("t_ve", T_VE) 3179 p_term("t_vi", T_VI) 3180 p_term("t_VS", T_CVS) 3181 p_term("t_vs", T_VS) 3182 p_term("t_WP", T_CWP) 3183 p_term("t_WS", T_CWS) 3184 p_term("t_xn", T_XN) 3185 p_term("t_xs", T_XS) 3186 p_term("t_ZH", T_CZH) 3187 p_term("t_ZR", T_CZR) 3188 p_term("t_8f", T_8F) 3189 p_term("t_8b", T_8B) 3190 3191 /* terminal key codes are not in here */ 3192 3193 /* end marker */ 3194 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT} 3195 }; 3196 3197 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption)) 3198 3199 #ifdef FEAT_MBYTE 3200 static char *(p_ambw_values[]) = {"single", "double", NULL}; 3201 #endif 3202 static char *(p_bg_values[]) = {"light", "dark", NULL}; 3203 static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL}; 3204 static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL}; 3205 #ifdef FEAT_CRYPT 3206 static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL}; 3207 #endif 3208 #ifdef FEAT_CMDL_COMPL 3209 static char *(p_wop_values[]) = {"tagfile", NULL}; 3210 #endif 3211 #ifdef FEAT_WAK 3212 static char *(p_wak_values[]) = {"yes", "menu", "no", NULL}; 3213 #endif 3214 static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL}; 3215 static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL}; 3216 static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL}; 3217 static char *(p_km_values[]) = {"startsel", "stopsel", NULL}; 3218 #ifdef FEAT_BROWSE 3219 static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL}; 3220 #endif 3221 #ifdef FEAT_SCROLLBIND 3222 static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL}; 3223 #endif 3224 static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL}; 3225 static char *(p_ead_values[]) = {"both", "ver", "hor", NULL}; 3226 #ifdef FEAT_AUTOCMD 3227 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL}; 3228 #else 3229 static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL}; 3230 #endif 3231 static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL}; 3232 static char *(p_bs_values[]) = {"indent", "eol", "start", NULL}; 3233 #ifdef FEAT_FOLDING 3234 static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax", 3235 # ifdef FEAT_DIFF 3236 "diff", 3237 # endif 3238 NULL}; 3239 static char *(p_fcl_values[]) = {"all", NULL}; 3240 #endif 3241 #ifdef FEAT_INS_EXPAND 3242 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL}; 3243 #endif 3244 #ifdef FEAT_SIGNS 3245 static char *(p_scl_values[]) = {"yes", "no", "auto", NULL}; 3246 #endif 3247 3248 static void set_option_default(int, int opt_flags, int compatible); 3249 static void set_options_default(int opt_flags); 3250 static char_u *term_bg_default(void); 3251 static void did_set_option(int opt_idx, int opt_flags, int new_value); 3252 static char_u *illegal_char(char_u *, int); 3253 #ifdef FEAT_CMDWIN 3254 static char_u *check_cedit(void); 3255 #endif 3256 #ifdef FEAT_TITLE 3257 static void did_set_title(int icon); 3258 #endif 3259 static char_u *option_expand(int opt_idx, char_u *val); 3260 static void didset_options(void); 3261 static void didset_options2(void); 3262 static void check_string_option(char_u **pp); 3263 #if defined(FEAT_EVAL) || defined(PROTO) 3264 static long_u *insecure_flag(int opt_idx, int opt_flags); 3265 #else 3266 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags) 3267 #endif 3268 static void set_string_option_global(int opt_idx, char_u **varp); 3269 static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags); 3270 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); 3271 static char_u *set_chars_option(char_u **varp); 3272 #ifdef FEAT_SYN_HL 3273 static int int_cmp(const void *a, const void *b); 3274 #endif 3275 #ifdef FEAT_CLIPBOARD 3276 static char_u *check_clipboard_option(void); 3277 #endif 3278 #ifdef FEAT_SPELL 3279 static char_u *did_set_spell_option(int is_spellfile); 3280 static char_u *compile_cap_prog(synblock_T *synblock); 3281 #endif 3282 #ifdef FEAT_EVAL 3283 static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id); 3284 #endif 3285 static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags); 3286 static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags); 3287 static void check_redraw(long_u flags); 3288 static int findoption(char_u *); 3289 static int find_key_option(char_u *); 3290 static void showoptions(int all, int opt_flags); 3291 static int optval_default(struct vimoption *, char_u *varp); 3292 static void showoneopt(struct vimoption *, int opt_flags); 3293 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand); 3294 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep); 3295 static int put_setbool(FILE *fd, char *cmd, char *name, int value); 3296 static int istermoption(struct vimoption *); 3297 static char_u *get_varp_scope(struct vimoption *p, int opt_flags); 3298 static char_u *get_varp(struct vimoption *); 3299 static void option_value2string(struct vimoption *, int opt_flags); 3300 static void check_winopt(winopt_T *wop); 3301 static int wc_use_keyname(char_u *varp, long *wcp); 3302 #ifdef FEAT_LANGMAP 3303 static void langmap_init(void); 3304 static void langmap_set(void); 3305 #endif 3306 static void paste_option_changed(void); 3307 static void compatible_set(void); 3308 #ifdef FEAT_LINEBREAK 3309 static void fill_breakat_flags(void); 3310 #endif 3311 static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list); 3312 static int check_opt_strings(char_u *val, char **values, int); 3313 static int check_opt_wim(void); 3314 #ifdef FEAT_LINEBREAK 3315 static int briopt_check(win_T *wp); 3316 #endif 3317 3318 /* 3319 * Initialize the options, first part. 3320 * 3321 * Called only once from main(), just after creating the first buffer. 3322 */ 3323 void 3324 set_init_1(void) 3325 { 3326 char_u *p; 3327 int opt_idx; 3328 long_u n; 3329 3330 #ifdef FEAT_LANGMAP 3331 langmap_init(); 3332 #endif 3333 3334 /* Be Vi compatible by default */ 3335 p_cp = TRUE; 3336 3337 /* Use POSIX compatibility when $VIM_POSIX is set. */ 3338 if (mch_getenv((char_u *)"VIM_POSIX") != NULL) 3339 { 3340 set_string_default("cpo", (char_u *)CPO_ALL); 3341 set_string_default("shm", (char_u *)"A"); 3342 } 3343 3344 /* 3345 * Find default value for 'shell' option. 3346 * Don't use it if it is empty. 3347 */ 3348 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL) 3349 #if defined(MSWIN) 3350 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL) 3351 # ifdef WIN3264 3352 || ((p = (char_u *)default_shell()) != NULL && *p != NUL) 3353 # endif 3354 #endif 3355 ) 3356 set_string_default("sh", p); 3357 3358 #ifdef FEAT_WILDIGN 3359 /* 3360 * Set the default for 'backupskip' to include environment variables for 3361 * temp files. 3362 */ 3363 { 3364 # ifdef UNIX 3365 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"}; 3366 # else 3367 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"}; 3368 # endif 3369 int len; 3370 garray_T ga; 3371 int mustfree; 3372 3373 ga_init2(&ga, 1, 100); 3374 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n) 3375 { 3376 mustfree = FALSE; 3377 # ifdef UNIX 3378 if (*names[n] == NUL) 3379 p = (char_u *)"/tmp"; 3380 else 3381 # endif 3382 p = vim_getenv((char_u *)names[n], &mustfree); 3383 if (p != NULL && *p != NUL) 3384 { 3385 /* First time count the NUL, otherwise count the ','. */ 3386 len = (int)STRLEN(p) + 3; 3387 if (ga_grow(&ga, len) == OK) 3388 { 3389 if (ga.ga_len > 0) 3390 STRCAT(ga.ga_data, ","); 3391 STRCAT(ga.ga_data, p); 3392 add_pathsep(ga.ga_data); 3393 STRCAT(ga.ga_data, "*"); 3394 ga.ga_len += len; 3395 } 3396 } 3397 if (mustfree) 3398 vim_free(p); 3399 } 3400 if (ga.ga_data != NULL) 3401 { 3402 set_string_default("bsk", ga.ga_data); 3403 vim_free(ga.ga_data); 3404 } 3405 } 3406 #endif 3407 3408 /* 3409 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory 3410 */ 3411 opt_idx = findoption((char_u *)"maxmemtot"); 3412 if (opt_idx >= 0) 3413 { 3414 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) 3415 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L) 3416 #endif 3417 { 3418 #ifdef HAVE_AVAIL_MEM 3419 /* Use amount of memory available at this moment. */ 3420 n = (mch_avail_mem(FALSE) >> 1); 3421 #else 3422 # ifdef HAVE_TOTAL_MEM 3423 /* Use amount of memory available to Vim. */ 3424 n = (mch_total_mem(FALSE) >> 1); 3425 # else 3426 n = (0x7fffffff >> 11); 3427 # endif 3428 #endif 3429 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; 3430 opt_idx = findoption((char_u *)"maxmem"); 3431 if (opt_idx >= 0) 3432 { 3433 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM) 3434 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n 3435 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L) 3436 #endif 3437 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n; 3438 } 3439 } 3440 } 3441 3442 #ifdef FEAT_SEARCHPATH 3443 { 3444 char_u *cdpath; 3445 char_u *buf; 3446 int i; 3447 int j; 3448 int mustfree = FALSE; 3449 3450 /* Initialize the 'cdpath' option's default value. */ 3451 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree); 3452 if (cdpath != NULL) 3453 { 3454 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2)); 3455 if (buf != NULL) 3456 { 3457 buf[0] = ','; /* start with ",", current dir first */ 3458 j = 1; 3459 for (i = 0; cdpath[i] != NUL; ++i) 3460 { 3461 if (vim_ispathlistsep(cdpath[i])) 3462 buf[j++] = ','; 3463 else 3464 { 3465 if (cdpath[i] == ' ' || cdpath[i] == ',') 3466 buf[j++] = '\\'; 3467 buf[j++] = cdpath[i]; 3468 } 3469 } 3470 buf[j] = NUL; 3471 opt_idx = findoption((char_u *)"cdpath"); 3472 if (opt_idx >= 0) 3473 { 3474 options[opt_idx].def_val[VI_DEFAULT] = buf; 3475 options[opt_idx].flags |= P_DEF_ALLOCED; 3476 } 3477 else 3478 vim_free(buf); /* cannot happen */ 3479 } 3480 if (mustfree) 3481 vim_free(cdpath); 3482 } 3483 } 3484 #endif 3485 3486 #if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux)) 3487 /* Set print encoding on platforms that don't default to latin1 */ 3488 set_string_default("penc", 3489 # if defined(MSWIN) 3490 (char_u *)"cp1252" 3491 # else 3492 # ifdef VMS 3493 (char_u *)"dec-mcs" 3494 # else 3495 # ifdef EBCDIC 3496 (char_u *)"ebcdic-uk" 3497 # else 3498 # ifdef MAC 3499 (char_u *)"mac-roman" 3500 # else /* HPUX */ 3501 (char_u *)"hp-roman8" 3502 # endif 3503 # endif 3504 # endif 3505 # endif 3506 ); 3507 #endif 3508 3509 #ifdef FEAT_POSTSCRIPT 3510 /* 'printexpr' must be allocated to be able to evaluate it. */ 3511 set_string_default("pexpr", 3512 # if defined(MSWIN) 3513 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)" 3514 # else 3515 # ifdef VMS 3516 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)" 3517 3518 # else 3519 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error" 3520 # endif 3521 # endif 3522 ); 3523 #endif 3524 3525 /* 3526 * Set all the options (except the terminal options) to their default 3527 * value. Also set the global value for local options. 3528 */ 3529 set_options_default(0); 3530 3531 #ifdef FEAT_GUI 3532 if (found_reverse_arg) 3533 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); 3534 #endif 3535 3536 curbuf->b_p_initialized = TRUE; 3537 curbuf->b_p_ar = -1; /* no local 'autoread' value */ 3538 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL; 3539 check_buf_options(curbuf); 3540 check_win_options(curwin); 3541 check_options(); 3542 3543 /* Must be before option_expand(), because that one needs vim_isIDc() */ 3544 didset_options(); 3545 3546 #ifdef FEAT_SPELL 3547 /* Use the current chartab for the generic chartab. This is not in 3548 * didset_options() because it only depends on 'encoding'. */ 3549 init_spell_chartab(); 3550 #endif 3551 3552 /* 3553 * Expand environment variables and things like "~" for the defaults. 3554 * If option_expand() returns non-NULL the variable is expanded. This can 3555 * only happen for non-indirect options. 3556 * Also set the default to the expanded value, so ":set" does not list 3557 * them. 3558 * Don't set the P_ALLOCED flag, because we don't want to free the 3559 * default. 3560 */ 3561 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 3562 { 3563 if ((options[opt_idx].flags & P_GETTEXT) 3564 && options[opt_idx].var != NULL) 3565 p = (char_u *)_(*(char **)options[opt_idx].var); 3566 else 3567 p = option_expand(opt_idx, NULL); 3568 if (p != NULL && (p = vim_strsave(p)) != NULL) 3569 { 3570 *(char_u **)options[opt_idx].var = p; 3571 /* VIMEXP 3572 * Defaults for all expanded options are currently the same for Vi 3573 * and Vim. When this changes, add some code here! Also need to 3574 * split P_DEF_ALLOCED in two. 3575 */ 3576 if (options[opt_idx].flags & P_DEF_ALLOCED) 3577 vim_free(options[opt_idx].def_val[VI_DEFAULT]); 3578 options[opt_idx].def_val[VI_DEFAULT] = p; 3579 options[opt_idx].flags |= P_DEF_ALLOCED; 3580 } 3581 } 3582 3583 save_file_ff(curbuf); /* Buffer is unchanged */ 3584 3585 #if defined(FEAT_ARABIC) 3586 /* Detect use of mlterm. 3587 * Mlterm is a terminal emulator akin to xterm that has some special 3588 * abilities (bidi namely). 3589 * NOTE: mlterm's author is being asked to 'set' a variable 3590 * instead of an environment variable due to inheritance. 3591 */ 3592 if (mch_getenv((char_u *)"MLTERM") != NULL) 3593 set_option_value((char_u *)"tbidi", 1L, NULL, 0); 3594 #endif 3595 3596 didset_options2(); 3597 3598 #ifdef FEAT_MBYTE 3599 # if defined(WIN3264) && defined(FEAT_GETTEXT) 3600 /* 3601 * If $LANG isn't set, try to get a good value for it. This makes the 3602 * right language be used automatically. Don't do this for English. 3603 */ 3604 if (mch_getenv((char_u *)"LANG") == NULL) 3605 { 3606 char buf[20]; 3607 3608 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95. 3609 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use 3610 * only the first two. */ 3611 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, 3612 (LPTSTR)buf, 20); 3613 if (n >= 2 && STRNICMP(buf, "en", 2) != 0) 3614 { 3615 /* There are a few exceptions (probably more) */ 3616 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0) 3617 STRCPY(buf, "zh_TW"); 3618 else if (STRNICMP(buf, "chs", 3) == 0 3619 || STRNICMP(buf, "zhc", 3) == 0) 3620 STRCPY(buf, "zh_CN"); 3621 else if (STRNICMP(buf, "jp", 2) == 0) 3622 STRCPY(buf, "ja"); 3623 else 3624 buf[2] = NUL; /* truncate to two-letter code */ 3625 vim_setenv((char_u *)"LANG", (char_u *)buf); 3626 } 3627 } 3628 # else 3629 # ifdef MACOS_CONVERT 3630 /* Moved to os_mac_conv.c to avoid dependency problems. */ 3631 mac_lang_init(); 3632 # endif 3633 # endif 3634 3635 /* enc_locale() will try to find the encoding of the current locale. */ 3636 p = enc_locale(); 3637 if (p != NULL) 3638 { 3639 char_u *save_enc; 3640 3641 /* Try setting 'encoding' and check if the value is valid. 3642 * If not, go back to the default "latin1". */ 3643 save_enc = p_enc; 3644 p_enc = p; 3645 if (STRCMP(p_enc, "gb18030") == 0) 3646 { 3647 /* We don't support "gb18030", but "cp936" is a good substitute 3648 * for practical purposes, thus use that. It's not an alias to 3649 * still support conversion between gb18030 and utf-8. */ 3650 p_enc = vim_strsave((char_u *)"cp936"); 3651 vim_free(p); 3652 } 3653 if (mb_init() == NULL) 3654 { 3655 opt_idx = findoption((char_u *)"encoding"); 3656 if (opt_idx >= 0) 3657 { 3658 options[opt_idx].def_val[VI_DEFAULT] = p_enc; 3659 options[opt_idx].flags |= P_DEF_ALLOCED; 3660 } 3661 3662 #if defined(MSWIN) || defined(MACOS_X) || defined(VMS) 3663 if (STRCMP(p_enc, "latin1") == 0 3664 # ifdef FEAT_MBYTE 3665 || enc_utf8 3666 # endif 3667 ) 3668 { 3669 /* Adjust the default for 'isprint' and 'iskeyword' to match 3670 * latin1. Also set the defaults for when 'nocompatible' is 3671 * set. */ 3672 set_string_option_direct((char_u *)"isp", -1, 3673 ISP_LATIN1, OPT_FREE, SID_NONE); 3674 set_string_option_direct((char_u *)"isk", -1, 3675 ISK_LATIN1, OPT_FREE, SID_NONE); 3676 opt_idx = findoption((char_u *)"isp"); 3677 if (opt_idx >= 0) 3678 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1; 3679 opt_idx = findoption((char_u *)"isk"); 3680 if (opt_idx >= 0) 3681 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1; 3682 (void)init_chartab(); 3683 } 3684 #endif 3685 3686 # if defined(WIN3264) && !defined(FEAT_GUI) 3687 /* Win32 console: When GetACP() returns a different value from 3688 * GetConsoleCP() set 'termencoding'. */ 3689 if (GetACP() != GetConsoleCP()) 3690 { 3691 char buf[50]; 3692 3693 sprintf(buf, "cp%ld", (long)GetConsoleCP()); 3694 p_tenc = vim_strsave((char_u *)buf); 3695 if (p_tenc != NULL) 3696 { 3697 opt_idx = findoption((char_u *)"termencoding"); 3698 if (opt_idx >= 0) 3699 { 3700 options[opt_idx].def_val[VI_DEFAULT] = p_tenc; 3701 options[opt_idx].flags |= P_DEF_ALLOCED; 3702 } 3703 convert_setup(&input_conv, p_tenc, p_enc); 3704 convert_setup(&output_conv, p_enc, p_tenc); 3705 } 3706 else 3707 p_tenc = empty_option; 3708 } 3709 # endif 3710 # if defined(WIN3264) && defined(FEAT_MBYTE) 3711 /* $HOME may have characters in active code page. */ 3712 init_homedir(); 3713 # endif 3714 } 3715 else 3716 { 3717 vim_free(p_enc); 3718 p_enc = save_enc; 3719 } 3720 } 3721 #endif 3722 3723 #ifdef FEAT_MULTI_LANG 3724 /* Set the default for 'helplang'. */ 3725 set_helplang_default(get_mess_lang()); 3726 #endif 3727 } 3728 3729 /* 3730 * Set an option to its default value. 3731 * This does not take care of side effects! 3732 */ 3733 static void 3734 set_option_default( 3735 int opt_idx, 3736 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ 3737 int compatible) /* use Vi default value */ 3738 { 3739 char_u *varp; /* pointer to variable for current option */ 3740 int dvi; /* index in def_val[] */ 3741 long_u flags; 3742 long_u *flagsp; 3743 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; 3744 3745 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags); 3746 flags = options[opt_idx].flags; 3747 if (varp != NULL) /* skip hidden option, nothing to do for it */ 3748 { 3749 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT; 3750 if (flags & P_STRING) 3751 { 3752 /* Use set_string_option_direct() for local options to handle 3753 * freeing and allocating the value. */ 3754 if (options[opt_idx].indir != PV_NONE) 3755 set_string_option_direct(NULL, opt_idx, 3756 options[opt_idx].def_val[dvi], opt_flags, 0); 3757 else 3758 { 3759 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED)) 3760 free_string_option(*(char_u **)(varp)); 3761 *(char_u **)varp = options[opt_idx].def_val[dvi]; 3762 options[opt_idx].flags &= ~P_ALLOCED; 3763 } 3764 } 3765 else if (flags & P_NUM) 3766 { 3767 if (options[opt_idx].indir == PV_SCROLL) 3768 win_comp_scroll(curwin); 3769 else 3770 { 3771 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi]; 3772 /* May also set global value for local option. */ 3773 if (both) 3774 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = 3775 *(long *)varp; 3776 } 3777 } 3778 else /* P_BOOL */ 3779 { 3780 /* the cast to long is required for Manx C, long_i is needed for 3781 * MSVC */ 3782 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi]; 3783 #ifdef UNIX 3784 /* 'modeline' defaults to off for root */ 3785 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) 3786 *(int *)varp = FALSE; 3787 #endif 3788 /* May also set global value for local option. */ 3789 if (both) 3790 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = 3791 *(int *)varp; 3792 } 3793 3794 /* The default value is not insecure. */ 3795 flagsp = insecure_flag(opt_idx, opt_flags); 3796 *flagsp = *flagsp & ~P_INSECURE; 3797 } 3798 3799 #ifdef FEAT_EVAL 3800 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 3801 #endif 3802 } 3803 3804 /* 3805 * Set all options (except terminal options) to their default value. 3806 * When "opt_flags" is non-zero skip 'encoding'. 3807 */ 3808 static void 3809 set_options_default( 3810 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ 3811 { 3812 int i; 3813 win_T *wp; 3814 tabpage_T *tp; 3815 3816 for (i = 0; !istermoption(&options[i]); i++) 3817 if (!(options[i].flags & P_NODEFAULT) 3818 #if defined(FEAT_MBYTE) || defined(FEAT_CRYPT) 3819 && (opt_flags == 0 3820 || (TRUE 3821 # if defined(FEAT_MBYTE) 3822 && options[i].var != (char_u *)&p_enc 3823 # endif 3824 # if defined(FEAT_CRYPT) 3825 && options[i].var != (char_u *)&p_cm 3826 && options[i].var != (char_u *)&p_key 3827 # endif 3828 )) 3829 #endif 3830 ) 3831 set_option_default(i, opt_flags, p_cp); 3832 3833 /* The 'scroll' option must be computed for all windows. */ 3834 FOR_ALL_TAB_WINDOWS(tp, wp) 3835 win_comp_scroll(wp); 3836 #ifdef FEAT_CINDENT 3837 parse_cino(curbuf); 3838 #endif 3839 } 3840 3841 /* 3842 * Set the Vi-default value of a string option. 3843 * Used for 'sh', 'backupskip' and 'term'. 3844 */ 3845 void 3846 set_string_default(char *name, char_u *val) 3847 { 3848 char_u *p; 3849 int opt_idx; 3850 3851 p = vim_strsave(val); 3852 if (p != NULL) /* we don't want a NULL */ 3853 { 3854 opt_idx = findoption((char_u *)name); 3855 if (opt_idx >= 0) 3856 { 3857 if (options[opt_idx].flags & P_DEF_ALLOCED) 3858 vim_free(options[opt_idx].def_val[VI_DEFAULT]); 3859 options[opt_idx].def_val[VI_DEFAULT] = p; 3860 options[opt_idx].flags |= P_DEF_ALLOCED; 3861 } 3862 } 3863 } 3864 3865 /* 3866 * Set the Vi-default value of a number option. 3867 * Used for 'lines' and 'columns'. 3868 */ 3869 void 3870 set_number_default(char *name, long val) 3871 { 3872 int opt_idx; 3873 3874 opt_idx = findoption((char_u *)name); 3875 if (opt_idx >= 0) 3876 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 3877 } 3878 3879 #if defined(EXITFREE) || defined(PROTO) 3880 /* 3881 * Free all options. 3882 */ 3883 void 3884 free_all_options(void) 3885 { 3886 int i; 3887 3888 for (i = 0; !istermoption(&options[i]); i++) 3889 { 3890 if (options[i].indir == PV_NONE) 3891 { 3892 /* global option: free value and default value. */ 3893 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL) 3894 free_string_option(*(char_u **)options[i].var); 3895 if (options[i].flags & P_DEF_ALLOCED) 3896 free_string_option(options[i].def_val[VI_DEFAULT]); 3897 } 3898 else if (options[i].var != VAR_WIN 3899 && (options[i].flags & P_STRING)) 3900 /* buffer-local option: free global value */ 3901 free_string_option(*(char_u **)options[i].var); 3902 } 3903 } 3904 #endif 3905 3906 3907 /* 3908 * Initialize the options, part two: After getting Rows and Columns and 3909 * setting 'term'. 3910 */ 3911 void 3912 set_init_2(void) 3913 { 3914 int idx; 3915 3916 /* 3917 * 'scroll' defaults to half the window height. The stored default is zero, 3918 * which results in the actual value computed from the window height. 3919 */ 3920 idx = findoption((char_u *)"scroll"); 3921 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) 3922 set_option_default(idx, OPT_LOCAL, p_cp); 3923 comp_col(); 3924 3925 /* 3926 * 'window' is only for backwards compatibility with Vi. 3927 * Default is Rows - 1. 3928 */ 3929 if (!option_was_set((char_u *)"window")) 3930 p_window = Rows - 1; 3931 set_number_default("window", Rows - 1); 3932 3933 /* For DOS console the default is always black. */ 3934 #if !((defined(WIN3264)) && !defined(FEAT_GUI)) 3935 /* 3936 * If 'background' wasn't set by the user, try guessing the value, 3937 * depending on the terminal name. Only need to check for terminals 3938 * with a dark background, that can handle color. 3939 */ 3940 idx = findoption((char_u *)"bg"); 3941 if (idx >= 0 && !(options[idx].flags & P_WAS_SET) 3942 && *term_bg_default() == 'd') 3943 { 3944 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0); 3945 /* don't mark it as set, when starting the GUI it may be 3946 * changed again */ 3947 options[idx].flags &= ~P_WAS_SET; 3948 } 3949 #endif 3950 3951 #ifdef CURSOR_SHAPE 3952 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */ 3953 #endif 3954 #ifdef FEAT_MOUSESHAPE 3955 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */ 3956 #endif 3957 #ifdef FEAT_PRINTER 3958 (void)parse_printoptions(); /* parse 'printoptions' default value */ 3959 #endif 3960 } 3961 3962 /* 3963 * Return "dark" or "light" depending on the kind of terminal. 3964 * This is just guessing! Recognized are: 3965 * "linux" Linux console 3966 * "screen.linux" Linux console with screen 3967 * "cygwin.*" Cygwin shell 3968 * "putty.*" Putty program 3969 * We also check the COLORFGBG environment variable, which is set by 3970 * rxvt and derivatives. This variable contains either two or three 3971 * values separated by semicolons; we want the last value in either 3972 * case. If this value is 0-6 or 8, our background is dark. 3973 */ 3974 static char_u * 3975 term_bg_default(void) 3976 { 3977 #if defined(WIN3264) 3978 /* DOS console is nearly always black */ 3979 return (char_u *)"dark"; 3980 #else 3981 char_u *p; 3982 3983 if (STRCMP(T_NAME, "linux") == 0 3984 || STRCMP(T_NAME, "screen.linux") == 0 3985 || STRNCMP(T_NAME, "cygwin", 6) == 0 3986 || STRNCMP(T_NAME, "putty", 5) == 0 3987 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL 3988 && (p = vim_strrchr(p, ';')) != NULL 3989 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8') 3990 && p[2] == NUL)) 3991 return (char_u *)"dark"; 3992 return (char_u *)"light"; 3993 #endif 3994 } 3995 3996 /* 3997 * Initialize the options, part three: After reading the .vimrc 3998 */ 3999 void 4000 set_init_3(void) 4001 { 4002 #if defined(UNIX) || defined(WIN3264) 4003 /* 4004 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option. 4005 * This is done after other initializations, where 'shell' might have been 4006 * set, but only if they have not been set before. 4007 */ 4008 char_u *p; 4009 int idx_srr; 4010 int do_srr; 4011 # ifdef FEAT_QUICKFIX 4012 int idx_sp; 4013 int do_sp; 4014 # endif 4015 4016 idx_srr = findoption((char_u *)"srr"); 4017 if (idx_srr < 0) 4018 do_srr = FALSE; 4019 else 4020 do_srr = !(options[idx_srr].flags & P_WAS_SET); 4021 # ifdef FEAT_QUICKFIX 4022 idx_sp = findoption((char_u *)"sp"); 4023 if (idx_sp < 0) 4024 do_sp = FALSE; 4025 else 4026 do_sp = !(options[idx_sp].flags & P_WAS_SET); 4027 # endif 4028 p = get_isolated_shell_name(); 4029 if (p != NULL) 4030 { 4031 /* 4032 * Default for p_sp is "| tee", for p_srr is ">". 4033 * For known shells it is changed here to include stderr. 4034 */ 4035 if ( fnamecmp(p, "csh") == 0 4036 || fnamecmp(p, "tcsh") == 0 4037 # if defined(WIN3264) /* also check with .exe extension */ 4038 || fnamecmp(p, "csh.exe") == 0 4039 || fnamecmp(p, "tcsh.exe") == 0 4040 # endif 4041 ) 4042 { 4043 # if defined(FEAT_QUICKFIX) 4044 if (do_sp) 4045 { 4046 # ifdef WIN3264 4047 p_sp = (char_u *)">&"; 4048 # else 4049 p_sp = (char_u *)"|& tee"; 4050 # endif 4051 options[idx_sp].def_val[VI_DEFAULT] = p_sp; 4052 } 4053 # endif 4054 if (do_srr) 4055 { 4056 p_srr = (char_u *)">&"; 4057 options[idx_srr].def_val[VI_DEFAULT] = p_srr; 4058 } 4059 } 4060 else 4061 /* Always use bourne shell style redirection if we reach this */ 4062 if ( fnamecmp(p, "sh") == 0 4063 || fnamecmp(p, "ksh") == 0 4064 || fnamecmp(p, "mksh") == 0 4065 || fnamecmp(p, "pdksh") == 0 4066 || fnamecmp(p, "zsh") == 0 4067 || fnamecmp(p, "zsh-beta") == 0 4068 || fnamecmp(p, "bash") == 0 4069 || fnamecmp(p, "fish") == 0 4070 # ifdef WIN3264 4071 || fnamecmp(p, "cmd") == 0 4072 || fnamecmp(p, "sh.exe") == 0 4073 || fnamecmp(p, "ksh.exe") == 0 4074 || fnamecmp(p, "mksh.exe") == 0 4075 || fnamecmp(p, "pdksh.exe") == 0 4076 || fnamecmp(p, "zsh.exe") == 0 4077 || fnamecmp(p, "zsh-beta.exe") == 0 4078 || fnamecmp(p, "bash.exe") == 0 4079 || fnamecmp(p, "cmd.exe") == 0 4080 # endif 4081 ) 4082 { 4083 # if defined(FEAT_QUICKFIX) 4084 if (do_sp) 4085 { 4086 # ifdef WIN3264 4087 p_sp = (char_u *)">%s 2>&1"; 4088 # else 4089 p_sp = (char_u *)"2>&1| tee"; 4090 # endif 4091 options[idx_sp].def_val[VI_DEFAULT] = p_sp; 4092 } 4093 # endif 4094 if (do_srr) 4095 { 4096 p_srr = (char_u *)">%s 2>&1"; 4097 options[idx_srr].def_val[VI_DEFAULT] = p_srr; 4098 } 4099 } 4100 vim_free(p); 4101 } 4102 #endif 4103 4104 #if defined(WIN3264) 4105 /* 4106 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the 4107 * 'shell' option. 4108 * This is done after other initializations, where 'shell' might have been 4109 * set, but only if they have not been set before. Default for p_shcf is 4110 * "/c", for p_shq is "". For "sh" like shells it is changed here to 4111 * "-c" and "\"". And for Win32 we need to set p_sxq instead. 4112 */ 4113 if (strstr((char *)gettail(p_sh), "sh") != NULL) 4114 { 4115 int idx3; 4116 4117 idx3 = findoption((char_u *)"shcf"); 4118 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 4119 { 4120 p_shcf = (char_u *)"-c"; 4121 options[idx3].def_val[VI_DEFAULT] = p_shcf; 4122 } 4123 4124 /* Somehow Win32 requires the quotes around the redirection too */ 4125 idx3 = findoption((char_u *)"sxq"); 4126 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 4127 { 4128 p_sxq = (char_u *)"\""; 4129 options[idx3].def_val[VI_DEFAULT] = p_sxq; 4130 } 4131 } 4132 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL) 4133 { 4134 int idx3; 4135 4136 /* 4137 * cmd.exe on Windows will strip the first and last double quote given 4138 * on the command line, e.g. most of the time things like: 4139 * cmd /c "my path/to/echo" "my args to echo" 4140 * become: 4141 * my path/to/echo" "my args to echo 4142 * when executed. 4143 * 4144 * To avoid this, set shellxquote to surround the command in 4145 * parenthesis. This appears to make most commands work, without 4146 * breaking commands that worked previously, such as 4147 * '"path with spaces/cmd" "a&b"'. 4148 */ 4149 idx3 = findoption((char_u *)"sxq"); 4150 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 4151 { 4152 p_sxq = (char_u *)"("; 4153 options[idx3].def_val[VI_DEFAULT] = p_sxq; 4154 } 4155 4156 idx3 = findoption((char_u *)"shcf"); 4157 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET)) 4158 { 4159 p_shcf = (char_u *)"/c"; 4160 options[idx3].def_val[VI_DEFAULT] = p_shcf; 4161 } 4162 } 4163 #endif 4164 4165 if (BUFEMPTY()) 4166 { 4167 int idx_ffs = findoption((char_u *)"ffs"); 4168 4169 /* Apply the first entry of 'fileformats' to the initial buffer. */ 4170 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET)) 4171 set_fileformat(default_fileformat(), OPT_LOCAL); 4172 } 4173 4174 #ifdef FEAT_TITLE 4175 set_title_defaults(); 4176 #endif 4177 } 4178 4179 #if defined(FEAT_MULTI_LANG) || defined(PROTO) 4180 /* 4181 * When 'helplang' is still at its default value, set it to "lang". 4182 * Only the first two characters of "lang" are used. 4183 */ 4184 void 4185 set_helplang_default(char_u *lang) 4186 { 4187 int idx; 4188 4189 if (lang == NULL || STRLEN(lang) < 2) /* safety check */ 4190 return; 4191 idx = findoption((char_u *)"hlg"); 4192 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) 4193 { 4194 if (options[idx].flags & P_ALLOCED) 4195 free_string_option(p_hlg); 4196 p_hlg = vim_strsave(lang); 4197 if (p_hlg == NULL) 4198 p_hlg = empty_option; 4199 else 4200 { 4201 /* zh_CN becomes "cn", zh_TW becomes "tw". */ 4202 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) 4203 { 4204 p_hlg[0] = TOLOWER_ASC(p_hlg[3]); 4205 p_hlg[1] = TOLOWER_ASC(p_hlg[4]); 4206 } 4207 p_hlg[2] = NUL; 4208 } 4209 options[idx].flags |= P_ALLOCED; 4210 } 4211 } 4212 #endif 4213 4214 #ifdef FEAT_GUI 4215 static char_u *gui_bg_default(void); 4216 4217 static char_u * 4218 gui_bg_default(void) 4219 { 4220 if (gui_get_lightness(gui.back_pixel) < 127) 4221 return (char_u *)"dark"; 4222 return (char_u *)"light"; 4223 } 4224 4225 /* 4226 * Option initializations that can only be done after opening the GUI window. 4227 */ 4228 void 4229 init_gui_options(void) 4230 { 4231 /* Set the 'background' option according to the lightness of the 4232 * background color, unless the user has set it already. */ 4233 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0) 4234 { 4235 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0); 4236 highlight_changed(); 4237 } 4238 } 4239 #endif 4240 4241 #ifdef FEAT_TITLE 4242 /* 4243 * 'title' and 'icon' only default to true if they have not been set or reset 4244 * in .vimrc and we can read the old value. 4245 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if 4246 * they can be reset. This reduces startup time when using X on a remote 4247 * machine. 4248 */ 4249 void 4250 set_title_defaults(void) 4251 { 4252 int idx1; 4253 long val; 4254 4255 /* 4256 * If GUI is (going to be) used, we can always set the window title and 4257 * icon name. Saves a bit of time, because the X11 display server does 4258 * not need to be contacted. 4259 */ 4260 idx1 = findoption((char_u *)"title"); 4261 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) 4262 { 4263 #ifdef FEAT_GUI 4264 if (gui.starting || gui.in_use) 4265 val = TRUE; 4266 else 4267 #endif 4268 val = mch_can_restore_title(); 4269 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 4270 p_title = val; 4271 } 4272 idx1 = findoption((char_u *)"icon"); 4273 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET)) 4274 { 4275 #ifdef FEAT_GUI 4276 if (gui.starting || gui.in_use) 4277 val = TRUE; 4278 else 4279 #endif 4280 val = mch_can_restore_icon(); 4281 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val; 4282 p_icon = val; 4283 } 4284 } 4285 #endif 4286 4287 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4288 static void 4289 trigger_optionsset_string( 4290 int opt_idx, 4291 int opt_flags, 4292 char_u *oldval, 4293 char_u *newval) 4294 { 4295 if (oldval != NULL && newval != NULL) 4296 { 4297 char_u buf_type[7]; 4298 4299 sprintf((char *)buf_type, "%s", 4300 (opt_flags & OPT_LOCAL) ? "local" : "global"); 4301 set_vim_var_string(VV_OPTION_OLD, oldval, -1); 4302 set_vim_var_string(VV_OPTION_NEW, newval, -1); 4303 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 4304 apply_autocmds(EVENT_OPTIONSET, 4305 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL); 4306 reset_v_option_vars(); 4307 } 4308 } 4309 #endif 4310 4311 /* 4312 * Parse 'arg' for option settings. 4313 * 4314 * 'arg' may be IObuff, but only when no errors can be present and option 4315 * does not need to be expanded with option_expand(). 4316 * "opt_flags": 4317 * 0 for ":set" 4318 * OPT_GLOBAL for ":setglobal" 4319 * OPT_LOCAL for ":setlocal" and a modeline 4320 * OPT_MODELINE for a modeline 4321 * OPT_WINONLY to only set window-local options 4322 * OPT_NOWIN to skip setting window-local options 4323 * 4324 * returns FAIL if an error is detected, OK otherwise 4325 */ 4326 int 4327 do_set( 4328 char_u *arg, /* option string (may be written to!) */ 4329 int opt_flags) 4330 { 4331 int opt_idx; 4332 char_u *errmsg; 4333 char_u errbuf[80]; 4334 char_u *startarg; 4335 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */ 4336 int nextchar; /* next non-white char after option name */ 4337 int afterchar; /* character just after option name */ 4338 int len; 4339 int i; 4340 varnumber_T value; 4341 int key; 4342 long_u flags; /* flags for current option */ 4343 char_u *varp = NULL; /* pointer to variable for current option */ 4344 int did_show = FALSE; /* already showed one value */ 4345 int adding; /* "opt+=arg" */ 4346 int prepending; /* "opt^=arg" */ 4347 int removing; /* "opt-=arg" */ 4348 int cp_val = 0; 4349 char_u key_name[2]; 4350 4351 if (*arg == NUL) 4352 { 4353 showoptions(0, opt_flags); 4354 did_show = TRUE; 4355 goto theend; 4356 } 4357 4358 while (*arg != NUL) /* loop to process all options */ 4359 { 4360 errmsg = NULL; 4361 startarg = arg; /* remember for error message */ 4362 4363 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3]) 4364 && !(opt_flags & OPT_MODELINE)) 4365 { 4366 /* 4367 * ":set all" show all options. 4368 * ":set all&" set all options to their default value. 4369 */ 4370 arg += 3; 4371 if (*arg == '&') 4372 { 4373 ++arg; 4374 /* Only for :set command set global value of local options. */ 4375 set_options_default(OPT_FREE | opt_flags); 4376 didset_options(); 4377 didset_options2(); 4378 redraw_all_later(CLEAR); 4379 } 4380 else 4381 { 4382 showoptions(1, opt_flags); 4383 did_show = TRUE; 4384 } 4385 } 4386 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) 4387 { 4388 showoptions(2, opt_flags); 4389 show_termcodes(); 4390 did_show = TRUE; 4391 arg += 7; 4392 } 4393 else 4394 { 4395 prefix = 1; 4396 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0) 4397 { 4398 prefix = 0; 4399 arg += 2; 4400 } 4401 else if (STRNCMP(arg, "inv", 3) == 0) 4402 { 4403 prefix = 2; 4404 arg += 3; 4405 } 4406 4407 /* find end of name */ 4408 key = 0; 4409 if (*arg == '<') 4410 { 4411 nextchar = 0; 4412 opt_idx = -1; 4413 /* look out for <t_>;> */ 4414 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4]) 4415 len = 5; 4416 else 4417 { 4418 len = 1; 4419 while (arg[len] != NUL && arg[len] != '>') 4420 ++len; 4421 } 4422 if (arg[len] != '>') 4423 { 4424 errmsg = e_invarg; 4425 goto skip; 4426 } 4427 arg[len] = NUL; /* put NUL after name */ 4428 if (arg[1] == 't' && arg[2] == '_') /* could be term code */ 4429 opt_idx = findoption(arg + 1); 4430 arg[len++] = '>'; /* restore '>' */ 4431 if (opt_idx == -1) 4432 key = find_key_option(arg + 1); 4433 } 4434 else 4435 { 4436 len = 0; 4437 /* 4438 * The two characters after "t_" may not be alphanumeric. 4439 */ 4440 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) 4441 len = 4; 4442 else 4443 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_') 4444 ++len; 4445 nextchar = arg[len]; 4446 arg[len] = NUL; /* put NUL after name */ 4447 opt_idx = findoption(arg); 4448 arg[len] = nextchar; /* restore nextchar */ 4449 if (opt_idx == -1) 4450 key = find_key_option(arg); 4451 } 4452 4453 /* remember character after option name */ 4454 afterchar = arg[len]; 4455 4456 /* skip white space, allow ":set ai ?" */ 4457 while (VIM_ISWHITE(arg[len])) 4458 ++len; 4459 4460 adding = FALSE; 4461 prepending = FALSE; 4462 removing = FALSE; 4463 if (arg[len] != NUL && arg[len + 1] == '=') 4464 { 4465 if (arg[len] == '+') 4466 { 4467 adding = TRUE; /* "+=" */ 4468 ++len; 4469 } 4470 else if (arg[len] == '^') 4471 { 4472 prepending = TRUE; /* "^=" */ 4473 ++len; 4474 } 4475 else if (arg[len] == '-') 4476 { 4477 removing = TRUE; /* "-=" */ 4478 ++len; 4479 } 4480 } 4481 nextchar = arg[len]; 4482 4483 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */ 4484 { 4485 errmsg = (char_u *)N_("E518: Unknown option"); 4486 goto skip; 4487 } 4488 4489 if (opt_idx >= 0) 4490 { 4491 if (options[opt_idx].var == NULL) /* hidden option: skip */ 4492 { 4493 /* Only give an error message when requesting the value of 4494 * a hidden option, ignore setting it. */ 4495 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL 4496 && (!(options[opt_idx].flags & P_BOOL) 4497 || nextchar == '?')) 4498 errmsg = (char_u *)N_("E519: Option not supported"); 4499 goto skip; 4500 } 4501 4502 flags = options[opt_idx].flags; 4503 varp = get_varp_scope(&(options[opt_idx]), opt_flags); 4504 } 4505 else 4506 { 4507 flags = P_STRING; 4508 if (key < 0) 4509 { 4510 key_name[0] = KEY2TERMCAP0(key); 4511 key_name[1] = KEY2TERMCAP1(key); 4512 } 4513 else 4514 { 4515 key_name[0] = KS_KEY; 4516 key_name[1] = (key & 0xff); 4517 } 4518 } 4519 4520 /* Skip all options that are not window-local (used when showing 4521 * an already loaded buffer in a window). */ 4522 if ((opt_flags & OPT_WINONLY) 4523 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN)) 4524 goto skip; 4525 4526 /* Skip all options that are window-local (used for :vimgrep). */ 4527 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0 4528 && options[opt_idx].var == VAR_WIN) 4529 goto skip; 4530 4531 /* Disallow changing some options from modelines. */ 4532 if (opt_flags & OPT_MODELINE) 4533 { 4534 if (flags & (P_SECURE | P_NO_ML)) 4535 { 4536 errmsg = (char_u *)_("E520: Not allowed in a modeline"); 4537 goto skip; 4538 } 4539 #ifdef FEAT_DIFF 4540 /* In diff mode some options are overruled. This avoids that 4541 * 'foldmethod' becomes "marker" instead of "diff" and that 4542 * "wrap" gets set. */ 4543 if (curwin->w_p_diff 4544 && opt_idx >= 0 /* shut up coverity warning */ 4545 && ( 4546 #ifdef FEAT_FOLDING 4547 options[opt_idx].indir == PV_FDM || 4548 #endif 4549 options[opt_idx].indir == PV_WRAP)) 4550 goto skip; 4551 #endif 4552 } 4553 4554 #ifdef HAVE_SANDBOX 4555 /* Disallow changing some options in the sandbox */ 4556 if (sandbox != 0 && (flags & P_SECURE)) 4557 { 4558 errmsg = (char_u *)_(e_sandbox); 4559 goto skip; 4560 } 4561 #endif 4562 4563 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL) 4564 { 4565 arg += len; 4566 cp_val = p_cp; 4567 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i') 4568 { 4569 if (arg[3] == 'm') /* "opt&vim": set to Vim default */ 4570 { 4571 cp_val = FALSE; 4572 arg += 3; 4573 } 4574 else /* "opt&vi": set to Vi default */ 4575 { 4576 cp_val = TRUE; 4577 arg += 2; 4578 } 4579 } 4580 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL 4581 && arg[1] != NUL && !VIM_ISWHITE(arg[1])) 4582 { 4583 errmsg = e_trailing; 4584 goto skip; 4585 } 4586 } 4587 4588 /* 4589 * allow '=' and ':' for hystorical reasons (MSDOS command.com 4590 * allows only one '=' character per "set" command line. grrr. (jw) 4591 */ 4592 if (nextchar == '?' 4593 || (prefix == 1 4594 && vim_strchr((char_u *)"=:&<", nextchar) == NULL 4595 && !(flags & P_BOOL))) 4596 { 4597 /* 4598 * print value 4599 */ 4600 if (did_show) 4601 msg_putchar('\n'); /* cursor below last one */ 4602 else 4603 { 4604 gotocmdline(TRUE); /* cursor at status line */ 4605 did_show = TRUE; /* remember that we did a line */ 4606 } 4607 if (opt_idx >= 0) 4608 { 4609 showoneopt(&options[opt_idx], opt_flags); 4610 #ifdef FEAT_EVAL 4611 if (p_verbose > 0) 4612 { 4613 /* Mention where the option was last set. */ 4614 if (varp == options[opt_idx].var) 4615 last_set_msg(options[opt_idx].scriptID); 4616 else if ((int)options[opt_idx].indir & PV_WIN) 4617 last_set_msg(curwin->w_p_scriptID[ 4618 (int)options[opt_idx].indir & PV_MASK]); 4619 else if ((int)options[opt_idx].indir & PV_BUF) 4620 last_set_msg(curbuf->b_p_scriptID[ 4621 (int)options[opt_idx].indir & PV_MASK]); 4622 } 4623 #endif 4624 } 4625 else 4626 { 4627 char_u *p; 4628 4629 p = find_termcode(key_name); 4630 if (p == NULL) 4631 { 4632 errmsg = (char_u *)N_("E846: Key code not set"); 4633 goto skip; 4634 } 4635 else 4636 (void)show_one_termcode(key_name, p, TRUE); 4637 } 4638 if (nextchar != '?' 4639 && nextchar != NUL && !VIM_ISWHITE(afterchar)) 4640 errmsg = e_trailing; 4641 } 4642 else 4643 { 4644 if (flags & P_BOOL) /* boolean */ 4645 { 4646 if (nextchar == '=' || nextchar == ':') 4647 { 4648 errmsg = e_invarg; 4649 goto skip; 4650 } 4651 4652 /* 4653 * ":set opt!": invert 4654 * ":set opt&": reset to default value 4655 * ":set opt<": reset to global value 4656 */ 4657 if (nextchar == '!') 4658 value = *(int *)(varp) ^ 1; 4659 else if (nextchar == '&') 4660 value = (int)(long)(long_i)options[opt_idx].def_val[ 4661 ((flags & P_VI_DEF) || cp_val) 4662 ? VI_DEFAULT : VIM_DEFAULT]; 4663 else if (nextchar == '<') 4664 { 4665 /* For 'autoread' -1 means to use global value. */ 4666 if ((int *)varp == &curbuf->b_p_ar 4667 && opt_flags == OPT_LOCAL) 4668 value = -1; 4669 else 4670 value = *(int *)get_varp_scope(&(options[opt_idx]), 4671 OPT_GLOBAL); 4672 } 4673 else 4674 { 4675 /* 4676 * ":set invopt": invert 4677 * ":set opt" or ":set noopt": set or reset 4678 */ 4679 if (nextchar != NUL && !VIM_ISWHITE(afterchar)) 4680 { 4681 errmsg = e_trailing; 4682 goto skip; 4683 } 4684 if (prefix == 2) /* inv */ 4685 value = *(int *)(varp) ^ 1; 4686 else 4687 value = prefix; 4688 } 4689 4690 errmsg = set_bool_option(opt_idx, varp, (int)value, 4691 opt_flags); 4692 } 4693 else /* numeric or string */ 4694 { 4695 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL 4696 || prefix != 1) 4697 { 4698 errmsg = e_invarg; 4699 goto skip; 4700 } 4701 4702 if (flags & P_NUM) /* numeric */ 4703 { 4704 /* 4705 * Different ways to set a number option: 4706 * & set to default value 4707 * < set to global value 4708 * <xx> accept special key codes for 'wildchar' 4709 * c accept any non-digit for 'wildchar' 4710 * [-]0-9 set number 4711 * other error 4712 */ 4713 ++arg; 4714 if (nextchar == '&') 4715 value = (long)(long_i)options[opt_idx].def_val[ 4716 ((flags & P_VI_DEF) || cp_val) 4717 ? VI_DEFAULT : VIM_DEFAULT]; 4718 else if (nextchar == '<') 4719 { 4720 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to 4721 * use the global value. */ 4722 if ((long *)varp == &curbuf->b_p_ul 4723 && opt_flags == OPT_LOCAL) 4724 value = NO_LOCAL_UNDOLEVEL; 4725 else 4726 value = *(long *)get_varp_scope( 4727 &(options[opt_idx]), OPT_GLOBAL); 4728 } 4729 else if (((long *)varp == &p_wc 4730 || (long *)varp == &p_wcm) 4731 && (*arg == '<' 4732 || *arg == '^' 4733 || (*arg != NUL 4734 && (!arg[1] || VIM_ISWHITE(arg[1])) 4735 && !VIM_ISDIGIT(*arg)))) 4736 { 4737 value = string_to_key(arg, FALSE); 4738 if (value == 0 && (long *)varp != &p_wcm) 4739 { 4740 errmsg = e_invarg; 4741 goto skip; 4742 } 4743 } 4744 else if (*arg == '-' || VIM_ISDIGIT(*arg)) 4745 { 4746 /* Allow negative (for 'undolevels'), octal and 4747 * hex numbers. */ 4748 vim_str2nr(arg, NULL, &i, STR2NR_ALL, 4749 &value, NULL, 0); 4750 if (arg[i] != NUL && !VIM_ISWHITE(arg[i])) 4751 { 4752 errmsg = e_invarg; 4753 goto skip; 4754 } 4755 } 4756 else 4757 { 4758 errmsg = (char_u *)N_("E521: Number required after ="); 4759 goto skip; 4760 } 4761 4762 if (adding) 4763 value = *(long *)varp + value; 4764 if (prepending) 4765 value = *(long *)varp * value; 4766 if (removing) 4767 value = *(long *)varp - value; 4768 errmsg = set_num_option(opt_idx, varp, value, 4769 errbuf, sizeof(errbuf), opt_flags); 4770 } 4771 else if (opt_idx >= 0) /* string */ 4772 { 4773 char_u *save_arg = NULL; 4774 char_u *s = NULL; 4775 char_u *oldval = NULL; /* previous value if *varp */ 4776 char_u *newval; 4777 char_u *origval = NULL; 4778 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4779 char_u *saved_origval = NULL; 4780 char_u *saved_newval = NULL; 4781 #endif 4782 unsigned newlen; 4783 int comma; 4784 int bs; 4785 int new_value_alloced; /* new string option 4786 was allocated */ 4787 4788 /* When using ":set opt=val" for a global option 4789 * with a local value the local value will be 4790 * reset, use the global value here. */ 4791 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 4792 && ((int)options[opt_idx].indir & PV_BOTH)) 4793 varp = options[opt_idx].var; 4794 4795 /* The old value is kept until we are sure that the 4796 * new value is valid. */ 4797 oldval = *(char_u **)varp; 4798 4799 /* When setting the local value of a global 4800 * option, the old value may be the global value. */ 4801 if (((int)options[opt_idx].indir & PV_BOTH) 4802 && (opt_flags & OPT_LOCAL)) 4803 origval = *(char_u **)get_varp( 4804 &options[opt_idx]); 4805 else 4806 origval = oldval; 4807 4808 if (nextchar == '&') /* set to default val */ 4809 { 4810 newval = options[opt_idx].def_val[ 4811 ((flags & P_VI_DEF) || cp_val) 4812 ? VI_DEFAULT : VIM_DEFAULT]; 4813 if ((char_u **)varp == &p_bg) 4814 { 4815 /* guess the value of 'background' */ 4816 #ifdef FEAT_GUI 4817 if (gui.in_use) 4818 newval = gui_bg_default(); 4819 else 4820 #endif 4821 newval = term_bg_default(); 4822 } 4823 4824 /* expand environment variables and ~ (since the 4825 * default value was already expanded, only 4826 * required when an environment variable was set 4827 * later */ 4828 if (newval == NULL) 4829 newval = empty_option; 4830 else 4831 { 4832 s = option_expand(opt_idx, newval); 4833 if (s == NULL) 4834 s = newval; 4835 newval = vim_strsave(s); 4836 } 4837 new_value_alloced = TRUE; 4838 } 4839 else if (nextchar == '<') /* set to global val */ 4840 { 4841 newval = vim_strsave(*(char_u **)get_varp_scope( 4842 &(options[opt_idx]), OPT_GLOBAL)); 4843 new_value_alloced = TRUE; 4844 } 4845 else 4846 { 4847 ++arg; /* jump to after the '=' or ':' */ 4848 4849 /* 4850 * Set 'keywordprg' to ":help" if an empty 4851 * value was passed to :set by the user. 4852 * Misuse errbuf[] for the resulting string. 4853 */ 4854 if (varp == (char_u *)&p_kp 4855 && (*arg == NUL || *arg == ' ')) 4856 { 4857 STRCPY(errbuf, ":help"); 4858 save_arg = arg; 4859 arg = errbuf; 4860 } 4861 /* 4862 * Convert 'backspace' number to string, for 4863 * adding, prepending and removing string. 4864 */ 4865 else if (varp == (char_u *)&p_bs 4866 && VIM_ISDIGIT(**(char_u **)varp)) 4867 { 4868 i = getdigits((char_u **)varp); 4869 switch (i) 4870 { 4871 case 0: 4872 *(char_u **)varp = empty_option; 4873 break; 4874 case 1: 4875 *(char_u **)varp = vim_strsave( 4876 (char_u *)"indent,eol"); 4877 break; 4878 case 2: 4879 *(char_u **)varp = vim_strsave( 4880 (char_u *)"indent,eol,start"); 4881 break; 4882 } 4883 vim_free(oldval); 4884 if (origval == oldval) 4885 origval = *(char_u **)varp; 4886 oldval = *(char_u **)varp; 4887 } 4888 /* 4889 * Convert 'whichwrap' number to string, for 4890 * backwards compatibility with Vim 3.0. 4891 * Misuse errbuf[] for the resulting string. 4892 */ 4893 else if (varp == (char_u *)&p_ww 4894 && VIM_ISDIGIT(*arg)) 4895 { 4896 *errbuf = NUL; 4897 i = getdigits(&arg); 4898 if (i & 1) 4899 STRCAT(errbuf, "b,"); 4900 if (i & 2) 4901 STRCAT(errbuf, "s,"); 4902 if (i & 4) 4903 STRCAT(errbuf, "h,l,"); 4904 if (i & 8) 4905 STRCAT(errbuf, "<,>,"); 4906 if (i & 16) 4907 STRCAT(errbuf, "[,],"); 4908 if (*errbuf != NUL) /* remove trailing , */ 4909 errbuf[STRLEN(errbuf) - 1] = NUL; 4910 save_arg = arg; 4911 arg = errbuf; 4912 } 4913 /* 4914 * Remove '>' before 'dir' and 'bdir', for 4915 * backwards compatibility with version 3.0 4916 */ 4917 else if ( *arg == '>' 4918 && (varp == (char_u *)&p_dir 4919 || varp == (char_u *)&p_bdir)) 4920 { 4921 ++arg; 4922 } 4923 4924 /* 4925 * Copy the new string into allocated memory. 4926 * Can't use set_string_option_direct(), because 4927 * we need to remove the backslashes. 4928 */ 4929 /* get a bit too much */ 4930 newlen = (unsigned)STRLEN(arg) + 1; 4931 if (adding || prepending || removing) 4932 newlen += (unsigned)STRLEN(origval) + 1; 4933 newval = alloc(newlen); 4934 if (newval == NULL) /* out of mem, don't change */ 4935 break; 4936 s = newval; 4937 4938 /* 4939 * Copy the string, skip over escaped chars. 4940 * For MS-DOS and WIN32 backslashes before normal 4941 * file name characters are not removed, and keep 4942 * backslash at start, for "\\machine\path", but 4943 * do remove it for "\\\\machine\\path". 4944 * The reverse is found in ExpandOldSetting(). 4945 */ 4946 while (*arg && !VIM_ISWHITE(*arg)) 4947 { 4948 if (*arg == '\\' && arg[1] != NUL 4949 #ifdef BACKSLASH_IN_FILENAME 4950 && !((flags & P_EXPAND) 4951 && vim_isfilec(arg[1]) 4952 && (arg[1] != '\\' 4953 || (s == newval 4954 && arg[2] != '\\'))) 4955 #endif 4956 ) 4957 ++arg; /* remove backslash */ 4958 #ifdef FEAT_MBYTE 4959 if (has_mbyte 4960 && (i = (*mb_ptr2len)(arg)) > 1) 4961 { 4962 /* copy multibyte char */ 4963 mch_memmove(s, arg, (size_t)i); 4964 arg += i; 4965 s += i; 4966 } 4967 else 4968 #endif 4969 *s++ = *arg++; 4970 } 4971 *s = NUL; 4972 4973 /* 4974 * Expand environment variables and ~. 4975 * Don't do it when adding without inserting a 4976 * comma. 4977 */ 4978 if (!(adding || prepending || removing) 4979 || (flags & P_COMMA)) 4980 { 4981 s = option_expand(opt_idx, newval); 4982 if (s != NULL) 4983 { 4984 vim_free(newval); 4985 newlen = (unsigned)STRLEN(s) + 1; 4986 if (adding || prepending || removing) 4987 newlen += (unsigned)STRLEN(origval) + 1; 4988 newval = alloc(newlen); 4989 if (newval == NULL) 4990 break; 4991 STRCPY(newval, s); 4992 } 4993 } 4994 4995 /* locate newval[] in origval[] when removing it 4996 * and when adding to avoid duplicates */ 4997 i = 0; /* init for GCC */ 4998 if (removing || (flags & P_NODUP)) 4999 { 5000 i = (int)STRLEN(newval); 5001 bs = 0; 5002 for (s = origval; *s; ++s) 5003 { 5004 if ((!(flags & P_COMMA) 5005 || s == origval 5006 || (s[-1] == ',' && !(bs & 1))) 5007 && STRNCMP(s, newval, i) == 0 5008 && (!(flags & P_COMMA) 5009 || s[i] == ',' 5010 || s[i] == NUL)) 5011 break; 5012 /* Count backslashes. Only a comma with an 5013 * even number of backslashes or a single 5014 * backslash preceded by a comma before it 5015 * is recognized as a separator */ 5016 if ((s > origval + 1 5017 && s[-1] == '\\' 5018 && s[-2] != ',') 5019 || (s == origval + 1 5020 && s[-1] == '\\')) 5021 5022 ++bs; 5023 else 5024 bs = 0; 5025 } 5026 5027 /* do not add if already there */ 5028 if ((adding || prepending) && *s) 5029 { 5030 prepending = FALSE; 5031 adding = FALSE; 5032 STRCPY(newval, origval); 5033 } 5034 } 5035 5036 /* concatenate the two strings; add a ',' if 5037 * needed */ 5038 if (adding || prepending) 5039 { 5040 comma = ((flags & P_COMMA) && *origval != NUL 5041 && *newval != NUL); 5042 if (adding) 5043 { 5044 i = (int)STRLEN(origval); 5045 /* strip a trailing comma, would get 2 */ 5046 if (comma && i > 1 5047 && (flags & P_ONECOMMA) == P_ONECOMMA 5048 && origval[i - 1] == ',' 5049 && origval[i - 2] != '\\') 5050 i--; 5051 mch_memmove(newval + i + comma, newval, 5052 STRLEN(newval) + 1); 5053 mch_memmove(newval, origval, (size_t)i); 5054 } 5055 else 5056 { 5057 i = (int)STRLEN(newval); 5058 STRMOVE(newval + i + comma, origval); 5059 } 5060 if (comma) 5061 newval[i] = ','; 5062 } 5063 5064 /* Remove newval[] from origval[]. (Note: "i" has 5065 * been set above and is used here). */ 5066 if (removing) 5067 { 5068 STRCPY(newval, origval); 5069 if (*s) 5070 { 5071 /* may need to remove a comma */ 5072 if (flags & P_COMMA) 5073 { 5074 if (s == origval) 5075 { 5076 /* include comma after string */ 5077 if (s[i] == ',') 5078 ++i; 5079 } 5080 else 5081 { 5082 /* include comma before string */ 5083 --s; 5084 ++i; 5085 } 5086 } 5087 STRMOVE(newval + (s - origval), s + i); 5088 } 5089 } 5090 5091 if (flags & P_FLAGLIST) 5092 { 5093 /* Remove flags that appear twice. */ 5094 for (s = newval; *s;) 5095 { 5096 /* if options have P_FLAGLIST and 5097 * P_ONECOMMA such as 'whichwrap' */ 5098 if (flags & P_ONECOMMA) 5099 { 5100 if (*s != ',' && *(s + 1) == ',' 5101 && vim_strchr(s + 2, *s) != NULL) 5102 { 5103 /* Remove the duplicated value and 5104 * the next comma. */ 5105 STRMOVE(s, s + 2); 5106 continue; 5107 } 5108 } 5109 else 5110 { 5111 if ((!(flags & P_COMMA) || *s != ',') 5112 && vim_strchr(s + 1, *s) != NULL) 5113 { 5114 STRMOVE(s, s + 1); 5115 continue; 5116 } 5117 } 5118 ++s; 5119 } 5120 } 5121 5122 if (save_arg != NULL) /* number for 'whichwrap' */ 5123 arg = save_arg; 5124 new_value_alloced = TRUE; 5125 } 5126 5127 /* 5128 * Set the new value. 5129 */ 5130 *(char_u **)(varp) = newval; 5131 5132 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5133 if (!starting 5134 # ifdef FEAT_CRYPT 5135 && options[opt_idx].indir != PV_KEY 5136 # endif 5137 && origval != NULL && newval != NULL) 5138 { 5139 /* origval may be freed by 5140 * did_set_string_option(), make a copy. */ 5141 saved_origval = vim_strsave(origval); 5142 /* newval (and varp) may become invalid if the 5143 * buffer is closed by autocommands. */ 5144 saved_newval = vim_strsave(newval); 5145 } 5146 #endif 5147 5148 /* Handle side effects, and set the global value for 5149 * ":set" on local options. Note: when setting 'syntax' 5150 * or 'filetype' autocommands may be triggered that can 5151 * cause havoc. */ 5152 errmsg = did_set_string_option(opt_idx, (char_u **)varp, 5153 new_value_alloced, oldval, errbuf, opt_flags); 5154 5155 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5156 if (errmsg == NULL) 5157 trigger_optionsset_string(opt_idx, opt_flags, 5158 saved_origval, saved_newval); 5159 vim_free(saved_origval); 5160 vim_free(saved_newval); 5161 #endif 5162 /* If error detected, print the error message. */ 5163 if (errmsg != NULL) 5164 goto skip; 5165 } 5166 else /* key code option */ 5167 { 5168 char_u *p; 5169 5170 if (nextchar == '&') 5171 { 5172 if (add_termcap_entry(key_name, TRUE) == FAIL) 5173 errmsg = (char_u *)N_("E522: Not found in termcap"); 5174 } 5175 else 5176 { 5177 ++arg; /* jump to after the '=' or ':' */ 5178 for (p = arg; *p && !VIM_ISWHITE(*p); ++p) 5179 if (*p == '\\' && p[1] != NUL) 5180 ++p; 5181 nextchar = *p; 5182 *p = NUL; 5183 add_termcode(key_name, arg, FALSE); 5184 *p = nextchar; 5185 } 5186 if (full_screen) 5187 ttest(FALSE); 5188 redraw_all_later(CLEAR); 5189 } 5190 } 5191 5192 if (opt_idx >= 0) 5193 did_set_option(opt_idx, opt_flags, 5194 !prepending && !adding && !removing); 5195 } 5196 5197 skip: 5198 /* 5199 * Advance to next argument. 5200 * - skip until a blank found, taking care of backslashes 5201 * - skip blanks 5202 * - skip one "=val" argument (for hidden options ":set gfn =xx") 5203 */ 5204 for (i = 0; i < 2 ; ++i) 5205 { 5206 while (*arg != NUL && !VIM_ISWHITE(*arg)) 5207 if (*arg++ == '\\' && *arg != NUL) 5208 ++arg; 5209 arg = skipwhite(arg); 5210 if (*arg != '=') 5211 break; 5212 } 5213 } 5214 5215 if (errmsg != NULL) 5216 { 5217 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1); 5218 i = (int)STRLEN(IObuff) + 2; 5219 if (i + (arg - startarg) < IOSIZE) 5220 { 5221 /* append the argument with the error */ 5222 STRCAT(IObuff, ": "); 5223 mch_memmove(IObuff + i, startarg, (arg - startarg)); 5224 IObuff[i + (arg - startarg)] = NUL; 5225 } 5226 /* make sure all characters are printable */ 5227 trans_characters(IObuff, IOSIZE); 5228 5229 ++no_wait_return; /* wait_return done later */ 5230 emsg(IObuff); /* show error highlighted */ 5231 --no_wait_return; 5232 5233 return FAIL; 5234 } 5235 5236 arg = skipwhite(arg); 5237 } 5238 5239 theend: 5240 if (silent_mode && did_show) 5241 { 5242 /* After displaying option values in silent mode. */ 5243 silent_mode = FALSE; 5244 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ 5245 msg_putchar('\n'); 5246 cursor_on(); /* msg_start() switches it off */ 5247 out_flush(); 5248 silent_mode = TRUE; 5249 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */ 5250 } 5251 5252 return OK; 5253 } 5254 5255 /* 5256 * Call this when an option has been given a new value through a user command. 5257 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag. 5258 */ 5259 static void 5260 did_set_option( 5261 int opt_idx, 5262 int opt_flags, /* possibly with OPT_MODELINE */ 5263 int new_value) /* value was replaced completely */ 5264 { 5265 long_u *p; 5266 5267 options[opt_idx].flags |= P_WAS_SET; 5268 5269 /* When an option is set in the sandbox, from a modeline or in secure mode 5270 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the 5271 * flag. */ 5272 p = insecure_flag(opt_idx, opt_flags); 5273 if (secure 5274 #ifdef HAVE_SANDBOX 5275 || sandbox != 0 5276 #endif 5277 || (opt_flags & OPT_MODELINE)) 5278 *p = *p | P_INSECURE; 5279 else if (new_value) 5280 *p = *p & ~P_INSECURE; 5281 } 5282 5283 static char_u * 5284 illegal_char(char_u *errbuf, int c) 5285 { 5286 if (errbuf == NULL) 5287 return (char_u *)""; 5288 sprintf((char *)errbuf, _("E539: Illegal character <%s>"), 5289 (char *)transchar(c)); 5290 return errbuf; 5291 } 5292 5293 /* 5294 * Convert a key name or string into a key value. 5295 * Used for 'wildchar' and 'cedit' options. 5296 * When "multi_byte" is TRUE allow for multi-byte characters. 5297 */ 5298 int 5299 string_to_key(char_u *arg, int multi_byte) 5300 { 5301 if (*arg == '<') 5302 return find_key_option(arg + 1); 5303 if (*arg == '^') 5304 return Ctrl_chr(arg[1]); 5305 if (multi_byte) 5306 return PTR2CHAR(arg); 5307 return *arg; 5308 } 5309 5310 #ifdef FEAT_CMDWIN 5311 /* 5312 * Check value of 'cedit' and set cedit_key. 5313 * Returns NULL if value is OK, error message otherwise. 5314 */ 5315 static char_u * 5316 check_cedit(void) 5317 { 5318 int n; 5319 5320 if (*p_cedit == NUL) 5321 cedit_key = -1; 5322 else 5323 { 5324 n = string_to_key(p_cedit, FALSE); 5325 if (vim_isprintc(n)) 5326 return e_invarg; 5327 cedit_key = n; 5328 } 5329 return NULL; 5330 } 5331 #endif 5332 5333 #ifdef FEAT_TITLE 5334 /* 5335 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call 5336 * maketitle() to create and display it. 5337 * When switching the title or icon off, call mch_restore_title() to get 5338 * the old value back. 5339 */ 5340 static void 5341 did_set_title( 5342 int icon) /* Did set icon instead of title */ 5343 { 5344 if (starting != NO_SCREEN 5345 #ifdef FEAT_GUI 5346 && !gui.starting 5347 #endif 5348 ) 5349 { 5350 maketitle(); 5351 if (icon) 5352 { 5353 if (!p_icon) 5354 mch_restore_title(2); 5355 } 5356 else 5357 { 5358 if (!p_title) 5359 mch_restore_title(1); 5360 } 5361 } 5362 } 5363 #endif 5364 5365 /* 5366 * set_options_bin - called when 'bin' changes value. 5367 */ 5368 void 5369 set_options_bin( 5370 int oldval, 5371 int newval, 5372 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ 5373 { 5374 /* 5375 * The option values that are changed when 'bin' changes are 5376 * copied when 'bin is set and restored when 'bin' is reset. 5377 */ 5378 if (newval) 5379 { 5380 if (!oldval) /* switched on */ 5381 { 5382 if (!(opt_flags & OPT_GLOBAL)) 5383 { 5384 curbuf->b_p_tw_nobin = curbuf->b_p_tw; 5385 curbuf->b_p_wm_nobin = curbuf->b_p_wm; 5386 curbuf->b_p_ml_nobin = curbuf->b_p_ml; 5387 curbuf->b_p_et_nobin = curbuf->b_p_et; 5388 } 5389 if (!(opt_flags & OPT_LOCAL)) 5390 { 5391 p_tw_nobin = p_tw; 5392 p_wm_nobin = p_wm; 5393 p_ml_nobin = p_ml; 5394 p_et_nobin = p_et; 5395 } 5396 } 5397 5398 if (!(opt_flags & OPT_GLOBAL)) 5399 { 5400 curbuf->b_p_tw = 0; /* no automatic line wrap */ 5401 curbuf->b_p_wm = 0; /* no automatic line wrap */ 5402 curbuf->b_p_ml = 0; /* no modelines */ 5403 curbuf->b_p_et = 0; /* no expandtab */ 5404 } 5405 if (!(opt_flags & OPT_LOCAL)) 5406 { 5407 p_tw = 0; 5408 p_wm = 0; 5409 p_ml = FALSE; 5410 p_et = FALSE; 5411 p_bin = TRUE; /* needed when called for the "-b" argument */ 5412 } 5413 } 5414 else if (oldval) /* switched off */ 5415 { 5416 if (!(opt_flags & OPT_GLOBAL)) 5417 { 5418 curbuf->b_p_tw = curbuf->b_p_tw_nobin; 5419 curbuf->b_p_wm = curbuf->b_p_wm_nobin; 5420 curbuf->b_p_ml = curbuf->b_p_ml_nobin; 5421 curbuf->b_p_et = curbuf->b_p_et_nobin; 5422 } 5423 if (!(opt_flags & OPT_LOCAL)) 5424 { 5425 p_tw = p_tw_nobin; 5426 p_wm = p_wm_nobin; 5427 p_ml = p_ml_nobin; 5428 p_et = p_et_nobin; 5429 } 5430 } 5431 } 5432 5433 #ifdef FEAT_VIMINFO 5434 /* 5435 * Find the parameter represented by the given character (eg ', :, ", or /), 5436 * and return its associated value in the 'viminfo' string. 5437 * Only works for number parameters, not for 'r' or 'n'. 5438 * If the parameter is not specified in the string or there is no following 5439 * number, return -1. 5440 */ 5441 int 5442 get_viminfo_parameter(int type) 5443 { 5444 char_u *p; 5445 5446 p = find_viminfo_parameter(type); 5447 if (p != NULL && VIM_ISDIGIT(*p)) 5448 return atoi((char *)p); 5449 return -1; 5450 } 5451 5452 /* 5453 * Find the parameter represented by the given character (eg ''', ':', '"', or 5454 * '/') in the 'viminfo' option and return a pointer to the string after it. 5455 * Return NULL if the parameter is not specified in the string. 5456 */ 5457 char_u * 5458 find_viminfo_parameter(int type) 5459 { 5460 char_u *p; 5461 5462 for (p = p_viminfo; *p; ++p) 5463 { 5464 if (*p == type) 5465 return p + 1; 5466 if (*p == 'n') /* 'n' is always the last one */ 5467 break; 5468 p = vim_strchr(p, ','); /* skip until next ',' */ 5469 if (p == NULL) /* hit the end without finding parameter */ 5470 break; 5471 } 5472 return NULL; 5473 } 5474 #endif 5475 5476 /* 5477 * Expand environment variables for some string options. 5478 * These string options cannot be indirect! 5479 * If "val" is NULL expand the current value of the option. 5480 * Return pointer to NameBuff, or NULL when not expanded. 5481 */ 5482 static char_u * 5483 option_expand(int opt_idx, char_u *val) 5484 { 5485 /* if option doesn't need expansion nothing to do */ 5486 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL) 5487 return NULL; 5488 5489 /* If val is longer than MAXPATHL no meaningful expansion can be done, 5490 * expand_env() would truncate the string. */ 5491 if (val != NULL && STRLEN(val) > MAXPATHL) 5492 return NULL; 5493 5494 if (val == NULL) 5495 val = *(char_u **)options[opt_idx].var; 5496 5497 /* 5498 * Expanding this with NameBuff, expand_env() must not be passed IObuff. 5499 * Escape spaces when expanding 'tags', they are used to separate file 5500 * names. 5501 * For 'spellsuggest' expand after "file:". 5502 */ 5503 expand_env_esc(val, NameBuff, MAXPATHL, 5504 (char_u **)options[opt_idx].var == &p_tags, FALSE, 5505 #ifdef FEAT_SPELL 5506 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : 5507 #endif 5508 NULL); 5509 if (STRCMP(NameBuff, val) == 0) /* they are the same */ 5510 return NULL; 5511 5512 return NameBuff; 5513 } 5514 5515 /* 5516 * After setting various option values: recompute variables that depend on 5517 * option values. 5518 */ 5519 static void 5520 didset_options(void) 5521 { 5522 /* initialize the table for 'iskeyword' et.al. */ 5523 (void)init_chartab(); 5524 5525 #ifdef FEAT_MBYTE 5526 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE); 5527 #endif 5528 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE); 5529 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE); 5530 #ifdef FEAT_SESSION 5531 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE); 5532 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE); 5533 #endif 5534 #ifdef FEAT_FOLDING 5535 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE); 5536 #endif 5537 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE); 5538 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE); 5539 #ifdef FEAT_VIRTUALEDIT 5540 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE); 5541 #endif 5542 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS)) 5543 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE); 5544 #endif 5545 #ifdef FEAT_SPELL 5546 (void)spell_check_msm(); 5547 (void)spell_check_sps(); 5548 (void)compile_cap_prog(curwin->w_s); 5549 (void)did_set_spell_option(TRUE); 5550 #endif 5551 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 5552 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE); 5553 #endif 5554 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) 5555 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE); 5556 #endif 5557 #ifdef FEAT_CMDWIN 5558 /* set cedit_key */ 5559 (void)check_cedit(); 5560 #endif 5561 #ifdef FEAT_LINEBREAK 5562 briopt_check(curwin); 5563 #endif 5564 #ifdef FEAT_LINEBREAK 5565 /* initialize the table for 'breakat'. */ 5566 fill_breakat_flags(); 5567 #endif 5568 5569 } 5570 5571 /* 5572 * More side effects of setting options. 5573 */ 5574 static void 5575 didset_options2(void) 5576 { 5577 /* Initialize the highlight_attr[] table. */ 5578 (void)highlight_changed(); 5579 5580 /* Parse default for 'wildmode' */ 5581 check_opt_wim(); 5582 5583 (void)set_chars_option(&p_lcs); 5584 /* Parse default for 'fillchars'. */ 5585 (void)set_chars_option(&p_fcs); 5586 5587 #ifdef FEAT_CLIPBOARD 5588 /* Parse default for 'clipboard' */ 5589 (void)check_clipboard_option(); 5590 #endif 5591 } 5592 5593 /* 5594 * Check for string options that are NULL (normally only termcap options). 5595 */ 5596 void 5597 check_options(void) 5598 { 5599 int opt_idx; 5600 5601 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++) 5602 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL) 5603 check_string_option((char_u **)get_varp(&(options[opt_idx]))); 5604 } 5605 5606 /* 5607 * Check string options in a buffer for NULL value. 5608 */ 5609 void 5610 check_buf_options(buf_T *buf) 5611 { 5612 check_string_option(&buf->b_p_bh); 5613 check_string_option(&buf->b_p_bt); 5614 #ifdef FEAT_MBYTE 5615 check_string_option(&buf->b_p_fenc); 5616 #endif 5617 check_string_option(&buf->b_p_ff); 5618 #ifdef FEAT_FIND_ID 5619 check_string_option(&buf->b_p_def); 5620 check_string_option(&buf->b_p_inc); 5621 # ifdef FEAT_EVAL 5622 check_string_option(&buf->b_p_inex); 5623 # endif 5624 #endif 5625 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 5626 check_string_option(&buf->b_p_inde); 5627 check_string_option(&buf->b_p_indk); 5628 #endif 5629 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 5630 check_string_option(&buf->b_p_bexpr); 5631 #endif 5632 #if defined(FEAT_CRYPT) 5633 check_string_option(&buf->b_p_cm); 5634 #endif 5635 check_string_option(&buf->b_p_fp); 5636 #if defined(FEAT_EVAL) 5637 check_string_option(&buf->b_p_fex); 5638 #endif 5639 #ifdef FEAT_CRYPT 5640 check_string_option(&buf->b_p_key); 5641 #endif 5642 check_string_option(&buf->b_p_kp); 5643 check_string_option(&buf->b_p_mps); 5644 check_string_option(&buf->b_p_fo); 5645 check_string_option(&buf->b_p_flp); 5646 check_string_option(&buf->b_p_isk); 5647 #ifdef FEAT_COMMENTS 5648 check_string_option(&buf->b_p_com); 5649 #endif 5650 #ifdef FEAT_FOLDING 5651 check_string_option(&buf->b_p_cms); 5652 #endif 5653 check_string_option(&buf->b_p_nf); 5654 #ifdef FEAT_TEXTOBJ 5655 check_string_option(&buf->b_p_qe); 5656 #endif 5657 #ifdef FEAT_SYN_HL 5658 check_string_option(&buf->b_p_syn); 5659 check_string_option(&buf->b_s.b_syn_isk); 5660 #endif 5661 #ifdef FEAT_SPELL 5662 check_string_option(&buf->b_s.b_p_spc); 5663 check_string_option(&buf->b_s.b_p_spf); 5664 check_string_option(&buf->b_s.b_p_spl); 5665 #endif 5666 #ifdef FEAT_SEARCHPATH 5667 check_string_option(&buf->b_p_sua); 5668 #endif 5669 #ifdef FEAT_CINDENT 5670 check_string_option(&buf->b_p_cink); 5671 check_string_option(&buf->b_p_cino); 5672 parse_cino(buf); 5673 #endif 5674 #ifdef FEAT_AUTOCMD 5675 check_string_option(&buf->b_p_ft); 5676 #endif 5677 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 5678 check_string_option(&buf->b_p_cinw); 5679 #endif 5680 #ifdef FEAT_INS_EXPAND 5681 check_string_option(&buf->b_p_cpt); 5682 #endif 5683 #ifdef FEAT_COMPL_FUNC 5684 check_string_option(&buf->b_p_cfu); 5685 check_string_option(&buf->b_p_ofu); 5686 #endif 5687 #ifdef FEAT_KEYMAP 5688 check_string_option(&buf->b_p_keymap); 5689 #endif 5690 #ifdef FEAT_QUICKFIX 5691 check_string_option(&buf->b_p_gp); 5692 check_string_option(&buf->b_p_mp); 5693 check_string_option(&buf->b_p_efm); 5694 #endif 5695 check_string_option(&buf->b_p_ep); 5696 check_string_option(&buf->b_p_path); 5697 check_string_option(&buf->b_p_tags); 5698 check_string_option(&buf->b_p_tc); 5699 #ifdef FEAT_INS_EXPAND 5700 check_string_option(&buf->b_p_dict); 5701 check_string_option(&buf->b_p_tsr); 5702 #endif 5703 #ifdef FEAT_LISP 5704 check_string_option(&buf->b_p_lw); 5705 #endif 5706 check_string_option(&buf->b_p_bkc); 5707 #ifdef FEAT_MBYTE 5708 check_string_option(&buf->b_p_menc); 5709 #endif 5710 } 5711 5712 /* 5713 * Free the string allocated for an option. 5714 * Checks for the string being empty_option. This may happen if we're out of 5715 * memory, vim_strsave() returned NULL, which was replaced by empty_option by 5716 * check_options(). 5717 * Does NOT check for P_ALLOCED flag! 5718 */ 5719 void 5720 free_string_option(char_u *p) 5721 { 5722 if (p != empty_option) 5723 vim_free(p); 5724 } 5725 5726 void 5727 clear_string_option(char_u **pp) 5728 { 5729 if (*pp != empty_option) 5730 vim_free(*pp); 5731 *pp = empty_option; 5732 } 5733 5734 static void 5735 check_string_option(char_u **pp) 5736 { 5737 if (*pp == NULL) 5738 *pp = empty_option; 5739 } 5740 5741 /* 5742 * Mark a terminal option as allocated, found by a pointer into term_strings[]. 5743 */ 5744 void 5745 set_term_option_alloced(char_u **p) 5746 { 5747 int opt_idx; 5748 5749 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++) 5750 if (options[opt_idx].var == (char_u *)p) 5751 { 5752 options[opt_idx].flags |= P_ALLOCED; 5753 return; 5754 } 5755 return; /* cannot happen: didn't find it! */ 5756 } 5757 5758 #if defined(FEAT_EVAL) || defined(PROTO) 5759 /* 5760 * Return TRUE when option "opt" was set from a modeline or in secure mode. 5761 * Return FALSE when it wasn't. 5762 * Return -1 for an unknown option. 5763 */ 5764 int 5765 was_set_insecurely(char_u *opt, int opt_flags) 5766 { 5767 int idx = findoption(opt); 5768 long_u *flagp; 5769 5770 if (idx >= 0) 5771 { 5772 flagp = insecure_flag(idx, opt_flags); 5773 return (*flagp & P_INSECURE) != 0; 5774 } 5775 internal_error("was_set_insecurely()"); 5776 return -1; 5777 } 5778 5779 /* 5780 * Get a pointer to the flags used for the P_INSECURE flag of option 5781 * "opt_idx". For some local options a local flags field is used. 5782 */ 5783 static long_u * 5784 insecure_flag(int opt_idx, int opt_flags) 5785 { 5786 if (opt_flags & OPT_LOCAL) 5787 switch ((int)options[opt_idx].indir) 5788 { 5789 #ifdef FEAT_STL_OPT 5790 case PV_STL: return &curwin->w_p_stl_flags; 5791 #endif 5792 #ifdef FEAT_EVAL 5793 # ifdef FEAT_FOLDING 5794 case PV_FDE: return &curwin->w_p_fde_flags; 5795 case PV_FDT: return &curwin->w_p_fdt_flags; 5796 # endif 5797 # ifdef FEAT_BEVAL 5798 case PV_BEXPR: return &curbuf->b_p_bexpr_flags; 5799 # endif 5800 # if defined(FEAT_CINDENT) 5801 case PV_INDE: return &curbuf->b_p_inde_flags; 5802 # endif 5803 case PV_FEX: return &curbuf->b_p_fex_flags; 5804 # ifdef FEAT_FIND_ID 5805 case PV_INEX: return &curbuf->b_p_inex_flags; 5806 # endif 5807 #endif 5808 } 5809 5810 /* Nothing special, return global flags field. */ 5811 return &options[opt_idx].flags; 5812 } 5813 #endif 5814 5815 #ifdef FEAT_TITLE 5816 static void redraw_titles(void); 5817 5818 /* 5819 * Redraw the window title and/or tab page text later. 5820 */ 5821 static void redraw_titles(void) 5822 { 5823 need_maketitle = TRUE; 5824 redraw_tabline = TRUE; 5825 } 5826 #endif 5827 5828 /* 5829 * Set a string option to a new value (without checking the effect). 5830 * The string is copied into allocated memory. 5831 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used. 5832 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is 5833 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid". 5834 */ 5835 void 5836 set_string_option_direct( 5837 char_u *name, 5838 int opt_idx, 5839 char_u *val, 5840 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */ 5841 int set_sid UNUSED) 5842 { 5843 char_u *s; 5844 char_u **varp; 5845 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; 5846 int idx = opt_idx; 5847 5848 if (idx == -1) /* use name */ 5849 { 5850 idx = findoption(name); 5851 if (idx < 0) /* not found (should not happen) */ 5852 { 5853 EMSG2(_(e_intern2), "set_string_option_direct()"); 5854 IEMSG2(_("For option %s"), name); 5855 return; 5856 } 5857 } 5858 5859 if (options[idx].var == NULL) /* can't set hidden option */ 5860 return; 5861 5862 s = vim_strsave(val); 5863 if (s != NULL) 5864 { 5865 varp = (char_u **)get_varp_scope(&(options[idx]), 5866 both ? OPT_LOCAL : opt_flags); 5867 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED)) 5868 free_string_option(*varp); 5869 *varp = s; 5870 5871 /* For buffer/window local option may also set the global value. */ 5872 if (both) 5873 set_string_option_global(idx, varp); 5874 5875 options[idx].flags |= P_ALLOCED; 5876 5877 /* When setting both values of a global option with a local value, 5878 * make the local value empty, so that the global value is used. */ 5879 if (((int)options[idx].indir & PV_BOTH) && both) 5880 { 5881 free_string_option(*varp); 5882 *varp = empty_option; 5883 } 5884 # ifdef FEAT_EVAL 5885 if (set_sid != SID_NONE) 5886 set_option_scriptID_idx(idx, opt_flags, 5887 set_sid == 0 ? current_SID : set_sid); 5888 # endif 5889 } 5890 } 5891 5892 /* 5893 * Set global value for string option when it's a local option. 5894 */ 5895 static void 5896 set_string_option_global( 5897 int opt_idx, /* option index */ 5898 char_u **varp) /* pointer to option variable */ 5899 { 5900 char_u **p, *s; 5901 5902 /* the global value is always allocated */ 5903 if (options[opt_idx].var == VAR_WIN) 5904 p = (char_u **)GLOBAL_WO(varp); 5905 else 5906 p = (char_u **)options[opt_idx].var; 5907 if (options[opt_idx].indir != PV_NONE 5908 && p != varp 5909 && (s = vim_strsave(*varp)) != NULL) 5910 { 5911 free_string_option(*p); 5912 *p = s; 5913 } 5914 } 5915 5916 /* 5917 * Set a string option to a new value, and handle the effects. 5918 * 5919 * Returns NULL on success or error message on error. 5920 */ 5921 static char_u * 5922 set_string_option( 5923 int opt_idx, 5924 char_u *value, 5925 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ 5926 { 5927 char_u *s; 5928 char_u **varp; 5929 char_u *oldval; 5930 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5931 char_u *saved_oldval = NULL; 5932 char_u *saved_newval = NULL; 5933 #endif 5934 char_u *r = NULL; 5935 5936 if (options[opt_idx].var == NULL) /* don't set hidden option */ 5937 return NULL; 5938 5939 s = vim_strsave(value); 5940 if (s != NULL) 5941 { 5942 varp = (char_u **)get_varp_scope(&(options[opt_idx]), 5943 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 5944 ? (((int)options[opt_idx].indir & PV_BOTH) 5945 ? OPT_GLOBAL : OPT_LOCAL) 5946 : opt_flags); 5947 oldval = *varp; 5948 *varp = s; 5949 5950 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5951 if (!starting 5952 # ifdef FEAT_CRYPT 5953 && options[opt_idx].indir != PV_KEY 5954 # endif 5955 ) 5956 { 5957 saved_oldval = vim_strsave(oldval); 5958 saved_newval = vim_strsave(s); 5959 } 5960 #endif 5961 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL, 5962 opt_flags)) == NULL) 5963 did_set_option(opt_idx, opt_flags, TRUE); 5964 5965 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 5966 /* call autocommand after handling side effects */ 5967 if (r == NULL) 5968 trigger_optionsset_string(opt_idx, opt_flags, 5969 saved_oldval, saved_newval); 5970 vim_free(saved_oldval); 5971 vim_free(saved_newval); 5972 #endif 5973 } 5974 return r; 5975 } 5976 5977 #if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL) 5978 /* 5979 * Return TRUE if "val" is a valid 'filetype' name. 5980 * Also used for 'syntax' and 'keymap'. 5981 */ 5982 static int 5983 valid_filetype(char_u *val) 5984 { 5985 char_u *s; 5986 5987 for (s = val; *s != NUL; ++s) 5988 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL) 5989 return FALSE; 5990 return TRUE; 5991 } 5992 #endif 5993 5994 /* 5995 * Handle string options that need some action to perform when changed. 5996 * Returns NULL for success, or an error message for an error. 5997 */ 5998 static char_u * 5999 did_set_string_option( 6000 int opt_idx, /* index in options[] table */ 6001 char_u **varp, /* pointer to the option variable */ 6002 int new_value_alloced, /* new value was allocated */ 6003 char_u *oldval, /* previous value of the option */ 6004 char_u *errbuf, /* buffer for errors, or NULL */ 6005 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ 6006 { 6007 char_u *errmsg = NULL; 6008 char_u *s, *p; 6009 int did_chartab = FALSE; 6010 char_u **gvarp; 6011 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED); 6012 #ifdef FEAT_GUI 6013 /* set when changing an option that only requires a redraw in the GUI */ 6014 int redraw_gui_only = FALSE; 6015 #endif 6016 #ifdef FEAT_AUTOCMD 6017 int ft_changed = FALSE; 6018 #endif 6019 6020 /* Get the global option to compare with, otherwise we would have to check 6021 * two values for all local options. */ 6022 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL); 6023 6024 /* Disallow changing some options from secure mode */ 6025 if ((secure 6026 #ifdef HAVE_SANDBOX 6027 || sandbox != 0 6028 #endif 6029 ) && (options[opt_idx].flags & P_SECURE)) 6030 { 6031 errmsg = e_secure; 6032 } 6033 6034 /* Check for a "normal" directory or file name in some options. Disallow a 6035 * path separator (slash and/or backslash), wildcards and characters that 6036 * are often illegal in a file name. Be more permissive if "secure" is off. 6037 */ 6038 else if (((options[opt_idx].flags & P_NFNAME) 6039 && vim_strpbrk(*varp, (char_u *)(secure 6040 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL) 6041 || ((options[opt_idx].flags & P_NDNAME) 6042 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) 6043 { 6044 errmsg = e_invarg; 6045 } 6046 6047 /* 'term' */ 6048 else if (varp == &T_NAME) 6049 { 6050 if (T_NAME[0] == NUL) 6051 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string"); 6052 #ifdef FEAT_GUI 6053 if (gui.in_use) 6054 errmsg = (char_u *)N_("E530: Cannot change term in GUI"); 6055 else if (term_is_gui(T_NAME)) 6056 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI"); 6057 #endif 6058 else if (set_termname(T_NAME) == FAIL) 6059 errmsg = (char_u *)N_("E522: Not found in termcap"); 6060 else 6061 { 6062 /* Screen colors may have changed. */ 6063 redraw_later_clear(); 6064 6065 /* Both 'term' and 'ttytype' point to T_NAME, only set the 6066 * P_ALLOCED flag on 'term'. */ 6067 opt_idx = findoption((char_u *)"term"); 6068 free_oldval = (options[opt_idx].flags & P_ALLOCED); 6069 } 6070 } 6071 6072 /* 'backupcopy' */ 6073 else if (gvarp == &p_bkc) 6074 { 6075 char_u *bkc = p_bkc; 6076 unsigned int *flags = &bkc_flags; 6077 6078 if (opt_flags & OPT_LOCAL) 6079 { 6080 bkc = curbuf->b_p_bkc; 6081 flags = &curbuf->b_bkc_flags; 6082 } 6083 6084 if ((opt_flags & OPT_LOCAL) && *bkc == NUL) 6085 /* make the local value empty: use the global value */ 6086 *flags = 0; 6087 else 6088 { 6089 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK) 6090 errmsg = e_invarg; 6091 if ((((int)*flags & BKC_AUTO) != 0) 6092 + (((int)*flags & BKC_YES) != 0) 6093 + (((int)*flags & BKC_NO) != 0) != 1) 6094 { 6095 /* Must have exactly one of "auto", "yes" and "no". */ 6096 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE); 6097 errmsg = e_invarg; 6098 } 6099 } 6100 } 6101 6102 /* 'backupext' and 'patchmode' */ 6103 else if (varp == &p_bex || varp == &p_pm) 6104 { 6105 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex, 6106 *p_pm == '.' ? p_pm + 1 : p_pm) == 0) 6107 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal"); 6108 } 6109 #ifdef FEAT_LINEBREAK 6110 /* 'breakindentopt' */ 6111 else if (varp == &curwin->w_p_briopt) 6112 { 6113 if (briopt_check(curwin) == FAIL) 6114 errmsg = e_invarg; 6115 } 6116 #endif 6117 6118 /* 6119 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[] 6120 * If the new option is invalid, use old value. 'lisp' option: refill 6121 * g_chartab[] for '-' char 6122 */ 6123 else if ( varp == &p_isi 6124 || varp == &(curbuf->b_p_isk) 6125 || varp == &p_isp 6126 || varp == &p_isf) 6127 { 6128 if (init_chartab() == FAIL) 6129 { 6130 did_chartab = TRUE; /* need to restore it below */ 6131 errmsg = e_invarg; /* error in value */ 6132 } 6133 } 6134 6135 /* 'helpfile' */ 6136 else if (varp == &p_hf) 6137 { 6138 /* May compute new values for $VIM and $VIMRUNTIME */ 6139 if (didset_vim) 6140 { 6141 vim_setenv((char_u *)"VIM", (char_u *)""); 6142 didset_vim = FALSE; 6143 } 6144 if (didset_vimruntime) 6145 { 6146 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)""); 6147 didset_vimruntime = FALSE; 6148 } 6149 } 6150 6151 #ifdef FEAT_SYN_HL 6152 /* 'colorcolumn' */ 6153 else if (varp == &curwin->w_p_cc) 6154 errmsg = check_colorcolumn(curwin); 6155 #endif 6156 6157 #ifdef FEAT_MULTI_LANG 6158 /* 'helplang' */ 6159 else if (varp == &p_hlg) 6160 { 6161 /* Check for "", "ab", "ab,cd", etc. */ 6162 for (s = p_hlg; *s != NUL; s += 3) 6163 { 6164 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) 6165 { 6166 errmsg = e_invarg; 6167 break; 6168 } 6169 if (s[2] == NUL) 6170 break; 6171 } 6172 } 6173 #endif 6174 6175 /* 'highlight' */ 6176 else if (varp == &p_hl) 6177 { 6178 if (highlight_changed() == FAIL) 6179 errmsg = e_invarg; /* invalid flags */ 6180 } 6181 6182 /* 'nrformats' */ 6183 else if (gvarp == &p_nf) 6184 { 6185 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK) 6186 errmsg = e_invarg; 6187 } 6188 6189 #ifdef FEAT_SESSION 6190 /* 'sessionoptions' */ 6191 else if (varp == &p_ssop) 6192 { 6193 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK) 6194 errmsg = e_invarg; 6195 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) 6196 { 6197 /* Don't allow both "sesdir" and "curdir". */ 6198 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE); 6199 errmsg = e_invarg; 6200 } 6201 } 6202 /* 'viewoptions' */ 6203 else if (varp == &p_vop) 6204 { 6205 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK) 6206 errmsg = e_invarg; 6207 } 6208 #endif 6209 6210 /* 'scrollopt' */ 6211 #ifdef FEAT_SCROLLBIND 6212 else if (varp == &p_sbo) 6213 { 6214 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK) 6215 errmsg = e_invarg; 6216 } 6217 #endif 6218 6219 /* 'ambiwidth' */ 6220 #ifdef FEAT_MBYTE 6221 else if (varp == &p_ambw || varp == &p_emoji) 6222 { 6223 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK) 6224 errmsg = e_invarg; 6225 else if (set_chars_option(&p_lcs) != NULL) 6226 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'"); 6227 else if (set_chars_option(&p_fcs) != NULL) 6228 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'"); 6229 } 6230 #endif 6231 6232 /* 'background' */ 6233 else if (varp == &p_bg) 6234 { 6235 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK) 6236 { 6237 #ifdef FEAT_EVAL 6238 int dark = (*p_bg == 'd'); 6239 #endif 6240 6241 init_highlight(FALSE, FALSE); 6242 6243 #ifdef FEAT_EVAL 6244 if (dark != (*p_bg == 'd') 6245 && get_var_value((char_u *)"g:colors_name") != NULL) 6246 { 6247 /* The color scheme must have set 'background' back to another 6248 * value, that's not what we want here. Disable the color 6249 * scheme and set the colors again. */ 6250 do_unlet((char_u *)"g:colors_name", TRUE); 6251 free_string_option(p_bg); 6252 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light")); 6253 check_string_option(&p_bg); 6254 init_highlight(FALSE, FALSE); 6255 } 6256 #endif 6257 } 6258 else 6259 errmsg = e_invarg; 6260 } 6261 6262 /* 'wildmode' */ 6263 else if (varp == &p_wim) 6264 { 6265 if (check_opt_wim() == FAIL) 6266 errmsg = e_invarg; 6267 } 6268 6269 #ifdef FEAT_CMDL_COMPL 6270 /* 'wildoptions' */ 6271 else if (varp == &p_wop) 6272 { 6273 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK) 6274 errmsg = e_invarg; 6275 } 6276 #endif 6277 6278 #ifdef FEAT_WAK 6279 /* 'winaltkeys' */ 6280 else if (varp == &p_wak) 6281 { 6282 if (*p_wak == NUL 6283 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK) 6284 errmsg = e_invarg; 6285 # ifdef FEAT_MENU 6286 # ifdef FEAT_GUI_MOTIF 6287 else if (gui.in_use) 6288 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); 6289 # else 6290 # ifdef FEAT_GUI_GTK 6291 else if (gui.in_use) 6292 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm'); 6293 # endif 6294 # endif 6295 # endif 6296 } 6297 #endif 6298 6299 #ifdef FEAT_AUTOCMD 6300 /* 'eventignore' */ 6301 else if (varp == &p_ei) 6302 { 6303 if (check_ei() == FAIL) 6304 errmsg = e_invarg; 6305 } 6306 #endif 6307 6308 #ifdef FEAT_MBYTE 6309 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */ 6310 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc 6311 || gvarp == &p_menc) 6312 { 6313 if (gvarp == &p_fenc) 6314 { 6315 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL) 6316 errmsg = e_modifiable; 6317 else if (vim_strchr(*varp, ',') != NULL) 6318 /* No comma allowed in 'fileencoding'; catches confusing it 6319 * with 'fileencodings'. */ 6320 errmsg = e_invarg; 6321 else 6322 { 6323 # ifdef FEAT_TITLE 6324 /* May show a "+" in the title now. */ 6325 redraw_titles(); 6326 # endif 6327 /* Add 'fileencoding' to the swap file. */ 6328 ml_setflags(curbuf); 6329 } 6330 } 6331 if (errmsg == NULL) 6332 { 6333 /* canonize the value, so that STRCMP() can be used on it */ 6334 p = enc_canonize(*varp); 6335 if (p != NULL) 6336 { 6337 vim_free(*varp); 6338 *varp = p; 6339 } 6340 if (varp == &p_enc) 6341 { 6342 errmsg = mb_init(); 6343 # ifdef FEAT_TITLE 6344 redraw_titles(); 6345 # endif 6346 } 6347 } 6348 6349 # if defined(FEAT_GUI_GTK) 6350 if (errmsg == NULL && varp == &p_tenc && gui.in_use) 6351 { 6352 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */ 6353 if (STRCMP(p_tenc, "utf-8") != 0) 6354 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI"); 6355 } 6356 # endif 6357 6358 if (errmsg == NULL) 6359 { 6360 # ifdef FEAT_KEYMAP 6361 /* When 'keymap' is used and 'encoding' changes, reload the keymap 6362 * (with another encoding). */ 6363 if (varp == &p_enc && *curbuf->b_p_keymap != NUL) 6364 (void)keymap_init(); 6365 # endif 6366 6367 /* When 'termencoding' is not empty and 'encoding' changes or when 6368 * 'termencoding' changes, need to setup for keyboard input and 6369 * display output conversion. */ 6370 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc)) 6371 { 6372 if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL 6373 || convert_setup(&output_conv, p_enc, p_tenc) == FAIL) 6374 { 6375 EMSG3(_("E950: Cannot convert between %s and %s"), 6376 p_tenc, p_enc); 6377 errmsg = e_invarg; 6378 } 6379 } 6380 6381 # if defined(WIN3264) && defined(FEAT_MBYTE) 6382 /* $HOME may have characters in active code page. */ 6383 if (varp == &p_enc) 6384 init_homedir(); 6385 # endif 6386 } 6387 } 6388 #endif 6389 6390 #if defined(FEAT_POSTSCRIPT) 6391 else if (varp == &p_penc) 6392 { 6393 /* Canonize printencoding if VIM standard one */ 6394 p = enc_canonize(p_penc); 6395 if (p != NULL) 6396 { 6397 vim_free(p_penc); 6398 p_penc = p; 6399 } 6400 else 6401 { 6402 /* Ensure lower case and '-' for '_' */ 6403 for (s = p_penc; *s != NUL; s++) 6404 { 6405 if (*s == '_') 6406 *s = '-'; 6407 else 6408 *s = TOLOWER_ASC(*s); 6409 } 6410 } 6411 } 6412 #endif 6413 6414 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 6415 else if (varp == &p_imak) 6416 { 6417 if (!im_xim_isvalid_imactivate()) 6418 errmsg = e_invarg; 6419 } 6420 #endif 6421 6422 #ifdef FEAT_KEYMAP 6423 else if (varp == &curbuf->b_p_keymap) 6424 { 6425 if (!valid_filetype(*varp)) 6426 errmsg = e_invarg; 6427 else 6428 /* load or unload key mapping tables */ 6429 errmsg = keymap_init(); 6430 6431 if (errmsg == NULL) 6432 { 6433 if (*curbuf->b_p_keymap != NUL) 6434 { 6435 /* Installed a new keymap, switch on using it. */ 6436 curbuf->b_p_iminsert = B_IMODE_LMAP; 6437 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT) 6438 curbuf->b_p_imsearch = B_IMODE_LMAP; 6439 } 6440 else 6441 { 6442 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */ 6443 if (curbuf->b_p_iminsert == B_IMODE_LMAP) 6444 curbuf->b_p_iminsert = B_IMODE_NONE; 6445 if (curbuf->b_p_imsearch == B_IMODE_LMAP) 6446 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; 6447 } 6448 if ((opt_flags & OPT_LOCAL) == 0) 6449 { 6450 set_iminsert_global(); 6451 set_imsearch_global(); 6452 } 6453 status_redraw_curbuf(); 6454 } 6455 } 6456 #endif 6457 6458 /* 'fileformat' */ 6459 else if (gvarp == &p_ff) 6460 { 6461 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL)) 6462 errmsg = e_modifiable; 6463 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK) 6464 errmsg = e_invarg; 6465 else 6466 { 6467 /* may also change 'textmode' */ 6468 if (get_fileformat(curbuf) == EOL_DOS) 6469 curbuf->b_p_tx = TRUE; 6470 else 6471 curbuf->b_p_tx = FALSE; 6472 #ifdef FEAT_TITLE 6473 redraw_titles(); 6474 #endif 6475 /* update flag in swap file */ 6476 ml_setflags(curbuf); 6477 /* Redraw needed when switching to/from "mac": a CR in the text 6478 * will be displayed differently. */ 6479 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm') 6480 redraw_curbuf_later(NOT_VALID); 6481 } 6482 } 6483 6484 /* 'fileformats' */ 6485 else if (varp == &p_ffs) 6486 { 6487 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK) 6488 errmsg = e_invarg; 6489 else 6490 { 6491 /* also change 'textauto' */ 6492 if (*p_ffs == NUL) 6493 p_ta = FALSE; 6494 else 6495 p_ta = TRUE; 6496 } 6497 } 6498 6499 #if defined(FEAT_CRYPT) 6500 /* 'cryptkey' */ 6501 else if (gvarp == &p_key) 6502 { 6503 # if defined(FEAT_CMDHIST) 6504 /* Make sure the ":set" command doesn't show the new value in the 6505 * history. */ 6506 remove_key_from_history(); 6507 # endif 6508 if (STRCMP(curbuf->b_p_key, oldval) != 0) 6509 /* Need to update the swapfile. */ 6510 ml_set_crypt_key(curbuf, oldval, 6511 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm); 6512 } 6513 6514 else if (gvarp == &p_cm) 6515 { 6516 if (opt_flags & OPT_LOCAL) 6517 p = curbuf->b_p_cm; 6518 else 6519 p = p_cm; 6520 if (check_opt_strings(p, p_cm_values, TRUE) != OK) 6521 errmsg = e_invarg; 6522 else if (crypt_self_test() == FAIL) 6523 errmsg = e_invarg; 6524 else 6525 { 6526 /* When setting the global value to empty, make it "zip". */ 6527 if (*p_cm == NUL) 6528 { 6529 if (new_value_alloced) 6530 free_string_option(p_cm); 6531 p_cm = vim_strsave((char_u *)"zip"); 6532 new_value_alloced = TRUE; 6533 } 6534 /* When using ":set cm=name" the local value is going to be empty. 6535 * Do that here, otherwise the crypt functions will still use the 6536 * local value. */ 6537 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) 6538 { 6539 free_string_option(curbuf->b_p_cm); 6540 curbuf->b_p_cm = empty_option; 6541 } 6542 6543 /* Need to update the swapfile when the effective method changed. 6544 * Set "s" to the effective old value, "p" to the effective new 6545 * method and compare. */ 6546 if ((opt_flags & OPT_LOCAL) && *oldval == NUL) 6547 s = p_cm; /* was previously using the global value */ 6548 else 6549 s = oldval; 6550 if (*curbuf->b_p_cm == NUL) 6551 p = p_cm; /* is now using the global value */ 6552 else 6553 p = curbuf->b_p_cm; 6554 if (STRCMP(s, p) != 0) 6555 ml_set_crypt_key(curbuf, curbuf->b_p_key, s); 6556 6557 /* If the global value changes need to update the swapfile for all 6558 * buffers using that value. */ 6559 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0) 6560 { 6561 buf_T *buf; 6562 6563 FOR_ALL_BUFFERS(buf) 6564 if (buf != curbuf && *buf->b_p_cm == NUL) 6565 ml_set_crypt_key(buf, buf->b_p_key, oldval); 6566 } 6567 } 6568 } 6569 #endif 6570 6571 /* 'matchpairs' */ 6572 else if (gvarp == &p_mps) 6573 { 6574 #ifdef FEAT_MBYTE 6575 if (has_mbyte) 6576 { 6577 for (p = *varp; *p != NUL; ++p) 6578 { 6579 int x2 = -1; 6580 int x3 = -1; 6581 6582 if (*p != NUL) 6583 p += mb_ptr2len(p); 6584 if (*p != NUL) 6585 x2 = *p++; 6586 if (*p != NUL) 6587 { 6588 x3 = mb_ptr2char(p); 6589 p += mb_ptr2len(p); 6590 } 6591 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ',')) 6592 { 6593 errmsg = e_invarg; 6594 break; 6595 } 6596 if (*p == NUL) 6597 break; 6598 } 6599 } 6600 else 6601 #endif 6602 { 6603 /* Check for "x:y,x:y" */ 6604 for (p = *varp; *p != NUL; p += 4) 6605 { 6606 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ',')) 6607 { 6608 errmsg = e_invarg; 6609 break; 6610 } 6611 if (p[3] == NUL) 6612 break; 6613 } 6614 } 6615 } 6616 6617 #ifdef FEAT_COMMENTS 6618 /* 'comments' */ 6619 else if (gvarp == &p_com) 6620 { 6621 for (s = *varp; *s; ) 6622 { 6623 while (*s && *s != ':') 6624 { 6625 if (vim_strchr((char_u *)COM_ALL, *s) == NULL 6626 && !VIM_ISDIGIT(*s) && *s != '-') 6627 { 6628 errmsg = illegal_char(errbuf, *s); 6629 break; 6630 } 6631 ++s; 6632 } 6633 if (*s++ == NUL) 6634 errmsg = (char_u *)N_("E524: Missing colon"); 6635 else if (*s == ',' || *s == NUL) 6636 errmsg = (char_u *)N_("E525: Zero length string"); 6637 if (errmsg != NULL) 6638 break; 6639 while (*s && *s != ',') 6640 { 6641 if (*s == '\\' && s[1] != NUL) 6642 ++s; 6643 ++s; 6644 } 6645 s = skip_to_option_part(s); 6646 } 6647 } 6648 #endif 6649 6650 /* 'listchars' */ 6651 else if (varp == &p_lcs) 6652 { 6653 errmsg = set_chars_option(varp); 6654 } 6655 6656 /* 'fillchars' */ 6657 else if (varp == &p_fcs) 6658 { 6659 errmsg = set_chars_option(varp); 6660 } 6661 6662 #ifdef FEAT_CMDWIN 6663 /* 'cedit' */ 6664 else if (varp == &p_cedit) 6665 { 6666 errmsg = check_cedit(); 6667 } 6668 #endif 6669 6670 /* 'verbosefile' */ 6671 else if (varp == &p_vfile) 6672 { 6673 verbose_stop(); 6674 if (*p_vfile != NUL && verbose_open() == FAIL) 6675 errmsg = e_invarg; 6676 } 6677 6678 #ifdef FEAT_VIMINFO 6679 /* 'viminfo' */ 6680 else if (varp == &p_viminfo) 6681 { 6682 for (s = p_viminfo; *s;) 6683 { 6684 /* Check it's a valid character */ 6685 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) 6686 { 6687 errmsg = illegal_char(errbuf, *s); 6688 break; 6689 } 6690 if (*s == 'n') /* name is always last one */ 6691 { 6692 break; 6693 } 6694 else if (*s == 'r') /* skip until next ',' */ 6695 { 6696 while (*++s && *s != ',') 6697 ; 6698 } 6699 else if (*s == '%') 6700 { 6701 /* optional number */ 6702 while (vim_isdigit(*++s)) 6703 ; 6704 } 6705 else if (*s == '!' || *s == 'h' || *s == 'c') 6706 ++s; /* no extra chars */ 6707 else /* must have a number */ 6708 { 6709 while (vim_isdigit(*++s)) 6710 ; 6711 6712 if (!VIM_ISDIGIT(*(s - 1))) 6713 { 6714 if (errbuf != NULL) 6715 { 6716 sprintf((char *)errbuf, 6717 _("E526: Missing number after <%s>"), 6718 transchar_byte(*(s - 1))); 6719 errmsg = errbuf; 6720 } 6721 else 6722 errmsg = (char_u *)""; 6723 break; 6724 } 6725 } 6726 if (*s == ',') 6727 ++s; 6728 else if (*s) 6729 { 6730 if (errbuf != NULL) 6731 errmsg = (char_u *)N_("E527: Missing comma"); 6732 else 6733 errmsg = (char_u *)""; 6734 break; 6735 } 6736 } 6737 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0) 6738 errmsg = (char_u *)N_("E528: Must specify a ' value"); 6739 } 6740 #endif /* FEAT_VIMINFO */ 6741 6742 /* terminal options */ 6743 else if (istermoption(&options[opt_idx]) && full_screen) 6744 { 6745 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */ 6746 if (varp == &T_CCO) 6747 { 6748 int colors = atoi((char *)T_CCO); 6749 6750 /* Only reinitialize colors if t_Co value has really changed to 6751 * avoid expensive reload of colorscheme if t_Co is set to the 6752 * same value multiple times. */ 6753 if (colors != t_colors) 6754 { 6755 t_colors = colors; 6756 if (t_colors <= 1) 6757 { 6758 if (new_value_alloced) 6759 vim_free(T_CCO); 6760 T_CCO = empty_option; 6761 } 6762 /* We now have a different color setup, initialize it again. */ 6763 init_highlight(TRUE, FALSE); 6764 } 6765 } 6766 ttest(FALSE); 6767 if (varp == &T_ME) 6768 { 6769 out_str(T_ME); 6770 redraw_later(CLEAR); 6771 #if defined(WIN3264) && !defined(FEAT_GUI_W32) 6772 /* Since t_me has been set, this probably means that the user 6773 * wants to use this as default colors. Need to reset default 6774 * background/foreground colors. */ 6775 mch_set_normal_colors(); 6776 #endif 6777 } 6778 if (varp == &T_BE && termcap_active) 6779 { 6780 if (*T_BE == NUL) 6781 /* When clearing t_BE we assume the user no longer wants 6782 * bracketed paste, thus disable it by writing t_BD. */ 6783 out_str(T_BD); 6784 else 6785 out_str(T_BE); 6786 } 6787 } 6788 6789 #ifdef FEAT_LINEBREAK 6790 /* 'showbreak' */ 6791 else if (varp == &p_sbr) 6792 { 6793 for (s = p_sbr; *s; ) 6794 { 6795 if (ptr2cells(s) != 1) 6796 errmsg = (char_u *)N_("E595: contains unprintable or wide character"); 6797 MB_PTR_ADV(s); 6798 } 6799 } 6800 #endif 6801 6802 #ifdef FEAT_GUI 6803 /* 'guifont' */ 6804 else if (varp == &p_guifont) 6805 { 6806 if (gui.in_use) 6807 { 6808 p = p_guifont; 6809 # if defined(FEAT_GUI_GTK) 6810 /* 6811 * Put up a font dialog and let the user select a new value. 6812 * If this is cancelled go back to the old value but don't 6813 * give an error message. 6814 */ 6815 if (STRCMP(p, "*") == 0) 6816 { 6817 p = gui_mch_font_dialog(oldval); 6818 6819 if (new_value_alloced) 6820 free_string_option(p_guifont); 6821 6822 p_guifont = (p != NULL) ? p : vim_strsave(oldval); 6823 new_value_alloced = TRUE; 6824 } 6825 # endif 6826 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK) 6827 { 6828 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON) 6829 if (STRCMP(p_guifont, "*") == 0) 6830 { 6831 /* Dialog was cancelled: Keep the old value without giving 6832 * an error message. */ 6833 if (new_value_alloced) 6834 free_string_option(p_guifont); 6835 p_guifont = vim_strsave(oldval); 6836 new_value_alloced = TRUE; 6837 } 6838 else 6839 # endif 6840 errmsg = (char_u *)N_("E596: Invalid font(s)"); 6841 } 6842 } 6843 redraw_gui_only = TRUE; 6844 } 6845 # ifdef FEAT_XFONTSET 6846 else if (varp == &p_guifontset) 6847 { 6848 if (STRCMP(p_guifontset, "*") == 0) 6849 errmsg = (char_u *)N_("E597: can't select fontset"); 6850 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK) 6851 errmsg = (char_u *)N_("E598: Invalid fontset"); 6852 redraw_gui_only = TRUE; 6853 } 6854 # endif 6855 # ifdef FEAT_MBYTE 6856 else if (varp == &p_guifontwide) 6857 { 6858 if (STRCMP(p_guifontwide, "*") == 0) 6859 errmsg = (char_u *)N_("E533: can't select wide font"); 6860 else if (gui_get_wide_font() == FAIL) 6861 errmsg = (char_u *)N_("E534: Invalid wide font"); 6862 redraw_gui_only = TRUE; 6863 } 6864 # endif 6865 #endif 6866 6867 #ifdef CURSOR_SHAPE 6868 /* 'guicursor' */ 6869 else if (varp == &p_guicursor) 6870 errmsg = parse_shape_opt(SHAPE_CURSOR); 6871 #endif 6872 6873 #ifdef FEAT_MOUSESHAPE 6874 /* 'mouseshape' */ 6875 else if (varp == &p_mouseshape) 6876 { 6877 errmsg = parse_shape_opt(SHAPE_MOUSE); 6878 update_mouseshape(-1); 6879 } 6880 #endif 6881 6882 #ifdef FEAT_PRINTER 6883 else if (varp == &p_popt) 6884 errmsg = parse_printoptions(); 6885 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT) 6886 else if (varp == &p_pmfn) 6887 errmsg = parse_printmbfont(); 6888 # endif 6889 #endif 6890 6891 #ifdef FEAT_LANGMAP 6892 /* 'langmap' */ 6893 else if (varp == &p_langmap) 6894 langmap_set(); 6895 #endif 6896 6897 #ifdef FEAT_LINEBREAK 6898 /* 'breakat' */ 6899 else if (varp == &p_breakat) 6900 fill_breakat_flags(); 6901 #endif 6902 6903 #ifdef FEAT_TITLE 6904 /* 'titlestring' and 'iconstring' */ 6905 else if (varp == &p_titlestring || varp == &p_iconstring) 6906 { 6907 # ifdef FEAT_STL_OPT 6908 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON; 6909 6910 /* NULL => statusline syntax */ 6911 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) 6912 stl_syntax |= flagval; 6913 else 6914 stl_syntax &= ~flagval; 6915 # endif 6916 did_set_title(varp == &p_iconstring); 6917 6918 } 6919 #endif 6920 6921 #ifdef FEAT_GUI 6922 /* 'guioptions' */ 6923 else if (varp == &p_go) 6924 { 6925 gui_init_which_components(oldval); 6926 redraw_gui_only = TRUE; 6927 } 6928 #endif 6929 6930 #if defined(FEAT_GUI_TABLINE) 6931 /* 'guitablabel' */ 6932 else if (varp == &p_gtl) 6933 { 6934 redraw_tabline = TRUE; 6935 redraw_gui_only = TRUE; 6936 } 6937 /* 'guitabtooltip' */ 6938 else if (varp == &p_gtt) 6939 { 6940 redraw_gui_only = TRUE; 6941 } 6942 #endif 6943 6944 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS)) 6945 /* 'ttymouse' */ 6946 else if (varp == &p_ttym) 6947 { 6948 /* Switch the mouse off before changing the escape sequences used for 6949 * that. */ 6950 mch_setmouse(FALSE); 6951 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK) 6952 errmsg = e_invarg; 6953 else 6954 check_mouse_termcode(); 6955 if (termcap_active) 6956 setmouse(); /* may switch it on again */ 6957 } 6958 #endif 6959 6960 /* 'selection' */ 6961 else if (varp == &p_sel) 6962 { 6963 if (*p_sel == NUL 6964 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK) 6965 errmsg = e_invarg; 6966 } 6967 6968 /* 'selectmode' */ 6969 else if (varp == &p_slm) 6970 { 6971 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK) 6972 errmsg = e_invarg; 6973 } 6974 6975 #ifdef FEAT_BROWSE 6976 /* 'browsedir' */ 6977 else if (varp == &p_bsdir) 6978 { 6979 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK 6980 && !mch_isdir(p_bsdir)) 6981 errmsg = e_invarg; 6982 } 6983 #endif 6984 6985 /* 'keymodel' */ 6986 else if (varp == &p_km) 6987 { 6988 if (check_opt_strings(p_km, p_km_values, TRUE) != OK) 6989 errmsg = e_invarg; 6990 else 6991 { 6992 km_stopsel = (vim_strchr(p_km, 'o') != NULL); 6993 km_startsel = (vim_strchr(p_km, 'a') != NULL); 6994 } 6995 } 6996 6997 /* 'mousemodel' */ 6998 else if (varp == &p_mousem) 6999 { 7000 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK) 7001 errmsg = e_invarg; 7002 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002) 7003 else if (*p_mousem != *oldval) 7004 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need 7005 * to create or delete the popup menus. */ 7006 gui_motif_update_mousemodel(root_menu); 7007 #endif 7008 } 7009 7010 /* 'switchbuf' */ 7011 else if (varp == &p_swb) 7012 { 7013 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK) 7014 errmsg = e_invarg; 7015 } 7016 7017 /* 'debug' */ 7018 else if (varp == &p_debug) 7019 { 7020 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK) 7021 errmsg = e_invarg; 7022 } 7023 7024 /* 'display' */ 7025 else if (varp == &p_dy) 7026 { 7027 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK) 7028 errmsg = e_invarg; 7029 else 7030 (void)init_chartab(); 7031 7032 } 7033 7034 /* 'eadirection' */ 7035 else if (varp == &p_ead) 7036 { 7037 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK) 7038 errmsg = e_invarg; 7039 } 7040 7041 #ifdef FEAT_CLIPBOARD 7042 /* 'clipboard' */ 7043 else if (varp == &p_cb) 7044 errmsg = check_clipboard_option(); 7045 #endif 7046 7047 #ifdef FEAT_SPELL 7048 /* When 'spelllang' or 'spellfile' is set and there is a window for this 7049 * buffer in which 'spell' is set load the wordlists. */ 7050 else if (varp == &(curwin->w_s->b_p_spl) 7051 || varp == &(curwin->w_s->b_p_spf)) 7052 { 7053 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf)); 7054 } 7055 /* When 'spellcapcheck' is set compile the regexp program. */ 7056 else if (varp == &(curwin->w_s->b_p_spc)) 7057 { 7058 errmsg = compile_cap_prog(curwin->w_s); 7059 } 7060 /* 'spellsuggest' */ 7061 else if (varp == &p_sps) 7062 { 7063 if (spell_check_sps() != OK) 7064 errmsg = e_invarg; 7065 } 7066 /* 'mkspellmem' */ 7067 else if (varp == &p_msm) 7068 { 7069 if (spell_check_msm() != OK) 7070 errmsg = e_invarg; 7071 } 7072 #endif 7073 7074 /* When 'bufhidden' is set, check for valid value. */ 7075 else if (gvarp == &p_bh) 7076 { 7077 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK) 7078 errmsg = e_invarg; 7079 } 7080 7081 /* When 'buftype' is set, check for valid value. */ 7082 else if (gvarp == &p_bt) 7083 { 7084 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK) 7085 errmsg = e_invarg; 7086 else 7087 { 7088 if (curwin->w_status_height) 7089 { 7090 curwin->w_redr_status = TRUE; 7091 redraw_later(VALID); 7092 } 7093 curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); 7094 #ifdef FEAT_TITLE 7095 redraw_titles(); 7096 #endif 7097 } 7098 } 7099 7100 #ifdef FEAT_STL_OPT 7101 /* 'statusline' or 'rulerformat' */ 7102 else if (gvarp == &p_stl || varp == &p_ruf) 7103 { 7104 int wid; 7105 7106 if (varp == &p_ruf) /* reset ru_wid first */ 7107 ru_wid = 0; 7108 s = *varp; 7109 if (varp == &p_ruf && *s == '%') 7110 { 7111 /* set ru_wid if 'ruf' starts with "%99(" */ 7112 if (*++s == '-') /* ignore a '-' */ 7113 s++; 7114 wid = getdigits(&s); 7115 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL) 7116 ru_wid = wid; 7117 else 7118 errmsg = check_stl_option(p_ruf); 7119 } 7120 /* check 'statusline' only if it doesn't start with "%!" */ 7121 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') 7122 errmsg = check_stl_option(s); 7123 if (varp == &p_ruf && errmsg == NULL) 7124 comp_col(); 7125 } 7126 #endif 7127 7128 #ifdef FEAT_INS_EXPAND 7129 /* check if it is a valid value for 'complete' -- Acevedo */ 7130 else if (gvarp == &p_cpt) 7131 { 7132 for (s = *varp; *s;) 7133 { 7134 while (*s == ',' || *s == ' ') 7135 s++; 7136 if (!*s) 7137 break; 7138 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) 7139 { 7140 errmsg = illegal_char(errbuf, *s); 7141 break; 7142 } 7143 if (*++s != NUL && *s != ',' && *s != ' ') 7144 { 7145 if (s[-1] == 'k' || s[-1] == 's') 7146 { 7147 /* skip optional filename after 'k' and 's' */ 7148 while (*s && *s != ',' && *s != ' ') 7149 { 7150 if (*s == '\\' && s[1] != NUL) 7151 ++s; 7152 ++s; 7153 } 7154 } 7155 else 7156 { 7157 if (errbuf != NULL) 7158 { 7159 sprintf((char *)errbuf, 7160 _("E535: Illegal character after <%c>"), 7161 *--s); 7162 errmsg = errbuf; 7163 } 7164 else 7165 errmsg = (char_u *)""; 7166 break; 7167 } 7168 } 7169 } 7170 } 7171 7172 /* 'completeopt' */ 7173 else if (varp == &p_cot) 7174 { 7175 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK) 7176 errmsg = e_invarg; 7177 else 7178 completeopt_was_set(); 7179 } 7180 #endif /* FEAT_INS_EXPAND */ 7181 7182 #ifdef FEAT_SIGNS 7183 /* 'signcolumn' */ 7184 else if (varp == &curwin->w_p_scl) 7185 { 7186 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK) 7187 errmsg = e_invarg; 7188 } 7189 #endif 7190 7191 7192 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) 7193 /* 'toolbar' */ 7194 else if (varp == &p_toolbar) 7195 { 7196 if (opt_strings_flags(p_toolbar, p_toolbar_values, 7197 &toolbar_flags, TRUE) != OK) 7198 errmsg = e_invarg; 7199 else 7200 { 7201 out_flush(); 7202 gui_mch_show_toolbar((toolbar_flags & 7203 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); 7204 } 7205 } 7206 #endif 7207 7208 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) 7209 /* 'toolbariconsize': GTK+ 2 only */ 7210 else if (varp == &p_tbis) 7211 { 7212 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK) 7213 errmsg = e_invarg; 7214 else 7215 { 7216 out_flush(); 7217 gui_mch_show_toolbar((toolbar_flags & 7218 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0); 7219 } 7220 } 7221 #endif 7222 7223 /* 'pastetoggle': translate key codes like in a mapping */ 7224 else if (varp == &p_pt) 7225 { 7226 if (*p_pt) 7227 { 7228 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE); 7229 if (p != NULL) 7230 { 7231 if (new_value_alloced) 7232 free_string_option(p_pt); 7233 p_pt = p; 7234 new_value_alloced = TRUE; 7235 } 7236 } 7237 } 7238 7239 /* 'backspace' */ 7240 else if (varp == &p_bs) 7241 { 7242 if (VIM_ISDIGIT(*p_bs)) 7243 { 7244 if (*p_bs > '2' || p_bs[1] != NUL) 7245 errmsg = e_invarg; 7246 } 7247 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK) 7248 errmsg = e_invarg; 7249 } 7250 else if (varp == &p_bo) 7251 { 7252 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK) 7253 errmsg = e_invarg; 7254 } 7255 7256 /* 'tagcase' */ 7257 else if (gvarp == &p_tc) 7258 { 7259 unsigned int *flags; 7260 7261 if (opt_flags & OPT_LOCAL) 7262 { 7263 p = curbuf->b_p_tc; 7264 flags = &curbuf->b_tc_flags; 7265 } 7266 else 7267 { 7268 p = p_tc; 7269 flags = &tc_flags; 7270 } 7271 7272 if ((opt_flags & OPT_LOCAL) && *p == NUL) 7273 /* make the local value empty: use the global value */ 7274 *flags = 0; 7275 else if (*p == NUL 7276 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK) 7277 errmsg = e_invarg; 7278 } 7279 7280 #ifdef FEAT_MBYTE 7281 /* 'casemap' */ 7282 else if (varp == &p_cmp) 7283 { 7284 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK) 7285 errmsg = e_invarg; 7286 } 7287 #endif 7288 7289 #ifdef FEAT_DIFF 7290 /* 'diffopt' */ 7291 else if (varp == &p_dip) 7292 { 7293 if (diffopt_changed() == FAIL) 7294 errmsg = e_invarg; 7295 } 7296 #endif 7297 7298 #ifdef FEAT_FOLDING 7299 /* 'foldmethod' */ 7300 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm) 7301 { 7302 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK 7303 || *curwin->w_p_fdm == NUL) 7304 errmsg = e_invarg; 7305 else 7306 { 7307 foldUpdateAll(curwin); 7308 if (foldmethodIsDiff(curwin)) 7309 newFoldLevel(); 7310 } 7311 } 7312 # ifdef FEAT_EVAL 7313 /* 'foldexpr' */ 7314 else if (varp == &curwin->w_p_fde) 7315 { 7316 if (foldmethodIsExpr(curwin)) 7317 foldUpdateAll(curwin); 7318 } 7319 # endif 7320 /* 'foldmarker' */ 7321 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr) 7322 { 7323 p = vim_strchr(*varp, ','); 7324 if (p == NULL) 7325 errmsg = (char_u *)N_("E536: comma required"); 7326 else if (p == *varp || p[1] == NUL) 7327 errmsg = e_invarg; 7328 else if (foldmethodIsMarker(curwin)) 7329 foldUpdateAll(curwin); 7330 } 7331 /* 'commentstring' */ 7332 else if (gvarp == &p_cms) 7333 { 7334 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL) 7335 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s"); 7336 } 7337 /* 'foldopen' */ 7338 else if (varp == &p_fdo) 7339 { 7340 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK) 7341 errmsg = e_invarg; 7342 } 7343 /* 'foldclose' */ 7344 else if (varp == &p_fcl) 7345 { 7346 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK) 7347 errmsg = e_invarg; 7348 } 7349 /* 'foldignore' */ 7350 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi) 7351 { 7352 if (foldmethodIsIndent(curwin)) 7353 foldUpdateAll(curwin); 7354 } 7355 #endif 7356 7357 #ifdef FEAT_VIRTUALEDIT 7358 /* 'virtualedit' */ 7359 else if (varp == &p_ve) 7360 { 7361 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK) 7362 errmsg = e_invarg; 7363 else if (STRCMP(p_ve, oldval) != 0) 7364 { 7365 /* Recompute cursor position in case the new 've' setting 7366 * changes something. */ 7367 validate_virtcol(); 7368 coladvance(curwin->w_virtcol); 7369 } 7370 } 7371 #endif 7372 7373 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX) 7374 else if (varp == &p_csqf) 7375 { 7376 if (p_csqf != NULL) 7377 { 7378 p = p_csqf; 7379 while (*p != NUL) 7380 { 7381 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL 7382 || p[1] == NUL 7383 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL 7384 || (p[2] != NUL && p[2] != ',')) 7385 { 7386 errmsg = e_invarg; 7387 break; 7388 } 7389 else if (p[2] == NUL) 7390 break; 7391 else 7392 p += 3; 7393 } 7394 } 7395 } 7396 #endif 7397 7398 #ifdef FEAT_CINDENT 7399 /* 'cinoptions' */ 7400 else if (gvarp == &p_cino) 7401 { 7402 /* TODO: recognize errors */ 7403 parse_cino(curbuf); 7404 } 7405 #endif 7406 7407 #if defined(FEAT_RENDER_OPTIONS) 7408 /* 'renderoptions' */ 7409 else if (varp == &p_rop) 7410 { 7411 if (!gui_mch_set_rendering_options(p_rop)) 7412 errmsg = e_invarg; 7413 } 7414 #endif 7415 7416 #ifdef FEAT_AUTOCMD 7417 else if (gvarp == &p_ft) 7418 { 7419 if (!valid_filetype(*varp)) 7420 errmsg = e_invarg; 7421 else 7422 ft_changed = STRCMP(oldval, *varp) != 0; 7423 } 7424 #endif 7425 7426 #ifdef FEAT_SYN_HL 7427 else if (gvarp == &p_syn) 7428 { 7429 if (!valid_filetype(*varp)) 7430 errmsg = e_invarg; 7431 } 7432 #endif 7433 7434 #ifdef FEAT_TERMINAL 7435 /* 'termkey' */ 7436 else if (varp == &curwin->w_p_tk) 7437 { 7438 if (*curwin->w_p_tk != NUL && string_to_key(curwin->w_p_tk, TRUE) == 0) 7439 errmsg = e_invarg; 7440 } 7441 /* 'termsize' */ 7442 else if (varp == &curwin->w_p_tms) 7443 { 7444 if (*curwin->w_p_tms != NUL) 7445 { 7446 p = skipdigits(curwin->w_p_tms); 7447 if (p == curwin->w_p_tms || *p != 'x' || *skipdigits(p + 1) != NUL) 7448 errmsg = e_invarg; 7449 } 7450 } 7451 #endif 7452 7453 /* Options that are a list of flags. */ 7454 else 7455 { 7456 p = NULL; 7457 if (varp == &p_ww) /* 'whichwrap' */ 7458 p = (char_u *)WW_ALL; 7459 if (varp == &p_shm) /* 'shortmess' */ 7460 p = (char_u *)SHM_ALL; 7461 else if (varp == &(p_cpo)) /* 'cpoptions' */ 7462 p = (char_u *)CPO_ALL; 7463 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */ 7464 p = (char_u *)FO_ALL; 7465 #ifdef FEAT_CONCEAL 7466 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */ 7467 p = (char_u *)COCU_ALL; 7468 #endif 7469 else if (varp == &p_mouse) /* 'mouse' */ 7470 { 7471 #ifdef FEAT_MOUSE 7472 p = (char_u *)MOUSE_ALL; 7473 #else 7474 if (*p_mouse != NUL) 7475 errmsg = (char_u *)N_("E538: No mouse support"); 7476 #endif 7477 } 7478 #if defined(FEAT_GUI) 7479 else if (varp == &p_go) /* 'guioptions' */ 7480 p = (char_u *)GO_ALL; 7481 #endif 7482 if (p != NULL) 7483 { 7484 for (s = *varp; *s; ++s) 7485 if (vim_strchr(p, *s) == NULL) 7486 { 7487 errmsg = illegal_char(errbuf, *s); 7488 break; 7489 } 7490 } 7491 } 7492 7493 /* 7494 * If error detected, restore the previous value. 7495 */ 7496 if (errmsg != NULL) 7497 { 7498 if (new_value_alloced) 7499 free_string_option(*varp); 7500 *varp = oldval; 7501 /* 7502 * When resetting some values, need to act on it. 7503 */ 7504 if (did_chartab) 7505 (void)init_chartab(); 7506 if (varp == &p_hl) 7507 (void)highlight_changed(); 7508 } 7509 else 7510 { 7511 #ifdef FEAT_EVAL 7512 /* Remember where the option was set. */ 7513 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 7514 #endif 7515 /* 7516 * Free string options that are in allocated memory. 7517 * Use "free_oldval", because recursiveness may change the flags under 7518 * our fingers (esp. init_highlight()). 7519 */ 7520 if (free_oldval) 7521 free_string_option(oldval); 7522 if (new_value_alloced) 7523 options[opt_idx].flags |= P_ALLOCED; 7524 else 7525 options[opt_idx].flags &= ~P_ALLOCED; 7526 7527 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 7528 && ((int)options[opt_idx].indir & PV_BOTH)) 7529 { 7530 /* global option with local value set to use global value; free 7531 * the local value and make it empty */ 7532 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL); 7533 free_string_option(*(char_u **)p); 7534 *(char_u **)p = empty_option; 7535 } 7536 7537 /* May set global value for local option. */ 7538 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL) 7539 set_string_option_global(opt_idx, varp); 7540 7541 #ifdef FEAT_AUTOCMD 7542 /* 7543 * Trigger the autocommand only after setting the flags. 7544 */ 7545 # ifdef FEAT_SYN_HL 7546 /* When 'syntax' is set, load the syntax of that name */ 7547 if (varp == &(curbuf->b_p_syn)) 7548 { 7549 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, 7550 curbuf->b_fname, TRUE, curbuf); 7551 } 7552 # endif 7553 else if (varp == &(curbuf->b_p_ft)) 7554 { 7555 /* 'filetype' is set, trigger the FileType autocommand. 7556 * Skip this when called from a modeline and the filetype was 7557 * already set to this value. */ 7558 if (!(opt_flags & OPT_MODELINE) || ft_changed) 7559 { 7560 did_filetype = TRUE; 7561 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, 7562 curbuf->b_fname, TRUE, curbuf); 7563 /* Just in case the old "curbuf" is now invalid. */ 7564 if (varp != &(curbuf->b_p_ft)) 7565 varp = NULL; 7566 } 7567 } 7568 #endif 7569 #ifdef FEAT_SPELL 7570 if (varp == &(curwin->w_s->b_p_spl)) 7571 { 7572 char_u fname[200]; 7573 char_u *q = curwin->w_s->b_p_spl; 7574 7575 /* Skip the first name if it is "cjk". */ 7576 if (STRNCMP(q, "cjk,", 4) == 0) 7577 q += 4; 7578 7579 /* 7580 * Source the spell/LANG.vim in 'runtimepath'. 7581 * They could set 'spellcapcheck' depending on the language. 7582 * Use the first name in 'spelllang' up to '_region' or 7583 * '.encoding'. 7584 */ 7585 for (p = q; *p != NUL; ++p) 7586 if (vim_strchr((char_u *)"_.,", *p) != NULL) 7587 break; 7588 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); 7589 source_runtime(fname, DIP_ALL); 7590 } 7591 #endif 7592 } 7593 7594 #ifdef FEAT_MOUSE 7595 if (varp == &p_mouse) 7596 { 7597 # ifdef FEAT_MOUSE_TTY 7598 if (*p_mouse == NUL) 7599 mch_setmouse(FALSE); /* switch mouse off */ 7600 else 7601 # endif 7602 setmouse(); /* in case 'mouse' changed */ 7603 } 7604 #endif 7605 7606 if (curwin->w_curswant != MAXCOL 7607 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) 7608 curwin->w_set_curswant = TRUE; 7609 7610 #ifdef FEAT_GUI 7611 /* check redraw when it's not a GUI option or the GUI is active. */ 7612 if (!redraw_gui_only || gui.in_use) 7613 #endif 7614 check_redraw(options[opt_idx].flags); 7615 7616 return errmsg; 7617 } 7618 7619 #if defined(FEAT_SYN_HL) || defined(PROTO) 7620 /* 7621 * Simple int comparison function for use with qsort() 7622 */ 7623 static int 7624 int_cmp(const void *a, const void *b) 7625 { 7626 return *(const int *)a - *(const int *)b; 7627 } 7628 7629 /* 7630 * Handle setting 'colorcolumn' or 'textwidth' in window "wp". 7631 * Returns error message, NULL if it's OK. 7632 */ 7633 char_u * 7634 check_colorcolumn(win_T *wp) 7635 { 7636 char_u *s; 7637 int col; 7638 int count = 0; 7639 int color_cols[256]; 7640 int i; 7641 int j = 0; 7642 7643 if (wp->w_buffer == NULL) 7644 return NULL; /* buffer was closed */ 7645 7646 for (s = wp->w_p_cc; *s != NUL && count < 255;) 7647 { 7648 if (*s == '-' || *s == '+') 7649 { 7650 /* -N and +N: add to 'textwidth' */ 7651 col = (*s == '-') ? -1 : 1; 7652 ++s; 7653 if (!VIM_ISDIGIT(*s)) 7654 return e_invarg; 7655 col = col * getdigits(&s); 7656 if (wp->w_buffer->b_p_tw == 0) 7657 goto skip; /* 'textwidth' not set, skip this item */ 7658 col += wp->w_buffer->b_p_tw; 7659 if (col < 0) 7660 goto skip; 7661 } 7662 else if (VIM_ISDIGIT(*s)) 7663 col = getdigits(&s); 7664 else 7665 return e_invarg; 7666 color_cols[count++] = col - 1; /* 1-based to 0-based */ 7667 skip: 7668 if (*s == NUL) 7669 break; 7670 if (*s != ',') 7671 return e_invarg; 7672 if (*++s == NUL) 7673 return e_invarg; /* illegal trailing comma as in "set cc=80," */ 7674 } 7675 7676 vim_free(wp->w_p_cc_cols); 7677 if (count == 0) 7678 wp->w_p_cc_cols = NULL; 7679 else 7680 { 7681 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1)); 7682 if (wp->w_p_cc_cols != NULL) 7683 { 7684 /* sort the columns for faster usage on screen redraw inside 7685 * win_line() */ 7686 qsort(color_cols, count, sizeof(int), int_cmp); 7687 7688 for (i = 0; i < count; ++i) 7689 /* skip duplicates */ 7690 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) 7691 wp->w_p_cc_cols[j++] = color_cols[i]; 7692 wp->w_p_cc_cols[j] = -1; /* end marker */ 7693 } 7694 } 7695 7696 return NULL; /* no error */ 7697 } 7698 #endif 7699 7700 /* 7701 * Handle setting 'listchars' or 'fillchars'. 7702 * Returns error message, NULL if it's OK. 7703 */ 7704 static char_u * 7705 set_chars_option(char_u **varp) 7706 { 7707 int round, i, len, entries; 7708 char_u *p, *s; 7709 int c1, c2 = 0; 7710 struct charstab 7711 { 7712 int *cp; 7713 char *name; 7714 }; 7715 static struct charstab filltab[] = 7716 { 7717 {&fill_stl, "stl"}, 7718 {&fill_stlnc, "stlnc"}, 7719 {&fill_vert, "vert"}, 7720 {&fill_fold, "fold"}, 7721 {&fill_diff, "diff"}, 7722 }; 7723 static struct charstab lcstab[] = 7724 { 7725 {&lcs_eol, "eol"}, 7726 {&lcs_ext, "extends"}, 7727 {&lcs_nbsp, "nbsp"}, 7728 {&lcs_prec, "precedes"}, 7729 {&lcs_space, "space"}, 7730 {&lcs_tab2, "tab"}, 7731 {&lcs_trail, "trail"}, 7732 #ifdef FEAT_CONCEAL 7733 {&lcs_conceal, "conceal"}, 7734 #else 7735 {NULL, "conceal"}, 7736 #endif 7737 }; 7738 struct charstab *tab; 7739 7740 if (varp == &p_lcs) 7741 { 7742 tab = lcstab; 7743 entries = sizeof(lcstab) / sizeof(struct charstab); 7744 } 7745 else 7746 { 7747 tab = filltab; 7748 entries = sizeof(filltab) / sizeof(struct charstab); 7749 } 7750 7751 /* first round: check for valid value, second round: assign values */ 7752 for (round = 0; round <= 1; ++round) 7753 { 7754 if (round > 0) 7755 { 7756 /* After checking that the value is valid: set defaults: space for 7757 * 'fillchars', NUL for 'listchars' */ 7758 for (i = 0; i < entries; ++i) 7759 if (tab[i].cp != NULL) 7760 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' '); 7761 if (varp == &p_lcs) 7762 lcs_tab1 = NUL; 7763 else 7764 fill_diff = '-'; 7765 } 7766 p = *varp; 7767 while (*p) 7768 { 7769 for (i = 0; i < entries; ++i) 7770 { 7771 len = (int)STRLEN(tab[i].name); 7772 if (STRNCMP(p, tab[i].name, len) == 0 7773 && p[len] == ':' 7774 && p[len + 1] != NUL) 7775 { 7776 s = p + len + 1; 7777 #ifdef FEAT_MBYTE 7778 c1 = mb_ptr2char_adv(&s); 7779 if (mb_char2cells(c1) > 1) 7780 continue; 7781 #else 7782 c1 = *s++; 7783 #endif 7784 if (tab[i].cp == &lcs_tab2) 7785 { 7786 if (*s == NUL) 7787 continue; 7788 #ifdef FEAT_MBYTE 7789 c2 = mb_ptr2char_adv(&s); 7790 if (mb_char2cells(c2) > 1) 7791 continue; 7792 #else 7793 c2 = *s++; 7794 #endif 7795 } 7796 if (*s == ',' || *s == NUL) 7797 { 7798 if (round) 7799 { 7800 if (tab[i].cp == &lcs_tab2) 7801 { 7802 lcs_tab1 = c1; 7803 lcs_tab2 = c2; 7804 } 7805 else if (tab[i].cp != NULL) 7806 *(tab[i].cp) = c1; 7807 7808 } 7809 p = s; 7810 break; 7811 } 7812 } 7813 } 7814 7815 if (i == entries) 7816 return e_invarg; 7817 if (*p == ',') 7818 ++p; 7819 } 7820 } 7821 7822 return NULL; /* no error */ 7823 } 7824 7825 #ifdef FEAT_STL_OPT 7826 /* 7827 * Check validity of options with the 'statusline' format. 7828 * Return error message or NULL. 7829 */ 7830 char_u * 7831 check_stl_option(char_u *s) 7832 { 7833 int itemcnt = 0; 7834 int groupdepth = 0; 7835 static char_u errbuf[80]; 7836 7837 while (*s && itemcnt < STL_MAX_ITEM) 7838 { 7839 /* Check for valid keys after % sequences */ 7840 while (*s && *s != '%') 7841 s++; 7842 if (!*s) 7843 break; 7844 s++; 7845 if (*s != '%' && *s != ')') 7846 ++itemcnt; 7847 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK) 7848 { 7849 s++; 7850 continue; 7851 } 7852 if (*s == ')') 7853 { 7854 s++; 7855 if (--groupdepth < 0) 7856 break; 7857 continue; 7858 } 7859 if (*s == '-') 7860 s++; 7861 while (VIM_ISDIGIT(*s)) 7862 s++; 7863 if (*s == STL_USER_HL) 7864 continue; 7865 if (*s == '.') 7866 { 7867 s++; 7868 while (*s && VIM_ISDIGIT(*s)) 7869 s++; 7870 } 7871 if (*s == '(') 7872 { 7873 groupdepth++; 7874 continue; 7875 } 7876 if (vim_strchr(STL_ALL, *s) == NULL) 7877 { 7878 return illegal_char(errbuf, *s); 7879 } 7880 if (*s == '{') 7881 { 7882 s++; 7883 while (*s != '}' && *s) 7884 s++; 7885 if (*s != '}') 7886 return (char_u *)N_("E540: Unclosed expression sequence"); 7887 } 7888 } 7889 if (itemcnt >= STL_MAX_ITEM) 7890 return (char_u *)N_("E541: too many items"); 7891 if (groupdepth != 0) 7892 return (char_u *)N_("E542: unbalanced groups"); 7893 return NULL; 7894 } 7895 #endif 7896 7897 #ifdef FEAT_CLIPBOARD 7898 /* 7899 * Extract the items in the 'clipboard' option and set global values. 7900 */ 7901 static char_u * 7902 check_clipboard_option(void) 7903 { 7904 int new_unnamed = 0; 7905 int new_autoselect_star = FALSE; 7906 int new_autoselect_plus = FALSE; 7907 int new_autoselectml = FALSE; 7908 int new_html = FALSE; 7909 regprog_T *new_exclude_prog = NULL; 7910 char_u *errmsg = NULL; 7911 char_u *p; 7912 7913 for (p = p_cb; *p != NUL; ) 7914 { 7915 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL)) 7916 { 7917 new_unnamed |= CLIP_UNNAMED; 7918 p += 7; 7919 } 7920 else if (STRNCMP(p, "unnamedplus", 11) == 0 7921 && (p[11] == ',' || p[11] == NUL)) 7922 { 7923 new_unnamed |= CLIP_UNNAMED_PLUS; 7924 p += 11; 7925 } 7926 else if (STRNCMP(p, "autoselect", 10) == 0 7927 && (p[10] == ',' || p[10] == NUL)) 7928 { 7929 new_autoselect_star = TRUE; 7930 p += 10; 7931 } 7932 else if (STRNCMP(p, "autoselectplus", 14) == 0 7933 && (p[14] == ',' || p[14] == NUL)) 7934 { 7935 new_autoselect_plus = TRUE; 7936 p += 14; 7937 } 7938 else if (STRNCMP(p, "autoselectml", 12) == 0 7939 && (p[12] == ',' || p[12] == NUL)) 7940 { 7941 new_autoselectml = TRUE; 7942 p += 12; 7943 } 7944 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL)) 7945 { 7946 new_html = TRUE; 7947 p += 4; 7948 } 7949 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL) 7950 { 7951 p += 8; 7952 new_exclude_prog = vim_regcomp(p, RE_MAGIC); 7953 if (new_exclude_prog == NULL) 7954 errmsg = e_invarg; 7955 break; 7956 } 7957 else 7958 { 7959 errmsg = e_invarg; 7960 break; 7961 } 7962 if (*p == ',') 7963 ++p; 7964 } 7965 if (errmsg == NULL) 7966 { 7967 clip_unnamed = new_unnamed; 7968 clip_autoselect_star = new_autoselect_star; 7969 clip_autoselect_plus = new_autoselect_plus; 7970 clip_autoselectml = new_autoselectml; 7971 clip_html = new_html; 7972 vim_regfree(clip_exclude_prog); 7973 clip_exclude_prog = new_exclude_prog; 7974 #ifdef FEAT_GUI_GTK 7975 if (gui.in_use) 7976 { 7977 gui_gtk_set_selection_targets(); 7978 gui_gtk_set_dnd_targets(); 7979 } 7980 #endif 7981 } 7982 else 7983 vim_regfree(new_exclude_prog); 7984 7985 return errmsg; 7986 } 7987 #endif 7988 7989 #ifdef FEAT_SPELL 7990 static char_u * 7991 did_set_spell_option(int is_spellfile) 7992 { 7993 char_u *errmsg = NULL; 7994 win_T *wp; 7995 int l; 7996 7997 if (is_spellfile) 7998 { 7999 l = (int)STRLEN(curwin->w_s->b_p_spf); 8000 if (l > 0 && (l < 4 8001 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0)) 8002 errmsg = e_invarg; 8003 } 8004 8005 if (errmsg == NULL) 8006 { 8007 FOR_ALL_WINDOWS(wp) 8008 if (wp->w_buffer == curbuf && wp->w_p_spell) 8009 { 8010 errmsg = did_set_spelllang(wp); 8011 break; 8012 } 8013 } 8014 return errmsg; 8015 } 8016 8017 /* 8018 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'. 8019 * Return error message when failed, NULL when OK. 8020 */ 8021 static char_u * 8022 compile_cap_prog(synblock_T *synblock) 8023 { 8024 regprog_T *rp = synblock->b_cap_prog; 8025 char_u *re; 8026 8027 if (*synblock->b_p_spc == NUL) 8028 synblock->b_cap_prog = NULL; 8029 else 8030 { 8031 /* Prepend a ^ so that we only match at one column */ 8032 re = concat_str((char_u *)"^", synblock->b_p_spc); 8033 if (re != NULL) 8034 { 8035 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC); 8036 vim_free(re); 8037 if (synblock->b_cap_prog == NULL) 8038 { 8039 synblock->b_cap_prog = rp; /* restore the previous program */ 8040 return e_invarg; 8041 } 8042 } 8043 } 8044 8045 vim_regfree(rp); 8046 return NULL; 8047 } 8048 #endif 8049 8050 #if defined(FEAT_EVAL) || defined(PROTO) 8051 /* 8052 * Set the scriptID for an option, taking care of setting the buffer- or 8053 * window-local value. 8054 */ 8055 static void 8056 set_option_scriptID_idx(int opt_idx, int opt_flags, int id) 8057 { 8058 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; 8059 int indir = (int)options[opt_idx].indir; 8060 8061 /* Remember where the option was set. For local options need to do that 8062 * in the buffer or window structure. */ 8063 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) 8064 options[opt_idx].scriptID = id; 8065 if (both || (opt_flags & OPT_LOCAL)) 8066 { 8067 if (indir & PV_BUF) 8068 curbuf->b_p_scriptID[indir & PV_MASK] = id; 8069 else if (indir & PV_WIN) 8070 curwin->w_p_scriptID[indir & PV_MASK] = id; 8071 } 8072 } 8073 #endif 8074 8075 /* 8076 * Set the value of a boolean option, and take care of side effects. 8077 * Returns NULL for success, or an error message for an error. 8078 */ 8079 static char_u * 8080 set_bool_option( 8081 int opt_idx, /* index in options[] table */ 8082 char_u *varp, /* pointer to the option variable */ 8083 int value, /* new value */ 8084 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ 8085 { 8086 int old_value = *(int *)varp; 8087 8088 /* Disallow changing some options from secure mode */ 8089 if ((secure 8090 #ifdef HAVE_SANDBOX 8091 || sandbox != 0 8092 #endif 8093 ) && (options[opt_idx].flags & P_SECURE)) 8094 return e_secure; 8095 8096 *(int *)varp = value; /* set the new value */ 8097 #ifdef FEAT_EVAL 8098 /* Remember where the option was set. */ 8099 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 8100 #endif 8101 8102 #ifdef FEAT_GUI 8103 need_mouse_correct = TRUE; 8104 #endif 8105 8106 /* May set global value for local option. */ 8107 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) 8108 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value; 8109 8110 /* 8111 * Handle side effects of changing a bool option. 8112 */ 8113 8114 /* 'compatible' */ 8115 if ((int *)varp == &p_cp) 8116 { 8117 compatible_set(); 8118 } 8119 8120 #ifdef FEAT_LANGMAP 8121 if ((int *)varp == &p_lrm) 8122 /* 'langremap' -> !'langnoremap' */ 8123 p_lnr = !p_lrm; 8124 else if ((int *)varp == &p_lnr) 8125 /* 'langnoremap' -> !'langremap' */ 8126 p_lrm = !p_lnr; 8127 #endif 8128 8129 #ifdef FEAT_PERSISTENT_UNDO 8130 /* 'undofile' */ 8131 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf) 8132 { 8133 /* Only take action when the option was set. When reset we do not 8134 * delete the undo file, the option may be set again without making 8135 * any changes in between. */ 8136 if (curbuf->b_p_udf || p_udf) 8137 { 8138 char_u hash[UNDO_HASH_SIZE]; 8139 buf_T *save_curbuf = curbuf; 8140 8141 FOR_ALL_BUFFERS(curbuf) 8142 { 8143 /* When 'undofile' is set globally: for every buffer, otherwise 8144 * only for the current buffer: Try to read in the undofile, 8145 * if one exists, the buffer wasn't changed and the buffer was 8146 * loaded */ 8147 if ((curbuf == save_curbuf 8148 || (opt_flags & OPT_GLOBAL) || opt_flags == 0) 8149 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL) 8150 { 8151 u_compute_hash(hash); 8152 u_read_undo(NULL, hash, curbuf->b_fname); 8153 } 8154 } 8155 curbuf = save_curbuf; 8156 } 8157 } 8158 #endif 8159 8160 else if ((int *)varp == &curbuf->b_p_ro) 8161 { 8162 /* when 'readonly' is reset globally, also reset readonlymode */ 8163 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0) 8164 readonlymode = FALSE; 8165 8166 /* when 'readonly' is set may give W10 again */ 8167 if (curbuf->b_p_ro) 8168 curbuf->b_did_warn = FALSE; 8169 8170 #ifdef FEAT_TITLE 8171 redraw_titles(); 8172 #endif 8173 } 8174 8175 #ifdef FEAT_GUI 8176 else if ((int *)varp == &p_mh) 8177 { 8178 if (!p_mh) 8179 gui_mch_mousehide(FALSE); 8180 } 8181 #endif 8182 8183 /* when 'modifiable' is changed, redraw the window title */ 8184 else if ((int *)varp == &curbuf->b_p_ma) 8185 { 8186 # ifdef FEAT_TERMINAL 8187 /* Cannot set 'modifiable' when in Terminal mode. */ 8188 if (term_in_normal_mode() 8189 || (bt_terminal(curbuf) && !term_is_finished(curbuf))) 8190 { 8191 curbuf->b_p_ma = FALSE; 8192 return (char_u *)N_("E946: Cannot make a terminal with running job modifiable"); 8193 } 8194 # endif 8195 # ifdef FEAT_TITLE 8196 redraw_titles(); 8197 # endif 8198 } 8199 #ifdef FEAT_TITLE 8200 /* when 'endofline' is changed, redraw the window title */ 8201 else if ((int *)varp == &curbuf->b_p_eol) 8202 { 8203 redraw_titles(); 8204 } 8205 /* when 'fixeol' is changed, redraw the window title */ 8206 else if ((int *)varp == &curbuf->b_p_fixeol) 8207 { 8208 redraw_titles(); 8209 } 8210 # ifdef FEAT_MBYTE 8211 /* when 'bomb' is changed, redraw the window title and tab page text */ 8212 else if ((int *)varp == &curbuf->b_p_bomb) 8213 { 8214 redraw_titles(); 8215 } 8216 # endif 8217 #endif 8218 8219 /* when 'bin' is set also set some other options */ 8220 else if ((int *)varp == &curbuf->b_p_bin) 8221 { 8222 set_options_bin(old_value, curbuf->b_p_bin, opt_flags); 8223 #ifdef FEAT_TITLE 8224 redraw_titles(); 8225 #endif 8226 } 8227 8228 #ifdef FEAT_AUTOCMD 8229 /* when 'buflisted' changes, trigger autocommands */ 8230 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl) 8231 { 8232 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE, 8233 NULL, NULL, TRUE, curbuf); 8234 } 8235 #endif 8236 8237 /* when 'swf' is set, create swapfile, when reset remove swapfile */ 8238 else if ((int *)varp == &curbuf->b_p_swf) 8239 { 8240 if (curbuf->b_p_swf && p_uc) 8241 ml_open_file(curbuf); /* create the swap file */ 8242 else 8243 /* no need to reset curbuf->b_may_swap, ml_open_file() will check 8244 * buf->b_p_swf */ 8245 mf_close_file(curbuf, TRUE); /* remove the swap file */ 8246 } 8247 8248 /* when 'terse' is set change 'shortmess' */ 8249 else if ((int *)varp == &p_terse) 8250 { 8251 char_u *p; 8252 8253 p = vim_strchr(p_shm, SHM_SEARCH); 8254 8255 /* insert 's' in p_shm */ 8256 if (p_terse && p == NULL) 8257 { 8258 STRCPY(IObuff, p_shm); 8259 STRCAT(IObuff, "s"); 8260 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0); 8261 } 8262 /* remove 's' from p_shm */ 8263 else if (!p_terse && p != NULL) 8264 STRMOVE(p, p + 1); 8265 } 8266 8267 /* when 'paste' is set or reset also change other options */ 8268 else if ((int *)varp == &p_paste) 8269 { 8270 paste_option_changed(); 8271 } 8272 8273 /* when 'insertmode' is set from an autocommand need to do work here */ 8274 else if ((int *)varp == &p_im) 8275 { 8276 if (p_im) 8277 { 8278 if ((State & INSERT) == 0) 8279 need_start_insertmode = TRUE; 8280 stop_insert_mode = FALSE; 8281 } 8282 /* only reset if it was set previously */ 8283 else if (old_value) 8284 { 8285 need_start_insertmode = FALSE; 8286 stop_insert_mode = TRUE; 8287 if (restart_edit != 0 && mode_displayed) 8288 clear_cmdline = TRUE; /* remove "(insert)" */ 8289 restart_edit = 0; 8290 } 8291 } 8292 8293 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */ 8294 else if ((int *)varp == &p_ic && p_hls) 8295 { 8296 redraw_all_later(SOME_VALID); 8297 } 8298 8299 #ifdef FEAT_SEARCH_EXTRA 8300 /* when 'hlsearch' is set or reset: reset no_hlsearch */ 8301 else if ((int *)varp == &p_hls) 8302 { 8303 SET_NO_HLSEARCH(FALSE); 8304 } 8305 #endif 8306 8307 #ifdef FEAT_SCROLLBIND 8308 /* when 'scrollbind' is set: snapshot the current position to avoid a jump 8309 * at the end of normal_cmd() */ 8310 else if ((int *)varp == &curwin->w_p_scb) 8311 { 8312 if (curwin->w_p_scb) 8313 { 8314 do_check_scrollbind(FALSE); 8315 curwin->w_scbind_pos = curwin->w_topline; 8316 } 8317 } 8318 #endif 8319 8320 #if defined(FEAT_QUICKFIX) 8321 /* There can be only one window with 'previewwindow' set. */ 8322 else if ((int *)varp == &curwin->w_p_pvw) 8323 { 8324 if (curwin->w_p_pvw) 8325 { 8326 win_T *win; 8327 8328 FOR_ALL_WINDOWS(win) 8329 if (win->w_p_pvw && win != curwin) 8330 { 8331 curwin->w_p_pvw = FALSE; 8332 return (char_u *)N_("E590: A preview window already exists"); 8333 } 8334 } 8335 } 8336 #endif 8337 8338 /* when 'textmode' is set or reset also change 'fileformat' */ 8339 else if ((int *)varp == &curbuf->b_p_tx) 8340 { 8341 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags); 8342 } 8343 8344 /* when 'textauto' is set or reset also change 'fileformats' */ 8345 else if ((int *)varp == &p_ta) 8346 set_string_option_direct((char_u *)"ffs", -1, 8347 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"", 8348 OPT_FREE | opt_flags, 0); 8349 8350 /* 8351 * When 'lisp' option changes include/exclude '-' in 8352 * keyword characters. 8353 */ 8354 #ifdef FEAT_LISP 8355 else if (varp == (char_u *)&(curbuf->b_p_lisp)) 8356 { 8357 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */ 8358 } 8359 #endif 8360 8361 #ifdef FEAT_TITLE 8362 /* when 'title' changed, may need to change the title; same for 'icon' */ 8363 else if ((int *)varp == &p_title) 8364 { 8365 did_set_title(FALSE); 8366 } 8367 8368 else if ((int *)varp == &p_icon) 8369 { 8370 did_set_title(TRUE); 8371 } 8372 #endif 8373 8374 else if ((int *)varp == &curbuf->b_changed) 8375 { 8376 if (!value) 8377 save_file_ff(curbuf); /* Buffer is unchanged */ 8378 #ifdef FEAT_TITLE 8379 redraw_titles(); 8380 #endif 8381 #ifdef FEAT_AUTOCMD 8382 modified_was_set = value; 8383 #endif 8384 } 8385 8386 #ifdef BACKSLASH_IN_FILENAME 8387 else if ((int *)varp == &p_ssl) 8388 { 8389 if (p_ssl) 8390 { 8391 psepc = '/'; 8392 psepcN = '\\'; 8393 pseps[0] = '/'; 8394 } 8395 else 8396 { 8397 psepc = '\\'; 8398 psepcN = '/'; 8399 pseps[0] = '\\'; 8400 } 8401 8402 /* need to adjust the file name arguments and buffer names. */ 8403 buflist_slash_adjust(); 8404 alist_slash_adjust(); 8405 # ifdef FEAT_EVAL 8406 scriptnames_slash_adjust(); 8407 # endif 8408 } 8409 #endif 8410 8411 /* If 'wrap' is set, set w_leftcol to zero. */ 8412 else if ((int *)varp == &curwin->w_p_wrap) 8413 { 8414 if (curwin->w_p_wrap) 8415 curwin->w_leftcol = 0; 8416 } 8417 8418 else if ((int *)varp == &p_ea) 8419 { 8420 if (p_ea && !old_value) 8421 win_equal(curwin, FALSE, 0); 8422 } 8423 8424 else if ((int *)varp == &p_wiv) 8425 { 8426 /* 8427 * When 'weirdinvert' changed, set/reset 't_xs'. 8428 * Then set 'weirdinvert' according to value of 't_xs'. 8429 */ 8430 if (p_wiv && !old_value) 8431 T_XS = (char_u *)"y"; 8432 else if (!p_wiv && old_value) 8433 T_XS = empty_option; 8434 p_wiv = (*T_XS != NUL); 8435 } 8436 8437 #ifdef FEAT_BEVAL_GUI 8438 else if ((int *)varp == &p_beval) 8439 { 8440 if (!balloonEvalForTerm) 8441 { 8442 if (p_beval && !old_value) 8443 gui_mch_enable_beval_area(balloonEval); 8444 else if (!p_beval && old_value) 8445 gui_mch_disable_beval_area(balloonEval); 8446 } 8447 } 8448 #endif 8449 #ifdef FEAT_BEVAL_TERM 8450 else if ((int *)varp == &p_bevalterm) 8451 { 8452 mch_bevalterm_changed(); 8453 } 8454 #endif 8455 8456 #ifdef FEAT_AUTOCHDIR 8457 else if ((int *)varp == &p_acd) 8458 { 8459 /* Change directories when the 'acd' option is set now. */ 8460 DO_AUTOCHDIR 8461 } 8462 #endif 8463 8464 #ifdef FEAT_DIFF 8465 /* 'diff' */ 8466 else if ((int *)varp == &curwin->w_p_diff) 8467 { 8468 /* May add or remove the buffer from the list of diff buffers. */ 8469 diff_buf_adjust(curwin); 8470 # ifdef FEAT_FOLDING 8471 if (foldmethodIsDiff(curwin)) 8472 foldUpdateAll(curwin); 8473 # endif 8474 } 8475 #endif 8476 8477 #ifdef FEAT_MBYTE 8478 /* 'imdisable' */ 8479 else if ((int *)varp == &p_imdisable) 8480 { 8481 /* Only de-activate it here, it will be enabled when changing mode. */ 8482 if (p_imdisable) 8483 im_set_active(FALSE); 8484 else if (State & INSERT) 8485 /* When the option is set from an autocommand, it may need to take 8486 * effect right away. */ 8487 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); 8488 } 8489 #endif 8490 8491 #ifdef FEAT_SPELL 8492 /* 'spell' */ 8493 else if ((int *)varp == &curwin->w_p_spell) 8494 { 8495 if (curwin->w_p_spell) 8496 { 8497 char_u *errmsg = did_set_spelllang(curwin); 8498 if (errmsg != NULL) 8499 EMSG(_(errmsg)); 8500 } 8501 } 8502 #endif 8503 8504 #ifdef FEAT_FKMAP 8505 else if ((int *)varp == &p_altkeymap) 8506 { 8507 if (old_value != p_altkeymap) 8508 { 8509 if (!p_altkeymap) 8510 { 8511 p_hkmap = p_fkmap; 8512 p_fkmap = 0; 8513 } 8514 else 8515 { 8516 p_fkmap = p_hkmap; 8517 p_hkmap = 0; 8518 } 8519 (void)init_chartab(); 8520 } 8521 } 8522 8523 /* 8524 * In case some second language keymapping options have changed, check 8525 * and correct the setting in a consistent way. 8526 */ 8527 8528 /* 8529 * If hkmap or fkmap are set, reset Arabic keymapping. 8530 */ 8531 if ((p_hkmap || p_fkmap) && p_altkeymap) 8532 { 8533 p_altkeymap = p_fkmap; 8534 # ifdef FEAT_ARABIC 8535 curwin->w_p_arab = FALSE; 8536 # endif 8537 (void)init_chartab(); 8538 } 8539 8540 /* 8541 * If hkmap set, reset Farsi keymapping. 8542 */ 8543 if (p_hkmap && p_altkeymap) 8544 { 8545 p_altkeymap = 0; 8546 p_fkmap = 0; 8547 # ifdef FEAT_ARABIC 8548 curwin->w_p_arab = FALSE; 8549 # endif 8550 (void)init_chartab(); 8551 } 8552 8553 /* 8554 * If fkmap set, reset Hebrew keymapping. 8555 */ 8556 if (p_fkmap && !p_altkeymap) 8557 { 8558 p_altkeymap = 1; 8559 p_hkmap = 0; 8560 # ifdef FEAT_ARABIC 8561 curwin->w_p_arab = FALSE; 8562 # endif 8563 (void)init_chartab(); 8564 } 8565 #endif 8566 8567 #ifdef FEAT_ARABIC 8568 if ((int *)varp == &curwin->w_p_arab) 8569 { 8570 if (curwin->w_p_arab) 8571 { 8572 /* 8573 * 'arabic' is set, handle various sub-settings. 8574 */ 8575 if (!p_tbidi) 8576 { 8577 /* set rightleft mode */ 8578 if (!curwin->w_p_rl) 8579 { 8580 curwin->w_p_rl = TRUE; 8581 changed_window_setting(); 8582 } 8583 8584 /* Enable Arabic shaping (major part of what Arabic requires) */ 8585 if (!p_arshape) 8586 { 8587 p_arshape = TRUE; 8588 redraw_later_clear(); 8589 } 8590 } 8591 8592 /* Arabic requires a utf-8 encoding, inform the user if its not 8593 * set. */ 8594 if (STRCMP(p_enc, "utf-8") != 0) 8595 { 8596 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"); 8597 8598 msg_source(HL_ATTR(HLF_W)); 8599 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W)); 8600 #ifdef FEAT_EVAL 8601 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1); 8602 #endif 8603 } 8604 8605 # ifdef FEAT_MBYTE 8606 /* set 'delcombine' */ 8607 p_deco = TRUE; 8608 # endif 8609 8610 # ifdef FEAT_KEYMAP 8611 /* Force-set the necessary keymap for arabic */ 8612 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic", 8613 OPT_LOCAL); 8614 # endif 8615 # ifdef FEAT_FKMAP 8616 p_altkeymap = 0; 8617 p_hkmap = 0; 8618 p_fkmap = 0; 8619 (void)init_chartab(); 8620 # endif 8621 } 8622 else 8623 { 8624 /* 8625 * 'arabic' is reset, handle various sub-settings. 8626 */ 8627 if (!p_tbidi) 8628 { 8629 /* reset rightleft mode */ 8630 if (curwin->w_p_rl) 8631 { 8632 curwin->w_p_rl = FALSE; 8633 changed_window_setting(); 8634 } 8635 8636 /* 'arabicshape' isn't reset, it is a global option and 8637 * another window may still need it "on". */ 8638 } 8639 8640 /* 'delcombine' isn't reset, it is a global option and another 8641 * window may still want it "on". */ 8642 8643 # ifdef FEAT_KEYMAP 8644 /* Revert to the default keymap */ 8645 curbuf->b_p_iminsert = B_IMODE_NONE; 8646 curbuf->b_p_imsearch = B_IMODE_USE_INSERT; 8647 # endif 8648 } 8649 } 8650 8651 #endif 8652 8653 #ifdef FEAT_TERMGUICOLORS 8654 /* 'termguicolors' */ 8655 else if ((int *)varp == &p_tgc) 8656 { 8657 # ifdef FEAT_GUI 8658 if (!gui.in_use && !gui.starting) 8659 # endif 8660 highlight_gui_started(); 8661 } 8662 #endif 8663 8664 /* 8665 * End of handling side effects for bool options. 8666 */ 8667 8668 /* after handling side effects, call autocommand */ 8669 8670 options[opt_idx].flags |= P_WAS_SET; 8671 8672 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 8673 if (!starting) 8674 { 8675 char_u buf_old[2], buf_new[2], buf_type[7]; 8676 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE); 8677 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE); 8678 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); 8679 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); 8680 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); 8681 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 8682 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL); 8683 reset_v_option_vars(); 8684 } 8685 #endif 8686 8687 comp_col(); /* in case 'ruler' or 'showcmd' changed */ 8688 if (curwin->w_curswant != MAXCOL 8689 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) 8690 curwin->w_set_curswant = TRUE; 8691 check_redraw(options[opt_idx].flags); 8692 8693 return NULL; 8694 } 8695 8696 /* 8697 * Set the value of a number option, and take care of side effects. 8698 * Returns NULL for success, or an error message for an error. 8699 */ 8700 static char_u * 8701 set_num_option( 8702 int opt_idx, /* index in options[] table */ 8703 char_u *varp, /* pointer to the option variable */ 8704 long value, /* new value */ 8705 char_u *errbuf, /* buffer for error messages */ 8706 size_t errbuflen, /* length of "errbuf" */ 8707 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and 8708 OPT_MODELINE */ 8709 { 8710 char_u *errmsg = NULL; 8711 long old_value = *(long *)varp; 8712 long old_Rows = Rows; /* remember old Rows */ 8713 long old_Columns = Columns; /* remember old Columns */ 8714 long *pp = (long *)varp; 8715 8716 /* Disallow changing some options from secure mode. */ 8717 if ((secure 8718 #ifdef HAVE_SANDBOX 8719 || sandbox != 0 8720 #endif 8721 ) && (options[opt_idx].flags & P_SECURE)) 8722 return e_secure; 8723 8724 *pp = value; 8725 #ifdef FEAT_EVAL 8726 /* Remember where the option was set. */ 8727 set_option_scriptID_idx(opt_idx, opt_flags, current_SID); 8728 #endif 8729 #ifdef FEAT_GUI 8730 need_mouse_correct = TRUE; 8731 #endif 8732 8733 if (curbuf->b_p_sw < 0) 8734 { 8735 errmsg = e_positive; 8736 curbuf->b_p_sw = curbuf->b_p_ts; 8737 } 8738 8739 /* 8740 * Number options that need some action when changed 8741 */ 8742 if (pp == &p_wh || pp == &p_hh) 8743 { 8744 if (p_wh < 1) 8745 { 8746 errmsg = e_positive; 8747 p_wh = 1; 8748 } 8749 if (p_wmh > p_wh) 8750 { 8751 errmsg = e_winheight; 8752 p_wh = p_wmh; 8753 } 8754 if (p_hh < 0) 8755 { 8756 errmsg = e_positive; 8757 p_hh = 0; 8758 } 8759 8760 /* Change window height NOW */ 8761 if (!ONE_WINDOW) 8762 { 8763 if (pp == &p_wh && curwin->w_height < p_wh) 8764 win_setheight((int)p_wh); 8765 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) 8766 win_setheight((int)p_hh); 8767 } 8768 } 8769 8770 /* 'winminheight' */ 8771 else if (pp == &p_wmh) 8772 { 8773 if (p_wmh < 0) 8774 { 8775 errmsg = e_positive; 8776 p_wmh = 0; 8777 } 8778 if (p_wmh > p_wh) 8779 { 8780 errmsg = e_winheight; 8781 p_wmh = p_wh; 8782 } 8783 win_setminheight(); 8784 } 8785 else if (pp == &p_wiw) 8786 { 8787 if (p_wiw < 1) 8788 { 8789 errmsg = e_positive; 8790 p_wiw = 1; 8791 } 8792 if (p_wmw > p_wiw) 8793 { 8794 errmsg = e_winwidth; 8795 p_wiw = p_wmw; 8796 } 8797 8798 /* Change window width NOW */ 8799 if (!ONE_WINDOW && curwin->w_width < p_wiw) 8800 win_setwidth((int)p_wiw); 8801 } 8802 8803 /* 'winminwidth' */ 8804 else if (pp == &p_wmw) 8805 { 8806 if (p_wmw < 0) 8807 { 8808 errmsg = e_positive; 8809 p_wmw = 0; 8810 } 8811 if (p_wmw > p_wiw) 8812 { 8813 errmsg = e_winwidth; 8814 p_wmw = p_wiw; 8815 } 8816 win_setminheight(); 8817 } 8818 8819 /* (re)set last window status line */ 8820 else if (pp == &p_ls) 8821 { 8822 last_status(FALSE); 8823 } 8824 8825 /* (re)set tab page line */ 8826 else if (pp == &p_stal) 8827 { 8828 shell_new_rows(); /* recompute window positions and heights */ 8829 } 8830 8831 #ifdef FEAT_GUI 8832 else if (pp == &p_linespace) 8833 { 8834 /* Recompute gui.char_height and resize the Vim window to keep the 8835 * same number of lines. */ 8836 if (gui.in_use && gui_mch_adjust_charheight() == OK) 8837 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); 8838 } 8839 #endif 8840 8841 #ifdef FEAT_FOLDING 8842 /* 'foldlevel' */ 8843 else if (pp == &curwin->w_p_fdl) 8844 { 8845 if (curwin->w_p_fdl < 0) 8846 curwin->w_p_fdl = 0; 8847 newFoldLevel(); 8848 } 8849 8850 /* 'foldminlines' */ 8851 else if (pp == &curwin->w_p_fml) 8852 { 8853 foldUpdateAll(curwin); 8854 } 8855 8856 /* 'foldnestmax' */ 8857 else if (pp == &curwin->w_p_fdn) 8858 { 8859 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin)) 8860 foldUpdateAll(curwin); 8861 } 8862 8863 /* 'foldcolumn' */ 8864 else if (pp == &curwin->w_p_fdc) 8865 { 8866 if (curwin->w_p_fdc < 0) 8867 { 8868 errmsg = e_positive; 8869 curwin->w_p_fdc = 0; 8870 } 8871 else if (curwin->w_p_fdc > 12) 8872 { 8873 errmsg = e_invarg; 8874 curwin->w_p_fdc = 12; 8875 } 8876 } 8877 #endif /* FEAT_FOLDING */ 8878 8879 #if defined(FEAT_FOLDING) || defined(FEAT_CINDENT) 8880 /* 'shiftwidth' or 'tabstop' */ 8881 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts) 8882 { 8883 # ifdef FEAT_FOLDING 8884 if (foldmethodIsIndent(curwin)) 8885 foldUpdateAll(curwin); 8886 # endif 8887 # ifdef FEAT_CINDENT 8888 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes: 8889 * parse 'cinoptions'. */ 8890 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0) 8891 parse_cino(curbuf); 8892 # endif 8893 } 8894 #endif 8895 8896 #ifdef FEAT_MBYTE 8897 /* 'maxcombine' */ 8898 else if (pp == &p_mco) 8899 { 8900 if (p_mco > MAX_MCO) 8901 p_mco = MAX_MCO; 8902 else if (p_mco < 0) 8903 p_mco = 0; 8904 screenclear(); /* will re-allocate the screen */ 8905 } 8906 #endif 8907 8908 else if (pp == &curbuf->b_p_iminsert) 8909 { 8910 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST) 8911 { 8912 errmsg = e_invarg; 8913 curbuf->b_p_iminsert = B_IMODE_NONE; 8914 } 8915 p_iminsert = curbuf->b_p_iminsert; 8916 if (termcap_active) /* don't do this in the alternate screen */ 8917 showmode(); 8918 #if defined(FEAT_KEYMAP) 8919 /* Show/unshow value of 'keymap' in status lines. */ 8920 status_redraw_curbuf(); 8921 #endif 8922 } 8923 8924 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) 8925 /* 'imstyle' */ 8926 else if (pp == &p_imst) 8927 { 8928 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) 8929 errmsg = e_invarg; 8930 } 8931 #endif 8932 8933 else if (pp == &p_window) 8934 { 8935 if (p_window < 1) 8936 p_window = 1; 8937 else if (p_window >= Rows) 8938 p_window = Rows - 1; 8939 } 8940 8941 else if (pp == &curbuf->b_p_imsearch) 8942 { 8943 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST) 8944 { 8945 errmsg = e_invarg; 8946 curbuf->b_p_imsearch = B_IMODE_NONE; 8947 } 8948 p_imsearch = curbuf->b_p_imsearch; 8949 } 8950 8951 #ifdef FEAT_TITLE 8952 /* if 'titlelen' has changed, redraw the title */ 8953 else if (pp == &p_titlelen) 8954 { 8955 if (p_titlelen < 0) 8956 { 8957 errmsg = e_positive; 8958 p_titlelen = 85; 8959 } 8960 if (starting != NO_SCREEN && old_value != p_titlelen) 8961 need_maketitle = TRUE; 8962 } 8963 #endif 8964 8965 /* if p_ch changed value, change the command line height */ 8966 else if (pp == &p_ch) 8967 { 8968 if (p_ch < 1) 8969 { 8970 errmsg = e_positive; 8971 p_ch = 1; 8972 } 8973 if (p_ch > Rows - min_rows() + 1) 8974 p_ch = Rows - min_rows() + 1; 8975 8976 /* Only compute the new window layout when startup has been 8977 * completed. Otherwise the frame sizes may be wrong. */ 8978 if (p_ch != old_value && full_screen 8979 #ifdef FEAT_GUI 8980 && !gui.starting 8981 #endif 8982 ) 8983 command_height(); 8984 } 8985 8986 /* when 'updatecount' changes from zero to non-zero, open swap files */ 8987 else if (pp == &p_uc) 8988 { 8989 if (p_uc < 0) 8990 { 8991 errmsg = e_positive; 8992 p_uc = 100; 8993 } 8994 if (p_uc && !old_value) 8995 ml_open_files(); 8996 } 8997 #ifdef FEAT_CONCEAL 8998 else if (pp == &curwin->w_p_cole) 8999 { 9000 if (curwin->w_p_cole < 0) 9001 { 9002 errmsg = e_positive; 9003 curwin->w_p_cole = 0; 9004 } 9005 else if (curwin->w_p_cole > 3) 9006 { 9007 errmsg = e_invarg; 9008 curwin->w_p_cole = 3; 9009 } 9010 } 9011 #endif 9012 #ifdef MZSCHEME_GUI_THREADS 9013 else if (pp == &p_mzq) 9014 mzvim_reset_timer(); 9015 #endif 9016 9017 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) 9018 /* 'pyxversion' */ 9019 else if (pp == &p_pyx) 9020 { 9021 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3) 9022 errmsg = e_invarg; 9023 } 9024 #endif 9025 9026 /* sync undo before 'undolevels' changes */ 9027 else if (pp == &p_ul) 9028 { 9029 /* use the old value, otherwise u_sync() may not work properly */ 9030 p_ul = old_value; 9031 u_sync(TRUE); 9032 p_ul = value; 9033 } 9034 else if (pp == &curbuf->b_p_ul) 9035 { 9036 /* use the old value, otherwise u_sync() may not work properly */ 9037 curbuf->b_p_ul = old_value; 9038 u_sync(TRUE); 9039 curbuf->b_p_ul = value; 9040 } 9041 9042 #ifdef FEAT_LINEBREAK 9043 /* 'numberwidth' must be positive */ 9044 else if (pp == &curwin->w_p_nuw) 9045 { 9046 if (curwin->w_p_nuw < 1) 9047 { 9048 errmsg = e_positive; 9049 curwin->w_p_nuw = 1; 9050 } 9051 if (curwin->w_p_nuw > 10) 9052 { 9053 errmsg = e_invarg; 9054 curwin->w_p_nuw = 10; 9055 } 9056 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */ 9057 } 9058 #endif 9059 9060 else if (pp == &curbuf->b_p_tw) 9061 { 9062 if (curbuf->b_p_tw < 0) 9063 { 9064 errmsg = e_positive; 9065 curbuf->b_p_tw = 0; 9066 } 9067 #ifdef FEAT_SYN_HL 9068 { 9069 win_T *wp; 9070 tabpage_T *tp; 9071 9072 FOR_ALL_TAB_WINDOWS(tp, wp) 9073 check_colorcolumn(wp); 9074 } 9075 #endif 9076 } 9077 9078 /* 9079 * Check the bounds for numeric options here 9080 */ 9081 if (Rows < min_rows() && full_screen) 9082 { 9083 if (errbuf != NULL) 9084 { 9085 vim_snprintf((char *)errbuf, errbuflen, 9086 _("E593: Need at least %d lines"), min_rows()); 9087 errmsg = errbuf; 9088 } 9089 Rows = min_rows(); 9090 } 9091 if (Columns < MIN_COLUMNS && full_screen) 9092 { 9093 if (errbuf != NULL) 9094 { 9095 vim_snprintf((char *)errbuf, errbuflen, 9096 _("E594: Need at least %d columns"), MIN_COLUMNS); 9097 errmsg = errbuf; 9098 } 9099 Columns = MIN_COLUMNS; 9100 } 9101 limit_screen_size(); 9102 9103 /* 9104 * If the screen (shell) height has been changed, assume it is the 9105 * physical screenheight. 9106 */ 9107 if (old_Rows != Rows || old_Columns != Columns) 9108 { 9109 /* Changing the screen size is not allowed while updating the screen. */ 9110 if (updating_screen) 9111 *pp = old_value; 9112 else if (full_screen 9113 #ifdef FEAT_GUI 9114 && !gui.starting 9115 #endif 9116 ) 9117 set_shellsize((int)Columns, (int)Rows, TRUE); 9118 else 9119 { 9120 /* Postpone the resizing; check the size and cmdline position for 9121 * messages. */ 9122 check_shellsize(); 9123 if (cmdline_row > Rows - p_ch && Rows > p_ch) 9124 cmdline_row = Rows - p_ch; 9125 } 9126 if (p_window >= Rows || !option_was_set((char_u *)"window")) 9127 p_window = Rows - 1; 9128 } 9129 9130 if (curbuf->b_p_ts <= 0) 9131 { 9132 errmsg = e_positive; 9133 curbuf->b_p_ts = 8; 9134 } 9135 if (p_tm < 0) 9136 { 9137 errmsg = e_positive; 9138 p_tm = 0; 9139 } 9140 if ((curwin->w_p_scr <= 0 9141 || (curwin->w_p_scr > curwin->w_height 9142 && curwin->w_height > 0)) 9143 && full_screen) 9144 { 9145 if (pp == &(curwin->w_p_scr)) 9146 { 9147 if (curwin->w_p_scr != 0) 9148 errmsg = e_scroll; 9149 win_comp_scroll(curwin); 9150 } 9151 /* If 'scroll' became invalid because of a side effect silently adjust 9152 * it. */ 9153 else if (curwin->w_p_scr <= 0) 9154 curwin->w_p_scr = 1; 9155 else /* curwin->w_p_scr > curwin->w_height */ 9156 curwin->w_p_scr = curwin->w_height; 9157 } 9158 if (p_hi < 0) 9159 { 9160 errmsg = e_positive; 9161 p_hi = 0; 9162 } 9163 else if (p_hi > 10000) 9164 { 9165 errmsg = e_invarg; 9166 p_hi = 10000; 9167 } 9168 if (p_re < 0 || p_re > 2) 9169 { 9170 errmsg = e_invarg; 9171 p_re = 0; 9172 } 9173 if (p_report < 0) 9174 { 9175 errmsg = e_positive; 9176 p_report = 1; 9177 } 9178 if ((p_sj < -100 || p_sj >= Rows) && full_screen) 9179 { 9180 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */ 9181 p_sj = Rows / 2; 9182 else 9183 { 9184 errmsg = e_scroll; 9185 p_sj = 1; 9186 } 9187 } 9188 if (p_so < 0 && full_screen) 9189 { 9190 errmsg = e_scroll; 9191 p_so = 0; 9192 } 9193 if (p_siso < 0 && full_screen) 9194 { 9195 errmsg = e_positive; 9196 p_siso = 0; 9197 } 9198 #ifdef FEAT_CMDWIN 9199 if (p_cwh < 1) 9200 { 9201 errmsg = e_positive; 9202 p_cwh = 1; 9203 } 9204 #endif 9205 if (p_ut < 0) 9206 { 9207 errmsg = e_positive; 9208 p_ut = 2000; 9209 } 9210 if (p_ss < 0) 9211 { 9212 errmsg = e_positive; 9213 p_ss = 0; 9214 } 9215 9216 /* May set global value for local option. */ 9217 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0) 9218 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp; 9219 9220 options[opt_idx].flags |= P_WAS_SET; 9221 9222 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 9223 if (!starting && errmsg == NULL) 9224 { 9225 char_u buf_old[11], buf_new[11], buf_type[7]; 9226 vim_snprintf((char *)buf_old, 10, "%ld", old_value); 9227 vim_snprintf((char *)buf_new, 10, "%ld", value); 9228 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global"); 9229 set_vim_var_string(VV_OPTION_NEW, buf_new, -1); 9230 set_vim_var_string(VV_OPTION_OLD, buf_old, -1); 9231 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1); 9232 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL); 9233 reset_v_option_vars(); 9234 } 9235 #endif 9236 9237 comp_col(); /* in case 'columns' or 'ls' changed */ 9238 if (curwin->w_curswant != MAXCOL 9239 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0) 9240 curwin->w_set_curswant = TRUE; 9241 check_redraw(options[opt_idx].flags); 9242 9243 return errmsg; 9244 } 9245 9246 /* 9247 * Called after an option changed: check if something needs to be redrawn. 9248 */ 9249 static void 9250 check_redraw(long_u flags) 9251 { 9252 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */ 9253 int doclear = (flags & P_RCLR) == P_RCLR; 9254 int all = ((flags & P_RALL) == P_RALL || doclear); 9255 9256 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */ 9257 status_redraw_all(); 9258 9259 if ((flags & P_RBUF) || (flags & P_RWIN) || all) 9260 changed_window_setting(); 9261 if (flags & P_RBUF) 9262 redraw_curbuf_later(NOT_VALID); 9263 if (flags & P_RWINONLY) 9264 redraw_later(NOT_VALID); 9265 if (doclear) 9266 redraw_all_later(CLEAR); 9267 else if (all) 9268 redraw_all_later(NOT_VALID); 9269 } 9270 9271 /* 9272 * Find index for option 'arg'. 9273 * Return -1 if not found. 9274 */ 9275 static int 9276 findoption(char_u *arg) 9277 { 9278 int opt_idx; 9279 char *s, *p; 9280 static short quick_tab[27] = {0, 0}; /* quick access table */ 9281 int is_term_opt; 9282 9283 /* 9284 * For first call: Initialize the quick-access table. 9285 * It contains the index for the first option that starts with a certain 9286 * letter. There are 26 letters, plus the first "t_" option. 9287 */ 9288 if (quick_tab[1] == 0) 9289 { 9290 p = options[0].fullname; 9291 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++) 9292 { 9293 if (s[0] != p[0]) 9294 { 9295 if (s[0] == 't' && s[1] == '_') 9296 quick_tab[26] = opt_idx; 9297 else 9298 quick_tab[CharOrdLow(s[0])] = opt_idx; 9299 } 9300 p = s; 9301 } 9302 } 9303 9304 /* 9305 * Check for name starting with an illegal character. 9306 */ 9307 #ifdef EBCDIC 9308 if (!islower(arg[0])) 9309 #else 9310 if (arg[0] < 'a' || arg[0] > 'z') 9311 #endif 9312 return -1; 9313 9314 is_term_opt = (arg[0] == 't' && arg[1] == '_'); 9315 if (is_term_opt) 9316 opt_idx = quick_tab[26]; 9317 else 9318 opt_idx = quick_tab[CharOrdLow(arg[0])]; 9319 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++) 9320 { 9321 if (STRCMP(arg, s) == 0) /* match full name */ 9322 break; 9323 } 9324 if (s == NULL && !is_term_opt) 9325 { 9326 opt_idx = quick_tab[CharOrdLow(arg[0])]; 9327 for ( ; options[opt_idx].fullname != NULL; opt_idx++) 9328 { 9329 s = options[opt_idx].shortname; 9330 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */ 9331 break; 9332 s = NULL; 9333 } 9334 } 9335 if (s == NULL) 9336 opt_idx = -1; 9337 return opt_idx; 9338 } 9339 9340 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) 9341 /* 9342 * Get the value for an option. 9343 * 9344 * Returns: 9345 * Number or Toggle option: 1, *numval gets value. 9346 * String option: 0, *stringval gets allocated string. 9347 * Hidden Number or Toggle option: -1. 9348 * hidden String option: -2. 9349 * unknown option: -3. 9350 */ 9351 int 9352 get_option_value( 9353 char_u *name, 9354 long *numval, 9355 char_u **stringval, /* NULL when only checking existence */ 9356 int opt_flags) 9357 { 9358 int opt_idx; 9359 char_u *varp; 9360 9361 opt_idx = findoption(name); 9362 if (opt_idx < 0) /* unknown option */ 9363 { 9364 int key; 9365 9366 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' 9367 && (key = find_key_option(name)) != 0) 9368 { 9369 char_u key_name[2]; 9370 char_u *p; 9371 9372 if (key < 0) 9373 { 9374 key_name[0] = KEY2TERMCAP0(key); 9375 key_name[1] = KEY2TERMCAP1(key); 9376 } 9377 else 9378 { 9379 key_name[0] = KS_KEY; 9380 key_name[1] = (key & 0xff); 9381 } 9382 p = find_termcode(key_name); 9383 if (p != NULL) 9384 { 9385 if (stringval != NULL) 9386 *stringval = vim_strsave(p); 9387 return 0; 9388 } 9389 } 9390 return -3; 9391 } 9392 9393 varp = get_varp_scope(&(options[opt_idx]), opt_flags); 9394 9395 if (options[opt_idx].flags & P_STRING) 9396 { 9397 if (varp == NULL) /* hidden option */ 9398 return -2; 9399 if (stringval != NULL) 9400 { 9401 #ifdef FEAT_CRYPT 9402 /* never return the value of the crypt key */ 9403 if ((char_u **)varp == &curbuf->b_p_key 9404 && **(char_u **)(varp) != NUL) 9405 *stringval = vim_strsave((char_u *)"*****"); 9406 else 9407 #endif 9408 *stringval = vim_strsave(*(char_u **)(varp)); 9409 } 9410 return 0; 9411 } 9412 9413 if (varp == NULL) /* hidden option */ 9414 return -1; 9415 if (options[opt_idx].flags & P_NUM) 9416 *numval = *(long *)varp; 9417 else 9418 { 9419 /* Special case: 'modified' is b_changed, but we also want to consider 9420 * it set when 'ff' or 'fenc' changed. */ 9421 if ((int *)varp == &curbuf->b_changed) 9422 *numval = curbufIsChanged(); 9423 else 9424 *numval = (long) *(int *)varp; 9425 } 9426 return 1; 9427 } 9428 #endif 9429 9430 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) 9431 /* 9432 * Returns the option attributes and its value. Unlike the above function it 9433 * will return either global value or local value of the option depending on 9434 * what was requested, but it will never return global value if it was 9435 * requested to return local one and vice versa. Neither it will return 9436 * buffer-local value if it was requested to return window-local one. 9437 * 9438 * Pretends that option is absent if it is not present in the requested scope 9439 * (i.e. has no global, window-local or buffer-local value depending on 9440 * opt_type). Uses 9441 * 9442 * Returned flags: 9443 * 0 hidden or unknown option, also option that does not have requested 9444 * type (see SREQ_* in vim.h) 9445 * see SOPT_* in vim.h for other flags 9446 * 9447 * Possible opt_type values: see SREQ_* in vim.h 9448 */ 9449 int 9450 get_option_value_strict( 9451 char_u *name, 9452 long *numval, 9453 char_u **stringval, /* NULL when only obtaining attributes */ 9454 int opt_type, 9455 void *from) 9456 { 9457 int opt_idx; 9458 char_u *varp = NULL; 9459 struct vimoption *p; 9460 int r = 0; 9461 9462 opt_idx = findoption(name); 9463 if (opt_idx < 0) 9464 return 0; 9465 9466 p = &(options[opt_idx]); 9467 9468 /* Hidden option */ 9469 if (p->var == NULL) 9470 return 0; 9471 9472 if (p->flags & P_BOOL) 9473 r |= SOPT_BOOL; 9474 else if (p->flags & P_NUM) 9475 r |= SOPT_NUM; 9476 else if (p->flags & P_STRING) 9477 r |= SOPT_STRING; 9478 9479 if (p->indir == PV_NONE) 9480 { 9481 if (opt_type == SREQ_GLOBAL) 9482 r |= SOPT_GLOBAL; 9483 else 9484 return 0; /* Did not request global-only option */ 9485 } 9486 else 9487 { 9488 if (p->indir & PV_BOTH) 9489 r |= SOPT_GLOBAL; 9490 else if (opt_type == SREQ_GLOBAL) 9491 return 0; /* Requested global option */ 9492 9493 if (p->indir & PV_WIN) 9494 { 9495 if (opt_type == SREQ_BUF) 9496 return 0; /* Did not request window-local option */ 9497 else 9498 r |= SOPT_WIN; 9499 } 9500 else if (p->indir & PV_BUF) 9501 { 9502 if (opt_type == SREQ_WIN) 9503 return 0; /* Did not request buffer-local option */ 9504 else 9505 r |= SOPT_BUF; 9506 } 9507 } 9508 9509 if (stringval == NULL) 9510 return r; 9511 9512 if (opt_type == SREQ_GLOBAL) 9513 varp = p->var; 9514 else 9515 { 9516 if (opt_type == SREQ_BUF) 9517 { 9518 /* Special case: 'modified' is b_changed, but we also want to 9519 * consider it set when 'ff' or 'fenc' changed. */ 9520 if (p->indir == PV_MOD) 9521 { 9522 *numval = bufIsChanged((buf_T *) from); 9523 varp = NULL; 9524 } 9525 #ifdef FEAT_CRYPT 9526 else if (p->indir == PV_KEY) 9527 { 9528 /* never return the value of the crypt key */ 9529 *stringval = NULL; 9530 varp = NULL; 9531 } 9532 #endif 9533 else 9534 { 9535 aco_save_T aco; 9536 aucmd_prepbuf(&aco, (buf_T *) from); 9537 varp = get_varp(p); 9538 aucmd_restbuf(&aco); 9539 } 9540 } 9541 else if (opt_type == SREQ_WIN) 9542 { 9543 win_T *save_curwin; 9544 save_curwin = curwin; 9545 curwin = (win_T *) from; 9546 curbuf = curwin->w_buffer; 9547 varp = get_varp(p); 9548 curwin = save_curwin; 9549 curbuf = curwin->w_buffer; 9550 } 9551 if (varp == p->var) 9552 return (r | SOPT_UNSET); 9553 } 9554 9555 if (varp != NULL) 9556 { 9557 if (p->flags & P_STRING) 9558 *stringval = vim_strsave(*(char_u **)(varp)); 9559 else if (p->flags & P_NUM) 9560 *numval = *(long *) varp; 9561 else 9562 *numval = *(int *)varp; 9563 } 9564 9565 return r; 9566 } 9567 9568 /* 9569 * Iterate over options. First argument is a pointer to a pointer to a 9570 * structure inside options[] array, second is option type like in the above 9571 * function. 9572 * 9573 * If first argument points to NULL it is assumed that iteration just started 9574 * and caller needs the very first value. 9575 * If first argument points to the end marker function returns NULL and sets 9576 * first argument to NULL. 9577 * 9578 * Returns full option name for current option on each call. 9579 */ 9580 char_u * 9581 option_iter_next(void **option, int opt_type) 9582 { 9583 struct vimoption *ret = NULL; 9584 do 9585 { 9586 if (*option == NULL) 9587 *option = (void *) options; 9588 else if (((struct vimoption *) (*option))->fullname == NULL) 9589 { 9590 *option = NULL; 9591 return NULL; 9592 } 9593 else 9594 *option = (void *) (((struct vimoption *) (*option)) + 1); 9595 9596 ret = ((struct vimoption *) (*option)); 9597 9598 /* Hidden option */ 9599 if (ret->var == NULL) 9600 { 9601 ret = NULL; 9602 continue; 9603 } 9604 9605 switch (opt_type) 9606 { 9607 case SREQ_GLOBAL: 9608 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH)) 9609 ret = NULL; 9610 break; 9611 case SREQ_BUF: 9612 if (!(ret->indir & PV_BUF)) 9613 ret = NULL; 9614 break; 9615 case SREQ_WIN: 9616 if (!(ret->indir & PV_WIN)) 9617 ret = NULL; 9618 break; 9619 default: 9620 internal_error("option_iter_next()"); 9621 return NULL; 9622 } 9623 } 9624 while (ret == NULL); 9625 9626 return (char_u *)ret->fullname; 9627 } 9628 #endif 9629 9630 /* 9631 * Set the value of option "name". 9632 * Use "string" for string options, use "number" for other options. 9633 * 9634 * Returns NULL on success or error message on error. 9635 */ 9636 char_u * 9637 set_option_value( 9638 char_u *name, 9639 long number, 9640 char_u *string, 9641 int opt_flags) /* OPT_LOCAL or 0 (both) */ 9642 { 9643 int opt_idx; 9644 char_u *varp; 9645 long_u flags; 9646 9647 opt_idx = findoption(name); 9648 if (opt_idx < 0) 9649 { 9650 int key; 9651 9652 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_' 9653 && (key = find_key_option(name)) != 0) 9654 { 9655 char_u key_name[2]; 9656 9657 if (key < 0) 9658 { 9659 key_name[0] = KEY2TERMCAP0(key); 9660 key_name[1] = KEY2TERMCAP1(key); 9661 } 9662 else 9663 { 9664 key_name[0] = KS_KEY; 9665 key_name[1] = (key & 0xff); 9666 } 9667 add_termcode(key_name, string, FALSE); 9668 if (full_screen) 9669 ttest(FALSE); 9670 redraw_all_later(CLEAR); 9671 return NULL; 9672 } 9673 9674 EMSG2(_("E355: Unknown option: %s"), name); 9675 } 9676 else 9677 { 9678 flags = options[opt_idx].flags; 9679 #ifdef HAVE_SANDBOX 9680 /* Disallow changing some options in the sandbox */ 9681 if (sandbox > 0 && (flags & P_SECURE)) 9682 { 9683 EMSG(_(e_sandbox)); 9684 return NULL; 9685 } 9686 #endif 9687 if (flags & P_STRING) 9688 return set_string_option(opt_idx, string, opt_flags); 9689 else 9690 { 9691 varp = get_varp_scope(&(options[opt_idx]), opt_flags); 9692 if (varp != NULL) /* hidden option is not changed */ 9693 { 9694 if (number == 0 && string != NULL) 9695 { 9696 int idx; 9697 9698 /* Either we are given a string or we are setting option 9699 * to zero. */ 9700 for (idx = 0; string[idx] == '0'; ++idx) 9701 ; 9702 if (string[idx] != NUL || idx == 0) 9703 { 9704 /* There's another character after zeros or the string 9705 * is empty. In both cases, we are trying to set a 9706 * num option using a string. */ 9707 EMSG3(_("E521: Number required: &%s = '%s'"), 9708 name, string); 9709 return NULL; /* do nothing as we hit an error */ 9710 9711 } 9712 } 9713 if (flags & P_NUM) 9714 return set_num_option(opt_idx, varp, number, 9715 NULL, 0, opt_flags); 9716 else 9717 return set_bool_option(opt_idx, varp, (int)number, 9718 opt_flags); 9719 } 9720 } 9721 } 9722 return NULL; 9723 } 9724 9725 /* 9726 * Get the terminal code for a terminal option. 9727 * Returns NULL when not found. 9728 */ 9729 char_u * 9730 get_term_code(char_u *tname) 9731 { 9732 int opt_idx; 9733 char_u *varp; 9734 9735 if (tname[0] != 't' || tname[1] != '_' || 9736 tname[2] == NUL || tname[3] == NUL) 9737 return NULL; 9738 if ((opt_idx = findoption(tname)) >= 0) 9739 { 9740 varp = get_varp(&(options[opt_idx])); 9741 if (varp != NULL) 9742 varp = *(char_u **)(varp); 9743 return varp; 9744 } 9745 return find_termcode(tname + 2); 9746 } 9747 9748 char_u * 9749 get_highlight_default(void) 9750 { 9751 int i; 9752 9753 i = findoption((char_u *)"hl"); 9754 if (i >= 0) 9755 return options[i].def_val[VI_DEFAULT]; 9756 return (char_u *)NULL; 9757 } 9758 9759 #if defined(FEAT_MBYTE) || defined(PROTO) 9760 char_u * 9761 get_encoding_default(void) 9762 { 9763 int i; 9764 9765 i = findoption((char_u *)"enc"); 9766 if (i >= 0) 9767 return options[i].def_val[VI_DEFAULT]; 9768 return (char_u *)NULL; 9769 } 9770 #endif 9771 9772 /* 9773 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number. 9774 */ 9775 static int 9776 find_key_option(char_u *arg) 9777 { 9778 int key; 9779 int modifiers; 9780 9781 /* 9782 * Don't use get_special_key_code() for t_xx, we don't want it to call 9783 * add_termcap_entry(). 9784 */ 9785 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3]) 9786 key = TERMCAP2KEY(arg[2], arg[3]); 9787 else 9788 { 9789 --arg; /* put arg at the '<' */ 9790 modifiers = 0; 9791 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE); 9792 if (modifiers) /* can't handle modifiers here */ 9793 key = 0; 9794 } 9795 return key; 9796 } 9797 9798 /* 9799 * if 'all' == 0: show changed options 9800 * if 'all' == 1: show all normal options 9801 * if 'all' == 2: show all terminal options 9802 */ 9803 static void 9804 showoptions( 9805 int all, 9806 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */ 9807 { 9808 struct vimoption *p; 9809 int col; 9810 int isterm; 9811 char_u *varp; 9812 struct vimoption **items; 9813 int item_count; 9814 int run; 9815 int row, rows; 9816 int cols; 9817 int i; 9818 int len; 9819 9820 #define INC 20 9821 #define GAP 3 9822 9823 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) * 9824 PARAM_COUNT)); 9825 if (items == NULL) 9826 return; 9827 9828 /* Highlight title */ 9829 if (all == 2) 9830 MSG_PUTS_TITLE(_("\n--- Terminal codes ---")); 9831 else if (opt_flags & OPT_GLOBAL) 9832 MSG_PUTS_TITLE(_("\n--- Global option values ---")); 9833 else if (opt_flags & OPT_LOCAL) 9834 MSG_PUTS_TITLE(_("\n--- Local option values ---")); 9835 else 9836 MSG_PUTS_TITLE(_("\n--- Options ---")); 9837 9838 /* 9839 * do the loop two times: 9840 * 1. display the short items 9841 * 2. display the long items (only strings and numbers) 9842 */ 9843 for (run = 1; run <= 2 && !got_int; ++run) 9844 { 9845 /* 9846 * collect the items in items[] 9847 */ 9848 item_count = 0; 9849 for (p = &options[0]; p->fullname != NULL; p++) 9850 { 9851 varp = NULL; 9852 isterm = istermoption(p); 9853 if (opt_flags != 0) 9854 { 9855 if (p->indir != PV_NONE && !isterm) 9856 varp = get_varp_scope(p, opt_flags); 9857 } 9858 else 9859 varp = get_varp(p); 9860 if (varp != NULL 9861 && ((all == 2 && isterm) 9862 || (all == 1 && !isterm) 9863 || (all == 0 && !optval_default(p, varp)))) 9864 { 9865 if (p->flags & P_BOOL) 9866 len = 1; /* a toggle option fits always */ 9867 else 9868 { 9869 option_value2string(p, opt_flags); 9870 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1; 9871 } 9872 if ((len <= INC - GAP && run == 1) || 9873 (len > INC - GAP && run == 2)) 9874 items[item_count++] = p; 9875 } 9876 } 9877 9878 /* 9879 * display the items 9880 */ 9881 if (run == 1) 9882 { 9883 cols = (Columns + GAP - 3) / INC; 9884 if (cols == 0) 9885 cols = 1; 9886 rows = (item_count + cols - 1) / cols; 9887 } 9888 else /* run == 2 */ 9889 rows = item_count; 9890 for (row = 0; row < rows && !got_int; ++row) 9891 { 9892 msg_putchar('\n'); /* go to next line */ 9893 if (got_int) /* 'q' typed in more */ 9894 break; 9895 col = 0; 9896 for (i = row; i < item_count; i += rows) 9897 { 9898 msg_col = col; /* make columns */ 9899 showoneopt(items[i], opt_flags); 9900 col += INC; 9901 } 9902 out_flush(); 9903 ui_breakcheck(); 9904 } 9905 } 9906 vim_free(items); 9907 } 9908 9909 /* 9910 * Return TRUE if option "p" has its default value. 9911 */ 9912 static int 9913 optval_default(struct vimoption *p, char_u *varp) 9914 { 9915 int dvi; 9916 9917 if (varp == NULL) 9918 return TRUE; /* hidden option is always at default */ 9919 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT; 9920 if (p->flags & P_NUM) 9921 return (*(long *)varp == (long)(long_i)p->def_val[dvi]); 9922 if (p->flags & P_BOOL) 9923 /* the cast to long is required for Manx C, long_i is 9924 * needed for MSVC */ 9925 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]); 9926 /* P_STRING */ 9927 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0); 9928 } 9929 9930 /* 9931 * showoneopt: show the value of one option 9932 * must not be called with a hidden option! 9933 */ 9934 static void 9935 showoneopt( 9936 struct vimoption *p, 9937 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */ 9938 { 9939 char_u *varp; 9940 int save_silent = silent_mode; 9941 9942 silent_mode = FALSE; 9943 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ 9944 9945 varp = get_varp_scope(p, opt_flags); 9946 9947 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */ 9948 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed 9949 ? !curbufIsChanged() : !*(int *)varp)) 9950 MSG_PUTS("no"); 9951 else if ((p->flags & P_BOOL) && *(int *)varp < 0) 9952 MSG_PUTS("--"); 9953 else 9954 MSG_PUTS(" "); 9955 MSG_PUTS(p->fullname); 9956 if (!(p->flags & P_BOOL)) 9957 { 9958 msg_putchar('='); 9959 /* put value string in NameBuff */ 9960 option_value2string(p, opt_flags); 9961 msg_outtrans(NameBuff); 9962 } 9963 9964 silent_mode = save_silent; 9965 info_message = FALSE; 9966 } 9967 9968 /* 9969 * Write modified options as ":set" commands to a file. 9970 * 9971 * There are three values for "opt_flags": 9972 * OPT_GLOBAL: Write global option values and fresh values of 9973 * buffer-local options (used for start of a session 9974 * file). 9975 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for 9976 * curwin (used for a vimrc file). 9977 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh 9978 * and local values for window-local options of 9979 * curwin. Local values are also written when at the 9980 * default value, because a modeline or autocommand 9981 * may have set them when doing ":edit file" and the 9982 * user has set them back at the default or fresh 9983 * value. 9984 * When "local_only" is TRUE, don't write fresh 9985 * values, only local values (for ":mkview"). 9986 * (fresh value = value used for a new buffer or window for a local option). 9987 * 9988 * Return FAIL on error, OK otherwise. 9989 */ 9990 int 9991 makeset(FILE *fd, int opt_flags, int local_only) 9992 { 9993 struct vimoption *p; 9994 char_u *varp; /* currently used value */ 9995 char_u *varp_fresh; /* local value */ 9996 char_u *varp_local = NULL; /* fresh value */ 9997 char *cmd; 9998 int round; 9999 int pri; 10000 10001 /* 10002 * The options that don't have a default (terminal name, columns, lines) 10003 * are never written. Terminal options are also not written. 10004 * Do the loop over "options[]" twice: once for options with the 10005 * P_PRI_MKRC flag and once without. 10006 */ 10007 for (pri = 1; pri >= 0; --pri) 10008 { 10009 for (p = &options[0]; !istermoption(p); p++) 10010 if (!(p->flags & P_NO_MKRC) 10011 && !istermoption(p) 10012 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0))) 10013 { 10014 /* skip global option when only doing locals */ 10015 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL)) 10016 continue; 10017 10018 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc 10019 * file, they are always buffer-specific. */ 10020 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB)) 10021 continue; 10022 10023 /* Global values are only written when not at the default value. */ 10024 varp = get_varp_scope(p, opt_flags); 10025 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp)) 10026 continue; 10027 10028 round = 2; 10029 if (p->indir != PV_NONE) 10030 { 10031 if (p->var == VAR_WIN) 10032 { 10033 /* skip window-local option when only doing globals */ 10034 if (!(opt_flags & OPT_LOCAL)) 10035 continue; 10036 /* When fresh value of window-local option is not at the 10037 * default, need to write it too. */ 10038 if (!(opt_flags & OPT_GLOBAL) && !local_only) 10039 { 10040 varp_fresh = get_varp_scope(p, OPT_GLOBAL); 10041 if (!optval_default(p, varp_fresh)) 10042 { 10043 round = 1; 10044 varp_local = varp; 10045 varp = varp_fresh; 10046 } 10047 } 10048 } 10049 } 10050 10051 /* Round 1: fresh value for window-local options. 10052 * Round 2: other values */ 10053 for ( ; round <= 2; varp = varp_local, ++round) 10054 { 10055 if (round == 1 || (opt_flags & OPT_GLOBAL)) 10056 cmd = "set"; 10057 else 10058 cmd = "setlocal"; 10059 10060 if (p->flags & P_BOOL) 10061 { 10062 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL) 10063 return FAIL; 10064 } 10065 else if (p->flags & P_NUM) 10066 { 10067 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL) 10068 return FAIL; 10069 } 10070 else /* P_STRING */ 10071 { 10072 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) 10073 int do_endif = FALSE; 10074 10075 /* Don't set 'syntax' and 'filetype' again if the value is 10076 * already right, avoids reloading the syntax file. */ 10077 if ( 10078 # if defined(FEAT_SYN_HL) 10079 p->indir == PV_SYN 10080 # if defined(FEAT_AUTOCMD) 10081 || 10082 # endif 10083 # endif 10084 # if defined(FEAT_AUTOCMD) 10085 p->indir == PV_FT 10086 # endif 10087 ) 10088 { 10089 if (fprintf(fd, "if &%s != '%s'", p->fullname, 10090 *(char_u **)(varp)) < 0 10091 || put_eol(fd) < 0) 10092 return FAIL; 10093 do_endif = TRUE; 10094 } 10095 #endif 10096 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp, 10097 (p->flags & P_EXPAND) != 0) == FAIL) 10098 return FAIL; 10099 #if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD) 10100 if (do_endif) 10101 { 10102 if (put_line(fd, "endif") == FAIL) 10103 return FAIL; 10104 } 10105 #endif 10106 } 10107 } 10108 } 10109 } 10110 return OK; 10111 } 10112 10113 #if defined(FEAT_FOLDING) || defined(PROTO) 10114 /* 10115 * Generate set commands for the local fold options only. Used when 10116 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options". 10117 */ 10118 int 10119 makefoldset(FILE *fd) 10120 { 10121 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL 10122 # ifdef FEAT_EVAL 10123 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE) 10124 == FAIL 10125 # endif 10126 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE) 10127 == FAIL 10128 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE) 10129 == FAIL 10130 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL 10131 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL 10132 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL 10133 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL 10134 ) 10135 return FAIL; 10136 10137 return OK; 10138 } 10139 #endif 10140 10141 static int 10142 put_setstring( 10143 FILE *fd, 10144 char *cmd, 10145 char *name, 10146 char_u **valuep, 10147 int expand) 10148 { 10149 char_u *s; 10150 char_u *buf; 10151 10152 if (fprintf(fd, "%s %s=", cmd, name) < 0) 10153 return FAIL; 10154 if (*valuep != NULL) 10155 { 10156 /* Output 'pastetoggle' as key names. For other 10157 * options some characters have to be escaped with 10158 * CTRL-V or backslash */ 10159 if (valuep == &p_pt) 10160 { 10161 s = *valuep; 10162 while (*s != NUL) 10163 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) 10164 return FAIL; 10165 } 10166 else if (expand) 10167 { 10168 buf = alloc(MAXPATHL); 10169 if (buf == NULL) 10170 return FAIL; 10171 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); 10172 if (put_escstr(fd, buf, 2) == FAIL) 10173 { 10174 vim_free(buf); 10175 return FAIL; 10176 } 10177 vim_free(buf); 10178 } 10179 else if (put_escstr(fd, *valuep, 2) == FAIL) 10180 return FAIL; 10181 } 10182 if (put_eol(fd) < 0) 10183 return FAIL; 10184 return OK; 10185 } 10186 10187 static int 10188 put_setnum( 10189 FILE *fd, 10190 char *cmd, 10191 char *name, 10192 long *valuep) 10193 { 10194 long wc; 10195 10196 if (fprintf(fd, "%s %s=", cmd, name) < 0) 10197 return FAIL; 10198 if (wc_use_keyname((char_u *)valuep, &wc)) 10199 { 10200 /* print 'wildchar' and 'wildcharm' as a key name */ 10201 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) 10202 return FAIL; 10203 } 10204 else if (fprintf(fd, "%ld", *valuep) < 0) 10205 return FAIL; 10206 if (put_eol(fd) < 0) 10207 return FAIL; 10208 return OK; 10209 } 10210 10211 static int 10212 put_setbool( 10213 FILE *fd, 10214 char *cmd, 10215 char *name, 10216 int value) 10217 { 10218 if (value < 0) /* global/local option using global value */ 10219 return OK; 10220 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0 10221 || put_eol(fd) < 0) 10222 return FAIL; 10223 return OK; 10224 } 10225 10226 /* 10227 * Clear all the terminal options. 10228 * If the option has been allocated, free the memory. 10229 * Terminal options are never hidden or indirect. 10230 */ 10231 void 10232 clear_termoptions(void) 10233 { 10234 /* 10235 * Reset a few things before clearing the old options. This may cause 10236 * outputting a few things that the terminal doesn't understand, but the 10237 * screen will be cleared later, so this is OK. 10238 */ 10239 #ifdef FEAT_MOUSE_TTY 10240 mch_setmouse(FALSE); /* switch mouse off */ 10241 #endif 10242 #ifdef FEAT_TITLE 10243 mch_restore_title(3); /* restore window titles */ 10244 #endif 10245 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI) 10246 /* When starting the GUI close the display opened for the clipboard. 10247 * After restoring the title, because that will need the display. */ 10248 if (gui.starting) 10249 clear_xterm_clip(); 10250 #endif 10251 stoptermcap(); /* stop termcap mode */ 10252 10253 free_termoptions(); 10254 } 10255 10256 void 10257 free_termoptions(void) 10258 { 10259 struct vimoption *p; 10260 10261 for (p = &options[0]; p->fullname != NULL; p++) 10262 if (istermoption(p)) 10263 { 10264 if (p->flags & P_ALLOCED) 10265 free_string_option(*(char_u **)(p->var)); 10266 if (p->flags & P_DEF_ALLOCED) 10267 free_string_option(p->def_val[VI_DEFAULT]); 10268 *(char_u **)(p->var) = empty_option; 10269 p->def_val[VI_DEFAULT] = empty_option; 10270 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED); 10271 } 10272 clear_termcodes(); 10273 } 10274 10275 /* 10276 * Free the string for one term option, if it was allocated. 10277 * Set the string to empty_option and clear allocated flag. 10278 * "var" points to the option value. 10279 */ 10280 void 10281 free_one_termoption(char_u *var) 10282 { 10283 struct vimoption *p; 10284 10285 for (p = &options[0]; p->fullname != NULL; p++) 10286 if (p->var == var) 10287 { 10288 if (p->flags & P_ALLOCED) 10289 free_string_option(*(char_u **)(p->var)); 10290 *(char_u **)(p->var) = empty_option; 10291 p->flags &= ~P_ALLOCED; 10292 break; 10293 } 10294 } 10295 10296 /* 10297 * Set the terminal option defaults to the current value. 10298 * Used after setting the terminal name. 10299 */ 10300 void 10301 set_term_defaults(void) 10302 { 10303 struct vimoption *p; 10304 10305 for (p = &options[0]; p->fullname != NULL; p++) 10306 { 10307 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var)) 10308 { 10309 if (p->flags & P_DEF_ALLOCED) 10310 { 10311 free_string_option(p->def_val[VI_DEFAULT]); 10312 p->flags &= ~P_DEF_ALLOCED; 10313 } 10314 p->def_val[VI_DEFAULT] = *(char_u **)(p->var); 10315 if (p->flags & P_ALLOCED) 10316 { 10317 p->flags |= P_DEF_ALLOCED; 10318 p->flags &= ~P_ALLOCED; /* don't free the value now */ 10319 } 10320 } 10321 } 10322 } 10323 10324 /* 10325 * return TRUE if 'p' starts with 't_' 10326 */ 10327 static int 10328 istermoption(struct vimoption *p) 10329 { 10330 return (p->fullname[0] == 't' && p->fullname[1] == '_'); 10331 } 10332 10333 /* 10334 * Compute columns for ruler and shown command. 'sc_col' is also used to 10335 * decide what the maximum length of a message on the status line can be. 10336 * If there is a status line for the last window, 'sc_col' is independent 10337 * of 'ru_col'. 10338 */ 10339 10340 #define COL_RULER 17 /* columns needed by standard ruler */ 10341 10342 void 10343 comp_col(void) 10344 { 10345 #if defined(FEAT_CMDL_INFO) 10346 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW)); 10347 10348 sc_col = 0; 10349 ru_col = 0; 10350 if (p_ru) 10351 { 10352 # ifdef FEAT_STL_OPT 10353 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1; 10354 # else 10355 ru_col = COL_RULER + 1; 10356 # endif 10357 /* no last status line, adjust sc_col */ 10358 if (!last_has_status) 10359 sc_col = ru_col; 10360 } 10361 if (p_sc) 10362 { 10363 sc_col += SHOWCMD_COLS; 10364 if (!p_ru || last_has_status) /* no need for separating space */ 10365 ++sc_col; 10366 } 10367 sc_col = Columns - sc_col; 10368 ru_col = Columns - ru_col; 10369 if (sc_col <= 0) /* screen too narrow, will become a mess */ 10370 sc_col = 1; 10371 if (ru_col <= 0) 10372 ru_col = 1; 10373 #else 10374 sc_col = Columns; 10375 ru_col = Columns; 10376 #endif 10377 } 10378 10379 /* 10380 * Unset local option value, similar to ":set opt<". 10381 */ 10382 void 10383 unset_global_local_option(char_u *name, void *from) 10384 { 10385 struct vimoption *p; 10386 int opt_idx; 10387 buf_T *buf = (buf_T *)from; 10388 10389 opt_idx = findoption(name); 10390 if (opt_idx < 0) 10391 return; 10392 p = &(options[opt_idx]); 10393 10394 switch ((int)p->indir) 10395 { 10396 /* global option with local value: use local value if it's been set */ 10397 case PV_EP: 10398 clear_string_option(&buf->b_p_ep); 10399 break; 10400 case PV_KP: 10401 clear_string_option(&buf->b_p_kp); 10402 break; 10403 case PV_PATH: 10404 clear_string_option(&buf->b_p_path); 10405 break; 10406 case PV_AR: 10407 buf->b_p_ar = -1; 10408 break; 10409 case PV_BKC: 10410 clear_string_option(&buf->b_p_bkc); 10411 buf->b_bkc_flags = 0; 10412 break; 10413 case PV_TAGS: 10414 clear_string_option(&buf->b_p_tags); 10415 break; 10416 case PV_TC: 10417 clear_string_option(&buf->b_p_tc); 10418 buf->b_tc_flags = 0; 10419 break; 10420 #ifdef FEAT_FIND_ID 10421 case PV_DEF: 10422 clear_string_option(&buf->b_p_def); 10423 break; 10424 case PV_INC: 10425 clear_string_option(&buf->b_p_inc); 10426 break; 10427 #endif 10428 #ifdef FEAT_INS_EXPAND 10429 case PV_DICT: 10430 clear_string_option(&buf->b_p_dict); 10431 break; 10432 case PV_TSR: 10433 clear_string_option(&buf->b_p_tsr); 10434 break; 10435 #endif 10436 case PV_FP: 10437 clear_string_option(&buf->b_p_fp); 10438 break; 10439 #ifdef FEAT_QUICKFIX 10440 case PV_EFM: 10441 clear_string_option(&buf->b_p_efm); 10442 break; 10443 case PV_GP: 10444 clear_string_option(&buf->b_p_gp); 10445 break; 10446 case PV_MP: 10447 clear_string_option(&buf->b_p_mp); 10448 break; 10449 #endif 10450 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10451 case PV_BEXPR: 10452 clear_string_option(&buf->b_p_bexpr); 10453 break; 10454 #endif 10455 #if defined(FEAT_CRYPT) 10456 case PV_CM: 10457 clear_string_option(&buf->b_p_cm); 10458 break; 10459 #endif 10460 #ifdef FEAT_STL_OPT 10461 case PV_STL: 10462 clear_string_option(&((win_T *)from)->w_p_stl); 10463 break; 10464 #endif 10465 case PV_UL: 10466 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; 10467 break; 10468 #ifdef FEAT_LISP 10469 case PV_LW: 10470 clear_string_option(&buf->b_p_lw); 10471 break; 10472 #endif 10473 #ifdef FEAT_MBYTE 10474 case PV_MENC: 10475 clear_string_option(&buf->b_p_menc); 10476 break; 10477 #endif 10478 } 10479 } 10480 10481 /* 10482 * Get pointer to option variable, depending on local or global scope. 10483 */ 10484 static char_u * 10485 get_varp_scope(struct vimoption *p, int opt_flags) 10486 { 10487 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE) 10488 { 10489 if (p->var == VAR_WIN) 10490 return (char_u *)GLOBAL_WO(get_varp(p)); 10491 return p->var; 10492 } 10493 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) 10494 { 10495 switch ((int)p->indir) 10496 { 10497 case PV_FP: return (char_u *)&(curbuf->b_p_fp); 10498 #ifdef FEAT_QUICKFIX 10499 case PV_EFM: return (char_u *)&(curbuf->b_p_efm); 10500 case PV_GP: return (char_u *)&(curbuf->b_p_gp); 10501 case PV_MP: return (char_u *)&(curbuf->b_p_mp); 10502 #endif 10503 case PV_EP: return (char_u *)&(curbuf->b_p_ep); 10504 case PV_KP: return (char_u *)&(curbuf->b_p_kp); 10505 case PV_PATH: return (char_u *)&(curbuf->b_p_path); 10506 case PV_AR: return (char_u *)&(curbuf->b_p_ar); 10507 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags); 10508 case PV_TC: return (char_u *)&(curbuf->b_p_tc); 10509 #ifdef FEAT_FIND_ID 10510 case PV_DEF: return (char_u *)&(curbuf->b_p_def); 10511 case PV_INC: return (char_u *)&(curbuf->b_p_inc); 10512 #endif 10513 #ifdef FEAT_INS_EXPAND 10514 case PV_DICT: return (char_u *)&(curbuf->b_p_dict); 10515 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr); 10516 #endif 10517 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10518 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr); 10519 #endif 10520 #if defined(FEAT_CRYPT) 10521 case PV_CM: return (char_u *)&(curbuf->b_p_cm); 10522 #endif 10523 #ifdef FEAT_STL_OPT 10524 case PV_STL: return (char_u *)&(curwin->w_p_stl); 10525 #endif 10526 case PV_UL: return (char_u *)&(curbuf->b_p_ul); 10527 #ifdef FEAT_LISP 10528 case PV_LW: return (char_u *)&(curbuf->b_p_lw); 10529 #endif 10530 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); 10531 #ifdef FEAT_MBYTE 10532 case PV_MENC: return (char_u *)&(curbuf->b_p_menc); 10533 #endif 10534 } 10535 return NULL; /* "cannot happen" */ 10536 } 10537 return get_varp(p); 10538 } 10539 10540 /* 10541 * Get pointer to option variable. 10542 */ 10543 static char_u * 10544 get_varp(struct vimoption *p) 10545 { 10546 /* hidden option, always return NULL */ 10547 if (p->var == NULL) 10548 return NULL; 10549 10550 switch ((int)p->indir) 10551 { 10552 case PV_NONE: return p->var; 10553 10554 /* global option with local value: use local value if it's been set */ 10555 case PV_EP: return *curbuf->b_p_ep != NUL 10556 ? (char_u *)&curbuf->b_p_ep : p->var; 10557 case PV_KP: return *curbuf->b_p_kp != NUL 10558 ? (char_u *)&curbuf->b_p_kp : p->var; 10559 case PV_PATH: return *curbuf->b_p_path != NUL 10560 ? (char_u *)&(curbuf->b_p_path) : p->var; 10561 case PV_AR: return curbuf->b_p_ar >= 0 10562 ? (char_u *)&(curbuf->b_p_ar) : p->var; 10563 case PV_TAGS: return *curbuf->b_p_tags != NUL 10564 ? (char_u *)&(curbuf->b_p_tags) : p->var; 10565 case PV_TC: return *curbuf->b_p_tc != NUL 10566 ? (char_u *)&(curbuf->b_p_tc) : p->var; 10567 case PV_BKC: return *curbuf->b_p_bkc != NUL 10568 ? (char_u *)&(curbuf->b_p_bkc) : p->var; 10569 #ifdef FEAT_FIND_ID 10570 case PV_DEF: return *curbuf->b_p_def != NUL 10571 ? (char_u *)&(curbuf->b_p_def) : p->var; 10572 case PV_INC: return *curbuf->b_p_inc != NUL 10573 ? (char_u *)&(curbuf->b_p_inc) : p->var; 10574 #endif 10575 #ifdef FEAT_INS_EXPAND 10576 case PV_DICT: return *curbuf->b_p_dict != NUL 10577 ? (char_u *)&(curbuf->b_p_dict) : p->var; 10578 case PV_TSR: return *curbuf->b_p_tsr != NUL 10579 ? (char_u *)&(curbuf->b_p_tsr) : p->var; 10580 #endif 10581 case PV_FP: return *curbuf->b_p_fp != NUL 10582 ? (char_u *)&(curbuf->b_p_fp) : p->var; 10583 #ifdef FEAT_QUICKFIX 10584 case PV_EFM: return *curbuf->b_p_efm != NUL 10585 ? (char_u *)&(curbuf->b_p_efm) : p->var; 10586 case PV_GP: return *curbuf->b_p_gp != NUL 10587 ? (char_u *)&(curbuf->b_p_gp) : p->var; 10588 case PV_MP: return *curbuf->b_p_mp != NUL 10589 ? (char_u *)&(curbuf->b_p_mp) : p->var; 10590 #endif 10591 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 10592 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL 10593 ? (char_u *)&(curbuf->b_p_bexpr) : p->var; 10594 #endif 10595 #if defined(FEAT_CRYPT) 10596 case PV_CM: return *curbuf->b_p_cm != NUL 10597 ? (char_u *)&(curbuf->b_p_cm) : p->var; 10598 #endif 10599 #ifdef FEAT_STL_OPT 10600 case PV_STL: return *curwin->w_p_stl != NUL 10601 ? (char_u *)&(curwin->w_p_stl) : p->var; 10602 #endif 10603 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL 10604 ? (char_u *)&(curbuf->b_p_ul) : p->var; 10605 #ifdef FEAT_LISP 10606 case PV_LW: return *curbuf->b_p_lw != NUL 10607 ? (char_u *)&(curbuf->b_p_lw) : p->var; 10608 #endif 10609 #ifdef FEAT_MBYTE 10610 case PV_MENC: return *curbuf->b_p_menc != NUL 10611 ? (char_u *)&(curbuf->b_p_menc) : p->var; 10612 #endif 10613 10614 #ifdef FEAT_ARABIC 10615 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); 10616 #endif 10617 case PV_LIST: return (char_u *)&(curwin->w_p_list); 10618 #ifdef FEAT_SPELL 10619 case PV_SPELL: return (char_u *)&(curwin->w_p_spell); 10620 #endif 10621 #ifdef FEAT_SYN_HL 10622 case PV_CUC: return (char_u *)&(curwin->w_p_cuc); 10623 case PV_CUL: return (char_u *)&(curwin->w_p_cul); 10624 case PV_CC: return (char_u *)&(curwin->w_p_cc); 10625 #endif 10626 #ifdef FEAT_DIFF 10627 case PV_DIFF: return (char_u *)&(curwin->w_p_diff); 10628 #endif 10629 #ifdef FEAT_FOLDING 10630 case PV_FDC: return (char_u *)&(curwin->w_p_fdc); 10631 case PV_FEN: return (char_u *)&(curwin->w_p_fen); 10632 case PV_FDI: return (char_u *)&(curwin->w_p_fdi); 10633 case PV_FDL: return (char_u *)&(curwin->w_p_fdl); 10634 case PV_FDM: return (char_u *)&(curwin->w_p_fdm); 10635 case PV_FML: return (char_u *)&(curwin->w_p_fml); 10636 case PV_FDN: return (char_u *)&(curwin->w_p_fdn); 10637 # ifdef FEAT_EVAL 10638 case PV_FDE: return (char_u *)&(curwin->w_p_fde); 10639 case PV_FDT: return (char_u *)&(curwin->w_p_fdt); 10640 # endif 10641 case PV_FMR: return (char_u *)&(curwin->w_p_fmr); 10642 #endif 10643 case PV_NU: return (char_u *)&(curwin->w_p_nu); 10644 case PV_RNU: return (char_u *)&(curwin->w_p_rnu); 10645 #ifdef FEAT_LINEBREAK 10646 case PV_NUW: return (char_u *)&(curwin->w_p_nuw); 10647 #endif 10648 case PV_WFH: return (char_u *)&(curwin->w_p_wfh); 10649 case PV_WFW: return (char_u *)&(curwin->w_p_wfw); 10650 #if defined(FEAT_QUICKFIX) 10651 case PV_PVW: return (char_u *)&(curwin->w_p_pvw); 10652 #endif 10653 #ifdef FEAT_RIGHTLEFT 10654 case PV_RL: return (char_u *)&(curwin->w_p_rl); 10655 case PV_RLC: return (char_u *)&(curwin->w_p_rlc); 10656 #endif 10657 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr); 10658 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap); 10659 #ifdef FEAT_LINEBREAK 10660 case PV_LBR: return (char_u *)&(curwin->w_p_lbr); 10661 case PV_BRI: return (char_u *)&(curwin->w_p_bri); 10662 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt); 10663 #endif 10664 #ifdef FEAT_SCROLLBIND 10665 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb); 10666 #endif 10667 #ifdef FEAT_CURSORBIND 10668 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb); 10669 #endif 10670 #ifdef FEAT_CONCEAL 10671 case PV_COCU: return (char_u *)&(curwin->w_p_cocu); 10672 case PV_COLE: return (char_u *)&(curwin->w_p_cole); 10673 #endif 10674 #ifdef FEAT_TERMINAL 10675 case PV_TK: return (char_u *)&(curwin->w_p_tk); 10676 case PV_TMS: return (char_u *)&(curwin->w_p_tms); 10677 #endif 10678 10679 case PV_AI: return (char_u *)&(curbuf->b_p_ai); 10680 case PV_BIN: return (char_u *)&(curbuf->b_p_bin); 10681 #ifdef FEAT_MBYTE 10682 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb); 10683 #endif 10684 case PV_BH: return (char_u *)&(curbuf->b_p_bh); 10685 case PV_BT: return (char_u *)&(curbuf->b_p_bt); 10686 case PV_BL: return (char_u *)&(curbuf->b_p_bl); 10687 case PV_CI: return (char_u *)&(curbuf->b_p_ci); 10688 #ifdef FEAT_CINDENT 10689 case PV_CIN: return (char_u *)&(curbuf->b_p_cin); 10690 case PV_CINK: return (char_u *)&(curbuf->b_p_cink); 10691 case PV_CINO: return (char_u *)&(curbuf->b_p_cino); 10692 #endif 10693 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 10694 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw); 10695 #endif 10696 #ifdef FEAT_COMMENTS 10697 case PV_COM: return (char_u *)&(curbuf->b_p_com); 10698 #endif 10699 #ifdef FEAT_FOLDING 10700 case PV_CMS: return (char_u *)&(curbuf->b_p_cms); 10701 #endif 10702 #ifdef FEAT_INS_EXPAND 10703 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt); 10704 #endif 10705 #ifdef FEAT_COMPL_FUNC 10706 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu); 10707 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu); 10708 #endif 10709 case PV_EOL: return (char_u *)&(curbuf->b_p_eol); 10710 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol); 10711 case PV_ET: return (char_u *)&(curbuf->b_p_et); 10712 #ifdef FEAT_MBYTE 10713 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc); 10714 #endif 10715 case PV_FF: return (char_u *)&(curbuf->b_p_ff); 10716 #ifdef FEAT_AUTOCMD 10717 case PV_FT: return (char_u *)&(curbuf->b_p_ft); 10718 #endif 10719 case PV_FO: return (char_u *)&(curbuf->b_p_fo); 10720 case PV_FLP: return (char_u *)&(curbuf->b_p_flp); 10721 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert); 10722 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch); 10723 case PV_INF: return (char_u *)&(curbuf->b_p_inf); 10724 case PV_ISK: return (char_u *)&(curbuf->b_p_isk); 10725 #ifdef FEAT_FIND_ID 10726 # ifdef FEAT_EVAL 10727 case PV_INEX: return (char_u *)&(curbuf->b_p_inex); 10728 # endif 10729 #endif 10730 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 10731 case PV_INDE: return (char_u *)&(curbuf->b_p_inde); 10732 case PV_INDK: return (char_u *)&(curbuf->b_p_indk); 10733 #endif 10734 #ifdef FEAT_EVAL 10735 case PV_FEX: return (char_u *)&(curbuf->b_p_fex); 10736 #endif 10737 #ifdef FEAT_CRYPT 10738 case PV_KEY: return (char_u *)&(curbuf->b_p_key); 10739 #endif 10740 #ifdef FEAT_LISP 10741 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp); 10742 #endif 10743 case PV_ML: return (char_u *)&(curbuf->b_p_ml); 10744 case PV_MPS: return (char_u *)&(curbuf->b_p_mps); 10745 case PV_MA: return (char_u *)&(curbuf->b_p_ma); 10746 case PV_MOD: return (char_u *)&(curbuf->b_changed); 10747 case PV_NF: return (char_u *)&(curbuf->b_p_nf); 10748 case PV_PI: return (char_u *)&(curbuf->b_p_pi); 10749 #ifdef FEAT_TEXTOBJ 10750 case PV_QE: return (char_u *)&(curbuf->b_p_qe); 10751 #endif 10752 case PV_RO: return (char_u *)&(curbuf->b_p_ro); 10753 #ifdef FEAT_SMARTINDENT 10754 case PV_SI: return (char_u *)&(curbuf->b_p_si); 10755 #endif 10756 case PV_SN: return (char_u *)&(curbuf->b_p_sn); 10757 case PV_STS: return (char_u *)&(curbuf->b_p_sts); 10758 #ifdef FEAT_SEARCHPATH 10759 case PV_SUA: return (char_u *)&(curbuf->b_p_sua); 10760 #endif 10761 case PV_SWF: return (char_u *)&(curbuf->b_p_swf); 10762 #ifdef FEAT_SYN_HL 10763 case PV_SMC: return (char_u *)&(curbuf->b_p_smc); 10764 case PV_SYN: return (char_u *)&(curbuf->b_p_syn); 10765 #endif 10766 #ifdef FEAT_SPELL 10767 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc); 10768 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf); 10769 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl); 10770 #endif 10771 case PV_SW: return (char_u *)&(curbuf->b_p_sw); 10772 case PV_TS: return (char_u *)&(curbuf->b_p_ts); 10773 case PV_TW: return (char_u *)&(curbuf->b_p_tw); 10774 case PV_TX: return (char_u *)&(curbuf->b_p_tx); 10775 #ifdef FEAT_PERSISTENT_UNDO 10776 case PV_UDF: return (char_u *)&(curbuf->b_p_udf); 10777 #endif 10778 case PV_WM: return (char_u *)&(curbuf->b_p_wm); 10779 #ifdef FEAT_KEYMAP 10780 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); 10781 #endif 10782 #ifdef FEAT_SIGNS 10783 case PV_SCL: return (char_u *)&(curwin->w_p_scl); 10784 #endif 10785 default: IEMSG(_("E356: get_varp ERROR")); 10786 } 10787 /* always return a valid pointer to avoid a crash! */ 10788 return (char_u *)&(curbuf->b_p_wm); 10789 } 10790 10791 /* 10792 * Get the value of 'equalprg', either the buffer-local one or the global one. 10793 */ 10794 char_u * 10795 get_equalprg(void) 10796 { 10797 if (*curbuf->b_p_ep == NUL) 10798 return p_ep; 10799 return curbuf->b_p_ep; 10800 } 10801 10802 /* 10803 * Copy options from one window to another. 10804 * Used when splitting a window. 10805 */ 10806 void 10807 win_copy_options(win_T *wp_from, win_T *wp_to) 10808 { 10809 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); 10810 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); 10811 # ifdef FEAT_RIGHTLEFT 10812 # ifdef FEAT_FKMAP 10813 /* Is this right? */ 10814 wp_to->w_farsi = wp_from->w_farsi; 10815 # endif 10816 # endif 10817 #if defined(FEAT_LINEBREAK) 10818 briopt_check(wp_to); 10819 #endif 10820 } 10821 10822 /* 10823 * Copy the options from one winopt_T to another. 10824 * Doesn't free the old option values in "to", use clear_winopt() for that. 10825 * The 'scroll' option is not copied, because it depends on the window height. 10826 * The 'previewwindow' option is reset, there can be only one preview window. 10827 */ 10828 void 10829 copy_winopt(winopt_T *from, winopt_T *to) 10830 { 10831 #ifdef FEAT_ARABIC 10832 to->wo_arab = from->wo_arab; 10833 #endif 10834 to->wo_list = from->wo_list; 10835 to->wo_nu = from->wo_nu; 10836 to->wo_rnu = from->wo_rnu; 10837 #ifdef FEAT_LINEBREAK 10838 to->wo_nuw = from->wo_nuw; 10839 #endif 10840 #ifdef FEAT_RIGHTLEFT 10841 to->wo_rl = from->wo_rl; 10842 to->wo_rlc = vim_strsave(from->wo_rlc); 10843 #endif 10844 #ifdef FEAT_STL_OPT 10845 to->wo_stl = vim_strsave(from->wo_stl); 10846 #endif 10847 to->wo_wrap = from->wo_wrap; 10848 #ifdef FEAT_DIFF 10849 to->wo_wrap_save = from->wo_wrap_save; 10850 #endif 10851 #ifdef FEAT_LINEBREAK 10852 to->wo_lbr = from->wo_lbr; 10853 to->wo_bri = from->wo_bri; 10854 to->wo_briopt = vim_strsave(from->wo_briopt); 10855 #endif 10856 #ifdef FEAT_SCROLLBIND 10857 to->wo_scb = from->wo_scb; 10858 to->wo_scb_save = from->wo_scb_save; 10859 #endif 10860 #ifdef FEAT_CURSORBIND 10861 to->wo_crb = from->wo_crb; 10862 to->wo_crb_save = from->wo_crb_save; 10863 #endif 10864 #ifdef FEAT_SPELL 10865 to->wo_spell = from->wo_spell; 10866 #endif 10867 #ifdef FEAT_SYN_HL 10868 to->wo_cuc = from->wo_cuc; 10869 to->wo_cul = from->wo_cul; 10870 to->wo_cc = vim_strsave(from->wo_cc); 10871 #endif 10872 #ifdef FEAT_DIFF 10873 to->wo_diff = from->wo_diff; 10874 to->wo_diff_saved = from->wo_diff_saved; 10875 #endif 10876 #ifdef FEAT_CONCEAL 10877 to->wo_cocu = vim_strsave(from->wo_cocu); 10878 to->wo_cole = from->wo_cole; 10879 #endif 10880 #ifdef FEAT_TERMINAL 10881 to->wo_tk = vim_strsave(from->wo_tk); 10882 to->wo_tms = vim_strsave(from->wo_tms); 10883 #endif 10884 #ifdef FEAT_FOLDING 10885 to->wo_fdc = from->wo_fdc; 10886 to->wo_fdc_save = from->wo_fdc_save; 10887 to->wo_fen = from->wo_fen; 10888 to->wo_fen_save = from->wo_fen_save; 10889 to->wo_fdi = vim_strsave(from->wo_fdi); 10890 to->wo_fml = from->wo_fml; 10891 to->wo_fdl = from->wo_fdl; 10892 to->wo_fdl_save = from->wo_fdl_save; 10893 to->wo_fdm = vim_strsave(from->wo_fdm); 10894 to->wo_fdm_save = from->wo_diff_saved 10895 ? vim_strsave(from->wo_fdm_save) : empty_option; 10896 to->wo_fdn = from->wo_fdn; 10897 # ifdef FEAT_EVAL 10898 to->wo_fde = vim_strsave(from->wo_fde); 10899 to->wo_fdt = vim_strsave(from->wo_fdt); 10900 # endif 10901 to->wo_fmr = vim_strsave(from->wo_fmr); 10902 #endif 10903 #ifdef FEAT_SIGNS 10904 to->wo_scl = vim_strsave(from->wo_scl); 10905 #endif 10906 check_winopt(to); /* don't want NULL pointers */ 10907 } 10908 10909 /* 10910 * Check string options in a window for a NULL value. 10911 */ 10912 void 10913 check_win_options(win_T *win) 10914 { 10915 check_winopt(&win->w_onebuf_opt); 10916 check_winopt(&win->w_allbuf_opt); 10917 } 10918 10919 /* 10920 * Check for NULL pointers in a winopt_T and replace them with empty_option. 10921 */ 10922 static void 10923 check_winopt(winopt_T *wop UNUSED) 10924 { 10925 #ifdef FEAT_FOLDING 10926 check_string_option(&wop->wo_fdi); 10927 check_string_option(&wop->wo_fdm); 10928 check_string_option(&wop->wo_fdm_save); 10929 # ifdef FEAT_EVAL 10930 check_string_option(&wop->wo_fde); 10931 check_string_option(&wop->wo_fdt); 10932 # endif 10933 check_string_option(&wop->wo_fmr); 10934 #endif 10935 #ifdef FEAT_SIGNS 10936 check_string_option(&wop->wo_scl); 10937 #endif 10938 #ifdef FEAT_RIGHTLEFT 10939 check_string_option(&wop->wo_rlc); 10940 #endif 10941 #ifdef FEAT_STL_OPT 10942 check_string_option(&wop->wo_stl); 10943 #endif 10944 #ifdef FEAT_SYN_HL 10945 check_string_option(&wop->wo_cc); 10946 #endif 10947 #ifdef FEAT_CONCEAL 10948 check_string_option(&wop->wo_cocu); 10949 #endif 10950 #ifdef FEAT_TERMINAL 10951 check_string_option(&wop->wo_tk); 10952 check_string_option(&wop->wo_tms); 10953 #endif 10954 #ifdef FEAT_LINEBREAK 10955 check_string_option(&wop->wo_briopt); 10956 #endif 10957 } 10958 10959 /* 10960 * Free the allocated memory inside a winopt_T. 10961 */ 10962 void 10963 clear_winopt(winopt_T *wop UNUSED) 10964 { 10965 #ifdef FEAT_FOLDING 10966 clear_string_option(&wop->wo_fdi); 10967 clear_string_option(&wop->wo_fdm); 10968 clear_string_option(&wop->wo_fdm_save); 10969 # ifdef FEAT_EVAL 10970 clear_string_option(&wop->wo_fde); 10971 clear_string_option(&wop->wo_fdt); 10972 # endif 10973 clear_string_option(&wop->wo_fmr); 10974 #endif 10975 #ifdef FEAT_SIGNS 10976 clear_string_option(&wop->wo_scl); 10977 #endif 10978 #ifdef FEAT_LINEBREAK 10979 clear_string_option(&wop->wo_briopt); 10980 #endif 10981 #ifdef FEAT_RIGHTLEFT 10982 clear_string_option(&wop->wo_rlc); 10983 #endif 10984 #ifdef FEAT_STL_OPT 10985 clear_string_option(&wop->wo_stl); 10986 #endif 10987 #ifdef FEAT_SYN_HL 10988 clear_string_option(&wop->wo_cc); 10989 #endif 10990 #ifdef FEAT_CONCEAL 10991 clear_string_option(&wop->wo_cocu); 10992 #endif 10993 #ifdef FEAT_TERMINAL 10994 clear_string_option(&wop->wo_tk); 10995 clear_string_option(&wop->wo_tms); 10996 #endif 10997 } 10998 10999 /* 11000 * Copy global option values to local options for one buffer. 11001 * Used when creating a new buffer and sometimes when entering a buffer. 11002 * flags: 11003 * BCO_ENTER We will enter the buf buffer. 11004 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when 11005 * appropriate. 11006 * BCO_NOHELP Don't copy the values to a help buffer. 11007 */ 11008 void 11009 buf_copy_options(buf_T *buf, int flags) 11010 { 11011 int should_copy = TRUE; 11012 char_u *save_p_isk = NULL; /* init for GCC */ 11013 int dont_do_help; 11014 int did_isk = FALSE; 11015 11016 /* 11017 * Skip this when the option defaults have not been set yet. Happens when 11018 * main() allocates the first buffer. 11019 */ 11020 if (p_cpo != NULL) 11021 { 11022 /* 11023 * Always copy when entering and 'cpo' contains 'S'. 11024 * Don't copy when already initialized. 11025 * Don't copy when 'cpo' contains 's' and not entering. 11026 * 'S' BCO_ENTER initialized 's' should_copy 11027 * yes yes X X TRUE 11028 * yes no yes X FALSE 11029 * no X yes X FALSE 11030 * X no no yes FALSE 11031 * X no no no TRUE 11032 * no yes no X TRUE 11033 */ 11034 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER)) 11035 && (buf->b_p_initialized 11036 || (!(flags & BCO_ENTER) 11037 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL))) 11038 should_copy = FALSE; 11039 11040 if (should_copy || (flags & BCO_ALWAYS)) 11041 { 11042 /* Don't copy the options specific to a help buffer when 11043 * BCO_NOHELP is given or the options were initialized already 11044 * (jumping back to a help file with CTRL-T or CTRL-O) */ 11045 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help) 11046 || buf->b_p_initialized; 11047 if (dont_do_help) /* don't free b_p_isk */ 11048 { 11049 save_p_isk = buf->b_p_isk; 11050 buf->b_p_isk = NULL; 11051 } 11052 /* 11053 * Always free the allocated strings. 11054 * If not already initialized, set 'readonly' and copy 'fileformat'. 11055 */ 11056 if (!buf->b_p_initialized) 11057 { 11058 free_buf_options(buf, TRUE); 11059 buf->b_p_ro = FALSE; /* don't copy readonly */ 11060 buf->b_p_tx = p_tx; 11061 #ifdef FEAT_MBYTE 11062 buf->b_p_fenc = vim_strsave(p_fenc); 11063 #endif 11064 switch (*p_ffs) 11065 { 11066 case 'm': 11067 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break; 11068 case 'd': 11069 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break; 11070 case 'u': 11071 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break; 11072 default: 11073 buf->b_p_ff = vim_strsave(p_ff); 11074 } 11075 if (buf->b_p_ff != NULL) 11076 buf->b_start_ffc = *buf->b_p_ff; 11077 buf->b_p_bh = empty_option; 11078 buf->b_p_bt = empty_option; 11079 } 11080 else 11081 free_buf_options(buf, FALSE); 11082 11083 buf->b_p_ai = p_ai; 11084 buf->b_p_ai_nopaste = p_ai_nopaste; 11085 buf->b_p_sw = p_sw; 11086 buf->b_p_tw = p_tw; 11087 buf->b_p_tw_nopaste = p_tw_nopaste; 11088 buf->b_p_tw_nobin = p_tw_nobin; 11089 buf->b_p_wm = p_wm; 11090 buf->b_p_wm_nopaste = p_wm_nopaste; 11091 buf->b_p_wm_nobin = p_wm_nobin; 11092 buf->b_p_bin = p_bin; 11093 #ifdef FEAT_MBYTE 11094 buf->b_p_bomb = p_bomb; 11095 #endif 11096 buf->b_p_fixeol = p_fixeol; 11097 buf->b_p_et = p_et; 11098 buf->b_p_et_nobin = p_et_nobin; 11099 buf->b_p_et_nopaste = p_et_nopaste; 11100 buf->b_p_ml = p_ml; 11101 buf->b_p_ml_nobin = p_ml_nobin; 11102 buf->b_p_inf = p_inf; 11103 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf; 11104 #ifdef FEAT_INS_EXPAND 11105 buf->b_p_cpt = vim_strsave(p_cpt); 11106 #endif 11107 #ifdef FEAT_COMPL_FUNC 11108 buf->b_p_cfu = vim_strsave(p_cfu); 11109 buf->b_p_ofu = vim_strsave(p_ofu); 11110 #endif 11111 buf->b_p_sts = p_sts; 11112 buf->b_p_sts_nopaste = p_sts_nopaste; 11113 buf->b_p_sn = p_sn; 11114 #ifdef FEAT_COMMENTS 11115 buf->b_p_com = vim_strsave(p_com); 11116 #endif 11117 #ifdef FEAT_FOLDING 11118 buf->b_p_cms = vim_strsave(p_cms); 11119 #endif 11120 buf->b_p_fo = vim_strsave(p_fo); 11121 buf->b_p_flp = vim_strsave(p_flp); 11122 buf->b_p_nf = vim_strsave(p_nf); 11123 buf->b_p_mps = vim_strsave(p_mps); 11124 #ifdef FEAT_SMARTINDENT 11125 buf->b_p_si = p_si; 11126 #endif 11127 buf->b_p_ci = p_ci; 11128 #ifdef FEAT_CINDENT 11129 buf->b_p_cin = p_cin; 11130 buf->b_p_cink = vim_strsave(p_cink); 11131 buf->b_p_cino = vim_strsave(p_cino); 11132 #endif 11133 #ifdef FEAT_AUTOCMD 11134 /* Don't copy 'filetype', it must be detected */ 11135 buf->b_p_ft = empty_option; 11136 #endif 11137 buf->b_p_pi = p_pi; 11138 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT) 11139 buf->b_p_cinw = vim_strsave(p_cinw); 11140 #endif 11141 #ifdef FEAT_LISP 11142 buf->b_p_lisp = p_lisp; 11143 #endif 11144 #ifdef FEAT_SYN_HL 11145 /* Don't copy 'syntax', it must be set */ 11146 buf->b_p_syn = empty_option; 11147 buf->b_p_smc = p_smc; 11148 buf->b_s.b_syn_isk = empty_option; 11149 #endif 11150 #ifdef FEAT_SPELL 11151 buf->b_s.b_p_spc = vim_strsave(p_spc); 11152 (void)compile_cap_prog(&buf->b_s); 11153 buf->b_s.b_p_spf = vim_strsave(p_spf); 11154 buf->b_s.b_p_spl = vim_strsave(p_spl); 11155 #endif 11156 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL) 11157 buf->b_p_inde = vim_strsave(p_inde); 11158 buf->b_p_indk = vim_strsave(p_indk); 11159 #endif 11160 buf->b_p_fp = empty_option; 11161 #if defined(FEAT_EVAL) 11162 buf->b_p_fex = vim_strsave(p_fex); 11163 #endif 11164 #ifdef FEAT_CRYPT 11165 buf->b_p_key = vim_strsave(p_key); 11166 #endif 11167 #ifdef FEAT_SEARCHPATH 11168 buf->b_p_sua = vim_strsave(p_sua); 11169 #endif 11170 #ifdef FEAT_KEYMAP 11171 buf->b_p_keymap = vim_strsave(p_keymap); 11172 buf->b_kmap_state |= KEYMAP_INIT; 11173 #endif 11174 /* This isn't really an option, but copying the langmap and IME 11175 * state from the current buffer is better than resetting it. */ 11176 buf->b_p_iminsert = p_iminsert; 11177 buf->b_p_imsearch = p_imsearch; 11178 11179 /* options that are normally global but also have a local value 11180 * are not copied, start using the global value */ 11181 buf->b_p_ar = -1; 11182 buf->b_p_ul = NO_LOCAL_UNDOLEVEL; 11183 buf->b_p_bkc = empty_option; 11184 buf->b_bkc_flags = 0; 11185 #ifdef FEAT_QUICKFIX 11186 buf->b_p_gp = empty_option; 11187 buf->b_p_mp = empty_option; 11188 buf->b_p_efm = empty_option; 11189 #endif 11190 buf->b_p_ep = empty_option; 11191 buf->b_p_kp = empty_option; 11192 buf->b_p_path = empty_option; 11193 buf->b_p_tags = empty_option; 11194 buf->b_p_tc = empty_option; 11195 buf->b_tc_flags = 0; 11196 #ifdef FEAT_FIND_ID 11197 buf->b_p_def = empty_option; 11198 buf->b_p_inc = empty_option; 11199 # ifdef FEAT_EVAL 11200 buf->b_p_inex = vim_strsave(p_inex); 11201 # endif 11202 #endif 11203 #ifdef FEAT_INS_EXPAND 11204 buf->b_p_dict = empty_option; 11205 buf->b_p_tsr = empty_option; 11206 #endif 11207 #ifdef FEAT_TEXTOBJ 11208 buf->b_p_qe = vim_strsave(p_qe); 11209 #endif 11210 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) 11211 buf->b_p_bexpr = empty_option; 11212 #endif 11213 #if defined(FEAT_CRYPT) 11214 buf->b_p_cm = empty_option; 11215 #endif 11216 #ifdef FEAT_PERSISTENT_UNDO 11217 buf->b_p_udf = p_udf; 11218 #endif 11219 #ifdef FEAT_LISP 11220 buf->b_p_lw = empty_option; 11221 #endif 11222 #ifdef FEAT_MBYTE 11223 buf->b_p_menc = empty_option; 11224 #endif 11225 11226 /* 11227 * Don't copy the options set by ex_help(), use the saved values, 11228 * when going from a help buffer to a non-help buffer. 11229 * Don't touch these at all when BCO_NOHELP is used and going from 11230 * or to a help buffer. 11231 */ 11232 if (dont_do_help) 11233 buf->b_p_isk = save_p_isk; 11234 else 11235 { 11236 buf->b_p_isk = vim_strsave(p_isk); 11237 did_isk = TRUE; 11238 buf->b_p_ts = p_ts; 11239 buf->b_help = FALSE; 11240 if (buf->b_p_bt[0] == 'h') 11241 clear_string_option(&buf->b_p_bt); 11242 buf->b_p_ma = p_ma; 11243 } 11244 } 11245 11246 /* 11247 * When the options should be copied (ignoring BCO_ALWAYS), set the 11248 * flag that indicates that the options have been initialized. 11249 */ 11250 if (should_copy) 11251 buf->b_p_initialized = TRUE; 11252 } 11253 11254 check_buf_options(buf); /* make sure we don't have NULLs */ 11255 if (did_isk) 11256 (void)buf_init_chartab(buf, FALSE); 11257 } 11258 11259 /* 11260 * Reset the 'modifiable' option and its default value. 11261 */ 11262 void 11263 reset_modifiable(void) 11264 { 11265 int opt_idx; 11266 11267 curbuf->b_p_ma = FALSE; 11268 p_ma = FALSE; 11269 opt_idx = findoption((char_u *)"ma"); 11270 if (opt_idx >= 0) 11271 options[opt_idx].def_val[VI_DEFAULT] = FALSE; 11272 } 11273 11274 /* 11275 * Set the global value for 'iminsert' to the local value. 11276 */ 11277 void 11278 set_iminsert_global(void) 11279 { 11280 p_iminsert = curbuf->b_p_iminsert; 11281 } 11282 11283 /* 11284 * Set the global value for 'imsearch' to the local value. 11285 */ 11286 void 11287 set_imsearch_global(void) 11288 { 11289 p_imsearch = curbuf->b_p_imsearch; 11290 } 11291 11292 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 11293 static int expand_option_idx = -1; 11294 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL}; 11295 static int expand_option_flags = 0; 11296 11297 void 11298 set_context_in_set_cmd( 11299 expand_T *xp, 11300 char_u *arg, 11301 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ 11302 { 11303 int nextchar; 11304 long_u flags = 0; /* init for GCC */ 11305 int opt_idx = 0; /* init for GCC */ 11306 char_u *p; 11307 char_u *s; 11308 int is_term_option = FALSE; 11309 int key; 11310 11311 expand_option_flags = opt_flags; 11312 11313 xp->xp_context = EXPAND_SETTINGS; 11314 if (*arg == NUL) 11315 { 11316 xp->xp_pattern = arg; 11317 return; 11318 } 11319 p = arg + STRLEN(arg) - 1; 11320 if (*p == ' ' && *(p - 1) != '\\') 11321 { 11322 xp->xp_pattern = p + 1; 11323 return; 11324 } 11325 while (p > arg) 11326 { 11327 s = p; 11328 /* count number of backslashes before ' ' or ',' */ 11329 if (*p == ' ' || *p == ',') 11330 { 11331 while (s > arg && *(s - 1) == '\\') 11332 --s; 11333 } 11334 /* break at a space with an even number of backslashes */ 11335 if (*p == ' ' && ((p - s) & 1) == 0) 11336 { 11337 ++p; 11338 break; 11339 } 11340 --p; 11341 } 11342 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0) 11343 { 11344 xp->xp_context = EXPAND_BOOL_SETTINGS; 11345 p += 2; 11346 } 11347 if (STRNCMP(p, "inv", 3) == 0) 11348 { 11349 xp->xp_context = EXPAND_BOOL_SETTINGS; 11350 p += 3; 11351 } 11352 xp->xp_pattern = arg = p; 11353 if (*arg == '<') 11354 { 11355 while (*p != '>') 11356 if (*p++ == NUL) /* expand terminal option name */ 11357 return; 11358 key = get_special_key_code(arg + 1); 11359 if (key == 0) /* unknown name */ 11360 { 11361 xp->xp_context = EXPAND_NOTHING; 11362 return; 11363 } 11364 nextchar = *++p; 11365 is_term_option = TRUE; 11366 expand_option_name[2] = KEY2TERMCAP0(key); 11367 expand_option_name[3] = KEY2TERMCAP1(key); 11368 } 11369 else 11370 { 11371 if (p[0] == 't' && p[1] == '_') 11372 { 11373 p += 2; 11374 if (*p != NUL) 11375 ++p; 11376 if (*p == NUL) 11377 return; /* expand option name */ 11378 nextchar = *++p; 11379 is_term_option = TRUE; 11380 expand_option_name[2] = p[-2]; 11381 expand_option_name[3] = p[-1]; 11382 } 11383 else 11384 { 11385 /* Allow * wildcard */ 11386 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') 11387 p++; 11388 if (*p == NUL) 11389 return; 11390 nextchar = *p; 11391 *p = NUL; 11392 opt_idx = findoption(arg); 11393 *p = nextchar; 11394 if (opt_idx == -1 || options[opt_idx].var == NULL) 11395 { 11396 xp->xp_context = EXPAND_NOTHING; 11397 return; 11398 } 11399 flags = options[opt_idx].flags; 11400 if (flags & P_BOOL) 11401 { 11402 xp->xp_context = EXPAND_NOTHING; 11403 return; 11404 } 11405 } 11406 } 11407 /* handle "-=" and "+=" */ 11408 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=') 11409 { 11410 ++p; 11411 nextchar = '='; 11412 } 11413 if ((nextchar != '=' && nextchar != ':') 11414 || xp->xp_context == EXPAND_BOOL_SETTINGS) 11415 { 11416 xp->xp_context = EXPAND_UNSUCCESSFUL; 11417 return; 11418 } 11419 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL) 11420 { 11421 xp->xp_context = EXPAND_OLD_SETTING; 11422 if (is_term_option) 11423 expand_option_idx = -1; 11424 else 11425 expand_option_idx = opt_idx; 11426 xp->xp_pattern = p + 1; 11427 return; 11428 } 11429 xp->xp_context = EXPAND_NOTHING; 11430 if (is_term_option || (flags & P_NUM)) 11431 return; 11432 11433 xp->xp_pattern = p + 1; 11434 11435 if (flags & P_EXPAND) 11436 { 11437 p = options[opt_idx].var; 11438 if (p == (char_u *)&p_bdir 11439 || p == (char_u *)&p_dir 11440 || p == (char_u *)&p_path 11441 || p == (char_u *)&p_pp 11442 || p == (char_u *)&p_rtp 11443 #ifdef FEAT_SEARCHPATH 11444 || p == (char_u *)&p_cdpath 11445 #endif 11446 #ifdef FEAT_SESSION 11447 || p == (char_u *)&p_vdir 11448 #endif 11449 ) 11450 { 11451 xp->xp_context = EXPAND_DIRECTORIES; 11452 if (p == (char_u *)&p_path 11453 #ifdef FEAT_SEARCHPATH 11454 || p == (char_u *)&p_cdpath 11455 #endif 11456 ) 11457 xp->xp_backslash = XP_BS_THREE; 11458 else 11459 xp->xp_backslash = XP_BS_ONE; 11460 } 11461 else 11462 { 11463 xp->xp_context = EXPAND_FILES; 11464 /* for 'tags' need three backslashes for a space */ 11465 if (p == (char_u *)&p_tags) 11466 xp->xp_backslash = XP_BS_THREE; 11467 else 11468 xp->xp_backslash = XP_BS_ONE; 11469 } 11470 } 11471 11472 /* For an option that is a list of file names, find the start of the 11473 * last file name. */ 11474 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p) 11475 { 11476 /* count number of backslashes before ' ' or ',' */ 11477 if (*p == ' ' || *p == ',') 11478 { 11479 s = p; 11480 while (s > xp->xp_pattern && *(s - 1) == '\\') 11481 --s; 11482 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3)) 11483 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0)) 11484 { 11485 xp->xp_pattern = p + 1; 11486 break; 11487 } 11488 } 11489 11490 #ifdef FEAT_SPELL 11491 /* for 'spellsuggest' start at "file:" */ 11492 if (options[opt_idx].var == (char_u *)&p_sps 11493 && STRNCMP(p, "file:", 5) == 0) 11494 { 11495 xp->xp_pattern = p + 5; 11496 break; 11497 } 11498 #endif 11499 } 11500 11501 return; 11502 } 11503 11504 int 11505 ExpandSettings( 11506 expand_T *xp, 11507 regmatch_T *regmatch, 11508 int *num_file, 11509 char_u ***file) 11510 { 11511 int num_normal = 0; /* Nr of matching non-term-code settings */ 11512 int num_term = 0; /* Nr of matching terminal code settings */ 11513 int opt_idx; 11514 int match; 11515 int count = 0; 11516 char_u *str; 11517 int loop; 11518 int is_term_opt; 11519 char_u name_buf[MAX_KEY_NAME_LEN]; 11520 static char *(names[]) = {"all", "termcap"}; 11521 int ic = regmatch->rm_ic; /* remember the ignore-case flag */ 11522 11523 /* do this loop twice: 11524 * loop == 0: count the number of matching options 11525 * loop == 1: copy the matching options into allocated memory 11526 */ 11527 for (loop = 0; loop <= 1; ++loop) 11528 { 11529 regmatch->rm_ic = ic; 11530 if (xp->xp_context != EXPAND_BOOL_SETTINGS) 11531 { 11532 for (match = 0; match < (int)(sizeof(names) / sizeof(char *)); 11533 ++match) 11534 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0)) 11535 { 11536 if (loop == 0) 11537 num_normal++; 11538 else 11539 (*file)[count++] = vim_strsave((char_u *)names[match]); 11540 } 11541 } 11542 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL; 11543 opt_idx++) 11544 { 11545 if (options[opt_idx].var == NULL) 11546 continue; 11547 if (xp->xp_context == EXPAND_BOOL_SETTINGS 11548 && !(options[opt_idx].flags & P_BOOL)) 11549 continue; 11550 is_term_opt = istermoption(&options[opt_idx]); 11551 if (is_term_opt && num_normal > 0) 11552 continue; 11553 match = FALSE; 11554 if (vim_regexec(regmatch, str, (colnr_T)0) 11555 || (options[opt_idx].shortname != NULL 11556 && vim_regexec(regmatch, 11557 (char_u *)options[opt_idx].shortname, (colnr_T)0))) 11558 match = TRUE; 11559 else if (is_term_opt) 11560 { 11561 name_buf[0] = '<'; 11562 name_buf[1] = 't'; 11563 name_buf[2] = '_'; 11564 name_buf[3] = str[2]; 11565 name_buf[4] = str[3]; 11566 name_buf[5] = '>'; 11567 name_buf[6] = NUL; 11568 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11569 { 11570 match = TRUE; 11571 str = name_buf; 11572 } 11573 } 11574 if (match) 11575 { 11576 if (loop == 0) 11577 { 11578 if (is_term_opt) 11579 num_term++; 11580 else 11581 num_normal++; 11582 } 11583 else 11584 (*file)[count++] = vim_strsave(str); 11585 } 11586 } 11587 /* 11588 * Check terminal key codes, these are not in the option table 11589 */ 11590 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) 11591 { 11592 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) 11593 { 11594 if (!isprint(str[0]) || !isprint(str[1])) 11595 continue; 11596 11597 name_buf[0] = 't'; 11598 name_buf[1] = '_'; 11599 name_buf[2] = str[0]; 11600 name_buf[3] = str[1]; 11601 name_buf[4] = NUL; 11602 11603 match = FALSE; 11604 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11605 match = TRUE; 11606 else 11607 { 11608 name_buf[0] = '<'; 11609 name_buf[1] = 't'; 11610 name_buf[2] = '_'; 11611 name_buf[3] = str[0]; 11612 name_buf[4] = str[1]; 11613 name_buf[5] = '>'; 11614 name_buf[6] = NUL; 11615 11616 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11617 match = TRUE; 11618 } 11619 if (match) 11620 { 11621 if (loop == 0) 11622 num_term++; 11623 else 11624 (*file)[count++] = vim_strsave(name_buf); 11625 } 11626 } 11627 11628 /* 11629 * Check special key names. 11630 */ 11631 regmatch->rm_ic = TRUE; /* ignore case here */ 11632 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) 11633 { 11634 name_buf[0] = '<'; 11635 STRCPY(name_buf + 1, str); 11636 STRCAT(name_buf, ">"); 11637 11638 if (vim_regexec(regmatch, name_buf, (colnr_T)0)) 11639 { 11640 if (loop == 0) 11641 num_term++; 11642 else 11643 (*file)[count++] = vim_strsave(name_buf); 11644 } 11645 } 11646 } 11647 if (loop == 0) 11648 { 11649 if (num_normal > 0) 11650 *num_file = num_normal; 11651 else if (num_term > 0) 11652 *num_file = num_term; 11653 else 11654 return OK; 11655 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *))); 11656 if (*file == NULL) 11657 { 11658 *file = (char_u **)""; 11659 return FAIL; 11660 } 11661 } 11662 } 11663 return OK; 11664 } 11665 11666 int 11667 ExpandOldSetting(int *num_file, char_u ***file) 11668 { 11669 char_u *var = NULL; /* init for GCC */ 11670 char_u *buf; 11671 11672 *num_file = 0; 11673 *file = (char_u **)alloc((unsigned)sizeof(char_u *)); 11674 if (*file == NULL) 11675 return FAIL; 11676 11677 /* 11678 * For a terminal key code expand_option_idx is < 0. 11679 */ 11680 if (expand_option_idx < 0) 11681 { 11682 var = find_termcode(expand_option_name + 2); 11683 if (var == NULL) 11684 expand_option_idx = findoption(expand_option_name); 11685 } 11686 11687 if (expand_option_idx >= 0) 11688 { 11689 /* put string of option value in NameBuff */ 11690 option_value2string(&options[expand_option_idx], expand_option_flags); 11691 var = NameBuff; 11692 } 11693 else if (var == NULL) 11694 var = (char_u *)""; 11695 11696 /* A backslash is required before some characters. This is the reverse of 11697 * what happens in do_set(). */ 11698 buf = vim_strsave_escaped(var, escape_chars); 11699 11700 if (buf == NULL) 11701 { 11702 vim_free(*file); 11703 *file = NULL; 11704 return FAIL; 11705 } 11706 11707 #ifdef BACKSLASH_IN_FILENAME 11708 /* For MS-Windows et al. we don't double backslashes at the start and 11709 * before a file name character. */ 11710 for (var = buf; *var != NUL; MB_PTR_ADV(var)) 11711 if (var[0] == '\\' && var[1] == '\\' 11712 && expand_option_idx >= 0 11713 && (options[expand_option_idx].flags & P_EXPAND) 11714 && vim_isfilec(var[2]) 11715 && (var[2] != '\\' || (var == buf && var[4] != '\\'))) 11716 STRMOVE(var, var + 1); 11717 #endif 11718 11719 *file[0] = buf; 11720 *num_file = 1; 11721 return OK; 11722 } 11723 #endif 11724 11725 /* 11726 * Get the value for the numeric or string option *opp in a nice format into 11727 * NameBuff[]. Must not be called with a hidden option! 11728 */ 11729 static void 11730 option_value2string( 11731 struct vimoption *opp, 11732 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */ 11733 { 11734 char_u *varp; 11735 11736 varp = get_varp_scope(opp, opt_flags); 11737 11738 if (opp->flags & P_NUM) 11739 { 11740 long wc = 0; 11741 11742 if (wc_use_keyname(varp, &wc)) 11743 STRCPY(NameBuff, get_special_key_name((int)wc, 0)); 11744 else if (wc != 0) 11745 STRCPY(NameBuff, transchar((int)wc)); 11746 else 11747 sprintf((char *)NameBuff, "%ld", *(long *)varp); 11748 } 11749 else /* P_STRING */ 11750 { 11751 varp = *(char_u **)(varp); 11752 if (varp == NULL) /* just in case */ 11753 NameBuff[0] = NUL; 11754 #ifdef FEAT_CRYPT 11755 /* don't show the actual value of 'key', only that it's set */ 11756 else if (opp->var == (char_u *)&p_key && *varp) 11757 STRCPY(NameBuff, "*****"); 11758 #endif 11759 else if (opp->flags & P_EXPAND) 11760 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); 11761 /* Translate 'pastetoggle' into special key names */ 11762 else if ((char_u **)opp->var == &p_pt) 11763 str2specialbuf(p_pt, NameBuff, MAXPATHL); 11764 else 11765 vim_strncpy(NameBuff, varp, MAXPATHL - 1); 11766 } 11767 } 11768 11769 /* 11770 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be 11771 * printed as a keyname. 11772 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'. 11773 */ 11774 static int 11775 wc_use_keyname(char_u *varp, long *wcp) 11776 { 11777 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) 11778 { 11779 *wcp = *(long *)varp; 11780 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0) 11781 return TRUE; 11782 } 11783 return FALSE; 11784 } 11785 11786 #if defined(FEAT_LANGMAP) || defined(PROTO) 11787 /* 11788 * Any character has an equivalent 'langmap' character. This is used for 11789 * keyboards that have a special language mode that sends characters above 11790 * 128 (although other characters can be translated too). The "to" field is a 11791 * Vim command character. This avoids having to switch the keyboard back to 11792 * ASCII mode when leaving Insert mode. 11793 * 11794 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim 11795 * commands. 11796 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of 11797 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >= 11798 * 256. 11799 */ 11800 # if defined(FEAT_MBYTE) || defined(PROTO) 11801 /* 11802 * With multi-byte support use growarray for 'langmap' chars >= 256 11803 */ 11804 typedef struct 11805 { 11806 int from; 11807 int to; 11808 } langmap_entry_T; 11809 11810 static garray_T langmap_mapga; 11811 static void langmap_set_entry(int from, int to); 11812 11813 /* 11814 * Search for an entry in "langmap_mapga" for "from". If found set the "to" 11815 * field. If not found insert a new entry at the appropriate location. 11816 */ 11817 static void 11818 langmap_set_entry(int from, int to) 11819 { 11820 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); 11821 int a = 0; 11822 int b = langmap_mapga.ga_len; 11823 11824 /* Do a binary search for an existing entry. */ 11825 while (a != b) 11826 { 11827 int i = (a + b) / 2; 11828 int d = entries[i].from - from; 11829 11830 if (d == 0) 11831 { 11832 entries[i].to = to; 11833 return; 11834 } 11835 if (d < 0) 11836 a = i + 1; 11837 else 11838 b = i; 11839 } 11840 11841 if (ga_grow(&langmap_mapga, 1) != OK) 11842 return; /* out of memory */ 11843 11844 /* insert new entry at position "a" */ 11845 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a; 11846 mch_memmove(entries + 1, entries, 11847 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T)); 11848 ++langmap_mapga.ga_len; 11849 entries[0].from = from; 11850 entries[0].to = to; 11851 } 11852 11853 /* 11854 * Apply 'langmap' to multi-byte character "c" and return the result. 11855 */ 11856 int 11857 langmap_adjust_mb(int c) 11858 { 11859 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data); 11860 int a = 0; 11861 int b = langmap_mapga.ga_len; 11862 11863 while (a != b) 11864 { 11865 int i = (a + b) / 2; 11866 int d = entries[i].from - c; 11867 11868 if (d == 0) 11869 return entries[i].to; /* found matching entry */ 11870 if (d < 0) 11871 a = i + 1; 11872 else 11873 b = i; 11874 } 11875 return c; /* no entry found, return "c" unmodified */ 11876 } 11877 # endif 11878 11879 static void 11880 langmap_init(void) 11881 { 11882 int i; 11883 11884 for (i = 0; i < 256; i++) 11885 langmap_mapchar[i] = i; /* we init with a one-to-one map */ 11886 # ifdef FEAT_MBYTE 11887 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8); 11888 # endif 11889 } 11890 11891 /* 11892 * Called when langmap option is set; the language map can be 11893 * changed at any time! 11894 */ 11895 static void 11896 langmap_set(void) 11897 { 11898 char_u *p; 11899 char_u *p2; 11900 int from, to; 11901 11902 #ifdef FEAT_MBYTE 11903 ga_clear(&langmap_mapga); /* clear the previous map first */ 11904 #endif 11905 langmap_init(); /* back to one-to-one map */ 11906 11907 for (p = p_langmap; p[0] != NUL; ) 11908 { 11909 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';'; 11910 MB_PTR_ADV(p2)) 11911 { 11912 if (p2[0] == '\\' && p2[1] != NUL) 11913 ++p2; 11914 } 11915 if (p2[0] == ';') 11916 ++p2; /* abcd;ABCD form, p2 points to A */ 11917 else 11918 p2 = NULL; /* aAbBcCdD form, p2 is NULL */ 11919 while (p[0]) 11920 { 11921 if (p[0] == ',') 11922 { 11923 ++p; 11924 break; 11925 } 11926 if (p[0] == '\\' && p[1] != NUL) 11927 ++p; 11928 #ifdef FEAT_MBYTE 11929 from = (*mb_ptr2char)(p); 11930 #else 11931 from = p[0]; 11932 #endif 11933 to = NUL; 11934 if (p2 == NULL) 11935 { 11936 MB_PTR_ADV(p); 11937 if (p[0] != ',') 11938 { 11939 if (p[0] == '\\') 11940 ++p; 11941 #ifdef FEAT_MBYTE 11942 to = (*mb_ptr2char)(p); 11943 #else 11944 to = p[0]; 11945 #endif 11946 } 11947 } 11948 else 11949 { 11950 if (p2[0] != ',') 11951 { 11952 if (p2[0] == '\\') 11953 ++p2; 11954 #ifdef FEAT_MBYTE 11955 to = (*mb_ptr2char)(p2); 11956 #else 11957 to = p2[0]; 11958 #endif 11959 } 11960 } 11961 if (to == NUL) 11962 { 11963 EMSG2(_("E357: 'langmap': Matching character missing for %s"), 11964 transchar(from)); 11965 return; 11966 } 11967 11968 #ifdef FEAT_MBYTE 11969 if (from >= 256) 11970 langmap_set_entry(from, to); 11971 else 11972 #endif 11973 langmap_mapchar[from & 255] = to; 11974 11975 /* Advance to next pair */ 11976 MB_PTR_ADV(p); 11977 if (p2 != NULL) 11978 { 11979 MB_PTR_ADV(p2); 11980 if (*p == ';') 11981 { 11982 p = p2; 11983 if (p[0] != NUL) 11984 { 11985 if (p[0] != ',') 11986 { 11987 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p); 11988 return; 11989 } 11990 ++p; 11991 } 11992 break; 11993 } 11994 } 11995 } 11996 } 11997 } 11998 #endif 11999 12000 /* 12001 * Return TRUE if format option 'x' is in effect. 12002 * Take care of no formatting when 'paste' is set. 12003 */ 12004 int 12005 has_format_option(int x) 12006 { 12007 if (p_paste) 12008 return FALSE; 12009 return (vim_strchr(curbuf->b_p_fo, x) != NULL); 12010 } 12011 12012 /* 12013 * Return TRUE if "x" is present in 'shortmess' option, or 12014 * 'shortmess' contains 'a' and "x" is present in SHM_A. 12015 */ 12016 int 12017 shortmess(int x) 12018 { 12019 return p_shm != NULL && 12020 ( vim_strchr(p_shm, x) != NULL 12021 || (vim_strchr(p_shm, 'a') != NULL 12022 && vim_strchr((char_u *)SHM_A, x) != NULL)); 12023 } 12024 12025 /* 12026 * paste_option_changed() - Called after p_paste was set or reset. 12027 */ 12028 static void 12029 paste_option_changed(void) 12030 { 12031 static int old_p_paste = FALSE; 12032 static int save_sm = 0; 12033 static int save_sta = 0; 12034 #ifdef FEAT_CMDL_INFO 12035 static int save_ru = 0; 12036 #endif 12037 #ifdef FEAT_RIGHTLEFT 12038 static int save_ri = 0; 12039 static int save_hkmap = 0; 12040 #endif 12041 buf_T *buf; 12042 12043 if (p_paste) 12044 { 12045 /* 12046 * Paste switched from off to on. 12047 * Save the current values, so they can be restored later. 12048 */ 12049 if (!old_p_paste) 12050 { 12051 /* save options for each buffer */ 12052 FOR_ALL_BUFFERS(buf) 12053 { 12054 buf->b_p_tw_nopaste = buf->b_p_tw; 12055 buf->b_p_wm_nopaste = buf->b_p_wm; 12056 buf->b_p_sts_nopaste = buf->b_p_sts; 12057 buf->b_p_ai_nopaste = buf->b_p_ai; 12058 buf->b_p_et_nopaste = buf->b_p_et; 12059 } 12060 12061 /* save global options */ 12062 save_sm = p_sm; 12063 save_sta = p_sta; 12064 #ifdef FEAT_CMDL_INFO 12065 save_ru = p_ru; 12066 #endif 12067 #ifdef FEAT_RIGHTLEFT 12068 save_ri = p_ri; 12069 save_hkmap = p_hkmap; 12070 #endif 12071 /* save global values for local buffer options */ 12072 p_ai_nopaste = p_ai; 12073 p_et_nopaste = p_et; 12074 p_sts_nopaste = p_sts; 12075 p_tw_nopaste = p_tw; 12076 p_wm_nopaste = p_wm; 12077 } 12078 12079 /* 12080 * Always set the option values, also when 'paste' is set when it is 12081 * already on. 12082 */ 12083 /* set options for each buffer */ 12084 FOR_ALL_BUFFERS(buf) 12085 { 12086 buf->b_p_tw = 0; /* textwidth is 0 */ 12087 buf->b_p_wm = 0; /* wrapmargin is 0 */ 12088 buf->b_p_sts = 0; /* softtabstop is 0 */ 12089 buf->b_p_ai = 0; /* no auto-indent */ 12090 buf->b_p_et = 0; /* no expandtab */ 12091 } 12092 12093 /* set global options */ 12094 p_sm = 0; /* no showmatch */ 12095 p_sta = 0; /* no smarttab */ 12096 #ifdef FEAT_CMDL_INFO 12097 if (p_ru) 12098 status_redraw_all(); /* redraw to remove the ruler */ 12099 p_ru = 0; /* no ruler */ 12100 #endif 12101 #ifdef FEAT_RIGHTLEFT 12102 p_ri = 0; /* no reverse insert */ 12103 p_hkmap = 0; /* no Hebrew keyboard */ 12104 #endif 12105 /* set global values for local buffer options */ 12106 p_tw = 0; 12107 p_wm = 0; 12108 p_sts = 0; 12109 p_ai = 0; 12110 } 12111 12112 /* 12113 * Paste switched from on to off: Restore saved values. 12114 */ 12115 else if (old_p_paste) 12116 { 12117 /* restore options for each buffer */ 12118 FOR_ALL_BUFFERS(buf) 12119 { 12120 buf->b_p_tw = buf->b_p_tw_nopaste; 12121 buf->b_p_wm = buf->b_p_wm_nopaste; 12122 buf->b_p_sts = buf->b_p_sts_nopaste; 12123 buf->b_p_ai = buf->b_p_ai_nopaste; 12124 buf->b_p_et = buf->b_p_et_nopaste; 12125 } 12126 12127 /* restore global options */ 12128 p_sm = save_sm; 12129 p_sta = save_sta; 12130 #ifdef FEAT_CMDL_INFO 12131 if (p_ru != save_ru) 12132 status_redraw_all(); /* redraw to draw the ruler */ 12133 p_ru = save_ru; 12134 #endif 12135 #ifdef FEAT_RIGHTLEFT 12136 p_ri = save_ri; 12137 p_hkmap = save_hkmap; 12138 #endif 12139 /* set global values for local buffer options */ 12140 p_ai = p_ai_nopaste; 12141 p_et = p_et_nopaste; 12142 p_sts = p_sts_nopaste; 12143 p_tw = p_tw_nopaste; 12144 p_wm = p_wm_nopaste; 12145 } 12146 12147 old_p_paste = p_paste; 12148 } 12149 12150 /* 12151 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found. 12152 * 12153 * Reset 'compatible' and set the values for options that didn't get set yet 12154 * to the Vim defaults. 12155 * Don't do this if the 'compatible' option has been set or reset before. 12156 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet. 12157 */ 12158 void 12159 vimrc_found(char_u *fname, char_u *envname) 12160 { 12161 int opt_idx; 12162 int dofree = FALSE; 12163 char_u *p; 12164 12165 if (!option_was_set((char_u *)"cp")) 12166 { 12167 p_cp = FALSE; 12168 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 12169 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF))) 12170 set_option_default(opt_idx, OPT_FREE, FALSE); 12171 didset_options(); 12172 didset_options2(); 12173 } 12174 12175 if (fname != NULL) 12176 { 12177 p = vim_getenv(envname, &dofree); 12178 if (p == NULL) 12179 { 12180 /* Set $MYVIMRC to the first vimrc file found. */ 12181 p = FullName_save(fname, FALSE); 12182 if (p != NULL) 12183 { 12184 vim_setenv(envname, p); 12185 vim_free(p); 12186 } 12187 } 12188 else if (dofree) 12189 vim_free(p); 12190 } 12191 } 12192 12193 /* 12194 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg. 12195 */ 12196 void 12197 change_compatible(int on) 12198 { 12199 int opt_idx; 12200 12201 if (p_cp != on) 12202 { 12203 p_cp = on; 12204 compatible_set(); 12205 } 12206 opt_idx = findoption((char_u *)"cp"); 12207 if (opt_idx >= 0) 12208 options[opt_idx].flags |= P_WAS_SET; 12209 } 12210 12211 /* 12212 * Return TRUE when option "name" has been set. 12213 * Only works correctly for global options. 12214 */ 12215 int 12216 option_was_set(char_u *name) 12217 { 12218 int idx; 12219 12220 idx = findoption(name); 12221 if (idx < 0) /* unknown option */ 12222 return FALSE; 12223 if (options[idx].flags & P_WAS_SET) 12224 return TRUE; 12225 return FALSE; 12226 } 12227 12228 /* 12229 * Reset the flag indicating option "name" was set. 12230 */ 12231 void 12232 reset_option_was_set(char_u *name) 12233 { 12234 int idx = findoption(name); 12235 12236 if (idx >= 0) 12237 options[idx].flags &= ~P_WAS_SET; 12238 } 12239 12240 /* 12241 * compatible_set() - Called when 'compatible' has been set or unset. 12242 * 12243 * When 'compatible' set: Set all relevant options (those that have the P_VIM) 12244 * flag) to a Vi compatible value. 12245 * When 'compatible' is unset: Set all options that have a different default 12246 * for Vim (without the P_VI_DEF flag) to that default. 12247 */ 12248 static void 12249 compatible_set(void) 12250 { 12251 int opt_idx; 12252 12253 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 12254 if ( ((options[opt_idx].flags & P_VIM) && p_cp) 12255 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp)) 12256 set_option_default(opt_idx, OPT_FREE, p_cp); 12257 didset_options(); 12258 didset_options2(); 12259 } 12260 12261 #ifdef FEAT_LINEBREAK 12262 12263 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) 12264 /* Borland C++ screws up loop optimisation here (negri) */ 12265 #pragma option -O-l 12266 # endif 12267 12268 /* 12269 * fill_breakat_flags() -- called when 'breakat' changes value. 12270 */ 12271 static void 12272 fill_breakat_flags(void) 12273 { 12274 char_u *p; 12275 int i; 12276 12277 for (i = 0; i < 256; i++) 12278 breakat_flags[i] = FALSE; 12279 12280 if (p_breakat != NULL) 12281 for (p = p_breakat; *p; p++) 12282 breakat_flags[*p] = TRUE; 12283 } 12284 12285 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) 12286 #pragma option -O.l 12287 # endif 12288 12289 #endif 12290 12291 /* 12292 * Check an option that can be a range of string values. 12293 * 12294 * Return OK for correct value, FAIL otherwise. 12295 * Empty is always OK. 12296 */ 12297 static int 12298 check_opt_strings( 12299 char_u *val, 12300 char **values, 12301 int list) /* when TRUE: accept a list of values */ 12302 { 12303 return opt_strings_flags(val, values, NULL, list); 12304 } 12305 12306 /* 12307 * Handle an option that can be a range of string values. 12308 * Set a flag in "*flagp" for each string present. 12309 * 12310 * Return OK for correct value, FAIL otherwise. 12311 * Empty is always OK. 12312 */ 12313 static int 12314 opt_strings_flags( 12315 char_u *val, /* new value */ 12316 char **values, /* array of valid string values */ 12317 unsigned *flagp, 12318 int list) /* when TRUE: accept a list of values */ 12319 { 12320 int i; 12321 int len; 12322 unsigned new_flags = 0; 12323 12324 while (*val) 12325 { 12326 for (i = 0; ; ++i) 12327 { 12328 if (values[i] == NULL) /* val not found in values[] */ 12329 return FAIL; 12330 12331 len = (int)STRLEN(values[i]); 12332 if (STRNCMP(values[i], val, len) == 0 12333 && ((list && val[len] == ',') || val[len] == NUL)) 12334 { 12335 val += len + (val[len] == ','); 12336 new_flags |= (1 << i); 12337 break; /* check next item in val list */ 12338 } 12339 } 12340 } 12341 if (flagp != NULL) 12342 *flagp = new_flags; 12343 12344 return OK; 12345 } 12346 12347 /* 12348 * Read the 'wildmode' option, fill wim_flags[]. 12349 */ 12350 static int 12351 check_opt_wim(void) 12352 { 12353 char_u new_wim_flags[4]; 12354 char_u *p; 12355 int i; 12356 int idx = 0; 12357 12358 for (i = 0; i < 4; ++i) 12359 new_wim_flags[i] = 0; 12360 12361 for (p = p_wim; *p; ++p) 12362 { 12363 for (i = 0; ASCII_ISALPHA(p[i]); ++i) 12364 ; 12365 if (p[i] != NUL && p[i] != ',' && p[i] != ':') 12366 return FAIL; 12367 if (i == 7 && STRNCMP(p, "longest", 7) == 0) 12368 new_wim_flags[idx] |= WIM_LONGEST; 12369 else if (i == 4 && STRNCMP(p, "full", 4) == 0) 12370 new_wim_flags[idx] |= WIM_FULL; 12371 else if (i == 4 && STRNCMP(p, "list", 4) == 0) 12372 new_wim_flags[idx] |= WIM_LIST; 12373 else 12374 return FAIL; 12375 p += i; 12376 if (*p == NUL) 12377 break; 12378 if (*p == ',') 12379 { 12380 if (idx == 3) 12381 return FAIL; 12382 ++idx; 12383 } 12384 } 12385 12386 /* fill remaining entries with last flag */ 12387 while (idx < 3) 12388 { 12389 new_wim_flags[idx + 1] = new_wim_flags[idx]; 12390 ++idx; 12391 } 12392 12393 /* only when there are no errors, wim_flags[] is changed */ 12394 for (i = 0; i < 4; ++i) 12395 wim_flags[i] = new_wim_flags[i]; 12396 return OK; 12397 } 12398 12399 /* 12400 * Check if backspacing over something is allowed. 12401 */ 12402 int 12403 can_bs( 12404 int what) /* BS_INDENT, BS_EOL or BS_START */ 12405 { 12406 switch (*p_bs) 12407 { 12408 case '2': return TRUE; 12409 case '1': return (what != BS_START); 12410 case '0': return FALSE; 12411 } 12412 return vim_strchr(p_bs, what) != NULL; 12413 } 12414 12415 /* 12416 * Save the current values of 'fileformat' and 'fileencoding', so that we know 12417 * the file must be considered changed when the value is different. 12418 */ 12419 void 12420 save_file_ff(buf_T *buf) 12421 { 12422 buf->b_start_ffc = *buf->b_p_ff; 12423 buf->b_start_eol = buf->b_p_eol; 12424 #ifdef FEAT_MBYTE 12425 buf->b_start_bomb = buf->b_p_bomb; 12426 12427 /* Only use free/alloc when necessary, they take time. */ 12428 if (buf->b_start_fenc == NULL 12429 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0) 12430 { 12431 vim_free(buf->b_start_fenc); 12432 buf->b_start_fenc = vim_strsave(buf->b_p_fenc); 12433 } 12434 #endif 12435 } 12436 12437 /* 12438 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value 12439 * from when editing started (save_file_ff() called). 12440 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was 12441 * changed and 'binary' is not set. 12442 * Also when 'endofline' was changed and 'fixeol' is not set. 12443 * When "ignore_empty" is true don't consider a new, empty buffer to be 12444 * changed. 12445 */ 12446 int 12447 file_ff_differs(buf_T *buf, int ignore_empty) 12448 { 12449 /* In a buffer that was never loaded the options are not valid. */ 12450 if (buf->b_flags & BF_NEVERLOADED) 12451 return FALSE; 12452 if (ignore_empty 12453 && (buf->b_flags & BF_NEW) 12454 && buf->b_ml.ml_line_count == 1 12455 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL) 12456 return FALSE; 12457 if (buf->b_start_ffc != *buf->b_p_ff) 12458 return TRUE; 12459 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol) 12460 return TRUE; 12461 #ifdef FEAT_MBYTE 12462 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb) 12463 return TRUE; 12464 if (buf->b_start_fenc == NULL) 12465 return (*buf->b_p_fenc != NUL); 12466 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0); 12467 #else 12468 return FALSE; 12469 #endif 12470 } 12471 12472 /* 12473 * return OK if "p" is a valid fileformat name, FAIL otherwise. 12474 */ 12475 int 12476 check_ff_value(char_u *p) 12477 { 12478 return check_opt_strings(p, p_ff_values, FALSE); 12479 } 12480 12481 /* 12482 * Return the effective shiftwidth value for current buffer, using the 12483 * 'tabstop' value when 'shiftwidth' is zero. 12484 */ 12485 long 12486 get_sw_value(buf_T *buf) 12487 { 12488 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts; 12489 } 12490 12491 /* 12492 * Return the effective softtabstop value for the current buffer, using the 12493 * 'tabstop' value when 'softtabstop' is negative. 12494 */ 12495 long 12496 get_sts_value(void) 12497 { 12498 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; 12499 } 12500 12501 /* 12502 * Check matchpairs option for "*initc". 12503 * If there is a match set "*initc" to the matching character and "*findc" to 12504 * the opposite character. Set "*backwards" to the direction. 12505 * When "switchit" is TRUE swap the direction. 12506 */ 12507 void 12508 find_mps_values( 12509 int *initc, 12510 int *findc, 12511 int *backwards, 12512 int switchit) 12513 { 12514 char_u *ptr; 12515 12516 ptr = curbuf->b_p_mps; 12517 while (*ptr != NUL) 12518 { 12519 #ifdef FEAT_MBYTE 12520 if (has_mbyte) 12521 { 12522 char_u *prev; 12523 12524 if (mb_ptr2char(ptr) == *initc) 12525 { 12526 if (switchit) 12527 { 12528 *findc = *initc; 12529 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); 12530 *backwards = TRUE; 12531 } 12532 else 12533 { 12534 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); 12535 *backwards = FALSE; 12536 } 12537 return; 12538 } 12539 prev = ptr; 12540 ptr += mb_ptr2len(ptr) + 1; 12541 if (mb_ptr2char(ptr) == *initc) 12542 { 12543 if (switchit) 12544 { 12545 *findc = *initc; 12546 *initc = mb_ptr2char(prev); 12547 *backwards = FALSE; 12548 } 12549 else 12550 { 12551 *findc = mb_ptr2char(prev); 12552 *backwards = TRUE; 12553 } 12554 return; 12555 } 12556 ptr += mb_ptr2len(ptr); 12557 } 12558 else 12559 #endif 12560 { 12561 if (*ptr == *initc) 12562 { 12563 if (switchit) 12564 { 12565 *backwards = TRUE; 12566 *findc = *initc; 12567 *initc = ptr[2]; 12568 } 12569 else 12570 { 12571 *backwards = FALSE; 12572 *findc = ptr[2]; 12573 } 12574 return; 12575 } 12576 ptr += 2; 12577 if (*ptr == *initc) 12578 { 12579 if (switchit) 12580 { 12581 *backwards = FALSE; 12582 *findc = *initc; 12583 *initc = ptr[-2]; 12584 } 12585 else 12586 { 12587 *backwards = TRUE; 12588 *findc = ptr[-2]; 12589 } 12590 return; 12591 } 12592 ++ptr; 12593 } 12594 if (*ptr == ',') 12595 ++ptr; 12596 } 12597 } 12598 12599 #if defined(FEAT_LINEBREAK) || defined(PROTO) 12600 /* 12601 * This is called when 'breakindentopt' is changed and when a window is 12602 * initialized. 12603 */ 12604 static int 12605 briopt_check(win_T *wp) 12606 { 12607 char_u *p; 12608 int bri_shift = 0; 12609 long bri_min = 20; 12610 int bri_sbr = FALSE; 12611 12612 p = wp->w_p_briopt; 12613 while (*p != NUL) 12614 { 12615 if (STRNCMP(p, "shift:", 6) == 0 12616 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6]))) 12617 { 12618 p += 6; 12619 bri_shift = getdigits(&p); 12620 } 12621 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4])) 12622 { 12623 p += 4; 12624 bri_min = getdigits(&p); 12625 } 12626 else if (STRNCMP(p, "sbr", 3) == 0) 12627 { 12628 p += 3; 12629 bri_sbr = TRUE; 12630 } 12631 if (*p != ',' && *p != NUL) 12632 return FAIL; 12633 if (*p == ',') 12634 ++p; 12635 } 12636 12637 wp->w_p_brishift = bri_shift; 12638 wp->w_p_brimin = bri_min; 12639 wp->w_p_brisbr = bri_sbr; 12640 12641 return OK; 12642 } 12643 #endif 12644 12645 /* 12646 * Get the local or global value of 'backupcopy'. 12647 */ 12648 unsigned int 12649 get_bkc_value(buf_T *buf) 12650 { 12651 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags; 12652 } 12653 12654 #if defined(FEAT_SIGNS) || defined(PROTO) 12655 /* 12656 * Return TRUE when window "wp" has a column to draw signs in. 12657 */ 12658 int 12659 signcolumn_on(win_T *wp) 12660 { 12661 if (*wp->w_p_scl == 'n') 12662 return FALSE; 12663 if (*wp->w_p_scl == 'y') 12664 return TRUE; 12665 return (wp->w_buffer->b_signlist != NULL 12666 # ifdef FEAT_NETBEANS_INTG 12667 || wp->w_buffer->b_has_sign_column 12668 # endif 12669 ); 12670 } 12671 #endif 12672 12673 #if defined(FEAT_EVAL) || defined(PROTO) 12674 /* 12675 * Get window or buffer local options. 12676 */ 12677 dict_T * 12678 get_winbuf_options(int bufopt) 12679 { 12680 dict_T *d; 12681 int opt_idx; 12682 12683 d = dict_alloc(); 12684 if (d == NULL) 12685 return NULL; 12686 12687 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++) 12688 { 12689 struct vimoption *opt = &options[opt_idx]; 12690 12691 if ((bufopt && (opt->indir & PV_BUF)) 12692 || (!bufopt && (opt->indir & PV_WIN))) 12693 { 12694 char_u *varp = get_varp(opt); 12695 12696 if (varp != NULL) 12697 { 12698 if (opt->flags & P_STRING) 12699 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp); 12700 else if (opt->flags & P_NUM) 12701 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL); 12702 else 12703 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL); 12704 } 12705 } 12706 } 12707 12708 return d; 12709 } 12710 #endif 12711