;; Unavailable until recentf has been loaded.
(recentf-auto-cleanup))))
-(defcustom recentf-initialize-file-name-history t
- "Non-nil means to initialize `file-name-history' with the recent list.
-If `file-name-history' is not empty, do nothing."
- :group 'recentf
- :type 'boolean)
-
-(defcustom recentf-load-hook nil
- "Normal hook run at end of loading the `recentf' package."
- :group 'recentf
- :type 'hook)
-(make-obsolete-variable 'recentf-load-hook
- "use `with-eval-after-load' instead." "28.1")
-
(defcustom recentf-filename-handlers '(abbreviate-file-name)
"Functions to post process recent file names.
They are successively passed a file name to transform it."
:group 'recentf
:type 'boolean)
-(defcustom recentf-show-messages t
- "Whether to show verbose messages about low-level recentf actions.
-nil means to not show messages related to the recentf machinery.
-t means show messages that were printed by default on Emacs <= 31.1."
- :group 'recentf
- :type 'boolean
- :version "31.1")
\f
;;; Utilities
;;
(setq list (cdr list)))
list)
-(defun recentf-dump-variable (variable &optional limit)
- "Insert a \"(setq VARIABLE value)\" in the current buffer.
-When the value of VARIABLE is a list, optional argument LIMIT
-specifies a maximum number of elements to insert. By default insert
-the full list."
- (let ((value (symbol-value variable)))
- (if (atom value)
- (insert (format "\n(setq %S '%S)\n" variable value))
- (when (and (integerp limit) (> limit 0))
- (setq value (seq-take value limit)))
- (insert (format "\n(setq %S\n '(" variable))
- (dolist (e value)
- (insert (format "\n %S" e)))
- (insert "\n ))\n"))))
-
(defvar recentf-auto-cleanup-timer nil
"Timer used to automatically cleanup the recent list.
See also the option `recentf-auto-cleanup'.")
";;; Automatically generated by `recentf' on %s. -*- mode: lisp-data -*-\n"
"Header to be written into the `recentf-save-file'.")
-(defconst recentf-save-file-coding-system
- (if (coding-system-p 'utf-8-emacs)
- 'utf-8-emacs
- 'emacs-mule)
- "Coding system of the file `recentf-save-file'.")
-
(defun recentf-save-list ()
"Save the recent list.
Write data into the file specified by `recentf-save-file'."
(interactive)
- (condition-case error
- (with-temp-buffer
- (erase-buffer)
- (set-buffer-file-coding-system recentf-save-file-coding-system)
- (insert (format-message recentf-save-file-header
- (current-time-string)))
- (recentf-dump-variable 'recentf-list recentf-max-saved-items)
- (recentf-dump-variable 'recentf-filter-changer-current)
- (insert "\n\f\n;; Local Variables:\n"
- (format ";; coding: %s\n" recentf-save-file-coding-system)
- ";; End:\n")
- (write-region (point-min)
- (point-max)
- (expand-file-name recentf-save-file) nil
- (unless (or (called-interactively-p 'interactive)
- recentf-show-messages)
- 'quiet))
- (when recentf-save-file-modes
- (set-file-modes recentf-save-file recentf-save-file-modes))
- nil)
- (error
- (warn "recentf mode: %s" (error-message-string error)))))
+ (with-temp-buffer
+ (insert (format-message recentf-save-file-header (current-time-string)))
+ (prin1 (take recentf-max-saved-items recentf-list) (current-buffer))
+ (write-region
+ (point-min) (point-max) (expand-file-name recentf-save-file) nil 'quiet)
+ (when recentf-save-file-modes
+ (set-file-modes recentf-save-file recentf-save-file-modes))))
(defun recentf-load-list ()
"Load a previously saved recent list.
;; We do not want Tramp asking for passwords.
(non-essential t))
(when (file-readable-p file)
- (load-file file)
- (and recentf-initialize-file-name-history
- (not file-name-history)
- (setq file-name-history (mapcar #'abbreviate-file-name
- recentf-list))))))
+ (setq recentf-list (with-temp-buffer
+ (insert-file-contents file)
+ (goto-char (point-min))
+ (read (current-buffer)))))))
(defun recentf-cleanup ()
"Cleanup the recent list.
That is, remove duplicates, non-kept, and excluded files."
(interactive)
- (message "Cleaning up the recentf list...")
(let ((n 0)
(ht (make-hash-table
:size recentf-max-saved-items
(progn
(push f newlist)
(puthash key t ht))
- (setq n (1+ n))
- (message "File %s removed from the recentf list" f)))
- (message "Cleaning up the recentf list...done (%d removed)" n)
+ (setq n (1+ n))))
(setq recentf-list (nreverse newlist))))
+
\f
;;; The minor mode
;;
;; continue standard unloading
nil)
-;; Obsolete.
-
-(define-obsolete-function-alias 'recentf-trunc-list #'seq-take "28.1")
-
-(defun recentf-elements (n)
- "Return a list of the first N elements of the recent list."
- (declare (obsolete "use `(seq-take recentf-list n)'." "29.1"))
- (seq-take recentf-list n))
-
(provide 'recentf)
-
-(run-hooks 'recentf-load-hook)
-
;;; recentf.el ends here