[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/add-lisp-data-mode e95703c: Don't mess with lisp-mode-variables
From: |
João Távora |
Subject: |
scratch/add-lisp-data-mode e95703c: Don't mess with lisp-mode-variables |
Date: |
Sun, 19 Apr 2020 16:17:58 -0400 (EDT) |
branch: scratch/add-lisp-data-mode
commit e95703c2db48d5f5ce465e2cf2b9a3165f8ecb2b
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Don't mess with lisp-mode-variables
* doc/lispref/modes.texi (Example Major Modes): Update example to
match reality.
* lisp/chistory.el (command-history-mode): Revert previous change.
* lisp/help-fns.el (describe-variable): Revert previous change.
* lisp/emacs-lisp/lisp-mode.el (lisp-mode-variables): Rvert previous change.
(lisp-data-mode): Use full form of lisp-mode-variables for clarity.
(lisp-mode): Simplify.
* lisp/emacs-lisp/pp.el (pp-to-string): Revert previous change.
* lisp/progmodes/elisp-mode.el (emacs-lisp-mode): Case sensitive
font-lock keywords.
* lisp/progmodes/inf-lisp.el (inferior-lisp-mode): Revert previous
change.
---
doc/lispref/modes.texi | 17 ++++-------------
lisp/chistory.el | 2 +-
lisp/emacs-lisp/lisp-mode.el | 36 ++++++++++++++++++++++--------------
lisp/emacs-lisp/pp.el | 2 +-
lisp/help-fns.el | 2 +-
lisp/progmodes/elisp-mode.el | 2 +-
lisp/progmodes/inf-lisp.el | 2 +-
7 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index df7458c..6dd1e8a 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1352,20 +1352,12 @@ illustrate how these modes are written.
@end smallexample
The three modes for Lisp share much of their code. For instance,
-each calls the following function to set various variables:
-
-@smallexample
-@group
-(defun lisp-mode-variables ()
- "Common initialization routine for lisp modes."
- (setq-local paragraph-ignore-fill-prefix t)
- @dots{}
-@end group
-@end smallexample
+Lisp mode and Emacs Lisp mode inherit from Lisp Data mode and Lisp
+Interaction Mode inherits from Emacs Lisp mode.
@noindent
-Amongst other things, this function sets up the @code{comment-start}
-variable to handle Lisp comments:
+Amongst other things, Lisp Data mode calls a function to setds up the
+@code{comment-start} variable to handle Lisp comments:
@smallexample
@group
@@ -1425,7 +1417,6 @@ Note that `run-lisp' may be used either to start an
inferior Lisp job
or to switch back to an existing one."
@end group
@group
- (lisp-mode-variables)
(setq-local find-tag-default-function 'lisp-find-tag-default)
(setq-local comment-start-skip
"\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
diff --git a/lisp/chistory.el b/lisp/chistory.el
index 485515d..c9aa927 100644
--- a/lisp/chistory.el
+++ b/lisp/chistory.el
@@ -139,7 +139,7 @@ The buffer is left in Command History mode."
Keybindings:
\\{command-history-mode-map}"
- (lisp-mode-variables)
+ (lisp-mode-variables nil)
(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 13263f2..30cf7d7 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -611,10 +611,17 @@ Value for `adaptive-fill-function'."
;; a single docstring. Let's fix it here.
(if (looking-at "\\s-+\"[^\n\"]+\"\\s-*$") ""))
-(defun lisp-mode-variables (&rest ignored)
+;; Maybe this should be discouraged/obsoleted and users should be
+;; encouraged to use `lisp-data-mode` instead.
+(defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive
+ elisp)
"Common initialization routine for lisp modes.
-Any number of parameters is accepted and ignored."
- (set-syntax-table lisp-mode-syntax-table)
+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))
(setq-local paragraph-ignore-fill-prefix t)
(setq-local fill-paragraph-function 'lisp-fill-paragraph)
(setq-local adaptive-fill-function #'lisp-adaptive-fill)
@@ -638,11 +645,17 @@ Any number of parameters is accepted and ignored."
(setq-local multibyte-syntax-as-symbol t)
;; (setq-local syntax-begin-function 'beginning-of-defun) ;;Bug#16247.
(setq font-lock-defaults
- (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)))
+ `(,(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)))
(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))
@@ -651,7 +664,7 @@ Any number of parameters is accepted and ignored."
(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)
+ (lisp-mode-variables t t nil)
(setq-local electric-quote-string t)
(setq imenu-case-fold-search nil))
@@ -743,11 +756,6 @@ Blank lines separate paragraphs. Semicolons start
comments.
\\{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."
- (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 4d8bf52..3df7b0e 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -42,7 +42,7 @@
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)
+ (lisp-mode-variables nil)
(set-syntax-table emacs-lisp-mode-syntax-table)
(let ((print-escape-newlines pp-escape-newlines)
(print-quoted t))
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index dbf2cb8..0a99b8d 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1000,7 +1000,7 @@ it is displayed along with the global value."
(terpri)
(let ((buf (current-buffer)))
(with-temp-buffer
- (lisp-mode-variables)
+ (lisp-mode-variables nil)
(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 2f23178..b737134 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -272,7 +272,7 @@ Blank lines separate paragraphs. Semicolons start comments.
'(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)
+ (setf (nth 2 font-lock-defaults) nil)
(add-hook 'after-load-functions #'elisp--font-lock-flush-elisp-buffers)
(if (boundp 'electric-pair-text-pairs)
(setq-local electric-pair-text-pairs
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index fca803b..9f34a37 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -274,7 +274,7 @@ If you accidentally suspend your process, use
\\[comint-continue-subjob]
to continue it."
(setq comint-prompt-regexp inferior-lisp-prompt)
(setq mode-line-process '(":%s"))
- (lisp-mode-variables)
+ (lisp-mode-variables t)
(setq comint-get-old-input (function lisp-get-old-input))
(setq comint-input-filter (function lisp-input-filter)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/add-lisp-data-mode e95703c: Don't mess with lisp-mode-variables,
João Távora <=