From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id gCDOHRyDfWdrJwEAqHPOHw:P1 (envelope-from ) for ; Tue, 07 Jan 2025 19:40:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id gCDOHRyDfWdrJwEAqHPOHw (envelope-from ) for ; Tue, 07 Jan 2025 20:40:12 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=rensoliemans.nl header.s=soverin header.b=ZuhZzBg2; 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=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1736278811; 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=NKFLDx3noWVXDNwOv2AFiCDWoHBZo72n7E9l+dI0Mbw=; b=FeGReA+7EgBeAdggTK8z67HekqFUAonyCaB1jr3zWa1SGvQnGTSB/kT5hay3wCeNcO+qi4 S3ghhB1HroB7jYMXnCKdJBbQs1urapE03q57S3rs+H4WCbHDbTChBzubrAFv1s9oIdBDn8 u56Nch0SOOuDblG2Ysg7wn6TEe7yrOZQDg3bw9JCWAxWj1pz5gkdTD0DbDUdPsRYXyNmsB p+VwnpylZWlnim+gxDAYkHWeD2EsK6vbeXvmaq0bnIMA8BYZrnnzpsmzyw9vfFtrnBPTkb Mth1sizpJZmTpdqwfIXQCTyJJobpC2tEdvCndwPhgapmtG25ZChiYDFJWqNWmw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=rensoliemans.nl header.s=soverin header.b=ZuhZzBg2; 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=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1736278811; a=rsa-sha256; cv=none; b=Q+/5VvxUezfWEKre533jRqmhKSGGEyIShO5ZgTwWrHF7DBJCEbCpI7iON05mqp82A2FDlK SRkImSgo5H3trOaVr5c5TosRWLr4zSEloeb2iHAtL3PUGTVYQckguDN8frTfdNia+4NFJD SZgrXZhiuv81pu7qovCclUNntypfdKcJdqzdKHy7zOgHIzOdTNxky28TRHtGqAW2/2Kp8E CsCWaWI5VMG5V4gOU/qcJKuqV5KvZXE4VMQopxXWxeDmZABSmISAU1ujnLmQfFpka6AqX3 xZ0XcsI6ReSHp/7zOeGvUIMn+Yp5rQYdyL8TwokPG0JrHmB8JD3B+2KeaK07FA== 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 3D3985E3E4 for ; Tue, 07 Jan 2025 20:40:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVFQB-0008Sn-98; Tue, 07 Jan 2025 14:39:23 -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 1tVFQ8-0008RT-IG for emacs-orgmode@gnu.org; Tue, 07 Jan 2025 14:39:21 -0500 Received: from outbound.soverin.net ([185.233.34.146]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVFQ3-0000jK-Ry for emacs-orgmode@gnu.org; Tue, 07 Jan 2025 14:39:20 -0500 Received: from smtp.soverin.net (c04cst-smtp-sov02.int.sover.in [10.10.4.100]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 4YSLvp1Cqgz7f; Tue, 7 Jan 2025 19:39:02 +0000 (UTC) Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by soverin.net (Postfix) with ESMTPSA id 4YSLvn2c35z1d; Tue, 7 Jan 2025 19:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rensoliemans.nl; s=soverin; t=1736278742; bh=hSgcjRVZpP5bnArbMlOq00nSSD2cAihpSmORbdjGufs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ZuhZzBg2YOr4+Zffxl2r3cFPPEO+R2oCjKF5XAkotHqf9xtQwpGMY54Edpx1TliVl xHCOeno6EIy4p+ZUdhsU5x7R1sTcbfVkOBqf777udPa/8iqPfxB2tBdzfHyShyGA+j 7hQyer/Nkk68E9DmvaW87XxzpLIgswaMkJYiCjhbKZgjlqdeIIn9A0S5uUIjKVw9/A bAgAWVQt6pb1diJkh7qwaAw+j1+jXCg16Ye3Q2QUxvXMOwIMgBeF8ktNkkwF7MEwPG HIPjTkGHiAwWJd65sU5EQWcH/OISZ/y4Sm1CO4egfANp5abylgDHV9mXuAYUYWByJu XoxxYhNYsB1Ew== X-CMAE-Score: 0 X-CM-Envelope: MS4xfChGoPZ6wJzTp0NDAK7o7z1X2l7DwE2F2II3BXHjuIJV9NwALWac+QEEgTrY+lYlM75X7b04DnDmtbyLcE3brT87XGDYorPQww6SSjDnEReVBRcuE9WY u2lQLw4SXwzaCZFwT0yRCYA8HTwwxcLhnsOhsVWBD4Lng8vr/RBRFTgF9m6alXtEVLZEbuUVxIrmVKATi/VYQ+ir/XGew6CfZ5qjAb9egw8SQ2JcqtgpvU2Z 76oBjtFQZUgfHf+c8IT6BAoPQd+i1te0EbDUOg4ZrM66BP4zi0CoIRX7YDmCFG3FsX4Hy2LiJWcqVm1JSgFffA== X-CM-Analysis: v=2.4 cv=UsCZN/wB c=1 sm=1 tr=0 ts=677d82d5 a=4bom3OyIvp8zk49k3DLuvQ==:617 a=xqWC_Br6kY4A:10 a=uChsZFC9AAAA:8 a=m5GSA0hEBrUM5eoJoHsA:9 a=mDV3o1hIAAAA:8 a=iwN5AyGDq5iWONXh20YA:9 a=ULtXvzFHYWHLyBAuiDia:22 From: Rens Oliemans To: Ihor Radchenko Cc: "emacs-orgmode@gnu.org" , Daniel Kraus Subject: Re: [BUG] ob-clojure doesn't handle namespaces properly In-Reply-To: <87v7vc7x4a.fsf@localhost> References: <87mshdowic.fsf@rensoliemans.nl> <87v7vc7x4a.fsf@localhost> Date: Tue, 07 Jan 2025 20:39:52 +0100 Message-ID: <87a5c2s99z.fsf@rensoliemans.nl> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spampanel-Class: ham Received-SPF: pass client-ip=185.233.34.146; envelope-from=hallo@rensoliemans.nl; helo=outbound.soverin.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-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 X-Migadu-Queue-Id: 3D3985E3E4 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 0.43 X-Spam-Score: 0.43 X-TUID: ImO03RhLoHQ3 --=-=-= Content-Type: text/plain Sorry for the late reply, I took a good holiday. Ihor Radchenko writes: > I cannot reproduce the problems you are showing. Although I am able to > reproduce *different* problems. That's interesting, I can reproduce the problems with emacs -Q. Attached is the new org file which reproduces the error with =make repro=. Included are some settings (such as installing clojure-mode and cider). Apologies for the longish file, if I had more time I would have made it shorter. "Bug 2" is easiest to reproduce, it just requires a tangle and 'clj -M tangled.clj' should then fail. Best, Rens --=-=-= Content-Type: text/org Content-Disposition: attachment; filename=bugs.org #+title: Clojure bugs I bisected this to [[https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6efb073463481ee572eb3bb1155cc3b0d6987df6][6efb073463481ee572eb3bb1155cc3b0d6987df6]]. I've only tested this on =cider=, I'm not sure if that makes a difference. * Preface I'm running this via =make repro=, on [[https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=405787dfbcbd4ae5e1d2227ce5aa7d4d20938388][405787dfbcbd4ae5e1d2227ce5aa7d4d20938388]]. This installs and loads =cider= and =clojure-mode= - I usually do this via =use-package= but that makes the config for this a bit more complicated, so please forgive any uncommon practices. #+begin_src elisp :results silent (require 'ob-core) ;(setq org-confirm-babel-evaluate nil) (org-babel-do-load-languages 'org-babel-load-languages '((shell . t) (clojure . t))) (require 'ob-clojure) (setq org-babel-clojure-backend 'cider) (require 'package) (package-initialize) (package-refresh-contents) (package-install 'clojure-mode) (package-install 'cider) (add-to-list 'load-path "~/.emacs.d") (require 'clojure-mode) (require 'cider) #+end_src * Bug 1: Different namespaces in the same document don't work well Say I have the following structure: ** Util :PROPERTIES: :header-args:clojure: :exports both :session *clojure-util* :END: It seems ~(ns example.util)~ isn't run properly in the first code block: =sum= gets added to the default =user= namespace the first time it's run. The second time it's run, it does work as expected. In general, a block with a ~(ns)~ call needs to be run twice, it seems? Rather than executing the code blocks below, check the list of CALLS below them so they're executed in the correct order. #+name: define-sum #+begin_src clojure (ns example.util) (defn sum [vec] (reduce + vec)) #+end_src #+name: use-sum #+begin_src clojure (sum (range 10)) #+end_src *** Calls Execute these calls one by one: For this one, I use =cider-jack-in-clj=. #+CALL: define-sum() #+RESULTS: : Please reevaluate when nREPL is connected The call below should, imo, add =sum= to the =util= namespace, which it doesn't. #+CALL: define-sum() #+RESULTS: : #'user/sum Therefore, the call below errors: #+CALL: use-sum() #+RESULTS: : class clojure.lang.Compiler$CompilerException When =define-sum= is run for the second time, it's added correctly. #+CALL: define-sum() #+RESULTS: : #'example.util/sum And it can be used as expected. #+CALL: use-sum() #+RESULTS: : 45 ** Program using Util :PROPERTIES: :header-args:clojure: :exports both :session *clojure-01* :END: This code block always errors: #+begin_src clojure (ns example.program (:require [example.util :as util])) (util/sum (range 10)) #+end_src #+RESULTS: : class clojure.lang.Compiler$CompilerException * Bug 2: When tangling, code blocks can't see previously defined vars :PROPERTIES: :header-args:clojure: :tangle tangled.clj :session *clojure-tangle* :results none :END: Let's create a clojure file that first defines a function =sum=: #+begin_src clojure (ns example.tangle) (defn sum [xs] (reduce + xs)) #+end_src And then uses it: #+begin_src clojure (sum (range 10)) #+end_src If we tangle this subtree, we get the following output: #+begin_src elisp (org-babel-tangle) (with-temp-buffer (insert-file-contents "tangled.clj") (buffer-string)) #+end_src #+RESULTS: : (prn (binding [*out* (java.io.StringWriter.)](ns example.tangle) : : (defn sum [xs] (reduce + xs)))) : : (prn (binding [*out* (java.io.StringWriter.)](sum (range 10)))) Note that each code block is wrapped in an invidiual =(prn (binding ...))= block. This means that later code blocks have a different scope to prior code blocks. Executing this file also leads to an error: #+begin_src sh :results output clj -M tangled.clj 2>&1 #+end_src #+RESULTS: : #'user/sum : Syntax error compiling at (tangled.clj:5:46). : Unable to resolve symbol: sum in this context : : Full report at: : /tmp/clojure-11215251630972501185.edn --=-=-=--