chiark / gitweb /
el/dot-emacs.el: Add support for Ada.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 17 Jul 2024 01:41:54 +0000 (02:41 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 17 Jul 2024 01:41:54 +0000 (02:41 +0100)
el/dot-emacs.el

index df3397dc3ff433248916aa08e4f846ee4a6f3419..e7383adf76764a96e6d69ca2fec1edbe9c71eeab 100644 (file)
@@ -4051,6 +4051,87 @@ (progn
   (add-hook 'f90-mode-hook 'mdw-misc-mode-config t)
   (add-hook 'f90-mode-hook 'mdw-fontify-f90 t))
 
   (add-hook 'f90-mode-hook 'mdw-misc-mode-config t)
   (add-hook 'f90-mode-hook 'mdw-fontify-f90 t))
 
+;;;--------------------------------------------------------------------------
+;;; Ada programming configuration.
+
+(setq ada-auto-case nil
+      ada-broken-indent 2
+      ada-broken-decl-indent 2
+      ada-indent 2
+      ada-indent-handle-comment-special t
+      ada-indent-record-rel-type 2
+      ada-indent-return 2
+      ada-fill-comment-prefix "-- "
+      ada-fill-comment-postfix ""
+      ada-label-indent -2
+      ada-language-version 'ada2005
+      ada-when-indent 2)
+
+(defun mdw-fontify-ada ()
+
+  ;; Set the fill prefix.
+  (mdw-standard-fill-prefix "\\([ \t]*--+[ \t]*\\)")
+  (setq fill-paragraph-function nil)
+
+  ;; Fontify keywords and things.
+  (make-local-variable 'font-lock-keywords)
+  (let ((ada-keywords
+        (mdw-regexps "abort" "abs" "abstract" "accept" "access" "aliased"
+                       "all" "and" "array" "at"
+                     "begin" "body"
+                     "case" "constant"
+                     "declare" "delay" "delta" "digits" "do"
+                     "else" "elsif" "end" "entry" "exception" "exit"
+                     "for" "function"
+                     "generic" "goto"
+                     "if" "in" "interface" "is"
+                     "limited" "loop"
+                     "mod"
+                     "new" "not" "null"
+                     "of" "or" "others" "out" "overriding"
+                     "package" "parallel" "pragma" "private" "procedure"
+                       "protected"
+                     "raise" "range" "record" "rem" "renames" "requeue"
+                       "return" "reverse"
+                     "select" "separate" "some" "subtype" "synchronized"
+                     "tagged" "task" "terminate" "then" "type"
+                     "until" "use"
+                     "when" "while" "with"
+                     "xor")))
+    (setq font-lock-keywords
+           (list
+
+            ;; Handle the keywords defined above.
+            (list (concat "\\_<\\(" ada-keywords "\\)\\_>")
+                  '(0 font-lock-keyword-face))
+
+            ;; Handle numbers too.
+            (list (concat "\\_<"
+                          "[0-9]+\\(_[0-9]+\\)*"
+                          "\\(" "#"
+                                "[0-9a-f]+\\(_[0-9a-f]+\\)*"
+                                "\\(" "\\."
+                                      "[0-9a-f]+\\(_[0-9a-f]+\\)*" "\\)?"
+                                "#"
+                                "\\(" "e" "[-+]?"
+                                      "[0-9]+\\(_[0-9]+\\)*" "\\_>" "\\)?"
+                          "\\|" "\\(" "\\." "[0-9]+\\(_[0-9]+\\)*" "\\)?"
+                                "\\(" "e" "[-+]?"
+                                      "[0-9]+\\(_[0-9]+\\)*" "\\)?"
+                                "\\_>"
+                          "\\)")
+                  '(0 mdw-number-face))
+
+            ;; And anything else is punctuation.
+            (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+                  '(0 mdw-punct-face)))
+           ;font-lock-syntactic-face-function nil
+                                                )))
+
+(progn
+  (add-hook 'ada-mode-hook 'mdw-misc-mode-config t)
+  (add-hook 'ada-mode-hook 'mdw-fontify-ada t))
+
 ;;;--------------------------------------------------------------------------
 ;;; Assembler mode.
 
 ;;;--------------------------------------------------------------------------
 ;;; Assembler mode.