Oops, forgot to clean up the second defines list. How embarrassing.
Anyway...I actually experimented, and for this error list, :1cc tries jumping to the first "cruft" line, :2cc to the 2nd, etc. So actually in this case, the line number DOES correspond to the error number.
If you use getloclist(0) or getqflist() then each item returned has a "valid" field; the cruft lines have valid set false, but they ARE in the error list. So I don't actually know when the error list entries don't correspond to the line numbers, if that is ever the case.
I'm putting that mapping in my vim config now, thanks a ton! I only modified it slightly to also work with the location list. Here is something I do when setting filetype to quickfix, to detect whether it's a location list or a quickfix list:
if &buftype=='quickfix'
if v:version >= 700
if !exists('s:processing')
let listbufnr = bufnr("%")
let numwindows = winnr('$')
let curwin = winnr()
let s:processing = 1
copen
call setbufvar(listbufnr, 'errorlist_type', (curwin == winnr() ? 'quickfix' : 'location'))
" close the quickfix list if it was closed when we began
if numwindows != winnr('$')
cclose
endif
" return to quickfix/location list
exe curwin 'wincmd w'
It works by using "copen" to jump to the quickfix list, and if the current window changed then we must have been in the location list before.
Now I can use this as the map function:
function! QfEnter()
let l:lnum = line('.')
if b:errorlist_type == 'location'
let l:cmd = 'll'
else
let l:cmd = 'cc'
endif
wincmd p
exe l:cmd l:lnum
endfunction