Tags
webcam vindaloo version vegan unix unicef trojan todo thinkpad textmate testing tagging syntax svn sugar subversion stubbing sphinx spam spaces solaris sitemap site sinatra shoulda sheet set security search schema_info SchemaInfo ruby rinari restaurant relationships refresh rdiff-backup ramaze railsconf08 railsconf07 rails protools production power placeboeffect pink floyd PIC perl overheat outbreak osx os x NYHS NYC nginx netbeans nested nanophotonics mysql music MPEG-4 mongrel model migration microvolunteer macbook mac logrotate logic log linux less leopard keynote JAX javascript java jacksonville imunizator highlighting hanna Handbrake haml hacks google geocoding genghistron gem gaming gabrielle's funny functional fun friends food fixes fixed firefox FF3 ferretThe Fixer said over 2 years ago permalink Comment? (0)
Tagged: emacs rinari
Rinari fixes
I’m using Rinari for editing Rails in Emacs, but the current trunk in svn is … slightly broken and hasn’t been maintained in a bit.
Here are a couple of fixes to it that I’ve been using recently. This reverts the switch-to-view shortcut key to something that isn’t stubbed out, and also makes the switch-to-view look for .haml files in additional to .rhtml files. I suppose it should look for .erb as well, but since we’re not using that convention (yet), I haven’t been motivated to add that in.
===================================================================
--- rinari.el (revision 96)
+++ rinari.el (working copy)
@@ -45,11 +45,21 @@
(defun rinari-find-view ()
(interactive)
- (let* ((funname (which-function))
- (cls (rinari-make-dirname (rinari-name-components funname)))
- (fn (and (string-match "#\(.*\)" funname) (match-string 1 funname)))
- (railsdir (rails-root (directory-file-name (file-name-directory (buffer-file-name))))))
- (find-file (concat railsdir "/app/views/" cls "/" fn ".rhtml"))))
+ (let* (basename
+ (funname (which-function))
+ (cls (rinari-make-dirname (rinari-name-components funname)))
+ (fn (and (string-match "#\(.*\)" funname) (match-string 1 funname)))
+ (railsdir (rails-root (directory-file-name (file-name-directory (buffer-file-name))))))
+ (setq basename (concat railsdir "/app/views/" cls "/" fn))
+ (if (file-exists-p (concat basename ".haml"))
+ (find-file (concat basename ".haml"))
+ (if (file-exists-p (concat basename ".rjs"))
+ (find-file (concat basename ".rjs"))
+ (if (file-exists-p (concat basename ".rhtml"))
+ (find-file (concat basename ".rhtml"))
+ (find-file (concat basename ".haml"))
+ )))
+ ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; find-file-in-project
@@ -169,7 +179,7 @@
(define-key ruby-mode-map
"\C-c\C-s" 'rinari-console)
(define-key ruby-mode-map
- "\C-c\C-v" (lambda () (interactive) (toggle-buffer 'rails-view)))
+ "\C-c\C-v" 'rinari-find-view)
(define-key ruby-mode-map
"\C-c\C-t" 'toggle-buffer)
(define-key ruby-mode-map
Index: rhtml/rhtml-mode.el
===================================================================
--- rhtml/rhtml-mode.el (revision 96)
+++ rhtml/rhtml-mode.el (working copy)
@@ -54,11 +54,14 @@
(rhtml-activate-fontification))
(add-to-list 'auto-mode-alist '("\.rhtml$" . rhtml-mode))
+(add-to-list 'auto-mode-alist '("\.rjs$" . rhtml-mode))
(define-key ruby-mode-map
"\C-c\C-v" (lambda () (interactive) (toggle-buffer 'rails-view)))
(define-key rhtml-mode-map
"\C-c\C-b" 'rinari-find-by-context)
+(define-key rhtml-mode-map
+ "\C-c\C-v" 'rhtml-find-action)
(defun extract-partial (begin end partial-name)
(interactive "r\nsName your partial: ")