emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] Prevent overwriting of output files from babel calls wit


From: Éibhear
Subject: Re: [O] [PATCH] Prevent overwriting of output files from babel calls with nil result
Date: Thu, 29 Oct 2015 17:31:10 -0000
User-agent: SquirrelMail/1.4.22

> Hi Éibhear,
>
> I'm afraid I don't understand the problem the patch is trying to fix.
> Can you provide a MWE (minimal working example) that illustrates the bug
> you're observing?
>
> Thanks,
>
> --
> Aaron Ecay
>

Hi Aaron,

Thanks for getting back to me.

Prerequisites:
- The dot utility from graphvis is available
- org-babel-load-languages includes '(dot . t)

See below for a sample org file.

For org-mode 8.2.10, invoking C-c C-c on the #+BEGIN_SRC line produces a
file called sample-flow.png, representing a simple flow from a "Start"
node to an "End" node.

In org-mode 8.3.1 and 8.3.2, sample-flow.png contains only the text "nil".

I believe the bug to be in `org-babel-execute:emacs-lisp', when the second
parameter to `org-babel-result-cond' is being evaluated. When `result' is
nil, it is converted to "nil", and this is being written into the
sample-flow.png file, overwriting the contents that the dot utility had
created.

My patch prevents a nil result being converted into a text string when
calling `org-babel-result-cond'. I believe this is an appropriate change.

Éibhear

---------------------->8==========================
* Charts
** Chart from flows
   #+name: chart-from-flows
   #+HEADER: :var nodes=sample-elements graph=sample-connections
ranks=sample-ranks
   #+BEGIN_SRC emacs-lisp :file ./sample-flow.png :colnames yes :exports
results
    (org-babel-execute:dot
     (concat
          "digraph {\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\" color=\"%s\" style=\"%s\"]"
                             (car x)
                             (nth 1 x)
                             (nth 2 x)
                             (if (string= "" (nth 3 x)) "black" (nth 3 x))
                             (if (string= "" (nth 4 x)) "solid" (nth 4 x))
                             )) graph "\n")
          "\n"
          (mapconcat
           (lambda (x)
             (format "{rank=%s %s}"
                             (if (or (string= "min" (car x)) (string=
"max" (car x))) (car x) (concat "same; " (car
x))) (nth 1 x))) ranks "\n")
          "}\n") params)
   #+END_SRC

   #+RESULTS: chart-from-flows
   [[file:./sample-flow.png]]

** Development process flow
*** Flow elements
    #+name: sample-elements
    | *node* | *label* | *shape* | *fillcolor* |
    |--------+---------+---------+-------------|
    | start  | Start   | ellipse |             |
    | end    | End     | ellipse |             |
*** Flow connections
    #+name: sample-connections
    | from  | to  | label | colour | style |
    |-------+-----+-------+--------+-------|
    | start | end |       |        |       |
*** Flow ranks
    #+name: sample-ranks
    | anchor | node  |
    |--------+-------|
    | min    | start |
    | start  | end   |
---------------------->8==========================



-- 
Éibhear Ó hAnluain,
Dublin, Ireland
+-------------------------------+--------------------------------+
| e-mail: address@hidden | Web: [http://www.gibiris.org/] |
| Twitter: @eibhear             | Google+: +Éibhear Ó hAnluain   |
| Mobile: +353 86 856 5666      | VoIP: sip:address@hidden |
+-------------------------------+--------------------------------+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]