我正在尝试将组织项目发布为 html,并使用以下组织项目定义自动执行该任务:
(defconst home (file-name-directory (or load-file-name buffer-file-name)))
(require 'org-publish)
(setq org-publish-project-alist
'(
;; add all the components here
;; *notes* - publishes org files to html
("org-notes"
:base-directory (concat home "org/")
:base-extension "org" ; Filename suffix without dot
:publishing-directory (concat home "../public_html/")
:recursive t ; includes subdirectories
:publishing-function org-publish-org-to-html
:headline-levels 4 ; Just the default for this project.
:auto-preamble t
:auto-sitemap t ; generate automagically
:sitemap-filename "sitemap.org"
:sitemap-title "Sitemap"
)
;; *static* - copies files to directories
("org-static"
:base-directory (concat home "org/")
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory (concat home "../public_html/")
:recursive t
:publishing-function org-publish-attachment
)
;; *publish* with M-x org-publish-project RET emacsclub RET
("emacsclub" :components ("org-notes" "org-static"))
))
但是,在导出项目时,我收到错误
错误的类型参数:stringp, (concat home "org")
从 Elisp 的角度来看,到底发生了什么? concat的输出不是字符串吗?在这种情况下为什么会失败?我尝试 stringp
它本身与 concat 参数一起返回 true。
我试图完成的其他事情是在评估此文件时导出整个项目。我尝试过类似的事情
(命令执行组织发布全部)
但它也抱怨类型参数错误。我可以用什么来完成这件事?
问题是引用第二个参数(setq org-publish-project-alist '(...))
意味着该列表结构中的任何内容都不会被评估。换句话说,Emacs 告诉你这个值(concat home "org")
不是字符串:实际上它是一个包含三个元素的列表(如果对其求值,将给出一个字符串)。
一种可能的解决方法可能是使用“反引号”或“准引号”机制,就像quote
or '
但允许您使用以下方法有选择地拼接已评估的 Lisp 代码位,
and ,@
. (See (elisp)Backquote
有关更多详细信息,请参阅信息手册)。因此,您可以将上面的代码更改为类似的内容
(setq org-publish-project-alist
`( ; note ` instead of '
("org-notes"
;; Note commas , in front of code to evaluate
:base-directory ,(concat home "org/")
:base-extension "org"
:publishing-directory ,(concat home "../public_html/")
....
请注意,当(setq ...)
评估表单:换句话说,如果您需要这些值针对不同的项目目录动态更改,这对您没有帮助。但既然你定义了home
作为一个常数也许这并不重要?
PS:如果您需要更详细地了解您的位置wrong-type-argument
错误来自,尝试做M-x toggle-debug-on-error
或评估(setq debug-on-error t)
以获得详细的回溯。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)