emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Prevent overwriting of output files from babel calls with nil result
@ 2015-10-27 22:55 Éibhear
  2015-10-29 13:53 ` Aaron Ecay
  0 siblings, 1 reply; 6+ messages in thread
From: Éibhear @ 2015-10-27 22:55 UTC (permalink / raw)
  To: Org Mode

[-- 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


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

end of thread, other threads:[~2015-11-04 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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"
2015-10-29 19:59     ` Aaron Ecay
2015-10-30 23:41       ` Éibhear
2015-11-04 10:59         ` Aaron Ecay

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