Subject: bug#40573: 27.0.90; flymake-mode broken in scratch buffer

From: Juri Linkov <[email-masked]>
Date: Tue, 14 Apr 2020 02:17:11 +0300

> As I said in that old discussion, I'm not opposed to such a mode, if
> it supports more than just running Flymake in .dir-locals.el.  If you
> have a bunch of other files for which such a mode could be useful,
> please describe the files, their names or other telltale indications
> (to be used for turning on this mode), and their special needs that
> distinguish them from ELisp source files.  Also, if you have some
> wishes for commands special to such files, or how the behavior of the
> existing commands should differ in such files, please tell that as
> well.

All files in http://git.savannah.nongnu.org/cgit/ee.git/tree/view
are ELisp data files.  They contain Lisp data lists including
alists with some code in lambdas.  Here is an example from
http://git.savannah.nongnu.org/cgit/ee.git/tree/view/buffers.ee

 [((type . view)
   (name . "by Recency/list-buffers")
   (description . "emulates the default display of function `list-buffers'")
   (r-filter . (lambda (r)
    (let ((buffer-name (ee-field 'buffer-name r)))
      (not (or (and (> (length buffer-name) 0) (eq (aref buffer-name 0) ?\040))
               (equal (ee-buffers-buffer-name) buffer-name))))))

These files need font-locking from emacs-lisp-mode for viewing, and other
features of emacs-lisp-mode for editing: indentation, commenting, etc.
i.e. everything from emacs-lisp-mode except code evaluation.  This is
one difference between emacs-lisp-data-mode and emacs-lisp-mode.

Another difference is that distinction between dynamic/lexical binding
makes no sense for ELisp data files.  It's wrong to use "ELisp/d" as
a mode name for ELisp data files where "/d" indicates dynamic binding.

A new mode could help to solve these problems, so ELisp data files could
enable emacs-lisp-data-mode regardless of their file extension. e.g.
http://git.savannah.nongnu.org/cgit/ee.git/tree/ee-datafile.el
currently assigns emacs-lisp-mode:

  (add-to-list 'auto-mode-alist '("\\.ee\\'" . emacs-lisp-mode))

but could use emacs-lisp-data-mode instead:

  (add-to-list 'auto-mode-alist '("\\.ee\\'" . emacs-lisp-data-mode))

There are many other examples of ELisp data files.  One is already
mentioned .dir-locals.el that needs editing features from
emacs-lisp-mode (indentation, commenting, ...) as well,
but doesn't need the dynamic/lexical distinction.

More ELisp data files can be found in ~/.emacs.d/
Here are some examples with short excerpts:

1. ~/.emacs.d/elpa/archives/gnu/archive-contents

  (ace-window .
              [(0 9 0)
               ((avy
                 (0 2 0)))
               "Quickly switch windows." single
               ((:keywords "window" "location")

2. ~/.emacs.d/bookmarks

  ;;;; Emacs Bookmark Format Version 1 ;;;; -*- coding: utf-8-emacs -*-
  ;;; This format is meant to be slightly human-readable;
  ;;; nevertheless, you probably don't want to edit it.
  ;;; -*- End Of Bookmark File Format Version Stamp -*-

3. ~/.emacs.d/tramp

  ;; -*- emacs-lisp -*-
  ;; Tramp connection history.  Don't change this file.
  ;; Run `M-x tramp-cleanup-all-connections' instead.

4. ~/.emacs.d/places

All these data files have one difference from ELisp code files:
they are not loaded with evaluation.  For example, code that reads
~/.emacs.d/places looks like

        (let ((file (expand-file-name save-place-file)))
          (if (file-readable-p file)
              (with-current-buffer (get-buffer-create " *Saved Places*")
                (delete-region (point-min) (point-max))
                (insert-file-contents file)

They all could benefit from a dedicated emacs-lisp-data-mode.