emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: aditya siram <aditya.siram@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [Babel] Parsing source block bug ...
Date: Fri, 13 Sep 2013 22:08:35 -0500	[thread overview]
Message-ID: <CAJrReyiGje0xOpU1Wu9u+23q6GzYmDvUa4o=JZ5-D-5M6aL85A@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 388 bytes --]

Hi all,
This patch fixes a bug where the regexp for parsing source blocks is too
greedy on the body and so fails in the presence of empty code blocks. For
instance given the following:

#+begin_src c
#+end_src

#+begin_src c
hello world
#+end_src

, doing (org-babel-get-src-block-info) the first #+begin_src will include
everything up to the second #+end_src as part of the body.
-deech

[-- Attachment #1.2: Type: text/html, Size: 516 bytes --]

[-- Attachment #2: src_block_regexp_fix.patch --]
[-- Type: application/octet-stream, Size: 910 bytes --]

From 222474d99d80c5cc411df6ca31f7ad1a3bc7aea0 Mon Sep 17 00:00:00 2001
From: Aditya Siram <aditya siram at gmail dot com>
Date: Fri, 13 Sep 2013 09:57:25 -0500
Subject: [PATCH 3/6] Given a block with an empty body
 org-babel-src-block-regexp gobbled up everything until the ending delimiter
 of the next code block. Fixed this by making the body regexp non-greedy.

---
 lisp/ob-core.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d57806b..e8f16a0 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -188,7 +188,7 @@ This string must include a \"%s\" which will be replaced by the results."
    ;; (4) header arguments
    "\\([^\n]*\\)\n"
    ;; (5) body
-   "\\([^\000]*?\n\\)?[ \t]*#\\+end_src")
+   "\\([^\000]*?\n\\)??[ \t]*#\\+end_src")
   "Regexp used to identify code blocks.")
 
 (defvar org-babel-inline-src-block-regexp
-- 
1.8.1.2


             reply	other threads:[~2013-09-14  3:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-14  3:08 aditya siram [this message]
2013-09-14 15:28 ` [Babel] Parsing source block bug Eric Schulte

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='CAJrReyiGje0xOpU1Wu9u+23q6GzYmDvUa4o=JZ5-D-5M6aL85A@mail.gmail.com' \
    --to=aditya.siram@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).