alphapapa / org-ql

A searching tool for Org-mode, including custom query languages, commands, saved searches and agenda-like views, etc.
GNU General Public License v3.0
1.4k stars 110 forks source link

Respect org-agenda-hide-tags-regexp in org-ql views #417

Closed ParetoOptimalDev closed 3 weeks ago

ParetoOptimalDev commented 7 months ago

OS/platform

NixOS

Emacs version and provenance

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0) NixOS using https://github.com/nix-community/emacs-overlay

Org version and provenance

Org mode version 9.6.19 ( @ /nix/store/d74and44lhvi9plj293jf9jhbjy6n95a-emacs-packages-deps/share/emacs/site-lisp/elpa/org-9.6.19/)

org-ql package version and provenance

Version: 0.9-pre

Description

I want org-ql views to respect org-agenda-hide-tags-regexp or provide an equivalent.

I found org-ql-tag-line-re and tried setting it to an empty string but the same tags were still matched.

Etc.

Context: I use olivetti-mode to center my org-agenda buffers to have whitespace on each side. When tags are aligned all the way to the right and olivetti centers things I get multiple lines per heading because the long lines get wrapped.

I'd prefer to just not show the tags to sidestep this issue, though it would be acceptable for org-ql view to somehow integrate better with olivetti-mode. I suspect the former will be the more preferred of the two given the value of using olivetti is very subjective.

alphapapa commented 7 months ago

It's unlikely that I would add support for org-agenda-hide-tags-regexp specifically, because one of the reasons I developed org-ql was to have a simpler implementation without so many options that make for spaghetti code.

If you don't want tags to be displayed, you could copy the function org-ql-view--format-element and comment out the code that is related to tags.

Someday I hope to provide a more flexible means of formatting results, but that probably won't happen soon.

evertedsphere commented 3 weeks ago

I ended up with this, using el-patch templates:

(after! (:and el-patch org-ql)
  (el-patch-feature org-ql)
  (el-patch-define-and-eval-template
   (defun org-ql-view--format-element)
   (tag-string (when tag-list
                 (--> tag-list
                      (el-patch-add (remove "project" it) (remove "draft" it))
                      (el-patch-swap (s-join ":" it) (s-join " " it))
                      (el-patch-remove (s-wrap it ":"))
                      (org-add-props it nil 'face 'org-tag))))))

M-x el-patch-ediff-patch shows:

image

In your case you could go further and just make tag-list an empty list:

(el-patch-define-and-eval-template
   (defun org-ql-view--format-element)
   (tag-list (el-patch-swap ... nil)))