README
======

HISTORY
-------

2012-08-17:
    * 初期設定すべきgitのaliasについて追記

2012-06-26:
    * vim-gistとその設定ファイル作成タスク追加

2012-07-25:
    * vimprocの更新がpullされた時に自動的にcompileしたかったので，
      vimproc/.git/post-merge を作成.

TODO
----

* quickrun等でrvmのRuby,GemSetを使うようにする方法


Git config alias
----------------

```sh
$ git config --global alias.<alias_name> <command>
```

<!-- 
    Do not edit 1st & 2nd row because table style will broken ... 
    See https://gist.github.com/3375344
-->
| alias_name | command |
| ---------- | ------- |
| st   | status                                                                 | 
| co   | checkout                                                               | 
| cm   | commit                                                                 | 
| br   | branch                                                                 | 
| hist | "log --graph --all --color --pretty='%x09%h %cn%x09%s %Cred%d%Creset'" | 


Rake task れあどめ
------------------
(TODO)

    rake clean:all         # Cleans files in backup and swap

    rake clean:backup      # Cleans files in backup directory

    rake clean:swap        # Cleans files in swap directory

    rake compile:vimproc   # compiles vimproc binary (work on only linux)

    rake download:vimproc  # download dll file of vimproc(for windows only)

    rake install:Ricty     # Install Ricty font(for ubuntu only) : TODO

    rake install:gvimrc    # Creates .gvimrc which loading .vim/gvimrc

    rake install:rcs       # Creates .vimrc, gvimrc which loading .vim/vimrc, gvimrc

    rake install:vimrc     # Creates .vimrc which loading .vim/vimrc

    rake install:vundle    # Install vundle plugin

    rake setup:gist        # makes configuration file for gist-vim
        > ./github.confから~/.gist-vimを作成する。(gist-vim用アカウント設定ファイル)


vimprocの自動コンパイル
-----------------------

### 目的

BundleInstall!実行後にcompile:vimprocのrakeタスクを自動実行したい．

### 方法

vimprocのローカルレポジトリで，
pull操作が行われた時に実行されるhookスクリプトに
compile:vimprocのタスクを実行するように仕込む．

ただしpost-pullというhookは存在しないので，代わりにpost-mergeを使う．
pull処理はその過程で必ずmergeを呼び出すのでこういった代用が可能．
ただしpullでないmergeでも呼び出されてしまうため注意が必要で，
あくまで代用として用いている．
今回は特にいじる予定のないローカルレポジトリに仕込むだけなので，
post-pullの代用としてpost-mergeを利用することに問題はない．
(ローカルでpull以外のクリティカルなmergeは発生することはない)

以下操作手順．

    $ touch ~/.vim/bundle/vimproc/.git/hooks/post-merge 
    $ chmod 755 ~/.vim/bundle/vimproc/.git/hooks/post-merge 
    $ vim ~/.vim/bundle/vimproc/.git/hooks/post-merge
    $ cat ~/.vim/bundle/vimproc/.git/hooks/post-merge 
        #!/bin/bash
        # This hook is invoked by git merge, which happens when a git pull is
        # done on a local repository. The hook takes a single parameter, a status
        # flag specifying whether or not the merge being done was a squash merge.
        # This hook cannot affect the outcome of git merge and is not executed,
        # if the merge failed due to conflicts.
        # 
        # This hook can be used in conjunction with a corresponding pre-commit
        # hook to save and restore any form of metadata associated with the
        # working tree (eg: permissions/ownership, ACLS, etc). See
        # contrib/hooks/setgitperms.perl for an example of how to do this.

        ## vimproc compile trigger(I want to execute it when repo is updated by vundle).
        LOG_FILE=/home/tyrex/.vim/VIMPROC_COMPILE.LOG

        rake compile:vimproc >> $LOG_FILE 
        echo `date +"%Y-%m-%d %H:%M:%S Auto vimproc compile executed by post-merge"` >> $LOG_FILE


### 結果

次回(2012-07-25以降)，vimprocの更新があった時に以下のステータスで判定する.

* VIMPROC_COMPILE.LOGが作成されている => 少なくともpost-mergeが実行はされた
* LOGのコンパイルログでコンパイルの成功している



vim-gistの設定ファイル仕様調査
------------------------------

* ファイルパスは ~/.gist-vim
* username:passwordのフォーマットでBASE64エンコード
* basic (encoded username and password)を.gist-vimに書いておく

Vim compile on Windows by VS2010
--------------------------------

### Environments

* OS - Win XP SP3
* vim - ver.7.3.434
* Ruby - ver.1.9.2p136
* Python - ver.2.5.2


### Rrequirement

*コンパイラ*
[Visual C++](http://www.microsoft.com/japan/msdn/vstudio/express/)

*RCS*
[Mercurial SCM](http://mercurial.selenic.com/)
MercurialはtortoiseHgをインストールしてパスを通してもOK.

*香り屋パッチ*
[Kaoriya VIM](http://www.kaoriya.net/software/vim/about)
ZIPを展開して、patche内のパッチを取得する


### Procedure

1. Vimのソースをclone 

        $ hg clone https://vim.googlecode.com/hg .
        
2. Kaoriyaパッチを当てる

        ## 作業時VIMのtipとKaoriyaパッチの対象バージョンが同じだったので
        ## コンフリクトなしでパッチを適用できた。
        ## コメントとか、thincaさんのサンプルそのまま :P
        $ hg import kaoriya-hg.diff -m "Applied the kaoriya's patches"

3. ビルド

        @echo off
        
        pushd %~dp0\src
        setlocal
        
        rem Visual C++ 2010 の場合。
        call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
        
        set OPTIONS=FEATURES=HUGE MBYTE=yes GIME=yes OLE=yes PYTHON=H:\lib\python\2.5 DYNAMIC_PYTHON=yes PYTHON_VER=25 RUBY=H:\lib\ruby\ruby-1.9.2 DYNAMIC_RUBY=yes RUBY_VER=191 RUBY_VER_LONG=1.9.1 IME=yes CSCOPE=yes MIGEMO=yes
        
        set INSTALL_DIR=H:\lib\vim73
        
        rem Compiled by を変えたい場合に設定する。%USERNAME%@%USERDOMAIN% になる。
        rem set USERNAME=
        rem set USERDOMAIN=
        
        nmake -f Make_mvc.mak GUI=no  clean
        nmake -f Make_mvc.mak GUI=yes clean
        nmake -f Make_mvc.mak GUI=no  %OPTIONS%
        nmake -f Make_mvc.mak GUI=yes %OPTIONS%
        
        if not "%INSTALL_DIR%"=="" (
            if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
            copy *.exe "%INSTALL_DIR%"
            copy xxd\xxd.exe "%INSTALL_DIR%"
            copy ..\vimtutor.bat "%INSTALL_DIR%"
        )
        popd
        
[WindowsでVimをソースコードからビルドする@永遠に未完成](http://d.hatena.ne.jp/thinca/20100710/1278708702)
から引用。Ruby周りの設定でエラーが出たのでOPTIONSを若干変更している

4. インストール
    
        kaoriya版のexeだけを野良コンパイルしたものに置き換えた。


### コンパイル時エラーメモ

1. vim2.ico

        fatal error U1073: 'vim2.ico'のビルド方法が指定されていません

src/vim.icoをsrc/vim2.icoにコピー


2. Rubyオプションでコンパイルできない
    
        if_ruby.c(88) : fatal error C1083: include ファイルを開けません。'ruby.h': No such file or directory
        NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : リターン コード '0x2'

[Windows用Vim/GVimのコンパイルと実行環境の作成](https://sites.google.com/site/fudist/Home/vim-nihongo-ban/mingwvim)
を参考にOPTIONSを変更


3. MSC version unmatch ... ?
    
        if_ruby.c
        H:\lib\ruby\ruby-1.9.2\include\ruby-1.9.1\i386-mswin32\ruby/config.h(2) : fatal error C1189: #error :  MSC version unmatch: _MSC_VER: 1200 is expected.
        NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.EXE"' : リターン コード '0x2'

[rubyをC++で使ってみる(1)](http://d.hatena.ne.jp/nakiddance/20101015/p3)
を参考にH:\lib\ruby\ruby-1.9.2\include\ruby-1.9.1\i386-mswin32\ruby/config.hの１行目を変更


4. その他

多分本家のマニュアルは[こちら](http://vimdoc.sourceforge.net/howto/win32-compile/Vim-Compile-Win32-HOWTO.pdf)


vimproc error on Win
--------------------

2012-01-16

vimprocをアップデートしたところ、ファイルの保存(:w)時に
vimproc#get_command_name(関数名はうろ覚え)で"vimなんてファイルはしらんよ"
と必ず怒られるようになってしまった。

調べてみると、

1. 保存時にneocomplcache#cache#async_load_from_fileによって
    ctagsでタグファイルの作成とs:async_load(@neocomplcache/cache.vim)
    の呼び出しが実行される。

2. s:async_loadではasync_cache.vimをvimコマンドからロードする(?)

とやっているのだけれど、vimコマンドによるロードを実行しようとして、
vimのexecutableへのパスを検索するのだけれど、その結果が空になっていたため、
エラーとなっていた。

msysgitのvim.exeがパスに入っていたので、平素お世話になってるvim様へのパスは
通してなかったのだけれど、vim.cmdとか作ってパスが通っているディレクトリに
配置したら、問題なく動くようになった。

ひとまず自分の環境スペスィフィックな問題のような気がするので、
レポートはしない方がいいかな…。


JAVA on Ubuntu
-------------

#### Jarファイルの実行

    java -jar /path/to/jar/file.jar

#### sun-javaへの切り替え

    sudo update-alternatives --config java
    (sun-javaバイナリへのパスの番号を選択する)

#### 文字化けの解消

    cd /usr/lib/jvm/java-6-sun/jre/lib/fonts
    sudo mkdir fallback
    cd fallback
    sudo cp (path to font) .


(git) diff mode changed issue @Windows 
--------------------------------------

    http://stackoverflow.com/questions/1257592/removing-files-saying-old-mode-100755-new-mode-100644-from-unstaged-changes-in
    git config core.filemode false


Installing Ricty Font @ Ubuntu
------------------------------

    # install through apt
    sudo apt-get install fontforge
    sudo apt-get install ttf-inconsolata
    # install migu-1m font
    # check newest download url
    wget http://sourceforge.jp/frs/redir.php?m=iij&f=%2Fmix-mplus-ipa%2F53389%2Fmigu-1m-20111002.zip -O migu1m.zip
    mkdir ~/.fonts
    mv ./migu1m.zip ~/.fonts
    unzip ~/.fonts/migu1m.zip
    # clear font cache
    fc-cache -fv
    # install ricty
    wget http://save.sys.t.u-tokyo.ac.jp/~yusa/fonts/ricty/Ricty-3.1.3.tar.gz
    tar zxvf Ricty-3.1.3.tar.gz
    mv ./Ricty ./fonts
    ~/.fonts/Ricty/ricty_generator.sh auto



pythonchomplete#Complete : R6034 Error
--------------------------------------

### 現象(1)
omnifuncがpythonchompleteの時、R6034のランタイムエラーが発生する. 特に標準
ライブラリ以外の外部ライブラリをimportしているスクリプトで補間を呼び出すと発生.
Windows限定.

### 原因(1)
根本的な原因は不明だが、環境変数PATHに設定されているディレクトリに、msvcp90.dll
もしくはmsvcr90.dllが含まれているとR6034が発生する模様.
Vimの問題ではなく、Python周りの問題.

https://www.google.com/search?gcx=w&sourceid=chrome&ie=UTF-8&q=python+R6034

    Hi, I was having the R6034 error, while starting boxee(or trying
    to play audio files) and realized that XBMC had the same problem. 
    So, I searched their forums and discovered that the solution had
    been found for this problem:

    http://xbmc.org/forum/showthread.php?t=61971&highlight=Runtime+Error+R6034

    In short, it seems that the problem is having msvcp90.dll and 
    msvcr90.dll somewhere in your PATH. In the posters case it was 
    ImageMagick that added some directories to the PATH that contained 
    the offending dlls, but in my case it was miktex (both opensource 
    stuff ported from linux...). 
    So, all you have to do is go through all the dirs in your PATH 
    environment variable, find where those dlls are and rename them. 

### 対処(1)
上記の引用にもあるが、PATHに設定されているディレクトリに存在するmsvc(p|r)90.dll
をリネームする. 私の環境では C:\\WINDOWS\\system32\\msvcr90.dll が存在していたが、
これを\_\_msvcr90.dllにリネームしたところ、omnifunc=pythonchomplete$Completeで
ランタイムエラーは発生しなくなった.

### 現象(2)
msvcr90.dllをリネームしたら以下のようになってしまった.

    # msvcr90.dllはそのまま
    #   -> きちんと補間候補が出力される
    #   -> 外部ライブラリをimportすると補間時にランタイムエラー
    # msvcr90.dllをリネーム
    #   -> 補完候補が明らかに足りない
    #   -> 外部ライブラリをimportしてもランタイムエラーはない
    #   -> vimprocで保存時(:w)にエラーが発生する

Pythonぇ…


Markdown with Vim
-----------------

### 目標
_Markdown形式のファイルの自動コンパイル._

### 方法
*requires:*

+ vim-quickrun : https://github.com/thinca/vim-quickrun
+ vim-markdown : https://github.com/hallison/vim-markdown

パーサーは以下に対応しているとのこと.どれかをインストールする.

    Markdown.pl (Perl. cpan install Markdownかな?)
    kramdown (Ruby. gem install kramdown)
    bluecloth (Ruby. gem install bluecloth)
    redcarpet (GitHubなどで使われている悪評高いMarkdownエンジン)
    pandoc (Haskell. cabal install pandoc) http://johnmacfarlane.net/pandoc/index.html

全部インストールした時点でquickrunのバッファにコンパイルされたHTMLが出力されるよう
になる(＼すげぇ／). あとはこれをブラウザで開いてもらうようにする.

vimrcにquickrunの設定を追加する.

    let g:quickrun_config['markdown'] = {
          \ 'outputter' : 'browser'
          \}

pandocを使う場合はもちょっと設定が必要.

### 結果
\rでコンパイルされた文書がブラウザに表示されるようになった.

あとはデフォルトのテンプレートを設定したい. Vimではなく、パーサーの設定だけど.

### 参考1
というか、書かれているママをやっただけなの.

+ Markdown形式の文書を書く2 : http://vim-users.jp/2011/09/hack230/

### 参考2
パーサーのインストール後にはvimを再起動してからでないと、
quickrunにcommand not found と言われてしまう(Ubuntu11.04で確認).



vimproc コンパイルエラー
------------------------

### 2011-12-20
vimproc ver6.1のdllをコンパイルしようとするとエラーが発生する.

    C:\Documents and Settings\********\.vim\bundle\vimproc>nmake /f make_msvc.mak

    Microsoft(R) Program Maintenance Utility Version 9.00.30729.01
    Copyright (C) Microsoft Corporation.  All rights reserved.

            cl /wd4996 /LD /Feautoload/proc.dll autoload/proc_w32.c ws2_32.lib advapi32.lib shell32.lib

    Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
    Copyright (C) Microsoft Corporation.  All rights reserved.

    proc_w32.c
    Microsoft (R) Incremental Linker Version 9.00.30729.01
    Copyright (C) Microsoft Corporation.  All rights reserved.

    /dll
    /implib:autoload/proc.lib
    /out:autoload/proc.dll
    proc_w32.obj
    ws2_32.lib
    advapi32.lib
    shell32.lib
    LINK : fatal error LNK1104: ファイル 'autoload/proc.dll' を開くことができません。
    NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : リターン コード '0x2'
    Stop.

ひとまず、ver 6.1になる直前のコミットに戻してコンパイル. これで様子見をする.

    $ git checkout 95d49addd7a0f72a099162f587f209126af985b5
    Note: checking out '95d49addd7a0f72a099162f587f209126af985b5'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:

      git checkout -b new_branch_name

    HEAD is now at 95d49ad... Merge pull request #9 from enukane/master

*2011-12-23追記*
Shougoさんも問題を認識してたみたい。アップデートしたら治った…きがする.

Ruby Dictionary
---------------

http://d.hatena.ne.jp/holypp/20110703/1309711799

    @Ubuntu 11.10
    (Ruby refe の入手先)
    http://doc.okkez.net/

#### 入力と出力からメソッド名を補完する

http://vim-users.jp/2011/09/hack231/
Ruby 1.9.3を入れろというgithubでのREADMEだったので保留.

    $ gem install methodfinder
    $ (bundle install : neco-rubymf)


Vim x Ubuntu
-------------------------

#### Font Issue : Gnome端末でアンダーバー(\_)が見えない
    https://forums.ubuntulinux.jp/viewtopic.php?pid=986

    (@.gvimrc)
    set gfn=DejaVu\ Sans\ Mono\ 10

### MSYSGIT pushing issue

msysgitで$GIT_HOMEをplink.exeにしてたらリモートプッシュができなくて困った。
最終的に$GIT_HOMEをssh.exe(MSYSGIT版)にして、
さらに$HOMEに.ssh(rsaキーファイルとか置いてある)があるディレクトリを設定でFA.

VDBI
----
モジュールのインストール方法．vdbi-vim/README.mkdを参照．

### cpanmのインストール

    $ sudo cpan App::cpanminus

### 必要モジュールのインストール

cpanm経由で落とせた．

    $ cpanm DBI Plack JSON

DBD-Pg がcpanmで落とせなかった．

    $ sudo apt-get install libdbd-pg-perl


Python Another TIPs
-------------------

### python after setup

#### Installing pip

    $ curl http://python-distribute.org/distribute_setup.py | python
    $ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python


### PyQt at Windows

PyQtをインストーラでインストールするとレジストリの以下のパスにインストールパス
が追加される。
インストーラでアンインストールしなかった等でこれが残っていると、後から
インストールしようとしてエラーになる。とりあえずPyQt4以下のキーを消せばOK。

    HKEY_LOCAL_MACHINE\SOFTWARE\PyQt4\Py2.7\InstallPath

### python-mode and Pydoc 

Pythonのインストール直後など、PydocにPATHが通っていないとpython-modeがエラーを吐く.

1. PydocにPathを通す
2. オプションでpydocをoffにする

のいずれかを行う必要がある


### python-mode's Pyflake with Python 2.5

python2.5を参照する用にコンパイルし直した後、pythonスクリプト保存時にエラーがごちゃっと
出るようになった。python-modeが保存時にpyflakesでコードチェックしてるけど、そのpyflakes
のランタイムエラー（？）が発生しているらしい。

調べたら、python-modeでは公式のではなくパッチされたpyflakesをソースコードにincludeしていて、
その一部がpython2.5に対応していなかったのが原因だった。
このバグに対する[プルリクエスト](https://github.com/kevinw/pyflakes/pull/21)は出ているけど、
５ヶ月放置されているのを見るとkevinwはpullするつもりがないらしい…。

バグの原因はpython 2.6以降実装されたdecorator_listプロパティを参照している部分があったからで、
decoratorsにrespondしない場合はdecorator_listを使うというように変更して修正完了。

とりあえずプルリクエストにあったdiff通りにbundle/python-mode/pylibs/pyflakes/check.pyを
修正したら、エラーはでなくなった。

<!-- vim: set ft=markdown sw=4 ts=4 :-->
