summaryrefslogtreecommitdiff
path: root/recentf-conf.el
blob: f9e2c84869e2b97a51e097b424f0d489940aa002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
;;; recentf-conf.el --- My configurations concerning recentf -*- lexical-binding: t; -*-

(require 'recentf)

(set 'recentf-save-file (expand-file-name "recentf" load-file-directory))

(recentf-mode 1)

(defun file-exists-or-remote-p (filename)
  "Return t if file FILENAME exists or is a remote file.
If this file is remote, as determined by `file-remote-p', then
this returns t.

Otherwise, this returns the result of `file-exists-p'."
  (cond ((file-remote-p filename) t) ((file-exists-p filename))))

;;;###autoload
(defun choose-recent-file ()
  "Choose a recently visited file to visit.
This uses `completing-read' to choose a file from `recentf-list'."
  (interactive)
  (let ((choice (completing-read "Choose a recently visited file: "
                                 recentf-list
                                 #'file-exists-or-remote-p t)))
    (find-file choice)))