From: Mark Wooding Date: Wed, 17 Jul 2024 01:41:54 +0000 (+0100) Subject: el/dot-emacs.el: Add support for Ada. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/e98b12c7afb34be03edda58d5f54c23a07d8991e el/dot-emacs.el: Add support for Ada. --- diff --git a/el/dot-emacs.el b/el/dot-emacs.el index df3397d..e7383ad 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -4051,6 +4051,87 @@ (progn (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.