I've put "the code" in a branch in our repo, called 'scratch/add-lisp-data'.
It's also after my sig.
and sets it for dir-locals. The seconds sets it for 5 or 6 files. Thanks Juri
instead of "emacs-lisp-data-mode". There's probably details I'm more than
in a place there, or not doing that setcar or those setf nth.
Anyway, I hope we can now talk about concrete stuff.
commit 035137bc92ec4b3ceab43409d4b8ea0deb975459
Author: João Távora <
joaotavora@gmail.com>
Date: Sat Apr 18 09:04:13 2020 +0100
Use lisp-data-mode in 5 more places
Thanks to Juri Linkov and Basil L. Contovounesios for the list and the
indication of the function that needed to be changed.
* lisp/bookmark.el (bookmark-insert-file-format-version-stamp):
Use lisp-data-mode.
* lisp/saveplace.el (save-place-alist-to-file): Use
lisp-data-mode.
* lisp/net/eww.el (eww-write-bookmarks): Use lisp-data-mode.
* lisp/net/nsm.el (nsm-write-settings): Use lisp-data-mode.
* lisp/net/tramp-cache.el (tramp-dump-connection-properties): Use
lisp-data-mode.
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 720ad18c16..f2384973e9 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -734,8 +734,10 @@ bookmark-insert-file-format-version-stamp
(if (memq (coding-system-base coding) '(undecided prefer-utf-8))
(setq coding 'utf-8-emacs))
(insert
- (format ";;;; Emacs Bookmark Format Version %d ;;;; -*- coding: %S -*-\n"
- bookmark-file-format-version (coding-system-base coding)))
+ (format
+ ";;;; Emacs Bookmark Format Version %d\
+;;;; -*- coding: %S mode: lisp-data -*-\n"
+ bookmark-file-format-version (coding-system-base coding)))
(insert ";;; This format is meant to be slightly human-readable;\n"
";;; nevertheless, you probably don't want to edit it.\n"
";;; "
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index c83884fd25..a4544023f6 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1733,7 +1733,7 @@ eww-add-bookmark
(defun eww-write-bookmarks ()
(with-temp-file (expand-file-name "eww-bookmarks" eww-bookmarks-directory)
- (insert ";; Auto-generated file; don't edit\n")
+ (insert ";; Auto-generated file; don't edit -*- mode: lisp-data -*-\n")
(pp eww-bookmarks (current-buffer))))
(defun eww-read-bookmarks ()
diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index 2d36c5e257..cc22427e6d 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -964,6 +964,7 @@ nsm-save-host
(defun nsm-write-settings ()
(with-temp-file nsm-settings-file
+ (insert ";;;; -*- mode: lisp-data -*-\n")
(insert "(\n")
(dolist (setting nsm-permanent-host-settings)
(insert " ")
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 09e30f000f..6d87ce297b 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -472,7 +472,7 @@ tramp-dump-connection-properties
;; Dump it.
(with-temp-file tramp-persistency-file-name
(insert
- ";; -*- emacs-lisp -*-"
+ ";; -*- lisp-data -*-"
;; `time-stamp-string' might not exist in all Emacs flavors.
(condition-case nil
(progn
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index fa0e181bb1..f78639db24 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -248,7 +248,7 @@ save-place-alist-to-file
(delete-region (point-min) (point-max))
(when save-place-forget-unreadable-files
(save-place-forget-unreadable-files))
- (insert (format ";;; -*- coding: %s -*-\n"
+ (insert (format ";;; -*- coding: %s mode: lisp-data -*-\n"
(symbol-name coding-system-for-write)))
(let ((print-length nil)
(print-level nil))
commit b4af4a3578303741364dc91acdd5908d9b11e3a4
Author: João Távora <
joaotavora@gmail.com>
Date: Sat Apr 18 02:46:04 2020 +0100
Add a lisp-data-mode for editing non-code lisp data
To provide a cleaner implementation remove arguments from the
auxiliary routine lisp-mode-variables. The modes/functions that need
to do some something special adjustment do them in their own bodies.
* lisp/chistory.el (command-history-mode): Don't pass nil to
lisp-mode-variables.
* lisp/files.el (auto-mode-alist): Add entry for ".dir-locals".
* lisp/help-fns.el (describe-variable): Don't pass useless args to
lisp-mode-variables.
* lisp/emacs-lisp/pp.el (pp-to-string): Don't pass useless args to
lisp-mode-variables.
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-variables):
Simplify. Always set same variables.
(lisp-data-mode): New major mode.
(lisp-mode): Inherit from lisp-data-mode. Set special lisp-mode
stuff here.
* lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Inherit from
lisp-data-mode.
(emacs-lisp-mode): Simplify.
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode): Set the needed
syntax table here, not through other function.
diff --git a/lisp/chistory.el b/lisp/chistory.el
index c9aa927b94..485515d07b 100644
--- a/lisp/chistory.el
+++ b/lisp/chistory.el
@@ -139,7 +139,7 @@ command-history-mode
Keybindings:
\\{command-history-mode-map}"
- (lisp-mode-variables nil)
+ (lisp-mode-variables)
(set (make-local-variable 'revert-buffer-function) 'command-history-revert)
(set-syntax-table emacs-lisp-mode-syntax-table))
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 3b0f5493ee..8f7e6c0431 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -611,15 +611,8 @@ lisp-adaptive-fill
;; a single docstring. Let's fix it here.
(if (looking-at "\\s-+\"[^\n\"]+\"\\s-*$") ""))
-(defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive
- elisp)
- "Common initialization routine for lisp modes.
-The LISP-SYNTAX argument is used by code in inf-lisp.el and is
-\(uselessly) passed from pp.el, chistory.el, gnus-kill.el and
-score-mode.el. KEYWORDS-CASE-INSENSITIVE non-nil means that for
-font-lock keywords will not be case sensitive."
- (when lisp-syntax
- (set-syntax-table lisp-mode-syntax-table))
+(defun lisp-mode-variables ()
+ "Common initialization routine for lisp modes."
(setq-local paragraph-ignore-fill-prefix t)
(setq-local fill-paragraph-function 'lisp-fill-paragraph)
(setq-local adaptive-fill-function #'lisp-adaptive-fill)
@@ -643,21 +636,24 @@ lisp-mode-variables
(setq-local multibyte-syntax-as-symbol t)
;; (setq-local syntax-begin-function 'beginning-of-defun) ;;Bug#16247.
(setq font-lock-defaults
- `(,(if elisp '(lisp-el-font-lock-keywords
- lisp-el-font-lock-keywords-1
- lisp-el-font-lock-keywords-2)
- '(lisp-cl-font-lock-keywords
- lisp-cl-font-lock-keywords-1
- lisp-cl-font-lock-keywords-2))
- nil ,keywords-case-insensitive nil nil
- (font-lock-mark-block-function . mark-defun)
- (font-lock-extra-managed-props help-echo)
- (font-lock-syntactic-face-function
- . lisp-font-lock-syntactic-face-function)))
+ (list nil nil nil nil nil
+ '(font-lock-mark-block-function . mark-defun)
+ '(font-lock-extra-managed-props help-echo)
+ '(font-lock-syntactic-face-function
+ . lisp-font-lock-syntactic-face-function)))
(setq-local prettify-symbols-alist lisp-prettify-symbols-alist)
(setq-local electric-pair-skip-whitespace 'chomp)
(setq-local electric-pair-open-newline-between-pairs nil))
+;;;###autoload
+(define-derived-mode lisp-data-mode prog-mode "Lisp-Data"
+ "Major mode for buffers holding data written in Lisp syntax."
+ :group 'lisp
+ (lisp-mode-variables)
+ (set-syntax-table lisp-mode-syntax-table)
+ (setq-local electric-quote-string t)
+ (setq imenu-case-fold-search nil))
+
(defun lisp-outline-level ()
"Lisp mode `outline-level' function."
(let ((len (- (match-end 0) (match-beginning 0))))
@@ -737,7 +733,7 @@ lisp-mode-map
"Keymap for ordinary Lisp mode.
All commands in `lisp-mode-shared-map' are inherited by this map.")
-(define-derived-mode lisp-mode prog-mode "Lisp"
+(define-derived-mode lisp-mode lisp-data-mode "Lisp"
"Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
Commands:
Delete converts tabs to spaces as it moves back.
@@ -746,7 +742,11 @@ lisp-mode
\\{lisp-mode-map}
Note that `run-lisp' may be used either to start an inferior Lisp job
or to switch back to an existing one."
- (lisp-mode-variables nil t)
+ (setf
+ (nth 0 font-lock-defaults) '(lisp-cl-font-lock-keywords
+ lisp-cl-font-lock-keywords-1
+ lisp-cl-font-lock-keywords-2)
+ (nth 2 font-lock-defaults) t)
(setq-local lisp-indent-function 'common-lisp-indent-function)
(setq-local find-tag-default-function 'lisp-find-tag-default)
(setq-local comment-start-skip
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index 3df7b0e368..4d8bf52934 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -42,7 +42,7 @@ pp-to-string
OBJECT can be any Lisp object. Quoting characters are used as needed
to make output that `read' can handle, whenever this is possible."
(with-temp-buffer
- (lisp-mode-variables nil)
+ (lisp-mode-variables)
(set-syntax-table emacs-lisp-mode-syntax-table)
(let ((print-escape-newlines pp-escape-newlines)
(print-quoted t))
diff --git a/lisp/files.el b/lisp/files.el
index fa72e51c49..a769d061f9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -2657,6 +2657,9 @@ auto-mode-alist
("\\.ltx\\'" . latex-mode)
("\\.dtx\\'" . doctex-mode)
("\\.org\\'" . org-mode)
+ ;; .dir-locals.el is not really elisp. Can't use the
+ ;; `dir-locals-file' constant since that is defined below.
+ (".dir-locals.el" . lisp-data-mode)
("\\.el\\'" . emacs-lisp-mode)
("Project\\.ede\\'" . emacs-lisp-mode)
("\\.\\(scm\\|stk\\|ss\\|sch\\)\\'" . scheme-mode)
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 0a99b8d6a3..dbf2cb807b 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1000,7 +1000,7 @@ describe-variable
(terpri)
(let ((buf (current-buffer)))
(with-temp-buffer
- (lisp-mode-variables nil)
+ (lisp-mode-variables)
(set-syntax-table emacs-lisp-mode-syntax-table)
(insert print-rep)
(pp-buffer)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index f85fd771ca..2f231781ba 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -250,7 +250,7 @@ elisp--dynlex-modeline-map
map))
;;;###autoload
-(define-derived-mode emacs-lisp-mode prog-mode
+(define-derived-mode emacs-lisp-mode lisp-data-mode
`("ELisp"
(lexical-binding (:propertize "/l"
help-echo "Using lexical-binding mode")
@@ -268,35 +268,26 @@ emacs-lisp-mode
\\{emacs-lisp-mode-map}"
:group 'lisp
(defvar project-vc-external-roots-function)
- (lisp-mode-variables nil nil 'elisp)
+ (setcar font-lock-defaults
+ '(lisp-el-font-lock-keywords
+ lisp-el-font-lock-keywords-1
+ lisp-el-font-lock-keywords-2))
+ (set-syntax-table emacs-lisp-mode-syntax-table)
(add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers)
(if (boundp 'electric-pair-text-pairs)
(setq-local electric-pair-text-pairs
(append '((?\` . ?\') (?\‘ . ?\’))
electric-pair-text-pairs))
(add-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs))
- (setq-local electric-quote-string t)
- (setq imenu-case-fold-search nil)
(add-hook 'eldoc-documentation-functions
#'elisp-eldoc-documentation-function nil t)
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
(add-hook 'completion-at-point-functions
#'elisp-completion-at-point nil 'local)
- ;; .dir-locals.el and lock files will cause the byte-compiler and
- ;; checkdoc emit spurious warnings, because they don't follow the
- ;; conventions of Emacs Lisp sources. Until we have a better fix,
- ;; like teaching elisp-mode about files that only hold data
- ;; structures, we disable the ELisp Flymake backend for these files.
- (unless
- (let* ((bfname (buffer-file-name))
- (fname (and (stringp bfname) (file-name-nondirectory bfname))))
- (and (stringp fname)
- (or (string-match "\\`\\.#" fname)
- (string-equal dir-locals-file fname))))
- (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
- (add-hook 'flymake-diagnostic-functions
- #'elisp-flymake-byte-compile nil t)))
+ (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
+ (add-hook 'flymake-diagnostic-functions
+ #'elisp-flymake-byte-compile nil t))
;; Font-locking support.
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index 9f34a377f4..aa6c718041 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -274,7 +274,8 @@ inferior-lisp-mode
to continue it."
(setq comint-prompt-regexp inferior-lisp-prompt)
(setq mode-line-process '(":%s"))
- (lisp-mode-variables t)
+ (set-syntax-table lisp-mode-syntax-table)
+ (lisp-mode-variables)
(setq comint-get-old-input (function lisp-get-old-input))
(setq comint-input-filter (function lisp-input-filter)))