I'd like to make the size of the emacs command history unlimited. I open and edit too many files in many different folders and I need a way to keep track of them. The emacs command history looks like a good place to do that. How can I do that?

2 Answers 2


I don't know if there's a command history proper, but there's a minibuffer history. The manual says the following about it:

Every argument that you enter with the minibuffer is saved in a “minibuffer history list” so you can easily use it again later.


Emacs keeps separate history lists for several different kinds of arguments. For example, there is a list for file names, used by all the commands that read file names. Other history lists include buffer names, command names (used by ‘M-x’), and command arguments (used by commands like ‘query-replace’).

The file of file names is what you want. About the length of these lists:

The variable ‘history-length’ specifies the maximum length of a minibuffer history list; adding a new element deletes the oldest element if the list gets too long. If the value is ‘t’, there is no maximum length.

So you can achieve that by adding the following line in you init file:

(setq history-length t)

Your original post sounds like an XY problem: you want to keep track of lots of buffers and files (the real issue), and you wonder if the command history would be a good way to do that.

Depending on your needs (hard to tell from the original post), try using:

  • Thank you for the answer. The need should be evident: Keeping history of all files I've opened in Emacs. Emacs seems to have a limit on that, which is 10 items or so, which was way too low for me. (setq history-length t) solved the issue. Thanks.
    – Terry
    Jul 14, 2017 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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