mclear-tools / consult-notes

Use consult to search notes
GNU General Public License v3.0
163 stars 15 forks source link

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

Open deadcombo opened 6 months ago

deadcombo commented 6 months ago

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 commented 6 months ago

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 commented 5 months ago

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 commented 5 months ago

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.