From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Org Babel Bug Date: Tue, 09 Feb 2010 19:11:21 -0700 Message-ID: <87iqa5rgae.fsf@gmail.com> References: <4B7141AE.9040105@manor-farm.org> <87k4umbb8g.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nf23D-0007uK-Ri for emacs-orgmode@gnu.org; Tue, 09 Feb 2010 21:11:35 -0500 Received: from [199.232.76.173] (port=46930 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nf23D-0007u5-HQ for emacs-orgmode@gnu.org; Tue, 09 Feb 2010 21:11:35 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nf23A-0001QV-V1 for emacs-orgmode@gnu.org; Tue, 09 Feb 2010 21:11:35 -0500 Received: from mail-px0-f198.google.com ([209.85.216.198]:50622) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nf239-0001Q0-AN for emacs-orgmode@gnu.org; Tue, 09 Feb 2010 21:11:32 -0500 Received: by pxi36 with SMTP id 36so7749535pxi.26 for ; Tue, 09 Feb 2010 18:11:28 -0800 (PST) In-Reply-To: <87k4umbb8g.fsf@gmail.com> (Eric Schulte's message of "Tue, 09 Feb 2010 09:54:55 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: lists@manor-farm.org Cc: emacs-orgmode@gnu.org Hi, Since the patch below greatly simplifies the code, and it has worked in all my tests, I'm going to apply it now. Please do let me know if the export problems persist. Best -- Eric "Eric Schulte" writes: > Hi Ian, > > The implementation of our block exportation has been bothering me for > some time now. The attached patch *greatly* simplifies the exportation > code. Could you please give it a try and let me know if it fixes your > bug? > > If so I will apply it to the main repository. > > Thanks -- Eric > > > diff --git a/contrib/babel/lisp/org-babel-exp.el b/contrib/babel/lisp/org-babel-exp.el > index 8ce52b6..b299d57 100644 > --- a/contrib/babel/lisp/org-babel-exp.el > +++ b/contrib/babel/lisp/org-babel-exp.el > @@ -73,20 +73,10 @@ results - just like none only the block is run on export ensuring > none ----- do not display either code or results upon export" > (interactive) > (message "org-babel-exp processing...") > - (flet ((cond-progress-marker () (when (and progress-marker (< progress-marker (point))) > - progress-marker))) > - (or (and (re-search-backward org-babel-src-block-regexp (cond-progress-marker) t) > - (setq progress-marker (match-end 0)) > - (org-babel-exp-do-export (org-babel-get-src-block-info) 'block)) > - (save-excursion > - (forward-line 0) > - (and (org-babel-where-is-src-block-head) > - (goto-char (org-babel-where-is-src-block-head)) > - (org-babel-exp-do-export (org-babel-get-src-block-info) 'block))) > - (and (re-search-backward org-block-regexp (cond-progress-marker) t) > - (setq progress-marker (match-end 0)) > - (match-string 0)) > - (error "Unmatched block [bug in `org-babel-exp-src-blocks'].")))) > + (when (member (first headers) org-babel-interpreters) > + (save-excursion > + (goto-char (match-beginning 0)) > + (org-babel-exp-do-export (org-babel-get-src-block-info) 'block)))) > > (defun org-babel-exp-inline-src-blocks (start end) > "Process inline src blocks between START and END for export. > diff --git a/lisp/org-exp-blocks.el b/lisp/org-exp-blocks.el > index 1d43d3a..af53b60 100644 > --- a/lisp/org-exp-blocks.el > +++ b/lisp/org-exp-blocks.el > @@ -183,13 +183,15 @@ specified in BLOCKS which default to the value of > (setq body (save-match-data (org-remove-indentation body)))) > (unless (memq type types) (setq types (cons type types))) > (save-match-data (interblock start (match-beginning 0))) > - (if (setq func (cadr (assoc type org-export-blocks))) > - (progn > - (replace-match (save-match-data > + (when (setq func (cadr (assoc type org-export-blocks))) > + (let ((replacement (save-match-data > (if (memq type org-export-blocks-witheld) "" > - (apply func body headers))) t t) > + (apply func body headers))))) > + (when replacement > + (replace-match replacement t t) > (unless preserve-indent > - (indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))) > + (indent-code-rigidly > + (match-beginning 0) (match-end 0) indentation))))) > (setq start (match-end 0))) > (interblock start (point-max)))))) > > > > Ian Barton writes: > >> I am using Babel to maintein my .emacs file. When I try to publish I >> am getting a Babel error from one of my org files. The offending >> section of the org file seems to be: >> >> #+BEGIN_SRC emacs-shell >> 127.0.0.1 mail.wilkesley.org localhost >> >> # The following lines are desirable for IPv6 capable hosts >> ::1 ip6-localhost ip6-loopback >> fe00::0 ip6-localnet >> ff00::0 ip6-mcastprefix >> ff02::1 ip6-allnodes >> ff02::2 ip6-allrouters >> ff02::3 ip6-allhosts >> >> #+END_SRC >> >> I am using a recent git checkout of org and GNU Emacs 23.1.50.1 >> (x86_64-pc-linux-gnu, GTK+ Version 2.18.0). >> >> The backtrace is: >> >> Debugger entered--Lisp error: (error "Unmatched block [bug in >> org-babel-exp-src-blocks'].") >> signal(error ("Unmatched block [bug in `org-babel-exp-src-blocks'].")) >> error("Unmatched block [bug in `org-babel-exp-src-blocks'].") >> (or (and (re-search-backward org-babel-src-block-regexp ... t) (setq >> progress-marker ...) (org-babel-exp-do-export ... ...)) >> (save-excursion (forward-line 0) (and ... ... ...)) (and >> (re-search-backward org-block-regexp ... t) (setq progress-marker ...) >> (match-string 0)) (error "Unmatched block [bug in >> org-babel-exp-src-blocks'].")) >> (progn (fset (quote cond-progress-marker) (function* ...)) (or (and >> ... ... ...) (save-excursion ... ...) (and ... ... ...) (error >> "Unmatched block [bug in `org-babel-exp-src-blocks']."))) >> (unwind-protect (progn (fset ... ...) (or ... ... ... ...)) (if >> --cl-letf-bound-- (fset ... --cl-letf-save--) (fmakunbound ...))) >> (let* ((--cl-letf-bound-- ...) (--cl-letf-save-- ...)) >> (unwind-protect (progn ... ...) (if --cl-letf-bound-- ... ...))) >> (letf ((... ...)) (or (and ... ... ...) (save-excursion ... ...) >> (and ... ... ...) (error "Unmatched block [bug in >> org-babel-exp-src-blocks']."))) >> (letf* ((... ...)) (or (and ... ... ...) (save-excursion ... ...) >> (and ... ... ...) (error "Unmatched block [bug in >> org-babel-exp-src-blocks']."))) >> (flet ((cond-progress-marker nil ...)) (or (and ... ... ...) >> (save-excursion ... ...) (and ... ... ...) (error "Unmatched block >> [bug in `org-babel-exp-src-blocks']."))) >> org-babel-exp-src-blocks(#("127.0.0.1 mail.wilkesley.org >> localhost\n\n# The following lines are desirable for IPv6 capable >> hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 >> ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 >> ip6-allhosts\n" 0 240 (fontified nil)) #("emacs-shell" 0 11 (fontified >> nil))) >> apply(org-babel-exp-src-blocks #("127.0.0.1 mail.wilkesley.org >> localhost\n\n# The following lines are desirable for IPv6 capable >> hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 >> ip6-mcastprefix\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\nff02::3 >> ip6-allhosts\n" 0 240 (fontified nil)) #("emacs-shell" 0 11 (fontified >> nil))) >> >> byte-code("\306\307\211\211\211\211\211\211\211\211.......#.$.%.&\310\311!\211.'\205# >> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode