emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Éibhear <eibhear.geo@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [PATCH] Prevent overwriting of output files from babel calls with nil result
Date: Tue, 27 Oct 2015 22:55:51 +0000	[thread overview]
Message-ID: <563000F7.3090409@gmail.com> (raw)

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

Here's a patch to ob-emacs-lisp.el to allow me to start generating
graphs with dot again.

Thanks,

Éibhear

- -- 
É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 |
+-------------------------------+--------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlYwAPcACgkQ0ST+nPIXcQb+7QCbB9M8FNYMQM/AO9Sy57vMyjdD
TsMAn0KiaebLDLAxcbQX7OmuQvULwQ42
=wDzV
-----END PGP SIGNATURE-----

[-- Attachment #2: 0001-ob-emacs-lisp.el-Don-t-convert-a-nil-result-to-nil.patch --]
[-- Type: text/x-patch, Size: 1996 bytes --]

From a25cd4da8791ff9bb759ba38c05ff07650555055 Mon Sep 17 00:00:00 2001
From: Eibhear O hAnluain <eibhear.geo@gmail.com>
Date: Tue, 27 Oct 2015 22:43:02 +0000
Subject: [PATCH] ob-emacs-lisp.el: Don't convert a nil result to "nil"

* ob-emacs-lisp.el (org-babel-execute:emacs-lisp): if `result' is nil
  after the execution of the emacs-lisp code, then it should be passed
  to `ob-babel-result-cond' as nil, and not converted to "nil".

When successful, `org-babel-execute:dot' returns nil, as the output is
written to a file.  Commit 041ca4b6f4c7fe1a7e7eb22e2f08ec2e08577bf9
causes the macro `org-babel-result-cond' to overwrite the file and
populate it with the text "nil". This is because the nil `result' from
the call to the emacs-lisp code is converted to "nil" in
`org-babel-execute:emacs-lisp' when calling `org-babel-result-cond'.
This patch preserves `result' as nil.

TINYCHANGE
---
 lisp/ob-emacs-lisp.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el
index 796293b..bbd3dc8 100644
--- a/lisp/ob-emacs-lisp.el
+++ b/lisp/ob-emacs-lisp.el
@@ -59,12 +59,14 @@
                                (org-babel-expand-body:emacs-lisp
                                 body params))))))
       (org-babel-result-cond (cdr (assoc :result-params params))
-	(let ((print-level nil)
-              (print-length nil))
-          (if (or (member "scalar" (cdr (assoc :result-params params)))
-                  (member "verbatim" (cdr (assoc :result-params params))))
-              (format "%S" result)
-            (format "%s" result)))
+	(if result
+	    (let ((print-level nil)
+		  (print-length nil))
+	      (if (or (member "scalar" (cdr (assoc :result-params params)))
+		      (member "verbatim" (cdr (assoc :result-params params))))
+		  (format "%S" result)
+		(format "%s" result)))
+	  )
 	(org-babel-reassemble-table
 	 result
          (org-babel-pick-name (cdr (assoc :colname-names params))
-- 
2.1.4


             reply	other threads:[~2015-10-27 22:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 22:55 Éibhear [this message]
2015-10-29 13:53 ` [PATCH] Prevent overwriting of output files from babel calls with nil result Aaron Ecay
2015-10-29 17:31   ` "Éibhear"
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=563000F7.3090409@gmail.com \
    --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).