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

Add recursive loading support #2

Merged
merged 2 commits into from
Jul 9, 2014

Conversation

lambdalisue
Copy link
Contributor

If g:unite_gist_recursive_loading is 1, it use
gist#list_recursively instead of gist#list.

See: mattn/vim-gist#158

自分の持っている gist をすべてフィルタリングしたかったので gist-vim に関数を追加して実現しました。gist-vim に存在しない関数を呼び出すことによるエラーを避けるためにデフォルトでは機能をOFFにしてあります。

If `g:unite_gist_recursive_loading` is 1, it use
`gist#list_recursively` instead of `gist#list`.

See: mattn/vim-gist#158
@mattn
Copy link
Owner

mattn commented Jun 12, 2014

gist#list が呼ばれるタイミングだと既に autoload/gist.vim は読み込まれているので exists("*gist#list_recursively") で0/1が返ると思います。お手数ですがこの exists のチェックを入れて貰えますか。

@lambdalisue
Copy link
Contributor Author

なるほど、読み込まれているのですね。了解です。行っておきます。

@lambdalisue
Copy link
Contributor Author

下記のような処理を足してみたのですが、どうやらこの時点ではexists("*gist#list_recursively")が0を返してしまいます。

  if get(g:, 'unite_gist_recursive_loading', 0)
    if !exists("*gist#list_recursively")
      echo 'g:unite_gist_recursive_loading was specified but gist#list_recursively could not be found.'
      echo 'Make sure that you are using a latest gist-vim.'
      " use gist#list instead
      let gists = gist#list(user)
    else
      let gists = gist#list_recursively(user)
    endif
  else
    let gists = gist#list(user)
  endif

なお gist-vim および unite-gist は下記のように Lazy で読み込んでいます。

  NeoBundleLazy 'mattn/unite-gist', {
        \ 'depends': ['Shougo/unite.vim', 'mattn/gist-vim'],
        \ 'autoload': {
        \   'unite_sources': 'gist',
        \ }}

  " Enable Gist command
  NeoBundleLazy 'mattn/gist-vim', { 
        \ 'depends': [
        \   'mattn/webapi-vim',
        \ ]}

unite_sources により Unite gist で unite-gist が呼ばれた際に、先に gist-vim が呼ばれるはずだと思うのですが、unite-gistで呼び出す一番最初の関数が gist#list もしくは gist#list_recursively になるようなので exists では判断できそうにありませんでした。

osyoさんに習って Try で判定したものを加えたほうがよろしいでしょうか?(http://d.hatena.ne.jp/osyo-manga/20120412/1334158849)

@mattn
Copy link
Owner

mattn commented Jun 13, 2014

あ、すみません。そうでしたね。
設定を行ったvimrcで、最新のgist-vimを使いながら、古いgist-vimが入ったPCにvimrcを持って行って、というのを考えると try/catch があった方が良いかと思います。

@lambdalisue
Copy link
Contributor Author

了解です。加えておきます。

Add try-cache to examine the presence of a new implemented function of
'gist-vim'.
It is required when that user does not use a latest gist-vim in them
environment and (somehow) accidentally specified
'g:unite_gist_recursively_loading' in them vimrc.

If the user specified the 'g:unite_gist_recursively_loading' and
the 'gist#list_recursively' is not found (determined from E117 exception), the
function displays the warnings and use 'gist#list' instead.

See PR mattn#2 conversation for detail (in Japanese).
@mattn
Copy link
Owner

mattn commented Jun 13, 2014

ありがとうございます。動作確認後にマージします。

mattn added a commit that referenced this pull request Jul 9, 2014
@mattn mattn merged commit 93dc282 into mattn:master Jul 9, 2014
@mattn
Copy link
Owner

mattn commented Jul 9, 2014

ありがとうございました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants