emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: mahmood sheikh <mahmod.m2015@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: nested blocks in org
Date: Tue, 5 Mar 2024 16:27:08 +0200	[thread overview]
Message-ID: <CAOj1L_cx9XP5fS3_=x=UJSSt3xjcfcQ68Uef6E4DTi68Kr_ABw@mail.gmail.com> (raw)
In-Reply-To: <87il2mc1v3.fsf@localhost>

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	other threads:[~2024-03-05 14:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 22:51 nested blocks in org mahmood sheikh
2024-02-17 16:04 ` Ihor Radchenko
     [not found]   ` <CAOj1L_fau2YcXrkUduEn=m8H0tUh=FPisMXAOTD0Ebn7sYHbrA@mail.gmail.com>
2024-02-17 19:44     ` Ihor Radchenko
2024-03-05 14:27       ` mahmood sheikh [this message]
2024-03-06 10:34         ` Ihor Radchenko
2024-05-13 12:03           ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOj1L_cx9XP5fS3_=x=UJSSt3xjcfcQ68Uef6E4DTi68Kr_ABw@mail.gmail.com' \
    --to=mahmod.m2015@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).