# HG changeset patch # User vimboss # Date 1141771127 0 # Node ID 8ae24f338cab86cb35fd495ddc3cbe2101ae1558 # Parent b526e10493b1fd55e23214d166d729481a44d149 updated for version 7.0217 diff --git a/runtime/autoload/ccomplete.vim b/runtime/autoload/ccomplete.vim --- a/runtime/autoload/ccomplete.vim +++ b/runtime/autoload/ccomplete.vim @@ -1,7 +1,7 @@ " Vim completion script " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2006 Feb 10 +" Last Change: 2006 Mar 07 " This function is used for the 'omnifunc' option. @@ -123,7 +123,7 @@ function! ccomplete#Complete(findstart, if match(line, match . '\s*\[') > 0 let match .= '[' else - let res = s:Nextitem(strpart(line, 0, col), [''], 0) + let res = s:Nextitem(strpart(line, 0, col), [''], 0, 1) if len(res) > 0 " There are members, thus add "." or "->". if match(line, '\*[ \t(]*' . match . '\>') > 0 @@ -136,7 +136,7 @@ function! ccomplete#Complete(findstart, let res = [{'match': match, 'tagline' : ''}] else " Completing "var.", "var.something", etc. - let res = s:Nextitem(strpart(line, 0, col), items[1:], 0) + let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1) endif endif @@ -153,7 +153,7 @@ function! ccomplete#Complete(findstart, for i in range(len(diclist)) " New ctags has the "typename" field. if has_key(diclist[i], 'typename') - call extend(res, s:StructMembers(diclist[i]['typename'], items[1:])) + call extend(res, s:StructMembers(diclist[i]['typename'], items[1:], 1)) endif " For a variable use the command, which must be a search pattern that @@ -162,7 +162,7 @@ function! ccomplete#Complete(findstart, let line = diclist[i]['cmd'] if line[0] == '/' && line[1] == '^' let col = match(line, '\<' . items[0] . '\>') - call extend(res, s:Nextitem(strpart(line, 2, col - 2), items[1:], 0)) + call extend(res, s:Nextitem(strpart(line, 2, col - 2), items[1:], 0, 1)) endif endif endfor @@ -173,7 +173,7 @@ function! ccomplete#Complete(findstart, " TODO: join previous line if it makes sense let line = getline('.') let col = col('.') - let res = s:Nextitem(strpart(line, 0, col), items[1:], 0) + let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1) endif " If the last item(s) are [...] they need to be added to the matches. @@ -197,7 +197,7 @@ function! s:GetAddition(line, match, mem endif " Check if the item has members. - if len(s:SearchMembers(a:memarg, [''])) > 0 + if len(s:SearchMembers(a:memarg, [''], 0)) > 0 " If there is a '*' before the name use "->". if match(a:line, '\*[ \t(]*' . a:match . '\>') > 0 return '->' @@ -248,8 +248,8 @@ endfunction function! s:Tagcmd2extra(cmd, name, fname) if a:cmd =~ '^/^' " The command is a search command, useful to see what it is. - let x = matchstr(a:cmd, '^/^\zs.*\ze$/') - let x = substitute(x, a:name, '@@', '') + let x = matchstr(a:cmd, '^/^\s*\zs.*\ze$/') + let x = substitute(x, '\<' . a:name . '\>', '@@', '') let x = substitute(x, '\\\(.\)', '\1', 'g') let x = x . ' - ' . a:fname elseif a:cmd =~ '^\d*$' @@ -266,7 +266,7 @@ endfunction " Repeat this recursively for items[1], if it's there. " When resolving typedefs "depth" is used to avoid infinite recursion. " Return the list of matches. -function! s:Nextitem(lead, items, depth) +function! s:Nextitem(lead, items, depth, all) " Use the text up to the variable name and split it in tokens. let tokens = split(a:lead, '\s\+\|\<') @@ -277,7 +277,7 @@ function! s:Nextitem(lead, items, depth) " Recognize "struct foobar" and "union foobar". if (tokens[tidx] == 'struct' || tokens[tidx] == 'union') && tidx + 1 < len(tokens) - let res = s:StructMembers(tokens[tidx] . ':' . tokens[tidx + 1], a:items) + let res = s:StructMembers(tokens[tidx] . ':' . tokens[tidx + 1], a:items, a:all) break endif @@ -291,7 +291,7 @@ function! s:Nextitem(lead, items, depth) for tagidx in range(len(diclist)) " New ctags has the "typename" field. if has_key(diclist[tagidx], 'typename') - call extend(res, s:StructMembers(diclist[tagidx]['typename'], a:items)) + call extend(res, s:StructMembers(diclist[tagidx]['typename'], a:items, a:all)) continue endif @@ -317,11 +317,11 @@ function! s:Nextitem(lead, items, depth) endif endfor if name != '' - call extend(res, s:StructMembers(cmdtokens[0] . ':' . name, a:items)) + call extend(res, s:StructMembers(cmdtokens[0] . ':' . name, a:items, a:all)) endif elseif a:depth < 10 " Could be "typedef other_T some_T". - call extend(res, s:Nextitem(cmdtokens[0], a:items, a:depth + 1)) + call extend(res, s:Nextitem(cmdtokens[0], a:items, a:depth + 1, a:all)) endif endif endif @@ -338,7 +338,9 @@ endfunction " Search for members of structure "typename" in tags files. " Return a list with resulting matches. " Each match is a dictionary with "match" and "tagline" entries. -function! s:StructMembers(typename, items) +" When "all" is non-zero find all, otherwise just return 1 if there is any +" member. +function! s:StructMembers(typename, items, all) " Todo: What about local structures? let fnames = join(map(tagfiles(), 'escape(v:val, " \\")')) if fnames == '' @@ -347,8 +349,13 @@ function! s:StructMembers(typename, item let typename = a:typename let qflist = [] + if a:all == 0 + let n = '1' " stop at first found match + else + let n = '' + endif while 1 - exe 'silent! vimgrep /\t' . typename . '\(\t\|$\)/j ' . fnames + exe 'silent! ' . n . 'vimgrep /\t' . typename . '\(\t\|$\)/j ' . fnames let qflist = getqflist() if len(qflist) > 0 || match(typename, "::") < 0 break @@ -380,7 +387,7 @@ function! s:StructMembers(typename, item " More items following. For each of the possible members find the " matching following members. - return s:SearchMembers(matches, a:items[idx :]) + return s:SearchMembers(matches, a:items[idx :], a:all) endif " Failed to find anything. @@ -388,7 +395,9 @@ function! s:StructMembers(typename, item endfunction " For matching members, find matches for following items. -function! s:SearchMembers(matches, items) +" When "all" is non-zero find all, otherwise just return 1 if there is any +" member. +function! s:SearchMembers(matches, items, all) let res = [] for i in range(len(a:matches)) let typename = '' @@ -405,18 +414,22 @@ function! s:SearchMembers(matches, items let typename = matchstr(line, '[^\t]*', e) endif endif + if typename != '' - call extend(res, s:StructMembers(typename, a:items)) + call extend(res, s:StructMembers(typename, a:items, a:all)) else " Use the search command (the declaration itself). let s = match(line, '\t\zs/^') if s > 0 let e = match(line, '\<' . a:matches[i]['match'] . '\>', s) if e > 0 - call extend(res, s:Nextitem(strpart(line, s, e - s), a:items, 0)) + call extend(res, s:Nextitem(strpart(line, s, e - s), a:items, 0, a:all)) endif endif endif + if a:all == 0 && len(res) > 0 + break + endif endfor return res endfunc diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 7.0aa. Last change: 2006 Feb 27 +*autocmd.txt* For Vim version 7.0aa. Last change: 2006 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -274,6 +274,7 @@ Name triggered by ~ |FuncUndefined| a user function is used but it isn't defined |SpellFileMissing| a spell file is used but it can't be found +|SourcePre| before sourcing a Vim script |FocusGained| Vim got input focus |FocusLost| Vim lost input focus @@ -666,6 +667,8 @@ RemoteReply When a reply from a Vim th *SessionLoadPost* SessionLoadPost After loading the session file created using the |:mksession| command. + *SourcePre* +SourcePre Before sourcing a Vim script. |:source| *SpellFileMissing* SpellFileMissing When trying to load a spell checking file and it can't be found. is the language, 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: 2006 Mar 06 +*eval.txt* For Vim version 7.0aa. Last change: 2006 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1429,6 +1429,7 @@ v:swapcommand Normal mode command to be opened. Can be used for a |SwapExists| autocommand to have another Vim open the file and jump to the right place. For example, when jumping to a tag the value is ":tag tagname\r". + For ":edit +cmd file" the value is ":cmd\r". *v:termresponse* *termresponse-variable* v:termresponse The escape sequence returned by the terminal for the |t_RV| diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim version 7.0aa. Last change: 2006 Feb 04 +*quickfix.txt* For Vim version 7.0aa. Last change: 2006 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -499,6 +499,12 @@ 5.1 using Vim's internal grep pattern to ignore case or |/\C| to match case. 'smartcase' is not used. + When a number is put before the command this is used + as the maximum number of matches to find. Use + ":1vimgrep pattern file" to find only the first. + Useful if you only want to check if there is a match + and quit quickly when it's found. + Without the 'j' flag Vim jumps to the first match. With 'j' only the quickfix list is updated. With the [!] any changes in the current buffer are diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 7.0aa. Last change: 2005 Jun 26 +*repeat.txt* For Vim version 7.0aa. Last change: 2006 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -144,6 +144,7 @@ For writing a Vim script, see chapter 41 *:so* *:source* *load-vim-script* :so[urce] {file} Read Ex commands from {file}. These are commands that start with a ":". + Triggers the |SourcePre| autocommand. :so[urce]! {file} Read Vim commands from {file}. These are commands that are executed from Normal mode, like you type diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -4123,6 +4123,7 @@ Select-mode-mapping visual.txt /*Select- Session starting.txt /*Session* SessionLoad-variable starting.txt /*SessionLoad-variable* SessionLoadPost autocmd.txt /*SessionLoadPost* +SourcePre autocmd.txt /*SourcePre* SpellFileMissing autocmd.txt /*SpellFileMissing* StdinReadPost autocmd.txt /*StdinReadPost* StdinReadPre autocmd.txt /*StdinReadPre* @@ -5483,7 +5484,6 @@ hebrew hebrew.txt /*hebrew* hebrew.txt hebrew.txt /*hebrew.txt* help various.txt /*help* help-context help.txt /*help-context* -help-tags tags 1 help-translated various.txt /*help-translated* help-xterm-window various.txt /*help-xterm-window* help.txt help.txt /*help.txt* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.0aa. Last change: 2006 Mar 06 +*todo.txt* For Vim version 7.0aa. Last change: 2006 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,47 +30,30 @@ be worked on, but only if you sponsor Vi *known-bugs* -------------------- Known bugs and current work ----------------------- -When expanding on the command line, recognize shell commands, such as ":!cmd". - Move from ExpandFromContext() to separate function. - Check for file being executable. EW_EXEC - Escape special characters ";&<>(){}". Also in file names. (Adri Verhoef) - -Autoload: -- Add a Vim script in $VIMRUNTIME/tools that takes a file with a list of - script names and a help file and produces a script that can be sourced to - install the scripts in the user's directories. - Use findfile(), so that only file names need to be given: - script plugin/myscript.vim - script autoload/mylib.vim - script autoload/yourlib.vim - helpfile doc/myscript.txt - For the "helpfile" item ":helptags" is run. - Win32: Describe how to do debugging and describe it. (George Reilly) -Are there more commands where v:swapcommand can be set to something useful? - Mac unicode patch (Da Woon Jung): - Mac: Unicode input and display (Eckehard Berns, 2004 June 27) Other patch from Da Woon Jung, 2005 Jan 16. 8 Add patch from Muraoka Taro (Mar 16) to support input method on Mac? New patch 2004 Jun 16 +- Add default key mappings for the command key (Alan Schmitt) + use http://macvim.org/OSX/files/gvimrc - selecting proportional font breaks display - UTF-8 text causes display problems. Font replacement causes this. - Command-key mappings do not work. (Alan Schmitt) -- Add default key mappings for the command key (Alan Schmitt) - use http://macvim.org/OSX/files/gvimrc - With 'nopaste' pasting is wrong, with 'paste' Command-V doesn't work. (Alan Schmitt) +Bug in Netbeans interface. (Xavier de Gaye, 2006 Mar 7) CONSIDERED FOR VERSION 7.0: Omni completion: ccomplete: - Finding out if an item has members (to add '.' or '->') requires a grep - in the tags files, that is very slow. Is there another solution? At - least stop at the first match. + in the tags files, that is very slow. Is there another solution? + Check what happens when taglist() is called. Could build the list of items for each structure in memory. Is that faster? Not using too much memory? - For C add tag "kind" field to each match? @@ -1625,6 +1608,15 @@ 7 SpecialKey highlighting overrules sy Built-in script language: +9 Autoload: Add a Vim script in $VIMRUNTIME/tools that takes a file with a + list of script names and a help file and produces a script that can be + sourced to install the scripts in the user's directories. + Use findfile(), so that only file names need to be given: + script plugin/myscript.vim + script autoload/mylib.vim + script autoload/yourlib.vim + helpfile doc/myscript.txt + For the "helpfile" item ":helptags" is run. 7 Execute a function with standard option values. No need to save and restore option values. Especially useful for new options. Problem: how to avoid a performance penalty (esp. for string options)? diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt --- a/runtime/doc/version7.txt +++ b/runtime/doc/version7.txt @@ -1,4 +1,4 @@ -*version7.txt* For Vim version 7.0aa. Last change: 2006 Mar 06 +*version7.txt* For Vim version 7.0aa. Last change: 2006 Mar 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -647,6 +647,8 @@ New autocommand events: ~ |SpellFileMissing| when a spell file can't be found +|SourcePre| before sourcing a Vim script + |CursorHoldI| the user doesn't press a key for a while in Insert mode |CursorMoved| the cursor was moved in Normal mode |CursorMovedI| the cursor was moved in Insert mode @@ -725,6 +727,9 @@ Vietnamese message translations and menu Others: ~ +The Netbeans interface was updated for Sun Studio 10. The protocol number +goes from 2.2 to 2.3. (Gordon Prieur) + Mac: Add the selection type to the clipboard, so that Block, line and character selections can be used between two Vims. (Eckehard Berns) Also fixes the problem that setting 'clipboard' to "unnamed" breaks using @@ -792,6 +797,9 @@ IMPROVEMENTS *improvements-7* Move the help for printing to a separate help file. It's quite a lot now. +When doing completion for ":!cmd", ":r !cmd" or ":w !cmd" executable files are +found in $PATH instead of looking for ordinary files in the current directlry. + When ":silent" is used and a backwards range is given for an Ex command the range is swapped automatically instead of asking if that is OK. @@ -1862,4 +1870,7 @@ MS-DOS, Win32: When 'encoding' defaults 'iskeyword' was still for CPxxx. And when 'nocompatible' was set 'isprint' would also be the wrong value. +When a command was defined not to take arguments and no '|' no warning message +would be given for using a '|'. Also with ":loadkeymap". + vim:tw=78:ts=8:ft=help:norl: diff --git a/src/auto/configure b/src/auto/configure --- a/src/auto/configure +++ b/src/auto/configure @@ -2930,7 +2930,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: not found" >&5 echo "${ECHO_T}not found" >&6 - CFLAGS="save_cflags" + CFLAGS="$save_cflags" echo "$as_me:$LINENO: checking if Intel architecture is supported" >&5 echo $ECHO_N "checking if Intel architecture is supported... $ECHO_C" >&6 CPPFLAGS="$CPPFLAGS -arch i386" diff --git a/src/configure.in b/src/configure.in --- a/src/configure.in +++ b/src/configure.in @@ -123,7 +123,7 @@ if test "`(uname) 2>/dev/null`" = Darwin AC_MSG_RESULT(found, will make universal binary), AC_MSG_RESULT(not found) - CFLAGS="save_cflags" + CFLAGS="$save_cflags" AC_MSG_CHECKING(if Intel architecture is supported) CPPFLAGS="$CPPFLAGS -arch i386" LDFLAGS="$save_ldflags -arch i386" diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -111,7 +111,7 @@ static int compl_matches = 0; static char_u *compl_pattern = NULL; static int compl_direction = FORWARD; static int compl_shows_dir = FORWARD; -static int compl_pending = FALSE; +static int compl_pending = 0; /* > 1 for postponed CTRL-N */ static pos_T compl_startpos; static colnr_T compl_col = 0; /* column where the text starts * that is being completed */ @@ -2466,6 +2466,12 @@ ins_compl_show_pum() if (compl == compl_shown_match) { did_find_shown_match = TRUE; + + /* When the original text is the shown match don't set + * compl_shown_match. */ + if (compl->cp_flags & ORIGINAL_TEXT) + shown_match_ok = TRUE; + if (!shown_match_ok && shown_compl != NULL) { /* The shown match isn't displayed, set it to the @@ -3837,14 +3843,14 @@ ins_compl_next(allow_get_expansion, coun /* Delete old text to be replaced */ ins_compl_delete(); - compl_pending = FALSE; - /* Repeat this for when or is typed. But don't wrap * around. */ while (--todo >= 0) { if (compl_shows_dir == FORWARD && compl_shown_match->cp_next != NULL) { + if (compl_pending != 0) + --compl_pending; compl_shown_match = compl_shown_match->cp_next; found_end = (compl_first_match != NULL && (compl_shown_match->cp_next == compl_first_match @@ -3853,18 +3859,23 @@ ins_compl_next(allow_get_expansion, coun else if (compl_shows_dir == BACKWARD && compl_shown_match->cp_prev != NULL) { + if (compl_pending != 0) + ++compl_pending; found_end = (compl_shown_match == compl_first_match); compl_shown_match = compl_shown_match->cp_prev; found_end |= (compl_shown_match == compl_first_match); } else { - compl_pending = TRUE; + if (compl_shows_dir == BACKWARD) + --compl_pending; + else + ++compl_pending; if (!allow_get_expansion) return -1; num_matches = ins_compl_get_exp(&compl_startpos); - if (compl_pending && compl_direction == compl_shows_dir) + if (compl_pending != 0 && compl_direction == compl_shows_dir) compl_shown_match = compl_curr_match; found_end = FALSE; } @@ -3939,7 +3950,7 @@ ins_compl_next(allow_get_expansion, coun /* * Call this while finding completions, to check whether the user has hit a key * that should change the currently displayed completion, or exit completion - * mode. Also, when compl_pending is TRUE, show a completion as soon as + * mode. Also, when compl_pending is not zero, show a completion as soon as * possible. -- webb * "frequency" specifies out of how many calls we actually check. */ @@ -3976,8 +3987,9 @@ ins_compl_check_keys(frequency) else if (c != Ctrl_R) compl_interrupted = TRUE; } - if (compl_pending && !got_int) - (void)ins_compl_next(FALSE, 1, TRUE); + if (compl_pending != 0 && !got_int) + (void)ins_compl_next(FALSE, compl_pending > 0 + ? compl_pending : -compl_pending, TRUE); } /* @@ -4081,6 +4093,7 @@ ins_complete(c) line = ml_get(curwin->w_cursor.lnum); curs_col = curwin->w_cursor.col; + compl_pending = 0; /* if this same ctrl_x_mode has been interrupted use the text from * "compl_startpos" to the cursor as a pattern to add a new word diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -931,7 +931,7 @@ var_redir_start(name, append) else set_var_lval(redir_lval, redir_endp, &tv, TRUE, (char_u *)"="); err = did_emsg; - did_emsg += save_emsg; + did_emsg |= save_emsg; if (err) { var_redir_stop(); @@ -979,7 +979,7 @@ var_redir_str(value, len) did_emsg = FALSE; set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)"."); err = did_emsg; - did_emsg += save_emsg; + did_emsg |= save_emsg; if (err) var_redir_stop(); @@ -8961,7 +8961,7 @@ filter_map(argvars, rettv, map) int rem; int todo; char_u *msg = map ? (char_u *)"map()" : (char_u *)"filter()"; - int save_called_emsg; + int save_did_emsg; rettv->vval.v_number = 0; if (argvars[0].v_type == VAR_LIST) @@ -8991,11 +8991,10 @@ filter_map(argvars, rettv, map) prepare_vimvar(VV_VAL, &save_val); expr = skipwhite(expr); - /* We reset "called_emsg" to be able to detect whether an error - * occurred during evaluation of the expression. "did_emsg" can't be - * used, because it is reset when calling a function. */ - save_called_emsg = called_emsg; - called_emsg = FALSE; + /* We reset "did_emsg" to be able to detect whether an error + * occurred during evaluation of the expression. */ + save_did_emsg = did_emsg; + did_emsg = FALSE; if (argvars[0].v_type == VAR_DICT) { @@ -9015,7 +9014,7 @@ filter_map(argvars, rettv, map) break; vimvars[VV_KEY].vv_str = vim_strsave(di->di_key); if (filter_map_one(&di->di_tv, expr, map, &rem) == FAIL - || called_emsg) + || did_emsg) break; if (!map && rem) dictitem_remove(d, di); @@ -9034,7 +9033,7 @@ filter_map(argvars, rettv, map) break; nli = li->li_next; if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL - || called_emsg) + || did_emsg) break; if (!map && rem) listitem_remove(l, li); @@ -9043,7 +9042,7 @@ filter_map(argvars, rettv, map) restore_vimvar(VV_VAL, &save_val); - called_emsg |= save_called_emsg; + did_emsg |= save_did_emsg; } copy_tv(&argvars[0], rettv); @@ -17830,6 +17829,7 @@ ex_function(eap) else eap->skip = TRUE; } + /* An error in a function call during evaluation of an expression in magic * braces should not cause the function not to be defined. */ saved_did_emsg = did_emsg; diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2962,6 +2962,7 @@ do_ecmd(fnum, ffname, sfname, eap, newln int auto_buf = FALSE; /* TRUE if autocommands brought us into the buffer unexpectedly */ char_u *new_name = NULL; + int did_set_swapcommand = FALSE; #endif buf_T *buf; #if defined(FEAT_AUTOCMD) || defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) @@ -3082,6 +3083,32 @@ do_ecmd(fnum, ffname, sfname, eap, newln reset_VIsual(); #endif +#ifdef FEAT_AUTOCMD + if ((command != NULL || newlnum > (linenr_T)0) + && *get_vim_var_str(VV_SWAPCOMMAND) == NUL) + { + int len; + char_u *p; + + /* Set v:swapcommand for the SwapExists autocommands. */ + if (command != NULL) + len = STRLEN(command) + 3; + else + len = 30; + p = alloc((unsigned)len); + if (p != NULL) + { + if (command != NULL) + vim_snprintf((char *)p, len, ":%s\r", command); + else + vim_snprintf((char *)p, len, "%ldG", (long)newlnum); + set_vim_var_string(VV_SWAPCOMMAND, p, -1); + did_set_swapcommand = TRUE; + vim_free(p); + } + } +#endif + /* * If we are starting to edit another file, open a (new) buffer. * Otherwise we re-use the current buffer. @@ -3619,6 +3646,10 @@ do_ecmd(fnum, ffname, sfname, eap, newln #endif theend: +#ifdef FEAT_AUTOCMD + if (did_set_swapcommand) + set_vim_var_string(VV_SWAPCOMMAND, NULL, -1); +#endif #ifdef FEAT_BROWSE vim_free(browse_file); #endif diff --git a/src/ex_cmds.h b/src/ex_cmds.h --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -402,9 +402,9 @@ EX(CMD_global, "global", ex_global, EX(CMD_goto, "goto", ex_goto, RANGE|NOTADR|COUNT|TRLBAR|SBOXOK|CMDWIN), EX(CMD_grep, "grep", ex_make, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_grepadd, "grepadd", ex_make, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_gui, "gui", ex_gui, BANG|FILES|EDITCMD|ARGOPT|TRLBAR|CMDWIN), EX(CMD_gvim, "gvim", ex_gui, @@ -514,9 +514,9 @@ EX(CMD_lfirst, "lfirst", ex_cc, EX(CMD_lgetfile, "lgetfile", ex_cfile, TRLBAR|FILE1|BANG), EX(CMD_lgrep, "lgrep", ex_make, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_lgrepadd, "lgrepadd", ex_make, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_lhelpgrep, "lhelpgrep", ex_helpgrep, EXTRA|NOTRLCOM|NEEDARG), EX(CMD_ll, "ll", ex_cc, @@ -562,9 +562,9 @@ EX(CMD_ltag, "ltag", ex_tag, EX(CMD_lunmap, "lunmap", ex_unmap, EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN), EX(CMD_lvimgrep, "lvimgrep", ex_vimgrep, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_lvimgrepadd, "lvimgrepadd", ex_vimgrep, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_lwindow, "lwindow", ex_cwindow, RANGE|NOTADR|COUNT|TRLBAR), EX(CMD_ls, "ls", buflist_list, @@ -974,9 +974,9 @@ EX(CMD_visual, "visual", ex_edit, EX(CMD_view, "view", ex_edit, BANG|FILE1|EDITCMD|ARGOPT|TRLBAR), EX(CMD_vimgrep, "vimgrep", ex_vimgrep, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_vimgrepadd, "vimgrepadd", ex_vimgrep, - BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), + RANGE|NOTADR|BANG|NEEDARG|EXTRA|NOTRLCOM|TRLBAR|XFILE), EX(CMD_viusage, "viusage", ex_viusage, TRLBAR), EX(CMD_vmap, "vmap", ex_map, diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2612,9 +2612,10 @@ cmd_source(fname, eap) if (*fname == NUL) EMSG(_(e_argreq)); - /* ":source!" read vi commands */ else if (eap != NULL && eap->forceit) - /* Need to execute the commands directly when: + /* ":source!": read Normal mdoe commands + * Need to execute the commands directly. This is required at least + * for: * - ":g" command busy * - after ":argdo", ":windo" or ":bufdo" * - another command follows @@ -2768,6 +2769,10 @@ do_source(fname, check_other, is_vimrc) goto theend; } +#ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, FALSE, curbuf); +#endif + #if defined(WIN32) && defined(FEAT_CSCOPE) cookie.fp = fopen_noinh_readbin((char *)fname_exp); #else diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -103,6 +103,7 @@ static void set_expand_context __ARGS((e static int ExpandFromContext __ARGS((expand_T *xp, char_u *, int *, char_u ***, int)); static int expand_showtail __ARGS((expand_T *xp)); #ifdef FEAT_CMDL_COMPL +static int expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg)); static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname)); # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file)); @@ -4180,93 +4181,6 @@ ExpandFromContext(xp, pat, num_file, fil return ret; } - if (xp->xp_context == EXPAND_SHELLCMD) - { - /* - * Expand shell command. - */ - int i; - char_u *path; - int mustfree = FALSE; - garray_T ga; - char_u *buf = alloc(MAXPATHL); - int l; - char_u *s, *e; - - if (buf == NULL) - return FAIL; - - /* for ":set path=" and ":set tags=" halve backslashes for escaped - * space */ - pat = vim_strsave(pat); - for (i = 0; pat[i]; ++i) - if (pat[i] == '\\' && pat[i + 1] == ' ') - STRCPY(pat + i, pat + i + 1); - - flags |= EW_FILE | EW_EXEC; - /* For an absolute name we don't use $PATH. */ - if ((pat[0] == '.' && (vim_ispathsep(pat[1]) - || (pat[1] == '.' && vim_ispathsep(pat[2]))))) - path = (char_u *)"."; - else - path = vim_getenv((char_u *)"PATH", &mustfree); - - ga_init2(&ga, (int)sizeof(char *), 10); - for (s = path; *s != NUL; s = e) - { -#if defined(MSDOS) || defined(MSWIN) || defined(OS2) - e = vim_strchr(s, ';'); -#else - e = vim_strchr(s, ':'); -#endif - if (e == NULL) - e = s + STRLEN(s); - - l = e - s; - if (l > MAXPATHL - 5) - break; - vim_strncpy(buf, s, l); - add_pathsep(buf); - l = STRLEN(buf); - vim_strncpy(buf + l, pat, MAXPATHL - 1 - l); - - /* Expand matches in one directory of $PATH. */ - ret = expand_wildcards(1, &buf, num_file, file, flags); - if (ret == OK) - { - if (ga_grow(&ga, *num_file) == FAIL) - FreeWild(*num_file, *file); - else - { - for (i = 0; i < *num_file; ++i) - { - s = (*file)[i]; - if (STRLEN(s) > l) - { - /* Remove the path again. */ - mch_memmove(s, s + l, STRLEN(s + l) + 1); - ((char_u **)ga.ga_data)[ga.ga_len] = s; - ++ga.ga_len; - } - else - vim_free(s); - } - vim_free(*file); - } - } - if (*e != NUL) - ++e; - } - *file = ga.ga_data; - *num_file = ga.ga_len; - - vim_free(buf); - vim_free(pat); - if (mustfree) - vim_free(path); - return ret; - } - *file = (char_u **)""; *num_file = 0; if (xp->xp_context == EXPAND_HELP) @@ -4284,6 +4198,8 @@ ExpandFromContext(xp, pat, num_file, fil #ifndef FEAT_CMDL_COMPL return FAIL; #else + if (xp->xp_context == EXPAND_SHELLCMD) + return expand_shellcmd(pat, num_file, file, flags); if (xp->xp_context == EXPAND_OLD_SETTING) return ExpandOldSetting(num_file, file); if (xp->xp_context == EXPAND_BUFFERS) @@ -4457,6 +4373,107 @@ ExpandGeneric(xp, regmatch, num_file, fi return OK; } +/* + * Complete a shell command. + * Returns FAIL or OK; + */ + static int +expand_shellcmd(filepat, num_file, file, flagsarg) + char_u *filepat; /* pattern to match with command names */ + int *num_file; /* return: number of matches */ + char_u ***file; /* return: array with matches */ + int flagsarg; /* EW_ flags */ +{ + char_u *pat; + int i; + char_u *path; + int mustfree = FALSE; + garray_T ga; + char_u *buf = alloc(MAXPATHL); + size_t l; + char_u *s, *e; + int flags = flagsarg; + int ret; + + if (buf == NULL) + return FAIL; + + /* for ":set path=" and ":set tags=" halve backslashes for escaped + * space */ + pat = vim_strsave(filepat); + for (i = 0; pat[i]; ++i) + if (pat[i] == '\\' && pat[i + 1] == ' ') + STRCPY(pat + i, pat + i + 1); + + flags |= EW_FILE | EW_EXEC; + + /* For an absolute name we don't use $PATH. */ + if ((pat[0] == '.' && (vim_ispathsep(pat[1]) + || (pat[1] == '.' && vim_ispathsep(pat[2]))))) + path = (char_u *)"."; + else + path = vim_getenv((char_u *)"PATH", &mustfree); + + /* + * Go over all directories in $PATH. Expand matches in that directory and + * collect them in "ga". + */ + ga_init2(&ga, (int)sizeof(char *), 10); + for (s = path; *s != NUL; s = e) + { +#if defined(MSDOS) || defined(MSWIN) || defined(OS2) + e = vim_strchr(s, ';'); +#else + e = vim_strchr(s, ':'); +#endif + if (e == NULL) + e = s + STRLEN(s); + + l = e - s; + if (l > MAXPATHL - 5) + break; + vim_strncpy(buf, s, l); + add_pathsep(buf); + l = STRLEN(buf); + vim_strncpy(buf + l, pat, MAXPATHL - 1 - l); + + /* Expand matches in one directory of $PATH. */ + ret = expand_wildcards(1, &buf, num_file, file, flags); + if (ret == OK) + { + if (ga_grow(&ga, *num_file) == FAIL) + FreeWild(*num_file, *file); + else + { + for (i = 0; i < *num_file; ++i) + { + s = (*file)[i]; + if (STRLEN(s) > l) + { + /* Remove the path again. */ + mch_memmove(s, s + l, STRLEN(s + l) + 1); + ((char_u **)ga.ga_data)[ga.ga_len++] = s; + } + else + vim_free(s); + } + vim_free(*file); + } + } + if (*e != NUL) + ++e; + } + *file = ga.ga_data; + *num_file = ga.ga_len; + + vim_free(buf); + vim_free(pat); + if (mustfree) + vim_free(path); + return OK; +} + + # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) static void * call_user_expand_func __ARGS((void *(*user_expand_func) __ARGS((char_u *, int, char_u **, int)), expand_T *xp, int *num_file, char_u ***file)); diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -8938,6 +8938,7 @@ expand_backtick(gap, pat, flags) * Add a file to a file list. Accepted flags: * EW_DIR add directories * EW_FILE add files + * EW_EXEC add executable files * EW_NOTFOUND add even when it doesn't exist * EW_ADDSLASH add slash after directory name */ @@ -8964,6 +8965,10 @@ addfile(gap, f, flags) if ((isdir && !(flags & EW_DIR)) || (!isdir && !(flags & EW_FILE))) return; + /* If the file isn't executable, may not add it. Do accept directories. */ + if (!isdir && (flags & EW_EXEC) && !mch_can_exe(f)) + return; + /* Make room for another item in the file list. */ if (ga_grow(gap, 1) == FAIL) return; diff --git a/src/os_amiga.c b/src/os_amiga.c --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -810,7 +810,6 @@ mch_mkdir(name) UnLock(lock); } -#if defined(FEAT_EVAL) || defined(PROTO) /* * Return 1 if "name" can be executed, 0 if not. * Return -1 if unknown. @@ -822,7 +821,6 @@ mch_can_exe(name) /* TODO */ return -1; } -#endif /* * Check what "name" is: diff --git a/src/os_msdos.c b/src/os_msdos.c --- a/src/os_msdos.c +++ b/src/os_msdos.c @@ -2938,7 +2938,6 @@ mch_isdir(char_u *name) return TRUE; } -#if defined(FEAT_EVAL) || defined(PROTO) /* * Return 1 if "name" can be executed, 0 if not. * Return -1 if unknown. @@ -2954,7 +2953,6 @@ mch_can_exe(name) return FALSE; return TRUE; } -#endif /* * Check what "name" is: diff --git a/src/popupmenu.c b/src/popupmenu.c --- a/src/popupmenu.c +++ b/src/popupmenu.c @@ -40,7 +40,8 @@ static int pum_col; /* left column of pum_display(array, size, selected, row, height, col) pumitem_T *array; int size; - int selected; /* index of initially selected item */ + int selected; /* index of initially selected item, none if + out of range */ int row; int height; int col; @@ -256,7 +257,7 @@ pum_get_selected() /* * Set the index of the currently selected item. The menu will scroll when - * necessary. + * necessary. When "n" is out of range don't scroll. */ void pum_set_selected(n) @@ -264,7 +265,7 @@ pum_set_selected(n) { pum_selected = n; - if (pum_selected >= 0) + if (pum_selected >= 0 && pum_selected < pum_size) { if (pum_first > pum_selected - 4) { diff --git a/src/quickfix.c b/src/quickfix.c --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2905,6 +2905,7 @@ ex_vimgrep(eap) char_u *au_name = NULL; int flags = 0; colnr_T col; + long tomatch; switch (eap->cmdidx) { @@ -2933,6 +2934,11 @@ ex_vimgrep(eap) return; } + if (eap->addr_count > 0) + tomatch = eap->line2; + else + tomatch = MAXLNUM; + /* Get the search pattern: either white-separated or enclosed in // */ regmatch.regprog = NULL; p = skip_vimgrep_pat(eap->arg, &s, &flags); @@ -2975,7 +2981,7 @@ ex_vimgrep(eap) } seconds = (time_t)0; - for (fi = 0; fi < fcount && !got_int; ++fi) + for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi) { if (time(NULL) > seconds) { @@ -3035,7 +3041,8 @@ ex_vimgrep(eap) { found_match = FALSE; /* Try for a match in all lines of the buffer. */ - for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum) + for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; + ++lnum) { /* For ":1vimgrep" look for multiple matches. */ col = 0; @@ -3059,8 +3066,9 @@ ex_vimgrep(eap) got_int = TRUE; break; } - else - found_match = TRUE; + found_match = TRUE; + if (--tomatch == 0) + break; if ((flags & VGR_GLOBAL) == 0 || regmatch.endpos[0].lnum > 0) break; 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 (2006 Mar 6)" -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 6, compiled " +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 7)" +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2006 Mar 7, compiled "