Jens Schmidt <[email protected]> writes:

>> Having example would help.
>> [...]
>
> Sorry for the late reply.  Have been busy and I wanted to provide
> real-life examples.  See attached patch.
> ...
> - But in general, I hope they show what `org-element-boundaries' can
>   do.  At least I find the new code more readable, but that's in the
>   eye of the beholder, as always.
>
> - To find the examples, I searched (rather lazily and only in two or
>   three sources) for "skip-syntax-backward".  These are usually good
>   replacement candidates.

Well. What I see can be achieved in a slightly different way.
Here is what I have been planning to introduce to org-element:

(defsubst org-element-value-begin (node)
  "Get `:value-begin' property of NODE."
  (org-element-property :value-begin node))

(defsubst org-element-value-end (node)
  "Get `:value-end' property of NODE."
  (org-element-property :value-end node))

(defsubst org-element-pos-before-blank (node)
  "Get `:pos-before-blank' property of NODE."
  (org-element-property :pos-before-blank node))

*** Org parser now records boundaries of verbatim contents and post-blank lines

All the parser objects can now contain new standard properties:

- =:value-begin=, =:value-end= :: Boundaries of verbatim contents of
  inside the AST node, as buffer positions.  For example, in source
  blocks, the new properties store the boundaries of the code.
- =:pos-before-blank= :: Position after syntax node, before all its
  blank lines (for elements) or blank spaces after (for objects).

These 3 new AST node properties can cover all the examples you provided
just fine. They will also be more consistent with the existing
org-element approach (:begin/:end, :contents-begin/end).

Note that there is nothing special about skipping whitespace inside
code/verbatim blocks. But your examples did not use that feature either.

WDYT?

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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