From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?w4lpYmhlYXI=?= Subject: [PATCH] Prevent overwriting of output files from babel calls with nil result Date: Tue, 27 Oct 2015 22:55:51 +0000 Message-ID: <563000F7.3090409@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090501080703070205010504" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrD9u-0002gb-Qz for emacs-orgmode@gnu.org; Tue, 27 Oct 2015 18:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrD9r-0008ST-KZ for emacs-orgmode@gnu.org; Tue, 27 Oct 2015 18:56:02 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:32860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrD9r-0008SP-6O for emacs-orgmode@gnu.org; Tue, 27 Oct 2015 18:55:59 -0400 Received: by wmeg8 with SMTP id g8so2328614wme.0 for ; Tue, 27 Oct 2015 15:55:58 -0700 (PDT) Received: from [192.168.0.17] (188-141-88-96.dynamic.upc.ie. [188.141.88.96]) by smtp.googlemail.com with ESMTPSA id p10sm47160860wjx.36.2015.10.27.15.55.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2015 15:55:56 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode This is a multi-part message in MIME format. --------------090501080703070205010504 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit -----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----- --------------090501080703070205010504 Content-Type: text/x-patch; name="0001-ob-emacs-lisp.el-Don-t-convert-a-nil-result-to-nil.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-ob-emacs-lisp.el-Don-t-convert-a-nil-result-to-nil.patc"; filename*1="h" >From a25cd4da8791ff9bb759ba38c05ff07650555055 Mon Sep 17 00:00:00 2001 From: Eibhear O hAnluain 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 --------------090501080703070205010504--