emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: "Dr. Arne Babenhauserheide" <arne_bab@web.de>,
	Florin Boariu <florin.om@rootshell.ro>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el
Date: Thu, 9 Nov 2023 03:17:07 +0000	[thread overview]
Message-ID: <87sf5f7h04.fsf@t14.reltub.ca> (raw)
In-Reply-To: <87y1fwtkth.fsf@localhost> (Ihor Radchenko's message of "Sat, 21 Oct 2023 08:56:58 +0000")

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

On Sat, Oct 21 2023, Ihor Radchenko <yantar92@posteo.net> wrote:

> "Dr. Arne Babenhauserheide" <arne_bab@web.de> writes:
>
>>>> In my current source I see [...]
>>>>
>>>> (use C-h v org-babel-ditaa-java-cmd to see the value of the java
>>>> executable — you can then customize this to use a different command)
>>>
>>> As far as I understand that part of code it still kind-of assumes that
>>> I'm using a command line of type "java -jar ditaa.jar ...", just with
>>> more flexibility in choosing which "java" command I'm using, right?
>>
>> Yes, it does. ob-plantuml already migrated to allow a regular command,
>> but ob-ditaa still only enables using the jar directly.
>>
>> That is something which would be nice to fix — and ob-plantuml should
>> show the path forward.
>
> +1
> This is a relatively simple task.
> One can indeed use ob-plantuml as a reference to extend ob-ditaa.
> Patches welcome!

While I was reviewing the documentation, ob-doc-ditaa.org, and the
source, ob-ditaa.el, I realized that there is a simple way to run a
script file instead of a jar file. The documentation patch includes such
an example.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-contrib-babel-languages-ob-doc-ditaa.org-update-.patch --]
[-- Type: text/x-diff; name="0001-org-contrib-babel-languages-ob-doc-ditaa.org-update-.patch", Size: 10308 bytes --]

From 6424527dde6e487ce55dddae1260df3d84c2775e Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Thu, 26 Oct 2023 20:49:41 -0500
Subject: [PATCH] * org-contrib/babel/languages/ob-doc-ditaa.org: update
 documentation

* org-contrib/babel/languages/ob-doc-ditaa.org: Add a subsection that
documents the four DEFCUSTOM variables.  Modify the existing examples
so that the org code that is exported also creates the code-blocks
that are executed.  Add a subsection that documents how to use those
customization variables in order to run ditaa from a script, not
necessarily as a jar file.

* org-contrib/babel/languages/images/hello-world-from-script.png:
This is a new file created by the new example.

Ref: https://list.orgmode.org/ZTEML8zWrB6kQflk@toolbox/T/
---
 .../images/hello-world-from-script.png        | Bin 0 -> 3314 bytes
 org-contrib/babel/languages/ob-doc-ditaa.org  |  86 ++++++++++++++++--
 2 files changed, 77 insertions(+), 9 deletions(-)
 create mode 100644 org-contrib/babel/languages/images/hello-world-from-script.png

diff --git a/org-contrib/babel/languages/images/hello-world-from-script.png b/org-contrib/babel/languages/images/hello-world-from-script.png
new file mode 100644
index 0000000000000000000000000000000000000000..8a039e1bad997ebd31d8906cc1d1f234e9159e09
GIT binary patch
literal 3314
zcmchacQjn<8pcV8kQk!(8ex<mPL7sfbTgui5)m0e)M%q-Bzo^9Lq-dR5zz@5(FNfQ
zu5Ltv7$o5k!5C$fyR+`O>#lXzy7#|(_gZ`J_5HEm_xslOd!FyviDo7S%uIYtG&D5K
zMuxg@;Qbl6Q!btZo|w00qBJy@-x=vbET14Y3*C)5iNbLVb~e)IxEefsds>|opv_k9
zPE8Q{37)&3Qy<^oFLUp*Bu9@QK)ld=%yQFiy31UTQ#eu$Q!31msn~>zST1r@!fNBf
zS-z@s3&>ZV?cgZ}RmAdjI9I7l>BXY|Xo3G0go9r+tK_@P#ltZ(sF+|g+?ss{Qi9f1
zlaj~;L5<3y;cRQg|BqoQJ+2+OtZ!*)iT9r8a16+BUg6^<!p5%JLJ3N)e>*rj@}6(K
zDI)_*Hcnw`OtBMR9!L{>N~P3Hd(>1^R8&?@JRVnRsviO4`W?6T_f3tBrySXoB2u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>S>FPclv`iS^rcgkPjE9HcikzIBHZ@rYqoeVRA*u!Aa5!n+
z!qO6*pZ^rFCp4Pl^XfKmSOF#i{weCHn{jW2`<{MnCUQmaWBhpqh<v;fkU<FqXv!yG
zhcQ-PP8HhiTYPEX4AW)5>9a{_66+eg;g^~szBQ;J5b;+B>#FG0d}SYBS5;M2US3{h
zpM_%}eOOpn)Ljve8vfT8VeD~#taD{IR#sM4S67#n(Iszl%Ok$%ziDi|VI{=oBs!6F
zEH*TF^F~^`IMr9HPEXto0<N->mywpPww8%Qw)-gbc5ily>C@%vg=PNA%mxejE{_6X
qFe5|u|7~zz&&*;q`m06S8LeG+hGOd>J{tI!p)t}k(XG{f81;7r&UPvQ

literal 0
HcmV?d00001

diff --git a/org-contrib/babel/languages/ob-doc-ditaa.org b/org-contrib/babel/languages/ob-doc-ditaa.org
index 0ae949c2..66f7d4ad 100644
--- a/org-contrib/babel/languages/ob-doc-ditaa.org
+++ b/org-contrib/babel/languages/ob-doc-ditaa.org
@@ -57,6 +57,14 @@ Activate evaluation of =ditaa= source code blocks by adding =ditaa= to
      '((ditaa . t))) ; this line activates ditaa
 #+END_SRC
 
+** Customization Options
+Org needs to know a few things about =ditaa= and the =java= executable in order to function. The following is a list of variables that can be customized.
+
+- org-ditaa-jar-path :: The path to the =ditaa= jar file.
+- org-babel-ditaa-java-cmd :: The name or path to the Java executable used to run the =ditaa= jar file.
+- org-ditaa-eps-jar-path :: The path to the =ditaaeps= jar file. [[https://ditaa-addons.sourceforge.net/][DitaaEps]] is maintained as part of the [[https://ditaa-addons.sourceforge.net/][ditaa-addons]] project.
+- org-ditaa-jar-option :: The prefix used before the =ditaa= jar path. The default is =-jar=.
+
 * Babel Features for ditaa Code Blocks
 ** Header Arguments
    - file :: =ditaa= source code blocks require that an output file be specified
@@ -67,8 +75,13 @@ Activate evaluation of =ditaa= source code blocks by adding =ditaa= to
 ** Result Types
 =Ditaa= source code blocks return a link to a [[http://www.libpng.org/pub/png/][png]] bitmap file.
 * Examples of Use
+** Hello World
 The obligatory Hello World! example in =ditaa=:
-#+BEGIN_EXAMPLE
+
+#+NAME: hello-world.org
+#+BEGIN_SRC org :exports code :results replace
+,#+NAME: hello-world
+,#+HEADER: :exports results
 ,#+BEGIN_SRC ditaa :file images/hello-world.png
 +--------------+
 |              |
@@ -76,9 +89,11 @@ The obligatory Hello World! example in =ditaa=:
 |              |
 +--------------+
 ,#+END_SRC
-#+END_EXAMPLE
+#+END_SRC
 
-#+header: :exports results
+#+RESULTS: hello-world.org
+#+NAME: hello-world
+#+HEADER: :exports results
 #+BEGIN_SRC ditaa :file images/hello-world.png
 +--------------+
 |              |
@@ -87,23 +102,29 @@ The obligatory Hello World! example in =ditaa=:
 +--------------+
 #+END_SRC
 
-#+RESULTS:
+#+RESULTS: hello-world
 [[file:images/hello-world.png]]
+** Passing command-line options to =ditaa=
 
 Now, round all corners by passing =ditaa= the =-r,--round-corners=
 command line switch.
 
-#+BEGIN_EXAMPLE
-#+BEGIN_SRC ditaa :file images/hello-world-round.png :cmdline -r
+#+NAME: hello-world-round.org
+#+BEGIN_SRC org :exports code :results replace
+,#+NAME: hello-world-round
+,#+HEADER: :exports results
+,#+BEGIN_SRC ditaa :file images/hello-world-round.png :cmdline -r
 +--------------+
 |              |
 | Hello World! |
 |              |
 +--------------+
+,#+END_SRC
 #+END_SRC
-#+END_EXAMPLE
 
-#+header: :exports results
+#+RESULTS: hello-world-round.org
+#+NAME: hello-world-round
+#+HEADER: :exports results
 #+BEGIN_SRC ditaa :file images/hello-world-round.png :cmdline -r
 +--------------+
 |              |
@@ -112,6 +133,53 @@ command line switch.
 +--------------+
 #+END_SRC
 
-#+RESULTS:
+#+RESULTS: hello-world-round
 [[file:images/hello-world-round.png]]
 
+** 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
+[[file:images/hello-world-from-script.png]]
-- 
2.42.0


  reply	other threads:[~2023-11-09  4:03 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
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         ` Leo Butler [this message]
2023-11-09 12:17           ` [TASK] Allow customizeable ditaa executable in ob-ditaa.el 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=87sf5f7h04.fsf@t14.reltub.ca \
    --to=leo.butler@umanitoba.ca \
    --cc=arne_bab@web.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=florin.om@rootshell.ro \
    --cc=yantar92@posteo.net \
    /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).