From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WEKtK7n+5mJeWwAAbAwnHQ (envelope-from ) for ; Mon, 01 Aug 2022 00:14:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MK6qK7n+5mKnhgAA9RJhRA (envelope-from ) for ; Mon, 01 Aug 2022 00:14:17 +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 054E33887E for ; Mon, 1 Aug 2022 00:14:17 +0200 (CEST) Received: from localhost ([::1]:46996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIHCS-00060r-4h for larch@yhetil.org; Sun, 31 Jul 2022 18:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIHBb-00060g-Nf for emacs-orgmode@gnu.org; Sun, 31 Jul 2022 18:13:23 -0400 Received: from out0.migadu.com ([2001:41d0:2:267::]:23387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIHBZ-0006Bm-7Y for emacs-orgmode@gnu.org; Sun, 31 Jul 2022 18:13:23 -0400 References: <20220719231520.100206-1-joseph@breatheoutbreathe.in> <87bktduydf.fsf@localhost> <87o7xdot4d.fsf@breatheoutbreathe.in> <877d40ctho.fsf@localhost> <87h732w5og.fsf@breatheoutbreathe.in> <87a68t9uds.fsf@localhost> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1659305589; h=from:from: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; bh=UUOg4dlTZpjVA0etFUemAa+EalFfPNRNB3jeSianelI=; b=dljEFkJrEPKRfOvjSN8sVEAbSf8+zTvFfn+01TKY8g99OyOeS0kDBfiZEXIk33Uc5L8Cu7 ylP6bekEfCgFJot8dgQ9LABiDAAAL3ViyLyjp71vMj9qQYs8NuwoUOtxqWkJfj6ni0ex1W Q0CrSu+lgCzlIWNV60A0s5xA1mFPE0E= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] lisp/ob-plantuml.el: Insert results in buffer Date: Sun, 31 Jul 2022 15:05:58 -0700 In-reply-to: <87a68t9uds.fsf@localhost> Message-ID: <875yjdkk25.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2001:41d0:2:267::; envelope-from=joseph@breatheoutbreathe.in; helo=out0.migadu.com 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, SPF_HELO_PASS=-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" 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=1659305657; 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=UUOg4dlTZpjVA0etFUemAa+EalFfPNRNB3jeSianelI=; b=TsnZJZ8nWYFR2dPLTKkNhXtXfLS+a5eOHnQloMtWs3D2qJsm3Ml7I4Ud6KPZdKN2FYgSuV xkX1e/CTDLsr9enQFYru99y3bKQd0xps3KMDwIEW2CWtgFTn9RMEaJpyzForZoOtZid+40 gDpGW2K2T+ECJSShS7UDyqGZYeqFzjNP2GpE6LJSCnqM1jbWSyb0BUoHpLfWutTKiShvvE 99eEEEM/yJcCAqcvCdZmJSrZm52EDcp6Xq5M11RE7ZbXefB+zKDM+wHpLeqkF30+7spUVo D3ennfh88ce+r2tvNyQtpBG9IU53Bh/qms9fT/oE/6ALgE7mf4C0eXT6/6Q3/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659305657; a=rsa-sha256; cv=none; b=Qz+6RzLl443wFtAPXNQFzNeJLk5szPToQcWyfGRGY35Sp4TTb7d384H6/tA+OvgK40vk4u If0IBnpNQDGZCr+zdNZ8WsRFqeLHVv3sCXoNnRe+mSA9VVbRELBO/moD9GbMGMG2xULKqv OqaClqKqt2uD5ambjbwepHyPy+1PR1tu+NNupQkp3dhYAzg+ox1yjRQpwqbuI5LxKPpzKW b+PLclIffLdEIwyPc87s5fUlq0OuXd+Ofdl00/+nwC4WWLWuyllo7GgEbIvptSRmJ4JHzm pvyuFOQ/sD3CDFyCNSyiIk3yXWDuzxXR3Ve7f3UjqPILTHC5oBZ76cPaEKtfvA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b=dljEFkJr; dmarc=pass (policy=quarantine) header.from=breatheoutbreathe.in; 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: -3.92 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b=dljEFkJr; dmarc=pass (policy=quarantine) header.from=breatheoutbreathe.in; 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: 054E33887E X-Spam-Score: -3.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: hL1oQ3ZOemVX Ihor Radchenko writes: > You also need to change :result-params and :result-type. > See `org-babel-execute-src-block'. Here's what I've got so far: ``` (defvar org-babel-default-header-args:plantuml '((:exports . "results")) "Default arguments for evaluating a plantuml source block.") (defun org-babel-execute:plantuml (body params) "Execute a block of plantuml code with org-babel. This function is called by `org-babel-execute-src-block'." (let* ((do-export (cdr (assq :file params))) (params (if do-export (map-merge 'list params '((:results . "file") (:result-params "replace" "file"))) params)) (out-file (or do-export (org-babel-temp-file "plantuml-" ".txt"))) ; if ":file" is not provided, don't export, just print ASCII results (cmdline (cdr (assq :cmdline params))) (in-file (org-babel-temp-file "plantuml-")) (java (or (cdr (assq :java params)) "")) (executable (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-path) (t "java"))) (executable-args (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-args) ((string= "" org-plantuml-jar-path) (error "`org-plantuml-jar-path' is not set")) ((not (file-exists-p org-plantuml-jar-path)) (error "Could not find plantuml.jar at %s" org-plantuml-jar-path)) (t (list java "-jar" (shell-quote-argument (expand-file-name org-plantuml-jar-path)))))) (full-body (org-babel-plantuml-make-body body params)) (cmd (mapconcat #'identity (append (list executable) executable-args (pcase (file-name-extension out-file) ("png" '("-tpng")) ("svg" '("-tsvg")) ("eps" '("-teps")) ("pdf" '("-tpdf")) ("tex" '("-tlatex")) ("vdx" '("-tvdx")) ("xmi" '("-txmi")) ("scxml" '("-tscxml")) ("html" '("-thtml")) ("txt" '("-ttxt")) ("utxt" '("-utxt"))) (list "-p" cmdline "<" (org-babel-process-file-name in-file) ">" (org-babel-process-file-name out-file))) " "))) (with-temp-file in-file (insert full-body)) (message "\n%s\n" do-export) (message "\n%s\n" params) (message "%s" cmd) (org-babel-eval cmd "") (if (and (string= (file-name-extension out-file) "svg") org-babel-plantuml-svg-text-to-path) (org-babel-eval (format "inkscape %s -T -l %s" out-file out-file) "")) (unless do-export (with-temp-buffer (insert-file-contents out-file) (buffer-substring-no-properties (point-min) (point-max)))))) ``` I've added a couple of (message ...) blocks to log the value of do-export and params. It appears that this combination is producing a params value which is equivalent to the value of params produced by the current org-babel-execute:plantuml function. However, when the above function is executed on a block like: #+begin_src plantuml :file "this.png" Bob->Alice : Hello1! #+end_src I get "Code block produced no output." I suspect that setting the scoped params variable has no effect on the execution of the function, since I can set params to '((:results . "none")), and I'll still get a printed result if org-babel-default-header-args:plantuml is set to the above value. Is it safe to modify the value of org-babel-default-header-args:plantuml from within the function? Would that even work? Thank you for your patience in figuring this out with me :) Joseph