emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix ob-plantuml over TRAMP
@ 2021-11-24 17:29 guillaume
  2021-11-25 12:40 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: guillaume @ 2021-11-24 17:29 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi All,

My Emacs Workflow involves connecting to a dev server over SSH so I can use my machines as thin clients and avoid synchronizing files,
for that I do pretty much everything over TRAMP as I don’t want to lose the benefits of GUI Emacs.
While everything mostly works impressively fine, I noticed writing my specifications that ob-plantuml fails to generate diagrams.

It seems to me that there is a redundant check which uses `file-exists-p` even if using TRAMP, the plantuml jar is located on the remote server, so 
it fails with an error even though the command to actually render the diagrams works fine.

The patch I propose involves keeping this check but moving it so it only generates a message instead of failing the whole generation process,
doing so allows to restore the functionality and I can finally generate my sequence diagrams over TRAMP.

For more details, see the attached patch.

--
Guillaume


[-- Attachment #2: 0001-Allow-ob-plantuml-to-work-over-Tramp.patch --]
[-- Type: application/octet-stream, Size: 1435 bytes --]

From 91c07f05988190adf51bbf33fd64f34245bc97be Mon Sep 17 00:00:00 2001
From: Guillaume Buisson <guillaume@gbuisson.com>
Date: Wed, 24 Nov 2021 16:42:31 +0100
Subject: [PATCH] Allow ob-plantuml to work over Tramp

* lisp/ob-plantuml.el (org-babel-plantuml): Modify the jar file check so it doesn't fail the generation,
allowing ob-plantuml to be used with TRAMP setups.

---
 lisp/ob-plantuml.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index fc621600c..e8fff0742 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -116,11 +116,11 @@ This function is called by `org-babel-execute-src-block'."
 	 (java (or (cdr (assq :java params)) ""))
 	 (executable (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-path)
 			   (t "java")))
+         (jar-exists? (or (file-exists-p org-plantuml-jar-path)
+			  (message "Could not find plantuml.jar at %s" org-plantuml-jar-path)))
 	 (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))))))
-- 
2.31.1


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

* Re: [PATCH] Fix ob-plantuml over TRAMP
  2021-11-24 17:29 [PATCH] Fix ob-plantuml over TRAMP guillaume
@ 2021-11-25 12:40 ` Ihor Radchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Ihor Radchenko @ 2021-11-25 12:40 UTC (permalink / raw)
  To: guillaume; +Cc: emacs-orgmode

guillaume@gbuisson.com writes:

> It seems to me that there is a redundant check which uses `file-exists-p` even if using TRAMP, the plantuml jar is located on the remote server, so 
> it fails with an error even though the command to actually render the diagrams works fine.

I disagree that the check is redundant. It is still a good idea to check
if plantuml jar exists on server itself. Another question is how to make
`file-exists-p' work with TRAMP.

> The patch I propose involves keeping this check but moving it so it only generates a message instead of failing the whole generation process,
> doing so allows to restore the functionality and I can finally generate my sequence diagrams over TRAMP.

Your patch will break legitimate check for people running plantuml
locally. A better way would be checking default-directory and if we are
in a remote server, using appropriate check working over TRAMP.

Best,
Ihor


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

* [PATCH] Fix ob-plantuml over TRAMP
@ 2021-11-24 16:11 Guillaume Buisson (gbuisson)
  0 siblings, 0 replies; 3+ messages in thread
From: Guillaume Buisson (gbuisson) @ 2021-11-24 16:11 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi All,

My Emacs Workflow involves connecting to a dev server over SSH so I can use my machines as thin clients and avoid synchronizing files,
for that I do pretty much everything over TRAMP as I don’t want to lose the benefits of GUI Emacs.
While everything mostly works impressively fine, I noticed writing my specifications that ob-plantuml fails to generate diagrams.

It seems to me that there is a redundant check which uses `file-exists-p` even if using TRAMP, the plantuml jar is located on the remote server, so 
it fails with an error even though the command to actually render the diagrams works fine.

The patch I propose involves keeping this check but moving it so it only generates a message instead of failing the whole generation process,
doing so allows to restore the functionality and I can finally generate my sequence diagrams over TRAMP.

For more details, see the attached patch.

--
Guillaume


[-- Attachment #2: 0001-Allow-ob-plantuml-to-work-over-Tramp.patch --]
[-- Type: application/octet-stream, Size: 1402 bytes --]

From 91c07f05988190adf51bbf33fd64f34245bc97be Mon Sep 17 00:00:00 2001
From: Guillaume Buisson <guillaume@gbuisson.com>
Date: Wed, 24 Nov 2021 16:42:31 +0100
Subject: [PATCH] Allow ob-plantuml to work over Tramp

* lisp/ob-plantuml.el (org-babel-plantuml): Modify the jar file check so it doesn't fail the generation,
allowing ob-plantuml to be used with TRAMP setups.

---
 lisp/ob-plantuml.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-plantuml.el b/lisp/ob-plantuml.el
index fc621600c..e8fff0742 100644
--- a/lisp/ob-plantuml.el
+++ b/lisp/ob-plantuml.el
@@ -116,11 +116,11 @@ This function is called by `org-babel-execute-src-block'."
 	 (java (or (cdr (assq :java params)) ""))
 	 (executable (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-path)
 			   (t "java")))
+         (jar-exists? (or (file-exists-p org-plantuml-jar-path)
+			  (message "Could not find plantuml.jar at %s" org-plantuml-jar-path)))
 	 (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))))))
-- 
2.31.1


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

end of thread, other threads:[~2021-11-25 12:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 17:29 [PATCH] Fix ob-plantuml over TRAMP guillaume
2021-11-25 12:40 ` Ihor Radchenko
  -- strict thread matches above, loose matches on Subject: below --
2021-11-24 16:11 Guillaume Buisson (gbuisson)

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).