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

Exclude org-roam-dailies pages from consult-notes command #58

Open
deadcombo opened this issue Mar 14, 2024 · 3 comments
Open

Exclude org-roam-dailies pages from consult-notes command #58

deadcombo opened this issue Mar 14, 2024 · 3 comments

Comments

@deadcombo
Copy link

Hello,

I use the org-roam configuration you demonstrate in the readme.

I use org-roam-dailies a lot which means I have hundreds of daily files. This is cumbersome when calling consult-notes, the files are named with dates and there are a lot of them.
How can I exclude org-roam-dailies-directory from the consult-notes command?
I'd still like them to be covered by consult-notes-search-all-notes, just not the consult-notes.

@mclearc
Copy link
Contributor

mclearc commented Mar 15, 2024

Part of the function consult-notes-org-roam-mode involves adding these when the minor mode is activated:

         (add-to-list 'consult-notes-all-sources 'consult-notes-org-roam--nodes 'append)
         (add-to-list 'consult-notes-all-sources 'consult-notes-org-roam--refs 'append)

Have you tried adding advice to the minor mode to remove from consult-notes-all-sources the directory containing the daily files? This won't affect your search of all notes since that uses the value of org-roam-directory

@deadcombo
Copy link
Author

Would you give me a hand with that?

I had a go at:
(advice-add 'consult-notes-org-roam--nodes :after '(remove org-roam-dailies-directory '(consult-notes-all-sources)))

But that doesn't seem to do it. The output of consult-notes-org-roam--nodes is a bit more than I can handle.

@mclearc
Copy link
Contributor

mclearc commented Apr 11, 2024

I don't have org-roam to test this but @deadcombo I think what you'll need to do is modify the lambdas for :items to filter out nodes or refs based on their file location. So you'll want to swap in this:

:items ,(lambda () 
              (let* ((nodes (org-roam-node-read--completions))
                     (filtered-nodes (seq-filter (lambda (node)
                                                   (not (string-prefix-p org-roam-dailies-directory
                                                                         (org-roam-node-file (cdr node)))))
                                                 nodes)))
                (mapcar #'org-roam-node-title (mapcar #'cdr filtered-nodes))))
                

for what is there in consult-notes-org-roam--nodes. You'll need to apply a similar modification to the consult-notes-org-roam--refs var if refs are also stored in daily files you wish to exclude.

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

No branches or pull requests

2 participants