From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IHpGAcETuWU5NwAAe85BDQ:P1 (envelope-from ) for ; Tue, 30 Jan 2024 16:20:33 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id IHpGAcETuWU5NwAAe85BDQ (envelope-from ) for ; Tue, 30 Jan 2024 16:20:33 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UAyjhd6P; 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=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706628032; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=OtFdbVjL9d2PLX/fU+VE5i3y8fatEsZcZSf1hIOTjXg=; b=l//tmY+EpLBUEYXRrVMYmtg1wygQRlf8k3ltL1kAM3G1RvrlEIpCTjf31uunJx+ipGSXRd 8w/BWjVC3bgZnHhY9Qz7QeOZ11OYD77YSt/HS3f3v8b3fzbi+Gjzy21pWX3Pp1btRgtDiz J8NFUCg/IuXVtJd/N2p3PWDSz9acJRi5trtvHYyegtRwB+Hs1WYPtYuBEC2KNpiq3s6QNY lj7AL3LGMBM90UaQVCr9cw/Hn9Gi4u9LVi/SOH2DJ6w948kWeDHXca3fm1Ge3LzQmzgT82 q9Bb8DjTWqL3IrttGipZ/fnop3SEH5qggZ3hJnW0Y9VaXhA/vqUizIe6UMuM+g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=UAyjhd6P; 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=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706628032; a=rsa-sha256; cv=none; b=txzpgGvGTvE+AI5fujr+7hvvUIDgPTLQEDzcK6dOPmWq8BR92l8plkpZa0+RTvjqpyljEo TCz7AXH+6UgS6Vc2tOKkbdmaj5g7OqifirjJGjklHBuyF6SCenxj0QM7pLVm/6q6H4Rhmm iHac6KQO2nHZkoeMO7qtdrY8sS8SPR5Oq/jk+RKAQxeq4kDV0G+aOCiEDLBx6vAZjAB/aI YGsHYC/CD6fitptdR7u+/0BNQe8gVw1cmrk8XycCwpx1o0/LMbJ+NAJPwFyZIVDJwdAPtX zrjCZZ74FLmLbpH8RecdRXJnGlUtiCPdgXa25xwsmX1XfDOd/QVFNeTRuZ1ykg== 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 AF81016C0E for ; Tue, 30 Jan 2024 16:20:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUpt4-0005G4-Sg; Tue, 30 Jan 2024 10:19:00 -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 1rUpsx-00058i-Fh for emacs-orgmode@gnu.org; Tue, 30 Jan 2024 10:18:51 -0500 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUpsu-0004oe-Bh for emacs-orgmode@gnu.org; Tue, 30 Jan 2024 10:18:51 -0500 Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-680b1335af6so45896916d6.1 for ; Tue, 30 Jan 2024 07:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706627925; x=1707232725; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=OtFdbVjL9d2PLX/fU+VE5i3y8fatEsZcZSf1hIOTjXg=; b=UAyjhd6P/MxOgVAzXyFJJB4M/3l/KVkOjZ1/NNT3LlAJGPinjyg2IDvcpP0KWJktCl aP3tZTEd/NDo5gtnn5mQ3MjYnDaLCpBrsWhTusv/zPhngnc8/LaohQjeEALGPRjLwUqS YTkc/jfzIPm/5YE3RkJvzAXr1EegJwVIYOoBrGGYFZFJwxP8To5cTEC1gsFciALO5NwQ MQDJlElioRikKwZ0PxlTAWJEUu2IzcJ5sOoThDEPsRmlsQdNeP+ff7l3bS4mHN8i02Hz lDVbyS542r+DRQQadE4Czefa1D5bETq3nHNU6PBsyfvHE4niYfgS9TmP41U8QByZTIGG wWcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706627925; x=1707232725; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OtFdbVjL9d2PLX/fU+VE5i3y8fatEsZcZSf1hIOTjXg=; b=Ba9TyBgHoIsWDX5LsQrQN6Cf0oEdFyJMCNlUxN5xb86kP/FqKylcoeQ3EONbPJM5Gw O4BKYgzMFMokc7c8z0/DgeSh3be9Or6bLjnGY83pWhKsCPp3ekbBMtWIzrrWdSAaQBz0 UuoCKECtBoKYRHxAV6UqJMXsrZDAG89PjAWSQ+RAPyeikYsmiq+IaU/cBnSXBboMHJs9 nWBOfsSgKrdmkbm5xbzO8HR8Xeaknc2FChV8gQxft3ef4TEYZGWVoymrmGm1aq3ctvmm lekPduouD5gZu2Ft0AY9of83olild8TCFcSzwwzoRlkjgFS9HhDygR7OMnx/Qe2Hc58o X7Vw== X-Gm-Message-State: AOJu0Yw8fJ16npfNYg8I5CBqBaeqza0LWBqq5fhbaBP6Wp3xNdhQ8W7o FNj4c3Xr2Mcl8viu3B/lwm6u9GfCFDotqHDt7MyeK9PHyARWe3lA0YZ62QP/xBc= X-Google-Smtp-Source: AGHT+IGeGT/8J2OYqIS/cYU+g5aNi01DFPQjfZuPk7iPdtjeOjZapmXN9sYjfY7ol7WZeUPMpqwjFw== X-Received: by 2002:a0c:b414:0:b0:68b:5142:ba18 with SMTP id u20-20020a0cb414000000b0068b5142ba18mr1729839qve.9.1706627925410; Tue, 30 Jan 2024 07:18:45 -0800 (PST) Received: from tekunen ([2601:547:1500:6340::f92c]) by smtp.gmail.com with ESMTPSA id c25-20020a056214071900b006869dae6ef2sm2943016qvz.106.2024.01.30.07.18.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 07:18:45 -0800 (PST) From: Hunter Jozwiak To: emacs-orgmode@gnu.org Subject: Re: Connecting to an Already Running Scheme REPL with org-babel In-Reply-To: <87v87b829j.fsf@localhost> (Ihor Radchenko's message of "Tue, 30 Jan 2024 11:54:48 +0000") References: <874jex3xxh.fsf@gmail.com> <87v87dm613.fsf@localhost> <87r0i03kgq.fsf@gmail.com> <87il3cmg4o.fsf@localhost> <87zfwojbsn.fsf@gmail.com> <87v87b829j.fsf@localhost> Date: Tue, 30 Jan 2024 10:18:43 -0500 Message-ID: <87v87akfxo.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="===-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=hunter.t.joz@gmail.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: -12.08 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: -12.08 X-Migadu-Queue-Id: AF81016C0E X-TUID: 1CZ5YcnYBdVR --===-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain Ihor Radchenko writes: > Hunter Jozwiak writes: > >>>> + (host (cdr (assq :host params))) >>>> + (port (cdr (assq :port params))) >>> >>> Please declare these new scheme-specific header argument in >>> `org-babel-header-args:scheme'. >>> See `org-babel-header-args:C' for an example. >>> This is necessary for header argument completion to work. > >> Okay. Is there a way to tighten these inputs further? I have them set to >> :any for the moment, but I wonder if there is a way to leverage the >> values for `geiser-repl-default-host` and `geiser-repl-default-port`. > > Org-mode currently does not provide completion for header argument > values. (see `pcomplete/org-mode/block-option/src') > > If Org were to support such completion, you could theoretically allow > special values for :host/:port like default: > > #+begin_src scheme :host default :port default > ... > #+end_src > > to use `geiser-repl-default-host'/`...-port'. > > Then, you could add these values as (default :any). > >>>> - (and (not (string= session "none")) session)))) ; session >>>> + (and (not (string= session "none")) session) host port))) ; session >>> >>> This does not look right. Your change will disable session support >>> completely when host and port are not provided. >> Is there a way to test this and pinpoint the problem? > > Hmm. I just realized that I am reading that line wrongly - host and port > are additional arguments passed to > `org-babel-scheme-execute-with-geiser', not a part of > (and (not ...) host port) > > So, my only comment remaining is to put each argument in its own line, > like it is done for all the previous arguments: > > (org-babel-scheme-execute-with-geiser > full-body ; code > (string= result-type "output") ; output? > impl ; implementation > (and (not (string= session "none")) session) ; session > host ; repl host name > port) ; repl port > > That will make the code more readable. Here is an updated patch. --==-=-= Content-Type: text/html

Ihor Radchenko <yantar92@posteo.net> writes:

Hunter Jozwiak <hunter.t.joz@gmail.com> writes:

+ (host (cdr (assq :host params))) + (port (cdr (assq :port params)))

Please declare these new scheme-specific header argument in `org-babel-header-args:scheme'. See `org-babel-header-args:C' for an example. This is necessary for header argument completion to work.

Okay. Is there a way to tighten these inputs further? I have them set to :any for the moment, but I wonder if there is a way to leverage the values for `geiser-repl-default-host` and `geiser-repl-default-port`.

Org-mode currently does not provide completion for header argument values. (see `pcomplete/org-mode/block-option/src')

If Org were to support such completion, you could theoretically allow special values for :host/:port like default:

#+beginsrc scheme :host default :port default … #+endsrc

to use `geiser-repl-default-host'/`…-port'.

Then, you could add these values as (default :any).

- (and (not (string= session "none")) session)))) ; session + (and (not (string= session "none")) session) host port))) ; session

This does not look right. Your change will disable session support completely when host and port are not provided.
Is there a way to test this and pinpoint the problem?

Hmm. I just realized that I am reading that line wrongly - host and port are additional arguments passed to `org-babel-scheme-execute-with-geiser', not a part of (and (not …) host port)

So, my only comment remaining is to put each argument in its own line, like it is done for all the previous arguments:

(org-babel-scheme-execute-with-geiser full-body ; code (string= result-type "output") ; output? impl ; implementation (and (not (string= session "none")) session) ; session host ; repl host name port) ; repl port

That will make the code more readable.

Here is an updated patch.

--==-=-=-- --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-mode-allow-ob-scheme-to-accept-a-remote-connecti.patch Content-Transfer-Encoding: quoted-printable Content-Description: Updated patch. From=20ff82afda9b862a7899abf10b7d1a4cde3c1d5314 Mon Sep 17 00:00:00 2001 From: Hunter Jozwiak Date: Sun, 28 Jan 2024 21:48:05 -0500 Subject: [PATCH] org-mode: allow ob-scheme to accept a remote connection. * lisp/org/ob-scheme.el (org-babel-scheme-get-repl): introduce two optional variables host and port. If there are not given, just run Geiser as before. In the case when both are given, connect to the remotely running Scheme process. * lisp/org/ob-scheme (org-babel-scheme-execute-with-geiser, org-babel-execute:scheme): take these optional arguments into account. * lisp/org/ob-scheme.el (org-babel-header-args:scheme): define host and port for completion. =2D-- lisp/org/ob-scheme.el | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lisp/org/ob-scheme.el b/lisp/org/ob-scheme.el index d13b975084c..4a214b222eb 100644 =2D-- a/lisp/org/ob-scheme.el +++ b/lisp/org/ob-scheme.el @@ -1,4 +1,4 @@ =2D;;; ob-scheme.el --- Babel Functions for Scheme -*- lexical-binding= : t; -*- +;; ob-scheme.el --- Babel Functions for Scheme -*- lexical-binding: t= ; -*- =20 ;; Copyright (C) 2010-2024 Free Software Foundation, Inc. =20 @@ -54,7 +54,7 @@ geiser-debug-show-debug-p (defvar geiser-debug-jump-to-debug-p) ; Defined in geiser-debug.el (defvar geiser-repl-use-other-window) ; Defined in geiser-repl.el (defvar geiser-repl-window-allow-split) ; Defined in geiser-repl.el =2D +(declare-function geiser-connect "ext:geiser-repl" (impl &optional host po= rt)) (declare-function run-geiser "ext:geiser-repl" (impl)) (declare-function geiser "ext:geiser-repl" (impl)) (declare-function geiser-mode "ext:geiser-mode" ()) @@ -75,6 +75,9 @@ org-babel-scheme-null-to =20 (defvar org-babel-default-header-args:scheme '() "Default header arguments for scheme code blocks.") +(defconst org-babel-header-args:scheme '((host . :any) + (port . :any)) + "Header arguments supported in Scheme.") =20 (defun org-babel-expand-body:scheme (body params) "Expand BODY according to PARAMS, return the expanded body." @@ -116,13 +119,17 @@ org-babel-scheme-get-buffer-impl (with-current-buffer (set-buffer buffer) geiser-impl--implementation)) =20 =2D(defun org-babel-scheme-get-repl (impl name) =2D "Switch to a scheme REPL, creating it if it doesn't exist." +(defun org-babel-scheme-get-repl (impl name &optional host port) + "Switch to a scheme REPL, creating it if it doesn't exist. + +If the variables host and port are set, connect to the running Scheme REPL= ." (let ((buffer (org-babel-scheme-get-session-buffer name))) (or buffer (progn (if (fboundp 'geiser) =2D (geiser impl) + (if (and host port) + (geiser-connect impl host port) + (geiser impl)) ;; Obsolete since Geiser 0.26. (run-geiser impl)) (when name @@ -159,7 +166,7 @@ org-babel-scheme-capture-current-message ,@body (current-message)))) =20 =2D(defun org-babel-scheme-execute-with-geiser (code output impl repl) +(defun org-babel-scheme-execute-with-geiser (code output impl repl &optio= nal host port) "Execute code in specified REPL. If the REPL doesn't exist, create it using the given scheme implementation. @@ -175,7 +182,7 @@ org-babel-scheme-execute-with-geiser (let ((geiser-repl-window-allow-split nil) (geiser-repl-use-other-window nil)) (let ((repl-buffer (save-current-buffer =2D (org-babel-scheme-get-repl impl repl)))) + (org-babel-scheme-get-repl impl repl host port)))) (when (not (eq impl (org-babel-scheme-get-buffer-impl (current-buffer)))) (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp imp= l) @@ -231,6 +238,8 @@ org-babel-execute:scheme geiser-scheme-implementation geiser-default-implementation (car geiser-active-implementations))) + (host (cdr (assq :host params))) + (port (cdr (assq :port params))) (session (org-babel-scheme-make-session-name source-buffer-name (cdr (assq :session params)) impl)) (full-body (org-babel-expand-body:scheme body params)) @@ -240,7 +249,9 @@ org-babel-execute:scheme full-body ; code (string=3D result-type "output") ; output? impl ; implementation =2D (and (not (string=3D session "none")) session)))) ; session + (and (not (string=3D session "none")) session) ; session + host ; REPL host + port))) ; REPL port (let ((table (org-babel-reassemble-table result =2D-=20 2.43.0 --=-=-=-- --===-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFLBAEBCAA1FiEE8JmX63p3mcKAxtRbc+osy8QJTuEFAmW5E1MXHGh1bnRlci50 LmpvekBnbWFpbC5jb20ACgkQc+osy8QJTuGVCQgAjEVQQzZ7exQ/wHDD2nmBppaV hl38Q/twfAStoBjCE34ef94k8IbPTLpD1sC1DoFy9TzO08Xise3m6wGEzo9wYZtf xWnE9HC3EB5nIJkGkQRpgn0zeicie6FnlXws90T20QVhvVxMvCrUXB0X2Fg54Qbh Idti1aBO/9nmuILV3ck+dir+dfTgjiZR6pqnOvyvrdpJABX7vU3EphXARCNcYDb6 pJ/HVCbbmjdg/eGcA4/uz/YNbIdPoD/HuNP8oFKowFSByq/iafdmiT6e0zj41LcP u2sSB8Uh/Y86kgQG6iyDogC8GASwZQk5xIvLf6CgAg8DXsm24d16R6zVtpL5eg== =qUpq -----END PGP SIGNATURE----- --===-=-=--