emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-plantuml: Proposal to add 'jar-args' customizable variable
@ 2021-12-03 22:56 Dejan Josifović
  2022-01-06 19:53 ` Dejan Josifović
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Dejan Josifović @ 2021-12-03 22:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I use PlantUML integration in org-mode for years now, but only
recently I came across some unwanted behavior.

Using PlantUML from jar (org-plantuml-jar-path variable) and latest 
org-mode, I wanted to render a diagram containing some Unicode 
characters (such as '⊥' and '∀'), but the end image had some gibberish 
instead. However,
trying this from a standalone file using plantuml-mode[1], the end image 
rendered correctly. Here is some sample code which can reproduce the issue:

#+BEGIN_SRC plantuml :file ./test.png
A -> B: ∀ characters display correctly is ⊥
#+END_SRC

Comparing ob-plantuml.el and plantuml-mode.el files I found what is the 
problem. plantuml-mode has a customizable variable for specifying 
arguments when using PlantUML from jar (plantuml-jar-args (list 
"-charset" "UTF-8" ). The charset arguments is what is needed for
the images to render correctly (I confirmed it by implementing it locally).

I was wondering why such variable doesn't exist in ob-plantuml. I have
searched the mailing list archives, confirmed bugs and help page and 
couldn't find anything related.

Does anyone from the community know if such variable was deliberately 
omitted? If so, what is the reason?

If this is indeed a wanted feature, I will be more than happy to provide 
a patch.

[1] https://github.com/skuro/plantuml-mode

Thanks and regards,

-- 
Dejan Josifović | Дејан Јосифовић
Software engineer | Софтверски инжењер
https://theparanoidtimes.org

()  ascii ribbon campaign
/\  www.asciiribbon.org


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: ob-plantuml: Proposal to add 'jar-args' customizable variable
  2021-12-03 22:56 ob-plantuml: Proposal to add 'jar-args' customizable variable Dejan Josifović
@ 2022-01-06 19:53 ` Dejan Josifović
  2022-01-07  4:38   ` Ihor Radchenko
  2022-01-09 17:46 ` Andy Moreton
  2022-01-15  6:20 ` [PATCH] ob-plantuml: Allow setting PlantUML args for jar file Ihor Radchenko
  2 siblings, 1 reply; 15+ messages in thread
From: Dejan Josifović @ 2022-01-06 19:53 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1868 bytes --]

On 03-Dec-21 23:56, Dejan Josifović wrote:
> Hi all,
> 
> I use PlantUML integration in org-mode for years now, but only
> recently I came across some unwanted behavior.
> 
> Using PlantUML from jar (org-plantuml-jar-path variable) and latest 
> org-mode, I wanted to render a diagram containing some Unicode 
> characters (such as '⊥' and '∀'), but the end image had some gibberish 
> instead. However,
> trying this from a standalone file using plantuml-mode[1], the end image 
> rendered correctly. Here is some sample code which can reproduce the issue:
> 
> #+BEGIN_SRC plantuml :file ./test.png
> A -> B: ∀ characters display correctly is ⊥
> #+END_SRC
> 
> Comparing ob-plantuml.el and plantuml-mode.el files I found what is the 
> problem. plantuml-mode has a customizable variable for specifying 
> arguments when using PlantUML from jar (plantuml-jar-args (list 
> "-charset" "UTF-8" ). The charset arguments is what is needed for
> the images to render correctly (I confirmed it by implementing it locally).
> 
> I was wondering why such variable doesn't exist in ob-plantuml. I have
> searched the mailing list archives, confirmed bugs and help page and 
> couldn't find anything related.
> 
> Does anyone from the community know if such variable was deliberately 
> omitted? If so, what is the reason?
> 
> If this is indeed a wanted feature, I will be more than happy to provide 
> a patch.
> 
> [1] https://github.com/skuro/plantuml-mode
> 
> Thanks and regards,
> 

Hi all,

I has been a little over a month since i posted this to the mailing 
list, so I'm trying to bump it.

Thanks all.

Regards,

-- 
Dejan Josifović | Дејан Јосифовић
Software engineer | Софтверски инжењер
https://theparanoidtimes.org

()  ascii ribbon campaign
/\  www.asciiribbon.org

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: ob-plantuml: Proposal to add 'jar-args' customizable variable
  2022-01-06 19:53 ` Dejan Josifović
@ 2022-01-07  4:38   ` Ihor Radchenko
  2022-01-08 13:14     ` Dejan Josifović
  0 siblings, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2022-01-07  4:38 UTC (permalink / raw)
  To: Dejan Josifović; +Cc: emacs-orgmode

Dejan Josifović <www.paranoidtimes@gmail.com> writes:

> I has been a little over a month since i posted this to the mailing 
> list, so I'm trying to bump it.

Added to todo list. It may take a little while, but I will take a look
at it relatively soon.

Best,
Ihor


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: ob-plantuml: Proposal to add 'jar-args' customizable variable
  2022-01-07  4:38   ` Ihor Radchenko
@ 2022-01-08 13:14     ` Dejan Josifović
  0 siblings, 0 replies; 15+ messages in thread
From: Dejan Josifović @ 2022-01-08 13:14 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 598 bytes --]

On 07-Jan-22 05:38, Ihor Radchenko wrote:
> Dejan Josifović <www.paranoidtimes@gmail.com> writes:
> 
>> I has been a little over a month since i posted this to the mailing
>> list, so I'm trying to bump it.
> 
> Added to todo list. It may take a little while, but I will take a look
> at it relatively soon.
> 
> Best,
> Ihor

Thanks Ihor!

Mail me if you need more info.

Regards,

-- 
Dejan Josifović | Дејан Јосифовић
Software engineer | Софтверски инжењер
https://theparanoidtimes.org

()  ascii ribbon campaign
/\  www.asciiribbon.org

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: ob-plantuml: Proposal to add 'jar-args' customizable variable
  2021-12-03 22:56 ob-plantuml: Proposal to add 'jar-args' customizable variable Dejan Josifović
  2022-01-06 19:53 ` Dejan Josifović
@ 2022-01-09 17:46 ` Andy Moreton
  2022-01-10 16:00   ` Dejan Josifović
  2022-01-15  6:20 ` [PATCH] ob-plantuml: Allow setting PlantUML args for jar file Ihor Radchenko
  2 siblings, 1 reply; 15+ messages in thread
From: Andy Moreton @ 2022-01-09 17:46 UTC (permalink / raw)
  To: emacs-orgmode

On Fri 03 Dec 2021, Dejan Josifović wrote:

> Hi all,
>
> I use PlantUML integration in org-mode for years now, but only
> recently I came across some unwanted behavior.
>
> Using PlantUML from jar (org-plantuml-jar-path variable) and latest 
> org-mode, I wanted to render a diagram containing some Unicode 
> characters (such as '⊥' and '∀'), but the end image had some gibberish 
> instead. However,
> trying this from a standalone file using plantuml-mode[1], the end image 
> rendered correctly. Here is some sample code which can reproduce the issue:
>
> #+BEGIN_SRC plantuml :file ./test.png
> A -> B: ∀ characters display correctly is ⊥
> #+END_SRC
>
> Comparing ob-plantuml.el and plantuml-mode.el files I found what is the 
> problem. plantuml-mode has a customizable variable for specifying 
> arguments when using PlantUML from jar (plantuml-jar-args (list 
> "-charset" "UTF-8" ). The charset arguments is what is needed for
> the images to render correctly (I confirmed it by implementing it locally).
>
> I was wondering why such variable doesn't exist in ob-plantuml. I have
> searched the mailing list archives, confirmed bugs and help page and 
> couldn't find anything related.

I use this snippet to set the ob-plantuml.el args to match the
plantuml-mode.el settings:

  (setf (alist-get :java    org-babel-default-header-args:plantuml)
        (mapconcat #'identity plantuml-java-args " ")
        (alist-get :cmdline org-babel-default-header-args:plantuml)
        (mapconcat #'identity plantuml-jar-args " "))

Hope that helps,

    AndyM



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: ob-plantuml: Proposal to add 'jar-args' customizable variable
  2022-01-09 17:46 ` Andy Moreton
@ 2022-01-10 16:00   ` Dejan Josifović
  0 siblings, 0 replies; 15+ messages in thread
From: Dejan Josifović @ 2022-01-10 16:00 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1261 bytes --]

On 09-Jan-22 18:46, Andy Moreton wrote:
> I use this snippet to set the ob-plantuml.el args to match the
> plantuml-mode.el settings:
> 
>    (setf (alist-get :java    org-babel-default-header-args:plantuml)
>          (mapconcat #'identity plantuml-java-args " ")
>          (alist-get :cmdline org-babel-default-header-args:plantuml)
>          (mapconcat #'identity plantuml-jar-args " "))
> 
> Hope that helps,
> 
>      AndyM

Hi AndyM,

This is actually very helpful It didn't remotely cross my mind to do 
something like this. Thanks a bunch! I was using PlantUML from shell to 
create images to bypass this until now.

Of course, a native solution in babel for this is always better.

Looking at this, I see that in my initial post I made an argument only 
for arguments passed to PlantUML jar, but now I see that the same can be 
applied for arguments passed to java command/process. Both are 
customizable in plantuml-mode, but not in ob-plantuml. Maybe we should 
think about adding a separate var for those also.

Regards,

-- 
Dejan Josifović | Дејан Јосифовић
Software engineer | Софтверски инжењер
https://theparanoidtimes.org

()  ascii ribbon campaign
/\  www.asciiribbon.org

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2021-12-03 22:56 ob-plantuml: Proposal to add 'jar-args' customizable variable Dejan Josifović
  2022-01-06 19:53 ` Dejan Josifović
  2022-01-09 17:46 ` Andy Moreton
@ 2022-01-15  6:20 ` Ihor Radchenko
  2022-01-16  7:53   ` Max Nikulin
  2 siblings, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2022-01-15  6:20 UTC (permalink / raw)
  To: Dejan Josifović; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

Dejan Josifović <www.paranoidtimes@gmail.com> writes:

> Using PlantUML from jar (org-plantuml-jar-path variable) and latest 
> org-mode, I wanted to render a diagram containing some Unicode 
> characters (such as '⊥' and '∀'), but the end image had some gibberish 
> instead. However,
> trying this from a standalone file using plantuml-mode[1], the end image 
> rendered correctly. Here is some sample code which can reproduce the issue:
>
> #+BEGIN_SRC plantuml :file ./test.png
> A -> B: ∀ characters display correctly is ⊥
> #+END_SRC

FYI, I am unable to reproduce it on my system.

> Comparing ob-plantuml.el and plantuml-mode.el files I found what is the 
> problem. plantuml-mode has a customizable variable for specifying 
> arguments when using PlantUML from jar (plantuml-jar-args (list 
> "-charset" "UTF-8" ). The charset arguments is what is needed for
> the images to render correctly (I confirmed it by implementing it locally).
>
> I was wondering why such variable doesn't exist in ob-plantuml. I have
> searched the mailing list archives, confirmed bugs and help page and 
> couldn't find anything related.

Even though I was unable to reproduce your problem (most likely because
my system is different), it sounds like a good idea to allow users to
customise jar args as well.

Then, users might do something like
(setq org-plantuml-jar-path "/usr/share/plantuml/lib/plantuml.jar")
(setq org-plantuml-args (list "-headless" "-theme" "aws-orange"))
and set a global PlantUML theme.

See the attached patch. It appears that we can simply carry over the
executable args to jar (but please test it on other systems!)

Best,
Ihor

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-plantuml-Allow-setting-PlantUML-args-for-jar-file.patch --]
[-- Type: text/x-patch, Size: 3541 bytes --]

From 87accd87fa189198e69632da6081f60bc247ad94 Mon Sep 17 00:00:00 2001
Message-Id: <87accd87fa189198e69632da6081f60bc247ad94.1642227388.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 15 Jan 2022 14:14:36 +0800
Subject: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file

* lisp/ob-plantuml.el (org-plantuml-args): Rename
`org-plantuml-executable-args' to `org-plantuml-args'.
(org-babel-execute:plantuml): Use `org-plantuml-args' when calling
jar.
* lisp/org-compat.el (org-plantuml-executable-args): Obsolete old
variable name.
* etc/ORG-NEWS (=org-plantump-executable-args= is renamed and applies
to jar as well): Document change.
---
 etc/ORG-NEWS        |  6 ++++++
 lisp/ob-plantuml.el | 15 ++++++++-------
 lisp/org-compat.el  |  3 +++
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 335db4139..d311d495c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -98,6 +98,12 @@ argument.
 ~org-get-tags~ now accepts Org element or buffer position as first
 argument.
 
+** Removed or renamed functions and variables
+*** =org-plantump-executable-args= is renamed and applies to jar as well
+
+The new variable name is =org-plantump-args=.  It now applies to both
+jar PlantUML file and executable.
+
 ** Miscellaneous
 
 *** Styles are customizable in ~biblatex~ citation processor
diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index d237b0fe3..ddc2ff3dc 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -65,8 +65,8 @@ (defcustom org-plantuml-executable-path "plantuml"
   :package-version '(Org . "9.4")
   :type 'string)
 
-(defcustom org-plantuml-executable-args (list "-headless")
-  "The arguments passed to plantuml executable when executing PlantUML."
+(defcustom org-plantuml-args (list "-headless")
+  "The arguments passed to plantuml when executing PlantUML."
   :group 'org-babel
   :package-version '(Org . "9.4")
   :type '(repeat string))
@@ -116,15 +116,16 @@ (defun org-babel-execute:plantuml (body params)
 	 (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)
+	 (executable-args (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-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
-					 "-Djava.awt.headless=true"
-					 "-jar"
-					 (shell-quote-argument (expand-file-name org-plantuml-jar-path))))))
+				(t `(,java
+				     "-Djava.awt.headless=true"
+				     "-jar"
+				     ,(shell-quote-argument (expand-file-name org-plantuml-jar-path))
+                                     ,@org-plantuml-args))))
 	 (full-body (org-babel-plantuml-make-body body params))
 	 (cmd (mapconcat #'identity
 			 (append
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 14f6bc8dc..1d6c35e9a 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -351,6 +351,9 @@ (make-obsolete 'org-attach-expand-link "No longer used" "9.4")
 
 (define-obsolete-function-alias 'org-file-url-p 'org-url-p "9.5")
 
+(define-obsolete-variable-alias 'org-plantuml-executable-args 'org-plantuml-args
+  "Org 9.6")
+
 (defun org-in-fixed-width-region-p ()
   "Non-nil if point in a fixed-width region."
   (save-match-data
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-15  6:20 ` [PATCH] ob-plantuml: Allow setting PlantUML args for jar file Ihor Radchenko
@ 2022-01-16  7:53   ` Max Nikulin
  2022-01-17 17:19     ` Dejan Josifović
  0 siblings, 1 reply; 15+ messages in thread
From: Max Nikulin @ 2022-01-16  7:53 UTC (permalink / raw)
  To: Ihor Radchenko, Dejan Josifović; +Cc: emacs-orgmode

Hi.

Disclaimer: I am neither plantuml nor ditaa user, so my comments may 
have no sense.

On 15/01/2022 13:20, Ihor Radchenko wrote:
> Dejan Josifović writes:
> 
>> Comparing ob-plantuml.el and plantuml-mode.el files I found what is the
>> problem. plantuml-mode has a customizable variable for specifying
>> arguments when using PlantUML from jar (plantuml-jar-args (list
>> "-charset" "UTF-8" ). The charset arguments is what is needed for
>> the images to render correctly (I confirmed it by implementing it locally).
>>
>> I was wondering why such variable doesn't exist in ob-plantuml.

Dejan, have you tried :java or :cmdline header arguments?

> Even though I was unable to reproduce your problem (most likely because
> my system is different), it sounds like a good idea to allow users to
> customise jar args as well.

I agree that arguments should be customizable when the application is 
launched from jar, but there are already :java argument that is inserted 
before jar file and :cmdline argument that is appended after it.

Another consideration is that ob-ditaa and ob-plantuml should use 
similar set of header arguments for additional parameters. They (and 
third-party packages) may even share some parameters related to java 
executable location and arguments for tuning of java VM (memory limits, 
etc.).

> See the attached patch. It appears that we can simply carry over the
> executable args to jar (but please test it on other systems!)

> -				(t (list java
> -					 "-Djava.awt.headless=true"

(unrelated to this patch) The line above is a recent change, and I do 
not see a reason why it is not added in a customizable way through 
appending (:java "-Djava.awt.headless=true") to 
`org-babel-default-header-args:plantuml'. Maybe I just missed something 
stupid since I have not tried it.

> -					 "-jar"
> -					 (shell-quote-argument (expand-file-name org-plantuml-jar-path))))))
> +				(t `(,java
> +				     "-Djava.awt.headless=true"
> +				     "-jar"
> +				     ,(shell-quote-argument (expand-file-name org-plantuml-jar-path))
> +                                     ,@org-plantuml-args))))

Is there a case when some arguments are suitable for dedicated binary 
but should be avoided for jar (when a user has both executable from 
system package and manually downloaded jar having newer version)? It may 
be a reason to have separate variables (or header arguments).

I suppose, a part of problem that there are no plantuml and ditaa users 
and subscribers of this list who are ready to discuss code of related 
babel packages.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-16  7:53   ` Max Nikulin
@ 2022-01-17 17:19     ` Dejan Josifović
  2022-01-18 13:30       ` Ihor Radchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Dejan Josifović @ 2022-01-17 17:19 UTC (permalink / raw)
  To: Max Nikulin, Ihor Radchenko; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2243 bytes --]

On 16-Jan-22 08:53, Max Nikulin wrote:
> Dejan, have you tried :java or :cmdline header arguments?

Hi Max! Yes, I have tried with those header arguments and they naturally 
work. Maybe I should've mentioned that.

But, since ob-plantuml already had variable for arguments for executable 
it fells natural to me to have customizable variables for when using 
jar. These headers are of course easier, but the user would have to 
write them on each source block to achieve something that should be 
globally customizable (like charset).

On 15-Jan-22 07:20, Ihor Radchenko wrote:
> See the attached patch. It appears that we can simply carry over the
> executable args to jar (but please test it on other systems!)
I have tested the patch on my machine and it works fine. I have set
the new/renamed variable like this:
(setq org-plantuml-args (list "-headless" "-charset" "UTF-8"))

and tried the same example:

#+BEGIN_SRC plantuml :file ./test.png
   A -> B: Hello ∧
#+END_SRC

and it renders correctly.
However, I have a couple of concerns.

I second the concern that Max stated:
> Is there a case when some arguments are suitable for dedicated binary but should be avoided for jar (when a user has both executable from system package and manually downloaded jar having newer version)? It may be a reason to have separate variables (or header arguments).
I believe it is better design decision to separate arguments for 
executable and jar.

Since we are making jar arguments customizable, we should think about 
adding java arguments customizable (also mentioned by Max!). This line 
in patch:
+		"-Djava.awt.headless=true"
can be also added to a separate variable.

Lastly, there is a typo in the patch:
+** Removed or renamed functions and variables
+*** =org-plantump-executable-args= is renamed and applies to jar as well
+
+The new variable name is =org-plantump-args=.  It now applies to both
+jar PlantUML file and executable.
Word plantump should be plantuml I guess. :-)

Thanks all,

-- 
Dejan Josifović | Дејан Јосифовић
Software engineer | Софтверски инжењер
https://theparanoidtimes.org

()  ascii ribbon campaign
/\  www.asciiribbon.org

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-17 17:19     ` Dejan Josifović
@ 2022-01-18 13:30       ` Ihor Radchenko
  2022-01-19 16:54         ` Max Nikulin
  0 siblings, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2022-01-18 13:30 UTC (permalink / raw)
  To: Dejan Josifović; +Cc: Max Nikulin, emacs-orgmode

Dejan Josifović <www.paranoidtimes@gmail.com> writes:

> But, since ob-plantuml already had variable for arguments for executable 
> it fells natural to me to have customizable variables for when using 
> jar. These headers are of course easier, but the user would have to 
> write them on each source block to achieve something that should be 
> globally customizable (like charset).

FYI, you can customise any header arg globally. See manual page 16.3
Using Header Arguments.

> I second the concern that Max stated:
>> Is there a case when some arguments are suitable for dedicated binary but should be avoided for jar (when a user has both executable from system package and manually downloaded jar having newer version)? It may be a reason to have separate variables (or header arguments).
> I believe it is better design decision to separate arguments for 
> executable and jar.

I am not sure about this specific case. The PlantUML executable is
literally a wrapper around java call to jar. Below is the contents of
plantuml file in my system:

#!/bin/bash
gjl_package=plantuml
gjl_jar="plantuml.jar"
source /usr/share/java-config-2/launcher/launcher.bash

Unless it is any different on your side, the arguments for jar and
executable should be literally the same.

> Since we are making jar arguments customizable, we should think about 
> adding java arguments customizable (also mentioned by Max!). This line 
> in patch:
> +		"-Djava.awt.headless=true"
> can be also added to a separate variable.

I feel that running headless mode in the ob-plantuml is deliberate. We
may not want users to change it. Otherwise, you are free to customize
java arguments in org-babel-default-header-args:plantuml

> Lastly, there is a typo in the patch:
> +** Removed or renamed functions and variables
> +*** =org-plantump-executable-args= is renamed and applies to jar as well
> +
> +The new variable name is =org-plantump-args=.  It now applies to both
> +jar PlantUML file and executable.
> Word plantump should be plantuml I guess. :-)

Thanks! Will fix.

Best,
Ihor


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-18 13:30       ` Ihor Radchenko
@ 2022-01-19 16:54         ` Max Nikulin
  2022-01-21 12:48           ` Ihor Radchenko
  2022-01-21 22:22           ` Dejan Josifović
  0 siblings, 2 replies; 15+ messages in thread
From: Max Nikulin @ 2022-01-19 16:54 UTC (permalink / raw)
  To: emacs-orgmode

On 18/01/2022 20:30, Ihor Radchenko wrote:
> Dejan Josifović writes:
> 
>> But, since ob-plantuml already had variable for arguments for executable
>> it fells natural to me to have customizable variables for when using
>> jar. These headers are of course easier, but the user would have to
>> write them on each source block to achieve something that should be
>> globally customizable (like charset).
> 
> FYI, you can customise any header arg globally. See manual page 16.3
> Using Header Arguments.

info "(org) Using Header Arguments" 
https://orgmode.org/manual/Using-Header-Arguments.html

> #!/bin/bash
> gjl_package=plantuml
> gjl_jar="plantuml.jar"
> source /usr/share/java-config-2/launcher/launcher.bash

It seems with with the suggested patch both -Djava.awt.headless=true and 
-headless are passed to jar. I suspect it is either redundant or 
launcher.bash converts "-headless" to "-Djava.awt.headless=true". In 
ubuntu there is no room for special treatment of "-headless" option by 
the shell wrapper:
--- >8 ----
if [ -n "${JAVA_HOME}" ] && [ -x "${JAVA_HOME}/bin/java" ] ; then
     JAVA="${JAVA_HOME}/bin/java"
elif [ -x /usr/bin/java ] ; then
     JAVA=/usr/bin/java
else
     echo Cannot find JVM
     exit 1
fi

$JAVA -jar -Djava.net.useSystemProxies=true 
/usr/share/plantuml/plantuml.jar ${@}
---- 8< ---

> I feel that running headless mode in the ob-plantuml is deliberate.

https://plantuml.com/faq
"Basically, this is because PlantUML needs to have access to some 
graphical resources"

I have no idea what is actually affected.

Which peace of code (java or plantuml.jar) handles "-headless" option? 
This question affects decision if jar and executable wrapper modes may 
share same list of arguments. Plantuml site recommends namely 
-Djava.awt.headless=true. Anyway with or without the patch, 
"-Djava.awt.headless=true" is added unconditionally in the jar mode. I 
would revert that patch and either add it to java header argument or to 
a new defcustom.

Are there cases when :cmdline header argument is not enough and extra 
custom variable org-plantuml-args (org-plantump-executable-args) should 
be used?

Actually I have realized that I do not understand why babel code uses 
mix of defcustom and header arguments. The latter are more flexible and 
may be adjusted per source block. On the other hand they may be set in 
init file. Even java executable and path to jar file may be obtained 
from header arguments.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-19 16:54         ` Max Nikulin
@ 2022-01-21 12:48           ` Ihor Radchenko
  2022-01-23 16:50             ` Max Nikulin
  2022-01-21 22:22           ` Dejan Josifović
  1 sibling, 1 reply; 15+ messages in thread
From: Ihor Radchenko @ 2022-01-21 12:48 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>> #!/bin/bash
>> gjl_package=plantuml
>> gjl_jar="plantuml.jar"
>> source /usr/share/java-config-2/launcher/launcher.bash
>
> It seems with with the suggested patch both -Djava.awt.headless=true and 
> -headless are passed to jar. I suspect it is either redundant or 
> launcher.bash converts "-headless" to "-Djava.awt.headless=true". In 
> ubuntu there is no room for special treatment of "-headless" option by 
> the shell wrapper:

It is redundant, but should not cause any harm. plantuml source code has:

if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) {
			System.setProperty("java.awt.headless", "true");
		}

I can of course add a condition to not add -headless if we are running
jar, but I do not see much benefit except purity argument.

>> I feel that running headless mode in the ob-plantuml is deliberate.
>
> https://plantuml.com/faq
> "Basically, this is because PlantUML needs to have access to some 
> graphical resources"
>
> I have no idea what is actually affected.

It mostly looks like otherwise there are some harmless warnings in the
output. 

> Which peace of code (java or plantuml.jar) handles "-headless" option? 
> This question affects decision if jar and executable wrapper modes may 
> share same list of arguments. Plantuml site recommends namely 
> -Djava.awt.headless=true. Anyway with or without the patch, 
> "-Djava.awt.headless=true" is added unconditionally in the jar mode. I 
> would revert that patch and either add it to java header argument or to 
> a new defcustom.

I do not see much point customising this particular argument. We _do
not_ want plantuml in gui mode. Ever. Otherwise, babel behaviour will be
unpredictable. If we make it customizeable, the only "benefit" would be
allowing users to shoot their own leg.

> Are there cases when :cmdline header argument is not enough and extra 
> custom variable org-plantuml-args (org-plantump-executable-args) should 
> be used?

> Actually I have realized that I do not understand why babel code uses 
> mix of defcustom and header arguments. The latter are more flexible and 
> may be adjusted per source block. On the other hand they may be set in 
> init file. Even java executable and path to jar file may be obtained 
> from header arguments.

Good questions. I think that the main reason is that most of header args
are not merged - only the last value is used. If you define :cmdline in
source block, it will override system-wide settings. Having an
additional defcustom allows to provide a "permanent" set of parameters -
to be used no matter what.

I realise that the current situation is kind of awkward. Maybe we should
encourage ob-* libraries to use special header args instead of
defcustoms and modify built-in libraries in this spirit. Would you be
interested to write a feature request?

Best,
Ihor





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-19 16:54         ` Max Nikulin
  2022-01-21 12:48           ` Ihor Radchenko
@ 2022-01-21 22:22           ` Dejan Josifović
  1 sibling, 0 replies; 15+ messages in thread
From: Dejan Josifović @ 2022-01-21 22:22 UTC (permalink / raw)
  To: Max Nikulin, Ihor Radchenko; +Cc: emacs-orgmode

On 19-Jan-22 17:54, Max Nikulin wrote:
>> FYI, you can customise any header arg globally. See manual page 16.3
>> Using Header Arguments.
> 
> info "(org) Using Header Arguments" https://orgmode.org/manual/Using-Header-Arguments.html

Thanks for the info. I'm still not fully proficient in org-mode so this 
(and the discussion) is very helpful.

On 18-Jan-22 14:30, Ihor Radchenko wrote:
> I am not sure about this specific case. The PlantUML executable is
> literally a wrapper around java call to jar. Below is the contents of
> plantuml file in my system:
> 
> #!/bin/bash
> gjl_package=plantuml
> gjl_jar="plantuml.jar"
> source /usr/share/java-config-2/launcher/launcher.bash
> 
> Unless it is any different on your side, the arguments for jar and
> executable should be literally the same.

I see your point here - no need for redundant custom variables.

> I realise that the current situation is kind of awkward. Maybe we should
> encourage ob-* libraries to use special header args instead of
> defcustoms and modify built-in libraries in this spirit. Would you be
> interested to write a feature request?

This is very interesting, I will keep an eye on this discussion to 
follow up on everything. :-)

Thanks.

Regards,

-- 
Dejan Josifović | Дејан Јосифовић
Software engineer | Софтверски инжењер
https://theparanoidtimes.org

()  ascii ribbon campaign
/\  www.asciiribbon.org


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-21 12:48           ` Ihor Radchenko
@ 2022-01-23 16:50             ` Max Nikulin
  2022-05-08  6:48               ` Ihor Radchenko
  0 siblings, 1 reply; 15+ messages in thread
From: Max Nikulin @ 2022-01-23 16:50 UTC (permalink / raw)
  To: emacs-orgmode

On 21/01/2022 19:48, Ihor Radchenko wrote:
> Max Nikulin writes:

I have reordered some parts of your message

> I do not see much point customising this particular argument. We _do
> not_ want plantuml in gui mode. Ever. Otherwise, babel behaviour will be
> unpredictable. If we make it customizeable, the only "benefit" would be
> allowing users to shoot their own leg.

I have tried plantuml and it does not start in GUI mode unless -gui 
option is specified. I admit it might be not so kind in the past. If you 
mean the following thread

Sun Lin. Subject: [PATCH] Fix DISPLAY error on exporting org with 
plantuml to html. Sat, 16 Oct 2021 03:25:40 +0000 (UTC) 
https://list.orgmode.org/388850760.3644614.1634354740816@mail.yahoo.com/

than it is some strange use case. A lot of applications behave 
incorrectly when DISPLAY environment variable has invalid value. So it 
is responsibility of the user to reset it. On the other hand I believe 
that nobody is still using e.g. remote font server and headless mode 
might be a bit more reproducible (e.g. screen dpi can not affect result).

Actually you patch makes headless mode customizable and I do not 
consider it as shooting somebody's foot:

> +(defcustom org-plantuml-args (list "-headless")

So in my opinion dropping "-Djava.awt.headless=true" is just a step to 
more consistent behavior for jar/wrapper modes.

> if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) {
> 			System.setProperty("java.awt.headless", "true");
> 		}

Thank you it makes thing more clear. By the way, latest wrapper in 
ubuntu has the following code

---- >8 ----
HEADLESS=
[ -z "$DISPLAY" ] && HEADLESS=-Djava.awt.headless=true

$JAVA -Djava.net.useSystemProxies=true $HEADLESS -jar 
/usr/share/plantuml/plantuml.jar "$@"
---- 8< ----

> I realise that the current situation is kind of awkward. Maybe we should
> encourage ob-* libraries to use special header args instead of
> defcustoms and modify built-in libraries in this spirit. Would you be
> interested to write a feature request?

I do not have clear vision how it should work yet. I am afraid that even 
if I were dump current state of ideas, they would be lost and nobody 
would remind about them when the question would be risen next time.

I do not object concerning common `org-plantuml-args' variable. Earlier 
I had in mind that user might have incompatible versions of plantuml 
installed as executable wrapper and available as another jar. Separate 
args variable might make it easier to switch between wrapper/jar modes. 
I do not think it is a case that must be supported, anyway it is 
currently impossible to switch mode through header arguments, e.g. to 
demonstrate version difference.

On 15/01/2022 13:20, Ihor Radchenko wrote:
> Dejan Josifović writes:
> 
>> Using PlantUML from jar (org-plantuml-jar-path variable) and latest 
>> org-mode, I wanted to render a diagram containing some Unicode 
>> characters (such as '⊥' and '∀'), but the end image had some gibberish 
>> instead.
>>
>> #+BEGIN_SRC plantuml :file ./test.png
>> A -> B: ∀ characters display correctly is ⊥
>> #+END_SRC
> 
> FYI, I am unable to reproduce it on my system.

Default charset depends on locale:

LANG=C plantuml -h | grep charset
     -charset xxx	To use a specific charset (default is US-ASCII)

plantuml -h | grep charset
     -charset xxx	To use a specific charset (default is UTF-8)

echo $LANG
en_US.UTF-8

To wrap up, I suggest (and I do not insist) to drop 
"-Djava.awt.headless=true" since "-headless" is anyway added in jar 
mode. Those who desperately need namely "-Djava.awt.headless=true" (for 
some unknown to me reason) may customize :java header argument. I do not 
see any real problem with the change, just a minor improvement.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
  2022-01-23 16:50             ` Max Nikulin
@ 2022-05-08  6:48               ` Ihor Radchenko
  0 siblings, 0 replies; 15+ messages in thread
From: Ihor Radchenko @ 2022-05-08  6:48 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> To wrap up, I suggest (and I do not insist) to drop 
> "-Djava.awt.headless=true" since "-headless" is anyway added in jar 
> mode. Those who desperately need namely "-Djava.awt.headless=true" (for 
> some unknown to me reason) may customize :java header argument. I do not 
> see any real problem with the change, just a minor improvement.

After further consideration, I decided to follow your suggestion.
If we insist of -Djava.awt.headless=true in org-plantuml-exec-mode='jar
but not in 'plantuml, we may run into inconsistency between users using
the two alternatives.

Applied onto main as b5f0efc04.

Best,
Ihor


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-05-08  6:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 22:56 ob-plantuml: Proposal to add 'jar-args' customizable variable Dejan Josifović
2022-01-06 19:53 ` Dejan Josifović
2022-01-07  4:38   ` Ihor Radchenko
2022-01-08 13:14     ` Dejan Josifović
2022-01-09 17:46 ` Andy Moreton
2022-01-10 16:00   ` Dejan Josifović
2022-01-15  6:20 ` [PATCH] ob-plantuml: Allow setting PlantUML args for jar file Ihor Radchenko
2022-01-16  7:53   ` Max Nikulin
2022-01-17 17:19     ` Dejan Josifović
2022-01-18 13:30       ` Ihor Radchenko
2022-01-19 16:54         ` Max Nikulin
2022-01-21 12:48           ` Ihor Radchenko
2022-01-23 16:50             ` Max Nikulin
2022-05-08  6:48               ` Ihor Radchenko
2022-01-21 22:22           ` Dejan Josifović

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).