Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some rake functions.

  • Loading branch information...
commit b4aa1147acc42741235e855bb8f674783d6422f9 1 parent 3967f4b
@technomancy authored
Showing with 26 additions and 2 deletions.
  1. +26 −2 starter-kit-ruby.el
View
28 starter-kit-ruby.el
@@ -17,9 +17,35 @@
(global-set-key (kbd "C-h r") 'ri)
+;; Rake files are ruby, too.
+(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
+(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
+
;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")
+(add-hook 'ruby-mode-hook 'my-coding-hook)
+
+;;; Rake
+
+(defun pcomplete/rake ()
+ "Completion rules for the `ssh' command."
+ (pcomplete-here (pcmpl-rake-tasks)))
+
+(defun pcmpl-rake-tasks ()
+ "Return a list of all the rake tasks defined in the current
+projects. I know this is a hack to put all the logic in the
+exec-to-string command, but it works and seems fast"
+ (delq nil (mapcar '(lambda(line)
+ (if (string-match "rake \\([^ ]+\\)" line) (match-string 1 line)))
+ (split-string (shell-command-to-string "rake -T") "[\n]"))))
+
+(defun rake (task)
+ (interactive (list (completing-read "Rake (default: default): "
+ (pcmpl-rake-tasks))))
+ (shell-command-to-string (concat "rake " (if (= 0 (length task)) "default" task))))
+
+
;; Clear the compilation buffer between test runs.
(eval-after-load 'ruby-compilation
'(progn
@@ -30,8 +56,6 @@
(delete-region (point-min) (point-max))))))
(ad-activate 'ruby-do-run-w/compilation)))
-(add-hook 'ruby-mode-hook 'my-coding-hook)
-
;; TODO: set up ri
;; TODO: electric
;; TODO: flymake
Please sign in to comment.
Something went wrong with that request. Please try again.