(setq auto-mode-alist (cons (cons "\\.ada$" (quote ada-mode)) auto-mode-alist)) (defvar ada-mode-syntax-table nil "\ Syntax table in use in Ada-mode buffers.") (let ((table (make-syntax-table))) (modify-syntax-entry 95 "_" table) (modify-syntax-entry 35 "_" table) (modify-syntax-entry 40 "()" table) (modify-syntax-entry 41 ")(" table) (modify-syntax-entry 36 "." table) (modify-syntax-entry 42 "." table) (modify-syntax-entry 47 "." table) (modify-syntax-entry 43 "." table) (modify-syntax-entry 45 "." table) (modify-syntax-entry 61 "." table) (modify-syntax-entry 38 "." table) (modify-syntax-entry 124 "." table) (modify-syntax-entry 60 "." table) (modify-syntax-entry 62 "." table) (modify-syntax-entry 91 "." table) (modify-syntax-entry 93 "." table) (modify-syntax-entry 123 "." table) (modify-syntax-entry 125 "." table) (modify-syntax-entry 46 "." table) (modify-syntax-entry 92 "." table) (modify-syntax-entry 58 "." table) (modify-syntax-entry 59 "." table) (modify-syntax-entry 39 "." table) (modify-syntax-entry 34 "\"" table) (setq ada-mode-syntax-table table)) (defvar ada-mode-map nil "\ Keymap used in Ada mode.") (let ((map (make-sparse-keymap))) (define-key map " " (quote ada-newline)) (define-key map "" (quote backward-delete-char-untabify)) (define-key map " " (quote ada-tab)) (define-key map " " (quote ada-untab)) (define-key map "<" (quote ada-backward-to-same-indent)) (define-key map ">" (quote ada-forward-to-same-indent)) (define-key map "h" (quote ada-header)) (define-key map "(" (quote ada-paired-parens)) (define-key map "-" (quote ada-inline-comment)) (define-key map "" (quote ada-array)) (define-key map "b" (quote ada-exception-block)) (define-key map "d" (quote ada-declare-block)) (define-key map "" (quote ada-exception)) (define-key map "c" (quote ada-case)) (define-key map "" (quote ada-package-spec)) (define-key map "k" (quote ada-package-body)) (define-key map "" (quote ada-procedure-spec)) (define-key map "p" (quote ada-subprogram-body)) (define-key map "" (quote ada-function-spec)) (define-key map "f" (quote ada-for-loop)) (define-key map "l" (quote ada-loop)) (define-key map "i" (quote ada-if)) (define-key map "I" (quote ada-elsif)) (define-key map "e" (quote ada-else)) (define-key map "" (quote ada-private)) (define-key map "" (quote ada-record)) (define-key map "" (quote ada-subtype)) (define-key map "s" (quote ada-separate)) (define-key map "" (quote ada-type)) (define-key map "t" (quote ada-tabsize)) (define-key map "w" (quote ada-while-loop)) (define-key map "" (quote ada-when)) (define-key map "x" (quote ada-exit)) (define-key map "C" (quote ada-compile)) (define-key map "B" (quote ada-bind)) (define-key map "E" (quote ada-find-listing)) (define-key map "L" (quote ada-library-name)) (define-key map "O" (quote ada-options-for-bind)) (setq ada-mode-map map)) (defvar ada-indent 4 "\ *Value is the number of columns to indent in Ada-Mode.") (defun ada-mode nil "\ This is a mode intended to support program development in Ada. Most control constructs and declarations of Ada can be inserted in the buffer by typing Control-C followed by a character mnemonic for the construct. C-c C-a array C-c b exception block C-c C-e exception C-c d declare block C-c C-k package spec C-c k package body C-c C-p procedure spec C-c p proc/func body C-c C-f func spec C-c f for loop C-c i if C-c I elsif C-c e else C-c C-v private C-c l loop C-c C-r record C-c c case C-c C-s subtype C-c s separate C-c C-t type C-c t tab spacing for indents C-c C-w when C-c w while C-c x exit C-c ( paired parens C-c - inline comment C-c h header sec C-c C compile C-c B bind C-c E find error list C-c L name library C-c O options for bind C-c < and C-c > move backward and forward respectively to the next line having the same (or lesser) level of indentation. Variable ada-indent controls the number of spaces for indent/undent. \\{ada-mode-map} " (interactive) (byte-code "ÑˆÒ ˆÓ!ˆÔ‰ˆÕ‰ˆÖÃ!ˆ×‰ˆÖÄ!ˆØ‰ˆÙ !ˆÖÆ!ˆÚP‰ˆÖÈ!ˆ‰ˆÖÉ!ˆÊ‰ ˆÖË!ˆÊ‰ˆÖÌ!ˆÛ‰ˆÖÍ!ˆÜ‰ ˆÖÃ!ˆ×‰ˆÖÎ!ˆÝ‰ˆÖÏ!ˆÞ‰ˆÖÐ!ˆÊ‰ˆßà!‡" [ada-mode-map major-mode mode-name comment-column end-comment-column ada-mode-syntax-table paragraph-start page-delimiter paragraph-separate paragraph-ignore-fill-prefix t require-final-newline comment-start comment-end comment-start-skip comment-indent-hook parse-sexp-ignore-comments nil kill-all-local-variables use-local-map ada-mode "Ada" make-local-variable 41 72 set-syntax-table "^$\\|" "--" " " "--+ *" c-comment-indent run-hooks ada-mode-hook] 17)) (defun ada-tabsize (s) "\ changes spacing used for indentation. Reads spacing from minibuffer." (interactive "nnew indentation spacing: ") (byte-code "ˆ ‰‡" [ada-indent s nil] 2)) (defun ada-newline nil "\ Start new line and indent to current tab stop." (interactive) (byte-code "ÁˆÂ à ˆj)‡" [ada-cc nil current-indentation newline] 3)) (defun ada-tab nil "\ Indent to next tab stop." (interactive) (byte-code "ÁˆÂÃÄ \"T\"j‡" [ada-indent nil * / current-indentation] 5)) (defun ada-untab nil "\ Delete backwards to previous tab stop." (interactive) (byte-code "ÁˆÂÁ\"‡" [ada-indent nil backward-delete-char-untabify] 3)) (defun ada-go-to-this-indent (step indent-level) "\ Move point repeatedly by <step> lines till the current line has given indent-level or less, or the start/end of the buffer is hit. Ignore blank lines, statement labels, block/loop names." (byte-code "ÃÄ!!…$ ÅÆ!†$ ÅÇ!†$ ÅÈ!†$ ÅÉ!†$ Ê V…, ˆ‚ ‡" [step indent-level nil zerop forward-line looking-at "^[ ]*$" "^[ ]*--" "^<<[A-Za-z0-9_]+>>" "^[A-Za-z0-9_]+:" current-indentation] 9)) (defun ada-backward-to-same-indent nil "\ Move point backwards to nearest line with same indentation or less. If not found, point is left at top of buffer." (interactive) (byte-code "ÀˆÁÂà \"ˆÄ ‡" [nil ada-go-to-this-indent -1 current-indentation back-to-indentation] 4)) (defun ada-forward-to-same-indent nil "\ Move point forwards to nearest line with same indentation or less. If not found, point is left at start of last line in buffer." (interactive) (byte-code "ÀˆÁÂà \"ˆÄ ‡" [nil ada-go-to-this-indent 1 current-indentation back-to-indentation] 4)) (defun ada-array nil "\ Insert array type definition, prompting for component type, leaving the user to type in the index subtypes." (interactive) (byte-code "ÀˆÁcˆÂ ˆÃÄ!cˆÅ ˆÆcˆÂ ˆÃÇ!cˆÅ ‡" [nil "array ()" backward-char read-string "index subtype[s]: " end-of-line " of ;" "component-type: "] 7)) (defun ada-case nil "\ Build skeleton case statment, prompting for the selector expression. starts up the first when clause, too." (interactive) (byte-code "ÀˆÁcˆÂÃÄ!Å\"ˆÆ ˆÆ ˆÇcˆÈÉ!ˆÊ ˆÊ ˆË ‡" [nil "case " insert read-string "selector expression: " " is" ada-newline "end case;" end-of-line 0 ada-tab ada-when] 9)) (defun ada-declare-block nil "\ Insert a block with a declare part and indent for the 1st declaration." (interactive) (byte-code "ÁˆÂÃ!ÄcˆÅÆ\"?…# Ç ˆÈÉ!ˆÊË\"ˆÌÉ!ˆÍ ˆÎ ˆÎ ˆÏcˆÎ ˆÎ ˆÅÆ\"ƒ? Ðc‚D ÊÑÒ#)ˆÍÓ!ˆÔ ‡" [ada-block-name nil read-string "[block name]: " "declare" string-equal "" beginning-of-line open-line 1 insert ":" next-line end-of-line ada-newline "begin" "end;" "end " ";" -2 ada-tab] 16)) (defun ada-exception-block nil "\ Insert a block with an exception part and indent for the 1st line of code." (interactive) (byte-code "ˆÃÄ!ÅcˆÆÇ\"?…# È ˆÉÊ!ˆËÌ\"ˆÍÊ!ˆÎ ˆÏ ˆÏ ˆÐcˆÏ ˆÏ ˆÆÇ\"ƒ? Ñc‚D ËÒÓ#)ˆÎÔ!ˆÕ ‡" [block-name t nil read-string "[block name]: " "begin" string-equal "" beginning-of-line open-line 1 insert ":" next-line end-of-line ada-newline "exception" "end;" "end " ";" -2 ada-tab] 16)) (defun ada-exception nil "\ Undent and insert an exception part into a block. Reindent." (interactive) (byte-code "ÀˆÁ ˆÂcˆÃ ˆÄ ‡" [nil ada-untab "exception" ada-newline ada-tab] 4)) (defun ada-else nil "\ Add an else clause inside an if-then-end-if clause." (interactive) (byte-code "ÀˆÁ ˆÂcˆÃ ˆÄ ‡" [nil ada-untab "else" ada-newline ada-tab] 4)) (defun ada-exit nil "\ Insert an exit statement, prompting for loop name and condition." (interactive) (byte-code "ˆÃcˆÄÅ!ÆÇ\"?… ÈÉ\")ˆÄÊ!Æ Ç\"?…5 ËÌ \"ƒ1 ÈÉ \"‚5 ÈÍ \")ˆÎc‡" [ada-loop-name ada-exit-condition nil "exit" read-string "[name of loop to exit]: " string-equal "" insert " " "[exit condition]: " string-match "^ *[Ww][Hh][Ee][Nn] +" " when " ";"] 10)) (defun ada-when nil "\ Start a case statement alternative with a when clause." (interactive) (byte-code "ÀˆÁ ˆÂcˆÃÄÅ!Æ\"ˆÇ ˆÈ ‡" [nil ada-untab "when " insert read-string "'|'-delimited choice list: " " =>" ada-newline ada-tab] 6)) (defun ada-for-loop nil "\ Build a skeleton for-loop statement, prompting for the loop parameters." (interactive) (byte-code "ˆÃcˆÄÅ!ÆÇ\"? …&