0

I have a working setup with ox-publish and now i am trying to organize it. My problem is that i cannot assign a variable to the keyword-symbols like in the snippet below.

(setq my-org-base-dir "~/documents/todo")
(setq my-org-exp-dir "~/documents/todo_html")
(require 'ox-publish)
(setq org-publish-project-alist
  '(
    ("org-notes"
     :base-directory my-org-base-dir
     :base-extension "org"
      ; ....
     )
    ("org-static"
     :base-directory my-org-base-dir
      ; ....
     )
    ("org" :components ("org-notes" "org-static"))
    ))

Using :base-directory "~/documents/todo" works just fine but if i try to use the value from a variable (:base-directory my-org-base-dir) emacs gives me Wrong type argument: stringp, org-base-dir when i try to export.

How do i assign a value to a Keyword?

user3637541
  • 675
  • 4
  • 15

2 Answers2

1

When you do

(setq org-publish-project-alist '( ... ))

you're setting the value of org-publish-project-alist to a literal list. It's not that you can't "assign a value to a keyword [argument]", it's that quotation of a list prevents evaluation of variables within it. E.g.,

(let ((a 1) (b 2) (c 3))
  (setq foo '(a b c)))
;=> (a b c)               
; *not* (1 2 3)

To get the variables "interpolated" you either need to use list to construct the list, or use a backquote so that you can splice in the values. E.g.,

(setq org-publish-project-alist
  `(                                    ;; backquote (`), not quote (')
    ("org-notes"
     :base-directory ,my-org-base-dir   ;; comma (,) to splice value in
     :base-extension "org"
      ; ....
     )
    ("org-static"
     :base-directory ,my-org-base-dir   ;; comma (,)
      ; ....
     )
    ("org" :components ("org-notes" "org-static"))
    ))
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
0

Edit: I think I may have misunderstood the question. This answers the question in the title, but doesn't look like it's the issue that the OP is running into.

You can't assign a value to a keyword. From the Emacs Lisp manual (emphasis added):

11.2 Variables that Never Change

In Emacs Lisp, certain symbols normally evaluate to themselves. These include nil and t, as well as any symbol whose name starts with ‘:’ (these are called keywords). These symbols cannot be rebound, nor can their values be changed. Any attempt to set or bind nil or t signals a setting-constant error. The same is true for a keyword (a symbol whose name starts with ‘:’), if it is interned in the standard obarray, except that setting such a symbol to itself is not an error.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Yes, you are right, i misunderstood the problem, that is why the tilte is missleading. Thx for the answer though. – user3637541 May 27 '16 at 21:40