I'm trying out the dashboard package and noticed that my .org files kept getting added to the recentf list, because dashboard uses OrgMode to generate the agenda that it displays.

So I added code to dashboard that boils down to:

;; When rendering the dashboard, do the following:

;; if recentf mode is on, turn it off
;; so we don't add items to the Most Recently Used list:
    (if (recentf-enabled-p) (recentf-mode -1))

;; render the dashboard by rendering each widget

;; if recentf mode was originally on, turn it back on
;; this is pseudocode, of course :)
    (if (recentf-WAS-enabled-p) (recentf-mode))

This works (I'm not saving the information into my recentf list) but this also has the effect of saving my recentf list every time that I disable recentf-mode. This happens every time I switch back to the dashboard buffer.

My question: is there a way to disable recentf-modewithout flushing the list to disk?

What I'm really trying to do is temporarily get recentf-mode to stop recording new entries in the list - I'm only turning it off because there doesn't seem to be another way to do that.

1 Answer 1


You can let-bind find-file-hook to prevent Recentf from recording the file, e.g.,

(let ((find-file-hook (remq 'recentf-track-opened-file find-file-hook)))
  (find-file "test.txt"))

Then to bypass Recentf during M-x org-agenda, use this:

(define-advice org-agenda (:around (old-fun &rest args) skip-recentf)
  (let ((find-file-hook (remq 'recentf-track-opened-file find-file-hook)))
    (apply old-fun args)))

I don't know about Dashboard, but I think the same technique should work, maybe simply replacing org-agenda with dashboard-get-agenda.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.