emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG?] Cache: org-scan-tags behaves differently on inlinetasks with and


From: Anders Johansson
Subject: [BUG?] Cache: org-scan-tags behaves differently on inlinetasks with and without cache
Date: Mon, 22 Nov 2021 09:29:13 +0100

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 via email to

[Prev in Thread] Current Thread [Next in Thread]