Created
September 28, 2011 18:08
-
-
Save jaydonnell/1248713 to your computer and use it in GitHub Desktop.
anything-git.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
(add-to-list 'load-path "/Users/jaydonnell/Library/Preferences/Aquamacs Emacs/aquamacs-emacs-starter-kit/vendor/anything-config") | |
(require 'anything) | |
(require 'anything-match-plugin) | |
(require 'anything-config) | |
(setq recentf-max-saved-items 500) | |
;; http://www.emacswiki.org/emacs/AnythingSources#toc65 | |
(defun anything-c-sources-git-project-for (pwd) | |
(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) pwd)) | |
(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 $(git rev-parse --show-cdup) %s" | |
(cdr elt)))))))) | |
(candidates-in-buffer) | |
(type . file)))) | |
(defun anything-git-project () | |
(interactive) | |
(let* ((pwd (shell-command-to-string "echo -n `pwd`")) | |
(sources (anything-c-sources-git-project-for pwd))) | |
(anything-other-buffer sources | |
(format "*Anything git project in %s*" pwd)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment