hyperbole-users
[Top][All Lists]
Advanced

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

Re: [BUG] hyperbole action key on path name results in org-element-cache


From: Ihor Radchenko
Subject: Re: [BUG] hyperbole action key on path name results in org-element-cache warning [9.6-pre (release_9.5.5-997-ge58bd0 @ /home/grfz/src/org-mode/lisp/)]
Date: Mon, 12 Dec 2022 11:47:37 +0000

Robert Weiner <rsw@gnu.org> writes:

> So if we want to determine the Org type of an element outside of an Org
> buffer (when using org-type minor modes for example), how would we change
> this 'let' code:
>
>  (let* ((context
>          ;; Only consider supported types, even if they are not
>          ;; the closest one.
>          (org-element-lineage
>           ;; Next line can trigger an error when `looking-at' is called
>           ;; with a `nil' value of `org-complex-heading-regexp'.
>           (org-element-context)
>           '(clock footnote-definition footnote-reference headline
>             inlinetask link timestamp)
>           t))
>         (type (org-element-type context))
>      ...)

Strictly speaking, thing at point outside Org buffers is ambiguous
because Org syntax is recursive, and we often need to parse buffer from
the very beginning to determine what is at point. One needs to load
org-mode on text in buffer to know for sure.

So, one way to address the issue may be creating an indirect buffer,
switching it to Org mode and calling `org-element-context'. Or you can
use `org-export-copy-buffer'.

The performance may be affected though.

Also, you may get unexpected result when trying to match Org object in
non-Org buffer when some other text there looks like Org.

If necessary, we may also define generic versions of predicates, similar
to what is done in `org-at-table-p': When in Org mode, use accurate
parser data, but fallback to regexp matching otherwise.

Then, we can also modify `org-context' to be generic.

If you want the latter, you can help us by searching all the predicate
functions to be converted in Org codebase. Then, I can extract them into
a separate library org-context.el.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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