Concrete use case: I got fed up by sh-mode notifying me about "Indentation setup for shell type bla" when editing shell source blocks in an Org buffer. (To reproduce, start "emacs -Q", open an empty org file, create a shell source block with contents " echo foo", and press TAB on that line.)
So I wanted to advice `sh-set-shell' to surpress all messages, *but only* when called from macro `org-babel-do-in-edit-buffer'. To detect that, I resorted to variable `org-inhibit-startup', but that is not really intended for that purpose. For this and similar use cases (run/do not run some major mode hook only in Org source environment), it would be helpful to have a documented dynamic variable (`org-in-babel-environment'?) set by `org-babel-do-in-edit-buffer' or the like that one could query as (when (and (boundp 'org-in-babel-environment) org-in-babel-environment) ;; do org-specific stuff) Emacs : GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2023-01-18, modified by Debian Package: Org mode version 9.5.2 (9.5.2 @ /usr/share/emacs/site-lisp/elpa/org-9.5.2/)