1

我在 lisp 中构造了这样的函数:

(defun set-web-hosting (hosting)
 """ this function sets the hosting of web to specific tramp like target """
(setq org-publish-project-alist
    '(
      ("belohrad.ch-notes"
       :base-directory "~/SVN/fiweb/"
       :base-extension "org"
   :publishing-directory hosting
       :recursive t
       :publishing-function org-publish-org-to-html
       :headline-levels 999
       :table-of-contents nil
       :section-numbers nil
       :auto-preamble t
       :auto-sitemap t
       :auto-postamble nil
       :style ""
       :sitemap-filename "sitemap.org"
       :sitemap-title "Sitemap"
       :sub-superscript nil
       :author "David Belohrad"
       :email "david@belohrad.ch"
       )
      ("belohrad.ch-static"
       :base-directory "~/SVN/fiweb"
       :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|deb"
   :publishing-directory hosting
       :recursive t
       :publishing-function org-publish-attachment
       )
      ("web" :components ("belohrad.ch-static" "belohrad.ch-notes"))
      )))

想,我可以用

(set-web-hosting "~/afs/www/org/")

将我的目标设置到提到的测试目录,以及

(set-web-hosting ".ssh:nlanla@nlsnls.org:/public_html/")

将其设置为生活网。

这不起作用,因为函数中的“托管”不被视为变量,而是“其他东西”。调用发布时,它以

org-publish-file: Wrong type argument: arrayp, hosting

如何正确设置:publishing-directory属性?

4

1 回答 1

4

使用 lisp 代码、反引号和逗号进行操作有一个特殊的习惯用法:

`(a ,b c)

(describe-function '\`)

你的设置是:

(defun set-web-hosting (hosting)
  " this function sets the hosting of web to specific tramp like target "
  (eval `(setq org-publish-project-alist
           '(
         ("belohrad.ch-notes"
          :base-directory "~/SVN/fiweb/"
          :base-extension "org"
          :publishing-directory ,hosting
          :recursive t
          :publishing-function org-publish-org-to-html
          :headline-levels 999
          :table-of-contents nil
          :section-numbers nil
          :auto-preamble t
          :auto-sitemap t
          :auto-postamble nil
          :style ""
          :sitemap-filename "sitemap.org"
          :sitemap-title "Sitemap"
          :sub-superscript nil
          :author "David Belohrad"
          :email "david@belohrad.ch"
          )
         ("belohrad.ch-static"
          :base-directory "~/SVN/fiweb"
          :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|deb"
          :publishing-directory ,hosting
          :recursive t
          :publishing-function org-publish-attachment
          )
         ("web" :components ("belohrad.ch-static" "belohrad.ch-notes"))
         ))))
于 2013-01-17T14:46:39.620 回答