From: "\"Éibhear\"" <eibhear.geo@gmail.com>
To: "\"Éibhear\"" <eibhear.geo@gmail.com>,
"Org Mode" <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Prevent overwriting of output files from babel calls with nil result
Date: Thu, 29 Oct 2015 17:31:10 -0000 [thread overview]
Message-ID: <87f4f16f12829a921a198d2f05f1874b.squirrel@www.gibiris.org> (raw)
In-Reply-To: <87si4tye5b.fsf@gmail.com>
> 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: eibhear.geo@gmail.com | Web: [http://www.gibiris.org/] |
| Twitter: @eibhear | Google+: +Éibhear Ó hAnluain |
| Mobile: +353 86 856 5666 | VoIP: sip:eibhear@linphone.org |
+-------------------------------+--------------------------------+
next prev parent reply other threads:[~2015-10-29 17:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 22:55 [PATCH] Prevent overwriting of output files from babel calls with nil result Éibhear
2015-10-29 13:53 ` Aaron Ecay
2015-10-29 17:31 ` "Éibhear" [this message]
2015-10-29 19:59 ` Aaron Ecay
2015-10-30 23:41 ` Éibhear
2015-11-04 10:59 ` Aaron Ecay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87f4f16f12829a921a198d2f05f1874b.squirrel@www.gibiris.org \
--to=eibhear.geo@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).