I open Emacs from the command line to inspect 10+ files, say like this:

emacs *.java

However, all the files are listed in reverse order. This is getting kind of annoying--I'd like to start with the A files, not the Z files. Is there any way to just reverse all the buffers? Or even better, a command-line option that opens the files in reverse order, so that Emacs has them the right way around? (Without explicitly typing in every file.)


They're "visited" in the order given, and the buffer list you see sorts them (by default) by order of "recency". But you can sort them some other way, such as alphabetically: move the cursor into the column of buffer names and press S to sort them by their name.

I found this solution in the following way: - C-h m showed me the description of buffer-menu-mode. - In that description C-s sort told me there's no sorting option specific to that mode, but C-s parent showed this mode derives from tabulated-list-mode, so I clicked on this name to find the doc of that parent mode. - C-s sort C-s to find that S is bound to tabulated-list-sort which does the trick.

| improve this answer | |
  • 1
    I'm not convinced that the OP is looking at the buffer list: my guess is that he is just seeing the buffer of the last file in the command-line sequence as the current buffer and he would like to see the buffer of the first file instead; then killing a buffer should reveal the buffer of the next file in the sequence. – NickD Jun 15 at 6:36
  • I'm not sure I follow; isn't C-s just a search function? Killing a buffer does indeed reveal the next buffer. It's not that I can't find a given file, it's that they're in a really wonky order. I'd like to alphabetize the buffers, so that when I move between them (say with C-x (arrow)) I get the next file alphabetically. – Adam Smith Jun 16 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.