emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* English and Dutch version of a Graphviz picture
@ 2018-09-01 10:38 Cecil Westerhof
  2018-09-01 15:04 ` Robert Klein
  0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2018-09-01 10:38 UTC (permalink / raw)
  To: emacs-orgmode

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

I have the following:
#+BEGIN_SRC dot :file Graphviz/habitLoop.png :cmdline -Kfdp -Tpng
digraph habitLoop {
    bgcolor = steelblue
    edge [penwidth = 4.0 ]
    node [fontcolor = white, fontsize = 60, style = filled]

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

    spur:e   -> habit:n
    habit:w  -> reward:e
    reward:n -> spur:w

    copyright [
                pos       = "4,.75!"
                color     = steelblue,
                fontcolor = black,
                fontsize  = 14,
                label     = "© Cecil Westerhof\nTimeManagement@Decebal.nl",
                shape     = plaintext
              ]

    spur   [label = "Spur"]
    habit  [label = "Habit"]
    reward [label = "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 = steelblue
    edge [penwidth = 4.0 ]
    node [fontcolor = white, fontsize = 60, style = filled]

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

    spur:e   -> habit:n
    habit:w  -> reward:e
    reward:n -> spur:w

    copyright [
                pos       = "4,.75!"
                color     = steelblue,
                fontcolor = black,
                fontsize  = 14,
                label     = "© Cecil Westerhof\nTimeManagement@Decebal.nl",
                shape     = plaintext
              ]

    spur   [label = "Prikkel"]
    habit  [label = "Gewoonte"]
    reward [label = "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.

-- 
Cecil Westerhof

[-- Attachment #2: Type: text/html, Size: 2908 bytes --]

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

* Re: English and Dutch version of a Graphviz picture
  2018-09-01 10:38 English and Dutch version of a Graphviz picture Cecil Westerhof
@ 2018-09-01 15:04 ` Robert Klein
  2018-09-02 13:27   ` Cecil Westerhof
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Klein @ 2018-09-01 15:04 UTC (permalink / raw)
  To: emacs-orgmode

Hi Cecil,

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 {
>     bgcolor = steelblue
>     edge [penwidth = 4.0 ]
>     node [fontcolor = white, fontsize = 60, style = filled]
> 
>     spur   [pos = "4,4!" color = red]
>     habit  [pos = "7,1!" color = darkgreen]
>     reward [pos = "1,1!" color = blue]
> 
>     spur:e   -> habit:n
>     habit:w  -> reward:e
>     reward:n -> spur:w
> 
>     copyright [
>                 pos       = "4,.75!"
>                 color     = steelblue,
>                 fontcolor = black,
>                 fontsize  = 14,
>                 label     = "© Cecil
> Westerhof\nTimeManagement@Decebal.nl", shape     = plaintext
>               ]
> 
>     spur   [label = "Spur"]
>     habit  [label = "Habit"]
>     reward [label = "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 = steelblue
>     edge [penwidth = 4.0 ]
>     node [fontcolor = white, fontsize = 60, style = filled]
> 
>     spur   [pos = "4,4!" color = red]
>     habit  [pos = "7,1!" color = darkgreen]
>     reward [pos = "1,1!" color = blue]
> 
>     spur:e   -> habit:n
>     habit:w  -> reward:e
>     reward:n -> spur:w
> 
>     copyright [
>                 pos       = "4,.75!"
>                 color     = steelblue,
>                 fontcolor = black,
>                 fontsize  = 14,
>                 label     = "© Cecil
> Westerhof\nTimeManagement@Decebal.nl", shape     = plaintext
>               ]
> 
>     spur   [label = "Prikkel"]
>     habit  [label = "Gewoonte"]
>     reward [label = "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 = steelblue
    edge [penwidth = 4.0 ]
    node [fontcolor = white, fontsize = 60, style = filled]

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

    spur:e   -> habit:n
    habit:w  -> reward:e
    reward:n -> spur:w

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


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

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

#+BEGIN_SRC dot :file habitLoop.png :cmdline -Kfdp -Tpng :noweb yes
digraph habitLoop {
    <<main-loop>>
    spur   [label = "Spur"]
    habit  [label = "Habit"]
    reward [label = "Reward"]
}
#+END_SRC


Note, for better looks I put the whole surrounding block in the
language-specific parts (the “digraph”-line could be in the
“habitloop-main” 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

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

* Re: English and Dutch version of a Graphviz picture
  2018-09-01 15:04 ` Robert Klein
@ 2018-09-02 13:27   ` Cecil Westerhof
  2018-09-05  7:00     ` Robert Klein
  0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2018-09-02 13:27 UTC (permalink / raw)
  To: emacs-orgmode

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

2018-09-01 17:04 GMT+02:00 Robert Klein <roklein@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 {
> >     bgcolor = steelblue
> >     edge [penwidth = 4.0 ]
> >     node [fontcolor = white, fontsize = 60, style = filled]
> >
> >     spur   [pos = "4,4!" color = red]
> >     habit  [pos = "7,1!" color = darkgreen]
> >     reward [pos = "1,1!" color = blue]
> >
> >     spur:e   -> habit:n
> >     habit:w  -> reward:e
> >     reward:n -> spur:w
> >
> >     copyright [
> >                 pos       = "4,.75!"
> >                 color     = steelblue,
> >                 fontcolor = black,
> >                 fontsize  = 14,
> >                 label     = "© Cecil
> > Westerhof\nTimeManagement@Decebal.nl", shape     = plaintext
> >               ]
> >
> >     spur   [label = "Spur"]
> >     habit  [label = "Habit"]
> >     reward [label = "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 = steelblue
> >     edge [penwidth = 4.0 ]
> >     node [fontcolor = white, fontsize = 60, style = filled]
> >
> >     spur   [pos = "4,4!" color = red]
> >     habit  [pos = "7,1!" color = darkgreen]
> >     reward [pos = "1,1!" color = blue]
> >
> >     spur:e   -> habit:n
> >     habit:w  -> reward:e
> >     reward:n -> spur:w
> >
> >     copyright [
> >                 pos       = "4,.75!"
> >                 color     = steelblue,
> >                 fontcolor = black,
> >                 fontsize  = 14,
> >                 label     = "© Cecil
> > Westerhof\nTimeManagement@Decebal.nl", shape     = plaintext
> >               ]
> >
> >     spur   [label = "Prikkel"]
> >     habit  [label = "Gewoonte"]
> >     reward [label = "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 = steelblue
>     edge [penwidth = 4.0 ]
>     node [fontcolor = white, fontsize = 60, style = filled]
>
>     spur   [pos = "4,4!" color = red]
>     habit  [pos = "7,1!" color = darkgreen]
>     reward [pos = "1,1!" color = blue]
>
>     spur:e   -> habit:n
>     habit:w  -> reward:e
>     reward:n -> spur:w
>
>     copyright [
>                 pos       = "4,.75!"
>                 color     = steelblue,
>                 fontcolor = black,
>                 fontsize  = 14,
>                 label     = "© Cecil
>     Westerhof\nTimeManagement@Decebal.nl",
>                 shape     = plaintext
>               ]
> #+END_SRC
>
>
> #+BEGIN_SRC dot :file gewoonteLoop.png :cmdline -Kfdp -Tpng :noweb yes
> digraph habitLoop {
>     <<main-loop>>
>     spur   [label = "Prikkel"]
>     habit  [label = "Gewoonte"]
>     reward [label = "Beloning"]
> }
> #+END_SRC
>
> #+RESULTS:
> [[file:gewoonteLoop.png]]
>
> #+BEGIN_SRC dot :file habitLoop.png :cmdline -Kfdp -Tpng :noweb yes
> digraph habitLoop {
>     <<main-loop>>
>     spur   [label = "Spur"]
>     habit  [label = "Habit"]
>     reward [label = "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 “digraph”-line could be in the
> “habitloop-main” 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.

-- 
Cecil Westerhof

[-- Attachment #2: Type: text/html, Size: 6749 bytes --]

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

* Re: English and Dutch version of a Graphviz picture
  2018-09-02 13:27   ` Cecil Westerhof
@ 2018-09-05  7:00     ` Robert Klein
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Klein @ 2018-09-05  7:00 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: emacs-orgmode

Hi Cecil,

On Sun, 2 Sep 2018 15:27:29 +0200
Cecil Westerhof <cldwesterhof@gmail.com> wrote:

> 2018-09-01 17:04 GMT+02:00 Robert Klein <roklein@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 {
> > >     bgcolor = steelblue
> > >     edge [penwidth = 4.0 ]
> > >     node [fontcolor = white, fontsize = 60, style = filled]
> > >
> > >     spur   [pos = "4,4!" color = red]
> > >     habit  [pos = "7,1!" color = darkgreen]
> > >     reward [pos = "1,1!" color = blue]
> > >
> > >     spur:e   -> habit:n
> > >     habit:w  -> reward:e
> > >     reward:n -> spur:w
> > >
> > >     copyright [
> > >                 pos       = "4,.75!"
> > >                 color     = steelblue,
> > >                 fontcolor = black,
> > >                 fontsize  = 14,
> > >                 label     = "© Cecil
> > > Westerhof\nTimeManagement@Decebal.nl", shape     = plaintext
> > >               ]
> > >
> > >     spur   [label = "Spur"]
> > >     habit  [label = "Habit"]
> > >     reward [label = "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 = steelblue
> > >     edge [penwidth = 4.0 ]
> > >     node [fontcolor = white, fontsize = 60, style = filled]
> > >
> > >     spur   [pos = "4,4!" color = red]
> > >     habit  [pos = "7,1!" color = darkgreen]
> > >     reward [pos = "1,1!" color = blue]
> > >
> > >     spur:e   -> habit:n
> > >     habit:w  -> reward:e
> > >     reward:n -> spur:w
> > >
> > >     copyright [
> > >                 pos       = "4,.75!"
> > >                 color     = steelblue,
> > >                 fontcolor = black,
> > >                 fontsize  = 14,
> > >                 label     = "© Cecil
> > > Westerhof\nTimeManagement@Decebal.nl", shape     = plaintext
> > >               ]
> > >
> > >     spur   [label = "Prikkel"]
> > >     habit  [label = "Gewoonte"]
> > >     reward [label = "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 = steelblue
> >     edge [penwidth = 4.0 ]
> >     node [fontcolor = white, fontsize = 60, style = filled]
> >
> >     spur   [pos = "4,4!" color = red]
> >     habit  [pos = "7,1!" color = darkgreen]
> >     reward [pos = "1,1!" color = blue]
> >
> >     spur:e   -> habit:n
> >     habit:w  -> reward:e
> >     reward:n -> spur:w
> >
> >     copyright [
> >                 pos       = "4,.75!"
> >                 color     = steelblue,
> >                 fontcolor = black,
> >                 fontsize  = 14,
> >                 label     = "© Cecil
> >     Westerhof\nTimeManagement@Decebal.nl",
> >                 shape     = plaintext
> >               ]
> > #+END_SRC
> >
> >
> > #+BEGIN_SRC dot :file gewoonteLoop.png :cmdline -Kfdp -Tpng :noweb
> > yes digraph habitLoop {
> >     <<main-loop>>
> >     spur   [label = "Prikkel"]
> >     habit  [label = "Gewoonte"]
> >     reward [label = "Beloning"]
> > }
> > #+END_SRC
> >
> > #+RESULTS:
> > [[file:gewoonteLoop.png]]
> >
> > #+BEGIN_SRC dot :file habitLoop.png :cmdline -Kfdp -Tpng :noweb yes
> > digraph habitLoop {
> >     <<main-loop>>
> >     spur   [label = "Spur"]
> >     habit  [label = "Habit"]
> >     reward [label = "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.

Did you C-c C-c on the two smaller snippets (not on the main-loop part)?


Best regards
Robert



> 
> > Note, for better looks I put the whole surrounding block in the
> > language-specific parts (the “digraph”-line could be in the
> > “habitloop-main” 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.
> 

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

end of thread, other threads:[~2018-09-05  7:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-01 10:38 English and Dutch version of a Graphviz picture Cecil Westerhof
2018-09-01 15:04 ` Robert Klein
2018-09-02 13:27   ` Cecil Westerhof
2018-09-05  7:00     ` Robert Klein

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