From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:5f26::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id CFjPB0iVnWVgVAAAkFu2QA (envelope-from ) for ; Tue, 09 Jan 2024 19:49:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id IEhmBEiVnWVDegEAqHPOHw (envelope-from ) for ; Tue, 09 Jan 2024 19:49:44 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=J7nLOb1E; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704824073; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=zcCmQVZ2A1gMfMONdyAWbYLfMTAOcxcR26cW8NCw4VY=; b=dl7Z5Dy9z97SedE2R7nwPfq9LyOKhzb2gwgmKc3XGKQs8j1fecC5IK7kX4pu5rjYDSdwOc akqCytLaezYwVpD7OrIkC8OlER6zVobHu7rV+KPaF2ar8d3Zu65n6TRJLAu/qxHWJLgKln CYr7ZiZjuhqJCZPA15oeVVu8OaQwMBlronq1Fvm2oxvESMsWpHdf/WkiRY9/fpBsC4VtGx qQDZamDTs5LY8sbaUMgJ8paU8/7uJq3w9hzq7eVAkRYrztiRFss/7Yk3SNba05rRHVjvOj SHzI8UaFd3BO2aj0mzVq7rnYUObCm7pYub/yhObGn3x5ugp52YMEi21gRwfGmw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704824073; a=rsa-sha256; cv=none; b=T/mpkyAVm7kMf+FQygK461UMZ0WTRlrC1OuagSoPkrphl4+VgQoDJNYCzexEJKOBhsDDL3 ouMsqyOwz1Uir1OEiTpzlvG5EDn1piLK8jbMMZ/qljfxmsNPC5gix9NZWkKA5OOTPU515D bpwOGqvz7bTpMZydJS5jsMiYtjW2bHLCmP/o7zfGURmG+Ky888Z1hjPpXBevJxkCgMSwGd adK2PqKFhaj22LDexy0Os2ASmbWZGm0eMAdCAuZ8EoI8KyuM1vdshIwxjd/HEOGJ9fGzx+ DWtvLi24uBzsifcidlL2FZDjNWbyRiNXRzAL9+3p5oE5hB2F7sYbVO9pU0hwsw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=J7nLOb1E; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B495519E5C for ; Tue, 9 Jan 2024 19:14:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNGbr-0004ga-Lm; Tue, 09 Jan 2024 13:13:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNGbo-0004bZ-BM for emacs-orgmode@gnu.org; Tue, 09 Jan 2024 13:13:52 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNGbh-0005uY-SK for emacs-orgmode@gnu.org; Tue, 09 Jan 2024 13:13:51 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B5AEA240027 for ; Tue, 9 Jan 2024 19:13:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704824022; bh=SFBL9zJ/s7Ubuq2KVrlg2OlIBXSeo84Bm0d6/l5QRLU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=J7nLOb1EYPvYzAJGITkw8jH9lxrrfsr50hpEDW0/qwTDWwLHBlB1AIIGHcOtpwjXg PIj3ClIu+kkxmToz5onxyt/pZfzjC818xcBEXr6Z84GbufBITAwz++vNkPKVbT0f+H LUFfSkmcTWYvBFLXqfiGiVlPhcfuDUZvrMnfV0FiVP8tB6UBhyeaQC1/1X5hhCkmAz Nm8y6n5z5f2aOz0OUAjK1OT5rlQ4scVQ129Co++Q36y1eUeL7IHCOQ9yMi2Urk5Jd0 FHMJf3OJyEgapu/nRQXRaslk63rdQjwoTGc3gADGqj9NCmzvURAmolP7aDBNuF6g+B xcxIjPfIh1muQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T8fFK5t5Gz9rxF; Tue, 9 Jan 2024 19:13:41 +0100 (CET) From: Ihor Radchenko To: Jack Kamm Cc: Liu Hui , emacs-orgmode@gnu.org Subject: Re: [PATCH] Set Python shell in Org edit buffer In-Reply-To: <87r0ir2ln8.fsf@gmail.com> References: <87ttovlb1u.fsf@localhost> <878r6647vv.fsf@localhost> <87bkb2rqer.fsf@localhost> <87edfwsuvx.fsf@localhost> <87sf4bsm1w.fsf@localhost> <87mstw18r4.fsf@gmail.com> <87bkaak0ol.fsf@localhost> <87ttnyz0jv.fsf@gmail.com> <87wmsn6ghw.fsf@localhost> <87o7dxu15h.fsf@gmail.com> <87msthwbfz.fsf@localhost> <87le91t13e.fsf@gmail.com> <87zfxgxb8m.fsf@localhost> <87r0ir2ln8.fsf@gmail.com> Date: Tue, 09 Jan 2024 18:16:49 +0000 Message-ID: <87zfxewewe.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -8.01 X-Spam-Score: -8.01 X-Migadu-Queue-Id: B495519E5C X-Migadu-Scanner: mx12.migadu.com X-TUID: KlF6tmCQXuJW --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-R-ob-julia-Do-not-force-start-session-in-Org-Src-.patch >From f6fd65f8e80b6efa0a5db084a9c9f94d46e67515 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Tue, 9 Jan 2024 19:08:44 +0100 Subject: [PATCH] ob-R, ob-julia: Do not force-start session in Org Src buffers * lisp/ob-R.el (org-babel-R-associate-session): Set `ess-gen-proc-buffer-name-function' to associate the right session buffer if user requests session interaction from inside Org Src edit buffer. (org-babel-edit-prep:R): Remove in favor of `org-babel-R-associate-session'. * lisp/ob-julia.el (org-babel-julia-associate-session): Implement analogous functionality. (org-babel-edit-prep:julia): Remove in favor of `org-babel-julia-associate-session'. * etc/ORG-NEWS (~org-edit-special~ no longer force-starts session in R and Julia source blocks): Document the change. Link: https://orgmode.org/list/87r0ir2ln8.fsf@gmail.com --- etc/ORG-NEWS | 11 +++++++++++ lisp/ob-R.el | 20 ++++++-------------- lisp/ob-julia.el | 16 +++++++++------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index b808357d8..245e595ff 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -13,6 +13,17 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) ** Important announcements and breaking changes +*** ~org-edit-special~ no longer force-starts session in R and Julia source blocks + +Previously, when R/Julia source block had =:session= header argument +set to a session name with "earmuffs" (like =*session-name*=), +~org-edit-special~ always started a session, if it does not exist. + +Now, ~org-edit-special~ arranges that a new session with correct name +is initiated only when user explicitly executes R/Julia-mode commands +that trigger session interactions. The same session will remain +available in the context of Org babel. + *** ~org-agenda-search-headline-for-time~ now ignores all the timestamp in headings Previously, ~org-agenda-search-headline-for-time~ made Org agenda diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 3d13c55a7..4b5cbf7c9 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -91,17 +91,6 @@ (defcustom org-babel-R-command "R --slave --no-save" :version "24.1" :type 'string) -(defvar ess-current-process-name) ; dynamically scoped -(defvar ess-local-process-name) ; dynamically scoped -(defun org-babel-edit-prep:R (info) - "Initiate R session for Org edit buffer, as needed. -The session name is taken from INFO." - (let ((session (cdr (assq :session (nth 2 info))))) - (when (and session - (string-prefix-p "*" session) - (string-suffix-p "*" session)) - (org-babel-R-initiate-session session nil)))) - ;; The usage of utils::read.table() ensures that the command ;; read.table() can be found even in circumstances when the utils ;; package is not in the search path from R. @@ -292,13 +281,16 @@ (defun org-babel-R-initiate-session (session params) (ess-wait-for-process R-proc))) (current-buffer)))))) +(defvar ess-current-process-name) ; dynamically scoped +(defvar ess-local-process-name) ; dynamically scoped (defun org-babel-R-associate-session (session) "Associate R code buffer with an R session. Make SESSION be the inferior ESS process associated with the current code buffer." - (setq ess-local-process-name - (process-name (get-buffer-process session))) - (ess-make-buffer-current)) + (when-let ((process (get-buffer-process session))) + (setq ess-local-process-name (process-name process)) + (ess-make-buffer-current)) + (setq-local ess-gen-proc-buffer-name-function (lambda (_) session))) (defvar org-babel-R-graphics-devices '((:bmp "bmp" "filename") diff --git a/lisp/ob-julia.el b/lisp/ob-julia.el index cddd25e79..10a331e54 100644 --- a/lisp/ob-julia.el +++ b/lisp/ob-julia.el @@ -70,12 +70,15 @@ (defvar ess-current-process-name) ; dynamically scoped (defvar ess-local-process-name) ; dynamically scoped (defvar ess-eval-visibly-p) ; dynamically scoped (defvar ess-local-customize-alist); dynamically scoped -(defun org-babel-edit-prep:julia (info) - (let ((session (cdr (assq :session (nth 2 info))))) - (when (and session - (string-prefix-p "*" session) - (string-suffix-p "*" session)) - (org-babel-julia-initiate-session session nil)))) +(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el +(defun org-babel-julia-associate-session (session) + "Associate R code buffer with an R session. +Make SESSION be the inferior ESS process associated with the +current code buffer." + (when-let ((process (get-buffer-process session))) + (setq ess-local-process-name (process-name process)) + (ess-make-buffer-current)) + (setq-local ess-gen-proc-buffer-name-function (lambda (_) session))) (defun org-babel-expand-body:julia (body params &optional _graphics-file) "Expand BODY according to PARAMS, return the expanded body." @@ -178,7 +181,6 @@ (defun org-babel-julia-assign-elisp (name value) (format "%s = %s" name (org-babel-julia-quote-csv-field value)))) (defvar ess-ask-for-ess-directory) ; dynamically scoped -(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el (defun org-babel-julia-initiate-session (session params) "If there is not a current julia process then create one." (unless (string= session "none") -- 2.43.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--