From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +EO1MarG6mL/+AAAbAwnHQ (envelope-from ) for ; Wed, 03 Aug 2022 21:04:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cHmUMarG6mKH7QAAauVa8A (envelope-from ) for ; Wed, 03 Aug 2022 21:04:10 +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 F10D510197 for ; Wed, 3 Aug 2022 21:04:07 +0200 (CEST) Received: from localhost ([::1]:51170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJJf4-0001US-T8 for larch@yhetil.org; Wed, 03 Aug 2022 15:04:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJJec-0001UF-BB for emacs-orgmode@gnu.org; Wed, 03 Aug 2022 15:03:38 -0400 Received: from out0.migadu.com ([2001:41d0:2:267::]:58120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJJeZ-0001w5-AN for emacs-orgmode@gnu.org; Wed, 03 Aug 2022 15:03: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=1659553406; 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=CyG2IoTrUqemUv1ybs62rIppkGCBvHvWjhqNvh3lMGg=; b=WDG49mx/YJmxj3lWHuUO4RUACN7gKKeDrVtRarvf7+HB5ARTYjnCApDfw2ZuOxE7GrKaVt UfmXeuHU6BEzoQzg1MFtjSVTG21nqZ0vCgl9Ecyy7TVZLf+Cc70llBZFTzN7uG3AMZt34G skAwmkwPlEqUArXppL3s7mwDu7m8P5s= From: Joseph Turner To: emacs-orgmode@gnu.org Cc: yantar92@gmail.com, Joseph Turner Subject: [PATCH v2] lisp/ob-plantuml.el: Insert results in buffer Date: Wed, 3 Aug 2022 12:02:45 -0700 Message-Id: <20220803190245.26056-1-joseph@breatheoutbreathe.in> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=1659553448; 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=CyG2IoTrUqemUv1ybs62rIppkGCBvHvWjhqNvh3lMGg=; b=ldXr0zIxspe9sd0Bhz4jABorwI4pQR5uBhbG4d2m23es4tEinRJW/IG4QhTFAZ72jwt9Qj LWj/dMpO+RoDyHNTVMYu7Zky/iwIqtk+BMXie3vUCvL85+XnIWVLgl5racpguajvJRlolF uV4ddBFKByAxpsREvQjn9bpw4et7hhrhJpfe4EVZrQTmX2bpP+b/KupOMJAYfNilXFTAfR 9ZL0GSMMvq19RF768suBOKs3RdKI30PDBp4cYKlJL+xB1LZwSV24/nFyCISf3K6Xvw8o4m xNvLNWX2mZFbvFDH0VgOY7A/vL6IBMYRH2+CijDEmwxyZlFMbhN02YrFhJefBA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1659553448; a=rsa-sha256; cv=none; b=C/tJx8hYvfuE6ecog27uDyLKESx2Y5y1PfcAzX20rbFI0N06bbRwZLtpbXlml6lbO1Z5ER cX9uevdAWFqZ8ZN0RtX9DRp4KKIG4TwEUAYAzkoWgxPnsBOzvIhw++ilnN/H9Nb/d5GHkc p++o0PkB9FIoc8kRVNI64rCfIK9tqu1WWSF40UTh6WlI8HuV79QfgirYXji6vvPyZhFbO6 1vm1b+BTDjI/J85OAxUU8O8HIHn3HP8FAvRrtQJZOGDCGMYnbEiHuB2aW3BXOSAud3dQSb kmeDe9J2XTJAdKrVTcmZNChrp+Xc2Zu/ttfayuADUPmW4le9p+05AA0VTGkcmw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b="WDG49mx/"; 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.91 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=breatheoutbreathe.in header.s=key1 header.b="WDG49mx/"; 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: F10D510197 X-Spam-Score: -0.91 X-Migadu-Scanner: scn0.migadu.com X-TUID: jBWklG3kj+fd 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 | 13 ++++++++++--- 2 files changed, 17 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..85dd34e62 100644 --- a/lisp/ob-plantuml.el +++ b/lisp/ob-plantuml.el @@ -109,8 +109,12 @@ 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" + (split-string (cdr (assq :results 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 +159,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