emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] Bug: Export code block before first heading
@ 2009-11-21  2:05 Andreas Burtzlaff
  2009-11-21  2:40 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Burtzlaff @ 2009-11-21  2:05 UTC (permalink / raw)
  To: emacs-orgmode

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

Exporting a file with a source block before the first heading, like:

#+BEGIN_SRC emacs-lisp

...

#+END_SRC 

to html yields the error 
"Before first headline at position 3 in buffer  org-mode-tmp"

A backtrace is attached.

Andreas

Emacs  : GNU Emacs 23.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.16.6)
 of 2009-11-18 on fluxx
Package: Org-mode version 6.33f (release_6.33f.16.ge103)

[-- Attachment #2: backtrace.txt --]
[-- Type: text/plain, Size: 18658 bytes --]

Debugger entered--Lisp error: (error "Before first headline at position 3 in buffer  org-mode-tmp")
  signal(error ("Before first headline at position 3 in buffer  org-mode-tmp"))
  error("Before first headline at position %d in buffer %s" 3 #<buffer  org-mode-tmp>)
  (condition-case nil (outline-back-to-heading invisible-ok) (error (error "Before first headline at position %d in buffer %s" ... ...)))
  org-back-to-heading(t)
  (progn (org-back-to-heading t) (point))
  (or beg (progn (org-back-to-heading t) (point)))
  (let* ((beg ...) (end ...)) (goto-char beg) (if (re-search-forward org-property-start-re end t) (setq beg ...) (if force ... ...) (goto-char beg) (if ... ...)) (if (re-search-forward org-property-end-re end t) (setq end ...) (or force ...) (goto-char beg) (setq end beg) (org-indent-line-function) (insert ":END:\n")) (cons beg end))
  (save-excursion (let* (... ...) (goto-char beg) (if ... ... ... ... ...) (if ... ... ... ... ... ... ...) (cons beg end)))
  (catch (quote exit) (save-excursion (let* ... ... ... ... ...)))
  org-get-property-block()
  (let ((range ...)) (if (and range ... ...) (if ... ... "")))
  (if (member property org-special-properties) (cdr (assoc property ...)) (let (...) (if ... ...)))
  (if (and inherit (if ... ... t)) (org-entry-get-with-inheritance property) (if (member property org-special-properties) (cdr ...) (let ... ...)))
  (save-excursion (goto-char (or pom ...)) (if (and inherit ...) (org-entry-get-with-inheritance property) (if ... ... ...)))
  (save-excursion (if (markerp pom) (set-buffer ...)) (save-excursion (goto-char ...) (if ... ... ...)))
  (org-with-point-at pom (if (and inherit ...) (org-entry-get-with-inheritance property) (if ... ... ...)))
  org-entry-get(3 "exports" selective)
  (or (org-entry-get (point) header-arg (quote selective)) (cdr (assoc header-arg org-file-properties)))
  (let ((val ...)) (when val (cons ... val)))
  (lambda (header-arg) (let (...) (when val ...)))("exports")
  mapcar((lambda (header-arg) (let (...) (when val ...))) ("exports" "results" "session" "tangle" "var"))
  (delq nil (mapcar (lambda ... ...) (quote ...)))
  (progn (delq nil (mapcar ... ...)))
  (unwind-protect (progn (delq nil ...)) (set-match-data save-match-data-internal (quote evaporate)))
  (let ((save-match-data-internal ...)) (unwind-protect (progn ...) (set-match-data save-match-data-internal ...)))
  (save-match-data (delq nil (mapcar ... ...)))
  org-babel-params-from-properties()
  (org-babel-merge-params org-babel-default-header-args (org-babel-params-from-properties) (if (boundp lang-headers) (eval lang-headers) nil) (org-babel-parse-header-arguments (org-babel-clean-text-properties ...)))
  (list lang (with-temp-buffer (save-match-data ... ... ...)) (org-babel-merge-params org-babel-default-header-args (org-babel-params-from-properties) (if ... ... nil) (org-babel-parse-header-arguments ...)) switches)
  (let* ((lang ...) (lang-headers ...) (switches ...) (body ...) (preserve-indentation ...)) (list lang (with-temp-buffer ...) (org-babel-merge-params org-babel-default-header-args ... ... ...) switches))
  org-babel-parse-src-block-match()
  (setq info (org-babel-parse-src-block-match))
  (save-excursion (goto-char head) (setq info (org-babel-parse-src-block-match)) (forward-line -1) (when (looking-at ...) (setq info ...) (if ... ...) (unless header-vars-only ...)) info)
  (if (setq head (org-babel-where-is-src-block-head)) (save-excursion (goto-char head) (setq info ...) (forward-line -1) (when ... ... ... ...) info) (if (save-excursion ... ...) (org-babel-parse-inline-src-block-match) nil))
  (let ((case-fold-search t) head info args) (if (setq head ...) (save-excursion ... ... ... ... info) (if ... ... nil)))
  org-babel-get-src-block-info()
  (org-babel-exp-do-export (org-babel-get-src-block-info) (quote block))
  (and (re-search-backward org-babel-src-block-regexp nil t) (org-babel-exp-do-export (org-babel-get-src-block-info) (quote block)))
  (or (and (re-search-backward org-babel-src-block-regexp nil t) (org-babel-exp-do-export ... ...)) (and (re-search-backward org-block-regexp nil t) (match-string 0)) (error "Unmatched block [bug in `org-babel-exp-src-blocks']."))
  org-babel-exp-src-blocks(#("\n" 0 1 (fontified t font-lock-fontified t)) #("emacs-lisp" 0 10 (font-lock-fontified t fontified t)))
  apply(org-babel-exp-src-blocks #("\n" 0 1 (fontified t font-lock-fontified t)) #("emacs-lisp" 0 10 (font-lock-fontified t fontified t)))
  (if (memq type org-export-blocks-witheld) "" (apply func body headers))
  (progn (if (memq type org-export-blocks-witheld) "" (apply func body headers)))
  (unwind-protect (progn (if ... "" ...)) (set-match-data save-match-data-internal (quote evaporate)))
  (let ((save-match-data-internal ...)) (unwind-protect (progn ...) (set-match-data save-match-data-internal ...)))
  (save-match-data (if (memq type org-export-blocks-witheld) "" (apply func body headers)))
  (replace-match (save-match-data (if ... "" ...)) t t)
  (progn (replace-match (save-match-data ...) t t) (unless preserve-indent (indent-code-rigidly ... ... indentation)))
  (if (setq func (cadr ...)) (progn (replace-match ... t t) (unless preserve-indent ...)))
  (while (re-search-forward "^\\([ 	]*\\)#\\+begin_\\(\\S-+\\)[ 	]*\\(.*\\)?[
\n]\\([^  (progn (fset (quote interblock) (function* ...)) (goto-char (point-min)) (setq start (point)) (while (re-search-forward "^\\([ 	]*\\)#\\+begin_\\(\\S-+\\)[ 	]*\\(.*\\)?[
\n]\\([^  (unwind-protect (progn (fset ... ...) (goto-char ...) (setq start ...) (while ... ... ... ... ... ... ... ... ... ... ...) (interblock start ...)) (if --cl-letf-bound-- (fset ... --cl-letf-save--) (fmakunbound ...)))
  (let* ((--cl-letf-bound-- ...) (--cl-letf-save-- ...)) (unwind-protect (progn ... ... ... ... ...) (if --cl-letf-bound-- ... ...)))
  (letf ((... ...)) (goto-char (point-min)) (setq start (point)) (while (re-search-forward "^\\([ 	]*\\)#\\+begin_\\(\\S-+\\)[ 	]*\\(.*\\)?[
\n]\\([^  (letf* ((... ...)) (goto-char (point-min)) (setq start (point)) (while (re-search-forward "^\\([ 	]*\\)#\\+begin_\\(\\S-+\\)[ 	]*\\(.*\\)?[
\n]\\([^  (flet ((interblock ... ...)) (goto-char (point-min)) (setq start (point)) (while (re-search-forward "^\\([ 	]*\\)#\\+begin_\\(\\S-+\\)[ 	]*\\(.*\\)?[
\n]\\([^  (let ((case-fold-search t) (types ...) indentation type func start body headers preserve-indent) (flet (...) (goto-char ...) (setq start ...) (while ... ... ... ... ... ... ... ... ... ... ...) (interblock start ...)))
  (save-window-excursion (let (... ... indentation type func start body headers preserve-indent) (flet ... ... ... ... ...)))
  org-export-blocks-preprocess()
  run-hooks(org-export-preprocess-hook)
  (save-current-buffer (set-buffer (get-buffer-create " org-mode-tmp")) (erase-buffer) (insert string) (setq case-fold-search t) (org-export-kill-licensed-text) (let (...) (org-mode)) (setq case-fold-search t) (org-install-letbind) (run-hooks (quote org-export-preprocess-hook)) (org-export-preprocess-apply-macros) (run-hooks (quote org-export-preprocess-after-macros-hook)) (untabify (point-min) (point-max)) (org-export-handle-include-files) (run-hooks (quote org-export-preprocess-after-include-files-hook)) (org-export-remove-archived-trees archived-trees) (org-export-remove-comment-blocks-and-subtrees) (org-export-handle-export-tags (plist-get parameters :select-tags) (plist-get parameters :exclude-tags)) (run-hooks (quote org-export-preprocess-after-tree-selection-hook)) (org-export-repla
 ce-src-segments-and-examples backend) (org-export-protect-colon-examples) (when (plist-get parameters :footnotes) (org-footnote-normalize nil t)) (setq target-alist (org-export-define-heading-targets target-alist)) (org-export-remove-or-extract-drawers drawers (plist-get parameters :drawers) backend) (when (plist-get parameters :skip-before-1st-heading) (goto-char ...) (when ... ... ... ...)) (when (plist-get parameters :add-text) (goto-char ...) (insert ... "\n")) (org-export-remove-headline-metadata parameters) (setq target-alist (org-export-handle-invisible-targets target-alist)) (org-export-select-backend-specific-text backend) (org-export-protect-quoted-subtrees) (org-export-remove-clock-lines) (org-export-protect-verbatim) (org-export-mark-blockquote-verse-center) (run-hooks (quote
  org-export-preprocess-after-blockquote-hook)) (unless (plist-get parameters :timestamps) (org-export-remove-timestamps)) (setq target-alist (org-export-attach-captions-and-attributes backend target-alist)) (org-export-mark-radio-links) (org-export-concatenate-multiline-links) (org-export-normalize-links) (org-export-target-internal-links target-alist) (when (plist-get parameters :emph-multiline) (org-export-concatenate-multiline-emphasis)) (when org-export-table-remove-special-lines (org-export-remove-special-table-lines)) (run-hooks (quote org-export-preprocess-before-backend-specifics-hook)) (when latexp (require ... nil) (org-export-latex-preprocess parameters)) (when asciip (org-export-ascii-preprocess parameters)) (when htmlp (org-export-html-preprocess parameters)) (when docbookp 
 (require ... nil) (org-export-docbook-preprocess parameters)) (org-export-handle-comments (plist-get parameters :comments)) (run-hooks (quote org-export-preprocess-final-hook)) (setq rtn (buffer-string)))
  (with-current-buffer (get-buffer-create " org-mode-tmp") (erase-buffer) (insert string) (setq case-fold-search t) (org-export-kill-licensed-text) (let (...) (org-mode)) (setq case-fold-search t) (org-install-letbind) (run-hooks (quote org-export-preprocess-hook)) (org-export-preprocess-apply-macros) (run-hooks (quote org-export-preprocess-after-macros-hook)) (untabify (point-min) (point-max)) (org-export-handle-include-files) (run-hooks (quote org-export-preprocess-after-include-files-hook)) (org-export-remove-archived-trees archived-trees) (org-export-remove-comment-blocks-and-subtrees) (org-export-handle-export-tags (plist-get parameters :select-tags) (plist-get parameters :exclude-tags)) (run-hooks (quote org-export-preprocess-after-tree-selection-hook)) (org-export-replace-src-segmen
 ts-and-examples backend) (org-export-protect-colon-examples) (when (plist-get parameters :footnotes) (org-footnote-normalize nil t)) (setq target-alist (org-export-define-heading-targets target-alist)) (org-export-remove-or-extract-drawers drawers (plist-get parameters :drawers) backend) (when (plist-get parameters :skip-before-1st-heading) (goto-char ...) (when ... ... ... ...)) (when (plist-get parameters :add-text) (goto-char ...) (insert ... "\n")) (org-export-remove-headline-metadata parameters) (setq target-alist (org-export-handle-invisible-targets target-alist)) (org-export-select-backend-specific-text backend) (org-export-protect-quoted-subtrees) (org-export-remove-clock-lines) (org-export-protect-verbatim) (org-export-mark-blockquote-verse-center) (run-hooks (quote org-export-p
 reprocess-after-blockquote-hook)) (unless (plist-get parameters :timestamps) (org-export-remove-timestamps)) (setq target-alist (org-export-attach-captions-and-attributes backend target-alist)) (org-export-mark-radio-links) (org-export-concatenate-multiline-links) (org-export-normalize-links) (org-export-target-internal-links target-alist) (when (plist-get parameters :emph-multiline) (org-export-concatenate-multiline-emphasis)) (when org-export-table-remove-special-lines (org-export-remove-special-table-lines)) (run-hooks (quote org-export-preprocess-before-backend-specifics-hook)) (when latexp (require ... nil) (org-export-latex-preprocess parameters)) (when asciip (org-export-ascii-preprocess parameters)) (when htmlp (org-export-html-preprocess parameters)) (when docbookp (require ... 
 nil) (org-export-docbook-preprocess parameters)) (org-export-handle-comments (plist-get parameters :comments)) (run-hooks (quote org-export-preprocess-final-hook)) (setq rtn (buffer-string)))
  (let* ((htmlp ...) (asciip ...) (latexp ...) (docbookp ...) (backend ...) (archived-trees ...) (inhibit-read-only t) (drawers org-drawers) (outline-regexp "\\*+ ") target-alist rtn) (setq org-export-target-aliases nil) (setq org-export-preferred-target-alist nil) (setq org-export-code-refs nil) (with-current-buffer (get-buffer-create " org-mode-tmp") (erase-buffer) (insert string) (setq case-fold-search t) (org-export-kill-licensed-text) (let ... ...) (setq case-fold-search t) (org-install-letbind) (run-hooks ...) (org-export-preprocess-apply-macros) (run-hooks ...) (untabify ... ...) (org-export-handle-include-files) (run-hooks ...) (org-export-remove-archived-trees archived-trees) (org-export-remove-comment-blocks-and-subtrees) (org-export-handle-export-tags ... ...) (run-hooks ...) (o
 rg-export-replace-src-segments-and-examples backend) (org-export-protect-colon-examples) (when ... ...) (setq target-alist ...) (org-export-remove-or-extract-drawers drawers ... backend) (when ... ... ...) (when ... ... ...) (org-export-remove-headline-metadata parameters) (setq target-alist ...) (org-export-select-backend-specific-text backend) (org-export-protect-quoted-subtrees) (org-export-remove-clock-lines) (org-export-protect-verbatim) (org-export-mark-blockquote-verse-center) (run-hooks ...) (unless ... ...) (setq target-alist ...) (org-export-mark-radio-links) (org-export-concatenate-multiline-links) (org-export-normalize-links) (org-export-target-internal-links target-alist) (when ... ...) (when org-export-table-remove-special-lines ...) (run-hooks ...) (when latexp ... ...) (w
 hen asciip ...) (when htmlp ...) (when docbookp ... ...) (org-export-handle-comments ...) (run-hooks ...) (setq rtn ...)) (kill-buffer " org-mode-tmp") rtn)
  org-export-preprocess-string(#("\n\n#+BEGIN_SRC emacs-lisp\n\n(defun test () )\n\n#+END_SRC \n\n" 0 2 (fontified t) 2 24 (fontified t face org-meta-line font-lock-fontified t font-lock-multiline t) 24 25 (fontified t font-lock-fontified t font-lock-multiline t face org-meta-line) 25 26 (fontified t font-lock-fontified t font-lock-multiline t face org-block) 26 43 (fontified t font-lock-fontified t font-lock-multiline t face org-block :org-license-to-kill t) 43 44 (fontified t font-lock-fontified t font-lock-multiline t face org-meta-line) 44 54 (fontified t face org-meta-line font-lock-fontified t font-lock-multiline t) 54 56 (fontified t)) :emph-multiline t :for-html t :skip-before-1st-heading nil :drawers nil :todo-keywords t :tags not-in-toc :priority nil :footnotes t :timestamps t :a
 rchived-trees headline :select-tags ("export") :exclude-tags ("noexport") :add-text nil :LaTeX-fragments nil)
  (org-split-string (org-export-preprocess-string region :emph-multiline t :for-html t :skip-before-1st-heading (plist-get opt-plist :skip-before-1st-heading) :drawers (plist-get opt-plist :drawers) :todo-keywords (plist-get opt-plist :todo-keywords) :tags (plist-get opt-plist :tags) :priority (plist-get opt-plist :priority) :footnotes (plist-get opt-plist :footnotes) :timestamps (plist-get opt-plist :timestamps) :archived-trees (plist-get opt-plist :archived-trees) :select-tags (plist-get opt-plist :select-tags) :exclude-tags (plist-get opt-plist :exclude-tags) :add-text (plist-get opt-plist :text) :LaTeX-fragments (plist-get opt-plist :LaTeX-fragments)) "[
\n]")
  (let* ((opt-plist ...) (body-only ...) (style ...) (html-extension ...) (link-validate ...) valid thetoc have-headings first-heading-pos (odd org-odd-levels-only) (region-p ...) (rbeg ...) (rend ...) (subtree-p ...) (level-offset ...) (opt-plist ...) (org-current-export-dir ...) (org-current-export-file buffer-file-name) (level 0) (line "") (origline "") txt todo (umax nil) (umax-toc nil) (filename ...) (current-dir ...) (buffer ...) (org-levels-open ...) (date ...) (author ...) (title ...) (link-up ...) (link-home ...) (dummy ...) (html-table-tag ...) (quote-re0 ...) (quote-re ...) (inquote nil) (infixed nil) (inverse nil) (in-local-list nil) (local-list-type nil) (local-list-indent nil) (llt org-plain-list-ordered-item-terminator) (email ...) (language ...) (keywords ...) (description 
 ...) (lang-words nil) ...) (let (...) (org-unmodified ...)) (message "Exporting...") (setq org-min-level (org-get-min-level lines level-offset)) (setq org-last-level org-min-level) (org-init-section-numbers) (cond (... ...) (date) (t ...)) (setq lang-words (or ... ...)) (set-buffer buffer) (let (...) (erase-buffer)) (fundamental-mode) (org-install-letbind) (and (fboundp ...) (set-buffer-file-coding-system coding-system-for-write)) (let (... ...) (mapc ... org-export-plist-vars) (setq umax ...) (setq umax-toc ...) (unless body-only ... ... ...) (if ... ...) (setq head-count 0) (org-init-section-numbers) (org-open-par) (while ... ...) (when inquote ... ...) (when in-local-list ... ...) (org-html-level-start 1 nil umax ... head-count) (when ... ...) (save-excursion ... ...) (when footnotes 
 ...) (let ... ...) (unless body-only ... ... ... ...) (unless ... ... ...) (goto-char ...) (when thetoc ... ... ... ...) (goto-char ...) (while ... ...) (goto-char ...) (while ... ...) (goto-char ...) (while ... ...) (goto-char ...) (let ... ...) (run-hooks ...) (or to-buffer ...) (goto-char ...) (or ... ...) (if ... ... ...)))
  org-export-as-html(nil)
  call-interactively(org-export-as-html)
  (if (and bg (nth 2 ass) (not ...) (not ...)) (let (...) (set-process-sentinel p ...) (message "Background process \"%s\": started" p)) (call-interactively (nth 1 ass)))
  (let* ((bg ...) (help "[t]   insert the export option template\n[v]   limit export to visible part of outline tree\n\n[a] export as ASCII   [A] to temporary buffer\n\n[h] export as HTML    [H] to temporary buffer   [R] export region\n[b] export as HTML and open in browser\n\n[l] export as LaTeX   [L] to temporary buffer\n[p] export as LaTeX and process to PDF\n[d] export as LaTeX, process to PDF, and open the resulting PDF document\n\n[D] export as DocBook\n[V] export as DocBook, process to PDF, and open the resulting PDF document\n\n[m] export as Freemind mind map\n\n[x] export as XOXO\n[g] export using Wes Hardaker's generic exporter\n\n[i] export current file as iCalendar file\n[I] export all agenda files as iCalendar files\n[c] export agenda files into combined iCalendar file\n\n[F] 
 publish current file          [P] publish current project\n[X] publish a project...          [E] publish every projects") (cmds ...) r1 r2 ass) (save-excursion (save-window-excursion ... ... ... ... ...)) (setq r2 (if ... ... r1)) (unless (setq ass ...) (error "No command associated with key %c" r1)) (if (and bg ... ... ...) (let ... ... ...) (call-interactively ...)))
  org-export(nil)
  call-interactively(org-export nil nil)

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: [babel] Bug: Export code block before first heading
  2009-11-21  2:05 [babel] Bug: Export code block before first heading Andreas Burtzlaff
@ 2009-11-21  2:40 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2009-11-21  2:40 UTC (permalink / raw)
  To: Andreas Burtzlaff; +Cc: emacs-orgmode

Hi Andreas,

Thanks for catching this bug, It should now be fixed in the HEAD of the
git repo.

Best -- Eric

Andreas Burtzlaff <andy13@gmx.net> writes:

> Exporting a file with a source block before the first heading, like:
>
> #+BEGIN_SRC emacs-lisp
>
> ...
>
> #+END_SRC 
>
> to html yields the error 
> "Before first headline at position 3 in buffer  org-mode-tmp"
>
> A backtrace is attached.
>
> Andreas
>
> Emacs  : GNU Emacs 23.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.16.6)
>  of 2009-11-18 on fluxx
> Package: Org-mode version 6.33f (release_6.33f.16.ge103)
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2009-11-21  2:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-21  2:05 [babel] Bug: Export code block before first heading Andreas Burtzlaff
2009-11-21  2:40 ` 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).