A Key Sequence For revert-buffer

The other day I was trawling through Aaron Hawley's excellent Emacs Reference Sheet and came across the entry for【Ctrl+x Ctrl+v Return】saying “same as previous.” The previous entry was for revert-buffer. My first thought was “How did I not know this?” I use revert-buffer a lot when I'm syncing files between computers with Git so this would really be useful to me. My next thought was, “Gee, I should blog about this.”

I remembered that every time I call revert-buffer it tells me that I can run it with【Super+u】 as well as with a menu. I always ignored these because I don't have a 【Super】 key and I avoid using the menu interface. Why didn't it tell me about the much easier【Ctrl+x Ctrl+v】? So I called【Ctrl+h k Ctrl+x Ctrl+v】to see what it said. Of course, it said that【Ctrl+x Ctrl+v】runs find-alternate-file (actually ido-find-alternate-file in my case), something I already knew but forgot in the excitement of discovering something new. I was disappointed that my discovery didn't work out. I thought that Hawley must have made a typo.

Today, I came across the same entry and this time I noticed that 【Return】 at the end of the 【Ctrl+x Ctrl+v】. Suddenly, it all made sense. The 【Ctrl+x Ctrl+vdoes run find-alternate-file and the 【Return】 selects the current buffer's file so the result the same as revert-buffer.

This is another one of those small things about Emacs that doesn't seem like much but does, in fact, make my life easier. It was there all the time if I'd had the wits to see it. Fortunately, I had Hawley to help me see the light.

This entry was posted in General and tagged . Bookmark the permalink.
  • bitti

    If you try to change a buffer who's content on disk has changed, emacs will normally interrupt you and give you the options y, n, r and C-h. r means revert, therefore just typing 'rr' in an changed buffer will revert it.

    Another option is using auto-revert-mode. Even though I don't have the guts to turn it on globally I found it kinda nice when viewing regularly changed PDFs in emacs (e.g. when editing graphviz dot files).

  • Erez

    I use global-auto-revert-mode and it saves me a ton of hassle, as almost everything I work on is in git repo. But I do glad you came into this, as this will solve the other 5% of files auto-revert-mode fails to revert

  • Sam

    The EmacWiki's page is also quite interesting:

    Thank you for the juicy blog!

  • Francesco

    Thanks for the tip. I always wondered if there was any faster way to auto-revert than M-x auto-revert.

    On a side note, since reverting git-controlled files seems to be your common use case, here is a snippet I use to automatically activate auto-revert-mode for version controlled files :

    ;; Auto-revert-mode for version-controlled files
    (defadvice vc-find-file-hook (after auto-revert-mode-for-vc activate)
    "vc-find-file-hook advice for activating auto-revert-mode"
    (when vc-mode (auto-revert-mode 1)))

  • Fimbles

    I use to use [Ctrl-x TAB y] for reverting buffer which works well too.