Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 7d6aa01e3343122c71dddc96be50070422912488 0 parents
@jpablobr authored
Showing with 136 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +29 −0 README.md
  3. +103 −0 anything-git-goto.el
4 .gitignore
@@ -0,0 +1,4 @@
+*~
+\#*
+.\#*
+*.elc
29 README.md
@@ -0,0 +1,29 @@
+Emacs Anything git-goto
+======================
+
+Emacs git(1) based emulation of TextMate fuzzy file search.
+
+## Functions:
+
+```
+M-x anything-git-goto
+```
+
+## Installation:
+
+In your emacs config:
+
+```
+(add-to-list 'load-path "~/.emacs.d/load/path/anything-git-goto.el")
+(require 'anything-git-goto)
+```
+
+## Requirements
+
+You will need to install
+[anything-mode](http://www.emacswiki.org/emacs/Anything). See
+documentation for how to install.
+
+## Copyright
+
+Copyright 2012 Jose Pablo Barrantes. MIT Licence, so go for it.
103 anything-git-goto.el
@@ -0,0 +1,103 @@
+;;; anything-git-goto.el --- Quick listing of:
+
+;; This file is not part of Emacs
+
+;; Copyright (C) 2011 Jose Pablo Barrantes
+;; Created: 18/Dec/11
+;; Version: 0.1.0
+
+;;; Installation:
+
+;; Put this file where you defined your `load-path` directory or just
+;; add the following line to your emacs config file:
+
+;; (load-file "/path/to/anything-git-goto.el")
+
+;; Finally require it:
+
+;; (require 'anything-git-goto)
+
+;; Usage:
+;; M-x anything-git-goto
+
+;; There is no need to setup load-path with add-to-list if you copy
+;; `anything-git-goto.el` to load-path directories.
+
+;; Requirements:
+
+;; http://www.emacswiki.org/emacs/Anything
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 3, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'anything)
+
+;;; --------------------------------------------------------------------
+;;; - Customization
+;;;
+(defvar *anything-git-goto-buffer-name*
+ "*Anything git-goto*")
+
+(defvar git-goto-cmd
+ "cd %s && git \
+ --no-pager ls-files \
+ -cmo \
+ --exclude-standard \
+ --directory")
+
+(defun anything-git-goto-find-git-repo (dir)
+ "Recursively search for a .git/ directory."
+ (if (string= "/" dir)
+ (message "not in a git repo.")
+ (if (file-exists-p (expand-file-name ".git/" dir))
+ dir
+ (anything-git-goto-find-git-repo (expand-file-name "../" dir)))))
+
+(defun anything-git-goto-file (file-content)
+ "Visit the source for the file result."
+ (setq file-full-path (expand-file-name
+ file-content
+ (expand-file-name
+ (anything-git-goto-find-git-repo file-content)
+ (anything-attr 'pwd))))
+ (if (file-exists-p file-full-path)
+ (find-file file-full-path))
+ (kill-buffer *anything-git-goto-buffer-name*))
+
+(defvar anything-c-source-git-goto
+ '((name . "Git goto")
+ (init
+ . (lambda ()
+ (call-process-shell-command
+ (format git-goto-cmd
+ (anything-git-goto-find-git-repo (shell-command-to-string "pwd")))
+ nil (anything-candidate-buffer 'global))))
+ (candidate-number-limit . 9999)
+ (candidates-in-buffer)
+ (action . anything-git-goto-file))
+ "Git goto.")
+
+;;;###autoload
+(defun anything-git-goto ()
+ "Git Find files."
+ (interactive)
+ (anything-other-buffer
+ '(anything-c-source-git-goto) *anything-git-goto-buffer-name*))
+
+(provide 'anything-git-goto)
Please sign in to comment.
Something went wrong with that request. Please try again.