Hi Bram and list,

2016-8-9(Tue) 6:27:17 UTC+9 Bram Moolenaar:
> Kent Sibilev wrote:
> 
> > On Saturday, August 6, 2016 at 1:02:18 PM UTC-4, Bram Moolenaar wrote:
> > > 
> > > The problem with this solution is that the names are translated.
> > > A more direct solution would be better.
> > > 
> > > The 'buftype' option is "quickfix" for both quickfix and location list.
> > > We can't change that without causing problems.
> > > 
> > > Perhaps we should add a buftype({expr}) function, that can get the
> > > buffer type of any buffer, and make a difference between "quickfix" and
> > > "loclist".
> > 
> > I see. Even though it's quite awkward to add a new function just to
> > accommodate this particular case, i'm attaching my attempt to
> > implement it.
> 
> Yes, it is unexpected to have this function.  But I can see it's useful.
> Would there be a better solution somehow?
> Perhaps using one of the existing quickfix functions?

Do you remember this thread?

We can't handle type which it's quickfix or location-list.
https://groups.google.com/d/msg/vim_dev/GIjn9QRyLag/M_8AJ5_UkMoJ

It also listed on the TODO.
TODO> Patch to check whether a buffer is quickfix or a location list.
TODO> (Yasuhiro Matsumoto, 2014 Dec 9)

I've arranged with several correct mistakes of this patch.
It will be `w:quickfix_type` is set. In the same way as the `w:quickfix_title`.
The values are 'quickfix' or 'location'.

What about an attached patch?
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
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/options.txt b/runtime/doc/options.txt
index 16002dd..8fb2f10 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1343,6 +1343,8 @@ A jump table for the options with a short description can be found at |Q_op|.
 			|+autocmd| feature}
 	  quickfix	quickfix buffer, contains list of errors |:cwindow|
 			or list of locations |:lwindow|
+			You can get a list type via window local variable
+			|w:quickfix_type|
 	  help		help buffer (you are not supposed to set this
 			manually)
 
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 1accede..06d5c69 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -394,7 +394,8 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
 =============================================================================
 2. The error window					*quickfix-window*
 
-					    *:cope* *:copen* *w:quickfix_title*
+							*:cope* *:copen*
+					*w:quickfix_title* *w:quickfix_type*
 :cope[n] [height]	Open a window to show the current list of errors.
 
 			When [height] is given, the window becomes that high
@@ -408,11 +409,15 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
 
 			The window will contain a special buffer, with
 			'buftype' equal to "quickfix".  Don't change this!
-			The window will have the w:quickfix_title variable set
-			which will indicate the command that produced the
-			quickfix list. This can be used to compose a custom
-			status line if the value of 'statusline' is adjusted
-			properly.
+			The window will have two window local variables.
+			|w:quickfix_title| set which will indicate the command
+			that produced the quickfix list. This can be used to
+			compose a custom status line if the value of
+			'statusline' is adjusted properly.
+			|w:quickfix_type| is set to the quickfix list type.
+			The values are:
+			    'quickfix'	quickfix list.
+			    'location'	location list.
 
 							*:lop* *:lopen*
 :lop[en] [height]	Open a window to show the location list for the
diff --git a/src/quickfix.c b/src/quickfix.c
index aa94ae6..5f0ef5b 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2963,6 +2963,8 @@ ex_copen(exarg_T *eap)
 	    set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
 								   OPT_LOCAL);
 #endif
+	    set_internal_string_var((char_u *)"w:quickfix_type",
+		    IS_QF_WINDOW(curwin) ? "quickfix" : "location");
 	}
 
 	/* Only set the height when still in the same tab page and there is no
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 9f0b510..5dfead6 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -443,7 +443,7 @@ func Test_vimgreptitle()
   augroup! QfBufWinEnter
 endfunc
 
-function XqfTitleTests(cchar)
+function XqfTitleAndTypeTests(cchar)
   call s:setup_commands(a:cchar)
 
   Xgetexpr ['file:1:1:message']
@@ -457,17 +457,20 @@ function XqfTitleTests(cchar)
   Xopen
   if a:cchar == 'c'
     let title = ':setqflist()'
+	let qftype = 'quickfix'
   else
     let title = ':setloclist()'
+	let qftype = 'location'
   endif
   call assert_equal(title, w:quickfix_title)
+  call assert_equal(qftype, w:quickfix_type)
   Xclose
 endfunction
 
-" Tests for quickfix window's title
-function Test_qf_title()
-  call XqfTitleTests('c')
-  call XqfTitleTests('l')
+" Tests for quickfix window's title and w:quickfix_type
+function Test_qf_title_and_type()
+  call XqfTitleAndTypeTests('c')
+  call XqfTitleAndTypeTests('l')
 endfunction
 
 " Tests for 'errorformat'

Raspunde prin e-mail lui