emacs-orgmode
[Top][All Lists]
Advanced

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

Re: nested blocks in org


From: mahmood sheikh
Subject: Re: nested blocks in org
Date: Tue, 5 Mar 2024 16:27:08 +0200

with the given minimal example:
```
#+begin_parent
#+begin_child
#+end_child
#+end_parent
```
the code
```lisp
(org-block-map (lambda () (message "elem: %s" (org-element-at-point))))
```
goes through only the parent element and doesnt run the lambda on the
child block
the docstring of org-block-map says it iterates through src blocks but
it also goes through special blocks, albeit not nested ones, i
might've confused it for org-element-map as im not sure about the
later functions behavior.

On Sat, Feb 17, 2024 at 7:44 PM Ihor Radchenko <yantar92@posteo.net> wrote:
>
> [ Adding Org list back to CC; please use Reply All or wide reply to keep
>   the discussion public ]
>
> mahmood sheikh <mahmod.m2015@gmail.com> writes:
>
> > consider the following block
> > ```
> > #+begin_solution
> > #+begin_src sql
> >   SELECT
> >     CONCAT(c.first_name, ' ', c.family_name) AS name, c.customer_id,
> > ...
> > #+end_solution
> > ```
> > the src block isnt fontified by org because it is inside another block
>
> ... which is just a bug in the Org fontification code.
> If you try M-: (org-element-at-point) <RET>, you will see that Org does
> recognize the code block.
>
> So ...
>
> > can you point me in the right direction of getting org mode to recognize
> > nested blocks,
>
> Org already recognizes nested blocks using Org element parser. See
> https://orgmode.org/worg/dev/org-element-api.html
>
> > ... like code highlighting for src blocks that are within
> > another special block?
>
> See https://list.orgmode.org/87ee7c9quk.fsf@localhost/
> This is something we are working in.
> To get parser-aware fontification locally, you can use a function
> MATCHER (as in font-lock-keywords docstring) and invoke
> `org-element-at-point' there to check context.
>
> > ... and getting org-element-map to iterate through both
> > a parent and its child blocks all the same?
>
> May you elaborate? `org-element-map' iterates through everything,
> including nested parent and child blocks. What did you try?
>
> > could modifying `org-block-regexp` to be a recursive regex be of help?
>
> Sorry, but it is hard to see how this is related to `org-element-map'.
>
> --
> 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]