;;; /tmp/test/.dir-locals.el ((auto-mode-alist . (("/\\.dir-locals\\(-2\\)?\\.el\\'" . lisp-data-mode) ("/[^/-][^/]*\\.el\\'" . emacs-lisp-mode)))) I use emacs -Q to visit file /tmp/test/.dir-locals.el, then Emacs chooses emacs-lisp-mode for this file.
What goes wrong? Why not lisp-data-mode?
GNU Emacs Lisp Reference Manual says that the variable auto-mode-alist uses the first match, so I think the pseudo-variable (I don't what is a pseudo-variable; I heard it from phils, seems like a good name) auto-mode-alist in ".dir-locals.el" should also do that, for consistency.
GNU Emacs Manual, 49.2.5 Per-Directory Local Variables:
The special key
auto-mode-alistin a.dir-locals.el... works much like the variableauto-mode-alist(see Choosing File Modes).
GNU Emacs Lisp Reference Manual, 24.2.2 How Emacs Chooses a Major Mode:
If
auto-mode-alisthas more than one element whose regexp matches the file name, Emacs will use the first match.
However, it seems that the current behavior of dir local auto-mode-alist is to choose a mode from back to front.
The reverse order is so contrary to perception.
lisp-data-mode. IOW, say what you say in your bug report, vis a vis the behavior difference betweenauto-mode-alistand entryauto-mode-alistin dir-locals.