emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG?] Cache: org-scan-tags behaves differently on inlinetasks with and without cache
@ 2021-11-22  8:29 Anders Johansson
  2021-11-22 11:35 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Anders Johansson @ 2021-11-22  8:29 UTC (permalink / raw)
  To: org-mode-email

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-22 15:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  8:29 [BUG?] Cache: org-scan-tags behaves differently on inlinetasks with and without cache Anders Johansson
2021-11-22 11:35 ` Ihor Radchenko
2021-11-22 14:39   ` Anders Johansson
2021-11-22 15:02     ` Ihor Radchenko

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).