This patch is intended to move lisp-mode toward better conformance
with Common Lisp. To this end:
o It removes case sensitivity in the highlighting code
o Adds some commonly used CL forms to the highlighting lists
o Adds indention specs for commonly used CL forms
Please note that I do not know what dependencies modes other than
emacs-lisp-mode may have on lisp-mode. It may turn out that it would be
better to implement my changes by creating a new common-lisp-mode and
have the .lisp and .lsp extensions select that mode instead of lisp-mode.
Craig
----------------------------------------------------------------------
2000-12-07 Craig Lanning <lanning(a)scra.org>
* font-lock.el: Support Common Lisp better
* font-lock.el (lisp-mode): Make case insensitive per Common Lisp
* font-lock.el (emacs-lisp-mode): Separate from lisp-mode so that
it can maintain its case sensitivity
* font-lock.el (lisp-font-lock-keywords-1): Support things like
cl:defvar or foo::define-object
* font-lock.el (lisp-font-lock-keywords-2):
Add with-open-file, with-open-stream, with-slots, handler-bind,
and handler-case to set of highlighted keywords
Add &body and &key to list of lambda list keywords
* lisp-mode.el (handler-case): Specify indention
* lisp-mode.el (handler-bind): ..
* lisp-mode.el (with-output-to-string): Change indention
* lisp-mode.el (with-slots): Specify indention
* lisp-mode.el (with-open-file): ..
* lisp-mode.el (with-open-stream): ..
* lisp-mode.el (print-unreadable-object): ..
----------------------------------------------------------------------
cvs server: Diffing lisp
Index: lisp/font-lock.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/font-lock.el,v
retrieving revision 1.7.2.26
diff -u -r1.7.2.26 font-lock.el
--- font-lock.el 2000/11/02 15:15:06 1.7.2.26
+++ font-lock.el 2000/12/07 13:11:50
@@ -1817,14 +1817,22 @@
(put 'lisp-mode 'font-lock-defaults
'((lisp-font-lock-keywords
lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
- nil nil
+ nil t
((?: . "w") (?- . "w") (?* . "w") (?+ .
"w") (?. . "w") (?< . "w")
(?> . "w") (?= . "w") (?! . "w") (?? . "w")
(?$ . "w") (?% . "w")
(?_ . "w") (?& . "w") (?~ . "w") (?^ . "w")
(?/ . "w"))
beginning-of-defun))
-(put 'emacs-lisp-mode 'font-lock-defaults 'lisp-mode)
(put 'lisp-interaction-mode 'font-lock-defaults 'lisp-mode)
+(put 'emacs-lisp-mode 'font-lock-defaults
+ '((lisp-font-lock-keywords
+ lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
+ nil nil
+ ((?: . "w") (?- . "w") (?* . "w") (?+ .
"w") (?. . "w") (?< . "w")
+ (?> . "w") (?= . "w") (?! . "w") (?? . "w")
(?$ . "w") (?% . "w")
+ (?_ . "w") (?& . "w") (?~ . "w") (?^ . "w")
(?/ . "w"))
+ beginning-of-defun))
+
(put 'scheme-mode 'font-lock-defaults
'(scheme-font-lock-keywords
nil t
@@ -1864,7 +1872,7 @@
;; Anything not a variable or type declaration is fontified as a function.
;; It would be cleaner to allow preceding whitespace, but it would also be
;; about five times slower.
- (list (concat "^(\\(def\\("
+ (list (concat "^(\\(\\(\\sw+::?\\)?def\\("
;; Variable declarations.
"\\(const\\(\\|ant\\)\\|ine-key\\(\\|-after\\)\\|var\\|custom\\)\\|"
;; Structure declarations.
@@ -1876,8 +1884,8 @@
"[ \t'\(]*"
"\\([^ \t\n\)]+\\)?")
'(1 font-lock-keyword-face)
- '(8 (cond ((match-beginning 3) 'font-lock-variable-name-face)
- ((match-beginning 6) 'font-lock-type-face)
+ '(9 (cond ((match-beginning 4) 'font-lock-variable-name-face)
+ ((match-beginning 7) 'font-lock-type-face)
(t 'font-lock-function-name-face))
nil t))
)
@@ -1902,10 +1910,11 @@
;; "save-current-buffer" "with-current-buffer"
;; "save-selected-window" "with-selected-window"
;; "save-selected-frame" "with-selected-frame"
+ ;; "with-open-file" "with-open-stream"
;; "with-temp-file" "with-temp-buffer"
"with-output-to-string"
- ;; "with-string-as-buffer-contents"
+ ;; "with-string-as-buffer-contents" "with-slots"
;; "save-match-data" "unwind-protect"
"call-with-condition-handler"
- ;; "condition-case" "track-mouse" "autoload"
+ ;; "handler-bind" "handler-case" "condition-case"
"track-mouse" "autoload"
;; "eval-after-load" "eval-and-compile"
"eval-when-compile"
;; "when" "unless" "do" "dolist"
"dotimes" "flet" "labels"
;; "lambda" "block" "return"
"return-from" "loop") t)
@@ -1914,12 +1923,13 @@
"autoload\\|block\\|c\\(?:a\\(?:ll-with-condition-handler\\|tch\\)\\|"
"ond\\(?:ition-case\\)?\\)\\|do\\(?:list\\|times\\)?\\|"
"eval-\\(?:a\\(?:fter-load\\|nd-compile\\)\\|when-compile\\)\\|flet\\|"
- "if\\|l\\(?:a\\(?:bels\\|mbda\\)\\|et\\*?\\|oop\\)\\|prog[12nv]?\\|"
- "return\\(?:-from\\)?\\|save-\\(?:current-buffer\\|excursion\\|"
- "match-data\\|restriction\\|selected-\\(?:frame\\|window\\)\\|"
- "window-excursion\\)\\|t\\(?:hrow\\|rack-mouse\\)\\|un\\(?:less\\|"
- "wind-protect\\)\\|w\\(?:h\\(?:en\\|ile\\)\\|ith-\\(?:current-buffer\\|"
- "output-to-string\\|s\\(?:elected-\\(?:frame\\|window\\)\\|"
+ "handler-\\(?:bind\\|case\\)\\|if\\|l\\(?:a\\(?:bels\\|mbda\\)\\|"
+ "et\\*?\\|oop\\)\\|prog[12nv]?\\|return\\(?:-from\\)?\\|"
+ "save-\\(?:current-buffer\\|excursion\\|match-data\\|restriction\\|"
+ "selected-\\(?:frame\\|window\\)\\|window-excursion\\)\\|t\\(?:hrow\\|"
+ "rack-mouse\\)\\|un\\(?:less\\|wind-protect\\)\\|w\\(?:h\\(?:en\\|"
+ "ile\\)\\|ith-\\(?:current-buffer\\|o\\(?:pen-\\(?:file\\|stream\\)\\|"
+ "utput-to-string\\)\\|s\\(?:elected-\\(?:frame\\|window\\)\\|lots\\|"
"tring-as-buffer-contents\\)\\|temp-\\(?:buffer\\|file\\)\\)\\)"
;; end of generated stuff
"\\)\\>") 1)
@@ -1938,7 +1948,7 @@
'("\\<:\\sw+\\>" 0 font-lock-reference-face prepend)
;;
;; ELisp and CLisp `&' keywords as types.
- '("\\<\\&\\(optional\\|rest\\|whole\\)\\>" .
font-lock-type-face)
+ '("\\<\\&\\(body\\|key\\|optional\\|rest\\|whole\\)\\>" .
font-lock-type-face)
))
"Gaudy level highlighting for Lisp modes.")
Index: lisp/lisp-mode.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/lisp-mode.el,v
retrieving revision 1.10.2.7
diff -u -r1.10.2.7 lisp-mode.el
--- lisp-mode.el 2000/11/23 06:27:36 1.10.2.7
+++ lisp-mode.el 2000/12/07 13:11:51
@@ -802,6 +802,8 @@
(put 'if 'lisp-indent-function 2)
(put 'catch 'lisp-indent-function 1)
(put 'condition-case 'lisp-indent-function 2)
+(put 'handler-case 'lisp-indent-function 1)
+(put 'handler-bind 'lisp-indent-function 1)
(put 'call-with-condition-handler 'lisp-indent-function 2)
(put 'unwind-protect 'lisp-indent-function 1)
(put 'save-current-buffer 'lisp-indent-function 0)
@@ -809,14 +811,18 @@
(put 'with-string-as-buffer-contents 'lisp-indent-function 1)
(put 'with-temp-file 'lisp-indent-function 1)
(put 'with-temp-buffer 'lisp-indent-function 0)
-(put 'with-output-to-string 'lisp-indent-function 0)
+(put 'with-output-to-string 'lisp-indent-function 1)
(put 'with-output-to-temp-buffer 'lisp-indent-function 1)
+(put 'with-slots 'lisp-indent-function 2)
+(put 'with-open-file 'lisp-indent-function 1)
+(put 'with-open-stream 'lisp-indent-function 1)
(put 'eval-after-load 'lisp-indent-function 1)
(put 'display-message 'lisp-indent-function 1)
(put 'display-warning 'lisp-indent-function 1)
(put 'lmessage 'lisp-indent-function 2)
(put 'lwarn 'lisp-indent-function 2)
(put 'global-set-key 'lisp-indent-function 1)
+(put 'print-unreadable-object 'lisp-indent-function 1)
(defun indent-sexp (&optional endpos)
"Indent each line of the list starting just after point.
cvs server: Diffing lisp/mule
cvs server: Diffing lisp/term