mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 13:33:04 +00:00
tweaking rails snippets slightly
This commit is contained in:
parent
485f34921b
commit
ba638c28a1
@ -3,7 +3,8 @@
|
|||||||
;; stolen from rinari-mode's rinari-root
|
;; stolen from rinari-mode's rinari-root
|
||||||
(defun yas/rails-root (&optional dir)
|
(defun yas/rails-root (&optional dir)
|
||||||
(or dir (setq dir default-directory))
|
(or dir (setq dir default-directory))
|
||||||
(or yas/rails-root-cache
|
(or (and (featurep 'rinari) (rinari-root dir))
|
||||||
|
yas/rails-root-cache
|
||||||
(if (file-exists-p (expand-file-name
|
(if (file-exists-p (expand-file-name
|
||||||
"environment.rb" (expand-file-name "config" dir)))
|
"environment.rb" (expand-file-name "config" dir)))
|
||||||
(set (make-local-variable 'yas/rails-root-cache) dir)
|
(set (make-local-variable 'yas/rails-root-cache) dir)
|
||||||
@ -134,8 +135,9 @@
|
|||||||
(and (yas/rails-root)
|
(and (yas/rails-root)
|
||||||
(string-match "db/migrate/" default-directory)))
|
(string-match "db/migrate/" default-directory)))
|
||||||
|
|
||||||
(defun yas/rails-activate-maybe
|
(defun yas/rails-activate-maybe ()
|
||||||
(when (yas/rails-root)
|
(when (and yas/minor-mode
|
||||||
|
(yas/rails-root))
|
||||||
(set (make-local-variable 'yas/mode-symbol) 'rails-mode)))
|
(set (make-local-variable 'yas/mode-symbol) 'rails-mode)))
|
||||||
|
|
||||||
(defadvice cd (after yas/rails-on-cd-activate activate)
|
(defadvice cd (after yas/rails-on-cd-activate activate)
|
||||||
@ -144,4 +146,4 @@ are recognized. Stolen from `rinari-mode' more or`' less."
|
|||||||
(setq yas/rails-root-cache nil)
|
(setq yas/rails-root-cache nil)
|
||||||
(yas/rails-activate-maybe))
|
(yas/rails-activate-maybe))
|
||||||
|
|
||||||
(add-hook 'find-file-hook 'yas/rails-activate-maybe)
|
(add-hook 'yas/minor-mode-hook 'yas/rails-activate-maybe)
|
||||||
|
@ -4,4 +4,8 @@
|
|||||||
# name: Go to Controller
|
# name: Go to Controller
|
||||||
# binding: C-c g c
|
# binding: C-c g c
|
||||||
# --
|
# --
|
||||||
(call-interactively (find-file (concat (yas/rails-root) "/app/controllers")))
|
(if (featurep 'rinari)
|
||||||
|
(call-interactively 'rinari-find-controller)
|
||||||
|
(let ((default-directory (concat (yas/rails-root) "/app/controllers/")))
|
||||||
|
(call-interactively 'find-file )))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user