Harry R. Schwartz

Code writer, sometime Internet enthusiast, attractive nuisance.

The author at the Palais du Luxembourg in Paris, November 2022. hacker news gitlab sourcehut pinboard librarything 1B41 8F2C 23DE DD9C 807E A74F 841B 3DAE 25AE 721B

Vancouver

British Columbia

Canada

vegan


Opening Your Last Rails Migration in Emacs

hrs

Published .
Tags: emacs, rails.

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: