Subject: 24.4; copy-file-locals-to-dir-locals generates malformed expression

From: Alain Kalker <[email-masked]>
Date: Mon, 10 Nov 2014 02:12:40 +0100

Short description: M-x copy-file-locals-to-dir-locals generates
".dir-locals.el" containing a malformed expression.  The syntax of the
expression doesn't match the documentation, and although it appears to
work well for variables with simple values, using more complex
expressions often results in errors when visiting files in the directory.

Steps to reproduce:

* Ensure that directory "~/tmp" exists
* Create test file: `C-x C-f ~/tmp/test-local-vars.c`
 Add local variable: `M-x add-file-local-variable <RET> tab-width <RET>
 4 <RET>`
* Buffer contents now should be:
---cut here---
/* Local Variables: */
/* tab-width: 4 */
/* End: */
---cut here---
* Save buffer: `C-x C-s`
* Revert buffer as instructed: `M-x revert-buffer`
* M-x copy-file-locals-to-dir-locals <RET>
* Buffer ".dir-locals.el" created with contents:
---cut here---
((c-mode
  (tab-width . 4)))
---cut here---
* Note that the expression doesn't conform to the syntax described in
the documentation "49.2.5 Per-Directory Local Variables".
* (If installed, Flycheck will report an error: Invalid function: (c-mode
(tab-width . 4))
* Save directory locals file: `C-x C-s`
* Switch back to test file: `C-x b test-local-vars.c <RET>`
* Edit buffer to remove local variables block
* Save buffer: `C-x C-s`
* Revert buffer to apply directory local variables: `M-x revert-buffer
<RET>`
* Note that Emacs does not report any errors about the malformed expression.

In GNU Emacs 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.3)
 of 2014-10-21 on bitzer.hoetzel.info
Windowing system distributor `The X.Org Foundation', version 11.0.11601000
System Description:	Arch Linux

Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  delete-selection-mode: t
  yas-global-mode: t
  show-paren-mode: t
  global-flycheck-mode: t
  cua-mode: t
  global-auto-complete-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o r t - e m a <tab> <return>

Recent messages:
[yas] Prepared just-in-time loading for ~/.emacs.d/snippets
[yas] Reloaded everything (snippets will load just-in-time)....
[yas] Loading for `lisp-interaction-mode', just-in-time: (lambda nil (yas--load-directory-1 (quote /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/lisp-interaction-mode) (quote lisp-interaction-mode)))!
[yas] Loading compiled snippets from /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/lisp-interaction-mode
[yas] Loading for `emacs-lisp-mode', just-in-time: (lambda nil (yas--load-directory-1 (quote /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/emacs-lisp-mode) (quote emacs-lisp-mode)))!
[yas] Loading compiled snippets from /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/emacs-lisp-mode
[yas] Loading for `prog-mode', just-in-time: (lambda nil (yas--load-directory-1 (quote /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/prog-mode) (quote prog-mode)))!
[yas] Loading compiled snippets from /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/prog-mode
Loading /home/miki/.emacs.d/elpa/yasnippet-20141102.1554/snippets/prog-mode/.yas-setup...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
/usr/share/emacs/site-lisp/SuperCollider/tree-widget hides /usr/share/emacs/24.4/lisp/tree-widget

Features:
(shadow sort gnus-util mail-extr emacsbug message idna cl-macs
format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils advice eldoc help-fns imenu
.emacs tsdh-dark-theme delsel yasnippet cl gv paren flycheck find-func
help-mode rx pcase subr-x dash cua-base cus-start cus-load ix grapnel
flymake compile comint ansi-color ring auto-complete-clang-async
auto-complete-config auto-complete edmacro kmacro popup cl-loaddefs
cl-lib ac-cider-autoloads info easymenu pkg-info-autoloads epl-autoloads
queue-autoloads sly-autoloads popup-autoloads package epg-config
time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind gfilenotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)

Memory information:
((conses 16 138761 8646)
 (symbols 48 24706 0)
 (miscs 40 81 115)
 (strings 32 29397 5044)
 (string-bytes 1 843125)
 (vectors 16 16816)
 (vector-slots 8 504577 7812)
 (floats 8 412 77)
 (intervals 56 215 0)
 (buffers 960 13)
 (heap 1024 44346 1095))