all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Xavier Garrido <xavier.garrido@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Exporting C++ code block to html
Date: Sat, 28 Sep 2013 06:05:22 -0600	[thread overview]
Message-ID: <87ob7dw238.fsf@gmail.com> (raw)
In-Reply-To: 5245D235.20709@gmail.com

Xavier Garrido <xavier.garrido@gmail.com> writes:

> Dear Orgers,
>
> I face a problem when I want to 'html' export a pretty simple org file : 
> test.org contains the following lines
>
> #+BEGIN_SRC c++
> int j= 1;
> #+END_SRC
>
> If I do
> emacs --batch -q --eval '(require (quote org))' --visit test.org \ 
> --funcall org-html-export-to-html
>

I had to do the following to re-create this error.

emacs --batch --eval "(progn (add-to-list 'load-path \"~/src/org-mode/lisp\") (require 'org) (add-to-list 'load-path \"~/src/org-mode/contrib/lisp\")(require 'htmlize))" --visit /tmp/cpp-test.org --funcall org-html-export-to-html

>
> I get
> Loading vc-git...
> Loading cc-langs...
> Symbol's function definition is void: nil
>

With the above I get the same

>
> I have also activated the debug mode but the messages are quite
> cryptic for me (attached file). The point is that it only crashes with
> C/C++ languages but works with python, awk, sh, emacs-lisp ...
>
> I'm using orgmode 8.2-35 from the git repository.
>

I think this may be a bug in cc-mode when run in a batch Emacs session.
My guess is that the `c-standard-font-lock-fontify-region-function' is
never set.  You could either try to set this value manually, or report
this to the cc-mode maintainers, but I wouldn't be surprised if they ask
why you want fontification in a batch session.

Setting this variable manually from the command line with the following
fixes this problem for me.

emacs --batch --eval "(progn (add-to-list 'load-path \"~/src/org-mode/lisp\") (require 'org) (add-to-list 'load-path \"~/src/org-mode/contrib/lisp\")(require 'htmlize) (setq c-standard-font-lock-fontify-region-function 'font-lock-default-fontify-region))" --visit /tmp/cpp-test.org --funcall org-html-export-to-html

Cheers,

>
> Thanks for your help,
> Xavier
>
> oading vc-git...
> Loading cc-langs...
> Debugger entered--Lisp error: (void-function nil)
>   nil(1 12 nil)
>   c-font-lock-fontify-region(1 12 nil)
>   font-lock-fontify-region(1 12 nil)
>   byte-code("\212\303 \304\216\305ed	#\210\306 \210\307\211+\207" [save-match-data-internal verbose font-lock-fontified match-data ((byte-code "\30\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) font-lock-fontify-region font-lock-after-fontify-buffer t] 4)
>   font-lock-default-fontify-buffer()
>   font-lock-fontify-buffer()
>   org-html-fontify-code("int j = 1;\n" "c++")
>   org-html-do-format-code("int j = 1;\n" "c++" nil t nil)
>   org-html-format-code((src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))) (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype "xhtml-strict" :html-container "div" :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" :html-head-include-default-style t :html-head-include-scripts t :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")) :html-inline-images t :creator "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> 24.3.1 (<a href=\"http://orgmode.org\">Org</a> mode 8.2)" :with-latex t :author nil ...))
>   org-html-src-block((src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))) nil (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype "xhtml-strict" :html-container "div" :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" :html-head-include-default-style t :html-head-include-scripts t :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")) :html-inline-images t :creator "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> 24.3.1 (<a href=\"http://orgmode.org\">Org</a> mode 8.2)" :with-latex t :author nil ...))
>   org-export-data((src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))) (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype "xhtml-strict" :html-container "div" :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" :html-head-include-default-style t :html-head-include-scripts t :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")) :html-inline-images t :creator "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> 24.3.1 (<a href=\"http://orgmode.org\">Org</a> mode 8.2)" :with-latex t :author nil ...))
>   #[(element) "\302     \"\207" [element info org-export-data] 3]((src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #2)) #0))))
>   mapconcat(#[(element) "\302   \"\207" [element info org-export-data] 3] ((src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #3)) #1)))) "")
>   org-export-data((section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #0)) (src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent #0))) (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype "xhtml-strict" :html-container "div" :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" :html-head-include-default-style t :html-head-include-scripts t :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")) :html-inline-images t :creator "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> 24.3.1 (<a href=\"http://orgmode.org\">Org</a> mode 8.2)" :with-latex t :author nil ...))
>   #[(element) "\302     \"\207" [element info org-export-data] 3]((section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #0)) (src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent #0))))
>   mapconcat(#[(element) "\302   \"\207" [element info org-export-data] 3] ((section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent (org-data nil #1)) (src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent #1)))) "")
>   org-export-data((org-data nil (section (:begin 1 :end 39 :contents-begin 1 :contents-end 39 :post-blank 0 :parent #0) (src-block (:language "c++" :switches nil :parameters nil :begin 1 :end 39 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :hiddenp nil :value "int j = 1;\n" :post-blank 0 :post-affiliated 1 :parent #1)))) (:export-options nil :input-file "/home/garrido/Teachdir/C++.test/test.org" :title "test" :html-extension "html" :html-link-org-as-html t :html-doctype "xhtml-strict" :html-container "div" :html-html5-fancy nil :html-link-use-abs-url nil :html-link-home "" :html-link-up "" :html-mathjax "" :html-postamble auto :html-preamble t :html-head "" :html-head-extra "" :html-head-include-default-style t :html-head-include-scripts t :html-table-attributes (:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") :html-table-row-tags ("<tr>" . "</tr>") :html-xml-declaration (("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")) :html-inline-images t :creator "<a href=\"http://www.gnu.org/software/emacs/\">Emacs</a> 24.3.1 (<a href=\"http://orgmode.org\">Org</a> mode 8.2)" :with-latex t :author nil ...))
>   org-export-as(html nil nil nil nil)
>   org-export-to-file(html "./test.html" nil nil nil nil nil)
>   org-html-export-to-html()
>   call-interactively(org-html-export-to-html nil nil)
>   command-execute(org-html-export-to-html)
>   command-line-1(("--eval" "(require (quote org))" "--eval" "(setq debug-on-error t)" "--visit" "test.org" "--funcall" "org-html-export-to-html"))
>   command-line()
>   normal-top-level()

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

  reply	other threads:[~2013-09-28 12:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27 18:45 Exporting C++ code block to html Xavier Garrido
2013-09-28 12:05 ` Eric Schulte [this message]
2013-09-28 15:53   ` Xavier Garrido
2013-09-28 14:11 ` Achim Gratz

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ob7dw238.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=xavier.garrido@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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.