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/)]

2022-12-12 Thread Ihor Radchenko
Robert Weiner  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 .
Support Org development at ,
or support my work at 



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/)]

2022-12-11 Thread Robert Weiner
Hi Ihor:

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

Thanks,

Bob

On Sat, Oct 22, 2022 at 3:53 AM Ihor Radchenko  wrote:

> Gregor Zattler  writes:
>
> > Dear org-mode and hyperbole developers, hitting hyperbole's
> > action-key with point in "~/src/org-mode/contrilb/lisp" in a
> > *Pp Eval Output* buffer holding my complete load-path
> > resulted in this org-element--cache warning:
> >
> >  ■  Warning (org-element-cache): org-element--cache: Org parser error in
> *Pp Eval Output*::5288. Resetting.
> >  The error was: (error "rx ‘**’ range error")
> >  Backtrace:
> > "  backtrace-to-string(nil)
> >   org-element-at-point()
> >   org-element-context()
> >   hsys-org-link-at-p()
>
> This is a hyperbole bug.
> The latest version of Org no longer supports calling
> org-element-at-point in non-Org buffers. Previously it worked by
> accident and did not throw an error.
>
> I recommend using regexp constants from Org to match against org-like
> constructs outside Org mode buffers.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>
>


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/)]

2022-10-22 Thread Ihor Radchenko
Gregor Zattler  writes:

> Dear org-mode and hyperbole developers, hitting hyperbole's
> action-key with point in "~/src/org-mode/contrilb/lisp" in a
> *Pp Eval Output* buffer holding my complete load-path
> resulted in this org-element--cache warning:
>
>  ■  Warning (org-element-cache): org-element--cache: Org parser error in *Pp 
> Eval Output*::5288. Resetting.
>  The error was: (error "rx ‘**’ range error")
>  Backtrace:
> "  backtrace-to-string(nil)
>   org-element-at-point()
>   org-element-context()
>   hsys-org-link-at-p()

This is a hyperbole bug.
The latest version of Org no longer supports calling
org-element-at-point in non-Org buffers. Previously it worked by
accident and did not throw an error.

I recommend using regexp constants from Org to match against org-like
constructs outside Org mode buffers.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[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/)]

2022-10-21 Thread Gregor Zattler


Dear org-mode and hyperbole developers, hitting hyperbole's
action-key with point in "~/src/org-mode/contrilb/lisp" in a
*Pp Eval Output* buffer holding my complete load-path
resulted in this org-element--cache warning:

 ■  Warning (org-element-cache): org-element--cache: Org parser error in *Pp 
Eval Output*::5288. Resetting.
 The error was: (error "rx ‘**’ range error")
 Backtrace:
"  backtrace-to-string(nil)
  org-element-at-point()
  org-element-context()
  hsys-org-link-at-p()
  ibtypes::org-link-outside-org-mode()
  ibut:at-p()
  hbut:at-p()
  eval((hbut:at-p))
  hkey-execute(nil)
  action-key-internal()
  action-key()
  funcall-interactively(action-key)
  call-interactively(action-key nil nil)
  command-execute(action-key)
"
 Please report this to Org mode mailing list (M-x org-submit-bug-report).

I wanted to know if this directory exists (it doesn't) and
thought it was easiest to use action-key in order to visit
it.


I assume hyperbole wrongly assumed that this was an org-mode
buffer and did something wrong with org-element, but I'm
only guessing, since this is way above my elisp foo.

I hope this somehow helps.

Emacs  : GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, cairo version 1.16.0)
 of 2022-10-19
Package: Org mode version 9.6-pre (release_9.5.5-997-ge58bd0 @ 
/home/grfz/src/org-mode/lisp/)

and hyperbole 8.0.0.

Ciao,
-- 
Gregor