The patch causes an informative error message to be reported for src blocks like this (no language):

#+begin_src
(+ 1 2)
#_end_src

when exporting instead of failing with a cryptic error message.

Arguably, it would be better to skip the malformed src block as `org-babel-map-src-blocks' does or (as per John's message) org-babel-tangle does.

WDYT?

Chuck


On Tue, 10 Mar 2015, Charles Berry wrote:

XIE Yuheng <xyheme <at> gmail.com> writes:



Bug: org-babel-parse-src-block-match reporting "Wrong type argument:
stringp, nil" when exporting a org-mode file with a lots of code blocks
[8.3beta (release_8.3beta-895-g375c83  <at>
/usr/share/emacs/site-lisp/org/)]

the following is *Messages* buffer
   https://www.refheap.com/98243
the following is the org-mode file with a lot of code blocks
   https://github.com/the-little-language-designer/cicada-nymph/blob/
master/cicada-nymph.org


Look at the *Messages*  buffer and you will see a list of src blocks that were
processed without error.

The src block *after* the last block in the list (before the error message)
caused the error.

`org-babel-parse-src-block-match' expects a language for a src block.

Specify a language for every src block and it will export.

HTH,

Chuck



From f9859c09c5ad4790ef94d87477e7dfb97f264880 Mon Sep 17 00:00:00 2001
From: Charles Berry <ccbe...@ucsd.edu>
Date: Tue, 10 Mar 2015 14:09:52 -0700
Subject: [PATCH] ob-exp.el: org-babel-exp-process-buffer reports src block w/o
 language

* lisp/ob-exp.el (org-babel-exp-process-buffer): Issue an error when a
  src block with neither language nor headers is processed.

Throw an error with an informative message when trying to export buffer
containing `#+src_block\n'.

Reported-by: XIE Yuheng <xyh...@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/95920>
---
 lisp/ob-exp.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 4c53a55..d17e49f 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -268,7 +268,11 @@ may make them unreachable."
                   ;; the block should be left as-is while an empty
                   ;; string should remove the block.
                   (let ((replacement
-                         (progn (goto-char match-start)
+                         (progn (when (null (car headers))
+                                  (error
+                                   "No src block language or headers at line 
%S"
+                                   (line-number-at-pos)))
+                                (goto-char match-start)
                                 (org-babel-exp-src-block headers))))
                     (cond ((not replacement) (goto-char end))
                           ((equal replacement "")
-- 
1.9.3 (Apple Git-50)

Reply via email to