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 gE0YBmhSYWJSHwAAbAwnHQ (envelope-from ) for ; Thu, 21 Apr 2022 14:47:36 +0200 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 UJU9BWhSYWJREwEAG6o9tA (envelope-from ) for ; Thu, 21 Apr 2022 14:47:36 +0200 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 AD5B838B62 for ; Thu, 21 Apr 2022 14:47:35 +0200 (CEST) Received: from localhost ([::1]:42554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhWDe-0003F0-5V for larch@yhetil.org; Thu, 21 Apr 2022 08:47:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhWCg-0003B4-9t for emacs-orgmode@gnu.org; Thu, 21 Apr 2022 08:46:34 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:42795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhWCe-0002lj-Kz for emacs-orgmode@gnu.org; Thu, 21 Apr 2022 08:46:33 -0400 Received: by mail-pf1-x431.google.com with SMTP id j17so4910485pfi.9 for ; Thu, 21 Apr 2022 05:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=Ye85M1qxQIFL4FIVlUj4nfhrbcxKXfj93k0PU3vGwrc=; b=mq2tbFCGcTil+Z0FM7dhQPwv+vWyBc4txGMfeJRqSQFWcSDFSsSQwNJ9lrl2/8fMBb Gqy7T1KWuMV9FOa7zwguhdU5JsLSZ9Mmmnx4iHauJUH+IBf4+xZz9lCsRoLjGKGsn/dm wglo6OigG2OfodL5IT7uu274ROKrCGcQTp4Y4gdQb3fvjVor/uD2acaVUSNB4a8/M/gM ZwmbtLZMN1fcVDbq3FULXdz9trMpdS4VsJBMI4vrNhybipWlN9IQp0qZ9a63Kf21aQT4 YIi943a7/5ccv49DwWClA1kMRsygWVqSAjL0cGfNY954Rd7uyHJwGsGZFNOtl2F0h1DT EFjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=Ye85M1qxQIFL4FIVlUj4nfhrbcxKXfj93k0PU3vGwrc=; b=OezNdyRXjNzS//SZlDZHwhqHj2R3pmGIAKch0xpOR+ZbiHjbbPjfOMyiWpDktIwJ44 enDB40khDC+SnQz8qvZ3/Jjo/qHZfscng05Zubm6i0izYIuqOWYg8JZyWNKBDfrm28GX 6y/i2ganPmsanCQjIqO7RodCW6kCyV1q2HaVUQUlnEzJ9ZGQ4gzn2gKmQf/NOtlAnzpc qKIdj7Z0sIUJz3vw8qrxntg+CVcPyi6w2kQm5q33y5vTrJRLKXkmH2quMP26GHYpdQCs 7mnmRH9sxSUcmr9wBSOJqcmjynv6A+xaeWSOqYv+BA5Fbm0U8Mx2rZxIAoEqTKoyQk8G 1Qpw== X-Gm-Message-State: AOAM533St7wwJVVmIsP8c/JnRun79ftPyWj2UqOxYkzGwnzA9U1ckrKm V561lEPJi1ctYyb8mDRkusc= X-Google-Smtp-Source: ABdhPJwuJMMqtl4lIXga6yhor0FH22eixEJn7XuPGT1qbtUzmkSLWox/U3q4Xb9mgrQBA1KVTFTKRA== X-Received: by 2002:a65:400d:0:b0:39d:2213:ca72 with SMTP id f13-20020a65400d000000b0039d2213ca72mr23183009pgp.332.1650545191129; Thu, 21 Apr 2022 05:46:31 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id x8-20020aa784c8000000b0050577c51d38sm22625817pfn.20.2022.04.21.05.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 05:46:30 -0700 (PDT) From: Ihor Radchenko To: Ryan Scott Subject: Re: [PATCH] Re: New source block results option for attaching file to node In-Reply-To: References: <981938.1630590273@apollo2.minshall.org> <87czpqjqvw.fsf@localhost> Date: Thu, 21 Apr 2022 20:47:21 +0800 Message-ID: <87zgkey55y.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=yantar92@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=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: , Cc: Greg Minshall , emacs-orgmode@gnu.org, Timothy Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650545255; 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=Ye85M1qxQIFL4FIVlUj4nfhrbcxKXfj93k0PU3vGwrc=; b=DUX3reO9v0y54sDFGYhWWw5zN2F3uObyFSLYD692N1n31Vi2Ft6PdPiAJPQoKpCAzxOF5I K8bmcXexA0fVTij1ZGvyjCYtDL2dwyEAV/GtoQ7hEjNZY9UxsRaV1erzPuhuV3Ys2KrL1m XDyd1/DPbkla6m/XN2I43aImCJVsfr5xdE7qyE1RhSSuBoiAtd5oQONXFrfXZfxXnU+Whp qjp+27mYkupP5sEtN9C+LlEuG+BSnWWd9wDV0Rq+tKfg575UCy9GpVzrUn87u5sL4LUYCL Am7ZCNeHxQhFp/2OHU1INxKaPc8yxxJjAzmkgW/BL80bbIUM5Ej/1D7RjGOQzA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650545255; a=rsa-sha256; cv=none; b=mV7qor6NdzdJmJjXy2u7dcabwVUjXRThA+aJ3Jj7pThrmhaFkKwPdHotFgPfug5ercE/rV BVhFqn5m8ejRw54eTWuLhgXbJK37p0LYLMzOng82YF1gtABxb7dFWMYRSLsN/kHIigge1G 0I5TotiSrsj1c7UKxSGy0ladmWmvIbbbtQVL3ULON/BQvgNiTbtVefxa73/o4fFmaFC/yx FWY+hEjd9Qq0VwA9d8+c46jHMgzklM7C4ltJ/UwHcpZ/QLoQrQ+4Nh2vt66ffCQZX420O8 U9XFYJO9s5eg38nYjF6lgWEnPPz6oC3fWlrfUNeK7A7oECaWuRFEZ/ZhBD6qUg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=mq2tbFCG; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Spam-Score: 6.66 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=mq2tbFCG; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Queue-Id: AD5B838B62 X-Spam-Score: 6.66 X-Migadu-Scanner: scn1.migadu.com X-TUID: G2iDlM7Ga97+ Ryan Scott writes: > Here's my latest patch. > Uses special :dir value 'attach to use attachment directory as working dir. > Now prompts to create IDs for nodes that are missing. > Solved a handful of issues with my previous versions of this and I've been > using it regularly for a bit now. > > I've added documentation and completed the copyright assignment to the FSF. I have consulted Bastien about our merge policy and apparently it is ok to merge staff into files without maintainer. ob-core.el is one of such files. So, I did a more elaborate testing of your patch. I have some comments. Firstly, the patch does not apply onto current main. > +Setting =dir= to the symbol ~attach~ or the string ~"'attach"~ will > ... > +Passing the symbol ~attach~ or string ='attach= to the =:dir= option When I was trying to use your patch, I felt slightly confused about the "'attach" part. It _looks_ like a type and I first tried to do :dir "attach" yielding predictable lack of attachment: file link. Maybe you can say "or the string ~"'attach"~ (with quote)". > + (org-babel-result-to-file > + result > + (org-babel--file-desc (nth 2 info) result) > + 'attachment)))) There are only 2 calls to org-babel-result-to-file in the whole Org codebase. And you did not change the second call, which yield strange side-effects: #+NAME: attr_wrap #+BEGIN_SRC sh :var data="" :var width="\\textwidth" :results output echo "#+ATTR_LATEX: :width $width" echo "$data" #+END_SRC #+begin_src gnuplot :dir 'attach :file test.png plot x #+end_src #+RESULTS: [[attachment:test.png]] #+begin_src gnuplot :dir 'attach :file test.png :post attr_wrap(width="5cm", data=*this*) :results drawer plot x #+end_src #+RESULTS: :results: #+ATTR_LATEX: :width 5cm [[file:data/4d/6a76f8-4016-4edf-9d26-e0b3a634dbc1/test20.png]] <----!!!!! this is not expected :end: > +If the optional TYPE is passed as 'attachment` and the path is a > +descendant of the DEFAULT-DIRECTORY, the generated link will be > +specified as an an \"attachment:\" style link" > + (in-attach-dir (when (and request-attachment (> (length result-file-name) attach-dir-len)) > + (string= > + (substring result-file-name 0 attach-dir-len) > + attach-dir)))) This is a risky heuristics. One can do something like (setq org-attach-id-dir "/tmp/alsjkdsalkjdlaskdjklasjdlkasjdlkasjdlkajdklasjdlasjlasdjk/") and often get your heuristics fail. Of course, it will require some terribly noncomplying ob-* library that will create file disregarding default-directory, but still... > + (if (y-or-n-p (format "Create ID for entry \"%s\"?" > + (org-get-heading t t t t))) This is a nice dialogue, but note that Emacs can run noninteractively or execute source block during export (including asynchronous). I would guard the query after consulting `noninteractive' variable. Best, Ihor