[-- Attachment #1: Type: text/plain, Size: 604 bytes --] I have been missing this feature for a while and noticed it had already been requested before (2014), See: https://lists.gnu.org/archive/html/emacs-orgmode/2016-08/msg00105.html With this patch you can switch between using jar or plantuml. The idea partly stemmed from plantuml-mode and my inability to use the default implementation. You can see the implementation for plantuml-mode here: https://github.com/skuro/plantuml-mode/pull/102/files My patch is available here: https://code.orgmode.org/terlar/org-mode/commit/fbe245c0b09513ee5a6d3b189e112708b9d08da0 And also see attached within this mail. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ob-plantuml-Add-support-for-plantuml-executable.patch --] [-- Type: text/x-patch, Size: 5657 bytes --] From fbe245c0b09513ee5a6d3b189e112708b9d08da0 Mon Sep 17 00:00:00 2001 From: Terje Larsen <terlar@gmail.com> 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`. --- lisp/ob-plantuml.el | 94 +++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 34 deletions(-) diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el index 09c9a3334..388d9f1b9 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 + :version "24.1" + :type 'symbol + :options '(jar plantuml)) + +(defcustom org-plantuml-executable-path "plantuml" + "Path to the PlantUML executable." + :group 'org-babel + :version "24.1" + :type 'string) + +(defcustom org-plantuml-executable-args (list "-headless") + "The arguments passed to plantuml executable when executing PlantUML." + :group 'org-babel + :version "24.1" + :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 @@ -82,40 +107,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) + (t (cond ((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 + (cond ((string= (file-name-extension out-file) "png") '("-tpng")) + ((string= (file-name-extension out-file) "svg") '("-tsvg")) + ((string= (file-name-extension out-file) "eps") '("-teps")) + ((string= (file-name-extension out-file) "pdf") '("-tpdf")) + ((string= (file-name-extension out-file) "tex") '("-tlatex")) + ((string= (file-name-extension out-file) "vdx") '("-tvdx")) + ((string= (file-name-extension out-file) "xmi") '("-txmi")) + ((string= (file-name-extension out-file) "scxml") '("-tscxml")) + ((string= (file-name-extension out-file) "html") '("-thtml")) + ((string= (file-name-extension out-file) "txt") '("-ttxt")) + ((string= (file-name-extension out-file) "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.23.0 [-- Attachment #3: Type: text/plain, Size: 54 bytes --] Hope this helps someone. Best regards, Terje Larsen
Hello, Terje Larsen <terlar@gmail.com> writes: > And also see attached within this mail. Thank you. Could you rebase it on top of "next" branch and add an entry in ORG-NEWS, section "Org 9.4" about it? > +(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 > + :version "24.1" Please use :package-version '(Org . "9.4") instead. > +(defcustom org-plantuml-executable-path "plantuml" > + "Path to the PlantUML executable." File name of the PlantUML executable. > +(defcustom org-plantuml-executable-args (list "-headless") > + "The arguments passed to plantuml executable when executing PlantUML." > + :group 'org-babel > + :version "24.1" See above. > + (executable-args (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-args) > + (t (cond ((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)))))))) Could you merge the two `cond' in `executable-args'? > + (cmd (string-join > + (append > + (list executable) > + executable-args > + (cond ((string= (file-name-extension out-file) "png") '("-tpng")) > + ((string= (file-name-extension out-file) "svg") '("-tsvg")) > + ((string= (file-name-extension out-file) "eps") '("-teps")) > + ((string= (file-name-extension out-file) "pdf") '("-tpdf")) > + ((string= (file-name-extension out-file) "tex") '("-tlatex")) > + ((string= (file-name-extension out-file) "vdx") '("-tvdx")) > + ((string= (file-name-extension out-file) "xmi") '("-txmi")) > + ((string= (file-name-extension out-file) "scxml") '("-tscxml")) > + ((string= (file-name-extension out-file) "html") '("-thtml")) > + ((string= (file-name-extension out-file) "txt") '("-ttxt")) > + ((string= (file-name-extension out-file) "utxt") '("-utxt"))) Could you use (pcase (file-name-extension out-file) ("png" ...) ...) instead? Regards, -- Nicolas Goaziou
[-- Attachment #1: Type: text/plain, Size: 196 bytes --] Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: Hello and thank you for the feedback, made me learn a few things and make some improvements. I have made the suggested changes (see attachment). [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Updated version of ob-plantuml patch --] [-- Type: text/x-patch, Size: 5922 bytes --] From e3c46993714234c0290f3100683cbec3c0d5f056 Mon Sep 17 00:00:00 2001 From: Terje Larsen <terlar@gmail.com> 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 | 5 +++ lisp/ob-plantuml.el | 94 +++++++++++++++++++++++++++++---------------- 2 files changed, 65 insertions(+), 34 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 689a07871..2cce7dd41 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -19,6 +19,11 @@ just as if it was at outline level 0. Inheritance for properties will work also for this level. In other words; defining things in a property drawer before the first headline will make them "inheritable" for all headlines. +*** Babel +**** 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. Executable mode can be configured via: +=org-plantuml-executable-path= and =org-plantuml-executable-args=. * Version 9.3 diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el index 09c9a3334..aeea1802f 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 @@ -82,40 +107,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.24.0 [-- Attachment #3: Type: text/plain, Size: 233 bytes --] > Could you rebase it on top of "next" branch and add an entry in > ORG-NEWS, section "Org 9.4" about it? > I didn't find a section Org 9.4, so I put it under the section Version Next. Thank you for your help. Best regards, Terje
Hi Terje, Terje Larsen <terlar@gmail.com> writes: > I have been missing this feature for a while and noticed it had already > been requested before (2014), See: > https://lists.gnu.org/archive/html/emacs-orgmode/2016-08/msg00105.html > > With this patch you can switch between using jar or plantuml. The idea > partly stemmed from plantuml-mode and my inability to use the default > implementation. You can see the implementation for plantuml-mode here: > https://github.com/skuro/plantuml-mode/pull/102/files > > My patch is available here: > https://code.orgmode.org/terlar/org-mode/commit/fbe245c0b09513ee5a6d3b189e112708b9d08da0 Thanks for the patch -- I see you're already on the list of committers with TINYCHANGE: https://orgmode.org/worg/org-contribute.html#orgcd077ac Would you like to sign the FSF papers and resubmit your patch on top of current master? https://orgmode.org/request-assign-future.txt Thanks a lot, -- Bastien
Thank you Bastien,
You are welcome, I have never gotten around to sign the FSF papers as
I thought it was a
bit of a hassle, but with those clear instructions I have now started
the process. I guess
I have to wait until the process is done until I can resubmit?
On Wed, Feb 12, 2020 at 6:31 PM Bastien <bzg@gnu.org> wrote:
>
> Hi Terje,
>
> Terje Larsen <terlar@gmail.com> writes:
>
> > I have been missing this feature for a while and noticed it had already
> > been requested before (2014), See:
> > https://lists.gnu.org/archive/html/emacs-orgmode/2016-08/msg00105.html
> >
> > With this patch you can switch between using jar or plantuml. The idea
> > partly stemmed from plantuml-mode and my inability to use the default
> > implementation. You can see the implementation for plantuml-mode here:
> > https://github.com/skuro/plantuml-mode/pull/102/files
> >
> > My patch is available here:
> > https://code.orgmode.org/terlar/org-mode/commit/fbe245c0b09513ee5a6d3b189e112708b9d08da0
>
> Thanks for the patch -- I see you're already on the list of committers
> with TINYCHANGE: https://orgmode.org/worg/org-contribute.html#orgcd077ac
>
> Would you like to sign the FSF papers and resubmit your patch on top
> of current master?
>
> https://orgmode.org/request-assign-future.txt
>
> Thanks a lot,
>
> --
> Bastien
--
// Terje Larsen
Hi Terje, Terje Larsen <terlar@gmail.com> writes: > You are welcome, I have never gotten around to sign the FSF papers as > I thought it was a > bit of a hassle, but with those clear instructions I have now started > the process. Thanks! > I guess I have to wait until the process is done until I can > resubmit? Yes, exactly. Thanks for contributing, -- Bastien
[-- Attachment #1: Type: text/plain, Size: 715 bytes --] Hello Bastien, I have now signed the FSF papers. Here is the updated patch on top of current master. Let me know if all looks good or if I need to make further changes or need to provide something else. Best regards, Terje On Mon, Feb 17, 2020 at 12:29 AM Bastien <bzg@gnu.org> wrote: > > Hi Terje, > > Terje Larsen <terlar@gmail.com> writes: > > > You are welcome, I have never gotten around to sign the FSF papers as > > I thought it was a > > bit of a hassle, but with those clear instructions I have now started > > the process. > > Thanks! > > > I guess I have to wait until the process is done until I can > > resubmit? > > Yes, exactly. Thanks for contributing, > > -- > Bastien -- // Terje Larsen [-- Attachment #2: 0001-ob-plantuml-Add-support-for-plantuml-executable.patch --] [-- Type: text/x-patch, Size: 5923 bytes --] From b5f1bf735e6cf7eeeaa4f8bfdab921bed0959b46 Mon Sep 17 00:00:00 2001 From: Terje Larsen <terlar@gmail.com> 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
[-- Attachment #1: Type: text/plain, Size: 476 bytes --] 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 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ob-plantuml-Add-support-for-plantuml-executable.patch --] [-- Type: text/x-diff, Size: 5923 bytes --] From b5f1bf735e6cf7eeeaa4f8bfdab921bed0959b46 Mon Sep 17 00:00:00 2001 From: Terje Larsen <terlar@gmail.com> 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
[-- Attachment #1: Type: text/plain, Size: 908 bytes --] Thank you Bastien, I didn't get what the updated patch with shorter lines meant, the only thing I could see difference between that patch and my previous patch was the line breaks using CR LF instead of LF. I generate my patch with git format-patch Here is the updated patch using mapconcat. Best regards Terje On Mon, Jun 1, 2020 at 4:00 PM Bastien <bzg@gnu.org> wrote: > > 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 -- // Terje Larsen [-- Attachment #2: 0001-ob-plantuml-Add-support-for-plantuml-executable.patch --] [-- Type: text/x-patch, Size: 5987 bytes --] From 5a26a6cf2783836bfa16e006607d06a911b97c56 Mon Sep 17 00:00:00 2001 From: Terje Larsen <terlar@gmail.com> 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 f313b07fe..93695dd01 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -255,6 +255,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..4d10a68f4 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 (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 "%s" cmd) (org-babel-eval cmd "") nil)) ;; signal that output has already been written to file -- 2.26.2
[-- Attachment #1: Type: text/plain, Size: 1223 bytes --] Did this look okay? I've had to rebase this once again due to some conflicts in the ORG-NEWS. Find the latest patch attached. Best regards Terje On Tue, Jun 9, 2020 at 8:53 AM Terje Larsen <terlar@gmail.com> wrote: > > Thank you Bastien, > > I didn't get what the updated patch with shorter lines meant, the only > thing I could see difference between that patch and my previous patch > was the line breaks using CR LF instead of LF. I generate my patch > with git format-patch > > Here is the updated patch using mapconcat. > > Best regards > Terje > > On Mon, Jun 1, 2020 at 4:00 PM Bastien <bzg@gnu.org> wrote: > > > > 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 > > > > -- > // Terje Larsen -- // Terje Larsen [-- Attachment #2: 0001-ob-plantuml-Add-support-for-plantuml-executable.patch --] [-- Type: text/x-patch, Size: 6012 bytes --] From d2d73cd6dce1576d7396f734c70657f9a9e1806f Mon Sep 17 00:00:00 2001 From: Terje Larsen <terlar@gmail.com> 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 10658a970..87c5696d8 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -266,6 +266,13 @@ can now be inserted with this prefix argument. Source code block header argument =:file-mode= can set file permissions if =:file= argument is provided. +*** =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..4d10a68f4 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 (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 "%s" cmd) (org-babel-eval cmd "") nil)) ;; signal that output has already been written to file -- 2.28.0
Hi Terje,
sorry for the late reply.
Terje Larsen <terlar@gmail.com> writes:
> Did this look okay? I've had to rebase this once again due to some
> conflicts in the ORG-NEWS.
Applied, thanks!
--
Bastien