emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: "Dejan Josifović" <www.paranoidtimes@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file
Date: Sat, 15 Jan 2022 14:20:26 +0800	[thread overview]
Message-ID: <87y23hr045.fsf@localhost> (raw)
In-Reply-To: <5d7eba13-b717-a12a-5f89-7d2c9414917e@gmail.com>

[-- 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


  parent reply	other threads:[~2022-01-15  6:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Ihor Radchenko [this message]
2022-01-16  7:53   ` [PATCH] ob-plantuml: Allow setting PlantUML args for jar file 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ć

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y23hr045.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=www.paranoidtimes@gmail.com \
    --subject='Re: [PATCH] ob-plantuml: Allow setting PlantUML args for jar file' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this 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).