[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why no setq, eval in a dir-locals?
From: |
irek |
Subject: |
Re: Why no setq, eval in a dir-locals? |
Date: |
Fri, 11 Feb 2022 12:22:03 +0100 |
Colin Baxter 😺 <m43cap@yandex.com> writes:
> I am curious though as to why I do not seem to need "setq" and "eval"
> terms. These are needed however if I wish to put the backups in a
> sub-directory:
>
> #+begin_src emacs-lisp
> ((latex-mode . (
> (eval setq backup-directory-alist '(("." . "sub-directory/")))
> (kept-old-versions . 2)
> (kept-new-versions . 16)
> ,,, etc.
> #+end_src
>
> This too works well.
>
> Can anyone tell me why the two cases appear to be different.
.dir-locals is not elisp file that gets evaluated like init.el file that
holds your Emacs configuration. .dir-locals hold (variable like) value.
It describes in what context (latex-mode in this example), what variable
(for example kept-old-versions) what value should be assigned (in case
of kept-old-versions in latex-mode in your example it's 2).
You can't put regular elisp code inside .dir-locals like `defun',
`setq', `global-set-key' etc. But if you need then you can use `eval'
keyword. Code after `eval' is evaluated so you can put any valid elisp
expression after it `eval'.
Not sure why do you assume that `eval setq' is required for
`backup-directory-alist' variable. It should work the same way as you
did for other variables. Provide variable name, period and value.
((latex-mode . (
(backup-directory-alist . (("." . "sub-directory/")))
(kept-old-versions . 2)
(kept-new-versions . 16))))
You can read info page (info "(emacs) Directory Variables") for better
understanding.