Opening Your Last Rails Migration in Emacs
I was pairing with a Vim user the other day, and I noticed that he had a nifty shortcut (from rails.vim?) to open up the last Rails migration.
Emacs being Emacs, I decided to implement it myself.
(defun visit-last-dired-file ()
"Open the last file in an open dired buffer."
(interactive)
(end-of-buffer)
(previous-line)
(dired-find-file))
(defun visit-last-migration ()
"Open the last file in 'db/migrate/'."
(interactive)
(dired (expand-file-name "db/migrate" (projectile-project-root)))
(visit-last-dired-file)
(kill-buffer "migrate"))
Just run that with M-x visit-last-migration
and it’ll summon up your
last migration. I haven’t bothered binding it to a key, since I don’t
really need it that often.
It’s a bit of a hack, and it depends on projectile-mode, so if you have an alternate solution I’d sure appreciate an email or pull request!
You might like these textually similar articles: