Am 14.05.2010 05:40, schrieb John Beckett:
I'm trying to cleanup an interesting tip that automatically
manipulates the quickfix list with a QuickfixCmdPost event.
The tip sorts the list by file name and line number and omits
duplicates:
http://vim.wikia.com/wiki/Automatically_sort_Quickfix_list
A custom sort function compares two items in the quickfix list
and the following code is used to determine whether the two
quickfix items have the same buffer name:
if bufname(a:i1.bufnr) == bufname(a:i2.bufnr)
The argument a:i1 is a quickfix item; it is a dictionary and
bufnr is a field that specifies the number of the buffer
associated with the quickfix item. See ':help getqflist()'.
Is the following line equivalent to the code above?
if a:i1.bufnr == a:i2.bufnr
I do not see how two different buffers could have the same
bufname(), so just checking the buffer number seems sufficient.
I concede that this is probably not worth worrying about, it's
just my curiosity and wondering what I'm missing.
John
(without looking at the tip ...)
I think it's a bug if two different buffers get the same name.
Little test:
:file foo
:new
:file foo
E95: Buffer with this name already exists
Comparing buffer numbers is even safer, imho, as there is no
problem with case on different systems.
e.g. on win32 (continuing the above example):
:file FOO
E95: Buffer with this name already exists
When comparing by buffer name, there should be two different
tests, one for unix and one for windows.
--
Andy
--
You received this message from the "vim_use" 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