Last active
December 16, 2015 02:09
-
-
Save tarao/5360238 to your computer and use it in GitHub Desktop.
This file is obsolete. Use anything-git-files.el https://github.com/tarao/anything-git-files-el
This file contains hidden or 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
;; http://shibayu36.hatenablog.com/entry/2012/12/22/135157 | |
(eval-when-compile (require 'cl)) | |
;;;###autoload | |
(defun anything-git-project-project-dir () | |
(let ((dir (shell-command-to-string "git rev-parse --show-toplevel"))) | |
(replace-regexp-in-string "[\n\r]+$" "" dir))) | |
;;;###autoload | |
(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)))) | |
;;;###autoload | |
(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))))) | |
(provide 'anything-git-project) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment