org-ql icon indicating copy to clipboard operation
org-ql copied to clipboard

Nil queries should match nothing

Open Gleek opened this issue 3 years ago • 3 comments

Hello, I've some commands that run on org-agenda-finalize-hook that I don't want to run when I execute org-ql-search. The way I'm thinking of doing this is something like this

(add-hook 'org-agenda-finalize-hook
          (lambda() 
            (unless (org-ql-view)
              (my-custom-agenda-modifications))))

I've just started exploring this project so it is most likely a miss, in reading the code, at my end.

I only see these local variables that can possibly be used for the purpose

(defvar-local org-ql-view-buffers-files nil)
(defvar-local org-ql-view-query nil)
(defvar-local org-ql-view-sort nil)
(defvar-local org-ql-view-narrow nil)
(defvar-local org-ql-view-super-groups nil)
(defvar-local org-ql-view-title nil)

Is there any simpler and more direct way of achieving this?

Thank you :)

Gleek avatar Jun 21 '21 16:06 Gleek

Hi,

Yes, for now, testing one of those variables would be the way to do it. (There will probably be an org-ql-view-mode someday.) The variable org-ql-view-query should always be non-nil in an org-ql-view buffer, so testing that should do the job.

alphapapa avatar Jun 21 '21 23:06 alphapapa

Alright, thanks. Will use these variables.

The variable org-ql-view-query should always be non-nil in an org-ql-view buffer

I actually was able to make the query nil (to look at all my items which are grouped/sorted by some metric, for eg), in the search view so was wondering if that was the way to go forward. I think a safer check might be to check the org-ql-view-buffers-files variable instead.

Anyways, thank you for clarifying. Also thank you for sharing this package :). It seems to have unlocked so more much potential in org, at least for me.

Gleek avatar Jun 22 '21 05:06 Gleek

I actually was able to make the query nil (to look at all my items which are grouped/sorted by some metric, for eg), in the search view so was wondering if that was the way to go forward. I think a safer check might be to check the org-ql-view-buffers-files variable instead.

Hm, a nil query should not match anything; if you want to match everything, you should use t. I guess I've never tested nil as the query before.

Anyways, thank you for clarifying. Also thank you for sharing this package :). It seems to have unlocked so more much potential in org, at least for me.

Thanks for the kind words. I'm glad it's useful to you.

alphapapa avatar Jul 08 '21 06:07 alphapapa