From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Klein Subject: Re: English and Dutch version of a Graphviz picture Date: Sat, 1 Sep 2018 17:04:06 +0200 Message-ID: <20180901170406.6f7f6a7d@happy.intern.roklein.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fw7Rm-0005xZ-78 for emacs-orgmode@gnu.org; Sat, 01 Sep 2018 11:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fw7Ri-0007U5-PH for emacs-orgmode@gnu.org; Sat, 01 Sep 2018 11:04:22 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:44789) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fw7Ri-0007Tb-E7 for emacs-orgmode@gnu.org; Sat, 01 Sep 2018 11:04:18 -0400 Received: from happy.intern.roklein.de ([91.67.155.33]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MOXED-1g1urt3Kej-005mCL for ; Sat, 01 Sep 2018 17:04:16 +0200 In-Reply-To: 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 Hi Cecil, 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] >=20 > spur [pos =3D "4,4!" color =3D red] > habit [pos =3D "7,1!" color =3D darkgreen] > reward [pos =3D "1,1!" color =3D blue] >=20 > spur:e -> habit:n > habit:w -> reward:e > reward:n -> spur:w >=20 > 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 > ] >=20 > spur [label =3D "Spur"] > habit [label =3D "Habit"] > reward [label =3D "Reward"] > } > #+END_SRC >=20 > 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] >=20 > spur [pos =3D "4,4!" color =3D red] > habit [pos =3D "7,1!" color =3D darkgreen] > reward [pos =3D "1,1!" color =3D blue] >=20 > spur:e -> habit:n > habit:w -> reward:e > reward:n -> spur:w >=20 > 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 > ] >=20 > spur [label =3D "Prikkel"] > habit [label =3D "Gewoonte"] > reward [label =3D "Beloning"] > } > #+END_SRC >=20 > 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. >=20 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 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. Then you'll probably have to go the elisp way. Best regards Robert