首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elisp,alist和strings.类型混淆

Elisp,alist和strings.类型混淆
EN

Stack Overflow用户
提问于 2012-02-26 00:15:52
回答 1查看 1.9K关注 0票数 4

我试图将一个org-project发布为html,并使用以下org项目定义实现任务的自动化:

代码语言:javascript
复制
(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)之类的东西,但它也抱怨错误的类型参数。我能用什么来完成这件事?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-26 00:54:52

问题是,引用(setq org-publish-project-alist '(...))中的第二个参数意味着列表结构中的任何内容都不会被计算。换句话说,Emacs告诉您,值(concat home "org")不是字符串:实际上,它是一个由三个元素组成的列表(如果对其进行评估,就会给出一个字符串)。

一种可能的解决方法可能是使用“反向引用”或“准引用”机制,这与quote'类似,但允许您使用,,@选择性地拼接计算出来的Lisp代码。(有关详细信息,请参阅信息手册中的(elisp)Backquote )。因此,您可以将上面的代码更改为

代码语言:javascript
复制
(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)以获得详细的回溯。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9449364

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档