Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Open Recent" in Emacs

Tags:

emacs

Does Emacs have the capability to open recent files (e.g. a menu like File > Open Recent...)?

I know that Aquamacs, for OS X, has this feature. But is it common to all Emacs versions?

like image 551
prosseek Avatar asked Aug 19 '10 23:08

prosseek


2 Answers

The most idiomatic method of providing this functionality that I know of is through the use of recentf-mode (more here). I enable it in my initialization file with:

(require 'recentf)

(recentf-mode 1)

It then provides an interactive function, recentf-open-files, which I bind to C-x f, which provides a numbered menu of recently opened files that spans sessions, i.e. even if you shut down emacs and restart it, it will retain your recently opened files. You can bind the function to an accelerator with another line in your initialization file, like:

(global-set-key "\C-xf" 'recentf-open-files)

(Optional)

If you make extensive use of Tramp, recentf will track those files too, and do it's periodic cleanup thing which can be a real mess since the files are remote. Prevent this by putting this in your startup file:

(setq recentf-auto-cleanup 'never)

like image 102
R. P. Dillon Avatar answered Sep 17 '22 19:09

R. P. Dillon


Ordinary GNU Emacs doesn't have a menu showing recently open files. However, all Emacs commands have history, including find-file (C-x C-f). Selecting “File | Open” in the menu or opening a file with emacsclient also adds to this history. After you press C-x C-f, press up and down to navigate the history of opened files.

The history is saved between sessions if you enable session saving with the desktop package.

like image 32
Gilles 'SO- stop being evil' Avatar answered Sep 19 '22 19:09

Gilles 'SO- stop being evil'