aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2020-04-10 18:27:36 -0400
committerStefan Monnier2020-04-11 13:56:03 -0400
commit5084fdb83e2421516f161daff37ea67d1cb63402 (patch)
tree06cdf5e597f6ecba9a2404446d43c7badb0933e3
parenta79019c16b23f40c29509b6c0bf6f79d87f18c1e (diff)
downloademacs-5084fdb83e2421516f161daff37ea67d1cb63402.tar.gz
emacs-5084fdb83e2421516f161daff37ea67d1cb63402.zip
* lisp/progmodes/cl-font-lock.el: New file
Taken from commit 1a54066611da213626ab69ea426ba3c63ece3438 of https://github.com/cl-font-lock/cl-font-lock, but with names reverted to a `cl-font-lock-` prefix.
-rw-r--r--lisp/progmodes/cl-font-lock.el284
1 files changed, 284 insertions, 0 deletions
diff --git a/lisp/progmodes/cl-font-lock.el b/lisp/progmodes/cl-font-lock.el
new file mode 100644
index 00000000000..6d6992e11c1
--- /dev/null
+++ b/lisp/progmodes/cl-font-lock.el
@@ -0,0 +1,284 @@
1;;; cl-font-lock.el --- Pretty Common Lisp font locking -*- lexical-binding: t; -*-
2;; Copyright (C) 2019 Yue Daian
3;; Author: Yue Daian
4;; Maintainer: Spenser Truex <web@spensertruex.com>
5;; Created: 2019-06-16
6;; Version: 0.3.0
7;; Package-Requires: ((emacs "24.5"))
8;; Keywords: lisp wp files convenience
9;; URL: https://github.com/cl-font-lock/cl-font-lock
10;; Homepage: https://github.com/cl-font-lock/cl-font-lock
11;; This file is not part of GNU Emacs, but you want to use GNU Emacs to run it.
12;; This file is very free software.
13
14;; This is free and unencumbered software released into the public domain.
15
16;; Anyone is free to copy, modify, publish, use, compile, sell, or
17;; distribute this software, either in source code form or as a compiled
18;; binary, for any purpose, commercial or non-commercial, and by any
19;; means.
20
21;; In jurisdictions that recognize copyright laws, the author or authors
22;; of this software dedicate any and all copyright interest in the
23;; software to the public domain. We make this dedication for the benefit
24;; of the public at large and to the detriment of our heirs and
25;; successors. We intend this dedication to be an overt act of
26;; relinquishment in perpetuity of all present and future rights to this
27;; software under copyright law.
28
29;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33;; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34;; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35;; OTHER DEALINGS IN THE SOFTWARE.
36
37;; For more information, please refer to <http://unlicense.org/>.
38
39
40;;; Commentary:
41
42;; Highlight all the symbols in the Common Lisp ANSI Standard, and prettify
43;; lambda to display the greek letter.
44;;
45;; Adds font-lock regexes to lisp-mode.
46
47;;; Code:
48
49(require 'cl-lib)
50(defvar cl-font-lock-built-in--functions
51 '("+" "-" "/" "/=" "<" "<=" "=" ">" ">=" "*" "1-" "1+" "abs" "acons" "acos"
52 "acosh" "add-method" "adjoin" "adjustable-array-p" "adjust-array"
53 "allocate-instance" "alpha-char-p" "alphanumericp" "and" "append" "apply"
54 "apropos" "apropos-list" "aref" "arithmetic-error-operands"
55 "arithmetic-error-operation" "array-dimension" "array-dimensions"
56 "array-displacement" "array-element-type" "array-has-fill-pointer-p"
57 "array-in-bounds-p" "arrayp" "array-rank" "array-row-major-index"
58 "array-total-size" "ash" "asin" "asinh" "assoc" "assoc-if" "assoc-if-not"
59 "atan" "atanh" "atom" "bit" "bit-and" "bit-andc1" "bit-andc2" "bit-eqv"
60 "bit-ior" "bit-nand" "bit-nor" "bit-not" "bit-orc1" "bit-orc2"
61 "bit-vector-p" "bit-xor" "boole" "both-case-p" "boundp"
62 "broadcast-stream-streams" "butlast" "byte" "byte-position" "byte-size"
63 "call-method" "call-next-method" "car" "catch" "cdr" "ceiling"
64 "cell-error-name" "change-class" "char" "char/=" "char<" "char<=" "char="
65 "char>" "char>=" "character" "characterp" "char-code" "char-downcase"
66 "char-equal" "char-greaterp" "char-int" "char-lessp" "char-name"
67 "char-not-equal" "char-not-greaterp" "char-not-lessp" "char-upcase" "cis"
68 "class-name" "class-of" "clear-input" "clear-output" "close" "clrhash"
69 "code-char" "coerce" "compile" "compiled-function-p" "compile-file"
70 "compile-file-pathname" "compiler-macro-function" "complement" "complex"
71 "complexp" "compute-applicable-methods" "compute-restarts" "concatenate"
72 "concatenated-stream-streams" "conjugate" "cons" "consp" "constantly"
73 "constantp" "continue" "copy-alist" "copy-list" "copy-pprint-dispatch"
74 "copy-readtable" "copy-seq" "copy-structure" "copy-symbol" "copy-tree"
75 "cos" "cosh" "count" "count-if" "count-if-not" "decf" "decode-float"
76 "decode-universal-time" "delete" "delete-duplicates" "delete-file"
77 "delete-if" "delete-if-not" "delete-package" "denominator" "deposit-field"
78 "describe" "describe-object" "digit-char" "digit-char-p" "directory"
79 "directory-namestring" "disassemble" "do-all-symbols" "documentation"
80 "do-external-symbols" "do-symbols" "dpb" "dribble"
81 "echo-stream-input-stream" "echo-stream-output-stream" "ed" "eighth" "elt"
82 "encode-universal-time" "endp" "enough-namestring"
83 "ensure-directories-exist" "ensure-generic-function" "eq" "eql" "equal"
84 "equalp" "eval" "evenp" "every" "exp" "export" "expt" "fboundp" "fceiling"
85 "fdefinition" "ffloor" "fifth" "file-author" "file-error-pathname"
86 "file-length" "file-namestring" "file-position" "file-string-length"
87 "file-write-date" "fill" "fill-pointer" "find" "find-all-symbols"
88 "find-class" "find-if" "find-if-not" "find-method" "find-package"
89 "find-restart" "find-symbol" "finish-output" "first" "float" "float-digits"
90 "floatp" "float-precision" "float-radix" "float-sign" "floor" "fmakunbound"
91 "force-output" "format" "formatter" "fourth" "fresh-line" "fround"
92 "ftruncate" "funcall" "function" "function-keywords"
93 "function-lambda-expression" "functionp" "gcd" "gensym" "gentemp" "get"
94 "get-decoded-time" "get-dispatch-macro-character" "getf" "gethash"
95 "get-internal-real-time" "get-internal-run-time" "get-macro-character"
96 "get-output-stream-string" "get-properties" "get-setf-expansion"
97 "get-universal-time" "graphic-char-p" "hash-table-count" "hash-table-p"
98 "hash-table-rehash-size" "hash-table-rehash-threshold" "hash-table-size"
99 "hash-table-test" "host-namestring" "identity" "imagpart" "import" "incf"
100 "initialize-instance" "input-stream-p" "inspect" "integer-decode-float"
101 "integer-length" "integerp" "interactive-stream-p" "intern" "intersection"
102 "invalid-method-error" "invoke-debugger" "invoke-restart"
103 "invoke-restart-interactively" "isqrt" "keywordp" "last" "lcm" "ldb"
104 "ldb-test" "ldiff" "length" "lisp-implementation-type"
105 "lisp-implementation-version" "list" "list\\*" "list-all-packages" "listen"
106 "list-length" "listp" "load" "load-logical-pathname-translations"
107 "load-time-value" "log" "logand" "logandc1" "logandc2" "logbitp" "logcount"
108 "logeqv" "logical-pathname" "logical-pathname-translations" "logior"
109 "lognand" "lognor" "lognot" "logorc1" "logorc2" "logtest" "logxor"
110 "long-site-name" "loop-finish" "lower-case-p" "machine-instance"
111 "machine-type" "machine-version" "macroexpand" "macroexpand-1"
112 "macro-function" "make-array" "make-array" "make-broadcast-stream"
113 "make-concatenated-stream" "make-condition" "make-dispatch-macro-character"
114 "make-echo-stream" "make-hash-table" "make-instance"
115 "make-instances-obsolete" "make-list" "make-load-form"
116 "make-load-form-saving-slots" "make-method" "make-package" "make-pathname"
117 "make-random-state" "make-sequence" "make-string"
118 "make-string-input-stream" "make-string-output-stream" "make-symbol"
119 "make-synonym-stream" "make-two-way-stream" "makunbound" "map" "mapc"
120 "mapcan" "mapcar" "mapcon" "maphash" "map-into" "mapl" "maplist"
121 "mask-field" "max" "member" "member-if" "member-if-not" "merge"
122 "merge-pathnames" "method-combination-error" "method-qualifiers" "min"
123 "minusp" "mismatch" "mod" "muffle-warning" "multiple-value-call"
124 "multiple-value-list" "multiple-value-setq" "name-char" "namestring"
125 "nbutlast" "nconc" "next-method-p" "nintersection" "ninth"
126 "no-applicable-method" "no-next-method" "not" "notany" "notevery" "nreconc"
127 "nreverse" "nset-difference" "nset-exclusive-or" "nstring-capitalize"
128 "nstring-downcase" "nstring-upcase" "nsublis" "nsubst" "nsubst-if"
129 "nsubst-if-not" "nsubstitute" "nsubstitute-if" "nsubstitute-if-not" "nth"
130 "nthcdr" "nth-value" "null" "numberp" "numerator" "nunion" "oddp" "open"
131 "open-stream-p" "or" "output-stream-p" "package-error-package"
132 "package-name" "package-nicknames" "packagep" "package-shadowing-symbols"
133 "package-used-by-list" "package-use-list" "pairlis" "parse-integer"
134 "parse-namestring" "pathname" "pathname-device" "pathname-directory"
135 "pathname-host" "pathname-match-p" "pathname-name" "pathnamep"
136 "pathname-type" "pathname-version" "peek-char" "phase" "plusp" "pop"
137 "position" "position-if" "position-if-not" "pprint" "pprint-dispatch"
138 "pprint-exit-if-list-exhausted" "pprint-fill" "pprint-indent"
139 "pprint-linear" "pprint-logical-block" "pprint-newline" "pprint-pop"
140 "pprint-tab" "pprint-tabular" "prin1" "prin1-to-string" "princ"
141 "princ-to-string" "print" "print-not-readable-object" "print-object"
142 "print-unreadable-object" "probe-file" "provide" "psetf" "psetq" "push"
143 "pushnew" "quote" "random" "random-state-p" "rassoc" "rassoc-if"
144 "rassoc-if-not" "rational" "rationalize" "rationalp" "read" "read-byte"
145 "read-char" "read-char-no-hang" "read-delimited-list" "read-from-string"
146 "read-line" "read-preserving-whitespace" "read-sequence" "readtable-case"
147 "readtablep" "realp" "realpart" "reduce" "reinitialize-instance" "rem"
148 "remf" "remhash" "remove" "remove-duplicates" "remove-if" "remove-if-not"
149 "remove-method" "remprop" "rename-file" "rename-package" "replace"
150 "require" "rest" "restart-name" "revappend" "reverse" "room" "rotatef"
151 "round" "row-major-aref" "rplaca" "rplacd" "sbit" "scale-float" "schar"
152 "search" "second" "set" "set-difference" "set-dispatch-macro-character"
153 "set-exclusive-or" "setf" "set-macro-character" "set-pprint-dispatch"
154 "setq" "set-syntax-from-char" "seventh" "shadow" "shadowing-import"
155 "shared-initialize" "shiftf" "short-site-name" "signum"
156 "simple-bit-vector-p" "simple-condition-format-arguments"
157 "simple-condition-format-control" "simple-string-p" "simple-vector-p" "sin"
158 "sinh" "sixth" "sleep" "slot-boundp" "slot-exists-p" "slot-makunbound"
159 "slot-missing" "slot-unbound" "slot-value" "software-type"
160 "software-version" "some" "sort" "special-operator-p" "sqrt" "stable-sort"
161 "standard-char-p" "step" "store-value" "stream-element-type"
162 "stream-error-stream" "stream-external-format" "streamp" "string"
163 "string/=" "string<" "string<=" "string=" "string>" "string>="
164 "string-capitalize" "string-downcase" "string-equal" "string-greaterp"
165 "string-left-trim" "string-lessp" "string-not-equal" "string-not-greaterp"
166 "string-not-lessp" "stringp" "string-right-trim" "string-trim"
167 "string-upcase" "sublis" "subseq" "subsetp" "subst" "subst-if"
168 "subst-if-not" "substitute" "substitute-if" "substitute-if-not" "subtypep"
169 "svref" "sxhash" "symbol-function" "symbol-name" "symbolp" "symbol-package"
170 "symbol-plist" "symbol-value" "synonym-stream-symbol" "tailp" "tan" "tanh"
171 "tenth" "terpri" "third" "throw" "time" "trace"
172 "translate-logical-pathname" "translate-pathname" "tree-equal" "truename"
173 "truncate" "two-way-stream-input-stream" "two-way-stream-output-stream"
174 "type-error-datum" "type-error-expected-type" "type-of" "typep"
175 "unbound-slot-instance" "unexport" "unintern" "union" "unread-char"
176 "untrace" "unuse-package" "update-instance-for-different-class"
177 "update-instance-for-redefined-class" "upgraded-array-element-type"
178 "upgraded-complex-part-type" "upper-case-p" "use-package"
179 "user-homedir-pathname" "use-value" "values" "values-list" "vector"
180 "vectorp" "vector-pop" "vector-push" "vector-push-extend" "wild-pathname-p"
181 "write" "write-byte" "write-char" "write-line" "write-sequence"
182 "write-string" "write-to-string" "yes-or-no-p" "y-or-n-p" "zerop"))
183
184(defvar cl-font-lock-built-in--variables
185 '("//" "///" "\\*load-pathname\\*" "\\*print-pprint-dispatch\\*"
186 "\\*break-on-signals\\*" "\\*load-print\\*" "\\*print-pprint-dispatch\\*"
187 "\\*break-on-signals\\*" "\\*load-truename\\*" "\\*print-pretty\\*"
188 "\\*load-verbose\\*" "\\*print-radix\\*" "\\*compile-file-pathname\\*"
189 "\\*macroexpand-hook\\*" "\\*print-readably\\*"
190 "\\*compile-file-pathname\\*" "\\*modules\\*" "\\*print-right-margin\\*"
191 "\\*compile-file-truename\\*" "\\*package\\*" "\\*print-right-margin\\*"
192 "\\*compile-file-truename\\*" "\\*print-array\\*" "\\*query-io\\*"
193 "\\*compile-print\\*" "\\*print-base\\*" "\\*random-state\\*"
194 "\\*compile-verbose\\*" "\\*default-pathname-defaults\\*"
195 "\\*print-length\\*" "\\*readtable\\*" "\\*error-output\\*"
196 "\\*print-level\\*" "\\*standard-input\\*" "\\*print-case\\*"
197 "\\*read-base\\*" "\\*compile-verbose\\*" "\\*print-circle\\*"
198 "\\*print-lines\\*" "\\*standard-output\\*" "\\*features\\*"
199 "\\*print-miser-width\\*" "\\*read-default-float-format\\*"
200 "\\*debug-io\\*" "\\*print-escape\\*" "\\*read-eval\\*"
201 "\\*debugger-hook\\*" "\\*print-gensym\\*" "\\*read-suppress\\*"
202 "\\*terminal-io\\*" "\\*gensym-counter\\*" "\\*print-miser-width\\*"
203 "\\*trace-output\\*" "array-dimension-limit" "array-rank-limit"
204 "array-total-size-limit" "boole-1" "boole-2" "boole-and" "boole-andc1"
205 "boole-andc2" "boole-c1" "boole-c2" "boole-clr" "boole-eqv" "boole-ior"
206 "boole-nand" "boole-nor" "boole-orc1" "boole-orc2" "boole-set" "boole-xor"
207 "call-arguments-limit" "char-code-limit" "double-float-epsilon"
208 "double-float-negative-epsilon" "internal-time-units-per-second"
209 "lambda-list-keywords" "lambda-parameters-limit"
210 "least-negative-double-float" "least-negative-long-float"
211 "least-negative-normalized-double-float"
212 "least-negative-normalized-long-float"
213 "least-negative-normalized-short-float"
214 "least-negative-normalized-single-float" "least-negative-short-float"
215 "least-negative-single-float" "least-positive-double-float"
216 "least-positive-long-float" "least-positive-normalized-double-float"
217 "least-positive-normalized-long-float"
218 "least-positive-normalized-short-float"
219 "least-positive-normalized-single-float" "least-positive-short-float"
220 "least-positive-single-float" "long-float-epsilon"
221 "long-float-negative-epsilon" "most-negative-double-float"
222 "most-negative-fixnum" "most-negative-long-float"
223 "most-negative-short-float" "most-negative-single-float"
224 "most-positive-double-float" "most-positive-fixnum"
225 "most-positive-long-float" "most-positive-short-float"
226 "most-positive-single-float" "multiple-values-limit" "short-float-epsilon"
227 "short-float-negative-epsilon" "single-float-epsilon"
228 "single-float-negative-epsilon" "pi"))
229
230(defvar cl-font-lock-built-in--types
231 '("arithmetic-error" "array" "base-char" "base-string" "bignum" "bit-vector"
232 "boolean" "broadcast-stream" "built-in-class" "cell-error" "class"
233 "compiled-function" "concatenated-stream" "condition" "control-error"
234 "division-by-zero" "double-float" "echo-stream" "end-of-file"
235 "extended-char" "file-error" "file-stream" "fixnum"
236 "floating-point-inexact" "floating-point-invalid-operation"
237 "floating-point-overflow" "floating-point-underflow" "generic-function"
238 "hash-table" "integer" "keyword" "long-float" "method" "method-combination"
239 "number" "package" "package-error" "parse-error" "print-not-readable"
240 "program-error" "random-state" "ratio" "reader-error" "readtable" "real"
241 "restart" "sequence" "serious-condition" "short-float" "signed-byte"
242 "simple-array" "simple-base-string" "simple-bit-vector" "simple-condition"
243 "simple-error" "simple-string" "simple-type-error" "simple-vector"
244 "simple-warning" "single-float" "standard-char" "standard-class"
245 "standard-generic-function" "standard-method" "standard-object"
246 "storage-condition" "stream" "stream-error" "string-stream"
247 "structure-class" "structure-object" "style-warning" "symbol"
248 "synonym-stream" "two-way-stream" "type-error" "unbound-slot"
249 "unbound-variable" "undefined-function" "unsigned-byte" "warning"))
250
251(defvar cl-font-lock-built-in--symbols
252 '("compilation-speed" "compiler-macro" "debug" "declaration" "dynamic-extent"
253 "ftype" "ignorable" "ignore" "inline" "notinline" "optimize" "otherwise"
254 "safety" "satisfies" "space" "special" "speed" "structure" "type"))
255
256(defvar cl-font-lock--character-names
257 '("newline" "space" "rubout" "page" "tab" "backspace" "return" "linefeed"))
258
259(defmacro cl-font-lock-add-regexes (fn mode &rest symbol-face)
260 "Expand to more than one call to font-lock.
261Argument FN is the function used to send off the regex. Commonly
262`font-lock-add-keywords' or `font-lock-remove-keywords'. Argument
263MODE is the mode where the regexes are sent.
264Optional argument SYMBOL-FACE dotted-pair of (regex-var . font-face)."
265 `(progn
266 ,@(cl-loop for s in symbol-face
267 collect
268 `(,fn
269 ',mode
270 `((,(regexp-opt ,(car s) 'symbols)
271 . ,(cdr ',s)))))))
272
273(cl-font-lock-add-regexes
274 font-lock-add-keywords
275 lisp-mode
276 (cl-font-lock-built-in--functions . font-lock-function-name-face)
277 (cl-font-lock-built-in--variables . font-lock-variable-name-face)
278 (cl-font-lock-built-in--types . font-lock-type-face)
279 (cl-font-lock-built-in--symbols . font-lock-builtin-face)
280 (cl-font-lock--character-names . font-lock-variable-name-face))
281
282(provide 'cl-font-lock)
283
284;;; cl-font-lock.el ends here