Function: recentf-mode

recentf-mode is an autoloaded, interactive and byte-compiled function defined in recentf.el.gz.

Signature

(recentf-mode &optional ARG)

Documentation

Toggle keeping track of opened files (Recentf mode).

This mode maintains a list of recently opened files and makes it easy to visit them. The recent files list is automatically saved across Emacs sessions.

You can use recentf-open or recentf-open-files to visit files.

When Recentf mode is enabled, a "Open Recent" submenu is displayed in the "File" menu, containing a list of files that were operated on recently, in the most-recently-used order.

By default, only operations like opening a file, writing a buffer to a file, and killing a buffer is counted as "operating" on the file. If instead you want to prioritize files that appear in buffers you switch to a lot, you can say something like the following:

  (add-hook 'buffer-list-update-hook #'recentf-track-opened-file)

This is a global minor mode. If called interactively, toggle the Recentf mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate (default-value \=recentf-mode)'.

The mode's hook is called both when the mode is enabled and when it is disabled.

View in manual

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/recentf.el.gz
;;;###autoload
(define-minor-mode recentf-mode
  "Toggle keeping track of opened files (Recentf mode).
This mode maintains a list of recently opened files and makes it
easy to visit them.  The recent files list is automatically saved
across Emacs sessions.

You can use `recentf-open' or `recentf-open-files' to visit
files.

When Recentf mode is enabled, a \"Open Recent\" submenu is
displayed in the \"File\" menu, containing a list of files that
were operated on recently, in the most-recently-used order.

By default, only operations like opening a file, writing a buffer
to a file, and killing a buffer is counted as \"operating\" on
the file.  If instead you want to prioritize files that appear in
buffers you switch to a lot, you can say something like the following:

  (add-hook \\='buffer-list-update-hook #\\='recentf-track-opened-file)"
  :global t
  :group 'recentf
  :keymap recentf-mode-map
  (unless (and recentf-mode (recentf-enabled-p))
    (if recentf-mode
        (progn
          (recentf-load-list)
          (recentf-show-menu))
      (recentf-hide-menu)
      (recentf-save-list))
    (recentf-auto-cleanup)
    (let ((hook-setup (if recentf-mode 'add-hook 'remove-hook)))
      (dolist (hook recentf-used-hooks)
        (apply hook-setup hook)))))