Skip to content

Commit

Permalink
Add buffers into the mix
Browse files Browse the repository at this point in the history
  • Loading branch information
kien committed Apr 7, 2012
1 parent 2cedde3 commit c62259c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions autoload/ctrlp/mixed.vim
@@ -1,6 +1,6 @@
" =============================================================================
" File: autoload/ctrlp/mixed.vim
" Description: Files + MRU
" Description: Mixing Files + MRU + Buffers
" Author: Kien Nguyen <github.com/kien>
" =============================================================================

Expand All @@ -13,7 +13,7 @@ let [g:loaded_ctrlp_mixed, g:ctrlp_newmix] = [1, 0]
let s:mixed_var = {
\ 'init': 'ctrlp#mixed#init(s:compare_lim)',
\ 'accept': 'ctrlp#acceptfile',
\ 'lname': 'fil + mru',
\ 'lname': 'fil + mru + buf',
\ 'sname': 'mix',
\ 'type': 'path',
\ 'opmul': 1,
Expand All @@ -40,11 +40,11 @@ fu! s:getnewmix(cwd, clim)
en
let g:ctrlp_lines = copy(ctrlp#files())
cal ctrlp#progress('Mixing...')
let mrufs = ctrlp#mrufiles#list('raw')
let mrufs = copy(ctrlp#mrufiles#list('raw'))
if exists('+ssl') && &ssl
cal map(mrufs, 'tr(v:val, "\\", "/")')
en
if len(mrufs) > len(g:ctrlp_lines) || v:version < 702
if len(mrufs) > len(g:ctrlp_lines)
cal filter(mrufs, 'stridx(v:val, a:cwd)')
el
let cwd_mrufs = filter(copy(mrufs), '!stridx(v:val, a:cwd)')
Expand Down
23 changes: 12 additions & 11 deletions autoload/ctrlp/mrufiles.vim
Expand Up @@ -25,12 +25,12 @@ fu! s:excl(fn)
retu !empty(s:ex) && a:fn =~# s:ex
endf

fu! s:mergelists()
fu! s:mergelists(...)
let diskmrufs = ctrlp#utils#readfile(ctrlp#mrufiles#cachefile())
cal filter(diskmrufs, 'index(s:mrufs, v:val) < 0')
let mrufs = s:mrufs + diskmrufs
if v:version < 702 | cal filter(mrufs, 'count(mrufs, v:val) == 1') | en
retu s:chop(mrufs)
let mrus = a:0 && a:1 == 'raw' ? s:mrbs : s:mrufs
cal filter(diskmrufs, 'index(mrus, v:val) < 0')
let mrua = mrus + diskmrufs
retu a:0 && a:1 == 'raw' ? mrua : s:chop(mrua)
endf

fu! s:chop(mrufs)
Expand All @@ -50,13 +50,15 @@ fu! s:record(bufnr)
if s:locked | retu | en
let bufnr = a:bufnr + 0
if bufnr <= 0 | retu | en
let fn = fnamemodify(bufname(bufnr), ':p')
let bufname = bufname(bufnr)
if empty(bufname) | retu | en
let fn = fnamemodify(bufname, ':p')
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
if empty(fn) || !empty(&bt) | retu | en
cal filter(s:mrbs, 'v:val !='.s:csen.' fn')
cal insert(s:mrbs, fn)
if empty(fn) || !empty(&bt) || ( !empty(s:in) && fn !~# s:in )
\ || ( !empty(s:ex) && fn =~# s:ex ) || !filereadable(fn)
retu
if ( !empty(s:in) && fn !~# s:in ) || ( !empty(s:ex) && fn =~# s:ex )
\ || !filereadable(fn) | retu
en
cal filter(s:mrufs, 'v:val !='.s:csen.' fn')
cal insert(s:mrufs, fn)
Expand Down Expand Up @@ -89,8 +91,7 @@ fu! ctrlp#mrufiles#remove(files)
endf

fu! ctrlp#mrufiles#list(...)
if a:0 && a:1 != 'raw' | retu | en
retu a:0 && a:1 == 'raw' ? s:mergelists() : s:reformat(s:mergelists())
retu a:0 ? a:1 == 'raw' ? s:mergelists(a:1) : 0 : s:reformat(s:mergelists())
endf

fu! ctrlp#mrufiles#bufs()
Expand Down
6 changes: 3 additions & 3 deletions doc/ctrlp.txt
Expand Up @@ -770,7 +770,7 @@ Available extensions:~
* Mixed mode:~
- Name: 'mixed'
- Command: ':CtrlPMixed'
- Search in both files and MRU files.
- Search in files, buffers and MRU files.

-------------------------------------------------------------------------------
Buffer Tag mode options:~
Expand Down Expand Up @@ -904,9 +904,9 @@ Special thanks:~
===============================================================================
CHANGELOG *ctrlp-changelog*

+ Remove: g:ctrlp_mruf_last_entered, make it the default for MRU mode.
+ Remove: g:ctrlp_mruf_last_entered, make it a default for MRU mode.
+ New commands: |:CtrlPLastMode|, open CtrlP in the last mode used.
|:CtrlPMixed|, search in both files and MRU files.
|:CtrlPMixed|, search in files, buffers and MRU files.

Before 2012/03/31~

Expand Down

0 comments on commit c62259c

Please sign in to comment.