kawabata / ox-pandoc

Another org-mode exporter via pandoc.
276 stars 46 forks source link

Unable to modify org-pandoc-menu-entry #84

Open mnsanghvi opened 2 years ago

mnsanghvi commented 2 years ago

When I use the Export Dispatcher using C-c C-e I do not see the menu entries for what I have enabled. I only see the default value in the dispatcher menu list. Even when I do (setq org-pandoc-menu-entry nil), I still see the defaul menu entries for ox-pandoc. Am I doing something incorrectly ?

(emacs-version)
"GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
 of 2021-03-27"
(org-release)
"9.4.6"
(org-git-version)
"9.4.6-13-g4be129-elpaplus"

I have the following setup for ox-pandoc

(use-package ox-pandoc
  :after org
  :init
  (with-eval-after-load 'org (require 'ox-pandoc))
  (add-to-list 'org-pandoc-menu-entry '(?q "to commonmark and open." org-pandoc-export-to-commonmark-and-open))
  (add-to-list 'org-pandoc-menu-entry '(?Q "as commonmark." org-pandoc-export-as-commonmark))
  ;; :config
  (setq org-pandoc-options '((standalone . t)))
  (setq org-pandoc-options-for-latex-pdf '((pdf-engine . "tectonic")
                                           (pdf-engine-opt . "--keep-logs:--keep-intermediates")))
  ;; org-pandoc has a lot of menu entries disabled. Enable them by adding them here
  ;; (setq org-pandoc-menu-entry nil)
  ;; (with-eval-after-load 'ox (require 'ox-pandoc))
  )

I have tried using :init as well as using :config for the use-package stanza above. In neither case does it work. I have commented out code that I have tried using but did not yield expected results.

Output of C-h v org-pandoc-menu-entry

((81 "as commonmark." org-pandoc-export-as-commonmark)
 (113 "to commonmark and open." org-pandoc-export-to-commonmark-and-open)
 (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)
 (60 "to slideous and open." org-pandoc-export-to-slideous-and-open)
 (44 "as slideous." org-pandoc-export-as-slideous)
 (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)
 (99 "to context-pdf and open." org-pandoc-export-to-context-pdf-and-open)
 (67 "to context-pdf." org-pandoc-export-to-context-pdf)
 (100 "to docbook5 and open." org-pandoc-export-to-docbook5-and-open)
 (68 "as docbook5." org-pandoc-export-as-docbook5)
 (101 "to epub3 and open." org-pandoc-export-to-epub3-and-open)
 (69 "to epub3." org-pandoc-export-to-epub3)
 (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)
 (105 "to icml and open." org-pandoc-export-to-icml-and-open)
 (73 "as icml." org-pandoc-export-as-icml)
 (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)
 (117 "to dokuwiki and open." org-pandoc-export-to-dokuwiki-and-open)
 (85 "as dokuwiki." org-pandoc-export-as-dokuwiki)
 (118 "to revealjs and open." org-pandoc-export-to-revealjs-and-open)
 (86 "as revealjs." org-pandoc-export-as-revealjs)
 (119 "to mediawiki and open." org-pandoc-export-to-mediawiki-and-open)
 (87 "as mediawiki." org-pandoc-export-as-mediawiki)
 (120 "to docx and open." org-pandoc-export-to-docx-and-open)
 (88 "to docx." org-pandoc-export-to-docx)
 (121 "to slidy and open." org-pandoc-export-to-slidy-and-open)
 (89 "as slidy." org-pandoc-export-as-slidy)
 (122 "to dzslides and open." org-pandoc-export-to-dzslides-and-open)
 (90 "as dzslides." org-pandoc-export-as-dzslides))
cilinder commented 1 year ago

Same problem. If I try org-pandoc-export-to-latex-pdf I get the message: org-export-barf-if-invalid-backend: Unknown "nil" back-end: Aborting export.

The debug trace I get is

Debugger entered--Lisp error: (error "Unknown \"nil\" back-end: Aborting export")
  error("Unknown \"%s\" back-end: Aborting export" nil)
  org-export-barf-if-invalid-backend(nil)
  org-export-as(pandoc nil nil nil (:output-file "20221010141137-domain_specific_type_theory_for_fin..."))
  org-export-to-file(pandoc "20221010141137-domain_specific_type_theory_for_fin..." nil nil nil nil nil #f(compiled-function (f) #<bytecode -0x1420d39f899a4f56>))
  org-pandoc-export(latex-pdf nil nil nil nil nil)
  org-pandoc-export-to-latex-pdf()
  (debug (org-pandoc-export-to-latex-pdf))
  eval-expression((debug (org-pandoc-export-to-latex-pdf)) nil nil 127)
  funcall-interactively(eval-expression (debug (org-pandoc-export-to-latex-pdf)) nil nil 127)
  command-execute(eval-expression)

My ox-pandoc config is:

(use-package ox-pandoc
  :ensure t
  :after org
  :config 
  (with-eval-after-load 'ox
    (require 'ox-pandoc)))
ag91 commented 10 months ago

A workaround is to add

(org-export-define-derived-backend 'pandoc 'org
    :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))
    ;; :export-block "PANDOC"
    :menu-entry
    `(?p "export via pandoc"
         ,org-pandoc-menu-entry)
    :options-alist
    '((: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")))

after you set org-pandoc-menu-entry in your :config section.

The issue is that

    `(?p "export via pandoc"
         ,org-pandoc-menu-entry)

is effectively "inlining" the value of the defcustom, so changing its value has no effect. An easy fix in the code is to use a function that access that value instead of inlining the variable.