On 22:24 Sun 14 Dec , Marcin Szamotulski wrote: > On 03:19 Sun 14 Dec , Bram Moolenaar wrote: > > > > Marcin Szamotulski wrote: > > > > > I also include another patch (on top of that) which adds support for > > > counts in :argdo, :bufdo, :tabdo and :windo commands. > > > > I haven't included this part yet. Can you please add some tests for > > using a range (and for no range, if that doesn't exist yet) for these > > four commands? > > Sure I will add some tests soon. > > Regards, > Marcin
Here is an updated patch which includes tests. Best regards, Marcin -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index 71f2f8c..82a7d02 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -832,8 +832,9 @@ current window. The two windows then share this list, until one of them uses
USING THE ARGUMENT LIST
*:argdo*
-:argdo[!] {cmd} Execute {cmd} for each file in the argument list.
- It works like doing this: >
+:[range]argdo[!] {cmd} Execute {cmd} for each file in the argument list or
+ if [range] is specified only for arguments in that
+ range. It works like doing this: >
:rewind
:{cmd}
:next
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index 47e1a4b..aded300 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -224,8 +224,10 @@ clarification what +N means in this context see |[range]|.
LOOPING OVER TAB PAGES:
*:tabd* *:tabdo*
-:tabd[o] {cmd} Execute {cmd} in each tab page.
- It works like doing this: >
+:[range]tabd[o] {cmd}
+ Execute {cmd} in each tab page or if [range] is given only in
+ tab pages which tab page number is in the [range]. It works
+ like doing this: >
:tabfirst
:{cmd}
:tabnext
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index 67925b8..532cca3 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -698,8 +698,9 @@ can also get to them with the buffer list commands, like ":bnext".
8. Do a command in all buffers or windows *list-repeat*
*:windo*
-:windo {cmd} Execute {cmd} in each window.
- It works like doing this: >
+:[range]windo {cmd} Execute {cmd} in each window or if [range] is given
+ only in windows for which the window number lies in
+ the [range]. It works like doing this: >
CTRL-W t
:{cmd}
CTRL-W w
@@ -717,8 +718,10 @@ can also get to them with the buffer list commands, like ":bnext".
Also see |:tabdo|, |:argdo| and |:bufdo|.
*:bufdo*
-:bufdo[!] {cmd} Execute {cmd} in each buffer in the buffer list.
- It works like doing this: >
+:[range]bufdo[!] {cmd} Execute {cmd} in each buffer in the buffer list or if
+ [range] is given only for buffers for which their
+ buffer numer is in the [range]. It works like doing
+ this: >
:bfirst
:{cmd}
:bnext
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 95a2289..31b0da9 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -133,8 +133,8 @@ EX(CMD_argdelete, "argdelete", ex_argdelete,
BANG|RANGE|NOTADR|FILES|TRLBAR,
ADDR_ARGUMENTS),
EX(CMD_argdo, "argdo", ex_listdo,
- BANG|NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_ARGUMENTS),
EX(CMD_argedit, "argedit", ex_argedit,
BANG|NEEDARG|RANGE|NOTADR|FILE1|EDITCMD|ARGOPT|TRLBAR,
ADDR_ARGUMENTS),
@@ -220,8 +220,8 @@ EX(CMD_buffers, "buffers", buflist_list,
BANG|TRLBAR|CMDWIN,
ADDR_LINES),
EX(CMD_bufdo, "bufdo", ex_listdo,
- BANG|NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_UNLOADED_BUFFERS),
EX(CMD_bunload, "bunload", ex_bunload,
BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
ADDR_LOADED_BUFFERS),
@@ -1384,8 +1384,8 @@ EX(CMD_tabclose, "tabclose", ex_tabclose,
RANGE|NOTADR|COUNT|BANG|TRLBAR|CMDWIN,
ADDR_TABS),
EX(CMD_tabdo, "tabdo", ex_listdo,
- NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_TABS),
EX(CMD_tabedit, "tabedit", ex_splitview,
BANG|FILE1|RANGE|NOTADR|ZEROR|EDITCMD|ARGOPT|TRLBAR,
ADDR_TABS),
@@ -1576,8 +1576,8 @@ EX(CMD_wincmd, "wincmd", ex_wincmd,
NEEDARG|WORD1|RANGE|NOTADR,
ADDR_LINES),
EX(CMD_windo, "windo", ex_listdo,
- BANG|NEEDARG|EXTRA|NOTRLCOM,
- ADDR_LINES),
+ BANG|NEEDARG|EXTRA|NOTRLCOM|RANGE|NOTADR|DFLALL,
+ ADDR_WINDOWS),
EX(CMD_winpos, "winpos", ex_winpos,
EXTRA|TRLBAR|CMDWIN,
ADDR_LINES),
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 4614dea..3fac506 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2472,15 +2472,34 @@ ex_listdo(eap)
| (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD))
{
- /* start at the first argument/window/buffer */
i = 0;
+ /* start at the eap->line1 argument/window/buffer */
#ifdef FEAT_WINDOWS
wp = firstwin;
tp = first_tabpage;
#endif
+ switch (eap->cmdidx)
+ {
+#ifdef FEAT_WINDOWS
+ case CMD_windo:
+ for (wp; wp != NULL && i+1 < eap->line1; wp = wp->w_next)
+ i++;
+ break;
+ case CMD_tabdo:
+ for(tp; tp != NULL && i+1 < eap->line1; tp = tp->tp_next)
+ i++;
+ break;
+#endif
+ case CMD_argdo:
+ i = eap->line1 - 1;
+ break;
+ case CMD_bufdo:
+ i = eap->line1;
+ break;
+ }
/* set pcmark now */
if (eap->cmdidx == CMD_bufdo)
- goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
+ goto_buffer(eap, DOBUF_FIRST, FORWARD, i);
else
setpcmark();
listcmd_busy = TRUE; /* avoids setting pcmark below */
@@ -2506,7 +2525,6 @@ ex_listdo(eap)
}
if (curwin->w_arg_idx != i)
break;
- ++i;
}
#ifdef FEAT_WINDOWS
else if (eap->cmdidx == CMD_windo)
@@ -2541,6 +2559,8 @@ ex_listdo(eap)
}
}
+ ++i;
+
/* execute the command */
do_cmdline(eap->arg, eap->getline, eap->cookie,
DOCMD_VERBOSE + DOCMD_NOWAIT);
@@ -2548,7 +2568,7 @@ ex_listdo(eap)
if (eap->cmdidx == CMD_bufdo)
{
/* Done? */
- if (next_fnum < 0)
+ if (next_fnum < 0 || next_fnum > eap->line2)
break;
/* Check if the buffer still exists. */
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
@@ -2579,6 +2599,14 @@ ex_listdo(eap)
do_check_scrollbind(TRUE);
#endif
}
+
+#ifdef FEAT_WINDOWS
+ if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo)
+ if (i+1 > eap->line2)
+ break;
+#endif
+ if (eap->cmdidx == CMD_argdo && i >= eap->line2)
+ break;
}
listcmd_busy = FALSE;
}
diff --git a/src/testdir/test_command_count.in b/src/testdir/test_command_count.in
index cca178e..4bca140 100644
--- a/src/testdir/test_command_count.in
+++ b/src/testdir/test_command_count.in
@@ -44,6 +44,37 @@ STARTTEST
:1tabonly
:e! test.out
:call append(0, g:lines)
+:unlet g:lines
+:w|bd
+:se hidden
+:b1
+ENDTEST
+
+STARTTEST
+:only!
+:let g:lines = []
+:%argd
+:arga a b c d e f
+:3argu
+:let args = ''
+:.,$-argdo let args .= ' '.expand('%')
+:call add(g:lines, 'argdo:' . args)
+:split|split|split|split
+:2wincmd w
+:let windows = ''
+:.,$-windo let windows .= ' '.winnr()
+:call add(g:lines, 'windo:'. windows)
+:b2
+:let buffers = ''
+:.,$-bufdo let buffers .= ' '.bufnr('%')
+:call add(g:lines, 'bufdo:' . buffers)
+:tabe|tabe|tabe|tabe
+:normal! 2gt
+:let tabpages = ''
+:.,$-tabdo let tabpages .= ' '.tabpagenr()
+:call add(g:lines, 'tabdo:' . tabpages)
+:e! test.out
+:call append('$', g:lines)
:w|qa!
ENDTEST
diff --git a/src/testdir/test_command_count.ok b/src/testdir/test_command_count.ok
index 11e88b3..566cb6d 100644
--- a/src/testdir/test_command_count.ok
+++ b/src/testdir/test_command_count.ok
@@ -15,3 +15,7 @@ RangeTabs 2 5
RangeTabs 1 5
RangeTabsAll 1 5
+argdo: c d e
+windo: 2 3 4
+bufdo: 2 3 4 5 6 7 8 9 11
+tabdo: 2 3 4
signature.asc
Description: Digital signature
