]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.566 v7.4.566
authorBram Moolenaar <Bram@vim.org>
Wed, 7 Jan 2015 15:54:21 +0000 (16:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 7 Jan 2015 15:54:21 +0000 (16:54 +0100)
Problem:    :argdo, :bufdo, :windo and :tabdo don't take a range.
Solution:   Support the range. (Marcin Szamotulski)

runtime/doc/editing.txt
runtime/doc/tabpage.txt
runtime/doc/windows.txt
src/ex_cmds.h
src/ex_cmds2.c
src/testdir/test_command_count.in
src/testdir/test_command_count.ok
src/version.c

index 71f2f8c25c09676aef4efac697949dcb86cec807..4b8e536df5815974c19825b0d206c7bbf1f1c33e 100644 (file)
@@ -1,4 +1,4 @@
-*editing.txt*   For Vim version 7.4.  Last change: 2014 Dec 05
+*editing.txt*   For Vim version 7.4.  Last change: 2015 Jan 04
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -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
@@ -1391,7 +1392,7 @@ reveal it to others.  The 'viminfo' file is not encrypted.
 You could do this to edit very secret text: >
        :set noundofile viminfo=
        :noswapfile edit secrets.txt
-Keep in mind that without a swap file you risk loosing your work in a crash.
+Keep in mind that without a swap file you risk losing your work in a crash.
 
 WARNING: If you make a typo when entering the key and then write the file and
 exit, the text will be lost!
index 47e1a4b6747a78bdbc6759cb93fc86fc36de8709..2d44fe2ff53dcc4269eadb2bc7cf6814389f0ab0 100644 (file)
@@ -1,4 +1,4 @@
-*tabpage.txt*   For Vim version 7.4.  Last change: 2014 Nov 27
+*tabpage.txt*   For Vim version 7.4.  Last change: 2015 Jan 04
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -206,7 +206,7 @@ REORDERING TAB PAGES:
                    :tabmove    " move the tab page to the right
                    :.tabmove   " as above
                    :+tabmove   " as above
-                   :0tabmove   " move the tab page to the begining of the tab
+                   :0tabmove   " move the tab page to the beginning of the tab
                                " list
                    :$tabmove   " move the tab page to the end of the tab list
 <
@@ -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
@@ -271,8 +273,8 @@ window on the same buffer and then edit another buffer.  Thus ":tabnew"
 triggers:
        WinLeave                leave current window
        TabLeave                leave current tab page
-       TabEnter                enter new tab page
        WinEnter                enter window in new tab page
+       TabEnter                enter new tab page
        BufLeave                leave current buffer
        BufEnter                enter new empty buffer
 
index 67925b864a91466569503bd318bd30f5af780643..532cca3e502d18f89a7ec29835c4d70ed712b857 100644 (file)
@@ -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
index 6396d60c25a6a6b287f0e231b44a9d7906ff6eec..50e82521a62b3d1dcc398fc232c82a2036197e9b 100644 (file)
@@ -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_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_WINDOWS),
 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),
index 4614deab80b60f0ff8f7d6ec0340244adf64167c..48badeb93fbcfbf4f29acc46bff37881ef8da7be 100644 (file)
@@ -2472,15 +2472,36 @@ 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 != NULL && i + 1 < eap->line1; wp = wp->w_next)
+                   i++;
+               break;
+           case CMD_tabdo:
+               for( ; 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;
+           default:
+               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 +2527,6 @@ ex_listdo(eap)
                }
                if (curwin->w_arg_idx != i)
                    break;
-               ++i;
            }
 #ifdef FEAT_WINDOWS
            else if (eap->cmdidx == CMD_windo)
@@ -2541,6 +2561,8 @@ ex_listdo(eap)
                    }
            }
 
+           ++i;
+
            /* execute the command */
            do_cmdline(eap->arg, eap->getline, eap->cookie,
                                                DOCMD_VERBOSE + DOCMD_NOWAIT);
@@ -2548,7 +2570,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 +2601,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;
     }
index e7dadd2bed5e6f18f8a95de1f1408f717dc48c3b..16daad0b2d01572ab557a4f336c6a3180898c3df 100644 (file)
@@ -90,6 +90,40 @@ STARTTEST
 :only!
 :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)
+:let buffers = ''
+:3,7bufdo 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
 
index 6e85f29d9487fff85941d345fa8b9435b2a8f9f1..a936715b36a93f47b0cb3323f95dddfba8d667ba 100644 (file)
@@ -28,3 +28,8 @@ $tabe 2
 $+tabe E16: Invalid range
 0tabm x
 
+argdo: c d e
+windo: 2 3 4
+bufdo: 2 3 4 5 6 7 8 9 10 12
+bufdo: 3 4 5 6 7
+tabdo: 2 3 4
index 835afbbf020b4e652a381a196b055c4a140e76b2..6339bcb724c99afdc68a2b29f8c537965fdd8e85 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    566,
 /**/
     565,
 /**/