emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Giuseppe Lipari <giulipari@gmail.com>
Cc: Bastien <bzg@gnu.org>, emacs-orgmode@gnu.org
Subject: Re: Bug: Org-babel export of c++11 code to Latex does not work properly [7.9.4 (7.9.4-elpa @ /home/lipari/.emacs.d/elpa/org-20130401/)]
Date: Mon, 20 Jan 2014 14:13:32 +0100	[thread overview]
Message-ID: <87eh42zthf.fsf@gmail.com> (raw)
In-Reply-To: <CABHo5SC-AxX_Ts8W+Aw-XCh63hJEJ-V0eFVHk4+erVVwnMkbAA@mail.gmail.com> (Giuseppe Lipari's message of "Mon, 20 Jan 2014 10:35:10 +0100")

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

Hello,

Giuseppe Lipari <giulipari@gmail.com> writes:

> thanks for the response. I did some debugging, but I am not an expert of
> elisp and org-mode. Anyway, this is what I found:
>
> I put a breakpoint in fuinction org-latex-src-block() which receives
> src-block as parameter. This parameter contains field language already set
> to c++\"-std=c++11\", which is of course wrong. Therefore the problem is
> before this function is called, but I could not follow the chain and so I
> do not know precisely which function is responsible for this.
>
> Also, the bug triggers also when I specify C as a language. Therefore,
> probably the problem is somewhere in ob-C.el.

I think the following patch fixes the issue. I'll let Eric decide if it
has to be applied or not.

Thank you for the report.


Regards,

-- 
Nicolas Goaziou

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-exp-Fix-export-of-src-blocks-with-flags.patch --]
[-- Type: text/x-diff, Size: 1959 bytes --]

From bbe85db3abbdcc0973dcd0fb783728d4374b20fb Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Mon, 20 Jan 2014 14:07:57 +0100
Subject: [PATCH] ob-exp: Fix export of src blocks with flags

* lisp/ob-exp.el (org-babel-exp-code): Fix export of src blocks with
  flags.
* testing/lisp/test-ob-exp.el (ob-export/export-src-block-with-flags):
  New test.

Thanks to Giuseppe Lipari for reporting it.
---
 lisp/ob-exp.el              | 3 ++-
 testing/lisp/test-ob-exp.el | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index b2be510..84eb011 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -341,11 +341,12 @@ replaced with its value."
    org-babel-exp-code-template
    `(("lang"  . ,(nth 0 info))
      ("body"  . ,(org-escape-code-in-string (nth 1 info)))
+     ("flags" . ,(let ((f (assq :flags (nth 2 info))))
+		   (when f (concat " " (cdr f)))))
      ,@(mapcar (lambda (pair)
 		 (cons (substring (symbol-name (car pair)) 1)
 		       (format "%S" (cdr pair))))
 	       (nth 2 info))
-     ("flags" . ,(let ((f (nth 3 info))) (when f (concat " " f))))
      ("name"  . ,(or (nth 4 info) "")))))
 
 (defun org-babel-exp-results (info type &optional silent hash)
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index 2f5342b..33585e4 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -303,6 +303,15 @@ Here is one at the end of a line. =2=
       (org-export-execute-babel-code)
       (buffer-string)))))
 
+(ert-deftest ob-export/export-src-block-with-flags ()
+  "Test exporting a source block with a flag."
+  (should
+   (string-match "\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
+    (org-test-with-temp-text
+	"#+BEGIN_SRC emacs-lisp :flags -some-flag\n\(+ 1 1)\n#+END_SRC"
+      (org-export-execute-babel-code)
+      (buffer-string)))))
+
 (provide 'test-ob-exp)
 
 ;;; test-ob-exp.el ends here
-- 
1.8.5.3


  reply	other threads:[~2014-01-20 13:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 13:55 Bug: Org-babel export of c++11 code to Latex does not work properly [7.9.4 (7.9.4-elpa @ /home/lipari/.emacs.d/elpa/org-20130401/)] Giuseppe Lipari
2014-01-19 16:02 ` Bastien
2014-01-20  9:35   ` Giuseppe Lipari
2014-01-20 13:13     ` Nicolas Goaziou [this message]
2014-01-20 13:17       ` Nicolas Goaziou
2014-01-20 13:22         ` Nicolas Goaziou
2014-01-20 13:41           ` Giuseppe Lipari
2014-01-20 15:26           ` Eric Schulte
2014-01-20 16:18             ` Nicolas Goaziou

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=87eh42zthf.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=giulipari@gmail.com \
    /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).