1 ;;; maxima-font-lock.el --- syntax highlighting for maxima.el
3 ;; Copyright: (C) 2001 Jay Belanger
5 ;; Author: Jay Belanger <belanger@truman.edu>
6 ;; $Name: version-5_19_2 $
8 ;; $Date: 2009/01/08 04:47:51 $
9 ;; Keywords: maxima, font-lock
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;; Please send suggestions and bug reports to <belanger@truman.edu>
27 ;; The latest version of this package should be available at
28 ;; ftp://vh213601.truman.edu/pub/Maxima
32 ;;; This file is used for font-lock for maxima.el
34 ;; The keywords are divided into the following groups, following the
36 ;; Functions (font-lock-builtin-face or font-lock-keyword-face)
37 ;; Variables (font-lock-keyword-face)
38 ;; Constants (font-lock-constant-face)
39 ;; Keywords (font-lock-keyword-face)
40 ;; Declarations (font-lock-keyword-face)
41 ;; Operators (font-lock-keyword-face)
42 ;; Property (font-lock-keyword-face)
43 ;; Macros (font-lock-keyword-face)
44 ;; Special operators (font-lock-keyword-face)
45 ;; Special symbols (font-lock-keyword-face)
51 (provide 'maxima-font-lock
)
55 ;; (defvar maxima-variable-face 'maxima-variable-face
56 ;; "The face to use for the variables.")
58 ;; (defvar maxima-function-face 'maxima-function-face
59 ;; "The face to use for the functions.")
61 ;; (defvar maxima-constant-face 'maxima-constant-face
62 ;; "The face to use for the constants.")
64 ;; (defvar maxima-keyword-face 'maxima-keyword-face
65 ;; "The face to use for the keywords.")
67 ;; (defvar maxima-operator-face 'maxima-operator-face
68 ;; "The face to use for the operators.")
70 ;; (defvar maxima-property-face 'maxima-property-face
71 ;; "The face to use for the properties.")
73 ;; (defvar maxima-macro-face 'maxima-macro-face
74 ;; "The face to use for the macros.")
76 ;; (defvar maxima-specop-face 'maxima-specop-face
77 ;; "The face to use for the special operators.")
79 ;; (defvar maxima-declaration-face 'maxima-declaration-face
80 ;; "The face to use for the macros.")
82 ;; (defvar maxima-specsymb-face 'maxima-specsymb-face
83 ;; "The face to use for the special symbols.")
94 (defvar maxima-match-variables-1
96 (eval-when-compile (regexp-opt maxima-vars-1
))
98 "regexp to match the maxima variables.")
100 (defvar maxima-vars-2
105 "change_filedefaults"
106 "current_let_rule_package"
107 "default_let_rule_package"
108 "display_format_internal"
115 "integration_constant_counter"
120 "matrix_element_mult"
121 "matrix_element_transpose"
126 "solve_inconsistent_error"
127 "sublis_apply_lambda"
129 "taylor_order_coefficients"
130 "taylor_truncate_polynomials"
133 "tr_bound_function_applyp"
134 "tr_file_tty_messagesp"
135 "tr_float_can_branch_complex"
136 "tr_function_call_default"
139 "tr_optimize_max_loop"
140 "tr_output_file_default"
141 "tr_predicate_brain_damage"
144 "tr_true_name_of_file_being_translated"
146 "tr_warn_bad_function_calls"
151 "tr_warn_undefined_variable"
156 (defvar maxima-match-variables-2
158 (eval-when-compile (regexp-opt maxima-vars-2
))
160 "regexp to match the maxima variables.")
162 (defvar maxima-vars-3
283 (defvar maxima-match-variables-3
285 (eval-when-compile (regexp-opt maxima-vars-3
))
287 "regexp to match the maxima variables.")
289 (defvar maxima-vars-4
392 (defvar maxima-match-variables-4
394 (eval-when-compile (regexp-opt maxima-vars-4
))
396 "regexp to match the maxima variables.")
408 (defvar maxima-match-functions-1
410 (eval-when-compile (regexp-opt maxima-fns-1
))
412 "regexp to match the maxima functions.")
590 (defvar maxima-match-functions-2
592 (eval-when-compile (regexp-opt maxima-fns-2
))
594 "regexp to match the maxima functions.")
628 "extract_linear_equations"
638 "fast_central_elements"
669 (defvar maxima-match-functions-3
671 (eval-when-compile (regexp-opt maxima-fns-3
))
673 "regexp to match the maxima functions.")
762 (defvar maxima-match-functions-4
764 (eval-when-compile (regexp-opt maxima-fns-4
))
766 "regexp to match the maxima functions.")
795 "monomial_dimensions"
896 (defvar maxima-match-functions-5
898 (eval-when-compile (regexp-opt maxima-fns-5
))
900 "regexp to match the maxima functions.")
944 "resolvante_alternee1"
945 "resolvante_bipartite"
946 "resolvante_diedrale"
949 "resolvante_produit_sym"
950 "resolvante_unitaire"
983 "set_up_dot_simplifications"
987 "similaritytransform"
1080 (defvar maxima-match-functions-6
1082 (eval-when-compile (regexp-opt maxima-fns-6
))
1084 "regexp to match the maxima functions.")
1086 (defvar maxima-const-1
1092 (defvar maxima-match-constants-1
1094 (eval-when-compile (regexp-opt maxima-const-1
))
1096 "regexp to match the maxima constants.")
1098 (defvar maxima-const-2
1106 (defvar maxima-match-constants-2
1108 (eval-when-compile (regexp-opt maxima-const-2
))
1110 "regexp to match the maxima constants.")
1112 (defvar maxima-match-constants-3
1113 "\\<\\([0-9]+\\)\\>"
1114 "regexp to match the maxima constants.")
1116 (defvar maxima-match-constants-4
1117 "\\<\\([0-9]+\.\\)?\\([0-9]+b[+-]?[0-9]\\)\\>"
1118 "regexp to match the maxima constants.")
1120 (defvar maxima-keywds
1124 (defvar maxima-match-keywords
1126 (eval-when-compile (regexp-opt maxima-keywds
))
1128 "regexp to match the maxima keywords.")
1130 (defvar maxima-match-operators
1152 "regexp to match the maxima operators.")
1154 (defvar maxima-props
1159 (defvar maxima-match-properties
1161 (eval-when-compile (regexp-opt maxima-props
))
1163 "regexp to match maxima properties.")
1165 (defvar maxima-macros
1171 (defvar maxima-match-macros
1173 (eval-when-compile (regexp-opt maxima-macros
))
1175 "regexp to match maxima macros.")
1177 (defvar maxima-specops
1191 (defvar maxima-match-specops
1193 (eval-when-compile (regexp-opt maxima-specops
))
1195 "regexp to match maxima special operators.")
1216 (defvar maxima-match-declarations
1218 (eval-when-compile (regexp-opt maxima-decs
))
1220 "regexp to match maxima declarations.")
1222 (defvar maxima-spsymbs-1
1234 (defvar maxima-match-specsymbs-1
1236 (eval-when-compile (regexp-opt maxima-spsymbs-1
))
1238 "regexp to match maxima special symbols.")
1240 (defvar maxima-match-specsymbs-2
1241 "\\(\\<\\?\\sw+\\>\\)"
1242 "regexp to match maxima special symbols.")
1244 ;;; now, create the faces.
1246 ;; (defface maxima-function-face
1247 ;; '((((type tty) (class color)) (:foreground "blue" :weight bold))
1248 ;; (((class color) (background light)) (:foreground "blue" :weight bold))
1249 ;; (((class color) (background dark)) (:foreground "lightskyblue" :weight bold))
1250 ;; (t (:inverse-video t :bold t)))
1251 ;; "font lock mode face used to highlight function names."
1254 ;; (defface maxima-constant-face
1255 ;; '((((type tty) (class color)) (:foreground "magenta"))
1256 ;; (((class grayscale) (background light))
1257 ;; (:foreground "lightgray" :bold t :underline t))
1258 ;; (((class grayscale) (background dark))
1259 ;; (:foreground "gray50" :bold t :underline t))
1260 ;; (((class color) (background light)) (:foreground "cadetblue" :weight bold))
1261 ;; (((class color) (background dark)) (:foreground "aquamarine" :weight bold))
1262 ;; (t (:bold t :underline t)))
1263 ;; "font lock mode face used to highlight constants and labels."
1266 ;; (defface maxima-keyword-face
1267 ;; '((((type tty) (class color)) (:foreground "cyan" :weight bold))
1268 ;; (((class grayscale) (background light)) (:foreground "lightgray" :bold t))
1269 ;; (((class grayscale) (background dark)) (:foreground "dimgray" :bold t))
1270 ;; (((class color) (background light)) (:foreground "purple" :weight bold))
1271 ;; (((class color) (background dark)) (:foreground "cyan" :weight bold))
1273 ;; "font lock mode face used to highlight keywords."
1276 ;; (defface maxima-operator-face
1277 ;; '((((type tty) (class color)) (:foreground "blue" :weight light))
1278 ;; (((class grayscale) (background light)) (:foreground "lightgray" :bold t))
1279 ;; (((class grayscale) (background dark)) (:foreground "dimgray" :bold t))
1280 ;; (((class color) (background light)) (:foreground "orchid" :weight bold))
1281 ;; (((class color) (background dark)) (:foreground "lightsteelblue" :weight bold))
1283 ;; "font lock mode face used to highlight builtins."
1286 ;; (defface maxima-property-face
1287 ;; '((((type tty) (class color)) (:foreground "green"))
1288 ;; (((class grayscale) (background light)) (:foreground "gray90" :bold t))
1289 ;; (((class grayscale) (background dark)) (:foreground "dimgray" :bold t))
1290 ;; (((class color) (background light)) (:foreground "forestgreen" :weight bold))
1291 ;; (((class color) (background dark)) (:foreground "palegreen" :weight bold))
1292 ;; (t (:bold t :underline t)))
1293 ;; "font lock mode face used to highlight type and classes."
1296 ;; (defface maxima-macro-face
1297 ;; '((((class color) (background dark)) (:foreground "steelblue1"))
1298 ;; (((class color) (background light)) (:foreground "blue3"))
1299 ;; (t (:underline t)))
1300 ;; "font lock mode face used to highlight preprocessor conditionals."
1303 ;; (defface maxima-specop-face
1304 ;; '((((type tty) (class color)) (:foreground "cyan" :weight bold))
1305 ;; (((class grayscale) (background light)) (:foreground "lightgray" :bold t))
1306 ;; (((class grayscale) (background dark)) (:foreground "dimgray" :bold t))
1307 ;; (((class color) (background light)) (:foreground "purple" :weight bold))
1308 ;; (((class color) (background dark)) (:foreground "cyan" :weight bold))
1310 ;; "font lock mode face used to highlight keywords."
1313 ;; (defface maxima-declaration-face
1314 ;; '((((type tty) (class color)) (:foreground "cyan" :weight bold))
1315 ;; (((class grayscale) (background light)) (:foreground "lightgray" :bold t))
1316 ;; (((class grayscale) (background dark)) (:foreground "dimgray" :bold t))
1317 ;; (((class color) (background light)) (:foreground "purple" :weight bold))
1318 ;; (((class color) (background dark)) (:foreground "cyan" :weight bold))
1320 ;; "font lock mode face used to highlight keywords."
1323 ;; (defface maxima-specsymb-face
1324 ;; '((((type tty) (class color)) (:foreground "red"))
1325 ;; (((class color) (background light)) (:foreground "red" :bold t))
1326 ;; (((class color) (background dark)) (:foreground "pink" :bold t))
1327 ;; (t (:inverse-video t :bold t)))
1328 ;; "font lock mode face used to highlight warnings."
1331 ;; (defface maxima-variable-face
1332 ;; '((((type tty) (class color)) (:foreground "yellow" :weight light))
1333 ;; (((class grayscale) (background light))
1334 ;; (:foreground "gray90" :bold t :italic t))
1335 ;; (((class grayscale) (background dark))
1336 ;; (:foreground "dimgray" :bold t :italic t))
1337 ;; (((class color) (background light)) (:foreground "darkgoldenrod" :italic t))
1338 ;; (((class color) (background dark)) (:foreground "lightgoldenrod" :italic t))
1339 ;; (t (:bold t :italic t)))
1340 ;; "font lock mode face used to highlight variable names."
1343 ;;; now, the keywords
1344 (unless (facep 'font-lock-builtin-face
)
1345 (copy-face 'font-lock-keyword-face
'font-lock-builtin-face
))
1347 (unless (facep 'font-lock-constant-face
)
1348 (copy-face 'font-lock-keyword-face
'font-lock-constant-face
))
1350 (defvar maxima-font-lock-keywords-1
1352 (,maxima-match-declarations . font-lock-keyword-face
))
1353 "Subdued level highlighting for Maxima mode.")
1355 (defvar maxima-font-lock-keywords-2
1356 (append maxima-font-lock-keywords-1
1358 (,maxima-match-operators . font-lock-keyword-face
)
1359 (,maxima-match-variables-1 . font-lock-keyword-face
)
1360 (,maxima-match-variables-2 . font-lock-keyword-face
)
1361 (,maxima-match-variables-3 . font-lock-keyword-face
)
1362 (,maxima-match-variables-4 . font-lock-keyword-face
)
1363 (,maxima-match-functions-1 . font-lock-builtin-face
)
1364 (,maxima-match-functions-2 . font-lock-builtin-face
)
1365 (,maxima-match-functions-3 . font-lock-builtin-face
)
1366 (,maxima-match-functions-4 . font-lock-builtin-face
)
1367 (,maxima-match-functions-5 . font-lock-builtin-face
)
1368 (,maxima-match-functions-6 . font-lock-builtin-face
)
1369 (,maxima-match-constants-1 . font-lock-constant-face
)
1370 (,maxima-match-constants-2 . font-lock-constant-face
)
1371 (,maxima-match-constants-3 . font-lock-constant-face
)
1372 (,maxima-match-constants-4 . font-lock-constant-face
)
1373 (,maxima-match-keywords . font-lock-keyword-face
)
1374 (,maxima-match-properties . font-lock-keyword-face
)
1375 (,maxima-match-macros . font-lock-keyword-face
)
1376 (,maxima-match-specops . font-lock-keyword-face
)
1377 (,maxima-match-specsymbs-1 . font-lock-keyword-face
)
1378 (,maxima-match-specsymbs-2 . font-lock-keyword-face
)))
1379 "Medium level highlighting for Maxima mode.")
1381 (defvar maxima-font-lock-keywords-3
1382 (append maxima-font-lock-keywords-2
1384 (list "^\\(.*\\)(\\(.*\\)) *:="
1385 '(1 font-lock-function-name-face
))
1386 (list "^.*(\\(.*\\)):="
1387 '(1 font-lock-variable-name-face
))))
1388 "Gaudy level highlighting for Maxima mode.")
1390 (defvar maxima-font-lock-keywords maxima-font-lock-keywords-1
1391 "Default expressions to highlight in Maxima mode.")
1393 (defun maxima-font-setup ()
1394 (make-local-variable 'font-lock-defaults
)
1395 (setq font-lock-defaults
1396 '((maxima-font-lock-keywords maxima-font-lock-keywords-1
1397 maxima-font-lock-keywords-2 maxima-font-lock-keywords-3
)
1400 (add-hook 'maxima-mode-hook
'maxima-font-setup
)
1402 ;;; A function to fontify the preamble in a Maxima process buffer
1403 (defvar maxima-preamble-fontlock t
)
1405 (defun maxima-match-preamble (limit)
1406 "Used to fontify the preamble."
1407 (if maxima-preamble-fontlock
1409 (setq maxima-preamble-fontlock nil
)
1410 (let ((beg (point-min))
1412 (if (search-forward "(C1)" limit
)
1415 (setq end
(maxima-line-end-position))
1416 (store-match-data (list beg end
))
1420 (defvar inferior-maxima-font-lock-keywords-1
1421 (append maxima-font-lock-keywords-1
1422 '((maxima-match-preamble (0 font-lock-string-face t t
)))))
1424 (defvar inferior-maxima-font-lock-keywords-2
1425 (append maxima-font-lock-keywords-2
1426 '((maxima-match-preamble (0 font-lock-string-face t t
)))))
1428 (defvar inferior-maxima-font-lock-keywords-3
1429 (append maxima-font-lock-keywords-3
1430 '((maxima-match-preamble (0 font-lock-string-face t t
)))))
1432 (defvar inferior-maxima-font-lock-keywords inferior-maxima-font-lock-keywords-1
1433 "Default expressions to highlight in Maxima mode.")
1435 (defun inferior-maxima-font-setup ()
1436 (make-local-variable 'font-lock-defaults
)
1437 (setq font-lock-defaults
1438 '((inferior-maxima-font-lock-keywords inferior-maxima-font-lock-keywords-1
1439 inferior-maxima-font-lock-keywords-2 inferior-maxima-font-lock-keywords-3
)
1442 ;;; now for the symbols
1444 (defvar maxima-symbols
1446 (lambda (x) (list x
))
1467 ;;; end of maxima-font-lock.el