Does Ema开发者_JAVA技巧cs 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?
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)
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.
If you just want to save the minibuffer history between emacs invocations you can put the following in your .emacs:
(savehist-mode 1)
Unlike the desktop package that can save all your open buffers across invocations, this does just the minibuffer history (e.g. when opening a file you can use the up arrow to navigate the list of files you opened in a previous session).
GNU Emacs does include library recentf.el
, since Emacs 22. Just do as indicated by R.P. Dillon.
精彩评论