elisp 脚本将 org 转换为 html 报错 (wrong-type-argument stringp nil)

我使用 elisp 脚本批量转化 org 为 html(用于 github pages),
脚本如下(在github):

(require 'org)
(setq org-publish-project-alist
      '(("org-pages"
         :base-directory "."
         :base-extension "org"
         :publishing-directory "./.."
         :recursive t
         :publishing-function org-html-export-to-html
         )))

(defun myweb-publish ()
     "Publish myweb."
     (interactive)
     (setq debug-on-error t)
     (org-publish-all))
(myweb-publish)

结果命令行询问 Output File,
我输入之后就报错: Wrong type argument: stringp, nil

求助

应该是导出函数用错了

换成org-html-publish-to-html就好了

1 个赞

在原版 emacs 里没有 :frowning:

image

这org自带的呀。

你的org-mode version是多少?

执行命令 M-x toggle-debug-on-error 打开调试功能,报错时会弹出堆栈,再看是哪里报错的。

哦你已经打开了,那在哪报错的?

org 9.4 emacs 27.2

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  make-process(:name "org-export-process" :buffer "*Org Export Process*" :command ("/usr/bin/emacs" "--batch" "-l" nil "-l" "/tmp/org-export-processYXonEa"))
  apply(make-process (:name "org-export-process" :buffer "*Org Export Process*" :command ("/usr/bin/emacs" "--batch" "-l" nil "-l" "/tmp/org-export-processYXonEa")))
  start-process("org-export-process" "*Org Export Process*" "/usr/bin/emacs" "--batch" "-l" nil "-l" "/tmp/org-export-processYXonEa")
  apply(start-process ("org-export-process" "*Org Export Process*" "/usr/bin/emacs" "--batch" "-l" nil "-l" "/tmp/org-export-processYXonEa"))
  org-export-to-file(html "abc.html" (:base-directory "." :base-extension "org" :publishing-directory "./.." :recursive t :publishing-function org-html-export-to-html) "/home/digua/git/dongdigua.github.io/org/cheatsheet..." "/home/digua/git/dongdigua.github.io/" nil nil)
  org-html-export-to-html((:base-directory "." :base-extension "org" :publishing-directory "./.." :recursive t :publishing-function org-html-export-to-html) "/home/digua/git/dongdigua.github.io/org/cheatsheet..." "/home/digua/git/dongdigua.github.io/")
  org-publish-file("/home/digua/git/dongdigua.github.io/org/cheatsheet..." ("org-pages" :base-directory "." :base-extension "org" :publishing-directory "./.." :recursive t :publishing-function org-html-export-to-html) t)
  org-publish-projects((("org-pages" :base-directory "." :base-extension "org" :publishing-directory "./.." :recursive t :publishing-function org-html-export-to-html)))
  org-publish-all()
  myweb-publish()
  funcall-interactively(myweb-publish)
  call-interactively(myweb-publish nil nil)
  command-execute(myweb-publish)
  command-line-1(("--eval" "(load-file \"publish_config.el\")" "-f" "myweb-publish"))
  command-line()
  normal-top-level()

那不可能没有,它和org-html-export-to-html都在ox-html.el里,你再仔细看看,或者require一下。

啊找到了, 得(require 'ox)