Anything source to search files in current GIT project (http://www.emacswiki.org/emacs/AnythingSources#toc64)
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
(defvar anything-c-source-git-project-files-cache nil "(path signature cached-buffer)") | |
(defvar anything-c-source-git-project-files | |
'((name . "Files from Current GIT Project") | |
(init . (lambda () | |
(let* ((git-top-dir (magit-get-top-dir (if (buffer-file-name) | |
(file-name-directory (buffer-file-name)) | |
default-directory))) | |
(top-dir (if git-top-dir | |
(file-truename git-top-dir) | |
default-directory)) | |
(default-directory top-dir) | |
(signature (magit-rev-parse "HEAD"))) | |
(unless (and anything-c-source-git-project-files-cache | |
(third anything-c-source-git-project-files-cache) | |
(equal (first anything-c-source-git-project-files-cache) top-dir) | |
(equal (second anything-c-source-git-project-files-cache) signature)) | |
(if (third anything-c-source-git-project-files-cache) | |
(kill-buffer (third anything-c-source-git-project-files-cache))) | |
(setq anything-c-source-git-project-files-cache | |
(list top-dir | |
signature | |
(anything-candidate-buffer 'global))) | |
(with-current-buffer (third anything-c-source-git-project-files-cache) | |
(dolist (filename (mapcar (lambda (file) (concat default-directory file)) | |
(magit-git-lines "ls-files"))) | |
(insert filename) | |
(newline)))) | |
(anything-candidate-buffer (third anything-c-source-git-project-files-cache))))) | |
(type . file) | |
(candidates-in-buffer))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment