emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anders Johansson <mejlaandersj@gmail.com>
To: org-mode-email <emacs-orgmode@gnu.org>
Subject: [BUG?] Cache: org-scan-tags behaves differently on inlinetasks with and without cache
Date: Mon, 22 Nov 2021 09:29:13 +0100	[thread overview]
Message-ID: <CAKJdtO8-KkVvhcviTqhi+DMZmSK=o37jn1jJPM9qxcuXZPnGgw@mail.gmail.com> (raw)

Hi,
I use inlinetasks with tags extensively in my library for coding
qualitative research data
(https://gitlab.com/andersjohansson/orgqda/).

With the new org-element caching functionality (which hopefully can
provide substantial speedups for my case, thanks Ihor!) I have
stumbled on a difference in how inlinetasks are handled by
org-scan-tags.

Without cache, inlinetasks are matched, but with cache they are not.

A minimal test file:

#+BEGIN_ORG
* Test heading :testtag:
Contents

* Another heading

*************** An inlinetask :testtag:
#+END_ORG

Executing this code in this file
#+BEGIN_SRC emacs-lisp
(let ((org-element-use-cache nil))
  (org-scan-tags
   (lambda () (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
   (cdr (org-make-tags-matcher "testtag"))
   nil))
#+END_SRC

Yields: ("* Test heading :testtag:" "*************** An inlinetask :testtag:")

That is, both the headline and inlinetask were matched

However:
#+BEGIN_SRC
(let ((org-element-use-cache t))
  (org-scan-tags
   (lambda () (buffer-substring-no-properties (point-at-bol) (point-at-eol)))
   (cdr (org-make-tags-matcher "testtag"))
   nil))
#+END_SRC

Yields: ("* Test heading :testtag:")
Only the headline was matched.

The difference is in org-scan-tags, where the code using cache always
retrieves tags for matching with org-get-tags, whereas the code
without cache takes tags from group 4 of the scanning regexp ("re").
It appears that org-get-tags doesn't fetch tags for inlinetasks, is
this really right? Otherwise, the small patch below gets me the right
behaviour (tags returned also for inlinetasks) for these tests.

Best,
Anders Johansson

---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 17b7ff597..98ff5dba7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11808,7 +11808,7 @@ (defun org-get-tags (&optional pos-or-element
local fontify)
                      (org-before-first-heading-p))
           (unless (org-element-type pos-or-element) (org-back-to-heading t))
           (let ((ltags (if (org-element-type pos-or-element)
-                           (org-element-property :tags
(org-element-lineage pos-or-element '(headline) t))
+                           (org-element-property :tags
(org-element-lineage pos-or-element '(headline inlinetask) t))
                          (org--get-local-tags fontify)))
                 itags)
             (if (or local (not org-use-tag-inheritance)) ltags
--
2.34.0


             reply	other threads:[~2021-11-22  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  8:29 Anders Johansson [this message]
2021-11-22 11:35 ` [BUG?] Cache: org-scan-tags behaves differently on inlinetasks with and without cache Ihor Radchenko
2021-11-22 14:39   ` Anders Johansson
2021-11-22 15:02     ` 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='CAKJdtO8-KkVvhcviTqhi+DMZmSK=o37jn1jJPM9qxcuXZPnGgw@mail.gmail.com' \
    --to=mejlaandersj@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).