我试图将一个org-project发布为html,并使用以下org项目定义实现任务的自动化:
(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 "org")
从伊莉斯的角度看,到底是怎么回事?这不是一个字符串的输出吗?在这种情况下,为什么会失败呢?我尝试使用concat参数自己使用stringp,然后返回true。
我要做的另一件事是,在评估该文件时,将整个项目导出。我尝试过(命令-执行、org-publish)之类的东西,但它也抱怨错误的类型参数。我能用什么来完成这件事?
发布于 2012-02-26 00:54:52
问题是,引用(setq org-publish-project-alist '(...))中的第二个参数意味着列表结构中的任何内容都不会被计算。换句话说,Emacs告诉您,值(concat home "org")不是字符串:实际上,它是一个由三个元素组成的列表(如果对其进行评估,就会给出一个字符串)。
一种可能的解决方法可能是使用“反向引用”或“准引用”机制,这与quote或'类似,但允许您使用,和,@选择性地拼接计算出来的Lisp代码。(有关详细信息,请参阅信息手册中的(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)以获得详细的回溯。
https://stackoverflow.com/questions/9449364
复制相似问题