Last active
August 29, 2015 14:06
-
-
Save rummelonp/eee20639f3fdb3797d90 to your computer and use it in GitHub Desktop.
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
(require 'vc-git) | |
(require 'anything-config) | |
(defgroup anything-rails nil | |
"anything for rails" | |
:prefix "anything-rails:" | |
:group 'anything) | |
(defun anything-rails:root () | |
(vc-git-root default-directory)) | |
(defun anything-rails:ls (buffer &rest args) | |
(apply 'vc-git-command buffer 0 nil "ls-files" args)) | |
(defun anything-rails:candidates (what args &optional root) | |
(let* ((root (or root | |
(anything-attr 'default-directory) | |
(anything-rails:root))) | |
(buffer-name (format " *anything candidates:%s:%s*" root what)) | |
(buffer (get-buffer-create buffer-name))) | |
(anything-attrset 'default-directory root) | |
(let ((default-directory root)) | |
(apply 'anything-rails:ls buffer "--full-name" args)) | |
(anything-candidate-buffer buffer) | |
(anything-candidates-in-buffer))) | |
(defun anything-rails:source (what args &optional root repository) | |
(let ((name (concat (format "Rails %s" (capitalize (format "%s" what))) | |
(or (and repository (format " in %s" repository)) "")))) | |
`((name . ,name) | |
(candidates . (lambda () | |
(anything-rails:candidates ',what ',args ,root))) | |
(type . file) | |
(display-to-real . (lambda (name) | |
(expand-file-name name (anything-attr 'default-directory))))))) | |
(defvar anything-rails:model-source nil) | |
(setq anything-rails:model-source | |
(anything-rails:source 'model '("app/models"))) | |
(defvar anything-rails:controller-source nil) | |
(setq anything-rails:controller-source | |
(anything-rails:source 'controller '("app/controllers"))) | |
(defvar anything-rails:view-source nil) | |
(setq anything-rails:view-source | |
(anything-rails:source 'view '("app/views"))) | |
(defvar anything-rails:migration-source nil) | |
(setq anything-rails:migration-source | |
(anything-rails:source 'migration '("db/migrate"))) | |
(defvar anything-rails:helper-source nil) | |
(setq anything-rails:helper-source | |
(anything-rails:source 'helper '("app/helpers"))) | |
(defvar anything-rails:test-source nil) | |
(setq anything-rails:test-source | |
(anything-rails:source 'test '("test"))) | |
(defvar anything-rails:spec-source nil) | |
(setq anything-rails:spec-source | |
(anything-rails:source 'spec '("spec"))) | |
(defvar anything-rails:fixture-source nil) | |
(setq anything-rails:fixture-source | |
(anything-rails:source 'fixture '("test/fixtures" | |
"spec/fixtures" | |
"test/factories" | |
"spec/factories"))) | |
(defvar anything-rails:sources nil) | |
(setq anything-rails:sources | |
'(anything-rails:model-source | |
anything-rails:controller-source | |
anything-rails:view-source | |
anything-rails:migration-source | |
anything-rails:helper-source | |
anything-rails:test-source | |
anything-rails:spec-source | |
anything-rails:fixture-source)) | |
(defun anything-rails () | |
(interactive) | |
(anything-other-buffer anything-rails:sources | |
"*anything for rails*")) | |
(provide 'anything-rails) |
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
(:name anything-rails | |
:type http | |
:url "https://gist.githubusercontent.com/mitukiii/eee20639f3fdb3797d90/raw/anything-rails.el" | |
:depends anything) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
設定例