From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cecil Westerhof Subject: Re: English and Dutch version of a Graphviz picture Date: Sun, 2 Sep 2018 15:27:29 +0200 Message-ID: References: <20180901170406.6f7f6a7d@happy.intern.roklein.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f832d20574e36227" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwTY8-00088S-AB for emacs-orgmode@gnu.org; Sun, 02 Sep 2018 10:40:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwTVQ-0004xg-6k for emacs-orgmode@gnu.org; Sun, 02 Sep 2018 10:37:37 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:36025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwTVQ-0004xO-0H for emacs-orgmode@gnu.org; Sun, 02 Sep 2018 10:37:36 -0400 Received: by mail-oi0-x242.google.com with SMTP id r69-v6so29535848oie.3 for ; Sun, 02 Sep 2018 07:37:35 -0700 (PDT) In-Reply-To: <20180901170406.6f7f6a7d@happy.intern.roklein.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --000000000000f832d20574e36227 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2018-09-01 17:04 GMT+02:00 Robert Klein : > On Sat, 1 Sep 2018 12:38:54 +0200 > Cecil Westerhof wrote: > > > I have the following: > > #+BEGIN_SRC dot :file Graphviz/habitLoop.png :cmdline -Kfdp -Tpng > > digraph habitLoop { > > bgcolor =3D steelblue > > edge [penwidth =3D 4.0 ] > > node [fontcolor =3D white, fontsize =3D 60, style =3D filled] > > > > spur [pos =3D "4,4!" color =3D red] > > habit [pos =3D "7,1!" color =3D darkgreen] > > reward [pos =3D "1,1!" color =3D blue] > > > > spur:e -> habit:n > > habit:w -> reward:e > > reward:n -> spur:w > > > > copyright [ > > pos =3D "4,.75!" > > color =3D steelblue, > > fontcolor =3D black, > > fontsize =3D 14, > > label =3D "=C2=A9 Cecil > > Westerhof\nTimeManagement@Decebal.nl", shape =3D plaintext > > ] > > > > spur [label =3D "Spur"] > > habit [label =3D "Habit"] > > reward [label =3D "Reward"] > > } > > #+END_SRC > > > > But I also want to have a Dutch version. So I also have: > > #+BEGIN_SRC dot :file Graphviz/gewoonteLoop.png :cmdline -Kfdp -Tpng > > digraph habitLoop { > > bgcolor =3D steelblue > > edge [penwidth =3D 4.0 ] > > node [fontcolor =3D white, fontsize =3D 60, style =3D filled] > > > > spur [pos =3D "4,4!" color =3D red] > > habit [pos =3D "7,1!" color =3D darkgreen] > > reward [pos =3D "1,1!" color =3D blue] > > > > spur:e -> habit:n > > habit:w -> reward:e > > reward:n -> spur:w > > > > copyright [ > > pos =3D "4,.75!" > > color =3D steelblue, > > fontcolor =3D black, > > fontsize =3D 14, > > label =3D "=C2=A9 Cecil > > Westerhof\nTimeManagement@Decebal.nl", shape =3D plaintext > > ] > > > > spur [label =3D "Prikkel"] > > habit [label =3D "Gewoonte"] > > reward [label =3D "Beloning"] > > } > > #+END_SRC > > > > The only difference are the three label statements. Can this be done > > more efficient? Because now I need to do updates at two places. That > > is an accident waiting to happen. > > > > > There's a complicated solution (like, using variables from tables) at > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-dot.html > > In your case you might want to use noweb (see > https://orgmode.org/org.html#Noweb-reference-syntax). Then your code > might look like this: > > #+Name: habitloop-main > #+BEGIN_SRC dot > bgcolor =3D steelblue > edge [penwidth =3D 4.0 ] > node [fontcolor =3D white, fontsize =3D 60, style =3D filled] > > spur [pos =3D "4,4!" color =3D red] > habit [pos =3D "7,1!" color =3D darkgreen] > reward [pos =3D "1,1!" color =3D blue] > > spur:e -> habit:n > habit:w -> reward:e > reward:n -> spur:w > > copyright [ > pos =3D "4,.75!" > color =3D steelblue, > fontcolor =3D black, > fontsize =3D 14, > label =3D "=C2=A9 Cecil > Westerhof\nTimeManagement@Decebal.nl", > shape =3D plaintext > ] > #+END_SRC > > > #+BEGIN_SRC dot :file gewoonteLoop.png :cmdline -Kfdp -Tpng :noweb yes > digraph habitLoop { > <> > spur [label =3D "Prikkel"] > habit [label =3D "Gewoonte"] > reward [label =3D "Beloning"] > } > #+END_SRC > > #+RESULTS: > [[file:gewoonteLoop.png]] > > #+BEGIN_SRC dot :file habitLoop.png :cmdline -Kfdp -Tpng :noweb yes > digraph habitLoop { > <> > spur [label =3D "Spur"] > habit [label =3D "Habit"] > reward [label =3D "Reward"] > } > #+END_SRC > I tried this, but I did not get it to work. Maybe something in my configuration is wrecking havoc on me. I have to play with it a bit more I am afraid. > Note, for better looks I put the whole surrounding block in the > language-specific parts (the =E2=80=9Cdigraph=E2=80=9D-line could be in t= he > =E2=80=9Chabitloop-main=E2=80=9D block, too). > > > When your code gets more involved this can get ugly, fast. Then you'll > probably have to go the elisp way. > For the moment I do not think it will get more involved very soon, but you never know. Maybe the elisp route is not a bad idea. --=20 Cecil Westerhof --000000000000f832d20574e36227 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
2018-09-01 17:04 GMT+02:00 Robert Klein <ro= klein@roklein.de>:
On Sat, 1 Sep 2018 12:38:54 +0200
Cecil Westerhof <cldwesterhof@= gmail.com> wrote:

> I have the following:
> #+BEGIN_SRC dot :file Graphviz/habitLoop.png :cmdline -Kfdp -Tpng
> digraph habitLoop {
>=C2=A0 =C2=A0 =C2=A0bgcolor =3D steelblue
>=C2=A0 =C2=A0 =C2=A0edge [penwidth =3D 4.0 ]
>=C2=A0 =C2=A0 =C2=A0node [fontcolor =3D white, fontsize =3D 60, style = =3D filled]
>
>=C2=A0 =C2=A0 =C2=A0spur=C2=A0 =C2=A0[pos =3D "4,4!" color = =3D red]
>=C2=A0 =C2=A0 =C2=A0habit=C2=A0 [pos =3D "7,1!" color =3D dar= kgreen]
>=C2=A0 =C2=A0 =C2=A0reward [pos =3D "1,1!" color =3D blue] >
>=C2=A0 =C2=A0 =C2=A0spur:e=C2=A0 =C2=A0-> habit:n
>=C2=A0 =C2=A0 =C2=A0habit:w=C2=A0 -> reward:e
>=C2=A0 =C2=A0 =C2=A0reward:n -> spur:w
>
>=C2=A0 =C2=A0 =C2=A0copyright [
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pos=C2=A0= =C2=A0 =C2=A0 =C2=A0=3D "4,.75!"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0color=C2= =A0 =C2=A0 =C2=A0=3D steelblue,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fontcolor= =3D black,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fontsize= =C2=A0 =3D 14,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0label=C2= =A0 =C2=A0 =C2=A0=3D "=C2=A9 Cecil
> Westerhof\nTimeManagement@Decebal.nl", shape=C2=A0 =C2=A0 = =C2=A0=3D plaintext
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0]
>
>=C2=A0 =C2=A0 =C2=A0spur=C2=A0 =C2=A0[label =3D "Spur"]
>=C2=A0 =C2=A0 =C2=A0habit=C2=A0 [label =3D "Habit"]
>=C2=A0 =C2=A0 =C2=A0reward [label =3D "Reward"]
> }
> #+END_SRC
>
> But I also want to have a Dutch version. So I also have:
> #+BEGIN_SRC dot :file Graphviz/gewoonteLoop.png :cmdline -Kfdp -Tpng > digraph habitLoop {
>=C2=A0 =C2=A0 =C2=A0bgcolor =3D steelblue
>=C2=A0 =C2=A0 =C2=A0edge [penwidth =3D 4.0 ]
>=C2=A0 =C2=A0 =C2=A0node [fontcolor =3D white, fontsize =3D 60, style = =3D filled]
>
>=C2=A0 =C2=A0 =C2=A0spur=C2=A0 =C2=A0[pos =3D "4,4!" color = =3D red]
>=C2=A0 =C2=A0 =C2=A0habit=C2=A0 [pos =3D "7,1!" color =3D dar= kgreen]
>=C2=A0 =C2=A0 =C2=A0reward [pos =3D "1,1!" color =3D blue] >
>=C2=A0 =C2=A0 =C2=A0spur:e=C2=A0 =C2=A0-> habit:n
>=C2=A0 =C2=A0 =C2=A0habit:w=C2=A0 -> reward:e
>=C2=A0 =C2=A0 =C2=A0reward:n -> spur:w
>
>=C2=A0 =C2=A0 =C2=A0copyright [
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pos=C2=A0= =C2=A0 =C2=A0 =C2=A0=3D "4,.75!"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0color=C2= =A0 =C2=A0 =C2=A0=3D steelblue,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fontcolor= =3D black,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fontsize= =C2=A0 =3D 14,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0label=C2= =A0 =C2=A0 =C2=A0=3D "=C2=A9 Cecil
> Westerhof\nTimeManagement@Decebal.nl", shape=C2=A0 =C2=A0 = =C2=A0=3D plaintext
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0]
>
>=C2=A0 =C2=A0 =C2=A0spur=C2=A0 =C2=A0[label =3D "Prikkel"] >=C2=A0 =C2=A0 =C2=A0habit=C2=A0 [label =3D "Gewoonte"]
>=C2=A0 =C2=A0 =C2=A0reward [label =3D "Beloning"]
> }
> #+END_SRC
>
> The only difference are the three label statements. Can this be done > more efficient? Because now I need to do updates at two places. That > is an accident waiting to happen.
>


There's a complicated solution (like, using variables from = tables) at
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-dot.html

In your case you might want to use noweb (see
https://orgmode.org/org.html#Noweb-reference= -syntax).=C2=A0 Then your code
might look like this:

#+Name: habitloop-main
#+BEGIN_SRC dot
=C2=A0 =C2=A0 bgcolor =3D steelblue
=C2=A0 =C2=A0 edge [penwidth =3D 4.0 ]
=C2=A0 =C2=A0 node [fontcolor =3D white, fontsize =3D 60, style =3D filled]=

=C2=A0 =C2=A0 spur=C2=A0 =C2=A0[pos =3D "4,4!" color =3D red]
=C2=A0 =C2=A0 habit=C2=A0 [pos =3D "7,1!" color =3D darkgreen] =C2=A0 =C2=A0 reward [pos =3D "1,1!" color =3D blue]

=C2=A0 =C2=A0 spur:e=C2=A0 =C2=A0-> habit:n
=C2=A0 =C2=A0 habit:w=C2=A0 -> reward:e
=C2=A0 =C2=A0 reward:n -> spur:w

=C2=A0 =C2=A0 copyright [
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pos=C2=A0 =C2=A0 = =C2=A0 =C2=A0=3D "4,.75!"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 color=C2=A0 =C2=A0 = =C2=A0=3D steelblue,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fontcolor =3D black= ,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fontsize=C2=A0 =3D = 14,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 label=C2=A0 =C2=A0 = =C2=A0=3D "=C2=A9 Cecil
=C2=A0 =C2=A0 Westerhof\nTimeManagement@Decebal.nl",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 shape=C2=A0 =C2=A0 = =C2=A0=3D plaintext
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ]
#+END_SRC


#+BEGIN_SRC dot :file gewoonteLoop.png :cmdline -Kfdp -Tpng :noweb yes
digraph habitLoop {
=C2=A0 =C2=A0 <<main-loop>>
=C2=A0 =C2=A0 spur=C2=A0 =C2=A0[label =3D "Prik= kel"]
=C2=A0 =C2=A0 habit=C2=A0 [label =3D "Gewoonte"]
=C2=A0 =C2=A0 reward [label =3D "Beloning"]
}
#+END_SRC

#+RESULTS:
[[file:gewoonteLoop.png]]

#+BEGIN_SRC dot :file habitLoop.png :cmdline -Kfdp -Tpng :noweb yes
digraph habitLoop {
=C2=A0 =C2=A0 <<main-loop>>
=C2=A0 =C2=A0 spur=C2=A0 =C2=A0[label =3D "Spur= "]
=C2=A0 =C2=A0 habit=C2=A0 [label =3D "Habit"]
=C2=A0 =C2=A0 reward [label =3D "Reward"]
}
#+END_SRC
=C2=A0
I tried this, but I did n= ot get it to work. Maybe something in my configuration is wrecking havoc on= me. I have to play with it a bit more I am afraid.

=C2= =A0
Note, for better looks I put the whole surrounding block in the
language-specific parts (the =E2=80=9Cdigraph=E2=80=9D-line could be in the=
=E2=80=9Chabitloop-main=E2=80=9D block, too).


When your code gets more involved this can get ugly, fast.=C2=A0 Then you&#= 39;ll
probably have to go the elisp way.

For the moment I do not think it will get more involved very soon, but = you never know. Maybe the elisp route is not a bad idea.

--
Cecil Westerhof
--000000000000f832d20574e36227--