Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Added some rake functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Dec 8, 2008
1 parent 3967f4b commit b4aa114
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions starter-kit-ruby.el
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b4aa114

Please sign in to comment.