* nested blocks in org @ 2024-02-15 22:51 mahmood sheikh 2024-02-17 16:04 ` Ihor Radchenko 0 siblings, 1 reply; 6+ messages in thread From: mahmood sheikh @ 2024-02-15 22:51 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 332 bytes --] can you point me in the right direction of getting org mode to recognize nested blocks, like code highlighting for src blocks that are within another special block? and getting org-element-map to iterate through both a parent and its child blocks all the same? could modifying `org-block-regexp` to be a recursive regex be of help? [-- Attachment #2: Type: text/html, Size: 379 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nested blocks in org 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> 0 siblings, 1 reply; 6+ messages in thread From: Ihor Radchenko @ 2024-02-17 16:04 UTC (permalink / raw) To: mahmood sheikh; +Cc: emacs-orgmode mahmood sheikh <mahmod.m2015@gmail.com> writes: > can you point me in the right direction of getting org mode to recognize > nested blocks, like code highlighting for src blocks that are within > another special block? May you please give an example of what you have in mind? -- 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> ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAOj1L_fau2YcXrkUduEn=m8H0tUh=FPisMXAOTD0Ebn7sYHbrA@mail.gmail.com>]
* Re: nested blocks in org [not found] ` <CAOj1L_fau2YcXrkUduEn=m8H0tUh=FPisMXAOTD0Ebn7sYHbrA@mail.gmail.com> @ 2024-02-17 19:44 ` Ihor Radchenko 2024-03-05 14:27 ` mahmood sheikh 0 siblings, 1 reply; 6+ messages in thread From: Ihor Radchenko @ 2024-02-17 19:44 UTC (permalink / raw) To: mahmood sheikh; +Cc: emacs-orgmode [ 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> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nested blocks in org 2024-02-17 19:44 ` Ihor Radchenko @ 2024-03-05 14:27 ` mahmood sheikh 2024-03-06 10:34 ` Ihor Radchenko 0 siblings, 1 reply; 6+ messages in thread From: mahmood sheikh @ 2024-03-05 14:27 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode 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> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nested blocks in org 2024-03-05 14:27 ` mahmood sheikh @ 2024-03-06 10:34 ` Ihor Radchenko 2024-05-13 12:03 ` Ihor Radchenko 0 siblings, 1 reply; 6+ messages in thread From: Ihor Radchenko @ 2024-03-06 10:34 UTC (permalink / raw) To: mahmood sheikh; +Cc: emacs-orgmode mahmood sheikh <mahmod.m2015@gmail.com> writes: > 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. This is a bug in `org-block-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> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: nested blocks in org 2024-03-06 10:34 ` Ihor Radchenko @ 2024-05-13 12:03 ` Ihor Radchenko 0 siblings, 0 replies; 6+ messages in thread From: Ihor Radchenko @ 2024-05-13 12:03 UTC (permalink / raw) To: mahmood sheikh; +Cc: emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > mahmood sheikh <mahmod.m2015@gmail.com> writes: > >> 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. > > This is a bug in `org-block-map'. Fixed, on main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=62356cb44 -- 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> ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-13 12:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2024-03-06 10:34 ` Ihor Radchenko 2024-05-13 12:03 ` Ihor Radchenko
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).