Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-30 Thread Martin Maechler
> Ihor Radchenko > on Mon, 22 Jan 2024 12:13:15 + writes: > "Sparapani, Rodney" writes: >> I’ve test that and it works for me per your prescription >> below. And, I have committed it to the ESS git repo. > Thank you! May I know which version of ESS will have

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-29 Thread Ihor Radchenko
Jack Kamm writes: >> Now, after amending `org-src-associate-babel-session' to execute even >> when no session is active, we can use >> `org-babel-python-associate-session'. >> >> Attaching tentative patch that should be equivalent to yours. > > Thanks Ihor. I tested the patch and it seems to

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-28 Thread Jack Kamm
Ihor Radchenko writes: > Applied, onto main, fixing the oversight in > org-src-associate-babel-session (now, it does not require session > running). > https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=319563cef > > Since ESS already released a new version with my patch for ESS

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-28 Thread Jack Kamm
Ihor Radchenko writes: > Liu Hui writes: > >> Yes, I have updated the text and you're welcome to improve it. Thanks! >> From c503b2ed5116e2abae25459b09abc919074ac54a Mon Sep 17 00:00:00 2001 >> From: Liu Hui >> Date: Tue, 5 Dec 2023 11:40:38 +0800 >> Subj

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-28 Thread Ihor Radchenko
Liu Hui writes: > Yes, I have updated the text and you're welcome to improve it. Thanks! > From c503b2ed5116e2abae25459b09abc919074ac54a Mon Sep 17 00:00:00 2001 > From: Liu Hui > Date: Tue, 5 Dec 2023 11:40:38 +0800 > Subject: [PATCH] Set Python shell in Org edit buffer Now,

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-28 Thread Ihor Radchenko
Jack Kamm writes: > Ihor Radchenko writes: > >>> My concern is that advising `ess-request-a-process' would cause >>> maintenance burden on ob-R. It would require some knowledge about the >>> ESS internals to maintain properly. >> >> Not really. I only meant writing an advice iff our request is

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-25 Thread Ihor Radchenko
"Sparapani, Rodney" writes: > This last remark below can’t possibly be true. Because I did not intend to > trigger > a release, ESS 24.01.0 was not initially tagged. However, after I received > that email > from ELPA, it was a fait accompli. So I fixed some cosmetic issues and > tagged it

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-25 Thread Sparapani, Rodney
setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer) ATTENTION: This email originated from a sender outside of MCW. Use caution when clicking on links or opening attachments. Martin Maechler writes: > >

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-25 Thread Sparapani, Rodney
/session name (was: [PATCH] Set Python shell in Org edit buffer) Also, unlike MELPA, ELPA uses stable (tagged) releases by default. Unstable releases (latest commit) are only available on demand, via ELPA-devel (https://urldefense.com/v3/__https://elpa.gnu.org/devel/ess.html__;!!H8mHWRdzp34

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-25 Thread Ihor Radchenko
"Sparapani, Rodney" writes: > I have never had much success with either MELPA or ELPA. Something about > my TLS setup that I have not figured how to fix. But, I did receive an email > that > we are available at ELPA too (however, I can’t test the veracity of that > myself). > See the

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-25 Thread Ihor Radchenko
Martin Maechler writes: > > Thank you! May I know which version of ESS will have this > > commit? > > The Melpa version that was just released, does. Noted. I did not know that ESS is distributed via MELPA. I am wondering why not ELPA/non-GNU ELPA - ELPA is built-in and users can

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-22 Thread Ihor Radchenko
"Sparapani, Rodney" writes: > I’ve test that and it works for me per your prescription below. > And, I have committed it to the ESS git repo. Thank you! May I know which version of ESS will have this commit? -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at

Re: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-21 Thread Sparapani, Rodney
respond when convenient. From: Ihor Radchenko Date: Sunday, January 21, 2024 at 5:45 AM To: Sparapani, Rodney Cc: Jack Kamm , ess-c...@r-project.org , Liu Hui , emacs-orgmode@gnu.org Subject: [PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Pytho

[PATCH] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-21 Thread Ihor Radchenko
Ihor Radchenko writes: > We recently discovered `ess-gen-proc-buffer-name-function', but it does > not work as we expected, unfortunately. (which is either because we > misunderstand something or because there is a bug). I am attaching tentative patch that will make `ess-request-a-process' obey

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-16 Thread Jack Kamm
Ihor Radchenko writes: >> My concern is that advising `ess-request-a-process' would cause >> maintenance burden on ob-R. It would require some knowledge about the >> ESS internals to maintain properly. > > Not really. I only meant writing an advice iff our request is accepted > by ESS devs.

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-16 Thread Ihor Radchenko
Jack Kamm writes: >>> Currently I lean towards a combination of #1 and #3, but am not sure, >>> and happy to go with whatever you think is best. >> >> We can also advice `ess-request-a-process' as a temporary workaround. > > My concern is that advising `ess-request-a-process' would cause >

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-14 Thread Jack Kamm
Ihor Radchenko writes: >> It's annoying there's no way to tell ESS to start new session instead of >> evaluating in existing one. Here are a few alternatives we could >> consider to deal with this: >> >> 1. Change the worg/ORG-NEWS, to suggest users make sure the session >> exists (either by

Re: [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-12 Thread Sparapani, Rodney
Sparapani, Rodney Cc: Jack Kamm , ess-c...@r-project.org , Liu Hui , emacs-orgmode@gnu.org Subject: Re: [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer) ATTENTION: This email originated from a sender outside of MCW. Use ca

Re: [External] [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-12 Thread Richard M. Heiberger
This idiscussion s reminding me of the following ESS functions ess-add-ess-process M-x ... RET Execute this command from within a buffer running a process to add ess-request-a-process M-x ... RET Ask for a process, and make it the current ESS process. ess-switch-process

Re: [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-12 Thread Sparapani, Rodney
name (was: [PATCH] Set Python shell in Org edit buffer) ATTENTION: This email originated from a sender outside of MCW. Use caution when clicking on links or opening attachments. Hi, I'd like to request a new ESS feature that will allow to choose which session

Re: [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-12 Thread Sparapani, Rodney
-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer) Hi Jack: Do you have a patch? I’m not an org-mode user so I can’t test this myself. Thanks -- Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His Vice President, Wisconsin

[ob-clojure] Clojure sessions in Org Src buffers (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-12 Thread Ihor Radchenko
"Christopher M. Miles" writes: >> (or (org-babel-comint-buffer-livep session) >> (eq org-src-auto-initiate-session t) >> (alist-get (nth 0 info) org-src-auto-initiate-session) >> (alist-get 'default org-src-auto-initiate-session)) >> >> With `org-src-auto-initiate-session' being a

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-11 Thread Christopher M. Miles
Ihor Radchenko writes: > Now, the question is what to do with the existing implementation of > `org-src-associate-babel-session'. It only runs > org-babel--associate-session when > > (and session (not (string= session "none")) >(org-babel-comint-buffer-livep session) >(let ((f

Re: [External] [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-10 Thread Ihor Radchenko
"Richard M. Heiberger" writes: > This idiscussion s reminding me of the following ESS functions > > ess-request-a-process M-x ... RET >Ask for a process, and make it the current ESS process. AFAIK, this is the function deciding whether to run a new ESS process or re-use the existing

Re: [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-10 Thread Ihor Radchenko
"Sparapani, Rodney" writes: > I see. But, I assume that you meant… > 8. Observe that the line still goes to "session1" Yup. > I usually launch another emacs for “session2”. > There’s probably a way to do this manually, > but, I take your point. However, if you are a > non-user, then why do

Re: [FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-10 Thread Ihor Radchenko
"Sparapani, Rodney" writes: > Hi Ihor: > > Do you have a patch? I’m not an org-mode user so I can’t test this myself. > Thanks Well. I am not exactly ESS user, so I wanted to get a general feedback first before trying anything blindly. I think I can demonstrate the problem we are facing

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-10 Thread Ihor Radchenko
Jack Kamm writes: >> --- >> etc/ORG-NEWS | 11 +++ >> lisp/ob-R.el | 20 ++-- >> lisp/ob-julia.el | 16 +--- >> 3 files changed, 26 insertions(+), 21 deletions(-) > > Not sure if you are doing this in a separate commit, but you also need > to make the

[FR] Add buffer-local setting to request specific ESS process/session name (was: [PATCH] Set Python shell in Org edit buffer)

2024-01-10 Thread Ihor Radchenko
Hi, I'd like to request a new ESS feature that will allow to choose which session is created by ESS when no session is yet associated with a buffer. Currently, `ess-request-a-process' unconditionally re-uses an existing ESS process with appropriate `ess-dialect', even when such process is not

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-09 Thread Jack Kamm
Ihor Radchenko writes: > See the attached tentative patch. Thanks! > --- > etc/ORG-NEWS | 11 +++ > lisp/ob-R.el | 20 ++-- > lisp/ob-julia.el | 16 +--- > 3 files changed, 26 insertions(+), 21 deletions(-) Not sure if you are doing this in a

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-09 Thread Ihor Radchenko
Jack Kamm writes: >> IMHO, it might be enough to adjust org-babel-R-associate-session as the >> following >... > Otherwise, this looks good to me. See the attached tentative patch. >From f6fd65f8e80b6efa0a5db084a9c9f94d46e67515 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date:

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-08 Thread Jack Kamm
Jack Kamm writes: > Also it seems unnecessary to call `ess-make-buffer-current', as it's > already called by `ess-force-buffer-current' (which is called by > `ess-eval-region'). Though it doesn't hurt to call it, either. On reflection, maybe it's better to keep `ess-make-buffer-current'. Maybe

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-08 Thread Jack Kamm
Ihor Radchenko writes: > Note that I proposed to remove auto-starting session completely, which > is in odds to what you propose below. Sure, I'm fine with that -- it seems like a reasonable change. > IMHO, it might be enough to adjust org-babel-R-associate-session as the > following > >

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-08 Thread Ihor Radchenko
Jack Kamm writes: > Ihor Radchenko writes: > >> So, a good option could be >> (1) removing (org-babel-comint-buffer-livep session) from >> `org-src-associate-babel-session' >> (2) Removing `org-babel-edit-prep:R' >> >> With the above, we can use `org-babel-python-associate-session' > >

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-07 Thread William Denton
On Sunday, January 7th, 2024 at 14:06, Jack Kamm wrote: > It looks like ob-R and ob-julia are the only languages that start > sessions on edit (based on grepping for "edit-prep" and > "associate-session"). > > I think their behavior is peculiar enough to have an ob-R/julia-specific > option on

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-07 Thread Jack Kamm
Ihor Radchenko writes: > So, a good option could be > (1) removing (org-babel-comint-buffer-livep session) from > `org-src-associate-babel-session' > (2) Removing `org-babel-edit-prep:R' > > With the above, we can use `org-babel-python-associate-session' Sounds good to me. > I imagine that

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-07 Thread Ihor Radchenko
Jack Kamm writes: >> Now, the question is what to do with the existing implementation of >> `org-src-associate-babel-session'. It only runs >> org-babel--associate-session when >> >> (and session (not (string= session "none")) >> (org-babel-comint-buffer-livep session) >> (let ((f

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-06 Thread Jack Kamm
Ihor Radchenko writes: > Now, the question is what to do with the existing implementation of > `org-src-associate-babel-session'. It only runs > org-babel--associate-session when > > (and session (not (string= session "none")) >(org-babel-comint-buffer-livep session) >(let ((f

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-05 Thread Ihor Radchenko
Jack Kamm writes: >> python.el is convenient as it allows setting the session buffer name in >> advance via buffer-local variable. Then, all the normal python-mode >> commands, including `run-python' or `python-shell-send-region' will work >> as expected. However, other babel backends like ob-R

Re: [PATCH] Set Python shell in Org edit buffer

2024-01-05 Thread Ihor Radchenko
Jack Kamm writes: >> Because I am still thinking about the idea with global customization and >> `org-babel--associate-session'. > > It's great that you're thinking about this -- it would be nice to have > better consistency between ob-R, ob-python, etc, and to have better > configurability on

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-31 Thread Jack Kamm
Ihor Radchenko writes: >> I agree that `python-shell-buffer-name' should be set according to the >> :session header, and that Liu's patch fixes a problem in ob-python. >> >> Is there any objection if I go ahead and apply it? > > Because I am still thinking about the idea with global

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-31 Thread Jack Kamm
Ihor Radchenko writes: > python.el is convenient as it allows setting the session buffer name in > advance via buffer-local variable. Then, all the normal python-mode > commands, including `run-python' or `python-shell-send-region' will work > as expected. However, other babel backends like ob-R

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-31 Thread Ihor Radchenko
Jack Kamm writes: >> What might be more robust is to provide an explicit "start session >> from Org Src buffer" command for ob-python and re-bind `run-python' to >> this command in Org Src buffers. > > We could refactor `org-babel-python-initiate-session-by-key' to call a > separate

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Liu Hui
Jack Kamm 于2023年12月30日周六 06:20写道: > > Liu Hui writes: > > > But it is indeed possible that two sessions are inconsistent, if users > > intend to have different org-babel-python-command and > > python-shell-interpreter, which are used by > > `org-babel-python-initiate-session' and `run-python',

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Jack Kamm
Liu Hui writes: > But it is indeed possible that two sessions are inconsistent, if users > intend to have different org-babel-python-command and > python-shell-interpreter, which are used by > `org-babel-python-initiate-session' and `run-python', respectively. I have just proposed this patch,

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Jack Kamm
Ihor Radchenko writes: > As long as it remains undocumented, we can break this in future (maybe > years from now, but still...). Fair enough, I've had to fix this feature from time to time due to breakage in the past. I just pushed d0d838b02 which should hopefully prevent future breakage:

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-28 Thread Ihor Radchenko
Jack Kamm writes: > Ihor Radchenko writes: > >> I think we have a misunderstanding here. >> >> Didn't we just discuss that C-c C-p in python is not equivalent to >> `org-babel-python-initiate-session'? > > ob-python works fine with sessions started externally by `run-python'. > And I have

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-28 Thread Ihor Radchenko
Jack Kamm writes: > Liu Hui writes: > >> I just want to set 'python-shell-buffer-name' in the edit buffer >> according to the :session header and don't need to start the session >> even if the session doesn't exist. > > Sorry that I missed this thread. > > I agree that

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-26 Thread Jack Kamm
Ihor Radchenko writes: > I think we have a misunderstanding here. > > Didn't we just discuss that C-c C-p in python is not equivalent to > `org-babel-python-initiate-session'? ob-python works fine with sessions started externally by `run-python'. And I have preserved this functionality, as I

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-26 Thread Jack Kamm
Liu Hui writes: > I just want to set 'python-shell-buffer-name' in the edit buffer > according to the :session header and don't need to start the session > even if the session doesn't exist. Sorry that I missed this thread. I agree that `python-shell-buffer-name' should be set according to the

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-09 Thread Liu Hui
Ihor Radchenko 于2023年12月9日周六 18:29写道: > > Liu Hui writes: > > >> 2. Check the new variable and attempt to run > >>`org-babel--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

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-09 Thread Ihor Radchenko
Liu Hui writes: >> 2. Check the new variable and attempt to run >>`org-babel--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

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-08 Thread Liu Hui
Ihor Radchenko 于2023年12月8日周五 21:06写道: > > Liu Hui 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

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-08 Thread Ihor Radchenko
Liu Hui 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--associate-session. If we need a customization

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-08 Thread Liu Hui
Ihor Radchenko 于2023年12月7日周四 23:16写道: > > Liu Hui writes: > > > Ihor Radchenko 于2023年12月7日周四 18:33写道: > > > >> > +(defun org-babel-edit-prep:python (info) > >> > + "Set Python shell in Org edit buffer according to INFO." > >> > + (let ((session (cdr (assq :session (nth 2 info) > >> > +

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-07 Thread Ihor Radchenko
Liu Hui writes: > Ihor Radchenko 于2023年12月7日周四 18:33写道: > >> > +(defun org-babel-edit-prep:python (info) >> > + "Set Python shell in Org edit buffer according to INFO." >> > + (let ((session (cdr (assq :session (nth 2 info) >> > +(when (and session (not (string= session "none"))) >> >

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-07 Thread Liu Hui
Ihor Radchenko 于2023年12月7日周四 18:33写道: > > +(defun org-babel-edit-prep:python (info) > > + "Set Python shell in Org edit buffer according to INFO." > > + (let ((session (cdr (assq :session (nth 2 info) > > +(when (and session (not (string= session "none"))) > > + (setq-local

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-07 Thread Ihor Radchenko
Liu Hui writes: >> May you also mention what this means in practice? Like that users can >> now send region for evaluation right from the edit src buffer? >> Otherwise, it may not be very clear for ordinary users what this feature >> adds. > > Yes, I have updated the text and you're welcome to

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-06 Thread Liu Hui
rwise, it may not be very clear for ordinary users what this feature > adds. Yes, I have updated the text and you're welcome to improve it. Thanks! From c503b2ed5116e2abae25459b09abc919074ac54a Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Tue, 5 Dec 2023 11:40:38 +0800 Subject: [PATCH] Set Py

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-06 Thread Ihor Radchenko
Liu Hui writes: >> Makes sense. >> I think we may drop a note about this new feature in ORG-NEWS. > > Thanks, I have added it in the attached patch. > ... > +When editing a Python src block, the editing buffer is now associated > +with the Python shell specified by the src block's ~:session~

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-05 Thread Liu Hui
"TODO" comment. > > To be safe, I'd prefer to mark `org-src-associate-babel-session' > obsolete and mention the removal in ORG-NEWS, pointing users to > `org-babel-edit-prep:..' instead. Fine by me. From 295b28fece2f2125b40635118a5a705af4c8ce74 Mon Sep 17 00:00:00 2001 From: L

Re: [PATCH] Set Python shell in Org edit buffer

2023-12-05 Thread Ihor Radchenko
Liu Hui writes: > When editing python src block using C-c ', the python shell is not set > in Org edit buffer according to the :session header argument of the > block. Consequently, commands such as python-shell-send-region cannot > send python code to the correct python process. To address

[PATCH] Set Python shell in Org edit buffer

2023-12-05 Thread Liu Hui
it is safe to remove it and related stuffs to avoid confusion. Best, Liu Hui From c8b9c174cf643bd625cedc311d2604e6fc3bb83a Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Tue, 5 Dec 2023 11:40:38 +0800 Subject: [PATCH] Set Python shell in Org edit buffer * lisp/ob-python.el (org-babel-edit