Hi,
On 3/6/07, Gary Johnson <[EMAIL PROTECTED]> wrote:
On 2007-03-07, "A.J.Mechelynck" <[EMAIL PROTECTED]> wrote:
> Gary Johnson wrote:
> > If I open a new window, read into it the results of a grep command,
> > e.g.,
> >
> > :r !grep -nH somepattern somefileset
> >
> > and then try to use that buffer as a quickfix list or location list
> > with either the :cb or :lb commands, respectively, I get
> >
> > E37: No write since last change (add ! to override)
> >
> > If I then try to add ! to the :cb or :lb commands, I get
> >
> > E477: No ! allowed
> >
> > It seems to me that the :cb and :lb commands are missing the ability
> > to handle a !.
> >
> > The most recent version of vim I had to verify this with was
> > 7.0.178.
> >
> > Regards,
> > Gary
> >
>
> If what you want to do with the output of grep is use it as a quickfix
> error list, then use ":grep" or ":lgrep" instead of ":r !grep". Or you can
> also use ":vimgrep" or ":lvimgrep" for internal grep (with Vim-style
> regexps).
>
> See ":help grep".
It seems pretty clear that there has been an oversight in the
implementation of the :cb and :lb commands, even pointed to by the
text of E37. If there is some reason that the :cb and :lb commands
should not be extended to accept !, then the current text of E37 is
inappropriate for that error condition.
Try using the attached patch which enables the "!" modifier for the
":cbuffer" and ":lbuffer" commands.
- Yegappan
Index: src/ex_cmds.h
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_cmds.h,v
retrieving revision 1.56
diff -c -p -r1.56 ex_cmds.h
*** src/ex_cmds.h 22 Jun 2006 19:15:58 -0000 1.56
--- src/ex_cmds.h 7 Mar 2007 02:21:53 -0000
*************** EX(CMD_call, "call", ex_call,
*** 198,204 ****
EX(CMD_catch, "catch", ex_catch,
EXTRA|SBOXOK|CMDWIN),
EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
! RANGE|NOTADR|WORD1|TRLBAR),
EX(CMD_cc, "cc", ex_cc,
RANGE|NOTADR|COUNT|TRLBAR|BANG),
EX(CMD_cclose, "cclose", ex_cclose,
--- 198,204 ----
EX(CMD_catch, "catch", ex_catch,
EXTRA|SBOXOK|CMDWIN),
EX(CMD_cbuffer, "cbuffer", ex_cbuffer,
! BANG|RANGE|NOTADR|WORD1|TRLBAR),
EX(CMD_cc, "cc", ex_cc,
RANGE|NOTADR|COUNT|TRLBAR|BANG),
EX(CMD_cclose, "cclose", ex_cclose,
*************** EX(CMD_laddfile, "laddfile", ex_cfile,
*** 498,504 ****
EX(CMD_later, "later", ex_later,
TRLBAR|EXTRA|NOSPC|CMDWIN),
EX(CMD_lbuffer, "lbuffer", ex_cbuffer,
! RANGE|NOTADR|WORD1|TRLBAR),
EX(CMD_lcd, "lcd", ex_cd,
BANG|FILE1|TRLBAR|CMDWIN),
EX(CMD_lchdir, "lchdir", ex_cd,
--- 498,504 ----
EX(CMD_later, "later", ex_later,
TRLBAR|EXTRA|NOSPC|CMDWIN),
EX(CMD_lbuffer, "lbuffer", ex_cbuffer,
! BANG|RANGE|NOTADR|WORD1|TRLBAR),
EX(CMD_lcd, "lcd", ex_cd,
BANG|FILE1|TRLBAR|CMDWIN),
EX(CMD_lchdir, "lchdir", ex_cd,