To: vim-dev@vim.org Subject: Patch 6.1.174 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.174 Problem: It is difficult to know in a script whether an option not only exists but really works. Solution: Add "exists('+option')". Files: runtime/doc/eval.txt, src/eval.c *** ../vim61.173/runtime/doc/eval.txt Sun Jun 23 21:29:33 2002 --- runtime/doc/eval.txt Sat Sep 7 21:05:07 2002 *************** *** 1,4 **** ! *eval.txt* For Vim version 6.1. Last change: 2002 May 12 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 6.1. Last change: 2002 Sep 07 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 1176,1181 **** --- 1176,1182 ---- contains one of these: &option-name Vim option (only checks if it exists, not if it really works) + +option-name Vim option that works. $ENVNAME environment variable (could also be done by comparing with an empty string) *** ../vim61.173/src/eval.c Fri Aug 30 22:27:17 2002 --- src/eval.c Sat Sep 7 21:04:47 2002 *************** *** 2026,2032 **** /* * Get an option value. ! * "arg" points to the '&' before the option name. * "arg" is advanced to character after the option name. * Return OK or FAIL. */ --- 2026,2032 ---- /* * Get an option value. ! * "arg" points to the '&' or '+' before the option name. * "arg" is advanced to character after the option name. * Return OK or FAIL. */ *************** *** 2041,2046 **** --- 2041,2047 ---- char_u *stringval; int opt_type; int c; + int working = (**arg == '+'); /* has("+option") */ int ret = OK; int opt_flags; *************** *** 2095,2100 **** --- 2096,2103 ---- retvar->var_val.var_string = stringval; } } + else if (working && (opt_type == -2 || opt_type == -1)) + ret = FAIL; *option_end = c; /* put back for error messages */ *arg = option_end; *************** *** 3409,3415 **** vim_free(p); } } ! else if (*p == '&') /* option */ n = (get_option_var(&p, NULL, TRUE) == OK); else if (*p == '*') /* internal or user defined function */ { --- 3412,3418 ---- vim_free(p); } } ! else if (*p == '&' || *p == '+') /* option */ n = (get_option_var(&p, NULL, TRUE) == OK); else if (*p == '*') /* internal or user defined function */ { *************** *** 7555,7561 **** /* * Skip over the name of an option: "&option", "&g:option" or "&l:option". ! * "arg" points to the "&" when called, to "option" when returning. * Returns NULL when no option name found. Otherwise pointer to the char * after the option name. */ --- 7558,7564 ---- /* * Skip over the name of an option: "&option", "&g:option" or "&l:option". ! * "arg" points to the "&" or '+' when called, to "option" when returning. * Returns NULL when no option name found. Otherwise pointer to the char * after the option name. */ *** ../vim61.173/src/version.c Sat Sep 7 17:16:30 2002 --- src/version.c Sat Sep 7 22:18:04 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 174, /**/ -- TIM: To the north there lies a cave, the cave of Caerbannog, wherein, carved in mystic runes, upon the very living rock, the last words of Olfin Bedwere of Rheged make plain the last resting place of the most Holy Grail. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///