# HG changeset patch # User vimboss # Date 1106837071 0 # Node ID 0ef5b70c3eaf694c9e9b85aed3f80af53e6fd9cf # Parent 88256bf8571c76c9a035c8904cbe81413988a701 updated for version 7.0045 diff --git a/runtime/doc/pi_expl.txt b/runtime/doc/pi_expl.txt deleted file mode 100644 --- a/runtime/doc/pi_expl.txt +++ /dev/null @@ -1,215 +0,0 @@ -*pi_expl.txt* For Vim version 7.0aa. Last change: 2004 Dec 29 - - - VIM REFERENCE MANUAL by M A Aziz Ahmed - updated by Mark Waggoner - - - *file-explorer* *file-browser* -Plugin for exploring (or browsing) directories and files - -1. Starting the file explorer |expl-starting| - -The functionality mentioned here is a |standard-plugin|. -This plugin is only available if 'compatible' is not set. -You can avoid loading this plugin by setting the "loaded_explorer" variable: > - :let loaded_explorer = 1 - -{Vi does not have any of this} - -============================================================================== -1. Starting the file explorer *expl-starting* - -This plugin is used to explore directories inside Vim. The file explorer is -launched whenever the user tries to edit a directory. - *:Explore* *:Sexplore* -To launch the explorer in the directory of the file currently edited: > - :Explore -If the file has changes the window is split. To always split the window: > - :Sexplore -To launch the explorer in a specific directory: > - :Explore dirname - :Sexplore dirname - -From inside the explorer move your cursor to a line containing a file or -directory name. The following command keys are available: - - will open the file in the window the explorer is currently - occupying. - 'o' will split a new window and open the file in the new window. - 'O' will open the file chosen using the window that the cursor was in just - before you started or entered the explorer window. If the explorer is - the only window, it will first split a new window to use for the file to - be opened. - 'p' will open (or use) the preview window showing the file - 'x' will execute the file with the system tools. Only when supported - (currently MS-Windows and KDE). - -When splitting off a new window, you can control where the split window will -go relative to the explorer window using the variables g:explVertical, -g:explSplitBelow and g:explSplitRight. - - *g:explVertical* - *g:explSplitBelow* - *g:explSplitRight* - *g:explStartBelow* - *g:explStartRight* -To control whether the split is made horizontally or vertically, use: > - let g:explVertical=1 " Split vertically - let g:explVertical=0 " Split horizontally (default) - -To control where the window goes relative to the explorer window when -splitting horizontally, use the variable: > - let g:explSplitBelow=1 " Put new window below explorer window - let g:explSplitBelow=0 " Put new window above explorer window -The default for this is the setting of splitbelow at the time the plugin is -loaded. - -To control where the window goes relative to the explorer window when -splitting vertically, use the variable: > - let g:explSplitRight=1 " Put new window to the right of the explorer - let g:explSplitRight=0 " Put new window to the left of the explorer -The default for this is the setting of splitright at the time the plugin is -loaded. - -To use a different split method for the explorer window, use: > - let g:explStartRight=1 " Put new explorer window to the right of the - " current window - let g:explStartRight=0 " Put new explorer window to the left of the - " current window -The default is the value of g:explSplitRight at the time the plugin is loaded. - -To use a different split method for the explorer window, use: > - let g:explStartBelow=1 " Put new explorer window below the - " current window - let g:explStartBelow=0 " Put new explorer window above the - " current window -The default is the value of g:explSplitBelow at the time the plugin is loaded. - -The start splits allow for the explorer window to be placed in a file browser -type arrangement, where the directories are shown on the left and the contents -opened on the right. The start split settings are only used when issuing -the Sexplore command. - -Note that the window split is done a little bit differently than window splits -are usually done. Ordinarily, when splitting a window, the space occupied by -the current window will be split to give space for the new window. The -explorer attempts to instead split from a window adjacent to the explorer -window so that the explorer window will not change sizes. If there is not an -adjacent window in the direction you are splitting, the explorer window is -split. - - *g:explWinSize* -After opening a file with the 'o' command, you might want to resize the -explorer window. This can be done by setting the variable > - let g:explWinSize=N -N is the number of rows (when the window is split horizontally) or the number -of columns (when the window is split vertically). If g:explWinSize is set to -an empty string (""), resizing will not be done. g:explWinSize defaults to -15. - - *g:explDetailedList* -The file size (in bytes) and modification time can be displayed inside the -file explorer window. By pressing 'i', you can toggle between the name only -display and the more lengthy display. If you want the size and date to show -by default, use > - let g:explDetailedList=1 -Doing this may slightly slow down explorer. The difference may or may not be -noticeable depending on your system and whether the directory is local or on -the network and on the size of the directory. - - *g:explDateFormat* -The format of date displayed is configurable using the variable -g:explDateFormat. explorer uses this variable to pass to strftime() to fetch -the date information. |strftime()| The default is > - let g:explDateFormat="%d %b %Y %H:%M" - -Note that for sorting purposes, the date is always placed at the end of the -line in its 'raw' form. If you have syntax highlighting turned on, this raw -date should be invisible. - - *g:explHideFiles* -You can hide some files by filling the variable g:explHidFiles with regular -expressions. A filename that matches any of these regular expressions will not -be shown. For example, > - - let g:explHideFiles='^\.,\.gz$,\.exe$,\.zip$' - -will not show files that begin with "." and those that end in .gz, .exe or -.zip. However, all directory names will always be shown. If while exploring, -you'd like to see the hidden files as well, use the command "a". -The explorer header will indicate if filtering is being done. - - *g:explDetailedHelp* -The help information spanning a few lines can be turned off (and just a single -help message enabled) using the option > - let g:explDetailedHelp=0 -You can anytime switch to the detailed help format by pressing ?. - - *explorer-delete* -Pressing 'D' inside explorer deletes the file under the cursor. You can delete -many files by visually selecting them and using 'D'. The deletion is -interactive in the form y/n/a/q. Directory deletion is not supported (mainly -because there is no way to delete a directory using a vim built-in function). - - *explorer-rename* -Pressing 'R' inside explorer will allow you to rename the file under the -cursor. - - *g:explSortBy* -The display in the file explorer can be sorted in forward or reverse order by -name, size, or modification date. You can set the default sorting direction -with the option > - let g:explSortBy='name' " alphabetically - let g:explSortBy='reverse name' " reverse alphabetically - let g:explSortBy='date' " newest first - let g:explSortBy='reverse date' " oldest first - let g:explSortBy='size' " largest first - let g:explSortBy='reverse size' " smallest first -While in the explorer, you can rotate through the sort fields by pressing the -'s' key and you can reverse the current sort order by pressing the 'r' key. -Sorting on fields other than the name will be faster if the size and date are -displayed (using 'i' or g:explDetailedList). -The explorer heading will indicate the current sort order. - - *g:explDirsFirst* -To control the segregation of directories and files, you can set this option > - let g:explDirsFirst=1 " Directories at the top of the list (default) - let g:explDirsFirst=0 " Directories mixed in with files - let g:explDirsFirst=-1 " Directories at the bottom of the list - - *g:explSuffixesLast* -To control the segregation of files matching the suffixes option, you can set -this option > - let g:explSuffixesLast=1 " Files matching suffixes sorted at the bottom - " of the list (default) - let g:explSuffixesLast=0 " Files matching suffixes sorted normally - let g:explSuffixesLast=-1 " Files matching suffixes sorted at the top of - " the list -The heading will indicate if suffixes have been moved to the end (or start) of -the list. - - *g:explUseSeparators* -Directories and files matching the suffixes list will be highlighted. If you -have the directories, files, and suffixes separated, and you would like a -separator line between the groups, you can set the option > - let g:explUseSeparators=1 " Use separator lines - let g:explUseSeparators=0 " Don't use separator lines -< - *g:explFileHandler* -If you set the "g:explFileHandler" variable to the name of a function, typing -'x' will call this function. The file or directory under the cursor will be -passed as an argument to the function. Suppose you have KDE, you could use -this: > - - function MyFileHandler(fn) - exec "silent! !kfmclient exec " . escape(a:fn,' \%#') - endfunction - let g:explFileHandler = 'MyFileHandler' - -For Win32 the variable is set by default to invoke the execute action. If you -type 'x' on a HTML file, Microsoft Internet Explorer will start (or whatever -application you have associated with HTML files). - -============================================================================== - vim:tw=78:noet:ts=8:ft=help:norl: diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -116,6 +116,12 @@ static dictitem_T globvars_var; #define globvarht globvardict.dv_hashtab /* + * Old Vim variables such as "v:version" are also available without the "v:". + * Also in functions. We need a special hashtable for them. + */ +hashtab_T compat_hashtab; + +/* * Array to hold the hashtab with variables local to each sourced script. * Each item holds a variable (nameless) that points to the dict_T. */ @@ -213,7 +219,7 @@ typedef struct typedef struct { dict_T *fd_dict; /* Dictionary used */ - char_u *fd_newkey; /* new key in "dict" */ + char_u *fd_newkey; /* new key in "dict" in allocated memory */ dictitem_T *fd_di; /* Dictionary item used */ } funcdict_T; @@ -599,6 +605,7 @@ eval_init() init_var_dict(&globvardict, &globvars_var); init_var_dict(&vimvardict, &vimvars_var); + hash_init(&compat_hashtab); for (i = 0; i < VV_LEN; ++i) { @@ -613,8 +620,8 @@ eval_init() /* add to v: scope dict */ hash_add(&vimvarht, p->vv_di.di_key); if (p->vv_flags & VV_COMPAT) - /* add to g: scope dict */ - hash_add(&globvardict.dv_hashtab, p->vv_di.di_key); + /* add to compat scope dict */ + hash_add(&compat_hashtab, p->vv_di.di_key); } } @@ -2548,7 +2555,9 @@ ex_call(eap) len = STRLEN(tofree); name = deref_func_name(tofree, &len); - startarg = arg; + /* Skip white space to allow ":call func ()". Not good, but required for + * backward compatibility. */ + startarg = skipwhite(arg); rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */ if (*startarg != '(') @@ -2815,12 +2824,12 @@ get_user_var_name(xp, idx) expand_T *xp; int idx; { - static int gdone; - static int bdone; - static int wdone; - static int vidx; - static hashitem_T *hi; - hashtab_T *ht; + static long_u gdone; + static long_u bdone; + static long_u wdone; + static int vidx; + static hashitem_T *hi; + hashtab_T *ht; if (idx == 0) gdone = bdone = wdone = vidx = 0; @@ -2830,6 +2839,8 @@ get_user_var_name(xp, idx) { if (gdone++ == 0) hi = globvarht.ht_array; + else + ++hi; while (HASHITEM_EMPTY(hi)) ++hi; if (STRNCMP("g:", xp->xp_pattern, 2) == 0) @@ -2843,6 +2854,8 @@ get_user_var_name(xp, idx) { if (bdone++ == 0) hi = ht->ht_array; + else + ++hi; while (HASHITEM_EMPTY(hi)) ++hi; return cat_prefix_varname('b', hi->hi_key); @@ -2859,6 +2872,8 @@ get_user_var_name(xp, idx) { if (bdone++ == 0) hi = ht->ht_array; + else + ++hi; while (HASHITEM_EMPTY(hi)) ++hi; return cat_prefix_varname('w', hi->hi_key); @@ -5717,7 +5732,7 @@ static struct fst {"string", 1, 1, f_string}, {"strlen", 1, 1, f_strlen}, {"strpart", 2, 3, f_strpart}, - {"strridx", 2, 2, f_strridx}, + {"strridx", 2, 3, f_strridx}, {"strtrans", 1, 1, f_strtrans}, {"submatch", 1, 1, f_submatch}, {"substitute", 4, 4, f_substitute}, @@ -11791,9 +11806,10 @@ f_stridx(argvars, rettv) if (argvars[2].v_type != VAR_UNKNOWN) { start_idx = get_tv_number(&argvars[2]); - if (start_idx < 0 || start_idx >= (int)STRLEN(haystack)) + if (start_idx >= (int)STRLEN(haystack)) return; - haystack += start_idx; + if (start_idx >= 0) + haystack += start_idx; } pos = (char_u *)strstr((char *)haystack, (char *)needle); @@ -11885,20 +11901,38 @@ f_strridx(argvars, rettv) char_u *haystack; char_u *rest; char_u *lastmatch = NULL; + int haystack_len, end_idx; needle = get_tv_string(&argvars[1]); haystack = get_tv_string_buf(&argvars[0], buf); + haystack_len = STRLEN(haystack); if (*needle == NUL) /* Empty string matches past the end. */ - lastmatch = haystack + STRLEN(haystack); - else + lastmatch = haystack + haystack_len; + else + { + if (argvars[2].v_type != VAR_UNKNOWN) + { + /* Third argument: upper limit for index */ + end_idx = get_tv_number(&argvars[2]); + if (end_idx < 0) + { + /* can never find a match */ + rettv->vval.v_number = -1; + return; + } + } + else + end_idx = haystack_len; + for (rest = haystack; *rest != '\0'; ++rest) { rest = (char_u *)strstr((char *)rest, (char *)needle); - if (rest == NULL) + if (rest == NULL || rest > haystack + end_idx) break; lastmatch = rest; } + } if (lastmatch == NULL) rettv->vval.v_number = -1; @@ -13408,6 +13442,11 @@ find_var_ht(name, varname) if (vim_strchr(name, ':') != NULL) return NULL; *varname = name; + + /* "version" is "v:version" in all scopes */ + if (!HASHITEM_EMPTY(hash_find(&compat_hashtab, name))) + return &compat_hashtab; + if (current_funccal == NULL) return &globvarht; /* global variable */ return ¤t_funccal->l_vars.dv_hashtab; /* l: variable */