Hi Bastien,

Please help to review this patch. Thanks

Best Regards

Lin Sun

----- Forwarded Message -----

From: Sun Lin <sunl...@yahoo.com>
To: emacs-orgmode@gnu.org <emacs-orgmode@gnu.org>
Sent: Saturday, October 16, 2021, 03:25:40 AM UTC
Subject: Subject: [PATCH] Fix DISPLAY error on exporting org with plantuml to 
html


Hi,

When the environment variable "DISPLAY" is invalid, exporting plantuml block in 
org will got error message:
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window 
server using 'localhost:11.0' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
...
To reproduce this issue, install the plantuml.jar and make sure it work inside 
org-mode.
Then open `/tmp/testing.org` and  input follow plantuml code and 
eval-expression `(progn (setenv "DISPLAY" 
"localhost:90")(org-html-export-to-html))`.
The root cause is org-mord execute the plantuml.jar in command line without 
headless parameter, then plantuml will try read the DISPLAY, it's unnecessary.
(For standalone plantuml, `org-plantuml-executable-args` has default value 
'-headless' to avoid reading DISPLAY).

Please help review the patch. Thanks.

Best Regards
Lin
From 5e04a800691b04edd940dd124987336f6f30dd62 Mon Sep 17 00:00:00 2001
From: Lin Sun <lin....@zoom.us>
Date: Sat, 16 Oct 2021 03:01:18 +0000
Subject: [PATCH] Fix DISPLAY error on exporting org with plantuml to html

* org-babel-execute:plantuml: using headless mode for org calling plantuml for exporting to html
---
 lisp/ob-plantuml.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index fc62160..7d92227 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -122,6 +122,7 @@ This function is called by `org-babel-execute-src-block'."
 				((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))))))
 	 (full-body (org-babel-plantuml-make-body body params))
-- 
2.7.0

Reply via email to