# HG changeset patch # User vimboss # Date 1105478944 0 # Node ID a2081e6febb8b321be281bbf801d9d4239b5b17f # Parent 0c2e08de4a75487f57e8e32b5cc10690b716f134 updated for version 7.0037 diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 09 +*eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -223,7 +223,7 @@ and a variable name: > This works like: > :let var1 = mylist[0] :let var2 = mylist[1] - :let rest = mjlist[2:] + :let rest = mylist[2:] Except that there is no error if there are only two items. "rest" will be an empty list then. @@ -248,6 +248,7 @@ examples: > :call extend(list, [1, 2]) " extend the list with two more items :let i = remove(list, 3) " remove item 3 :let l = remove(list, 3, -1) " remove items 3 to last item + :call filter(list, #& =~ 'x'#) " remove items with an 'x' Changing the oder of items in a list: > :call sort(list) " sort a list alphabetically @@ -274,6 +275,9 @@ Note that all items in the list should b results in an error |E706|. To avoid this |:unlet| the variable at the end of the loop. +If all you want to do is modify each item in the list then the |map()| +function might be a simpler method than a for loop. + Just like the |:let| command, |:for| also accepts a list of variables. This requires the argument to be a list of lists. > :for [lnum, col] in [[1, 3], [2, 8], [3, 0]] @@ -304,8 +308,10 @@ Functions that are useful with a List: > :let i = index(list, 'x') " index of first 'x' in list :let lines = getline(1, 10) " get ten text lines from buffer :call append('$', lines) " append text lines in buffer - :let list = str2list("a b c") " create list from items in a string + :let list = split("a b c") " create list from items in a string + :let string = join(list, ', ') " create string from list items :let s = string() " String representation of a list + :call map(list, #'>> ' . &#) " prepend ">> " to each item 1.4 More about variables ~ @@ -377,6 +383,7 @@ Expression syntax summary, from least to |expr9| number number constant "string" string constant, backslash is special 'string' string constant + #string# string constant [expr1, ...] List &option option value (expr1) nested expression @@ -676,8 +683,8 @@ literal-string *literal-string* *E1 Note that single quotes are used. This string is taken as it is. No backslashes are removed or have a special -meaning. A literal-string cannot contain a single quote. Use a normal, -double-quoted string for that. +meaning. A literal-string cannot contain a single quote. Use a double-quoted +string or sharp-string for that. Single quoted strings are useful for patterns, so that backslashes do not need to be doubled. These two commands are equivalent: > @@ -685,6 +692,17 @@ to be doubled. These two commands are e if a =~ '\s*' +sharp-string *sharp-string* +--------------- +#string# string constant *expr-#* + +Most characters in the string are taken as-is. Only the '#' character is +special: It needs to be double to get one. + +Sharp-strings are useful when a string may contain single quotes, double +quotes and/or backslashes. + + option *expr-option* *E112* *E113* ------ &option option value, local value if possible @@ -1146,7 +1164,8 @@ col( {expr}) Number column nr of curso confirm( {msg} [, {choices} [, {default} [, {type}]]]) Number number of choice picked by user copy( {expr}) any make a shallow copy of {expr} -count( {list}, {expr} [, {ic}]) Number count how many {expr} are in {list} +count( {list}, {expr} [, {start} [, {ic}]]) + Number count how many {expr} are in {list} cscope_connection( [{num} , {dbpath} [, {prepend}]]) Number checks existence of cscope connection cursor( {lnum}, {col}) Number position cursor at {lnum}, {col} @@ -1157,13 +1176,17 @@ diff_filler( {lnum}) Number diff filler diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col} empty( {expr}) Number TRUE if {expr} is empty escape( {string}, {chars}) String escape {chars} in {string} with '\' +eval( {string}) any evaluate {string} into its value eventhandler( ) Number TRUE if inside an event handler executable( {expr}) Number 1 if executable {expr} exists exists( {expr}) Number TRUE if {expr} exists expand( {expr}) String expand special keywords in {expr} filereadable( {file}) Number TRUE if {file} is a readable file +filter( {list}, {expr}) List remove from {list} where {expr} is 0 +finddir( {name}[, {path}[, {count}]]) + String Find directory {name} in {path} findfile( {name}[, {path}[, {count}]]) - String Find fine {name} in {path} + String Find file {name} in {path} filewritable( {file}) Number TRUE if {file} is a writable file fnamemodify( {fname}, {mods}) String modify file name foldclosed( {lnum}) Number first line of fold at {lnum} if closed @@ -1203,7 +1226,8 @@ hlID( {name}) Number syntax ID of high hostname() String name of the machine Vim is running on iconv( {expr}, {from}, {to}) String convert encoding of {expr} indent( {lnum}) Number indent of line {lnum} -index( {list}, {expr} [, {ic}]) Number index in {list} where {expr} appears +index( {list}, {expr} [, {start} [, {ic}]]) + Number index in {list} where {expr} appears input( {prompt} [, {text}]) String get input from the user inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog inputrestore() Number restore typeahead @@ -1211,6 +1235,7 @@ inputsave() Number save and clear type inputsecret( {prompt} [, {text}]) String like input() but hiding the text insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] isdirectory( {directory}) Number TRUE if {directory} is a directory +join( {list} [, {sep}]) String join {list} items into one String len( {expr}) Number the length of {expr} libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number @@ -1218,6 +1243,7 @@ line( {expr}) Number line nr of cursor line2byte( {lnum}) Number byte count of line {lnum} lispindent( {lnum}) Number Lisp indent for line {lnum} localtime() Number current time +map( {list}, {expr}) List change each item in {list} to {expr} maparg( {name}[, {mode}]) String rhs of mapping {name} in mode {mode} mapcheck( {name}[, {mode}]) String check for mappings matching {name} match( {expr}, {pat}[, {start}[, {count}]]) @@ -1258,10 +1284,10 @@ setreg( {n}, {v}[, {opt}]) Number set re setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} simplify( {filename}) String simplify filename as much as possible sort( {list} [, {func}]) List sort {list}, using {func} to compare -str2list( {expr} [, {pat}]) List make List from {pat} separated {expr} +split( {expr} [, {pat}]) List make List from {pat} separated {expr} strftime( {format}[, {time}]) String time in specified format stridx( {haystack}, {needle}) Number first index of {needle} in {haystack} -string( {expr}) String {expr} converted to a String +string( {expr}) String String representation of {expr} value strlen( {expr}) Number length of the String {expr} strpart( {src}, {start}[, {len}]) String {len} characters of {src} at {start} @@ -1571,9 +1597,10 @@ copy({expr}) Make a copy of {expr}. For changing an item changes the contents of both Lists. Also see |deepcopy()|. -count({list}, {expr} [, {ic}]) *count()* +count({list}, {expr} [, {start} [, {ic}]]) *count()* Return the number of times an item with value {expr} appears in List {list}. + If {start} is given then don't count items with a lower index. When {ic} is given and it's non-zero then case is ignored. @@ -1690,7 +1717,13 @@ escape({string}, {chars}) *escape()* :echo escape('c:\program files\vim', ' \') < results in: > c:\\program\ files\\vim -< + +< *eval()* +eval({string}) Evaluate {string} and return the result. Especially useful to + turn the result of |string()| back into the original value. + This works for Numbers, Strings and composites of them. + Also works for Funcrefs that refer to existing functions. + eventhandler() *eventhandler()* Returns 1 when inside an event handler. That is that Vim got interrupted while waiting for the user to type a character, @@ -1845,7 +1878,7 @@ extend({list1}, {list2} [, {idx}]) *ex Append {list2} to {list1}. If {idx} is given insert the items of {list2} before item {idx} in {list1}. When {idx} is zero insert before the first - item. When {idx} is equal to len({list1}) {list2} is + item. When {idx} is equal to len({list1}) then {list2} is appended. {list1} is changed when {list2} is not empty. {list2} remains unchanged. @@ -1866,6 +1899,23 @@ filereadable({file}) *filereadable() *file_readable()* Obsolete name: file_readable(). + +filter({list}, {expr}) *filter()* *E712* + For each item in {list} evaluate {expr} and when the result is + zero remove the item from the List. + Inside {expr} the symbol "&" stands for the existing + item. Example: > + :call filter(mylist, #& !~ "OLD"#) +< Removes the items where "OLD" appears. + Note that {expr} is an expression that evaluates to an + expression. Often it is good to use a |sharp-string| to avoid + having to double backslashes. + The operation is done in-place. If you want a list to remain + unmodified make a copy first: > + :let l = filter(copy(mylist), #& =~ "KEEP"#) +< Returns {list}. + + finddir({name}[, {path}[, {count}]]) *finddir()* Find directory {name} in {path}. If {path} is omitted or empty then 'path' is used. @@ -2036,7 +2086,7 @@ getcmdline() *getcmdline()* :cmap eescape(getcmdline(), ' \') < Also see |getcmdpos()| and |setcmdpos()|. -getcmdpos({pos}) *getcmdpos()* +getcmdpos() *getcmdpos()* Return the position of the cursor in the command line as a byte count. The first column is 1. Only works when editing the command line, thus requires use of @@ -2358,9 +2408,10 @@ indent({lnum}) The result is a Number, w When {lnum} is invalid -1 is returned. -index({list}, {expr} [, {ic}]) *index()* +index({list}, {expr} [, {start} [, {ic}]]) *index()* Return the lowest index in List {list} where the item has a value equal to {expr}. + If {start} is given then skip items with a lower index. When {ic} is given and it is non-zero, ignore case. Otherwise case must match. -1 is returned when {expr} is not found in {list}. @@ -2461,6 +2512,18 @@ isdirectory({directory}) *isdirectory exist, or isn't a directory, the result is FALSE. {directory} is any expression, which is used as a String. + +join({list} [, {sep}]) *join()* + Join the items in {list} together into one String. + When {sep} is specified it is put in between the items. If + {sep} is omitted a single space is used. + Note that {sep} is not added at the end. You might want to + add it there too: > + let lines = join(mylist, "\n") . "\n" +< String items are used as-is. Lists and Dictionaries are + converted into a string like with |string()|. + The opposite function is |split()|. + *len()* *E701* len({expr}) The result is a Number, which is the length of the argument. When {expr} is a String or a Number the length in bytes is @@ -2568,6 +2631,23 @@ localtime() *localtime()* Return the current time, measured as seconds since 1st Jan 1970. See also |strftime()| and |getftime()|. + +map({list}, {expr}) *map()* + Replace each item in {list} with the result of evaluating + {expr}. + Inside {expr} the symbol "&" stands for the existing + item. Example: > + :call map(mylist, #"> " . & . " <"#) +< This puts "> " before and " <" after each item in "mylist". + Note that {expr} is an expression that evaluates to an + expression. Often it is good to use a |sharp-string| to avoid + having to double backslashes. + The operation is done in-place. If you want a list to remain + unmodified make a copy first: > + :let tlist = map(copy(mylist), # & . "\t"#) +< Returns {list}. + + maparg({name}[, {mode}]) *maparg()* Return the rhs of mapping {name} in mode {mode}. When there is no mapping for {name}, an empty String is returned. @@ -2617,29 +2697,40 @@ mapcheck({name}[, {mode}]) *mapcheck( mapping for "_v" or for "_vvv". match({expr}, {pat}[, {start}[, {count}]]) *match()* - The result is a Number, which gives the index (byte offset) in - {expr} where {pat} matches. - A match at the first character returns zero. + When {expr} is a List then this returns the index of the first + item where {pat} matches. Each item is used as a String, + Lists and Dictionaries are used as echoed. + Otherwise, {expr} is used as a String. The result is a + Number, which gives the index (byte offset) in {expr} where + {pat} matches. + A match at the first character or List item returns zero. If there is no match -1 is returned. Example: > - :echo match("testing", "ing") -< results in "4". - See |string-match| for how {pat} is used. + :echo match("testing", "ing") " results in 4 + :echo match([1, 'x'], '\a') " results in 2 +< See |string-match| for how {pat} is used. + When {count} is given use the {count}'th match. When a match - is found the search for the next one starts on character - further. Thus this example results in 1: > + is found in a String the search for the next one starts on + character further. Thus this example results in 1: > echo match("testing", "..", 0, 2) -< If {start} is given, the search starts from index {start}. +< In a List the search continues in the next item. + + If {start} is given, the search starts from byte index + {start} in a String or item {start} in a List. The result, however, is still the index counted from the - first character. Example: > + first character/item. Example: > :echo match("testing", "ing", 2) < result is again "4". > :echo match("testing", "ing", 4) < result is again "4". > :echo match("testing", "t", 2) < result is "3". - If {start} < 0, it will be set to 0. - If {start} > strlen({expr}) -1 is returned. + For a String, if {start} < 0, it will be set to 0. For a list + the index is counted from the end. + If {start} is out of range (> strlen({expr} for a String or + > len({expr} for a List) -1 is returned. + See |pattern| for the patterns that are accepted. The 'ignorecase' option is used to set the ignore-caseness of the pattern. 'smartcase' is NOT used. The matching is always @@ -2655,6 +2746,7 @@ matchend({expr}, {pat}[, {start}[, {coun < results in "7". > :echo matchend("testing", "ing", 5) < result is "-1". + When {expr} is a List the result is equal to match(). matchstr({expr}, {pat}[, {start}[, {count}]]) *matchstr()* Same as match(), but return the matched string. Example: > @@ -2666,6 +2758,8 @@ matchstr({expr}, {pat}[, {start}[, {coun < results in "ing". > :echo matchstr("testing", "ing", 5) < result is "". + When {expr} is a List then the matching item is returned. + The type isn't changed, it's not necessarily a String. *max()* max({list}) Return the maximum value of all items in {list}. @@ -3076,6 +3170,7 @@ sort({list} [, {func}]) *sort()* *E7 want a list to remain unmodified make a copy first: > :let sortedlist = sort(copy(mylist)) < Uses the string representation of each item to sort on. + Numbers sort after Strings, Lists after Numbers. When {func} is given and it is one then case is ignored. When {func} is a Funcref or a function name, this function is called to compare items. The function is invoked with two @@ -3087,15 +3182,16 @@ sort({list} [, {func}]) *sort()* *E7 endfunc let sortedlist = sort(mylist, "MyCompare") -str2list({expr} [, {pattern}]) *str2list()* +split({expr} [, {pattern}]) *split()* Make a List out of {expr}. When {pattern} is omitted each white-separated sequence of characters becomes an item. Otherwise the string is split where {pattern} matches, removing the matched characters. Empty strings are omitted. Example: > - :let words = str2list(getline('.'), '\W\+') + :let words = split(getline('.'), '\W\+') < Since empty strings are not added the "\+" isn't required but it makes the function work a bit faster. + The opposite function is |join()|. strftime({format} [, {time}]) *strftime()* @@ -3129,14 +3225,15 @@ stridx({haystack}, {needle}) *stridx( :echo stridx("Starting point", "start") -1 < *string()* -string({expr}) Return {expr} converted to a String. +string({expr}) Return {expr} converted to a String. If {expr} is a Number, + String or a composition of them, then the result can be parsed + back with |eval()|. {expr} type result ~ - String identical - Number decimal representation - Funcref name of the function - List "[item, item]" form - Note that string values are not in quotes, thus the result - can't be parsed back to a List. + String #string# + Number 123 + Funcref function(#name#) + List [item, item] + Note that in String values the # character is doubled. *strlen()* strlen({expr}) The result is a Number, which is the length of the String diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -3600,7 +3600,12 @@ E704 eval.txt /*E704* E705 eval.txt /*E705* E706 eval.txt /*E706* E707 eval.txt /*E707* +E708 eval.txt /*E708* +E709 eval.txt /*E709* E71 pattern.txt /*E71* +E710 eval.txt /*E710* +E711 eval.txt /*E711* +E712 eval.txt /*E712* E72 message.txt /*E72* E73 tagsrch.txt /*E73* E74 message.txt /*E74* @@ -4576,6 +4581,7 @@ escape intro.txt /*escape* escape() eval.txt /*escape()* escape-bar version4.txt /*escape-bar* eval eval.txt /*eval* +eval() eval.txt /*eval()* eval-examples eval.txt /*eval-examples* eval-sandbox eval.txt /*eval-sandbox* eval.txt eval.txt /*eval.txt* @@ -4623,6 +4629,7 @@ expr-!=? eval.txt /*expr-!=?* expr-!~ eval.txt /*expr-!~* expr-!~# eval.txt /*expr-!~#* expr-!~? eval.txt /*expr-!~?* +expr-# eval.txt /*expr-#* expr-% eval.txt /*expr-%* expr-&& eval.txt /*expr-&&* expr-' eval.txt /*expr-'* @@ -4713,6 +4720,7 @@ filetypedetect-changed version6.txt /*fi filetypes filetype.txt /*filetypes* filewritable() eval.txt /*filewritable()* filter change.txt /*filter* +filter() eval.txt /*filter()* find-manpage usr_12.txt /*find-manpage* find-replace usr_10.txt /*find-replace* finddir() eval.txt /*finddir()* @@ -5276,6 +5284,7 @@ java-cinoptions indent.txt /*java-cinopt java-indenting indent.txt /*java-indenting* java-syntax syntax.txt /*java-syntax* java.vim syntax.txt /*java.vim* +join() eval.txt /*join()* jsbterm-mouse options.txt /*jsbterm-mouse* jtags tagsrch.txt /*jtags* jump-motions motion.txt /*jump-motions* @@ -5381,6 +5390,7 @@ make-syntax syntax.txt /*make-syntax* make.vim syntax.txt /*make.vim* man-plugin filetype.txt /*man-plugin* manual-copyright usr_01.txt /*manual-copyright* +map() eval.txt /*map()* map- map.txt /*map-* map-ambiguous map.txt /*map-ambiguous* map-backtick tips.txt /*map-backtick* @@ -5418,6 +5428,7 @@ match-highlight pattern.txt /*match-high matchend() eval.txt /*matchend()* matchit-install usr_05.txt /*matchit-install* matchstr() eval.txt /*matchstr()* +max() eval.txt /*max()* mbyte-IME mbyte.txt /*mbyte-IME* mbyte-XIM mbyte.txt /*mbyte-XIM* mbyte-conversion mbyte.txt /*mbyte-conversion* @@ -5441,6 +5452,7 @@ message-history message.txt /*message-hi message.txt message.txt /*message.txt* messages message.txt /*messages* meta intro.txt /*meta* +min() eval.txt /*min()* minimal-features os_msdos.txt /*minimal-features* missing-commands vi_diff.txt /*missing-commands* missing-options vi_diff.txt /*missing-options* @@ -6048,6 +6060,7 @@ sgml-syntax syntax.txt /*sgml-syntax* sgml.vim syntax.txt /*sgml.vim* sh-syntax syntax.txt /*sh-syntax* sh.vim syntax.txt /*sh.vim* +sharp-string eval.txt /*sharp-string* shell-window tips.txt /*shell-window* shell_error-variable eval.txt /*shell_error-variable* shift intro.txt /*shift* @@ -6081,6 +6094,7 @@ spec_chglog_prepend pi_spec.txt /*spec_c spec_chglog_release_info pi_spec.txt /*spec_chglog_release_info* special-buffers windows.txt /*special-buffers* speed-up tips.txt /*speed-up* +split() eval.txt /*split()* splitfind windows.txt /*splitfind* splitview windows.txt /*splitview* sponsor sponsor.txt /*sponsor* @@ -6107,7 +6121,6 @@ startup-terminal term.txt /*startup-term static-tag tagsrch.txt /*static-tag* status-line windows.txt /*status-line* statusmsg-variable eval.txt /*statusmsg-variable* -str2list() eval.txt /*str2list()* strftime() eval.txt /*strftime()* stridx() eval.txt /*stridx()* string() eval.txt /*string()* diff --git a/runtime/keymap/polish-slash_iso-8859-2.vim b/runtime/keymap/polish-slash_iso-8859-2.vim new file mode 100644 --- /dev/null +++ b/runtime/keymap/polish-slash_iso-8859-2.vim @@ -0,0 +1,38 @@ +" Polish letters keymap for iso-8859-2 +" Maintainer: HS6_06 +" Last Changed: 2005 Jan 9 + +" This keymap adds the special Polish letters +" to an existing Latin keyboard. +" All chars as usual except: +" Polish: +" instead of AltGr+{acelnosxz} you ve to use "/" followed by {acelnosxz} + +" short keymap name for statusline +let b:keymap_name = "polish-slash-iso-8859-2" + +scriptencoding latin1 + +loadkeymap + +" Polish letters +/a " LATIN SMALL LETTER A WITH OGONEK +/c " LATIN SMALL LETTER C WITH ACUTE +/e " LATIN SMALL LETTER E WITH OGONEK +/l " LATIN SMALL LETTER L WITH STROKE +/n " LATIN SMALL LETTER N WITH ACUTE +/o " LATIN SMALL LETTER O WITH ACUTE +/s " LATIN SMALL LETTER S WITH ACUTE +/x " LATIN SMALL LETTER Z WITH ACUTE +/z " LATIN SMALL LETTER Z WITH DOT ABOVE + +/A " LATIN CAPITAL LETTER A WITH OGONEK +/C " LATIN CAPITAL LETTER C WITH ACUTE +/E " LATIN CAPITAL LETTER E WITH OGONEK +/L " LATIN CAPITAL LETTER L WITH STROKE +/N " LATIN CAPITAL LETTER N WITH ACUTE +/O " LATIN CAPITAL LETTER O WITH ACUTE +/S " LATIN CAPITAL LETTER S WITH ACUTE +/X " LATIN CAPITAL LETTER Z WITH ACUTE +/Z " LATIN CAPITAL LETTER Z WITH DOT ABOVE + diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -80,6 +80,8 @@ static void correct_cmdspos __ARGS((int static void alloc_cmdbuff __ARGS((int len)); static int realloc_cmdbuff __ARGS((int len)); static void draw_cmdline __ARGS((int start, int len)); +static void save_cmdline __ARGS((struct cmdline_info *ccp)); +static void restore_cmdline __ARGS((struct cmdline_info *ccp)); static int cmdline_paste __ARGS((int regname, int literally)); #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) static void redrawcmd_preedit __ARGS((void)); @@ -593,8 +595,8 @@ getcmdline(firstc, count, indent) #ifdef FEAT_EVAL else if (c == 'e') { - struct cmdline_info save_ccline; - char_u *p; + struct cmdline_info save_ccline; + char_u *p = NULL; /* * Replace the command line with the result of an expression. @@ -605,16 +607,17 @@ getcmdline(firstc, count, indent) new_cmdpos = 99999; /* keep it at the end */ else new_cmdpos = ccline.cmdpos; - save_ccline = ccline; - ccline.cmdbuff = NULL; - ccline.cmdprompt = NULL; + + save_cmdline(&save_ccline); c = get_expr_register(); - ccline = save_ccline; + restore_cmdline(&save_ccline); if (c == '=') { + save_cmdline(&save_ccline); p = get_expr_line(); - if (p != NULL - && realloc_cmdbuff((int)STRLEN(p) + 1) == OK) + restore_cmdline(&save_ccline); + + if (p != NULL && realloc_cmdbuff((int)STRLEN(p) + 1) == OK) { ccline.cmdlen = STRLEN(p); STRCPY(ccline.cmdbuff, p); @@ -1031,11 +1034,9 @@ getcmdline(firstc, count, indent) } else { - save_ccline = ccline; - ccline.cmdbuff = NULL; - ccline.cmdprompt = NULL; + save_cmdline(&save_ccline); c = get_expr_register(); - ccline = save_ccline; + restore_cmdline(&save_ccline); } } #endif @@ -1727,7 +1728,13 @@ returncmd: ui_cursor_shape(); /* may show different cursor shape */ #endif - return ccline.cmdbuff; + { + char_u *p = ccline.cmdbuff; + + /* Make ccline empty, getcmdline() may try to use it. */ + ccline.cmdbuff = NULL; + return p; + } } #if (defined(FEAT_CRYPT) || defined(FEAT_EVAL)) || defined(PROTO) @@ -1747,12 +1754,11 @@ getcmdline_prompt(firstc, prompt, attr) struct cmdline_info save_ccline; int msg_col_save = msg_col; - save_ccline = ccline; - ccline.cmdbuff = NULL; + save_cmdline(&save_ccline); ccline.cmdprompt = prompt; ccline.cmdattr = attr; s = getcmdline(firstc, 1L, 0); - ccline = save_ccline; + restore_cmdline(&save_ccline); /* Restore msg_col, the prompt from input() may have changed it. */ msg_col = msg_col_save; @@ -2538,6 +2544,40 @@ put_on_cmdline(str, len, redraw) return retval; } +static struct cmdline_info prev_ccline; +static int prev_ccline_used = FALSE; + +/* + * Save ccline, because obtaining the "=" register may execute "normal :cmd" + * and overwrite it. But get_cmdline_str() may need it, thus make it + * available globally in prev_ccline. + */ + static void +save_cmdline(ccp) + struct cmdline_info *ccp; +{ + if (!prev_ccline_used) + { + vim_memset(&prev_ccline, 0, sizeof(struct cmdline_info)); + prev_ccline_used = TRUE; + } + *ccp = prev_ccline; + prev_ccline = ccline; + ccline.cmdbuff = NULL; + ccline.cmdprompt = NULL; +} + +/* + * Resture ccline after it has been saved with save_cmdline(). + */ + static void +restore_cmdline(ccp) + struct cmdline_info *ccp; +{ + ccline = prev_ccline; + prev_ccline = *ccp; +} + /* * paste a yank register into the command line. * used by CTRL-R command in command-line mode @@ -2572,13 +2612,10 @@ cmdline_paste(regname, literally) regname = may_get_selection(regname); #endif - /* Need to save and restore ccline, because obtaining the "=" register may - * execute "normal :cmd" and overwrite it. */ - save_ccline = ccline; - ccline.cmdbuff = NULL; - ccline.cmdprompt = NULL; + /* Need to save and restore ccline. */ + save_cmdline(&save_ccline); i = get_spec_reg(regname, &arg, &allocated, TRUE); - ccline = save_ccline; + restore_cmdline(&save_ccline); if (i) { @@ -4534,6 +4571,24 @@ get_history_idx(histype) return history[histype][hisidx[histype]].hisnum; } +static struct cmdline_info *get_ccline_ptr __ARGS((void)); + +/* + * Get pointer to the command line info to use. cmdline_paste() may clear + * ccline and put the previous value in prev_ccline. + */ + static struct cmdline_info * +get_ccline_ptr() +{ + if ((State & CMDLINE) == 0) + return NULL; + if (ccline.cmdbuff != NULL) + return &ccline; + if (prev_ccline_used && prev_ccline.cmdbuff != NULL) + return &prev_ccline; + return NULL; +} + /* * Get the current command line in allocated memory. * Only works when the command line is being edited. @@ -4542,9 +4597,11 @@ get_history_idx(histype) char_u * get_cmdline_str() { - if (ccline.cmdbuff == NULL || (State & CMDLINE) == 0) + struct cmdline_info *p = get_ccline_ptr(); + + if (p == NULL) return NULL; - return vim_strnsave(ccline.cmdbuff, ccline.cmdlen); + return vim_strnsave(p->cmdbuff, p->cmdlen); } /* @@ -4556,9 +4613,11 @@ get_cmdline_str() int get_cmdline_pos() { - if (ccline.cmdbuff == NULL || (State & CMDLINE) == 0) + struct cmdline_info *p = get_ccline_ptr(); + + if (p == NULL) return -1; - return ccline.cmdpos; + return p->cmdpos; } /* @@ -4570,7 +4629,9 @@ get_cmdline_pos() set_cmdline_pos(pos) int pos; { - if (ccline.cmdbuff == NULL || (State & CMDLINE) == 0) + struct cmdline_info *p = get_ccline_ptr(); + + if (p == NULL) return 1; /* The position is not set directly but after CTRL-\ e or CTRL-R = has diff --git a/src/gui_gtk.c b/src/gui_gtk.c --- a/src/gui_gtk.c +++ b/src/gui_gtk.c @@ -1422,7 +1422,7 @@ gui_mch_browsedir( #endif /* FEAT_BROWSE */ -#if (defined(FEAT_GUI_DIALOG) && !defined(HAVE_GTK2)) || defined(PROTO) +#if defined(FEAT_GUI_DIALOG) && !defined(HAVE_GTK2) static char_u *dialog_textfield = NULL; static GtkWidget *dialog_textentry; @@ -1956,7 +1956,7 @@ gui_mch_dialog( int type, /* type of di #endif /* FEAT_GUI_DIALOG && !HAVE_GTK2 */ -#if defined(FEAT_GUI_DIALOG) && defined(HAVE_GTK2) +#if (defined(FEAT_GUI_DIALOG) && defined(HAVE_GTK2)) || defined(PROTO) static GtkWidget * create_message_dialog(int type, char_u *title, char_u *message) diff --git a/src/gui_mac.c b/src/gui_mac.c --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -5674,7 +5674,8 @@ display_errors() /* * Get current mouse coordinates in text window. */ -void gui_mch_getmouse(int *x, int *y) + void +gui_mch_getmouse(int *x, int *y) { Point where; diff --git a/src/gui_photon.c b/src/gui_photon.c --- a/src/gui_photon.c +++ b/src/gui_photon.c @@ -1895,7 +1895,7 @@ gui_mch_mousehide(int hide) } } - int + void gui_mch_getmouse(int *x, int *y) { PhCursorInfo_t info; diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -4,6 +4,7 @@ int do_cmdline_cmd __ARGS((char_u *cmd)) int do_cmdline __ARGS((char_u *cmdline, char_u *(*getline)(int, void *, int), void *cookie, int flags)); int getline_equal __ARGS((char_u *(*getline)(int, void *, int), void *cookie, char_u *(*func)(int, void *, int))); void *getline_cookie __ARGS((char_u *(*getline)(int, void *, int), void *cookie)); +int checkforcmd __ARGS((char_u **pp, char *cmd, int len)); int cmd_exists __ARGS((char_u *name)); char_u *set_one_cmd_context __ARGS((expand_T *xp, char_u *buff)); char_u *skip_range __ARGS((char_u *cmd, int *ctx)); diff --git a/src/quickfix.c b/src/quickfix.c --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2295,7 +2295,7 @@ ex_vimgrep(eap) regmatch.regprog = vim_regcomp(s, RE_MAGIC); if (regmatch.regprog == NULL) goto theend; - regmatch.rmm_ic = FALSE; + regmatch.rmm_ic = p_ic; p = skipwhite(p); if (*p == NUL) diff --git a/src/testdir/test49.vim b/src/testdir/test49.vim --- a/src/testdir/test49.vim +++ b/src/testdir/test49.vim @@ -1,6 +1,6 @@ " Vim script language tests " Author: Servatius Brandt -" Last Change: 2004 Apr 03 +" Last Change: 2005 Jan 11 "------------------------------------------------------------------------------- " Test environment {{{1 @@ -8433,7 +8433,7 @@ if ExtraVim() call T(23, '(1 ? 2) + CONT(23)', 'E109', "Missing ':' after '?'") call T(24, '("abc) + CONT(24)', 'E114', "Missing quote") call T(25, "('abc) + CONT(25)", 'E115', "Missing quote") - call T(26, '& + CONT(26)', 'E112', "Option name missing") + call T(26, '& + CONT(26)', 'E712', "Using & outside of map()") call T(27, '&asdf + CONT(27)', 'E113', "Unknown option") Xpath 134217728 " X: 134217728 diff --git a/src/version.h b/src/version.h --- a/src/version.h +++ b/src/version.h @@ -36,5 +36,5 @@ #define VIM_VERSION_NODOT "vim70aa" #define VIM_VERSION_SHORT "7.0aa" #define VIM_VERSION_MEDIUM "7.0aa ALPHA" -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 9)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 9, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 11)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2004 Jan 11, compiled "