Subject: bug#32817: 27.0.50; Dotted pair syntax for directory-local variables

From: Juri Linkov <[email-masked]>
Date: Tue, 25 Sep 2018 22:41:51 +0300

>> +(defun add-dir-local-variables-to-string (variables)
>
> `add-dir-local-variables-to-string' is quite a confusing name.
> It makes it sound like the dir-local variables will be added to
> a string (which doesn't make a lot of sense), when it's actually
> formatting all of the dir-locals *as* a string.
>
> This is on account of the "add-" prefix, which I think is unnecessary
> -- the functionality isn't really tied to `add-dir-local-variable';
> it would work regardless of where its argument came from.
>
> `dir-locals-to-string' seems a better name to me, and is consistent
> with other dir-locals-* functions.

My intention was to use this prefix to add the new function
to the add-dir-local-variable* namespace.  But I agree that
dir-locals-* is more suitable, so I renamed the function.

>> +  (format "(%s)" (mapconcat
>> +                  (lambda (mode-variable)
>
> "mode-variables" (plural), I think.

Fixed as well.

>> +                    (format "(%S . %s)"
>> +                            (car mode-variable)
>> +                            (format "(%s)" (mapconcat
>> +                                            (lambda (variable-value)
>> +                                              (format "(%s . %S)"
>> +                                                      (car variable-value)
>
> Why is the variable symbol "%s" when the mode symbol was "%S" ?

The mode symbol is "%S" to support string values of a subdirectory like
"src/imported" in the example in (info "(emacs) Directory Variables")
But admittedly add-dir-local-variable doesn't support adding 3 levels
subdirectory-mode-variables anyway, it could be used only to create
an initial subdirectory-variable-value to allow the user adding mode
manually.  But for any case I changed the variable symbol "%s" to "%S".