emacsorphanage / ox-pandoc

Another org-mode exporter via pandoc.
GNU General Public License v2.0
46 stars 13 forks source link

Export via org-dispatcher fails while M-x org-pandoc-export-... works as expected #32

Closed emwal closed 9 months ago

emwal commented 9 months ago

Expected behaviour: Exporting org-buffer viaorg-export-dispatch and p (pandoc) + l (to latex-pdf and open) should produce the same results as M-x org-pandoc-export-to-latex-pdf-and-open.

Observed behaviour: M-x org-pandoc-export-to-latex-pdf-and-open. works flawlessly, while org-export-dispatch fails with "Symbol’s value as variable is void: org-pandoc-options-for-nil" (or at least I think this is the relevant part. The error message is way longer.).

Does anybody have a solution for this? Thank you for your help!

Org-Version: Org mode version 9.7-pre (release_9.6.13-986-g31caf8 Ox-pandoc version: 20230627.643 Pandoc version: 3.1.6, Features: +server +lua, Scripting engine: Lua 5.4

yantar92 commented 9 months ago

Please provide the full error message.

emwal commented 9 months ago

Full error message of a document with following content:

#+TITLE: Pandoc Export Test

This is a test.

Error message

Power off-line, battery discharging (48% load, remaining time 2:08)
[yas] Prepared just-in-time loading of snippets successfully.
Function provided is already compiled
Function provided is already compiled
Function provided is already compiled
Function provided is already compiled
Function provided is already compiled
Function provided is already compiled
Function provided is already compiled
Function provided is already compiled
ATTENTION: org-noter-pdf has many featues that depend on the package ‘pdf-tools’
ATTENTION: org-noter-nov needs the package ‘nov’
ATTENTION: org-noter-djvu needs the package ‘djvu’

Error: void-variable (org-pandoc-options-for-nil)
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode 0x10357d03c5ae8692>))
  debug-early-backtrace()
  debug-early(error (void-variable org-pandoc-options-for-nil))
  org-pandoc-template(#("This is a test.\n" 0 15 (:parent (paragraph (:standard-properties [31 31 31 47 47 0 nil nil nil nil nil nil nil nil #<buffer  *temp*-882635> nil nil (section (:standard-properties [1 1 1 47 47 0 nil first-section nil nil nil 1 47 nil #<buffer  *temp*-882635> nil nil (org-data (:standard-properties [1 1 1 47 47 0 nil org-data nil nil nil 3 47 nil #<buffer  *temp*-882635> nil nil nil] :path "/home/redacted/tmp/pandoc_test.org" :CATEGORY "pandoc_test") #8)]) (keyword (:standard-properties [1 1 nil nil 31 2 nil top-comment nil nil nil nil nil nil #<buffer  *temp*-882635> nil nil #8] :key "TITLE" :value "Pandoc Export Test")) #3)]) #("This is a test.\n" 0 16 (:parent #3))))) (:export-options nil :back-end #s(org-export-backend :name pandoc :parent org :transcoders ((entity . org-pandoc-entity) (export-block . org-pandoc-export-block) (export-snippet . org-pandoc-export-snippet) (latex-environment . org-pandoc-latex-environ) (link . org-pandoc-link) (paragraph . org-pandoc-paragraph) (src-block . org-pandoc-src-block) (table . org-pandoc-table) (template . org-pandoc-template)) :options ((:pandoc-options "PANDOC_OPTIONS" nil nil space) (:pandoc-extensions "PANDOC_EXTENSIONS" nil nil space) (:pandoc-metadata "PANDOC_METADATA" nil nil space) (:pandoc-variables "PANDOC_VARIABLES" nil nil space) (:epub-chapter-level "EPUB_CHAPTER_LEVEL" nil nil t) (:epub-cover-image "EPUB_COVER" nil nil t) (:epub-stylesheet "EPUB_STYLESHEET" nil nil t) (:epub-embed-font "EPUB_EMBED_FONT" nil nil newline) (:epub-meta "EPUB_META" nil nil newline) (:epub-css "EPUB_CSS" nil nil newline) (:epub-rights "EPUB_RIGHTS" nil nil newline) (:bibliography "BIBLIOGRAPHY")) :filters nil :blocks nil :menu (112 "export via pandoc" ((52 "to html5 and open." org-pandoc-export-to-html5-and-open) (36 "as html5." org-pandoc-export-as-html5) (53 "to html5-pdf and open." org-pandoc-export-to-html5-pdf-and-open) (37 "to html5-pdf." org-pandoc-export-to-html5-pdf) (61 "to ms-pdf and open." org-pandoc-export-to-ms-pdf-and-open) (45 "to ms-pdf." org-pandoc-export-to-ms-pdf) (98 "to beamer-pdf and open." org-pandoc-export-to-beamer-pdf-and-open) (66 "to beamer-pdf." org-pandoc-export-to-beamer-pdf) (100 "to docbook5 and open." org-pandoc-export-to-docbook5-and-open) (68 "as docbook5." org-pandoc-export-as-docbook5) (103 "to gfm and open." org-pandoc-export-to-gfm-and-open) (71 "as gfm." org-pandoc-export-as-gfm) (104 "to html4 and open." org-pandoc-export-to-html4-and-open) (72 "as html4." org-pandoc-export-as-html4) (106 "to json and open." org-pandoc-export-to-json-and-open) (74 "as json." org-pandoc-export-as-json) (108 "to latex-pdf and open." org-pandoc-export-to-latex-pdf-and-open) (76 "to latex-pdf." org-pandoc-export-to-latex-pdf) (109 "to man and open." org-pandoc-export-to-man-and-open) (77 "as man." org-pandoc-export-as-man) (110 "to native and open." org-pandoc-export-to-native-and-open) (78 "as native." org-pandoc-export-as-native) (111 "to odt and open." org-pandoc-export-to-odt-and-open) (79 "to odt." org-pandoc-export-to-odt) (112 "to pptx and open." org-pandoc-export-to-pptx-and-open) (80 "to pptx." org-pandoc-export-to-pptx) (114 "to rtf and open." org-pandoc-export-to-rtf-and-open) (82 "as rtf." org-pandoc-export-as-rtf) (120 "to docx and open." org-pandoc-export-to-docx-and-open) (88 "to docx." org-pandoc-export-to-docx)))) :translate-alist ((entity . org-pandoc-entity) (export-block . org-pandoc-export-block) (export-snippet . org-pandoc-export-snippet) (latex-environment . org-pandoc-latex-environ) (link . org-pandoc-link) (paragraph . org-pandoc-paragraph) (src-block . org-pandoc-src-block) (table . org-pandoc-table) (template . org-pandoc-template) (babel-call . org-org-identity) (bold . org-org-identity) (center-block . org-org-identity) (clock . org-org-identity) (code . org-org-identity) (diary-sexp . org-org-identity) (drawer . org-org-identity) (dynamic-block . org-org-identity) (entity . org-org-identity) (example-block . org-org-identity) (export-block . org-org-export-block) (fixed-width . org-org-identity) (footnote-definition . ignore) (footnote-reference . org-org-identity) (headline . org-org-headline) (horizontal-rule . org-org-identity) (inline-babel-call . org-org-identity) (inline-src-block . org-org-identity) (inlinetask . org-org-identity) (italic . org-org-identity) (item . org-org-identity) (keyword . org-org-keyword) (latex-environment . org-org-identity) (latex-fragment . org-org-identity) (line-break . org-org-identity) (link . org-org-link) (node-property . org-org-identity) (template . org-org-template) (paragraph . org-org-identity) (plain-list . org-org-identity) (planning . org-org-identity) (property-drawer . org-org-identity) (quote-block . org-org-identity) (radio-target . org-org-identity) (section . org-org-section) (special-block . org-org-identity) (src-block . org-org-identity) (statistics-cookie . org-org-identity) (strike-through . org-org-identity) (subscript . org-org-identity) (superscript . org-org-identity) (table . org-org-identity) (table-cell . org-org-identity) (table-row . org-org-identity) (target . org-org-identity) (timestamp . org-org-timestamp) (underline . org-org-identity) (verbatim . org-org-identity) (verse-block . org-org-identity)) :exported-data #<hash-table eq 5/4001 0x1586c515be41> :input-buffer " *temp*" :input-file "/home/redacted/tmp/pandoc_test.org" :pandoc-options nil :pandoc-extensions nil :pandoc-metadata nil :pandoc-variables nil :epub-chapter-level nil :epub-cover-image nil :epub-stylesheet nil :epub-embed-font nil :epub-meta nil :epub-css nil :epub-rights nil :bibliography nil :title (#("Pandoc Export Test" 0 18 (:parent #38))) :date nil :author (#("redacted" 0 13 (:parent #42))) :email "redacted@redacted.com" :language "en" :select-tags ("export") :exclude-tags ("noexport") :creator "Emacs 29.1 (Org mode 9.7-pre)" :headline-levels 3 :preserve-breaks nil :section-numbers t :time-stamp-file t :with-archived-trees headline :with-author t :expand-links t :with-broken-links nil :with-clocks nil :with-creator nil :with-date t :with-drawers (not "LOGBOOK") :with-email nil :with-emphasize t :with-entities t :with-fixed-width t :with-footnotes t :with-inlinetasks t :with-latex t :with-planning nil :with-priority nil :with-properties nil :with-smart-quotes nil :with-special-strings t :with-statistics-cookies t :with-sub-superscript t :with-toc t :with-tables t :with-tags t :with-tasks t :with-timestamps t :with-title t :with-todo-keywords t :cite-export (basic nil nil) :output-file "pandoc_test.tmpiJST0E.org" :filter-body nil :filter-bold nil :filter-babel-call nil :filter-center-block nil :filter-clock nil :filter-code nil :filter-diary-sexp nil :filter-drawer nil :filter-dynamic-block nil :filter-entity nil :filter-example-block nil :filter-export-block nil :filter-export-snippet nil :filter-final-output nil :filter-fixed-width nil :filter-footnote-definition nil :filter-footnote-reference nil :filter-headline nil :filter-horizontal-rule nil :filter-inline-babel-call nil :filter-inline-src-block nil :filter-inlinetask nil :filter-italic nil :filter-item nil :filter-keyword nil :filter-latex-environment nil :filter-latex-fragment nil :filter-line-break nil :filter-link nil :filter-node-property nil :filter-options nil :filter-paragraph nil :filter-parse-tree (org-org--add-missing-sections org-export-ignore-headlines) :filter-plain-list nil :filter-plain-text nil :filter-planning nil :filter-property-drawer nil :filter-quote-block nil :filter-radio-target nil :filter-section nil :filter-special-block nil :filter-src-block nil :filter-statistics-cookie nil :filter-strike-through nil :filter-subscript nil :filter-superscript nil :filter-table nil :filter-table-cell nil :filter-table-row nil :filter-target nil :filter-timestamp nil :filter-underline nil :filter-verbatim nil :filter-verse-block nil :ignore-list nil :parse-tree (org-data (:standard-properties [1 1 1 47 47 0 nil org-data nil nil nil 3 47 nil #<buffer  *temp*-882635> nil nil nil] :path "/home/redacted/tmp/pandoc_test.org" :CATEGORY "pandoc_test") (section (:standard-properties [1 1 1 47 47 0 nil first-section nil nil nil 1 47 nil #<buffer  *temp*-882635> nil nil #234]) (keyword (:standard-properties [1 1 nil nil 31 2 nil top-comment nil nil nil nil nil nil #<buffer  *temp*-882635> nil nil #237] :key "TITLE" :value "Pandoc Export Test")) (paragraph (:standard-properties [31 31 31 47 47 0 nil nil nil nil nil nil nil nil #<buffer  *temp*-882635> nil nil #237]) #("This is a test.\n" 0 16 (:parent #241))))) :headline-offset 0 :headline-numbering nil :id-alist nil :citations nil))
  org-export-as(pandoc nil nil nil (:output-file "pandoc_test.tmpiJST0E.org"))
  (let ((output (org-export-as 'pandoc nil nil nil '(:output-file "pandoc_test.tmpiJST0E.org")))) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert output) (if (bolp) nil (insert "\n")) (let ((coding-system-for-write 'utf-8-unix)) (write-region nil nil "pandoc_test.tmpiJST0E.org"))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (or (condition-case nil (progn (funcall '#f(compiled-function (f) #<bytecode -0x14203792ccac0316>) "pandoc_test.tmpiJST0E.org")) (error nil)) "pandoc_test.tmpiJST0E.org"))
  (print (let ((output (org-export-as 'pandoc nil nil nil '(:output-file "pandoc_test.tmpiJST0E.org")))) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert output) (if (bolp) nil (insert "\n")) (let ((coding-system-for-write 'utf-8-unix)) (write-region nil nil "pandoc_test.tmpiJST0E.org"))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (or (condition-case nil (progn (funcall '#f(compiled-function (f) #<bytecode -0x14203792ccac0316>) "pandoc_test.tmpiJST0E.org")) (error nil)) "pandoc_test.tmpiJST0E.org")))
  (progn nil (progn (setq kill-emacs-hook nil) (setq org-babel-confirm-evaluate-answer-no t)) (require 'ox) (funcall '#f(compiled-function () #<bytecode 0x1a4d330de95ef65a>)) (restore-buffer-modified-p nil) (print (let ((output (org-export-as 'pandoc nil nil nil '(:output-file "pandoc_test.tmpiJST0E.org")))) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert output) (if (bolp) nil (insert "\n")) (let ((coding-system-for-write 'utf-8-unix)) (write-region nil nil "pandoc_test.tmpiJST0E.org"))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (or (condition-case nil (progn (funcall '#f(compiled-function (f) #<bytecode -0x14203792ccac0316>) "pandoc_test.tmpiJST0E.org")) (error nil)) "pandoc_test.tmpiJST0E.org"))))
  (unwind-protect (progn nil (progn (setq kill-emacs-hook nil) (setq org-babel-confirm-evaluate-answer-no t)) (require 'ox) (funcall '#f(compiled-function () #<bytecode 0x1a4d330de95ef65a>)) (restore-buffer-modified-p nil) (print (let ((output (org-export-as 'pandoc nil nil nil '(:output-file "pandoc_test.tmpiJST0E.org")))) (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert output) (if (bolp) nil (insert "\n")) (let ((coding-system-for-write 'utf-8-unix)) (write-region nil nil "pandoc_test.tmpiJST0E.org"))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (or (condition-case nil (progn (funcall '#f(compiled-function (f) #<bytecode -0x14203792ccac0316>) "pandoc_test.tmpiJST0E.org")) (error nil)) "pandoc_test.tmpiJST0E.org")))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn nil (progn (setq kill-emacs-hook nil) (setq org-babel-confirm-evaluate-answer-no t)) (require 'ox) (funcall '#f(compiled-function () #<bytecode 0x1a4d330de95ef65a>)) (restore-buffer-modified-p nil) (print (let ((output (org-export-as 'pandoc nil nil nil '(:output-file "pandoc_test.tmpiJST0E.org")))) (let ((temp-buffer (generate-n

Hope, it helps! Thank you!

yantar92 commented 9 months ago

It does not look like a full message. You can try M-x toggle-debug-on-error. Then, the backtrace should appear in a separate window, where you can copy it from in full.

emwal commented 9 months ago

M-x toggle-debug-on-error does not trigger. My Messages buffer looks like this.

Debug on Error enabled globally
Initializing asynchronous export process
Process ‘org-export-process’ exited abnormally
Debug on Error disabled globally

Note the asynchronous export process instead of the synchronous. I set org-export-async-debug to t and tried again with the same result.

emwal commented 9 months ago

And org-pandoc-menu-entry has the following value:

((52 "to html5 and open." org-pandoc-export-to-html5-and-open)
 (36 "as html5." org-pandoc-export-as-html5)
 (53 "to html5-pdf and open." org-pandoc-export-to-html5-pdf-and-open)
 (37 "to html5-pdf." org-pandoc-export-to-html5-pdf)
 (61 "to ms-pdf and open." org-pandoc-export-to-ms-pdf-and-open)
 (45 "to ms-pdf." org-pandoc-export-to-ms-pdf)
 (98 "to beamer-pdf and open." org-pandoc-export-to-beamer-pdf-and-open)
 (66 "to beamer-pdf." org-pandoc-export-to-beamer-pdf)
 (100 "to docbook5 and open." org-pandoc-export-to-docbook5-and-open)
 (68 "as docbook5." org-pandoc-export-as-docbook5)
 (103 "to gfm and open." org-pandoc-export-to-gfm-and-open)
 (71 "as gfm." org-pandoc-export-as-gfm)
 (104 "to html4 and open." org-pandoc-export-to-html4-and-open)
 (72 "as html4." org-pandoc-export-as-html4)
 (106 "to json and open." org-pandoc-export-to-json-and-open)
 (74 "as json." org-pandoc-export-as-json)
 (108 "to latex-pdf and open." org-pandoc-export-to-latex-pdf-and-open)
 (76 "to latex-pdf." org-pandoc-export-to-latex-pdf)
 (109 "to man and open." org-pandoc-export-to-man-and-open)
 (77 "as man." org-pandoc-export-as-man)
 (110 "to native and open." org-pandoc-export-to-native-and-open)
 (78 "as native." org-pandoc-export-as-native)
 (111 "to odt and open." org-pandoc-export-to-odt-and-open)
 (79 "to odt." org-pandoc-export-to-odt)
 (112 "to pptx and open." org-pandoc-export-to-pptx-and-open)
 (80 "to pptx." org-pandoc-export-to-pptx)
 (114 "to rtf and open." org-pandoc-export-to-rtf-and-open)
 (82 "as rtf." org-pandoc-export-as-rtf)
 (120 "to docx and open." org-pandoc-export-to-docx-and-open)
 (88 "to docx." org-pandoc-export-to-docx))
emwal commented 9 months ago

I set org-export-in-background to nil and it worked as expected. Apparently the error is with the asynchronous export.

yantar92 commented 9 months ago

Thanks for investiating! I can see how it is a problem.