Last active
December 25, 2015 08:19
-
-
Save tnoda/6945413 to your computer and use it in GitHub Desktop.
Retrieved from http://shibayu36.hatenablog.com/entry/2012/12/22/135157 on Oct 12, 2013.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun shibayu36/chomp (str) | |
(replace-regexp-in-string "[\n\r]+$" "" str)) | |
(defun anything-git-project-project-dir () | |
(shibayu36/chomp | |
(shell-command-to-string "git rev-parse --show-toplevel"))) | |
(defun anything-c-sources-git-project-for () | |
(loop for elt in | |
'(("Modified files (%s)" . "--modified") | |
("Untracked files (%s)" . "--others --exclude-standard") | |
("All controlled files in this project (%s)" . "")) | |
collect | |
`((name . ,(format (car elt) (anything-git-project-project-dir))) | |
(init . (lambda () | |
(unless (and ,(string= (cdr elt) "") ;update candidate buffer every time except for that of all project files | |
(anything-candidate-buffer)) | |
(with-current-buffer | |
(anything-candidate-buffer 'global) | |
(insert | |
(shell-command-to-string | |
,(format "git ls-files --full-name $(git rev-parse --show-cdup) %s" | |
(cdr elt)))))))) | |
(candidates-in-buffer) | |
(display-to-real . (lambda (name) | |
(format "%s/%s" | |
(anything-git-project-project-dir) name))) | |
(type . file)))) | |
(defun anything-git-project () | |
(interactive) | |
(let* ((sources (anything-c-sources-git-project-for))) | |
(anything-other-buffer sources | |
(format "*Anything git project in %s*" | |
(anything-git-project-project-dir))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment