From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id sFMCLEJo+GY/xQAAqHPOHw:P1 (envelope-from ) for ; Sat, 28 Sep 2024 20:34:10 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id sFMCLEJo+GY/xQAAqHPOHw (envelope-from ) for ; Sat, 28 Sep 2024 22:34:10 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jVkZoY7R; dmarc=pass (policy=none) header.from=gmail.com; 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1727555650; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ku7uN4UzFuejMNBZ/4l5faSBcmRAJOFBg7DuhDvd/pY=; b=eduBn5/vXNxSAR6+nnu1qWJsdWw5KigNHWRak48FcE/7GVOebloSvkjXVQ7Rw2U2+q6P8y xkyZSvzPOfGakjzZDO2CD4qHDrnk1vQ1OfHPC8dMQwujPYs7JrYyCTbMbEF6YXCmBTkSOB Frw5M3m0TwOrjcfeFEmbmGfeZvEJLkbw1zSJL0XrqVmKzwZlSA4HElTJgCspYIbToF5Jun sTJlKFJWMyMvnwvMBfanW2y3tL4X7RiUmMozORHTybmpLsM+1FbO0ZeZr2lsdLYxMWMPYX 5OP63NLHgikkxMfp12T0sgvbk4yG/A7Sq9LLGiN4tLZNa47Xx6CMeEjDd3uOiw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jVkZoY7R; dmarc=pass (policy=none) header.from=gmail.com; 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=1727555650; a=rsa-sha256; cv=none; b=EPjRy+vbFEBF4Svex5KKE849F7JTeIIesOW/XDiO0Lj+t54+5nZ4icDKWhGsW0YFH2Xn+T byPsPWOKH2BlIxbqcprXSJgz1/GxqTlx/hKI3BgyhNzLn/Hbon8iWxNczbwI/DpeiuraH0 kWlU2aFijOn+iG5KugVZAxgP8MA9lG2oy9LZ/NWDIEWfilv0NW/qCx9aHf7YkamAdcF+KN /uSSn7cwAKY/tn7b49Tk/ceZexUh9yLXozkwR/9IukT46+1t5MTm2cvq9e75chiAXXyHUh 6XGP0p/A2zN5R0NQt+PZebMlmHQAv/iZQ85piZrkZz6po1v9Wk1/v6s6GsQKYQ== 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 2641D7C63A for ; Sat, 28 Sep 2024 22:34:10 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sue82-0007F3-6c; Sat, 28 Sep 2024 16:33:22 -0400 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 1sue7z-0007En-Ic for emacs-orgmode@gnu.org; Sat, 28 Sep 2024 16:33:20 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sue7x-000260-QD for emacs-orgmode@gnu.org; Sat, 28 Sep 2024 16:33:19 -0400 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7a9a7bea3cfso214091585a.1 for ; Sat, 28 Sep 2024 13:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727555596; x=1728160396; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=ku7uN4UzFuejMNBZ/4l5faSBcmRAJOFBg7DuhDvd/pY=; b=jVkZoY7RhMtqpwXrjoIGuAn9XsvVghyVNDdGgSukmeRPe4P4GA4+HlIa0+yY3ELY6n +B1v7KkE5Psk+qj6FyzRj1bUUivfq70wPkUnh1Ymc6o06ryIeal+1nVUIxZMWrunaBKF ETgG9iQjNpM2hFpGsqGUSsEXKRcXoh5LRysaPpfLpNrVpBvdmUGAEf/f60VNf/wjilQm iKQ5nXlfrARqDFE8uLdx0HyriJFEW/f9VqGwg6hNdOPXZDi13FFI/gvX9WI5fgsaS2xx HZLctEJWq29q1DdHgiDyythar9DXmEhW2LUMvErShvZaZdAM5zVmhL2I5AgS1xIvxq0U 4bZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727555596; x=1728160396; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ku7uN4UzFuejMNBZ/4l5faSBcmRAJOFBg7DuhDvd/pY=; b=Vw/Flwk/USWrNBwoLu1SLTP7UgB5ZSDaSeEq/JVH4W0VZ2VWBr1a/d9E13Gn/F91Ol jjuqXgYbXnglW8cQYIn1gXSUSzYp34l+cm6bEEyfGWWjri7Swk8J0kkk8FdYg2tLE3Xz XSRG9AtDUgko7k/pF3bJFDNktxx5X/BpXrIXhElRa8MtBKsofAGr47iVWo0QDRRAb4H3 TGl3+OzKqXM19pQ5UirBm+5eK11bfwOEqSBL+dWuDwchUkpH+N83r3BFBfXKeyPzjleo QJde4s3kTdyHOAre+Uz7yUaTRWI3CSTTv6H/pjPBl8vzNIMdWALX9REvbHkB7/x+mdZu 8k9w== X-Gm-Message-State: AOJu0YxV+TdLNNNL0G00mz+lwifF5aQJDY0QdFuo2TIvmBWWBvAoynBb gFaWh+DKRWjaSZ05F566ZwGVdR+8uouc6bKxgZD8I+SIZDlIghr5XJLZwQ== X-Google-Smtp-Source: AGHT+IEVozmuRnbfKgW5mAoR1LyC/Rdl9EZwWPgDylxzpbZK3mCmC5oTBjgr8R2OqatbDSKnS75W8w== X-Received: by 2002:a05:620a:1917:b0:7ac:b89f:5308 with SMTP id af79cd13be357-7ae37824642mr1330286485a.7.1727555595804; Sat, 28 Sep 2024 13:33:15 -0700 (PDT) Received: from pierrot.dokosmarshall.org ([70.22.187.146]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ae3783d25esm230897185a.119.2024.09.28.13.33.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 13:33:14 -0700 (PDT) From: Nick Dokos X-Google-Original-From: Nick Dokos To: emacs-orgmode@gnu.org Subject: [BUG][PATCH] org-babel: Shared list structure causes spurious changes in user options [9.8-pre (release_9.7.10-127-g07dd3b @ /usr/local/share/emacs/site-lisp/org/)] Date: Sat, 28 Sep 2024 16:33:13 -0400 Message-ID: <8734ljcyd2.fsf@pierrot.dokosmarshall.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=ndokos@gmail.com; helo=mail-qk1-x72b.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, SPF_HELO_NONE=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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 2641D7C63A X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -5.93 X-Spam-Score: -5.93 X-TUID: Zg8N1p23w2MG --=-=-= Content-Type: text/plain Remember to cover the basics, that is, what you expected to happen and what in fact did happen. You don't know how to make a good report? See https://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org mailing list. ------------------------------------------------------------------------ This is a simplified reproducer of the problem, as discovered by user @lyndhurst on SE Emacs. See https://emacs.stackexchange.com/questions/82261/set-org-babel-source-block-parameters-dynamically for more details. Starting with `emacs -Q', open the following file: --8<---------------cut here---------------start------------->8--- * Bug report example #+begin_src shell echo "foo" #+end_src * Code #+begin_src elisp :results raw (setq org-babel-default-header-args:shell '((:results . "file") (:file . "results.txt") (:output-dir . "a"))) #+end_src --8<---------------cut here---------------end--------------->8--- Evaluate the last code block to set `org-babel-default-header-args:shell' to the indicated value, then evaluate the shell code block repeatedly: the first time it works to produce an output file `a/results.txt'; subsequent evaluations produce errors: org-ctrl-c-ctrl-c: Opening output file: No such file or directory, .../a/a/results.txt org-ctrl-c-ctrl-c: Opening output file: No such file or directory, .../a/a/a/results.txt org-ctrl-c-ctrl-c: Opening output file: No such file or directory, .../a/a/a/a/results.txt Note the increasing number of copies of the `output-dir' setting. The value of `org-babel-default-header-args:shell' is modified every time: ((:results . "file") (:file . "a/a/a/a/results.txt") (:output-dir . "a")) The problem is the way that `org-babel-get-src-block-info' constructs the `info' variable, which is used to pass around information during the evaluation: the value depends on the `org-babel-default-header-args*' variables, but is modified in place, and because of shared list structure, the modification gets propagated to the user variables. Emacs : GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0) of 2024-08-09 Package: Org mode version 9.8-pre (release_9.7.10-127-g07dd3b @/usr/local/share/emacs/site-lisp/org/) ------------------------------------------------------------------ The following patch wraps calls to `copy-tree' around the relevant places to eliminate the sharing. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-babel-Avoid-changing-user-options-by-not-sharing.patch Content-Description: Patch for "Shared list structure caused spurious changes in user options" >From dfe13482a8b3997aaca35063e81c7535faf02c0b Mon Sep 17 00:00:00 2001 From: Nick Dokos Date: Sat, 28 Sep 2024 15:39:25 -0400 Subject: [PATCH] org-babel: Avoid changing user options by not sharing list structure * lisp/ob-core.el (org-babel-get-src-block-info): Use `copy-tree' when using `org-babel-default-header-args*' variables to prepare the `info' variable used in src block evaluation. The `info' variable gets modified, and the modifications were affecting the values of the user variables. In particular, the `:file' setting was modified in the presence of a `:output-dir' setting, concatenating more and more copies of the directory every time the block was evaluated. Reported-by: @lyndhurst on SE Emacs Link: https://emacs.stackexchange.com/questions/82261/ --- lisp/ob-core.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 90c52f8b7836..e6db422c9d20 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -731,9 +731,17 @@ Otherwise, return a list with the following pattern: lang (org-babel--normalize-body datum) (apply #'org-babel-merge-params - (if inline org-babel-default-inline-header-args - org-babel-default-header-args) - (and (boundp lang-headers) (eval lang-headers t)) + ;; Use `copy-tree' to avoid creating shared structure + ;; with the `org-babel-default-header-args-*' variables: + ;; modifications by `org-babel-generate-file-param' + ;; below would modify the shared structure, thereby + ;; modifying the variables. + (copy-tree + (if inline org-babel-default-inline-header-args + org-babel-default-header-args) + t) + (and (boundp lang-headers) + (copy-tree (eval lang-headers t) t)) (append ;; If DATUM is provided, make sure we get node ;; properties applicable to its location within -- 2.46.0 --=-=-= Content-Type: text/plain -- Nick --=-=-=--