protesilaos / denote

Simple notes for Emacs with an efficient file-naming scheme
https://protesilaos.com/emacs/denote
GNU General Public License v3.0
500 stars 53 forks source link

A general way to exclude files matching regexp from dblocks and maybe more (was: Exclude keywords while using dblocks) #421

Open bioingenieroDiegol opened 2 weeks ago

bioingenieroDiegol commented 2 weeks ago

Hello! I've started using dblocks to help me write metanotes, but I'm having trouble filtering notes to exclude certain keyword. For example, I want to list notes that contain the word "-adventure", but exclude the ones with the keyword "_books". I tried first with regexp and then with RX notation without success, the result is always empty. This was my last attempt:

#+BEGIN: denote-links :regexp (rx (and (regexp ".*-adventure") (not (regexp ".*_books.*")))) :sort-by-component title :reverse-sort nil :id-only nil

#+END:

Is there any error on this expression? Is there any alternative or easier way to achieve this? Also, I'm not sure if this is the right place to ask for help.

Thanks a lot to Prot and contributors for this excellent package!

protesilaos commented 1 week ago

From: Diego Efe @.***> Date: Sun, 1 Sep 2024 11:21:41 -0700

Hello!

Hello there!

[... 7 lines elided]

#+BEGIN: denote-links :regexp (rx (and (regexp ".*-adventure") (not (regexp ".*_books.*")))) :sort-by-component title :reverse-sort nil :id-only nil

#+END:

Is there any error on this expression?

I am not familiar with the 'rx' notation. When I evaluate it though, it gives me this:

(error "Illegal argument to rx ‘not’: (regexp \".*_books.*\")")

Reading the documentation, this one is about characters or character classes. It will not work with arbitrary strings.

Is there any alternative or easier way to achieve this?

I am not sure. As far as I know, Elisp regular expressions do not have this kind of negation. If so, we need some other mechanism to make this happen, which is possible such as with an extra parameter to the dblock.

But we need to think about it before adding new features.

Also, I'm not sure if this is the right place to ask for help.

This is fine.

Thanks a lot to Prot and contributors for this excellent package!

You are welcome!

-- Protesilaos Stavrou https://protesilaos.com

protesilaos commented 6 days ago

I think what we need here is a more general way of specifying a :not-regexp in the dblock parameters. This would be a regular expression like the one for :regexp for files to filter out. I guess we have no better way of going about it.

[ And this will probably extend to denote-sort-dired, because there is where the retrieval and sorting happens. ]