When using C-x C-F to open a file, pressing (up arrow) will iterate over the files I have recently opened. I believe the relevant lines from my ~/.emacs file are:

(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 50)

In any case, removing those lines empties my history (although the is still there, it complains about no items in history). If those are not the correct lines, you can see my entire .emacs file here.

How can I configure this so that if, after C-x C-F, I type foo and press , only those files in my history whose name starts with foo are displayed. In *nix shells, this can be done by adding the following lines to ~/.inputrc:

"\e[A": history-search-backward
"\e[B": history-search-forward

How can I get emacs to do the same?

1 Answer 1


You can use previous-complete-history-element and next-complete-history-element

To map to the Up and Down keys, use:

(define-key minibuffer-local-completion-map (kbd "<up>") 'previous-complete-history-element)
(define-key minibuffer-local-completion-map (kbd "<down>") 'next-complete-history-element)

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.