Skip to content

Commit b6f08f7

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 486020e + 9cdf86b commit b6f08f7

12 files changed

Lines changed: 399 additions & 16 deletions

File tree

runtime/doc/eval.txt

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 12
1+
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 13
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -764,13 +764,23 @@ expressions are referring to the same |List| or |Dictionary| instance. A copy
764764
of a |List| is different from the original |List|. When using "is" without
765765
a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot"
766766
equivalent to using "not equal". Except that a different type means the
767-
values are different: "4 == '4'" is true, "4 is '4'" is false and "0 is []" is
768-
false and not an error. "is#"/"isnot#" and "is?"/"isnot?" can be used to match
769-
and ignore case.
767+
values are different: >
768+
echo 4 == '4'
769+
1
770+
echo 4 is '4'
771+
0
772+
echo 0 is []
773+
0
774+
"is#"/"isnot#" and "is?"/"isnot?" can be used to match and ignore case.
770775

771776
When comparing a String with a Number, the String is converted to a Number,
772-
and the comparison is done on Numbers. This means that "0 == 'x'" is TRUE,
773-
because 'x' converted to a Number is zero.
777+
and the comparison is done on Numbers. This means that: >
778+
echo 0 == 'x'
779+
1
780+
because 'x' converted to a Number is zero. However: >
781+
echo [0] == ['x']
782+
0
783+
Inside a List or Dictionary this conversion is not used.
774784

775785
When comparing two Strings, this is done with strcmp() or stricmp(). This
776786
results in the mathematical difference (comparing byte values), not
@@ -2139,6 +2149,11 @@ values( {dict}) List values in {dict}
21392149
virtcol( {expr}) Number screen column of cursor or mark
21402150
visualmode( [expr]) String last visual mode used
21412151
wildmenumode() Number whether 'wildmenu' mode is active
2152+
win_findbuf( {bufnr}) List find windows containing {bufnr}
2153+
win_getid( [{win} [, {tab}]]) Number get window ID for {win} in {tab}
2154+
win_gotoid( {expr}) Number go to window with ID {expr}
2155+
win_id2tabwin( {expr}) List get tab and window nr from window ID
2156+
win_id2win( {expr}) Number get window nr from window ID
21422157
winbufnr( {nr}) Number buffer number of window {nr}
21432158
wincol() Number window column of the cursor
21442159
winheight( {nr}) Number height of window {nr}
@@ -7162,6 +7177,33 @@ wildmenumode() *wildmenumode()*
71627177
(Note, this needs the 'wildcharm' option set appropriately).
71637178

71647179

7180+
win_findbuf({bufnr}) *win_findbuf()*
7181+
Returns a list with window IDs for windows that contain buffer
7182+
{bufnr}. When there is none the list is empty.
7183+
7184+
win_getid([{win} [, {tab}]]) *win_getid()*
7185+
Get the window ID for the specified window.
7186+
When {win} is missing use the current window.
7187+
With {win} this is the window number. The top window has
7188+
number 1.
7189+
Without {tab} use the current tab, otherwise the tab with
7190+
number {tab}. The first tab has number one.
7191+
Return zero if the window cannot be found.
7192+
7193+
win_gotoid({expr}) *win_gotoid()*
7194+
Go to window with ID {expr}. This may also change the current
7195+
tabpage.
7196+
Return 1 if successful, 0 if the window cannot be found.
7197+
7198+
win_id2tabwin({expr} *win_id2tabwin()*
7199+
Return a list with the tab number and window number of window
7200+
with ID {expr}: [tabnr, winnr].
7201+
Return [0, 0] if the window cannot be found.
7202+
7203+
win_id2win({expr}) *win_id2win()*
7204+
Return the window number of window with ID {expr}.
7205+
Return 0 if the window cannot be found in the current tabpage.
7206+
71657207
*winbufnr()*
71667208
winbufnr({nr}) The result is a Number, which is the number of the buffer
71677209
associated with window {nr}. When {nr} is zero, the number of

src/Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ CClink = $(CC)
424424
# NOTE: This may cause threading to be enabled, which has side effects (such
425425
# as using different libraries and debugging becomes more difficult).
426426
# NOTE: Using this together with Perl may cause a crash in initialization.
427-
# For Python3 support make a symbolic link in /usr/local/bin:
427+
# For Python3 support make a symbolic link in /usr/local/bin:
428428
# ln -s python3 python3.1
429429
# If both python2.x and python3.x are enabled then the linking will be via
430430
# dlopen(), dlsym(), dlclose(), i.e. pythonX.Y.so must be available
@@ -2014,30 +2014,38 @@ test1 \
20142014
# Run individual NEW style test, assuming that Vim was already compiled.
20152015
test_arglist \
20162016
test_assert \
2017+
test_assign \
20172018
test_backspace_opt \
20182019
test_cdo \
20192020
test_channel \
20202021
test_cursor_func \
20212022
test_delete \
20222023
test_expand \
2024+
test_feedkeys \
2025+
test_file_perm \
20232026
test_glob2regpat \
20242027
test_hardcopy \
2028+
test_history \
20252029
test_increment \
2030+
test_join \
20262031
test_json \
20272032
test_langmap \
20282033
test_lispwords \
20292034
test_menu \
2035+
test_packadd \
20302036
test_perl \
20312037
test_quickfix \
20322038
test_reltime \
20332039
test_searchpos \
20342040
test_set \
20352041
test_sort \
2042+
test_syn_attr \
20362043
test_syntax \
20372044
test_undolevels \
20382045
test_unlet \
20392046
test_viminfo \
20402047
test_viml \
2048+
test_visual \
20412049
test_alot:
20422050
cd testdir; rm -f [email protected] test.log messages; $(MAKE) -f Makefile [email protected] VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
20432051
@if test -f testdir/test.log; then \
@@ -2121,6 +2129,9 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
21212129
-$(SHELL) ./installman.sh install $(DEST_MAN) "" $(INSTALLMANARGS)
21222130
@echo generating help tags
21232131
# Generate the help tags with ":helptags" to handle all languages.
2132+
# Move the distributed tags file aside and restore it, to avoid it being
2133+
# different from the repository.
2134+
cd $(HELPSOURCE); mv -f tags tags.dist
21242135
-@cd $(HELPSOURCE); $(MAKE) VIMEXE=$(DEST_BIN)/$(VIMTARGET) vimtags
21252136
cd $(HELPSOURCE); \
21262137
files=`ls *.txt tags`; \
@@ -2130,6 +2141,7 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
21302141
chmod $(HELPMOD) $$files
21312142
$(INSTALL_DATA) $(HELPSOURCE)/*.pl $(DEST_HELP)
21322143
chmod $(SCRIPTMOD) $(DEST_HELP)/*.pl
2144+
cd $(HELPSOURCE); mv -f tags.dist tags
21332145
# install the menu files
21342146
$(INSTALL_DATA) $(SCRIPTSOURCE)/menu.vim $(SYS_MENU_FILE)
21352147
chmod $(VIMSCRIPTMOD) $(SYS_MENU_FILE)

src/eval.c

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ static int dict_equal(dict_T *d1, dict_T *d2, int ic, int recursive);
434434
static int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
435435
static long list_find_nr(list_T *l, long idx, int *errorp);
436436
static long list_idx_of_item(list_T *l, listitem_T *item);
437-
static int list_append_number(list_T *l, varnumber_T n);
438437
static int list_extend(list_T *l1, list_T *l2, listitem_T *bef);
439438
static int list_concat(list_T *l1, list_T *l2, typval_T *tv);
440439
static list_T *list_copy(list_T *orig, int deep, int copyID);
@@ -808,6 +807,11 @@ static void f_values(typval_T *argvars, typval_T *rettv);
808807
static void f_virtcol(typval_T *argvars, typval_T *rettv);
809808
static void f_visualmode(typval_T *argvars, typval_T *rettv);
810809
static void f_wildmenumode(typval_T *argvars, typval_T *rettv);
810+
static void f_win_findbuf(typval_T *argvars, typval_T *rettv);
811+
static void f_win_getid(typval_T *argvars, typval_T *rettv);
812+
static void f_win_gotoid(typval_T *argvars, typval_T *rettv);
813+
static void f_win_id2tabwin(typval_T *argvars, typval_T *rettv);
814+
static void f_win_id2win(typval_T *argvars, typval_T *rettv);
811815
static void f_winbufnr(typval_T *argvars, typval_T *rettv);
812816
static void f_wincol(typval_T *argvars, typval_T *rettv);
813817
static void f_winheight(typval_T *argvars, typval_T *rettv);
@@ -6469,7 +6473,7 @@ list_append_string(list_T *l, char_u *str, int len)
64696473
* Append "n" to list "l".
64706474
* Returns FAIL when out of memory.
64716475
*/
6472-
static int
6476+
int
64736477
list_append_number(list_T *l, varnumber_T n)
64746478
{
64756479
listitem_T *li;
@@ -8385,6 +8389,11 @@ static struct fst
83858389
{"virtcol", 1, 1, f_virtcol},
83868390
{"visualmode", 0, 1, f_visualmode},
83878391
{"wildmenumode", 0, 0, f_wildmenumode},
8392+
{"win_findbuf", 1, 1, f_win_findbuf},
8393+
{"win_getid", 0, 2, f_win_getid},
8394+
{"win_gotoid", 1, 1, f_win_gotoid},
8395+
{"win_id2tabwin", 1, 1, f_win_id2tabwin},
8396+
{"win_id2win", 1, 1, f_win_id2win},
83888397
{"winbufnr", 1, 1, f_winbufnr},
83898398
{"wincol", 0, 0, f_wincol},
83908399
{"winheight", 1, 1, f_winheight},
@@ -12668,6 +12677,53 @@ f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
1266812677
#endif
1266912678
}
1267012679

12680+
/*
12681+
* "win_findbuf()" function
12682+
*/
12683+
static void
12684+
f_win_findbuf(typval_T *argvars, typval_T *rettv)
12685+
{
12686+
if (rettv_list_alloc(rettv) != FAIL)
12687+
win_findbuf(argvars, rettv->vval.v_list);
12688+
}
12689+
12690+
/*
12691+
* "win_getid()" function
12692+
*/
12693+
static void
12694+
f_win_getid(typval_T *argvars, typval_T *rettv)
12695+
{
12696+
rettv->vval.v_number = win_getid(argvars);
12697+
}
12698+
12699+
/*
12700+
* "win_gotoid()" function
12701+
*/
12702+
static void
12703+
f_win_gotoid(typval_T *argvars, typval_T *rettv)
12704+
{
12705+
rettv->vval.v_number = win_gotoid(argvars);
12706+
}
12707+
12708+
/*
12709+
* "win_id2tabwin()" function
12710+
*/
12711+
static void
12712+
f_win_id2tabwin(typval_T *argvars, typval_T *rettv)
12713+
{
12714+
if (rettv_list_alloc(rettv) != FAIL)
12715+
win_id2tabwin(argvars, rettv->vval.v_list);
12716+
}
12717+
12718+
/*
12719+
* "win_id2win()" function
12720+
*/
12721+
static void
12722+
f_win_id2win(typval_T *argvars, typval_T *rettv)
12723+
{
12724+
rettv->vval.v_number = win_id2win(argvars);
12725+
}
12726+
1267112727
/*
1267212728
* "getwinposy()" function
1267312729
*/

src/ex_getln.c

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int ExpandFromContext(expand_T *xp, char_u *, int *, char_u ***, int);
111111
static int expand_showtail(expand_T *xp);
112112
#ifdef FEAT_CMDL_COMPL
113113
static int expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, int flagsarg);
114-
static int ExpandRTDir(char_u *pat, int *num_file, char_u ***file, char *dirname[]);
114+
static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, char *dirname[]);
115115
static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file);
116116
# ifdef FEAT_CMDHIST
117117
static char_u *get_history_arg(expand_T *xp, int idx);
@@ -4639,22 +4639,23 @@ ExpandFromContext(
46394639
if (xp->xp_context == EXPAND_COLORS)
46404640
{
46414641
char *directories[] = {"colors", NULL};
4642-
return ExpandRTDir(pat, num_file, file, directories);
4642+
return ExpandRTDir(pat, DIP_START + DIP_OPT, num_file, file,
4643+
directories);
46434644
}
46444645
if (xp->xp_context == EXPAND_COMPILER)
46454646
{
46464647
char *directories[] = {"compiler", NULL};
4647-
return ExpandRTDir(pat, num_file, file, directories);
4648+
return ExpandRTDir(pat, 0, num_file, file, directories);
46484649
}
46494650
if (xp->xp_context == EXPAND_OWNSYNTAX)
46504651
{
46514652
char *directories[] = {"syntax", NULL};
4652-
return ExpandRTDir(pat, num_file, file, directories);
4653+
return ExpandRTDir(pat, 0, num_file, file, directories);
46534654
}
46544655
if (xp->xp_context == EXPAND_FILETYPE)
46554656
{
46564657
char *directories[] = {"syntax", "indent", "ftplugin", NULL};
4657-
return ExpandRTDir(pat, num_file, file, directories);
4658+
return ExpandRTDir(pat, 0, num_file, file, directories);
46584659
}
46594660
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
46604661
if (xp->xp_context == EXPAND_USER_LIST)
@@ -5133,13 +5134,19 @@ ExpandUserList(
51335134
#endif
51345135

51355136
/*
5136-
* Expand color scheme, compiler or filetype names:
5137-
* 'runtimepath'/{dirnames}/{pat}.vim
5137+
* Expand color scheme, compiler or filetype names.
5138+
* Search from 'runtimepath':
5139+
* 'runtimepath'/{dirnames}/{pat}.vim
5140+
* When "flags" has DIP_START: search also from 'start' of 'packpath':
5141+
* 'packpath'/pack/ * /start/ * /{dirnames}/{pat}.vim
5142+
* When "flags" has DIP_OPT: search also from 'opt' of 'packpath':
5143+
* 'packpath'/pack/ * /opt/ * /{dirnames}/{pat}.vim
51385144
* "dirnames" is an array with one or more directory names.
51395145
*/
51405146
static int
51415147
ExpandRTDir(
51425148
char_u *pat,
5149+
int flags,
51435150
int *num_file,
51445151
char_u ***file,
51455152
char *dirnames[])
@@ -5169,6 +5176,36 @@ ExpandRTDir(
51695176
vim_free(s);
51705177
}
51715178

5179+
if (flags & DIP_START) {
5180+
for (i = 0; dirnames[i] != NULL; ++i)
5181+
{
5182+
s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 22));
5183+
if (s == NULL)
5184+
{
5185+
ga_clear_strings(&ga);
5186+
return FAIL;
5187+
}
5188+
sprintf((char *)s, "pack/*/start/*/%s/%s*.vim", dirnames[i], pat);
5189+
globpath(p_pp, s, &ga, 0);
5190+
vim_free(s);
5191+
}
5192+
}
5193+
5194+
if (flags & DIP_OPT) {
5195+
for (i = 0; dirnames[i] != NULL; ++i)
5196+
{
5197+
s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 20));
5198+
if (s == NULL)
5199+
{
5200+
ga_clear_strings(&ga);
5201+
return FAIL;
5202+
}
5203+
sprintf((char *)s, "pack/*/opt/*/%s/%s*.vim", dirnames[i], pat);
5204+
globpath(p_pp, s, &ga, 0);
5205+
vim_free(s);
5206+
}
5207+
}
5208+
51725209
for (i = 0; i < ga.ga_len; ++i)
51735210
{
51745211
match = ((char_u **)ga.ga_data)[i];

src/proto/eval.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void list_append(list_T *l, listitem_T *item);
5959
int list_append_tv(list_T *l, typval_T *tv);
6060
int list_append_dict(list_T *list, dict_T *dict);
6161
int list_append_string(list_T *l, char_u *str, int len);
62+
int list_append_number(list_T *l, varnumber_T n);
6263
int list_insert_tv(list_T *l, typval_T *tv, listitem_T *item);
6364
void list_insert(list_T *l, listitem_T *ni, listitem_T *item);
6465
void vimlist_remove(list_T *l, listitem_T *item, listitem_T *item2);

src/proto/window.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ void clear_matches(win_T *wp);
8383
matchitem_T *get_match(win_T *wp, int id);
8484
int get_win_number(win_T *wp, win_T *first_win);
8585
int get_tab_number(tabpage_T *tp);
86+
int win_getid(typval_T *argvars);
87+
int win_gotoid(typval_T *argvars);
88+
void win_id2tabwin(typval_T *argvars, list_T *list);
89+
int win_id2win(typval_T *argvars);
90+
void win_findbuf(typval_T *argvars, list_T *list);
8691
/* vim: set ft=c : */

src/structs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,8 @@ struct matchitem
22852285
*/
22862286
struct window_S
22872287
{
2288+
int w_id; /* unique window ID */
2289+
22882290
buf_T *w_buffer; /* buffer we are a window into (used
22892291
often, keep it the first item!) */
22902292

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ NEW_TESTS = test_arglist.res \
186186
test_viminfo.res \
187187
test_viml.res \
188188
test_visual.res \
189+
test_window_id.res \
189190
test_alot.res
190191

191192

0 commit comments

Comments
 (0)