LoginSignup
6
5

More than 5 years have passed since last update.

gitプロジェクトのルートディレクトリ名を取得する

Posted at

locate-dominating-fileは、第一引数のディレクトリからディレクトリ構造を親方向にたどり、
第二引数と等しい名前のファイルやディレクトリを含むディレクトリの名前を返します。
第二引数と等しい名前のファイルやディレクトリが見つからない場合は、nilを返します。

カレントバッファのディレクトリはdefault-directoryで参照できるので、
カレントバッファのgitプロジェクトのルートディレクトリ名は、次のようにして取得できます。

(locate-dominating-file default-directory ".git")
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5