260 |
:group 'recentf |
:group 'recentf |
261 |
:type 'hook) |
:type 'hook) |
262 |
|
|
263 |
(defcustom recentf-filename-handler nil |
(defcustom recentf-filename-handlers nil |
264 |
"Function to call to process filename handled by recentf. |
"Functions to post process recent file names. |
265 |
It is passed a filename to give a chance to transform it. |
They are successively passed a file name to transform it." |
|
If it returns nil, the filename is left unchanged." |
|
266 |
:group 'recentf |
:group 'recentf |
267 |
:type '(choice (const :tag "None" nil) |
:type '(choice |
268 |
(const abbreviate-file-name) |
(const :tag "None" nil) |
269 |
function)) |
(repeat :tag "Functions" |
270 |
|
(choice |
271 |
|
(const file-truename) |
272 |
|
(const abbreviate-file-name) |
273 |
|
(function :tag "Other function"))))) |
274 |
|
|
275 |
(defcustom recentf-show-file-shortcuts-flag t |
(defcustom recentf-show-file-shortcuts-flag t |
276 |
"Whether to show ``[N]'' for the Nth item up to 10. |
"Whether to show ``[N]'' for the Nth item up to 10. |
365 |
(and m (setq recentf-list (delq (car m) recentf-list))) |
(and m (setq recentf-list (delq (car m) recentf-list))) |
366 |
(push filename recentf-list))) |
(push filename recentf-list))) |
367 |
|
|
368 |
|
(defun recentf-apply-filename-handlers (name) |
369 |
|
"Apply `recentf-filename-handlers' to file NAME. |
370 |
|
Return the transformed file name, or NAME if any handler failed, or |
371 |
|
returned nil." |
372 |
|
(or (condition-case nil |
373 |
|
(let ((handlers recentf-filename-handlers) |
374 |
|
(filename name)) |
375 |
|
(while (and filename handlers) |
376 |
|
(setq filename (funcall (car handlers) filename) |
377 |
|
handlers (cdr handlers))) |
378 |
|
filename) |
379 |
|
(error nil)) |
380 |
|
name)) |
381 |
|
|
382 |
(defsubst recentf-expand-file-name (name) |
(defsubst recentf-expand-file-name (name) |
383 |
"Convert filename NAME to absolute, and canonicalize it. |
"Convert file NAME to absolute, and canonicalize it. |
384 |
See also the function `expand-file-name'. |
NAME is first passed to the function `expand-file-name', then to |
385 |
If defined, call the function `recentf-filename-handler' |
`recentf-filename-handlers' to post process it." |
386 |
to post process the canonical name." |
(recentf-apply-filename-handlers (expand-file-name name))) |
|
(let* ((filename (expand-file-name name))) |
|
|
(or (and recentf-filename-handler |
|
|
(funcall recentf-filename-handler filename)) |
|
|
filename))) |
|
387 |
|
|
388 |
(defun recentf-include-p (filename) |
(defun recentf-include-p (filename) |
389 |
"Return non-nil if FILENAME should be included in the recent list. |
"Return non-nil if FILENAME should be included in the recent list. |
449 |
;;; Menu building |
;;; Menu building |
450 |
;; |
;; |
451 |
(defvar recentf-menu-items-for-commands |
(defvar recentf-menu-items-for-commands |
452 |
(list ["Cleanup list" |
(list |
453 |
recentf-cleanup |
["Cleanup list" |
454 |
:help "Remove all excluded and non-kept files from the recent list" |
recentf-cleanup |
455 |
:active t] |
:help "Remove duplicates, and obsoletes files from the recent list" |
456 |
["Edit list..." |
:active t] |
457 |
recentf-edit-list |
["Edit list..." |
458 |
:help "Edit the files that are kept in the recent list" |
recentf-edit-list |
459 |
:active t] |
:help "Manually remove files from the recent list" |
460 |
["Save list now" |
:active t] |
461 |
recentf-save-list |
["Save list now" |
462 |
:help "Save the list of recently opened files now" |
recentf-save-list |
463 |
:active t] |
:help "Save the list of recently opened files now" |
464 |
["Options..." |
:active t] |
465 |
(customize-group "recentf") |
["Options..." |
466 |
:help "Customize recently opened files menu and options" |
(customize-group "recentf") |
467 |
:active t] |
:help "Customize recently opened files menu and options" |
468 |
) |
:active t] |
469 |
|
) |
470 |
"List of menu items for recentf commands.") |
"List of menu items for recentf commands.") |
471 |
|
|
472 |
(defvar recentf-menu-filter-commands nil |
(defvar recentf-menu-filter-commands nil |
1250 |
recentf-list)))))) |
recentf-list)))))) |
1251 |
|
|
1252 |
(defun recentf-cleanup () |
(defun recentf-cleanup () |
1253 |
"Remove all non-kept and excluded files from the recent list." |
"Cleanup the recent list. |
1254 |
|
That is, remove duplicates, non-kept, and excluded files." |
1255 |
(interactive) |
(interactive) |
1256 |
(message "Cleaning up the recentf list...") |
(message "Cleaning up the recentf list...") |
1257 |
(let ((n 0) newlist) |
(let ((n 0) newlist) |
1258 |
(dolist (f recentf-list) |
(dolist (f recentf-list) |
1259 |
|
(setq f (recentf-expand-file-name f)) |
1260 |
(if (and (recentf-include-p f) |
(if (and (recentf-include-p f) |
1261 |
(recentf-keep-p f)) |
(recentf-keep-p f) |
1262 |
|
(not (recentf-string-member f newlist))) |
1263 |
(push f newlist) |
(push f newlist) |
1264 |
(setq n (1+ n)) |
(setq n (1+ n)) |
1265 |
(message "File %s removed from the recentf list" f))) |
(message "File %s removed from the recentf list" f))) |