From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 6Df8Gkxy2WJfFAEAbAwnHQ (envelope-from ) for ; Thu, 21 Jul 2022 17:35:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cE3SGkxy2WI/JgEAauVa8A (envelope-from ) for ; Thu, 21 Jul 2022 17:35:40 +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 08738B2F4 for ; Thu, 21 Jul 2022 17:35:40 +0200 (CEST) Received: from localhost ([::1]:53320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEYDC-0003gn-Ay for larch@yhetil.org; Thu, 21 Jul 2022 11:35:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDwS7-0001se-Df for emacs-orgmode@gnu.org; Tue, 19 Jul 2022 19:16:32 -0400 Received: from out2.migadu.com ([188.165.223.204]:58309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDwS5-0001Ml-0N for emacs-orgmode@gnu.org; Tue, 19 Jul 2022 19:16:31 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1658272582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qKA3WcxlPU/kUONSbcB1UVkVtHtJ3qfb6FU6svZvw4Y=; b=OQv0bKiZYO+A8z3AQw/u/roaEKbK9Xy0citcfoBuZEqlWd+58hgz+WAqC2MvfxadKWa3gg oqoY+FqXWcJKiWTZD6/cvhJahn8KARvxo7aTE4ewQ4h2TNkhPPZD1KxEFqrOAVsKZVXwp4 R/NjVls5D70zJ6QpIyKbN+DBKvE315c= From: Joseph Turner To: emacs-orgmode@gnu.org Cc: Joseph Turner Subject: [PATCH] lisp/ob-plantuml.el: Insert results in buffer Date: Tue, 19 Jul 2022 16:15:21 -0700 Message-Id: <20220719231520.100206-1-joseph@breatheoutbreathe.in> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=188.165.223.204; envelope-from=joseph@breatheoutbreathe.in; helo=out2.migadu.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, 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-Mailman-Approved-At: Thu, 21 Jul 2022 11:34:35 -0400 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=1658417740; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=qKA3WcxlPU/kUONSbcB1UVkVtHtJ3qfb6FU6svZvw4Y=; b=VpZouHOBojZbz+QixukcTU5Gxz3pFfqUNA7P9SkXgpHK8gfsF/zJxQhzw1j/12Y/fSiyuc 8q3YaRpjXalnL4MYbhe/4UVlZez14si7USOfQ5RiD+Ps3gGWCx7cpI3+1LM1xUHQyVnAcJ Ri2FhagivvKbQbwhjFEP2+b4C6y0GPLJ2TS0YKaXhrI+Ui/f/BKDaNsIIcAC09Haq22MIJ 6bxFFbio/OIgkRuNoGf+0Tm5pHJszsPj4qOo2OiIYnWtzq6IThGzNvcodNNjAC6k8O8WkJ BaWiK5h5kfwODcXPA3Q1a3mIgHyWj1hB5LZIPti2TdYDKhqIjil6VpVpqq59aw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1658417740; a=rsa-sha256; cv=none; b=Ce9PazX2TJVvCA7lMQjiJt1Zl3ZKh/e+NbRiooXg6gNSgZIpMRYVMRLbgJJmUYnyrZoeby VdxsP3BAQrX0uAcr3en6nZwcOYLZoNkqc8wjOeJ8mgAqk9fRGiDC2IFHPWDqAAoq1C1LEH 9fP+RzfwsCQK6MJ1/kAuAKHIPLBpRrp6VhpQ+6rrMNjnTx8YZ7fXo1RzycwLmvSPjmqHNo goVRCIGIX65AFdKKHjq6xO6T/CV4hi9PxiJ1TpD7+db9EdI57fkKddhB1smynD6wK0Fa2T Gpj7WjZSj7KFsJecy4A4iSquSjFOiixPcTEZZ3OBZ9A4b414XAyzwCgPSh1rWA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b=OQv0bKiZ; 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: -4.94 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b=OQv0bKiZ; 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: 08738B2F4 X-Spam-Score: -4.94 X-Migadu-Scanner: scn0.migadu.com X-TUID: TlZ0JUmmTdI/ Allow src block execution without ":file" header arg. When ":file" is omitted, insert txt output in buffer below src block. TINYCHANGE --- etc/ORG-NEWS | 5 +++++ lisp/ob-plantuml.el | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 4cda357f1..1613fdab5 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -295,6 +295,11 @@ files that are exported to Texinfo. =org-at-heading-p= now returns t by default on headings inside folds. Passing optional argument will produce the old behaviour. + +*** =org-babel-execute:plantuml= can output ASCII graphs in the buffer + +Previously, executing PlantUML src blocks required a ":file" header argument. Now, if that header argument is omitted, an ASCII graph will be inserted below the src block. + ** Removed or renamed functions and variables *** =org-plantump-executable-args= is renamed and applies to jar as well diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el index ebbcdf166..f9b41c140 100644 --- a/lisp/ob-plantuml.el +++ b/lisp/ob-plantuml.el @@ -109,8 +109,9 @@ If BODY does not contain @startXXX ... @endXXX clauses, @startuml (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* ((out-file (or (cdr (assq :file params)) - (error "PlantUML requires a \":file\" header argument"))) + (let* ((do-export (cdr (assq :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)) "")) @@ -155,7 +156,10 @@ This function is called by `org-babel-execute-src-block'." (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) "")) - nil)) ;; signal that output has already been written to file + (unless do-export (with-temp-buffer + (insert-file-contents out-file) + (buffer-substring-no-properties (point-min) (point-max)) + )))) (defun org-babel-prep-session:plantuml (_session _params) "Return an error because plantuml does not support sessions." -- 2.37.0