From: Leo Butler <Leo.Butler@umanitoba.ca>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Cc: Florin Boariu <florin.om@rootshell.ro>
Subject: Re: org-ditaa woes
Date: Thu, 26 Oct 2023 15:32:33 +0000 [thread overview]
Message-ID: <87bkcljt68.fsf@t14.reltub.ca> (raw)
In-Reply-To: <e98d4420-03e8-45c9-9622-1c02ef002ff4@gmail.com> (Max Nikulin's message of "Tue, 24 Oct 2023 14:55:33 +0700")
[-- Attachment #1: Type: text/plain, Size: 2747 bytes --]
On Tue, Oct 24 2023, Max Nikulin <manikulin@gmail.com> wrote:
> On 23/10/2023 18:18, Florin Boariu wrote:
>>
>>> sh-5.1$ flatpak-spawn --host toolbox run /usr/bin/ditaa
>>> /tmp/foo.txt -o /tmp/foo.png
>
> thanks
>
>> I really _need_ to generically execute a command.
>
> I hope, a couple of workarounds are still possible.
>
> 1. Get java command by adding bash -x (or /usr/bin/bash, or
> "/usr/bin/env bash")
>
> flatpak-spawn --host toolbox run bash -x /usr/bin/ditaa \
> /tmp/foo.txt -o /tmp/foo.png
>
> - set `org-babel-ditaa-java-cmd' to something like
> "flatpak-spawn --host toolbox run /usr/bin/java",
> - set `org-ditaa-jar-path' to path to ditaa.jar reported by the
> command above,
> - add other options to either `org-babel-header-args:ditaa' :java
> property or to `org-babel-ditaa-java-cmd'
> - perhaps add /usr/bin/env JAVA_HOME=... and other required
> environment variables before java binary.
>
>
> 2.
> - set `org-babel-ditaa-java-cmd' to
> "flatpak-spawn --host toolbox run /usr/bin/ditaa".
> - set `org-ditaa-jar-option' to empty string.
> - Call of `shell-quote-argument' makes it impossible to set
> `org-ditaa-jar-path' to empty string, so set the following variables
> to some harmless value, e.g. "-Dfile.encoding=UTF-8" (anything added
> through :java babel header argument):
> + `org-ditaa-jar-path'
> + `org-ditaa-eps-jar-path'
>
>
> I agree that it should be possible to call ditaa executable
> directly. Perhaps it is not possible because for a long time ditaa.jar
> was a part of Org mode repository (there were a lot of messages
> against dropping of jar files from the repository). It seems, nobody
> is ready to take responsibility and to become maintainer of
> ob-ditaa.el while active users have no ability to install ditaa as a
> package, so they anyway have to download .jar from upstream.
>
> I find it tedious to add "flatpak-spawn ..." to every tool used by
> Emacs. Who is the publisher of the flatpak? I would expect a directory
> with symlinks named ditaa, java, git, gcc, cpp, etc to a script line
>
> #!/bin/sh
> exec flatpak-spawn --host toolbox run /usr/bin/env "$0" "$@"
>
> (or "$(basename "$0")")
>
> mounted to flatpak runtime and added to $PATH. Perhaps another
> approach exist and it should be discussed with the packager and Emacs
> developers.
Florin,
Max is right, there are work-arounds possible, although a bit different
from what he suggests. The attached org file shows how to do what you
want using the existing ob-ditaa.el code. I have also attached the
exported html document with the image created.
Tell us if it works for the version of Org that you are using.
Leo
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-doc-ditaa-script.org --]
[-- Type: text/x-org; name="ob-doc-ditaa-script.org", Size: 1974 bytes --]
#+author: Leo Butler
#+title: Executing ditaa from a script
* Executing =ditaa= from a script
Org assumes that =ditaa= is run as a java jar file. Users may need to
use a script to run =ditaa=. This example shows how.
First, set ~org-babel-ditaa-java-cmd~ and ~org-ditaa-jar-option~ to
empty strings and ~org-ditaa-jar-path~ to the script's path; here, it
is =/usr/bin/ditaa=. This example uses ~setq-local~ to change only
the values in this buffer.
#+name: hello-world-from-script.el.org
#+begin_src org :exports code :results replace
,#+name: hello-world-from-script.el
,#+begin_src emacs-lisp :exports none :results none
(setq-local org-babel-ditaa-java-cmd ""
org-ditaa-jar-option ""
org-ditaa-jar-path "/usr/bin/ditaa")
,#+end_src
#+end_src
#+RESULTS: hello-world-from-script.el.org
#+name: hello-world-from-script.el
#+begin_src emacs-lisp :exports none :results none
(setq-local org-babel-ditaa-java-cmd ""
org-ditaa-jar-option ""
org-ditaa-jar-path "/usr/bin/ditaa")
#+end_src
Second, in the =ditaa= code-block, set the header argument =:java= to
the empty string =""=. The =:cmdline= header argument can be used to
pass command-line options to =ditaa= via the script.
#+name: hello-world-from-script.org
#+begin_src org :exports code :results replace
,#+name: hello-world-from-script
,#+begin_src ditaa :file images/hello-world-from-script.png :java "" :cmdline -r -e UTF-8
+----------------+
| |
| Hello World |
| from a script! |
| |
+----------------+
,#+end_src
#+end_src
#+RESULTS: hello-world-from-script.org
#+name: hello-world-from-script
#+begin_src ditaa :file images/hello-world-from-script.png :java "" :cmdline -r -e UTF-8
+----------------+
| |
| Hello World |
| from a script! |
| |
+----------------+
#+end_src
#+RESULTS: hello-world-from-script
[[file:images/hello-world-from-script.png]]
[-- Attachment #3: ob-doc-ditaa-script.html --]
[-- Type: text/html, Size: 11078 bytes --]
[-- Attachment #4: hello-world-from-script.png --]
[-- Type: image/png, Size: 3314 bytes --]
next prev parent reply other threads:[~2023-10-26 15:33 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-19 10:59 org-ditaa woes Florin Boariu
2023-10-20 17:22 ` Leo Butler
2023-10-20 18:16 ` Dr. Arne Babenhauserheide
2023-10-20 19:31 ` Leo Butler
2023-10-20 21:39 ` Florin Boariu
2023-10-21 3:50 ` Max Nikulin
2023-10-23 11:18 ` Florin Boariu
2023-10-24 7:55 ` Max Nikulin
2023-10-24 9:31 ` Florin Boariu
2023-10-24 9:38 ` Ihor Radchenko
2023-10-25 19:00 ` Leo Butler
2023-10-26 8:44 ` Max Nikulin
2023-10-26 9:30 ` Ihor Radchenko
2023-12-20 18:03 ` Leo Butler
2023-12-21 14:15 ` Ihor Radchenko
2023-10-26 15:32 ` Leo Butler [this message]
2023-10-23 12:25 ` Florin Boariu
2023-10-21 7:44 ` Dr. Arne Babenhauserheide
2023-10-21 8:56 ` [TASK] Allow customizeable ditaa executable in ob-ditaa.el (was: org-ditaa woes) Ihor Radchenko
2023-11-09 3:17 ` [TASK] Allow customizeable ditaa executable in ob-ditaa.el Leo Butler
2023-11-09 12:17 ` Max Nikulin
2023-11-10 3:19 ` Leo Butler
2023-11-10 10:09 ` Ihor Radchenko
2023-11-10 10:38 ` Max Nikulin
2023-11-10 15:21 ` Leo Butler
2023-11-11 10:07 ` Ihor Radchenko
2023-11-10 10:18 ` Ihor Radchenko
2023-11-10 14:59 ` Leo Butler
2023-11-11 10:24 ` Ihor Radchenko
2023-11-13 16:26 ` Leo Butler
2023-11-15 11:12 ` Formatting worg code examples (was: Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el) Max Nikulin
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=87bkcljt68.fsf@t14.reltub.ca \
--to=leo.butler@umanitoba.ca \
--cc=emacs-orgmode@gnu.org \
--cc=florin.om@rootshell.ro \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).