Skip to content

Commit

Permalink
rails-ruby.el: added flymake support to on the fly syntax check in ru…
Browse files Browse the repository at this point in the history
…by-mode

rails-test.el (rails-test:error-regexp-alist): updated


git-svn-id: svn+ssh://rubyforge.org/var/svn/emacs-rails/trunk@157 cc5033d0-740f-0410-afc7-949910e492f2
  • Loading branch information
dimaexe committed Apr 2, 2007
1 parent 2b59e9f commit 2bf7edd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2007-04-03 Dmitry Galinsky <[email protected]>

* rails-ruby.el: added flymake support to on the fly syntax check in ruby-mode

* rails-test.el (rails-test:error-regexp-alist): updated

2007-04-02 Dmitry Galinsky <[email protected]>

* rails-lib.el (merge-abbrev-tables): mark abbrev as system
Expand Down
4 changes: 4 additions & 0 deletions History
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
SVN
* Updated the compilation output, for better highlight of error and warnings
* Added the flymake support to on the fly syntax checked in the ruby-mode

0.5.99.2
* Added new dynamic snippets for RESTful,
for instance: in controller UsersController type "rshow<TAB>"
Expand Down
2 changes: 1 addition & 1 deletion rails-compat.el
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ save."
(untabify (point-min) (point-max))
(delete-trailing-whitespace)))) nil t)))

(provide 'rails-compat)
(provide 'rails-compat)
31 changes: 31 additions & 0 deletions rails-ruby.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,37 @@ See the variable `align-rules-list' for more details.")
(dolist (it ruby-align-rules-list)
(add-to-list 'align-rules-list it))

;; setup flymake for ruby
(require 'flymake)

(defconst flymake-allowed-ruby-file-name-masks
'((".rb" flymake-ruby-init)
(".rxml" flymake-ruby-init)
(".rjs" flymake-ruby-init))
"Filename extensions that switch on flymake-ruby mode syntax checks.")

(defconst flymake-ruby-error-line-pattern-regexp
'("^\\([^:]+\\):\\([0-9]+\\): *\\([\n]+\\)" 1 2 nil 3)
"Regexp matching ruby error messages.")

(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list rails-ruby-command (list "-c" local-file))))

(defun flymake-ruby-load ()
(setq flymake-allowed-file-name-masks (append flymake-allowed-file-name-masks flymake-allowed-ruby-file-name-masks))
(setq flymake-err-line-patterns (cons flymake-ruby-error-line-pattern-regexp flymake-err-line-patterns))
(flymake-mode t)
(local-set-key (kbd "\C-c d") 'flymake-display-err-menu-for-current-line))

(add-hook 'ruby-mode-hook 'flymake-ruby-load)

;; other stuff

(defun ruby-newline-and-indent ()
(interactive)
(newline)
Expand Down
11 changes: 4 additions & 7 deletions rails-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
"^[\\.EF]+$")

(defconst rails-test:error-regexp-alist
'((rails-test-failure
" \\[\\([^:\n]+\\):\\([0-9]+\\)\\]:" 1 2)
(rails-test-trace
" \\(\\(\\w:\\)?[^: \n]+\\):\\([0-9]+\\):in " 1 3 nil 0)
'((rails-test-trace
"\\(\\(\\.\\|[A-Za-z]:\\)?\\([a-z0-9_\/\\.]+\\.rb\\)\\):\\([0-9]+\\)" 1 4 nil 0)
(rails-test-error
" \\(\\(\\w:\\)?[^: \n]+\\):\\([0-9]+\\)\\(:in .+\\)?\n$" 1 2)))
"\\(\\(\\.\\|[A-Za-z]:\\)?\\([a-z0-9_\/\\.]+\\.rb\\)\\):\\([0-9]+\\).*\n$" 1 4 nil 2)))

(defun rails-test:print-result ()
(with-current-buffer (get-buffer rails-script:buffer-name)
Expand Down Expand Up @@ -81,8 +79,7 @@
(set (make-local-variable 'compilation-error-regexp-alist-alist)
rails-test:error-regexp-alist)
(set (make-local-variable 'compilation-error-regexp-alist)
'(rails-test-failure
rails-test-error
'(rails-test-error
rails-test-trace))
(add-hook 'after-change-functions 'rails-test:print-progress nil t)
(add-hook 'rails-script:run-after-stop-hook 'rails-test:print-result nil t)
Expand Down

0 comments on commit 2bf7edd

Please sign in to comment.