emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Babel] Parsing source block bug ...
@ 2013-09-14  3:08 aditya siram
  2013-09-14 15:28 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: aditya siram @ 2013-09-14  3:08 UTC (permalink / raw)
  To: emacs-orgmode


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


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

* Re: [Babel] Parsing source block bug ...
  2013-09-14  3:08 [Babel] Parsing source block bug aditya siram
@ 2013-09-14 15:28 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2013-09-14 15:28 UTC (permalink / raw)
  To: aditya siram; +Cc: emacs-orgmode

Thanks for this patch!  I've just applied it.

For future patches it is good form to keep the first line of the commit
message <= 50 characters long (used to summarize the patch), the second
line should be blank, and all subsequent lines should be <=70 characters
long.

Thanks again.

aditya siram <aditya.siram@gmail.com> writes:

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

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

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

end of thread, other threads:[~2013-09-14 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-14  3:08 [Babel] Parsing source block bug aditya siram
2013-09-14 15:28 ` Eric Schulte

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