[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Two problems with directory-local variables
From: |
Juri Linkov |
Subject: |
Re: Two problems with directory-local variables |
Date: |
Thu, 20 Sep 2018 01:38:35 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) |
>>> On this note, while I don't use the commands myself, I've often wished
>>> that add-dir-local-variable would generate the dotted-pair syntax,
>>> because I've often seen confusion about the syntax of dir-locals arising
>>> from dotted vs non-dotted possibilities, and I feel strongly that the
>>> dotted syntax is the most readable for these files.
>
> Agreed. We should probably have a `print-alist` kind of function for
> that purpose and then try and make use of it from add-dir-local-variable.
>
>> I don't know if something exists that could allow printing dotted syntax for
>>
>> (pp-to-string '(eval message "hello"))
>>
>> In its implementation I see the references to print-escape-newlines
>> and print-quoted, but there is no print-dotted.
>
> I don't think we could add a print-dotted because as you say we don't
> want (eval . (message . ("hello" . nil))) and only the human coder can
> know which cons cell should be printed dotted and which shouldn't.
Examples in (info "(emacs) Directory Variables") recommend dotted syntax
for alists on the first level:
((nil . ((indent-tabs-mode . t)
(fill-column . 80)))
(c-mode . ((c-file-style . "BSD")
(subdirs . nil))))
as well as for the second level:
(("src/imported"
. ((nil . ((change-log-default-name
. "ChangeLog.local"))))))
Taking into account the original problematic case with `eval',
dotted alist should be also on the third level:
(("src/imported"
. ((nil . ((eval
. (message "hello")))))))
Given that, I don't see what would be a good choice for generalization:
1. Since requirements for this feature are too vague, it doesn't seem
to fit well into low-level printing functions.
2. Reformatting the printed output in pp-buffer to add dots where necessary
also doesn't look like an elegant solution.
3. Implementing print-alist poses a question how to define at which levels
to print alists with dotted syntax.
4. Since only add-dir-local-variable knows the semantics of used data
structures, the simplest way would be to implement printing of each level
explicitly in add-dir-local-variable.
- Two problems with directory-local variables, Marcin Borkowski, 2018/09/17
- Re: Two problems with directory-local variables, Phil Sainty, 2018/09/17
- Re: Two problems with directory-local variables, Marcin Borkowski, 2018/09/17
- Re: Two problems with directory-local variables, Juri Linkov, 2018/09/17
- Re: Two problems with directory-local variables, Phil Sainty, 2018/09/17
- Re: Two problems with directory-local variables, Juri Linkov, 2018/09/17
- Re: Two problems with directory-local variables, Stefan Monnier, 2018/09/17
- Re: Two problems with directory-local variables,
Juri Linkov <=
- RE: Two problems with directory-local variables, Drew Adams, 2018/09/19
- Re: Two problems with directory-local variables, Juri Linkov, 2018/09/20