Skip to content

Commit

Permalink
Version 7.3.5
Browse files Browse the repository at this point in the history
Michael Henry added the ability to view "No Name" buffers.  This functionality was lost since version 7.3.0.  He also did some removal of "dead" code and cleaned up the code to handle filenames with embedded '"'.
  • Loading branch information
jeff lanzarotta authored and vim-scripts committed Feb 9, 2013
1 parent 6b5e630 commit 5ad9b12
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
17 changes: 14 additions & 3 deletions doc/bufexplorer.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*bufexplorer.txt* Buffer Explorer Last Change: 28 Jan 2013
*bufexplorer.txt* Buffer Explorer Last Change: 08 Feb 2013

Buffer Explorer *buffer-explorer* *bufexplorer*
Version 7.3.4
Version 7.3.5

Plugin for easily exploring (or browsing) Vim|:buffers|.

Expand Down Expand Up @@ -157,10 +157,16 @@ The default is NOT to sort in reverse order.
*g:bufExplorerShowDirectories*
Directories usually show up in the list from using a command like ":e .".
To control whether to show directories in the buffer list or not, use: >
let g:bufExplorerShowDirectories=0 " Do not show directories.
let g:bufExplorerShowDirectories=1 " Show directories.
let g:bufExplorerShowDirectories=0 " Don't show directories.
The default is to show directories.

*g:bufExplorerShowNoName*
To control whether to show "No Name" buffers or not, use: >
let g:bufExplorerShowNoName=0 " Do not "No Name" buffers.
let g:bufExplorerShowNoName=1 " Show "No Name" buffers.
The default is to NOT show "No Name buffers.

*g:bufExplorerShowRelativePath*
To control whether to show absolute paths or relative to the current
directory, use: >
Expand Down Expand Up @@ -226,6 +232,11 @@ The default is 0, so that the size is set by Vim.
===============================================================================
CHANGE LOG *bufexplorer-changelog*

7.3.5 February 08, 2013
* Michael Henry added the ability to view "No Name" buffers. This
functionality was lost since version 7.3.0. He also did some removal of
"dead" code and cleaned up the code to handle filenames with embedded
'"'.
7.3.4 January 28, 2013
* Thanks go out to John Szakmeister for finding and fixing a bug in the
RebuildBufferList method. The keepjumps line that clears the list could
Expand Down
54 changes: 26 additions & 28 deletions plugin/bufexplorer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
" Name Of File: bufexplorer.vim
" Description: Buffer Explorer Vim Plugin
" Maintainer: Jeff Lanzarotta (delux256-vim at yahoo dot com)
" Last Changed: Monday, 28 Jan 2013
" Last Changed: Friday, 08 Feb 2013
" Version: See g:bufexplorer_version for version number.
" Usage: This file should reside in the plugin directory and be
" automatically sourced.
Expand Down Expand Up @@ -49,7 +49,7 @@ endif
"2}}}

" Version number
let g:bufexplorer_version = "7.3.4"
let g:bufexplorer_version = "7.3.5"

" Check for Vim version {{{2
if v:version < 700
Expand Down Expand Up @@ -239,11 +239,6 @@ function! s:ShouldIgnore(buf)
return 1
endif

" Ignore unlisted buffers.
if buflisted(a:buf) == 0
return 1
endif

" Ignore buffers with no name.
if empty(bufname(a:buf)) == 1
return 1
Expand Down Expand Up @@ -355,21 +350,6 @@ function! BufExplorer(open)

silent let s:raw_buffer_listing = s:GetBufferInfo(0)

let buffer_listing_copy = copy(s:raw_buffer_listing)

if (g:bufExplorerShowUnlisted == 0)
call filter(buffer_listing_copy, 'v:val.attributes !~ "u"')
endif

if (!empty(buffer_listing_copy))
call filter(buffer_listing_copy, 'v:val.shortname !~ "\\\[No Name\\\]"')
endif

" if len(buffer_listing_copy) <= 1
" call s:Warning("Sorry, there are no more buffers to explore")
" return
" endif

" We may have to split the current window.
if (s:splitMode != "")
" Save off the original settings.
Expand Down Expand Up @@ -416,6 +396,14 @@ function! s:DisplayBufferList()

call s:SetupSyntax()
call s:MapKeys()

"NEW
" Wipe out any existing lines in case BufExplorer buffer exists and the
" user had changed any global settings that might reduce the number of
" lines needed in the buffer.
keepjumps 1,$d _
"NEW

call setline(1, s:CreateHelp())
call s:BuildBufferList()
call cursor(s:firstBufferLine, 1)
Expand Down Expand Up @@ -603,10 +591,19 @@ function! s:GetBufferInfo(bufnr)
" Loop over each line in the buffer.
for buf in split(bufoutput, '\n')
let bits = split(buf, '"')
let b = {"attributes": bits[0], "line": substitute(bits[2], '\s*', '', '')}

" Use first and last components after the split on '"', in case a
" filename with an embedded '"' is present.
let b = {"attributes": bits[0], "line": substitute(bits[-1], '\s*', '', '')}

let name = bufname(str2nr(b.attributes))
let b["hasNoName"] = empty(name)
if b.hasNoName
let name = "[No Name]"
endif

for [key, val] in items(s:types)
let b[key] = fnamemodify(bits[1], val)
let b[key] = fnamemodify(name, val)
endfor

if getftype(b.fullname) == "dir" && g:bufExplorerShowDirectories == 1
Expand Down Expand Up @@ -646,8 +643,8 @@ function! s:BuildBufferList()
continue
endif

" Ignore buffers with no name.
if empty(bufname(str2nr(buf.attributes))) == 1
" Skip "No Name" buffers if we are not to show them.
if (!g:bufExplorerShowNoName && buf.hasNoName)
continue
endif

Expand Down Expand Up @@ -934,9 +931,9 @@ function! s:RebuildBufferList(...)

let curPos = getpos('.')

if a:0 && (line('$') >= s:firstBufferLine)
if a:0 && a:000[0] && (line('$') >= s:firstBufferLine)
" Clear the list first.
exec "keepjumps ".s:firstBufferLine.',$d "_'
exec "keepjumps ".s:firstBufferLine.',$d _'
endif

let num_bufs = s:BuildBufferList()
Expand Down Expand Up @@ -1154,6 +1151,7 @@ call s:Set("g:bufExplorerShowDirectories", 1) " (Dir's are added by comman
call s:Set("g:bufExplorerShowRelativePath", 0) " Show listings with relative or absolute paths?
call s:Set("g:bufExplorerShowTabBuffer", 0) " Show only buffer(s) for this tab?
call s:Set("g:bufExplorerShowUnlisted", 0) " Show unlisted buffers?
call s:Set("g:bufExplorerShowNoName", 0) " Show "No Name" buffers?
call s:Set("g:bufExplorerSortBy", "mru") " Sorting methods are in s:sort_by:
call s:Set("g:bufExplorerSplitBelow", &splitbelow) " Should horizontal splits be below or above current window?
call s:Set("g:bufExplorerSplitOutPathName", 1) " Split out path and file name?
Expand Down

0 comments on commit 5ad9b12

Please sign in to comment.