From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Bug in new exporter with babel blocks Date: Tue, 22 Jan 2013 16:54:32 -0500 Message-ID: <87obggevdz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:46980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Txlnl-0003B1-AP for emacs-orgmode@gnu.org; Tue, 22 Jan 2013 16:54:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Txlni-0003YS-9k for emacs-orgmode@gnu.org; Tue, 22 Jan 2013 16:54:41 -0500 Received: from mail-vb0-f45.google.com ([209.85.212.45]:41708) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Txlni-0003Y2-5H for emacs-orgmode@gnu.org; Tue, 22 Jan 2013 16:54:38 -0500 Received: by mail-vb0-f45.google.com with SMTP id p1so3840298vbi.4 for ; Tue, 22 Jan 2013 13:54:37 -0800 (PST) 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, I=E2=80=99m dealing with a puzzling bug in the new exporter. As background, I=E2=80=99ve written a custom function to process special-blocks, to replic= ate in the new exporter the functionality of the org-exp-blocks package (http://orgmode.org/worg/org-contrib/org-exp-blocks.html). Because I need the un-processed text inside the special-block (not parsed into an org-elements structure nor escaped for LaTeX special characters), I use the :contents-begin and -end properties of the element to extract this information. These values aren=E2=80=99t accurate in the presence of babel source blocks= . In order to reproduce this, extract the attached elisp and org files into your home directory, adjust the paths to point to an up-to-date git checkout of the org sources (I am on today=E2=80=99s commit 196c579), and eval-buffer the lisp file in an emacs -Q (I am using an up-to-date trunk checkout of the meacs sources). Then look in the *Messages* buffer to see what follows =E2=80=9CRESULT IS: =E2=80=9C. It should be =E2=80=9Cbar= =E2=80=9D; I get something else (specifically =E2=80=9C 1)=E2=80=9D from the middle of the babel block= ). Deleting the babel block from the org file and re-running the export call delivers the expected =E2=80=9CRESULT IS: bar=E2=80=9D message. (Note that the final output is correct because the test elisp falls back to the original definition of =E2=80=98org-e-latex-special-block=E2=80=99, = but in my use the output is wrong because I rely on the result of the buffer-substring call.) I=E2=80=99m not sure if this is a long-standing problem or not; this is the first time I=E2=80=99ve combined babel with my custom special-blocks code. = I=E2=80=99m also at a loss of how to debug the internals of org-elements and org-export, two complex bits of machinery. I guess the value of the :contents-begin and -end properties needs to be fixed in any case. I=E2=80= =99d also be happy to discover another, better way of getting the raw text content of the special-block that doesn=E2=80=99t succumb to this problem. Thanks in advance, Aaron Ecay --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-bug.el Content-Transfer-Encoding: quoted-printable (add-to-list 'load-path "~/.emacs.d/git-elisp/org-mode/lisp") (add-to-list 'load-path "~/.emacs.d/git-elisp/org-mode/contrib/lisp") (require 'org) (require 'org-e-latex) (fset 'orig-oel-special-bl (symbol-function 'org-e-latex-special-block)) (defun org-e-latex-special-block (special-block contents info) (message "RESULT IS: %s" (buffer-substring-no-properties (org-element-property :contents-begin special-block) (org-element-property :contents-end special-block) )) (orig-oel-special-bl special-block contents info)) (find-file-noselect "~/org-bug.org") (with-current-buffer (get-buffer "org-bug.org") (org-export-as 'e-latex)) --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=org-bug.org * Intro #+name: setup #+begin_src elisp :results output :exports both (+ 1 1) #+end_src foo #+begin_foo bar #+end_foo baz --=-=-=--