Permalink
Browse files

- Print default action in action source.

  • Loading branch information...
Shougo committed Oct 6, 2012
1 parent 1b7571d commit 137fb1098e35b72f8666d27f33b2bb372cedc65f
Showing with 29 additions and 7 deletions.
  1. +13 −4 autoload/unite.vim
  2. +15 −3 autoload/unite/mappings.vim
  3. +1 −0 doc/unite.txt
View
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: unite.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 02 Oct 2012.
+" Last Modified: 06 Oct 2012.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -328,8 +328,11 @@ function! unite#get_all_sources(...)"{{{
return s:initialize_sources()
endif
+ let unite = unite#get_current_unite()
+
let all_sources = s:initialize_sources([], a:1)
- return get(all_sources, a:1, {})
+ return get(all_sources, a:1,
+ \ get(get(unite, 'sources', {}), a:1, {}))
endfunction"}}}
function! unite#get_filters(...)"{{{
if a:0 == 0
@@ -601,7 +604,10 @@ function! unite#get_default_action(source_name, kind)"{{{
return s:get_default_action(a:source_name, kinds[-1])
endfunction"}}}
function! s:get_default_action(source_name, kind_name)"{{{
- let source = unite#get_sources(a:source_name)
+ let source = unite#get_all_sources(a:source_name)
+ if empty(source)
+ return
+ endif
let source_kind = 'source/'.a:source_name.'/'.a:kind_name
let source_kind_wild = 'source/'.a:source_name.'/*'
@@ -917,7 +923,10 @@ function! unite#print_message(message)"{{{
endif
endfunction"}}}
function! unite#print_source_message(message, source_name)"{{{
- call unite#print_message(printf('[%s] %s', a:source_name, a:message))
+ let messages = type(a:message) == type([]) ?
+ \ a:message : [a:message]
+ call unite#print_message(map(copy(messages),
+ \ "printf('[%s] %s', a:source_name, v:val)"))
endfunction"}}}
function! unite#clear_message()"{{{
if &filetype ==# 'unite'
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: mappings.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
-" Last Modified: 02 Oct 2012.
+" Last Modified: 06 Oct 2012.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
@@ -951,8 +951,20 @@ function! s:source_action.gather_candidates(args, context)"{{{
let candidates = copy(a:args)
" Print candidates.
- call unite#print_message(map(copy(candidates),
- \ '"[action] candidates: ".v:val.unite__abbr."(".v:val.source.")"'))
+ call unite#print_source_message(map(copy(candidates),
+ \ "'candidates: '.v:val.unite__abbr.'('.v:val.source.')'"), self.name)
+
+ " Print default action.
+ let default_actions = []
+ for candidate in candidates
+ call add(default_actions, unite#get_default_action(
+ \ candidate.source, candidate.kind))
+ endfor
+ let default_actions = unite#util#uniq(default_actions)
+ if len(default_actions) == 1
+ call unite#print_source_message(
+ \ 'default_action: ' . default_actions[0], self.name)
+ endif
" Process Alias.
let actions = s:get_actions(candidates,
View
@@ -2743,6 +2743,7 @@ CHANGELOG *unite-changelog*
2012-10-06
- Fixed resume error.
+- Print default action in action source.
2012-10-03
- Added unite__new_candidate action in directory sources.

0 comments on commit 137fb10

Please sign in to comment.