When I use helm-projectile-recentf, it shows the currently open buffer in the list. Any way to not have it do that?;)

Also, it seems to look at file modification, so if I just had a buffer open and didn't change it, it doesn't put it on the top of the list. Any way to make it do that?;)

1 Answer 1


There doesn't seem to be an option for exclusion, so I made a filter function, HTH.

;; remove `projectile-project-root` from full path to match relative path in `projectile-recentf-files`
(defun strip-project-root (name)
  (replace-regexp-in-string (concat "^" (projectile-project-root)) "" name))

;; create a filter to return `projectile-recentf-files` - `buffer-list`
(defun my-projectile-recentf-files (list)
  "A filter to exclude currently open buffer from the original projectile-recentf-files."
  (let* ((buflist (mapcar 'strip-project-root (remove nil (mapcar 'buffer-file-name (buffer-list)))))
         (newlist list))
    (while buflist
      (setq newlist (remove (car buflist) newlist))
      (setq buflist (cdr buflist)))

;; put the filter after the original `projectile-recentf-files`
(eval-after-load 'projectile
  (advice-add 'projectile-recentf-files :filter-return #'my-projectile-recentf-files))
  • Thanks for this and sorry for taking ages to respond. This works perfectly;) Dec 21, 2023 at 11:20

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.