* Why no setq, eval in a dir-locals?
@ 2022-02-11 10:57 Colin Baxter 😺
2022-02-11 11:22 ` irek
0 siblings, 1 reply; 3+ messages in thread
From: Colin Baxter 😺 @ 2022-02-11 10:57 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
To backup tex files in the same working directory, I have a .dir-locals
file containing the following lines:
#+begin_src emacs-lisp
((latex-mode . (
(kept-old-versions . 2)
(kept-new-versions . 16)
(delete-old-versions . t)
(make-backup-files . t)
(version-control . t)
)))
#+end_src
It works well.
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.
Thank you.
Best wishes,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Why no setq, eval in a dir-locals?
2022-02-11 10:57 Why no setq, eval in a dir-locals? Colin Baxter 😺
@ 2022-02-11 11:22 ` irek
2022-02-11 12:01 ` Colin Baxter
0 siblings, 1 reply; 3+ messages in thread
From: irek @ 2022-02-11 11:22 UTC (permalink / raw)
To: Colin Baxter 😺; +Cc: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Why no setq, eval in a dir-locals?
2022-02-11 11:22 ` irek
@ 2022-02-11 12:01 ` Colin Baxter
0 siblings, 0 replies; 3+ messages in thread
From: Colin Baxter @ 2022-02-11 12:01 UTC (permalink / raw)
To: irek; +Cc: help-gnu-emacs
Thank you for your reply.
>>>>> irek <mail@gumen.pl> writes:
> 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.
> (backup-directory-alist . (("." . "sub-directory/")))
I did originally have that line ... or at least I thought I did! That
line appeared not to work which is why I was puzzled and went on to use
eval setq. I can only assume that I originally inserted a typo
somewhere.
All is now working satisfactorily.
Thank you for your help. Next time I'll double check for typos.
Best wishes,
Colin Baxter.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-11 12:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-11 10:57 Why no setq, eval in a dir-locals? Colin Baxter 😺
2022-02-11 11:22 ` irek
2022-02-11 12:01 ` Colin Baxter
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.