From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GPc+BwEK1V48ZAAA0tVLHw (envelope-from ) for ; Mon, 01 Jun 2020 14:00:33 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id wHT/AgEK1V6/FgAAbx9fmQ (envelope-from ) for ; Mon, 01 Jun 2020 14:00:33 +0000 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 16C879400EF for ; Mon, 1 Jun 2020 14:00:32 +0000 (UTC) Received: from localhost ([::1]:47624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfkzO-0007Vs-FD for larch@yhetil.org; Mon, 01 Jun 2020 10:00:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfkyy-0007Va-Bm for emacs-orgmode@gnu.org; Mon, 01 Jun 2020 10:00:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49320) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfkyy-0003ez-1v; Mon, 01 Jun 2020 10:00:04 -0400 Received: from [2a01:e35:2fe1:f780:a886:3d11:7807:868b] (port=37258 helo=guerry) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1jfkyv-0002Wj-Ft; Mon, 01 Jun 2020 10:00:02 -0400 Received: by guerry (Postfix, from userid 1000) id 1A3791A603C1; Mon, 1 Jun 2020 15:59:59 +0200 (CEST) From: Bastien To: Terje Larsen Subject: Re: [PATCH] ob-plantuml: Support for plantuml as well as the current java+jar solution Organization: GNU References: <874kzeijnz.fsf@gmail.com> <87h7zvpvan.fsf@gnu.org> <87imk6qff4.fsf@gnu.org> Date: Mon, 01 Jun 2020 15:59:59 +0200 In-Reply-To: (Terje Larsen's message of "Tue, 26 May 2020 21:29:29 +0200") Message-ID: <87367ezy1s.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: 4zXnlsig3rxL --=-=-= Content-Type: text/plain Hello Terje, > I have now signed the FSF papers. Here is the updated patch on top of > current master. Great, thanks. > Let me know if all looks good or if I need to make further changes or > need to provide something else. It looks good -- here is an updated patch with shorter lines. The last change you need to make is to use mapconcat instead of string-join, which would require us to load subr-x.el. Once this is done I'll apply your patch. Thanks, -- Bastien --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ob-plantuml-Add-support-for-plantuml-executable.patch >From b5f1bf735e6cf7eeeaa4f8bfdab921bed0959b46 Mon Sep 17 00:00:00 2001 From: Terje Larsen Date: Fri, 8 Nov 2019 10:25:49 +0100 Subject: [PATCH] ob-plantuml: Add support for plantuml executable * lisp/ob-plantuml (org-babel-variable-assignments:plantuml): Support using plantuml executable instead of jar. Some systems come with an executable for plantuml instead of a specific JAR file. This adds support for two different modes: - jar :: using java together with a JAR (previous behavior) - plantuml :: using a PlantUML executable The PlantUML executable can be configured via `org-plantuml-executable-path` and also the arguments that will be given via `org-plantuml-executable-args`. --- etc/ORG-NEWS | 7 ++++ lisp/ob-plantuml.el | 94 +++++++++++++++++++++++++++++---------------- 2 files changed, 67 insertions(+), 34 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 5183b58de..0b161a32b 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -243,6 +243,13 @@ explicitly: In situations where ~org-return~ calls ~newline~, multiple newlines can now be inserted with this prefix argument. +*** =ob-plantuml=: now supports using PlantUML executable to generate diagrams + +Set =org-plantuml-exec-mode= to ='plantuml= in order to use the +executable instead of JAR. When using an executable it is also +possible to configure executable location as well as arguments via: +=org-plantuml-executable-path= and =org-plantuml-executable-args=. + ** New commands *** ~org-table-header-line-mode~ diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el index 0e1d4eda2..67b469c31 100644 --- a/lisp/ob-plantuml.el +++ b/lisp/ob-plantuml.el @@ -31,7 +31,7 @@ ;;; Requirements: ;; plantuml | http://plantuml.sourceforge.net/ -;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file +;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file (when exec mode is `jar') ;;; Code: (require 'ob) @@ -46,6 +46,31 @@ :version "24.1" :type 'string) +(defcustom org-plantuml-exec-mode 'jar + "Method to use for PlantUML diagram generation. +`jar' means to use java together with the JAR. +The JAR can be configured via `org-plantuml-jar-path'. + +`plantuml' means to use the PlantUML executable. +The executable can be configured via `org-plantuml-executable-path'. +You can also configure extra arguments via `org-plantuml-executable-args'." + :group 'org-babel + :package-version '(Org . "9.4") + :type 'symbol + :options '(jar plantuml)) + +(defcustom org-plantuml-executable-path "plantuml" + "File name of the PlantUML executable." + :group 'org-babel + :package-version '(Org . "9.4") + :type 'string) + +(defcustom org-plantuml-executable-args (list "-headless") + "The arguments passed to plantuml executable when executing PlantUML." + :group 'org-babel + :package-version '(Org . "9.4") + :type '(repeat string)) + (defun org-babel-variable-assignments:plantuml (params) "Return a list of PlantUML statements assigning the block's variables. PARAMS is a property list of source block parameters, which may @@ -83,40 +108,41 @@ This function is called by `org-babel-execute-src-block'." (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 (if (string= "" org-plantuml-jar-path) - (error "`org-plantuml-jar-path' is not set") - (concat "java " java " -jar " - (shell-quote-argument - (expand-file-name org-plantuml-jar-path)) - (if (string= (file-name-extension out-file) "png") - " -tpng" "") - (if (string= (file-name-extension out-file) "svg") - " -tsvg" "") - (if (string= (file-name-extension out-file) "eps") - " -teps" "") - (if (string= (file-name-extension out-file) "pdf") - " -tpdf" "") - (if (string= (file-name-extension out-file) "tex") - " -tlatex" "") - (if (string= (file-name-extension out-file) "vdx") - " -tvdx" "") - (if (string= (file-name-extension out-file) "xmi") - " -txmi" "") - (if (string= (file-name-extension out-file) "scxml") - " -tscxml" "") - (if (string= (file-name-extension out-file) "html") - " -thtml" "") - (if (string= (file-name-extension out-file) "txt") - " -ttxt" "") - (if (string= (file-name-extension out-file) "utxt") - " -utxt" "") - " -p " cmdline " < " - (org-babel-process-file-name in-file) - " > " - (org-babel-process-file-name out-file))))) - (unless (file-exists-p org-plantuml-jar-path) - (error "Could not find plantuml.jar at %s" org-plantuml-jar-path)) + (cmd (string-join + (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 "%s" cmd) (org-babel-eval cmd "") nil)) ;; signal that output has already been written to file -- 2.26.2 --=-=-=--