Skip to content

Instantly share code, notes, and snippets.

@tarao
Last active December 16, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarao/5360238 to your computer and use it in GitHub Desktop.
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
;; 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