emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Mathena <jmmathena@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org-agenda-filter-by-category not working in block agendas due to inconsistent truncation
Date: Thu, 22 Feb 2024 17:23:53 -0600	[thread overview]
Message-ID: <CADywB5Lonxw-t1H7cvK+Au3oWq=EsB=Bthj13pt03MRP-Fn-4w@mail.gmail.com> (raw)

The category of items in an "agenda" block view as returned by
org-agenda-get-category are truncated based on the value of the prefix
format; this isn't the case for e.g. the tags-todo view. For instance,
if an item has a category "marathon training", and your agenda and
tags-todo views both have prefix formats of " %8.8:c ", calling
org-agenda-get-category on that item while it's being displayed in the
agenda will yield a category of "marathon", while calling it on the
same item in the tags-todo view will yield "marathon training".

This poses a problem while trying to use custom commands to do a block
agenda, since if you call org-agenda-filter-by-category on an entry
with a given category, other entries with that same category can get
filtered out if they're in a different view than the point was in when
you filtered. To recreate this issue, I:

1. Started emacs with emacs -Q

2. Ran eval-defun on the following elisp
(setq org-agenda-custom-commands '(("d" "demo"
                                    ((agenda ""

((org-agenda-prefix-format " %-12.12:c ")))
                                     (tags-todo "/TODO"
                                           ((org-agenda-prefix-format
" %16.16:c ")))
                                     (tags-todo "/TODO"
                                           ((org-agenda-prefix-format
" %-12.12:c ")))))))

3. Created an org file with the following contents and added it to
org-agenda-files with C-c [
* TODO This is a small project
:PROPERTIES:
:CATEGORY: small proj
:END:
** TODO Do foo
SCHEDULED: <2024-02-22 Thu>
* TODO This is a big, special project!
:PROPERTIES:
:CATEGORY: extra-special project
:END:
** TODO Do bar
SCHEDULED: <2024-02-22 Thu>
** TODO Do baz

4. Opened org-agenda with the "demo" view.

Now, if you use org-agenda-filter-by-category while in the agenda
block on the scheduled entry "Do foo", you'll see the category filter
appropriately in the tags-todo view, only leaving items with category
"small proj". However, if you use org-agenda-filter-by-category on the
scheduled entry "Do bar" in the agenda block, all items are filtered
out in the tags-todo views, including ones that should have the same
category. Calling org-agenda-get-category on the "Do bar" item in the
agenda yields "extra-speci" as the category of that entry.

Note that if you instead filter on "Do bar" while on one of its
entries in the tags-todo views, the entries in the other tags-todo
view are filtered correctly, despite them having a different length in
their prefix format; calling org-agenda-get-category on either of
those both yield the full "extra-special project" category.

My workflow involves giving significant projects a category, and
organizing tasks underneath those headings; then, I can schedule
individual tasks so that they show up on my agenda, and filter the
agenda tasks by category so that I see all other tasks that belong to
that project in a larger tags-todo view underneath the agenda.
However, this will now only work if I don't truncate the headings at
all in my agenda prefix-format so that they match the untruncated
categories of the tags-todo view, which is unfortunate, since it
throws others stuff in the agenda out of alignment.

(Due to projects sometimes having sub-projects,
org-agenda-filter-by-top-headline isn't a cure-all here).

In general, it seems like org-agenda-filter-by-category should work
based on the actual category of an item, rather than its display in
the buffer, which I find unexpected. I wasn't able to find any
configuration to change this behavior, but if I'm missing it, I'd
appreciate a point in the right direction!

This was recreated on GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu,
GTK+ Version 3.24.41, cairo version 1.18.0) of 2024-02-14, with Org
mode version 9.6.15 (release_9.6.15 @
/usr/share/emacs/30.0.50/lisp/org/)

Best,

John


             reply	other threads:[~2024-02-22 23:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 23:23 John Mathena [this message]
2024-02-24  9:35 ` org-agenda-filter-by-category not working in block agendas due to inconsistent truncation Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADywB5Lonxw-t1H7cvK+Au3oWq=EsB=Bthj13pt03MRP-Fn-4w@mail.gmail.com' \
    --to=jmmathena@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).