Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip the quickfix buffer when searching for alternative buffers. #23

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion plugin/bbye.vim
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,40 @@ function! s:bdelete(action, bang, buffer_name)
execute window . "wincmd w"

" Bprevious also wraps around the buffer list, if necessary:
try | exe bufnr("#") > 0 && buflisted(bufnr("#")) ? "buffer #" : "bprevious"
" try | exe bufnr("#") > 0 && buflisted(bufnr("#")) ? "buffer #" : "bprevious"
" catch /^Vim([^)]*):E85:/ " E85: There is no listed buffer
" endtry
try
if bufnr("#") > 0 && bufnr("#") != buffer && buflisted(bufnr("#")) && getbufvar(bufnr("#"), '&ft') != 'qf'
" If # buffer is listed and not quickfix switch to it
buffer #
" echom 'swith to alt'
continue
endif
" Emulate bprevious but excluding quickfix buffers
" listed buffer that are not quickfix buffers:
let buffers = map(filter(getbufinfo({'buflisted':1}), "getbufvar(v:val.bufnr, '&ft') != 'qf'"), "v:val.bufnr")
let buffers = filter(buffers, "v:val < buffer")
if len(buffers)
execute "buffer " . buffers[-1]
" echom 'swith to previous'
continue
endif
let buffers = map(filter(getbufinfo({'buflisted':1}), "getbufvar(v:val.bufnr, '&ft') != 'qf'"), "v:val.bufnr")
let buffers = filter(buffers, "v:val > buffer")
" Emulate bprevious but excluding quickfix buffers
if len(buffers)
execute "buffer " . buffers[-1]
" echom 'swith to last'
continue
endif
catch /^Vim([^)]*):E85:/ " E85: There is no listed buffer
endtry

" If found a new buffer for this window, mission accomplished:
if bufnr("%") != buffer | continue | endif

" Otherwise create an empty buffer
call s:new(a:bang)
endfor

Expand Down