Ihor Radchenko <yanta...@posteo.net> 于2023年12月8日周五 21:06写道: > > Liu Hui <liuhui1...@gmail.com> writes: > > >> What about displaying a yes/no query about starting a new session when > >> there is none? > > > > I think it is OK. I can add an option to allow users to disable the > > query. WDYT? > > I now have second thoughts about obsoleting > org-babel-<lang>-associate-session. > If we need a customization for the new session dialogue, I expect that > users will be willing to set it for all src blocks that support such a > feature, not just python. But then we somehow need to make this global > customization visible to babel backend authors - something we normally > do using the set of org-babel-...:<lang> functions. > > What I am thinking now is > 1. Introduce a global customization for users to choose whether to > start a new session in org-src buffers with allowed values t, nil, > 'ask, or an alist of (lang . t/nil/ask) for per-language customization.
I think it makes sense. Currently, org-babel-edit-prep:R/julia always start the session when editing src blocks with a valid session header, and other backends don't. It would allow users to change the behavior. > 2. Check the new variable and attempt to run > `org-babel-<lang>-associate-session' in org-src-mode definition. I think associating the edit buffer with some session doesn't require starting the session, which is at least feasible for ob-python. When editing python src block, users can use C-c C-p to start the session themselves for evaluating code. So it would be nice to allow a value of 'associate in the customization, which means just running `org-babel-<lang>-associate-session'.