chiark / gitweb /
dot/emacs, el/dot-emacs.el: Support for Algol 68 code.
[profile] / el / dot-emacs.el
index 4f9bd59d703e1a68b5a23850e5caf021a86b3c34..d594b17abb6553401b4c5bb37306f347d3dad0b1 100644 (file)
@@ -1968,6 +1968,50 @@ (defun mdw-fontify-dylan ()
 
   (mdw-post-config-mode-hack))
 
+;;;--------------------------------------------------------------------------
+;;; Algol 68 configuration.
+
+(setq a68-indent-step 2)
+
+(defun mdw-fontify-algol-68 ()
+
+  ;; Fix up the syntax table.
+  (modify-syntax-entry ?# "!" a68-mode-syntax-table)
+  (dolist (ch '(?- ?+ ?= ?< ?> ?* ?/ ?| ?&))
+    (modify-syntax-entry ch "." a68-mode-syntax-table))
+
+  (make-local-variable 'font-lock-keywords)
+
+  (let ((not-comment
+        (let ((word "COMMENT"))
+          (do ((regexp (concat "[^" (substring word 0 1) "]+")
+                       (concat regexp "\\|"
+                               (substring word 0 i)
+                               "[^" (substring word i (1+ i)) "]"))
+               (i 1 (1+ i)))
+              ((>= i (length word)) regexp)))))
+    (setq font-lock-keywords
+         (list (list (concat "\\<COMMENT\\>"
+                             "\\(" not-comment "\\)\\{0,5\\}"
+                             "\\(\\'\\|\\<COMMENT\\>\\)")
+                     '(0 font-lock-comment-face))
+               (list (concat "\\<CO\\>"
+                             "\\([^C]+\\|C[^O]\\)\\{0,5\\}"
+                             "\\($\\|\\<CO\\>\\)")
+                     '(0 font-lock-comment-face))
+               (list "\\<[A-Z_]+\\>"
+                     '(0 font-lock-keyword-face))
+               (list (concat "\\<"
+                             "[0-9]+"
+                             "\\(\\.[0-9]+\\)?"
+                             "\\([eE][-+]?[0-9]+\\)?"
+                             "\\>")
+                     '(0 mdw-number-face))
+               (list "\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/"
+                     '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
+
 ;;;--------------------------------------------------------------------------
 ;;; REXX configuration.