Re: allow to vimgrep current buffer

2016-02-10 Fir de Conversatie Christian Brabandt
Here is an updated patch. Changes include a new-style test and adapted 
to the recent source style changes.

Best,
Christian
-- 
Niederträchtigkeit der mittlern Zeit bis ins sechzehnte 
Jahrhundert, treffliche Menschen wie Aristoteles, Hippokrates durch 
dumme Märchen lächerlich zu machen.
-- Goethe, Maximen und Reflektionen, Nr. 1328

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -697,6 +697,21 @@ 5.1 using Vim's internal grep
 			the current window is used instead of the quickfix
 			list.
 
+		*:bv* *:bvimgrep*
+:bvimgrep[!] /{pattern}/[g][j] {buffer} ...
+:bvimgrep[!] {pattern} {buffer} ...
+			Same as ":vimgrep", except that it searches the given
+			buffers. If no buffer is given, searches the current
+			buffer. Buffer can be given as buffer name (including
+			file-patterns) or number.
+
+		*:bvimgrepa* *:bvimgrepadd*
+:bvimgrepa[dd][!] /{pattern}/[g][j] {buffer} ...
+:bvimgrepa[dd][!] {pattern} {buffer} ...
+			Just like ":bvimgrep", but instead of making a new
+			list of errors thep matches are appended to the
+			current list.
+
 5.2 External grep
 
 Vim can interface with "grep" and grep-like programs (such as the GNU
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2439,6 +2439,91 @@ ExpandBufnames(
 #endif /* FEAT_CMDL_COMPL */
 
 #ifdef HAVE_BUFLIST_MATCH
+
+#if defined(FEAT_QUICKFIX) || defined(PROTO)
+/*
+ * Parse a list of arguments (buffer names), expand them and return in
+ * a growarray. Return FAIL or OK.
+ */
+int
+get_buflist_exp(char_u *str, int *fcountp, garray_T *garray)
+{
+garray_T	ga;
+int		i = FAIL;
+int		j;
+int		save_magic;
+char_u	*save_cpo;
+regmatch_T	regmatch;
+buf_T	*buf;
+char_u	*pat;
+char_u	*pattern = NULL;
+
+ga_init2(garray, (int)sizeof(int), 1);
+if ((*str == NUL || str == NULL) && ga_grow(garray, 1) == OK)
+{
+	((int *)(garray->ga_data))
+	[garray->ga_len++] = curbuf->b_fnum;
+	*fcountp = 1;
+	return OK;
+}
+else if (get_arglist(, str) == FAIL)
+	return FAIL;
+
+/* Ignore 'magic' and 'cpoptions' here to make scripts portable */
+save_magic = p_magic;
+p_magic = TRUE;
+save_cpo = p_cpo;
+p_cpo = (char_u *)"";
+
+for (j = 0; j < ga.ga_len; j++)
+{
+	pattern = ((char_u **)ga.ga_data)[j];
+	if (*pattern == '%' || *pattern == '#')
+	{
+	if (ga_grow(garray, 1) == OK)
+		((int *)(garray->ga_data))
+		[garray->ga_len++] = *pattern == '*' ? curbuf->b_fnum : curwin->w_alt_fnum;
+	else
+		goto buflistend;
+	}
+	else
+	{
+	/* buffer number given */
+	if (VIM_ISDIGIT(*pattern))
+	{
+		if (ga_grow(garray, 1) == OK)
+		((int *)(garray->ga_data))[garray->ga_len++] = getdigits();
+	}
+	else
+	{
+		/* buffer pattern given */
+		pat = file_pat_to_reg_pat(pattern, pattern + STRLEN(pattern), NULL, FALSE);
+		regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
+		if (regmatch.regprog == NULL)
+		goto buflistend;
+		for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+		{
+		if (buflist_match(, buf, FALSE) != NULL && ga_grow(garray, 1) == OK)
+			((int *)(garray->ga_data))[garray->ga_len++] = buf->b_fnum;
+
+		}
+		vim_regfree(regmatch.regprog);
+		vim_free(pat);
+	}
+	}
+}
+*fcountp = garray->ga_len;
+i = OK;
+
+buflistend:
+p_magic = save_magic;
+p_cpo = save_cpo;
+
+ga_clear();
+return i;
+}
+#endif
+
 /*
  * Check for a match on the file name for buffer "buf" with regprog "prog".
  */
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -226,6 +226,12 @@ EX(CMD_bufdo,		"bufdo",	ex_listdo,
 EX(CMD_bunload,		"bunload",	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
 			ADDR_LOADED_BUFFERS),
+EX(CMD_bvimgrep,	"bvimgrep",	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR,
+			ADDR_LOADED_BUFFERS),
+EX(CMD_bvimgrepadd,	"bvimgrepadd",	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR,
+			ADDR_LOADED_BUFFERS),
 EX(CMD_bwipeout,	"bwipeout",	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR,
 			ADDR_BUFFERS),
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2872,10 +2872,11 @@ do_one_cmd(
 #ifdef FEAT_LISTCMDS
 /*
  * Accept buffer name.  Cannot be used at the same time with a buffer
- * number.  Don't do this for a user command.
+  

Re: allow to vimgrep current buffer

2014-12-06 Fir de Conversatie Christian Brabandt
Here is updated patch for 7.4.519 

Best,
Christian
-- 
Das Fernsehen macht aus dem Kreis der Familie einen Halbkreis.
-- Robert Lembke

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -628,6 +628,21 @@ 5.1 using Vim's internal grep
 			the current window is used instead of the quickfix
 			list.
 
+		*:bv* *:bvimgrep*
+:bvimgrep[!] /{pattern}/[g][j] {buffer} ...
+:bvimgrep[!] {pattern} {buffer} ...
+			Same as :vimgrep, except that it searches the given
+			buffers. If no buffer is given, searches the current
+			buffer. Buffer can be given as buffer name (including
+			file-patterns) or number.
+
+		*:bvimgrepa* *:bvimgrepadd*
+:bvimgrepa[dd][!] /{pattern}/[g][j] {buffer} ...
+:bvimgrepa[dd][!] {pattern} {buffer} ...
+			Just like :bvimgrep, but instead of making a new
+			list of errors thep matches are appended to the
+			current list.
+
 5.2 External grep
 
 Vim can interface with grep and grep-like programs (such as the GNU
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2456,6 +2456,94 @@ ExpandBufnames(pat, num_file, file, opti
 #endif /* FEAT_CMDL_COMPL */
 
 #ifdef HAVE_BUFLIST_MATCH
+
+#if defined(FEAT_QUICKFIX) || defined(PROTO)
+/*
+ * Parse a list of arguments (buffer names), expand them and return in
+ * a growarray. Return FAIL or OK.
+ */
+int
+get_buflist_exp(str, fcountp, garray)
+char_u	*str;
+int		*fcountp;
+garray_T	*garray;
+{
+garray_T	ga;
+int		i = FAIL;
+int		j;
+int		save_magic;
+char_u	*save_cpo;
+regmatch_T	regmatch;
+buf_T	*buf;
+char_u	*pat;
+char_u	*pattern = NULL;
+
+ga_init2(garray, (int)sizeof(int), 1);
+if ((*str == NUL || str == NULL)  ga_grow(garray, 1) == OK)
+{
+	((int *)(garray-ga_data))
+	[garray-ga_len++] = curbuf-b_fnum;
+	*fcountp = 1;
+	return OK;
+}
+else if (get_arglist(ga, str) == FAIL)
+	return FAIL;
+
+/* Ignore 'magic' and 'cpoptions' here to make scripts portable */
+save_magic = p_magic;
+p_magic = TRUE;
+save_cpo = p_cpo;
+p_cpo = (char_u *);
+
+for (j = 0; j  ga.ga_len; j++)
+{
+	pattern = ((char_u **)ga.ga_data)[j];
+	if (*pattern == '%' || *pattern == '#')
+	{
+	if (ga_grow(garray, 1) == OK)
+		((int *)(garray-ga_data))
+		[garray-ga_len++] = *pattern == '*' ? curbuf-b_fnum : curwin-w_alt_fnum;
+	else
+		goto buflistend;
+	}
+	else
+	{
+	/* buffer number given */
+	if (VIM_ISDIGIT(*pattern))
+	{
+		if (ga_grow(garray, 1) == OK)
+		((int *)(garray-ga_data))[garray-ga_len++] = getdigits(pattern);
+	}
+	else
+	{
+		/* buffer pattern given */
+		pat = file_pat_to_reg_pat(pattern, pattern + STRLEN(pattern), NULL, FALSE);
+		regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
+		if (regmatch.regprog == NULL)
+		goto buflistend;
+		for (buf = firstbuf; buf != NULL; buf = buf-b_next)
+		{
+		if (buflist_match(regmatch, buf, FALSE) != NULL  ga_grow(garray, 1) == OK)
+			((int *)(garray-ga_data))[garray-ga_len++] = buf-b_fnum;
+
+		}
+		vim_regfree(regmatch.regprog);
+		vim_free(pat);
+	}
+	}
+}
+*fcountp = garray-ga_len;
+i = OK;
+
+buflistend:
+p_magic = save_magic;
+p_cpo = save_cpo;
+
+ga_clear(ga);
+return i;
+}
+#endif
+
 /*
  * Check for a match on the file name for buffer buf with regprog prog.
  */
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -225,6 +225,12 @@ EX(CMD_bufdo,		bufdo,	ex_listdo,
 EX(CMD_bunload,		bunload,	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR,
 			ADDR_LOADED_BUFFERS),
+EX(CMD_bvimgrep,	bvimgrep,	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR,
+			ADDR_LOADED_BUFFERS),
+EX(CMD_bvimgrepadd,	bvimgrepadd,	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR,
+			ADDR_LOADED_BUFFERS),
 EX(CMD_bwipeout,	bwipeout,	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR,
 			ADDR_UNLOADED_BUFFERS),
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2820,10 +2820,11 @@ do_one_cmd(cmdlinep, sourcing,
 #ifdef FEAT_LISTCMDS
 /*
  * Accept buffer name.  Cannot be used at the same time with a buffer
- * number.  Don't do this for a user command.
+ * number.  Don't do this for a user command or :bvimgrep[add]
  */
 if ((ea.argt  BUFNAME)  *ea.arg != NUL  ea.addr_count == 

Re: allow to vimgrep current buffer

2014-12-06 Fir de Conversatie Bram Moolenaar

Christian wrote:

 Here is updated patch for 7.4.519 

Thanks, I'll update the todo list entry.

-- 
BLACK KNIGHT: I'm invincible!
ARTHUR:   You're a looney.
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-12 Fir de Conversatie Christian Brabandt
Hi Bram!

On Fr, 07 Nov 2014, Bram Moolenaar wrote:
  Okay. So here is a patch, implementing the :bvimgrep and 
  :bvimgrepadd commands.
 
 Great, thanks.
 
 I think this deserves a test.  Should not be too difficult, since it's
 grepping in specific buffers.

Here is an updated patch that includes a test.

Best,
Christian
-- 
Die Wahrheit kann nie so erzählt werden, daß man sie zwar begreift,
aber nicht an sie glaubt.
-- Blake William Bismarck

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -628,6 +628,21 @@ 5.1 using Vim's internal grep
 			the current window is used instead of the quickfix
 			list.
 
+		*:bv* *:bvimgrep*
+:bvimgrep[!] /{pattern}/[g][j] {buffer} ...
+:bvimgrep[!] {pattern} {buffer} ...
+			Same as :vimgrep, except that it searches the given
+			buffers. If no buffer is given, searches the current
+			buffer. Buffer can be given as buffer name (including
+			file-patterns) or number.
+
+		*:bvimgrepa* *:bvimgrepadd*
+:bvimgrepa[dd][!] /{pattern}/[g][j] {buffer} ...
+:bvimgrepa[dd][!] {pattern} {buffer} ...
+			Just like :bvimgrep, but instead of making a new
+			list of errors thep matches are appended to the
+			current list.
+
 5.2 External grep
 
 Vim can interface with grep and grep-like programs (such as the GNU
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2454,6 +2454,94 @@ ExpandBufnames(pat, num_file, file, opti
 #endif /* FEAT_CMDL_COMPL */
 
 #ifdef HAVE_BUFLIST_MATCH
+
+#if defined(FEAT_QUICKFIX) || defined(PROTO)
+/*
+ * Parse a list of arguments (buffer names), expand them and return in
+ * a growarray. Return FAIL or OK.
+ */
+int
+get_buflist_exp(str, fcountp, garray)
+char_u	*str;
+int		*fcountp;
+garray_T	*garray;
+{
+garray_T	ga;
+int		i = FAIL;
+int		j;
+int		save_magic;
+char_u	*save_cpo;
+regprog_T	*prog;
+buf_T	*buf;
+char_u	*pat;
+char_u	*pattern = NULL;
+
+ga_init2(garray, (int)sizeof(int), 1);
+if ((*str == NUL || str == NULL)  ga_grow(garray, 1) == OK)
+{
+	((int *)(garray-ga_data))
+	[garray-ga_len++] = curbuf-b_fnum;
+	*fcountp = 1;
+	return OK;
+}
+else if (get_arglist(ga, str) == FAIL)
+	return FAIL;
+
+/* Ignore 'magic' and 'cpoptions' here to make scripts portable */
+save_magic = p_magic;
+p_magic = TRUE;
+save_cpo = p_cpo;
+p_cpo = (char_u *);
+
+for (j = 0; j  ga.ga_len; j++)
+{
+	pattern = ((char_u **)ga.ga_data)[j];
+	if (*pattern == '%' || *pattern == '#')
+	{
+	if (ga_grow(garray, 1) == OK)
+		((int *)(garray-ga_data))
+		[garray-ga_len++] = *pattern == '*' ? curbuf-b_fnum : curwin-w_alt_fnum;
+	else
+		goto buflistend;
+	}
+	else
+	{
+	/* buffer number given */
+	if (VIM_ISDIGIT(*pattern))
+	{
+		if (ga_grow(garray, 1) == OK)
+		((int *)(garray-ga_data))[garray-ga_len++] = getdigits(pattern);
+	}
+	else
+	{
+		/* buffer pattern given */
+		pat = file_pat_to_reg_pat(pattern, pattern + STRLEN(pattern), NULL, FALSE);
+		prog = vim_regcomp(pat, RE_MAGIC);
+		if (prog == NULL)
+		goto buflistend;
+		for (buf = firstbuf; buf != NULL; buf = buf-b_next)
+		{
+		if (buflist_match(prog, buf, FALSE) != NULL  ga_grow(garray, 1) == OK)
+			((int *)(garray-ga_data))[garray-ga_len++] = buf-b_fnum;
+
+		}
+		vim_regfree(prog);
+		vim_free(pat);
+	}
+	}
+}
+*fcountp = garray-ga_len;
+i = OK;
+
+buflistend:
+p_magic = save_magic;
+p_cpo = save_cpo;
+
+ga_clear(ga);
+return i;
+}
+#endif
+
 /*
  * Check for a match on the file name for buffer buf with regprog prog.
  */
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -175,6 +175,10 @@ EX(CMD_bufdo,		bufdo,	ex_listdo,
 			BANG|NEEDARG|EXTRA|NOTRLCOM),
 EX(CMD_bunload,		bunload,	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR),
+EX(CMD_bvimgrep,	bvimgrep,	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR),
+EX(CMD_bvimgrepadd,	bvimgrepadd,	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR),
 EX(CMD_bwipeout,	bwipeout,	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR),
 EX(CMD_change,		change,	ex_change,
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2647,10 +2647,11 @@ do_one_cmd(cmdlinep, sourcing,
 #ifdef FEAT_LISTCMDS
 /*
  * Accept buffer name. 

Re: allow to vimgrep current buffer

2014-11-12 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

 Hi Bram!
 
 On Fr, 07 Nov 2014, Bram Moolenaar wrote:
   Okay. So here is a patch, implementing the :bvimgrep and 
   :bvimgrepadd commands.
  
  Great, thanks.
  
  I think this deserves a test.  Should not be too difficult, since it's
  grepping in specific buffers.
 
 Here is an updated patch that includes a test.

Thanks!


-- 
In Africa some of the native tribes have a custom of beating the ground
with clubs and uttering spine chilling cries.  Anthropologists call
this a form of primitive self-expression.  In America we call it golf.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-07 Fir de Conversatie Christian Brabandt
On Di, 28 Okt 2014, Ingo Karkat wrote:

 Well, then perhaps a separate :bvimgrep[add] set of commands would be
 better than overloading the existing commands:
 
 :bvimgrep[!] /{pattern}/[g][j] [bufname]
 :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...

Okay. So here is a patch, implementing the :bvimgrep and :bvimgrepadd 
commands.

Best,
Christian
-- 
Wie man sein Kind nicht nennen sollte: 
  Martin Ipur 

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -628,6 +628,21 @@ 5.1 using Vim's internal grep
 			the current window is used instead of the quickfix
 			list.
 
+		*:bv* *:bvimgrep*
+:bvimgrep[!] /{pattern}/[g][j] {buffer} ...
+:bvimgrep[!] {pattern} {buffer} ...
+			Same as :vimgrep, except that it searches the given
+			buffers. If no buffer is given, searches the current
+			buffer. Buffer can be given as buffer name (including
+			file-patterns) or number.
+
+		*:bvimgrepa* *:bvimgrepadd*
+:bvimgrepa[dd][!] /{pattern}/[g][j] {buffer} ...
+:bvimgrepa[dd][!] {pattern} {buffer} ...
+			Just like :bvimgrep, but instead of making a new
+			list of errors thep matches are appended to the
+			current list.
+
 5.2 External grep
 
 Vim can interface with grep and grep-like programs (such as the GNU
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2454,6 +2454,94 @@ ExpandBufnames(pat, num_file, file, opti
 #endif /* FEAT_CMDL_COMPL */
 
 #ifdef HAVE_BUFLIST_MATCH
+
+#if defined(FEAT_QUICKFIX) || defined(PROTO)
+/*
+ * Parse a list of arguments (buffer names), expand them and return in
+ * a growarray. Return FAIL or OK.
+ */
+int
+get_buflist_exp(str, fcountp, garray)
+char_u	*str;
+int		*fcountp;
+garray_T	*garray;
+{
+garray_T	ga;
+int		i = FAIL;
+int		j;
+int		save_magic;
+char_u	*save_cpo;
+regprog_T	*prog;
+buf_T	*buf;
+char_u	*pat;
+char_u	*pattern = NULL;
+
+ga_init2(garray, (int)sizeof(int), 1);
+if ((*str == NUL || str == NULL)  ga_grow(garray, 1) == OK)
+{
+	((int *)(garray-ga_data))
+	[garray-ga_len++] = curbuf-b_fnum;
+	*fcountp = 1;
+	return OK;
+}
+else if (get_arglist(ga, str) == FAIL)
+	return FAIL;
+
+/* Ignore 'magic' and 'cpoptions' here to make scripts portable */
+save_magic = p_magic;
+p_magic = TRUE;
+save_cpo = p_cpo;
+p_cpo = (char_u *);
+
+for (j = 0; j  ga.ga_len; j++)
+{
+	pattern = ((char_u **)ga.ga_data)[j];
+	if (*pattern == '%' || *pattern == '#')
+	{
+	if (ga_grow(garray, 1) == OK)
+		((int *)(garray-ga_data))
+		[garray-ga_len++] = *pattern == '*' ? curbuf-b_fnum : curwin-w_alt_fnum;
+	else
+		goto buflistend;
+	}
+	else
+	{
+	/* buffer number given */
+	if (VIM_ISDIGIT(*pattern))
+	{
+		if (ga_grow(garray, 1) == OK)
+		((int *)(garray-ga_data))[garray-ga_len++] = getdigits(pattern);
+	}
+	else
+	{
+		/* buffer pattern given */
+		pat = file_pat_to_reg_pat(pattern, pattern + STRLEN(pattern), NULL, FALSE);
+		prog = vim_regcomp(pat, RE_MAGIC);
+		if (prog == NULL)
+		goto buflistend;
+		for (buf = firstbuf; buf != NULL; buf = buf-b_next)
+		{
+		if (buflist_match(prog, buf, FALSE) != NULL  ga_grow(garray, 1) == OK)
+			((int *)(garray-ga_data))[garray-ga_len++] = buf-b_fnum;
+
+		}
+		vim_regfree(prog);
+		vim_free(pat);
+	}
+	}
+}
+*fcountp = garray-ga_len;
+i = OK;
+
+buflistend:
+p_magic = save_magic;
+p_cpo = save_cpo;
+
+ga_clear(ga);
+return i;
+}
+#endif
+
 /*
  * Check for a match on the file name for buffer buf with regprog prog.
  */
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -175,6 +175,10 @@ EX(CMD_bufdo,		bufdo,	ex_listdo,
 			BANG|NEEDARG|EXTRA|NOTRLCOM),
 EX(CMD_bunload,		bunload,	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR),
+EX(CMD_bvimgrep,	bvimgrep,	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR),
+EX(CMD_bvimgrepadd,	bvimgrepadd,	ex_vimgrep,
+			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|NEEDARG|EXTRA|NOTRLCOM|TRLBAR),
 EX(CMD_bwipeout,	bwipeout,	ex_bunload,
 			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR),
 EX(CMD_change,		change,	ex_change,
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2647,10 +2647,11 @@ do_one_cmd(cmdlinep, sourcing,
 #ifdef FEAT_LISTCMDS
 /*
  * Accept buffer name.  Cannot be used at the same time with a buffer
- * 

Re: allow to vimgrep current buffer

2014-11-07 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

 On Di, 28 Okt 2014, Ingo Karkat wrote:
 
  Well, then perhaps a separate :bvimgrep[add] set of commands would be
  better than overloading the existing commands:
  
  :bvimgrep[!] /{pattern}/[g][j] [bufname]
  :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...
 
 Okay. So here is a patch, implementing the :bvimgrep and :bvimgrepadd 
 commands.

Great, thanks.

I think this deserves a test.  Should not be too difficult, since it's
grepping in specific buffers.

-- 
   [SIR LAUNCELOT runs back up the stairs, grabs a rope
   of the wall and swings out over the heads of the CROWD in a
   swashbuckling manner towards a large window.  He stops just short
   of the window and is left swing pathetically back and forth.]
LAUNCELOT: Excuse me ... could somebody give me a push ...
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-04 Fir de Conversatie Christian Wellenbrock
Similarly, I feel like :`,` would be consistent with with how ' is 
linewise and ` is character wise (single quote vs backtick).

On Monday, November 3, 2014 9:25:21 PM UTC+1, Bram Moolenaar wrote:
 Christian Brabandt wrote:
 
  On Mi, 29 Okt 2014, Bram Moolenaar wrote:
  
   It could also be a solution for something that doesn't work yet: Search
   within a Visual block.  Since this is going to be a new command, we can
   make :',' respect the Visual mode, including block.  So you could
   select a block and type :bvimgrep /pattern/, then move to matches with
   :cn.
  
  That sounds like a different command than the suggested :bvimgrep 
  command, since it doesn't make sense to visually select a range and then 
  search in a range of buffers (but only in the visual selection for the 
  first buffer).
  
  And while I basically have a :bvimgrep command implementation available, 
  I have no idea how the suggested ',' block is supposed to work or 
  implemented.
 
 True, using a Visual selection and any other buffer, or multiple buffers
 at the same time does not make much sense.  In fact, a line range
 doesn't make much sense when specifying multiple buffers.
 
 Nevertheless, in some cases it could still be useful.  E.g. specifying
 the first 100 lines could work on multiple buffers.  And when selecting
 a column from position 8 to the end of the line, for all lines, this
 could also work in other buffers.  E.g., to skip line numbers in cobol
 files.
 
 Comes back to an old request: How to specify a block of text on the
 command line?  Always using :',' doesn't allow for easy scripting.
 Something like :[1,8],[50,$] would be from line 1 column 8 until line
 50, end of the line.
 
 Not that we decide how to do that now, just to keep in mind when
 deciding how a command with block selection could work.
 And how to pass things around internally.  Currently only the line range
 is passed around, we would need to add the virtual columns to that.
 
 
 -- 
 Witches prefer brooms: vacuum-cleaners need extension cords!
 
  /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
 ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
 \\\  an exciting new programming language -- http://www.Zimbu.org///
  \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-04 Fir de Conversatie Christian Brabandt
On Mo, 03 Nov 2014, Bram Moolenaar wrote:
 Nevertheless, in some cases it could still be useful.  E.g. specifying
 the first 100 lines could work on multiple buffers.  And when selecting
 a column from position 8 to the end of the line, for all lines, this
 could also work in other buffers.  E.g., to skip line numbers in cobol
 files.
 
 Comes back to an old request: How to specify a block of text on the
 command line?  Always using :',' doesn't allow for easy scripting.
 Something like :[1,8],[50,$] would be from line 1 column 8 until line
 50, end of the line.
 
 Not that we decide how to do that now, just to keep in mind when
 deciding how a command with block selection could work.
 And how to pass things around internally.  Currently only the line range
 is passed around, we would need to add the virtual columns to that.

Indeed. But that is way beyond what I can do. For now let me just post a 
patch that implements the :bvimgrep command. Everything else will be 
much more complicated and (correct me if I am wrong) will take forever 
until it will be merged, because the risk of breaking something is much 
more higher.

Best,
Christian

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-04 Fir de Conversatie Bram Moolenaar

Christian Wellenbrock wrote:

 Similarly, I feel like :`,` would be consistent with with how '
 is linewise and ` is character wise (single quote vs backtick).

True, but when you press : we can only either use ' or `.  That
could depend on being on Visual block mode, but many commands that
ignore the column position just work with line numbers.  If we want them
to work on what was actually selected we would need something else than
the different quote.  Otherwise too many things break.  Perhaps a
:block modifier.

I actually have ' mapped to `, thus for me ' and ` do the same thing.
The backtick is a bit hard to type.

It's not going to be completely consistent without breaking backwards
compatibility at the same time.

-- 
WOMAN:   Well, 'ow did you become king then?
ARTHUR:  The Lady of the Lake, [angels sing] her arm clad in the purest
 shimmering samite, held aloft Excalibur from the bosom of the water
 signifying by Divine Providence that I, Arthur, was to carry
 Excalibur.  [singing stops] That is why I am your king!
  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-03 Fir de Conversatie Bram Moolenaar

Christian Brabandt wrote:

 On Mi, 29 Okt 2014, Bram Moolenaar wrote:
 
  It could also be a solution for something that doesn't work yet: Search
  within a Visual block.  Since this is going to be a new command, we can
  make :',' respect the Visual mode, including block.  So you could
  select a block and type :bvimgrep /pattern/, then move to matches with
  :cn.
 
 That sounds like a different command than the suggested :bvimgrep 
 command, since it doesn't make sense to visually select a range and then 
 search in a range of buffers (but only in the visual selection for the 
 first buffer).
 
 And while I basically have a :bvimgrep command implementation available, 
 I have no idea how the suggested ',' block is supposed to work or 
 implemented.

True, using a Visual selection and any other buffer, or multiple buffers
at the same time does not make much sense.  In fact, a line range
doesn't make much sense when specifying multiple buffers.

Nevertheless, in some cases it could still be useful.  E.g. specifying
the first 100 lines could work on multiple buffers.  And when selecting
a column from position 8 to the end of the line, for all lines, this
could also work in other buffers.  E.g., to skip line numbers in cobol
files.

Comes back to an old request: How to specify a block of text on the
command line?  Always using :',' doesn't allow for easy scripting.
Something like :[1,8],[50,$] would be from line 1 column 8 until line
50, end of the line.

Not that we decide how to do that now, just to keep in mind when
deciding how a command with block selection could work.
And how to pass things around internally.  Currently only the line range
is passed around, we would need to add the virtual columns to that.


-- 
Witches prefer brooms: vacuum-cleaners need extension cords!

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-11-02 Fir de Conversatie Christian Brabandt
Hi Bram!

On Mi, 29 Okt 2014, Bram Moolenaar wrote:

 It could also be a solution for something that doesn't work yet: Search
 within a Visual block.  Since this is going to be a new command, we can
 make :',' respect the Visual mode, including block.  So you could
 select a block and type :bvimgrep /pattern/, then move to matches with
 :cn.

That sounds like a different command than the suggested :bvimgrep 
command, since it doesn't make sense to visually select a range and then 
search in a range of buffers (but only in the visual selection for the 
first buffer).

And while I basically have a :bvimgrep command implementation available, 
I have no idea how the suggested ',' block is supposed to work or 
implemented.

Best,
Christian
-- 
Die Lage war noch nie so ernst... wie immer.

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-10-31 Fir de Conversatie Bram Moolenaar

Zyx wrote:

 On October 29, 2014 10:54:38 PM EAT, Bram Moolenaar b...@moolenaar.net 
 wrote:
 
 Christian wrote:
 
  On Di, 28 Okt 2014, Ingo Karkat wrote:
   Well, then perhaps a separate :bvimgrep[add] set of commands would
 be
   better than overloading the existing commands:
  
   :bvimgrep[!] /{pattern}/[g][j] [bufname]
   :N,Mbvimgrep[!] /{pattern}/[g][j]
   :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...
 
  Sounds useful. Bram, would you consider including this feature, if I
  write a patch for that?
 
 I think it can be done with a bit of Vim script, but it might be
 generally useful, thus nice to work without installing a plugin.
 
 It could also be a solution for something that doesn't work yet: Search
 within a Visual block.  Since this is going to be a new command, we can
 make :',' respect the Visual mode, including block.  So you could
 select a block and type :bvimgrep /pattern/, then move to matches
 with
 :cn.
 
 I think we can actually call it :bgrep.  It's very unlikely 'grepprg'
 is useful to search in buffers and it's shorter to type.
 
 No. It is useful if you use something like ag (aka the silver
 searcher), because VimL regexes lack full Unicode support. Also naming
 command like bgrep in place of bvimgrep is inconsistent.

How would an external command access text in a buffer?  Would have to
write them into a file.

If regex is incomplete we could perhaps fix that.


-- 
A mouse can be just as dangerous as a bullet or a bomb.
 (US Representative Lamar Smith, R-Texas)

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-10-31 Fir de Conversatie Ingo Karkat
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 31-Oct-2014 12:42 +0100, Bram Moolenaar wrote:

 Zyx wrote:
 
 On October 29, 2014 10:54:38 PM EAT, Bram Moolenaar
 b...@moolenaar.net wrote:
 
 Christian wrote:
 
 On Di, 28 Okt 2014, Ingo Karkat wrote:
 Well, then perhaps a separate :bvimgrep[add] set of
 commands would
 be
 better than overloading the existing commands:
 
 :bvimgrep[!] /{pattern}/[g][j] [bufname] :N,Mbvimgrep[!]
 /{pattern}/[g][j] :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...
 
 Sounds useful. Bram, would you consider including this
 feature, if I write a patch for that?
 
 I think it can be done with a bit of Vim script, but it might
 be generally useful, thus nice to work without installing a
 plugin.
 
 It could also be a solution for something that doesn't work
 yet: Search within a Visual block.  Since this is going to be a
 new command, we can make :',' respect the Visual mode,
 including block.  So you could select a block and type
 :bvimgrep /pattern/, then move to matches with :cn.
 
 I think we can actually call it :bgrep.  It's very unlikely
 'grepprg' is useful to search in buffers and it's shorter to
 type.
 
 No. It is useful if you use something like ag (aka the silver 
 searcher), because VimL regexes lack full Unicode support. Also
 naming command like bgrep in place of bvimgrep is
 inconsistent.
 
 How would an external command access text in a buffer?  Would have
 to write them into a file.
 
 If regex is incomplete we could perhaps fix that.

I would also prefer :bvimgrep for consistency and to signify the
regexp dialect being used; it could be abbreviated as :bv. This keeps
the option of later implementing :bgrep that indeed writes the buffer
to a temp file (if necessary), and runs 'grepprg' over it. (Though the
biggest downside of :vimgrep for me isn't in the regexp dialect, but
its slowness due to loading all files into Vim, something that isn't
an issue when going over Vim's (already loaded) buffers.)

- -- regards, ingo
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJUVACeAAoJEA7ziXlAzQ/vL9IH/10eE8ZNaFgtFPRXeqtwLcmG
grXbtdRtwt2CbpR0lmduOf91D8OVPu/d+8UgjusVydSLUgbVMPROxDAlsgsTP/1d
EMe9dFHcM/qEbNHt7QR0GQfPqpZ6+yavxPfcqHPeuwsAZTn+KBoc291UkF7G5wgf
pURu5F0lQ/VwjGJvXpSsYCwMjEYn4Cnqv2oMQ6gMDpvUFga62z7MwGuTnKlOjsya
7gdGjOrAKZ2fet2TLrb+JfjNwu7pLPqxJWWcW+hYmOszjhtIFzA2Qr4PJwK6oKVc
hra0TttUVNTr7K7Z/eUV/UBHv5OeQlWKUXDLEf6gqsKAm75lu2K0ppm5o7FlKdI=
=cLGD
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-10-30 Fir de Conversatie Павлов Николай Александрович
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On October 29, 2014 10:54:38 PM EAT, Bram Moolenaar b...@moolenaar.net wrote:

Christian wrote:

 On Di, 28 Okt 2014, Ingo Karkat wrote:
  Well, then perhaps a separate :bvimgrep[add] set of commands would
be
  better than overloading the existing commands:
 
  :bvimgrep[!] /{pattern}/[g][j] [bufname]
  :N,Mbvimgrep[!] /{pattern}/[g][j]
  :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...

 Sounds useful. Bram, would you consider including this feature, if I
 write a patch for that?

I think it can be done with a bit of Vim script, but it might be
generally useful, thus nice to work without installing a plugin.

It could also be a solution for something that doesn't work yet: Search
within a Visual block.  Since this is going to be a new command, we can
make :',' respect the Visual mode, including block.  So you could
select a block and type :bvimgrep /pattern/, then move to matches
with
:cn.

I think we can actually call it :bgrep.  It's very unlikely 'grepprg'
is useful to search in buffers and it's shorter to type.

No. It is useful if you use something like ag (aka the silver searcher), 
because VimL regexes lack full Unicode support. Also naming command like 
bgrep in place of bvimgrep is inconsistent.
-BEGIN PGP SIGNATURE-
Version: APG v1.1.1

iQI1BAEBCgAfBQJUUjhWGBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
HhHSvu8xEACJearFWQR3HYeAV2G12pvCgKCYUIGhSTetmzBw52vh6yBepjQoq4qG
FyplLlRAa0XXAe9jakjNphnB45GzASnUHjtm/I/bmfJrHAISrFPwO9evsGWBDd2U
t3nV4e6he/fb636H6ZdCsnK7dJyp4ZvIgAylgcTchNfcJ/zgrAQZdj1dU+0rpFLw
I8NMAjBG65GUvmKVDZVivt9v8ljwnlhvgwi7TibvzKxKZjiMOWTIN3LShI3bwzjH
qyul0dBlP0DR8FUzVjJGDJyDGLXS4AIMswXc9Zws6qkDr35nd+emUxoOQjTvkkkP
fl7omQi3f1MaR5M5vsihdzMOGaQ5Hkh3CJ5PFxGHKOkbwdugTqRBKYdSGeS5irou
iuSF9ZbNUsdn+bNs4TfeQ4VnS2gGz4Vm70guXVduMZU+e38Lf34cuoW0/94owxTf
ZHUXOSaKHcXw4PrpLHkeGaQTz915LIX/a3vySzDjM7yFzvpKrTPHLCJFWIF5+lPh
bB3u0EsIvYZHWhTvKu6C33ahUPbzidUEdPTfd0ef9pN/jJUJTCjuqyOjNHp4Ns/s
Kz+xuHQSmL3dX/Nc9gMlcHZzO2bJD27iepswAwmAr56dvGXiepoyRlrpoApSbPY3
BLlAQvSm/A3cVr8WJcq/2I+DVpabl4e5ziFC9vz22jsDkaBHu+jmrg==
=z0oD
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-10-29 Fir de Conversatie Bram Moolenaar

Christian wrote:

 On Di, 28 Okt 2014, Ingo Karkat wrote:
  Well, then perhaps a separate :bvimgrep[add] set of commands would be
  better than overloading the existing commands:
  
  :bvimgrep[!] /{pattern}/[g][j] [bufname]
  :N,Mbvimgrep[!] /{pattern}/[g][j]
  :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...
 
 Sounds useful. Bram, would you consider including this feature, if I
 write a patch for that?

I think it can be done with a bit of Vim script, but it might be
generally useful, thus nice to work without installing a plugin.

It could also be a solution for something that doesn't work yet: Search
within a Visual block.  Since this is going to be a new command, we can
make :',' respect the Visual mode, including block.  So you could
select a block and type :bvimgrep /pattern/, then move to matches with
:cn.

I think we can actually call it :bgrep.  It's very unlikely 'grepprg'
is useful to search in buffers and it's shorter to type.

-- 
PRINCE:He's come to rescue me, father.
LAUNCELOT: (embarrassed) Well, let's not jump to conclusions ...
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] allow to vimgrep current buffer

2014-10-28 Fir de Conversatie Christian Brabandt

Am 2014-10-27 23:08, schrieb Bee:

On Monday, October 27, 2014 1:06:12 PM UTC-7, Christian Brabandt wrote:

Bram,
here is a patch, that allows to use
:vimgrep /foobar/
to search only the current buffer. You might want to argue this is
already possible just use '%' as the filename, but that does not work,
if the current buffer does not have a name yet. Then vimgrep complains
about not being able to access an unknown file, although it wouldn't
have to load the file, since it is already in memory, so it should be
possible to do so, without writing temporary files.



Just curious...

How is that different from simply using `/` ?

Is this a `just in case` scenario?


I find it convenient to have all search results in the quickfix buffer.

Best,
Christian

--
--
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] allow to vimgrep current buffer

2014-10-28 Fir de Conversatie James McCoy
On Oct 28, 2014 2:40 AM, Christian Brabandt cbli...@256bit.org wrote:

 Am 2014-10-27 23:08, schrieb Bee:
 Just curious...

 How is that different from simply using `/` ?

 Is this a `just in case` scenario?


 I find it convenient to have all search results in the quickfix buffer.

It'd be even more convenient to allow searching more than just the current
buffer (says someone that wrote a buffer grep plugin).

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] allow to vimgrep current buffer

2014-10-28 Fir de Conversatie Christian Brabandt

Am 2014-10-28 12:04, schrieb James McCoy:

On Oct 28, 2014 2:40 AM, Christian Brabandt cbli...@256bit.org
wrote:
 
  Am 2014-10-27 23:08, schrieb Bee:
  Just curious...
 
  How is that different from simply using `/` ?
 
  Is this a `just in case` scenario?
 
 
  I find it convenient to have all search results in the quickfix
buffer.

It'd be even more convenient to allow searching more than just the
current buffer (says someone that wrote a buffer grep plugin).


Sure, but I am not sure how to specify it:
Something like this (vimgrep buffers 1-4)?

:vimgrep /foobar/ 1,2,3,4
which would not work, if there is a file 1,2,3,4

We don't have commands, that accept several buffer numbers, right?
But perhaps an argdo/bufdo :vimgrep would suffice?

Best,
Christian


--
--
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] allow to vimgrep current buffer

2014-10-28 Fir de Conversatie Павлов Николай Александрович
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On October 28, 2014 3:22:58 PM EAT, Christian Brabandt cbli...@256bit.org 
wrote:
Am 2014-10-28 12:04, schrieb James McCoy:
 On Oct 28, 2014 2:40 AM, Christian Brabandt cbli...@256bit.org
 wrote:
  
   Am 2014-10-27 23:08, schrieb Bee:
   Just curious...
  
   How is that different from simply using `/` ?
  
   Is this a `just in case` scenario?
  
  
   I find it convenient to have all search results in the quickfix
 buffer.

 It'd be even more convenient to allow searching more than just the
 current buffer (says someone that wrote a buffer grep plugin).

Sure, but I am not sure how to specify it:
Something like this (vimgrep buffers 1-4)?

:vimgrep /foobar/ 1,2,3,4
which would not work, if there is a file 1,2,3,4

We don't have commands, that accept several buffer numbers, right?

Wrong. :bw and similar commands accept more then one buffer.

But perhaps an argdo/bufdo :vimgrep would suffice?

No. This will result in either having a hack for catching the situation 
vimgrep called from :*do or having a quickfix list with the results for the 
last buffer only.  There is :vimgrepadd, but this is not going to empty 
quickfix list before proceeding. And :bufdo is a) non-selective and b) switches 
current buffer.


Best,
Christian

-BEGIN PGP SIGNATURE-
Version: APG v1.1.1

iQI1BAEBCgAfBQJUT65yGBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
HhHSvkV/EACSwam1XxTBhas7Av6x3rxbcknrCzQGJ36OO4Ts3fLMcjSspODAFCBD
29etiHnn8yx2k+FC3WEfXIAa2nUsCR71b6KC5LenBao6umVI30haKjAOdOmIliF2
7HvF29unDZb1CSg9ldVsyiboPfmgwvy2WcteasbaKSLj6ABG8/zNoGLWhQFrr520
nT8R2ZTzmuKl7+N23ujCA0kIGjtFOD4fnNIu09NLhWCrpQCv36HylvIcVEFtfkbE
yWJFubdPaGF4e9c0OP2OBDj6W6KSYrnsbAfurvZQPZolMBqa1KPnANE4OYloI9A3
OzVzQW3gEa3IhMXe5KR0geMM86HO3X1H9eH5OL7W9SmhQGqPEl0VJtkq86Pf0HYv
tOJRc0+RJRhrMdJI7bKbCNemEuj2nh1pHP5w1sVJu4aaIW48ii1l3zD+L8LyaXJr
YgTUI9u4L106AKBeL22PltBfV4s1RnKi5XU5lMpYI2XvNbhPkQekvFySXzfYCjuV
LpUvvQxg66BdZ5BNBX8h3PL7UJOeH2y8ZO/EqnzhA+BNZ2VgTWDJV/NX3I4xUf0a
anFH338NFqZ4zifjkfeByUZtHfUK3I1yK7l87ZNDuuwiyoXjN6s/lOESJP9PNiPp
Fj6xY1dnVQstCb69Ij4ofxMgetez8/C8+onCzwLYpXFVU4L/py9ybA==
=DZS8
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-10-28 Fir de Conversatie Ingo Karkat
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 28-Oct-2014 15:55 +0100, Павлов Николай  Александрович wrote:

On 28-Oct-2014 15:55, Павлов Николай Александрович wrote: On October
28, 2014 3:22:58 PM EAT, Christian Brabandt cbli...@256bit.org wrote:
 Am 2014-10-28 12:04, schrieb James McCoy:
 On Oct 28, 2014 2:40 AM, Christian Brabandt 
 cbli...@256bit.org wrote:
 
 Am 2014-10-27 23:08, schrieb Bee:
 Just curious...
 
 How is that different from simply using `/` ?
 
 Is this a `just in case` scenario?
 
 
 I find it convenient to have all search results in the 
 quickfix
 buffer.
 
 It'd be even more convenient to allow searching more than just 
 the current buffer (says someone that wrote a buffer grep 
 plugin).
 
 Sure, but I am not sure how to specify it: Something like this 
 (vimgrep buffers 1-4)?
 
 :vimgrep /foobar/ 1,2,3,4 which would not work, if there is a 
 file 1,2,3,4
 
 We don't have commands, that accept several buffer numbers, 
 right?
 
 Wrong. :bw and similar commands accept more then one buffer.
 
 But perhaps an argdo/bufdo :vimgrep would suffice?
 
 No. This will result in either having a hack for catching the 
 situation vimgrep called from :*do or having a quickfix list
 with the results for the last buffer only.  There is :vimgrepadd,
 but this is not going to empty quickfix list before proceeding.
 And :bufdo is a) non-selective and b) switches current buffer.

Well, then perhaps a separate :bvimgrep[add] set of commands would be
better than overloading the existing commands:

:bvimgrep[!] /{pattern}/[g][j] [bufname]
:N,Mbvimgrep[!] /{pattern}/[g][j]
:bvimgrep[!] /{pattern}/[g][j] N1 N2 ...

- -- regards, ingo
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJUT7hAAAoJEA7ziXlAzQ/vj20H/j7Vng7ns2UVsWpT2nHHAjHw
CMxs8H5eTzwUOK6UxZ7CXKZvkeaoamm8fjIIqdk1kGzzRoTiylS3C6Iti7XsYnJH
1id/gzbDWuAc5h0MmBxmyLrRaErmlK2LsjKfjvH5tsJMzXZoaIj35kgvVdR0ZDmd
dPwSEfDwUnxUu14rNnE1LaKi/cSSmzMvqvLfiCwIrQfUrfQcRWXd3W2Pw8D7x33Z
MDTCSBVF9bCxbNEiUjOmun/rWGajyFfdhuzXcmciwkSSAUVJkq1sJleC7IES5QIg
Q1j0rf6RrfL3aHuVHlySDjQQCuqxqSbZnVYdBDg8aIbwg0iBJShhNLcYkcFNNfg=
=vlIz
-END PGP SIGNATURE-

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: allow to vimgrep current buffer

2014-10-28 Fir de Conversatie Christian Brabandt
On Di, 28 Okt 2014, Ingo Karkat wrote:
 Well, then perhaps a separate :bvimgrep[add] set of commands would be
 better than overloading the existing commands:
 
 :bvimgrep[!] /{pattern}/[g][j] [bufname]
 :N,Mbvimgrep[!] /{pattern}/[g][j]
 :bvimgrep[!] /{pattern}/[g][j] N1 N2 ...

Sounds useful. Bram, would you consider including this feature, if I 
write a patch for that?

Best,
Christian
-- 
In Deutschland feiern wir lieber weiße als grüne Weihnachten, in
Hongkong feiern mehr Gelbe als Weiße Weihnachten, in Afrika feiern
viele Farbige Weihnachten und nur wenige Weiße grüne Weihnachten!
-- Loriot (Vicco von Bülow)

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[patch] allow to vimgrep current buffer

2014-10-27 Fir de Conversatie Christian Brabandt
Bram,
here is a patch, that allows to use
:vimgrep /foobar/
to search only the current buffer. You might want to argue this is 
already possible just use '%' as the filename, but that does not work, 
if the current buffer does not have a name yet. Then vimgrep complains 
about not being able to access an unknown file, although it wouldn't 
have to load the file, since it is already in memory, so it should be 
possible to do so, without writing temporary files.

Best,
Christian
-- 
Man erzürnt sich immer mehr gegen einen, für den man erst den Zorn
einige Zeit aufheben muß - und genade ihm dann Gott!
-- Jean Paul

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -607,23 +607,26 @@ 5.1 using Vim's internal grep
 			pattern must start with an ID character.
 			Example: 
 :vimgrep Error *.c
-
+
+:vim[grep][!] {pattern} 
+			Like above, but only search current buffer.
+
 			*:lv* *:lvimgrep*
-:lv[imgrep][!] /{pattern}/[g][j] {file} ...
-:lv[imgrep][!] {pattern} {file} ...
+:lv[imgrep][!] /{pattern}/[g][j] [{file} ...]
+:lv[imgrep][!] {pattern} [{file} ...]
 			Same as :vimgrep, except the location list for the
 			current window is used instead of the quickfix list.
 
 		*:vimgrepa* *:vimgrepadd*
-:vimgrepa[dd][!] /{pattern}/[g][j] {file} ...
-:vimgrepa[dd][!] {pattern} {file} ...
+:vimgrepa[dd][!] /{pattern}/[g][j] [{file} ...]
+:vimgrepa[dd][!] {pattern} [{file} ...]
 			Just like :vimgrep, but instead of making a new list
 			of errors the matches are appended to the current
 			list.
 
 		*:lvimgrepa* *:lvimgrepadd*
-:lvimgrepa[dd][!] /{pattern}/[g][j] {file} ...
-:lvimgrepa[dd][!] {pattern} {file} ...
+:lvimgrepa[dd][!] /{pattern}/[g][j] [{file} ...]
+:lvimgrepa[dd][!] {pattern} [{file} ...]
 			Same as :vimgrepadd, except the location list for
 			the current window is used instead of the quickfix
 			list.
diff --git a/src/quickfix.c b/src/quickfix.c
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3175,6 +3175,7 @@ ex_vimgrep(eap)
 char_u	*target_dir = NULL;
 #ifdef FEAT_AUTOCMD
 char_u	*au_name =  NULL;
+int		only_curbuf = FALSE;
 
 switch (eap-cmdidx)
 {
@@ -3242,8 +3243,8 @@ ex_vimgrep(eap)
 p = skipwhite(p);
 if (*p == NUL)
 {
-	EMSG(_(E683: File name missing or invalid pattern));
-	goto theend;
+	only_curbuf = TRUE;
+	fcount = 1;
 }
 
 if ((eap-cmdidx != CMD_grepadd  eap-cmdidx != CMD_lgrepadd 
@@ -3258,7 +3259,7 @@ ex_vimgrep(eap)
 	;
 
 /* parse the list of arguments */
-if (get_arglist_exp(p, fcount, fnames, TRUE) == FAIL)
+if (!only_curbuf  get_arglist_exp(p, fcount, fnames, TRUE) == FAIL)
 	goto theend;
 if (fcount == 0)
 {
@@ -3284,29 +3285,38 @@ ex_vimgrep(eap)
 seconds = (time_t)0;
 for (fi = 0; fi  fcount  !got_int  tomatch  0; ++fi)
 {
-	fname = shorten_fname1(fnames[fi]);
-	if (time(NULL)  seconds)
+	if (!only_curbuf)
 	{
-	/* Display the file name every second or so, show the user we are
-	 * working on it. */
-	seconds = time(NULL);
-	msg_start();
-	p = msg_strtrunc(fname, TRUE);
-	if (p == NULL)
-		msg_outtrans(fname);
-	else
+	fname = shorten_fname1(fnames[fi]);
+	if (time(NULL)  seconds)
 	{
-		msg_outtrans(p);
-		vim_free(p);
+		/* Display the file name every second or so, show the user we are
+		* working on it. */
+		seconds = time(NULL);
+		msg_start();
+		p = msg_strtrunc(fname, TRUE);
+		if (p == NULL)
+		msg_outtrans(fname);
+		else
+		{
+		msg_outtrans(p);
+		vim_free(p);
+		}
+		msg_clr_eos();
+		msg_didout = FALSE;	/* overwrite this message */
+		msg_nowait = TRUE;	/* don't wait for this message */
+		msg_col = 0;
+		out_flush();
 	}
-	msg_clr_eos();
-	msg_didout = FALSE;	/* overwrite this message */
-	msg_nowait = TRUE;	/* don't wait for this message */
-	msg_col = 0;
-	out_flush();
+
+	buf = buflist_findname_exp(fnames[fi]);
 	}
-
-	buf = buflist_findname_exp(fnames[fi]);
+	else
+	{
+	buf = curbuf;
+	fname = NULL;
+	}
+
 	if (buf == NULL || buf-b_ml.ml_mfp == NULL)
 	{
 	/* Remember that a buffer with this name already exists. */
@@ -3472,7 +3482,8 @@ ex_vimgrep(eap)
 	}
 }
 
-FreeWild(fcount, fnames);
+if (!only_curbuf)
+	FreeWild(fcount, fnames);
 
 qi-qf_lists[qi-qf_curlist].qf_nonevalid = FALSE;
 qi-qf_lists[qi-qf_curlist].qf_ptr = qi-qf_lists[qi-qf_curlist].qf_start;


Re: [patch] allow to vimgrep current buffer

2014-10-27 Fir de Conversatie Bee
On Monday, October 27, 2014 1:06:12 PM UTC-7, Christian Brabandt wrote:
 Bram,
 here is a patch, that allows to use
 :vimgrep /foobar/
 to search only the current buffer. You might want to argue this is 
 already possible just use '%' as the filename, but that does not work, 
 if the current buffer does not have a name yet. Then vimgrep complains 
 about not being able to access an unknown file, although it wouldn't 
 have to load the file, since it is already in memory, so it should be 
 possible to do so, without writing temporary files.
 
 Best,
 Christian
 -- 
 Man erzürnt sich immer mehr gegen einen, für den man erst den Zorn
 einige Zeit aufheben muß - und genade ihm dann Gott!
   -- Jean Paul

Christian

Just curious...

How is that different from simply using `/` ?

Is this a `just in case` scenario?

Bill

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.