- List all the files in a git repository which the file of the current buffer belongs to
- List untracked files and modified files in different sources
- List files in the submodules
- Cache the list as long as the repository is not modified
- Avoid interrupting user inputs; external git command is invoked asynchronously
- Install dependent package anything.el
- Locate anything-git-files.el in your load path
Install by MELPA
- Type
M-x package-install RET anything-git-files RET
.
- Save the lines below as anything-git-files.rcp in your recipe directory
- Type
M-x el-get RET anything-git-files RET
(:name anything-git-files
:type github
:pkgname "tarao/anything-git-files-el"
:depends anything)
Load anything-git-files.el in your ~/.emacs or ~/emacs.d/init.el:
(require 'anything-git-files)
Then, M-x anything-git-files
will list the files in a git
repository. Note that M-x anything-git-files
will fail when the
file of the current buffer is not in a git repository.
The anything sources to get files in a git repository are
anything-git-files:modified-source
,
anything-git-files:untracked-source
and
anything-git-files:all-source
.
The list of anything sources for submodules can be retrieved by
function anything-git-files:submodule-sources
. The function takes
one argument, which is a list of symbols of source type, modified
,
untracked
or all
. For example,
(anything-git-files:submodule-sources '(untracked all)
returns
anything sources for untracked files and all files in the git
repository of the submodules.
The following example defines a custom anything function to list files from several sources, including ones from anything-git-files.el.
(defun tarao/anything-for-files ()
(interactive)
(require 'anything-config)
(require 'anything-git-files)
(let* ((git-source (and (anything-git-files:git-p)
`(anything-git-files:modified-source
anything-git-files:untracked-source
anything-git-files:all-source
,@(anything-git-files:submodule-sources 'all))))
(other-source '(anything-c-source-recentf
anything-c-source-bookmarks
anything-c-source-files-in-current-dir+
anything-c-source-locate))
(sources `(anything-c-source-buffers+
anything-c-source-ffap-line
anything-c-source-ffap-guesser
,@git-source
,@other-source)))
(anything-other-buffer sources "*anything for files*")))
- A guide in Japanese: anythingでgitリポジトリ内のファイルの全列挙をきちんとやる