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 oDeBGl577WLyywAAbAwnHQ (envelope-from ) for ; Fri, 05 Aug 2022 22:19:42 +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 2M90Gl577WKZLAAA9RJhRA (envelope-from ) for ; Fri, 05 Aug 2022 22:19:42 +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 2D0C22E6D4 for ; Fri, 5 Aug 2022 22:19:42 +0200 (CEST) Received: from localhost ([::1]:59078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oK3nJ-0007Aa-4K for larch@yhetil.org; Fri, 05 Aug 2022 16:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oK3mI-0007AS-Lz for emacs-orgmode@gnu.org; Fri, 05 Aug 2022 16:18:42 -0400 Received: from out2.migadu.com ([188.165.223.204]:16294) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oK3mG-0007mz-UH for emacs-orgmode@gnu.org; Fri, 05 Aug 2022 16:18:38 -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=1659730713; 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=/bxVdM4WIXm56F2/a5BtUkjMOJt9Uc3U1OlTP/4S6h0=; b=aG81+xstzgvLF+KiAknHsqecX6+hl6vhXP11+QtbalvrDIn8b2umQwST9suRqYbqAQ8P4O 9quE1oAdxo++uQe7iVuRGQmBWBOR7EtefoQ0SJ4YFugq8MVM+dRs0VUirqCRiKJ2SU8sgD 9CKjWra9EFjwtFDCNgu3ZygfgT/Ru1U= From: Joseph Turner To: emacs-orgmode@gnu.org Cc: yantar92@gmail.com, Joseph Turner Subject: [PATCH v3] lisp/ob-plantuml.el: Insert results in buffer Date: Fri, 5 Aug 2022 13:18:13 -0700 Message-Id: <20220805201813.14013-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-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=1659730782; 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=/bxVdM4WIXm56F2/a5BtUkjMOJt9Uc3U1OlTP/4S6h0=; b=WSQHJ3ypBHdC8+y2ETJX7IX58skJ1Fe9MYMRBRVPoB2xsP3z72HNwB/t50tBL0DTczC5ME 9JEFkL4CPQbtBKFNoZkmKxwcs1tMJ9QXfjFYNyJJ9PHUOF1n7wLK+3b1Z0HTp/9FlNc7lS woE3GFnUHcFeDCl74ZD0rvoaQrdcfA0zHSKt+IUUsJWs3Rpg3kLfVvOfpVte6pkJyH1pat v8PSZD3DikhgvhvMJpSSLMtYxcxUY0tQsvDKvzTz5vuEbQOp4JQcpeh0MCnlIIscpStQgX +YHVlHv4U91E1x4xsWRxQJtJL2/fgnVQVcfkanR1Dkx6SgrBmaoto7r+0KDx7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659730782; a=rsa-sha256; cv=none; b=KNVdVYm/uv/ydKSnywWPgM14JHqRwEsti0UEsctnCNNhLj7n8lpLjGuVa7kyDBTVqzEmun aif6NQ0c8rcmw4tjhVqLujls0f7ftjA9P3A3e1tohvIv9p71LP925h19beBlzx65B5QAoN yabuKPDwFT/ooiba2j2tHZbAvt/DvH9M8gXzueKkvRtmT8OkZCfrh8MulVcb52aCrqI/Mo HpR52nrn9lOU/5mA1LmzUODP0CQ9SY8Dy+TI/lJIsmbUnLQl3mFoKgvJfTh8m3L3wiljBS s1STKdcSAHraadOR8G58eR5FJpMW/mV3Q1ml3MIgH2S9i2/vB0WhoObESZmdkg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b=aG81+xst; 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: -0.90 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b=aG81+xst; 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: 2D0C22E6D4 X-Spam-Score: -0.90 X-Migadu-Scanner: scn1.migadu.com X-TUID: KUyr35thgf2v When :results header arg is set to a value that doesn't include "file", insert txt output in buffer below src block. TINYCHANGE --- etc/ORG-NEWS | 7 +++++++ lisp/ob-plantuml.el | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 4cda357f1..b8cd05d4e 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -295,6 +295,13 @@ 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 always exported to a file. Now, if +:results is set to a value which does not include "file", no file will be +exported and 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..a339d8485 100644 --- a/lisp/ob-plantuml.el +++ b/lisp/ob-plantuml.el @@ -109,8 +109,11 @@ 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 (member "file" (cdr (assq :result-params params)))) + (out-file (if do-export + (or (cdr (assq :file params)) + (error "No :file provided but :results set to file. For plain text output, set :results to verbatim")) + (org-babel-temp-file "plantuml-" ".txt"))) (cmdline (cdr (assq :cmdline params))) (in-file (org-babel-temp-file "plantuml-")) (java (or (cdr (assq :java params)) "")) @@ -155,7 +158,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