emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* process diagrams with dot and some glue using org
@ 2013-07-19 17:23 Eric S Fraga
  2013-07-19 17:37 ` Rick Frankel
  2013-07-21 19:05 ` Karl Voit
  0 siblings, 2 replies; 7+ messages in thread
From: Eric S Fraga @ 2013-07-19 17:23 UTC (permalink / raw)
  To: Karl Voit, emacs-orgmode

Dear Karl,

a couple of weeks ago you developed some code to convert a pair of
tables to a graphviz digraph and you wrote a very useful Worg page about
it:

  http://article.gmane.org/gmane.emacs.orgmode/74280
  http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html

I have today had a real need for this so I copied the code and used
it.  Worked like a charm!  Thanks for doing this.

I just wanted to say two things about it:

1. if the typical use case is to use the code with #+call:, it would be
     more helpful to delete the #+header: line in the source code in the
     Worg page.  This header line presumes that the particular tables in
     your first example exist.  Deleting this line means that the code
     can only be used via a #+call statement but I think this is more
     logical.

2. I appended a column to my node table with a description of each
     node.  You've written your code so that it doesn't care if there
     are extra columns.  This is a bonus!  My table not only provides
     the data for the graph but also explains the graph to a reader.

Thanks again,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.6-341-g338603

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

* Re: process diagrams with dot and some glue using org
  2013-07-19 17:23 process diagrams with dot and some glue using org Eric S Fraga
@ 2013-07-19 17:37 ` Rick Frankel
  2013-07-19 17:56   ` Eric S Fraga
  2013-07-20 11:02   ` Eric S Fraga
  2013-07-21 19:05 ` Karl Voit
  1 sibling, 2 replies; 7+ messages in thread
From: Rick Frankel @ 2013-07-19 17:37 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode

On 2013-07-19 13:23, Eric S Fraga wrote:

> a couple of weeks ago you developed some code to convert a pair of
> tables to a graphviz digraph and you wrote a very useful Worg page 
> about
> it:
> 
> http://article.gmane.org/gmane.emacs.orgmode/74280
> http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html
> 
> I just wanted to say two things about it:
> 
> 1. if the typical use case is to use the code with #+call:, it would be
> more helpful to delete the #+header: line in the source code in the
> Worg page.  This header line presumes that the particular tables in
> your first example exist.  Deleting this line means that the code
> can only be used via a #+call statement but I think this is more
> logical.

I (sort of) disagree. I think specifying required arguments as header 
vars makes the calling requirements clearer. Perhaps:

#+HEADER: :var nodes='() graph='()

would be better...

rick

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

* Re: process diagrams with dot and some glue using org
  2013-07-19 17:37 ` Rick Frankel
@ 2013-07-19 17:56   ` Eric S Fraga
  2013-07-20 11:02   ` Eric S Fraga
  1 sibling, 0 replies; 7+ messages in thread
From: Eric S Fraga @ 2013-07-19 17:56 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Rick Frankel <rick@rickster.com> writes:

[...]

> I (sort of) disagree. I think specifying required arguments as header 
> vars makes the calling requirements clearer. Perhaps:
>
> #+HEADER: :var nodes='() graph='()
>
> would be better...

Sure, that would be a good compromise.  I agree it is nice to have a
clear indication of the requirements.

The reason for my suggestion for deleting the header line was that the
call would not work with it in place as, for some reason, even though
the variables have been defined in the call statement, babel still
expects to find the tables the defaults point to.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.6-341-g338603

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

* Re: process diagrams with dot and some glue using org
  2013-07-19 17:37 ` Rick Frankel
  2013-07-19 17:56   ` Eric S Fraga
@ 2013-07-20 11:02   ` Eric S Fraga
  2013-07-20 12:47     ` Rick Frankel
  1 sibling, 1 reply; 7+ messages in thread
From: Eric S Fraga @ 2013-07-20 11:02 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Rick Frankel <rick@rickster.com> writes:

[...]

> I (sort of) disagree. I think specifying required arguments as header 
> vars makes the calling requirements clearer. Perhaps:
>
> #+HEADER: :var nodes='() graph='()
>
> would be better...
>
> rick
>

For Karl's benefit, the following is the latest version of the
graph-from-tables source code block including the above suggestion from
Rick and also the addition of an options variable.

#+begin_src org
  ,#+name: graph-from-tables
  ,#+header: :var options="" :var nodes='() graph='()
  ,#+BEGIN_SRC emacs-lisp :colnames yes 
    (org-babel-execute:dot
     (concat
          "digraph {\n"
          options "\n"   ;; "//rankdir=LR;\n" ;; remove comment characters '//' for horizontal layout; add for vertical layout
          (mapconcat
           (lambda (x)
             (format "%s [label=\"%s\" shape=%s style=\"filled\" fillcolor=\"%s\"]"
                             (car x)
                             (nth 1 x)
                             (if (string= "" (nth 2 x)) "box" (nth 2 x))
                             (if (string= "" (nth 3 x)) "none" (nth 3 x))
                             )) nodes "\n")
          "\n"
          (mapconcat
           (lambda (x)
             (format "%s -> %s [taillabel=\"%s\"]"
                             (car x) (nth 1 x) (nth 2 x))) graph "\n")
          "}\n") params)
  ,#+END_SRC
#+end_src

I can update the tutorial on Worg if desired.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.6-341-g338603

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

* Re: process diagrams with dot and some glue using org
  2013-07-20 11:02   ` Eric S Fraga
@ 2013-07-20 12:47     ` Rick Frankel
  0 siblings, 0 replies; 7+ messages in thread
From: Rick Frankel @ 2013-07-20 12:47 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode

On Sat, Jul 20, 2013 at 12:02:18PM +0100, Eric S Fraga wrote:
[...]

> For Karl's benefit, the following is the latest version of the
> graph-from-tables source code block including the above suggestion from
> Rick and also the addition of an options variable.
> 
> #+begin_src org
>   ,#+name: graph-from-tables
>   ,#+header: :var options="" :var nodes='() graph='()

nit. the extra `:var' isn't necessary:

     #+header: :var options="" nodes='() graph='()

>   ,#+BEGIN_SRC emacs-lisp :colnames yes 
>     (org-babel-execute:dot
>      (concat
>           "digraph {\n"
>           options "\n"   ;; "//rankdir=LR;\n" ;; remove comment characters '//' for horizontal layout; add for vertical layout
>           (mapconcat
>            (lambda (x)
>              (format "%s [label=\"%s\" shape=%s style=\"filled\" fillcolor=\"%s\"]"
>                              (car x)
>                              (nth 1 x)
>                              (if (string= "" (nth 2 x)) "box" (nth 2 x))
>                              (if (string= "" (nth 3 x)) "none" (nth 3 x))
>                              )) nodes "\n")
>           "\n"
>           (mapconcat
>            (lambda (x)
>              (format "%s -> %s [taillabel=\"%s\"]"
>                              (car x) (nth 1 x) (nth 2 x))) graph "\n")
>           "}\n") params)
>   ,#+END_SRC
> #+end_src
> 
> I can update the tutorial on Worg if desired.
> 

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

* Re: process diagrams with dot and some glue using org
  2013-07-19 17:23 process diagrams with dot and some glue using org Eric S Fraga
  2013-07-19 17:37 ` Rick Frankel
@ 2013-07-21 19:05 ` Karl Voit
  2013-07-22  8:00   ` Eric S Fraga
  1 sibling, 1 reply; 7+ messages in thread
From: Karl Voit @ 2013-07-21 19:05 UTC (permalink / raw)
  To: Eric S Fraga, emacs-orgmode; +Cc: Rick Frankel

Eric S Fraga (e.fraga@ucl.ac.uk) wrote:

> Dear Karl,

Hi Eric,

> a couple of weeks ago you developed some code to convert a pair of
> tables to a graphviz digraph and you wrote a very useful Worg page about
> it:
> 
>   http://article.gmane.org/gmane.emacs.orgmode/74280
>   http://orgmode.org/worg/org-tutorials/org-dot-diagrams.html

Glad you enjoyed it!

> I have today had a real need for this so I copied the code and used
> it.  Worked like a charm!  Thanks for doing this.

You are very welcome!

> I just wanted to say two things about it:
> 
> 1. if the typical use case is to use the code with #+call:, it would be
>      more helpful to delete the #+header: line in the source code in the
>      Worg page. 

I have to admit, that I did not come up with the technical solution
which is described in the tutorial.  My part was the
requirement/idea and a very basic attempt. Rick Frankel[1]
contributed the LISP code and the final structure of the tables. As
a matter of fact, I had never used #+call before by myself. Rick was
also the author of the call statement[2] to re-use the code with
several tables.

>      This header line presumes that the particular tables in
>      your first example exist.  Deleting this line means that the code
>      can only be used via a #+call statement but I think this is more
>      logical.

I see your point.

However, in the tutorial, I wanted to start with a full example
using two tables and the ELISP block only.

In a second step, I wanted to re-use the ELISP block. You are right,
the #+header line is not necessary if the ELISP block is used by
#+src only. Are you suggesting, that there should be a remark on
this in the tutorial? If so, feel free to improve the text, if you
do have good ideas!

> 2. I appended a column to my node table with a description of each
>      node.  You've written your code so that it doesn't care if there
>      are extra columns.  This is a bonus!  My table not only provides
>      the data for the graph but also explains the graph to a reader.

Yes, I also do like this "feature" to add additional things.

Once again: I had the requirement of creating simple work-flows
within Org-mode, Rick was so kind and contributed the solution, and
I summarized the method in the tutorial.

So the "thank you" definitely belongs to Rick. Therefore, I added
him to the Cc.

Nice greetings from sunny Graz, Austria!

  1. http://article.gmane.org/gmane.emacs.orgmode/73854
  2. http://article.gmane.org/gmane.emacs.orgmode/73972
-- 
Karl Voit

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

* Re: process diagrams with dot and some glue using org
  2013-07-21 19:05 ` Karl Voit
@ 2013-07-22  8:00   ` Eric S Fraga
  0 siblings, 0 replies; 7+ messages in thread
From: Eric S Fraga @ 2013-07-22  8:00 UTC (permalink / raw)
  To: Karl Voit; +Cc: Rick Frankel, emacs-orgmode

Karl Voit <mail@Karl-Voit.at> writes:

[...]

> I have to admit, that I did not come up with the technical solution
> which is described in the tutorial.  My part was the
> requirement/idea and a very basic attempt. Rick Frankel[1]
> contributed the LISP code and the final structure of the tables. As
> a matter of fact, I had never used #+call before by myself. Rick was
> also the author of the call statement[2] to re-use the code with
> several tables.

Yes, I was remiss in acknowledging this!  Thanks Rick!!

> #+src only. Are you suggesting, that there should be a remark on
> this in the tutorial? If so, feel free to improve the text, if you
> do have good ideas!

I will have a go at adding some text to the tutorial.  I understand your
original motivation of having a simple working example to start the
tutorial.

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.0.6-333-gca5623

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

end of thread, other threads:[~2013-07-22  8:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 17:23 process diagrams with dot and some glue using org Eric S Fraga
2013-07-19 17:37 ` Rick Frankel
2013-07-19 17:56   ` Eric S Fraga
2013-07-20 11:02   ` Eric S Fraga
2013-07-20 12:47     ` Rick Frankel
2013-07-21 19:05 ` Karl Voit
2013-07-22  8:00   ` Eric S Fraga

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