From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WJBCEcsUomO2EgAAbAwnHQ (envelope-from ) for ; Tue, 20 Dec 2022 21:02:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id eBJqEMsUomNejwAAG6o9tA (envelope-from ) for ; Tue, 20 Dec 2022 21:02:19 +0100 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 A262E2DF32 for ; Tue, 20 Dec 2022 21:02:18 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7inF-0001WP-W4; Tue, 20 Dec 2022 15:00:54 -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 1p7inD-0001W1-2n for emacs-orgmode@gnu.org; Tue, 20 Dec 2022 15:00:52 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.160]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p7inA-0000SQ-GC for emacs-orgmode@gnu.org; Tue, 20 Dec 2022 15:00:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1671566445; s=strato-dkim-0002; d=nieper-wisskirchen.de; h=Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:Cc:Date: From:Subject:Sender; bh=PrFyguDr/ZMZVa+q3lcMs+03TrpUOJvSsO1R4ybO6cc=; b=mFzZM8fjbudQ7hssMSX2MvGp5rWCj+8AKYkgcJ+LPx1DEvW7lcDxs5D1zjbZoDiJhL SR5yn+uWg9fe7SEdblV17uZa3H3WzU0IsiPyjCK7U5MiJFgxF7bEHxEApnDV2waHN6Yn qsMm5yGg66v8OoCqLvrphPnqs/GxHRvRrlCUhaZcyeOhZpymO/neEH6DfdzpeMuMGH6O 723OfvIurn1x64Ggd1DJnIn0Y5MDsQCsx7HeW5cIVWc/OwLw/RQ/1uEoAKgeo/O5N51U YtEgOl+5/YZWQce2whpyNmEUXzHfRaU8TVbwizQUfP8iYGf1zhFl1P7u2qfKhM7RNZY2 XI6A== X-RZG-AUTH: ":IW0WdmCmcvpIrP2+VJuPtIhjJvc4Ig+QdhX22iZVwSDOx4Kp3cYsBVGy6CZgmO/guIaKVMt57pGh" X-RZG-CLASS-ID: mo00 Received: from mail-wr1-f44.google.com by smtp.strato.de (RZmta 48.2.1 AUTH) with ESMTPSA id jcf20dyBKK0jaeE (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Tue, 20 Dec 2022 21:00:45 +0100 (CET) Received: by mail-wr1-f44.google.com with SMTP id i7so12838392wrv.8 for ; Tue, 20 Dec 2022 12:00:45 -0800 (PST) X-Gm-Message-State: ANoB5pmJ2Nezl5RW9WcXWLrjLugm2hQdicv6W2AN4x9IOJ7zmsEyBEjD zSApGcKB3GX6kL+oZk6dS6Q2akMz69RD3VbXmF0= X-Google-Smtp-Source: AA0mqf6uPc16H9x2X6ObDuXZTkODF81Ahh7FVWZz/Lw7StU5z7t2amt1dLcV5oGO8bqq1+avx4lYau6ag22JvXWOLLQ= X-Received: by 2002:a5d:6603:0:b0:24b:b74d:801f with SMTP id n3-20020a5d6603000000b0024bb74d801fmr2159665wru.567.1671566444755; Tue, 20 Dec 2022 12:00:44 -0800 (PST) MIME-Version: 1.0 References: <87k02o7uki.fsf@localhost> In-Reply-To: From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Tue, 20 Dec 2022 21:00:32 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Babel (scheme): Evaluation errors are not shown To: =?UTF-8?Q?Rudolf_Adamkovi=C4=8D?= Cc: Ihor Radchenko , emacs-orgmode@gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: none client-ip=81.169.146.160; envelope-from=marc@nieper-wisskirchen.de; helo=mo4-p00-ob.smtp.rzone.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=nieper-wisskirchen.de header.s=strato-dkim-0002 header.b=mFzZM8fj; dmarc=none; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671566538; a=rsa-sha256; cv=none; b=LTeyuqoMrkG1Urd9puqRI9UZHvt1zOIZJrnCVcXoFDCFtuPDlUVhymYKozpN78E7v6sbzk JjJULOcU1MZydDGkXLSbcslqLA6GxcsfvOpDlv+K7t2GADPDiUu9g0oFpGllvH07A1XA8y 0jZSCe1JBMalScF6mEtStY1xOD550m8MHOrmnWIgj+wjVcCqY3bqBk3elwZm63FrPzdYIg In76/nd1m0bRr7ghfDUs7THt+yOghknEDg/RtgCt9NEsWbbJR3jkh6GkXYINd2zv5v+pfH BB9IAvbuTAWF/s/A7gYp6Mc5Hw8xsiM1//RpFmMClZSBeydy6m44vaHjBRj6sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671566538; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=PrFyguDr/ZMZVa+q3lcMs+03TrpUOJvSsO1R4ybO6cc=; b=D8RXrvirLMI2E60a0VE5xgRht7Z0/mu8JWNobDrEup0CMhpbbrXTEdNt42IAmhr592Gpbm H2BtzOqUlK+yB4JOPssIHOpC9S1LgcDxWAl6N+dLGLGowNVNA+cTEdNoA1t/BHtC5bGhco n+F5x+JcIlwCVGZfXny4gGBs94zOL+89t+IkTuE+worq17N206TWGCcMpzHrvxuWN7J6zN avxLDlQXz3Vf5erGyx5tGcvsUxwBjLRDoioLN13kevlvH+xL+nZmhPUk5meUoboKxzXXtX o47/Jxesc+AvwyBnO48MP3GSI9InHH5wtfT36Kwzg2PCJG2IFyzU+95H6bonZQ== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=nieper-wisskirchen.de header.s=strato-dkim-0002 header.b=mFzZM8fj; dmarc=none; 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" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -1.79 X-Spam-Score: -1.79 X-Migadu-Queue-Id: A262E2DF32 X-TUID: ODya2TNgUns2 I have been talking to jao (from geiser). The following version of ob-scheme.el signals an error when executing Scheme code blocks. Besides two function declarations, the only change is in the function org-babel-scheme-execute-with-geiser. ;;; ob-scheme.el --- Babel Functions for Scheme -*- lexical-binding: t= ; -*- ;; Copyright (C) 2010-2022 Free Software Foundation, Inc. ;; Authors: Eric Schulte ;; Michael Gauland ;; Keywords: literate programming, reproducible research, scheme ;; URL: https://orgmode.org ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;; Commentary: ;; Now working with SBCL for both session and external evaluation. ;; ;; This certainly isn't optimally robust, but it seems to be working ;; for the basic use cases. ;;; Requirements: ;; - a working scheme implementation ;; (e.g. guile https://www.gnu.org/software/guile/guile.html) ;; ;; - for session based evaluation geiser is required, which is available fr= om ;; ELPA. ;;; Code: (require 'org-macs) (org-assert-version) (require 'ob) (require 'geiser nil t) (require 'geiser-impl nil t) (defvar geiser-repl--repl) ; Defined in geiser-repl.el (defvar geiser-impl--implementation) ; Defined in geiser-impl.el (defvar geiser-scheme-implementation) ; Defined in geiser-impl.el (defvar geiser-default-implementation) ; Defined in geiser-impl.el (defvar geiser-active-implementations) ; Defined in geiser-impl.el (defvar geiser-debug-show-debug-p) ; Defined in geiser-debug.el (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 (declare-function run-geiser "ext:geiser-repl" (impl)) (declare-function geiser "ext:geiser-repl" (impl)) (declare-function geiser-mode "ext:geiser-mode" ()) (declare-function geiser-eval-region "ext:geiser-mode" (start end &optional and-go raw nomsg)) (declare-function geiser-eval-region/wait "ext:geiser-mode" (start end &optional timeout)) (declare-function geiser-repl-exit "ext:geiser-repl" (&optional arg)) (declare-function geiser-eval--retort-output "ext:geiser-eval" (ret)) (declare-function geiser-eval--retort-result-str "ext:geiser-eval" (ret pre= fix)) (declare-function geiser-eval--retort-error "ext:geiser-eval" (ret)) (declare-function geiser-eval--retort-error-msg "ext:geiser-eval" (err)) (defcustom org-babel-scheme-null-to 'hline "Replace `null' and empty lists in scheme tables with this before returni= ng." :group 'org-babel :version "26.1" :package-version '(Org . "9.1") :type 'symbol) (defvar org-babel-default-header-args:scheme '() "Default header arguments for scheme code blocks.") (defun org-babel-expand-body:scheme (body params) "Expand BODY according to PARAMS, return the expanded body." (let ((vars (org-babel--get-vars params)) (prepends (cdr (assq :prologue params))) (postpends (cdr (assq :epilogue params)))) (concat (and prepends (concat prepends "\n")) (if (null vars) body (format "(let (%s)\n%s\n)" (mapconcat (lambda (var) (format "%S" (print `(,(car var) ',(cdr var))))) vars "\n ") body)) (and postpends (concat "\n" postpends))))) (defvar org-babel-scheme-repl-map (make-hash-table :test #'equal) "Map of scheme sessions to session names.") (defun org-babel-scheme-cleanse-repl-map () "Remove dead buffers from the REPL map." (maphash (lambda (x y) (unless (buffer-name y) (remhash x org-babel-scheme-repl-m= ap))) org-babel-scheme-repl-map)) (defun org-babel-scheme-get-session-buffer (session-name) "Look up the scheme buffer for a session; return nil if it doesn't exist.= " (org-babel-scheme-cleanse-repl-map) ; Prune dead sessions (gethash session-name org-babel-scheme-repl-map)) (defun org-babel-scheme-set-session-buffer (session-name buffer) "Record the scheme buffer used for a given session." (puthash session-name buffer org-babel-scheme-repl-map)) (defun org-babel-scheme-get-buffer-impl (buffer) "Return the scheme implementation geiser associates with the buffer." (with-current-buffer (set-buffer buffer) geiser-impl--implementation)) (defun org-babel-scheme-get-repl (impl name) "Switch to a scheme REPL, creating it if it doesn't exist." (let ((buffer (org-babel-scheme-get-session-buffer name))) (or buffer (progn (if (fboundp 'geiser) (geiser impl) ;; Obsolete since Geiser 0.26. (run-geiser impl)) (when name (rename-buffer name t) (org-babel-scheme-set-session-buffer name (current-buffer))) (current-buffer))))) (defun org-babel-scheme-make-session-name (buffer name impl) "Generate a name for the session buffer. For a named session, the buffer name will be the session name. If the session is unnamed (nil), generate a name. If the session is `none', use nil for the session name, and org-babel-scheme-execute-with-geiser will use a temporary session." (cond ((not name) (concat buffer " " (symbol-name impl) " REPL")) ((string=3D name "none") nil) (name))) (defmacro org-babel-scheme-capture-current-message (&rest body) "Capture current message in both interactive and noninteractive mode." `(if noninteractive (let ((original-message (symbol-function 'message)) (current-message nil)) (unwind-protect (progn (defun message (&rest args) (setq current-message (apply original-message args))) ,@body current-message) (fset 'message original-message))) (progn ,@body (current-message)))) (defun org-babel-scheme-execute-with-geiser (code output impl repl) "Execute code in specified REPL. If the REPL doesn't exist, create it using the given scheme implementation. Returns the output of executing the code if the OUTPUT parameter is true; otherwise returns the last value." (let ((result nil)) (with-temp-buffer (insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl)) (newline) (insert code) (geiser-mode) (let ((geiser-repl-window-allow-split nil) (geiser-repl-use-other-window nil)) (let ((repl-buffer (save-current-buffer (org-babel-scheme-get-repl impl repl)))) (when (not (eq impl (org-babel-scheme-get-buffer-impl (current-buffer)))) (message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp i= mpl) (org-babel-scheme-get-buffer-impl (current-buffer)) (symbolp (org-babel-scheme-get-buffer-impl (current-buffer))))) (setq geiser-repl--repl repl-buffer) (setq geiser-impl--implementation nil) (let ((geiser-debug-jump-to-debug-p nil) (geiser-debug-show-debug-p nil)) ;; `geiser-eval-region/wait' was introduced to await the ;; result of async evaluation in geiser version 0.22. (let ((ret (funcall (if (fboundp 'geiser-eval-region/wait) #'geiser-eval-region/wait #'geiser-eval-region) (point-min) (point-max)))) (let ((err (geiser-eval--retort-error ret))) (unless err (setq result (if output (or (geiser-eval--retort-output ret) "Geiser Interpreter produced no output") (geiser-eval--retort-result-str ret "")))) (when (not repl) (save-current-buffer (set-buffer repl-buffer) (geiser-repl-exit)) (set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil) (kill-buffer repl-buffer)) (when err (let ((msg (geiser-eval--error-msg err))) (user-error "%s" (if (listp msg) (car msg) msg)))))))))= ) result)) (defun org-babel-scheme--table-or-string (results) "Convert RESULTS into an appropriate elisp value. If the results look like a list or tuple, then convert them into an Emacs-lisp table, otherwise return the results as a string." (let ((res (org-babel-script-escape results))) (cond ((listp res) (mapcar (lambda (el) (if (or (null el) (eq el 'null)) org-babel-scheme-null-to el)) res)) (t res)))) (defun org-babel-execute:scheme (body params) "Execute a block of Scheme code with org-babel. This function is called by `org-babel-execute-src-block'." (let* ((source-buffer (current-buffer)) (source-buffer-name (replace-regexp-in-string ;; zap surrounding * "^ ?\\*\\([^*]+\\)\\*" "\\1" (buffer-name source-buffer)))) (save-excursion (let* ((result-type (cdr (assq :result-type params))) (impl (or (when (cdr (assq :scheme params)) (intern (cdr (assq :scheme params)))) geiser-scheme-implementation geiser-default-implementation (car geiser-active-implementations))) (session (org-babel-scheme-make-session-name source-buffer-name (cdr (assq :session params)) impl)) (full-body (org-babel-expand-body:scheme body params)) (result-params (cdr (assq :result-params params))) (result (org-babel-scheme-execute-with-geiser full-body ; code (string=3D result-type "output") ; output? impl ; implementation (and (not (string=3D session "none")) session)))) ; session (let ((table (org-babel-reassemble-table result (org-babel-pick-name (cdr (assq :colname-names params)) (cdr (assq :colnames params))) (org-babel-pick-name (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))) (org-babel-result-cond result-params result (org-babel-scheme--table-or-string table))))))) (provide 'ob-scheme) ;;; ob-scheme.el ends here Am Di., 20. Dez. 2022 um 01:39 Uhr schrieb Rudolf Adamkovi=C4=8D : > > Ihor Radchenko writes: > > > Note that we currently have no maintainer for ob-scheme and hence can > > only provide very limited support. New features are hard for us > > without experience with scheme and geiser. > > I volunteer to maintain `ob-scheme'. > > (I use Scheme and Geiser heavily at work, albeit not via Org.) > > Rudy > -- > "Mathematics takes us still further from what is human into the region > of absolute necessity, to which not only the actual world, but every > possible world, must conform." > -- Bertrand Russell, 1902 > > Rudolf Adamkovi=C4=8D [he/him] > Studenohorsk=C3=A1 25 > 84103 Bratislava > Slovakia