Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add predicate to exclude open files from being added to recentf #5280

Closed
wants to merge 1 commit into from

Conversation

punassuming
Copy link
Contributor

Fixes #4973 , recentf will no longer add files to the list that have never been viewed.

@punassuming
Copy link
Contributor Author

This should clear all the org files loading from org-agenda and any other major mode that loads files for information without the intent to view them. Because we are taking a snapshot of the recentf-list at init to keep the files that were not viewed this session, it might take clearing the recentf-list completely to get the non-viewed files off the list.

(spacemacs//file-was-viewed-p file))))

;; And, of course, you now need:
(setf recentf-keep '(spacemacs//recentf-viewed-predicate)))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why setf and not add-to-list? By overriding the existing value, we risk interfering with user's personal configuration.

@caikechao
Copy link
Contributor

Maybe I met a new issue here or maybe not. But I'd like to ask you guys first ...

If I set the dotspacemacs-startup-lists as follows,

   dotspacemacs-startup-lists '(agenda recents bookmarks projects)

then the recentf-exclude variable will be reset to nil (originally, spacemacs sets it to be ("COMMIT_EDITMSG\\'" "/home/user/.emacs.d/elpa" "/home/user/.emacs.d/.cache/")

But if I change the order of the startup list like as follows,

   dotspacemacs-startup-lists '(recents agenda bookmarks projects)

then the recentf-exclude will be the default value set by spacemacs.

I don't know why this happened... I really want the agenda list to be at the top of the home buffer without affecting the recentf-exclude set by spacemacs ... Could you help?

@punassuming
Copy link
Contributor Author

@bmag, awesome I didn't realize recentf-keep accepted lists of funcs. Will update the PR.

@punassuming
Copy link
Contributor Author

@kccai, is this after applying this PR, or in the current develop branch?

@caikechao
Copy link
Contributor

@Ralesi
I am in the current develop branch, not applying this PR. Hoping that this PR could solve this problem. Thanks~

@punassuming
Copy link
Contributor Author

@bmag, I updated with your suggestions, much better just adding to the recentf-keep list. Thanks.

@punassuming
Copy link
Contributor Author

@kccai , I do not see the same issue as you. Perhaps you can make an issue with the steps to repo?

@caikechao
Copy link
Contributor

@Ralesi Thanks, I will check it again and create an issue if this problem persists.

@punassuming punassuming changed the title Update recentf predicate to exclude non-viewed files. Update recentf predicate to exclude non-viewed files. [WIP] Mar 1, 2016
@punassuming
Copy link
Contributor Author

I am finding that org files are still being added, testing out applying changes as an exclude predicate.

@syl20bnr
Copy link
Owner

What's the status on this PR ?

@punassuming
Copy link
Contributor Author

@syl20bnr, I have got it working, but if agenda is listed before recent files in the startup list, the org files still get added. Will get it fixed and update the PR tonight.

@syl20bnr
Copy link
Owner

@Ralesi thank you 👍

@punassuming
Copy link
Contributor Author

@syl20bnr , I take that back. I cannot come up with a method to keep the recentf-list clean during startup. The method with the predicate works, but requires one to run recentf-cleanup after load, which is enough of a preference that I don't think it should be added to one of the default hooks. Optimally, we would have an exclusion predicate placed on recentf-exclude if the opened file is not viewed, but that hook runs right after after-find-file and the buffer is not completely set by set-window, which is what increments the buffer display counter.

If anyone else has other ideas to get this to work consistently with the additional org file loading at startup, I would be open to ideas.

@punassuming punassuming changed the title Update recentf predicate to exclude non-viewed files. [WIP] Add predicate to exclude open files from being added to recentf Jun 27, 2016
@punassuming
Copy link
Contributor Author

@syl20bnr, i updated and the current implementation works for me. I created a variable that will bypass recentf saving if let bound. I have also bound it on my call to org-refile in my own config to prevent that function from adding all the org files to my recent list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants