(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 " "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 "?O ^O!^?^?^OA!^?^OA!^?^U !^OA!^UP%^OE!^%^OE!^? ^OE!^? ^OI!^? ^OI!^? " "--+ *" 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 "?A A ^j)+" [ada-cc nil current-indentation newline] 3)) (defun ada-tab nil "\ Indent to next tab stop." (interactive) (byte-code "?AAA \"T\"j+" [ada-indent nil * / current-indentation] 5)) (defun ada-untab nil "\ Delete backwards to previous tab stop." (interactive) (byte-code "?AA\"+" [ada-indent nil backward-delete-char-untabify] 3)) (defun ada-go-to-this-indent (step indent-level) "\ Move point repeatedly by 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 "AA!!.$ (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 "?AAA \"^A +" [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 "?AAA \"^A +" [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 "?Ac^A ^AA!c^A ^Ac^A ^AC!c^A +" [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 "?Ac^AAA!A\"^A ^A ^Cc^EE!^E ^E ^E +" [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 "?AA!Ac^AA\"?.# (defun ada-exception-block nil "\ Insert a block with an exception part and indent for the 1st line of code." (interactive) (byte-code "^AA!Ac^AC\"?.# (defun ada-exception nil "\ Undent and insert an exception part into a block. Reindent." (interactive) (byte-code "?A ^Ac^A ^A +" [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 "?A ^Ac^A ^A +" [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 "^Ac^AA!AC\"?. (defun ada-when nil "\ Start a case statement alternative with a when clause." (interactive) (byte-code "?A ^Ac^AAA!A\"^C ^E +" [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 "^Ac^AA!AC\"? .& (defun ada-header nil "\ Insert a comment block containing the module title, author, etc." (interactive) (byte-code "?Ac^AA!c^AAA \"^ACE \"^AEE EI I%+" [nil "-- -- Title: " read-string "Title: " insert " -- Created: " current-time-string " -- Author: " user-full-name " -- <" user-login-name "@" system-name "> -- "] 13)) (defun ada-if nil "\ Insert skeleton if statment, prompting for a boolean-expression." (interactive) (byte-code "?Ac^AAA!A\"^A ^A ^Cc^EE!^E +" [nil "if " insert read-string "condition: " " then" ada-newline "end if;" end-of-line 0 ada-tab] 7)) (defun ada-elsif nil "\ Add an elsif clause to an if statement, prompting for the boolean-expression." (interactive) (byte-code "?A ^Ac^AAA!A\"^C ^E +" [nil ada-untab "elsif " insert read-string "condition: " " then" ada-newline ada-tab] 6)) (defun ada-loop nil "\ insert a skeleton loop statement. exit statement added by hand." (interactive) (byte-code "^Ac^AA!AC\"? .& (defun ada-package-spec nil "\ Insert a skeleton package specification." (interactive) (byte-code "?Ac^AA!AA\"^C ^C ^AEE#^EE!^I )+" [ada-package-name nil "package " read-string "package name: " insert " is" ada-newline "end " ";" end-of-line 0 ada-tab] 8)) (defun ada-package-body nil "\ Insert a skeleton package body -- includes a begin statement." (interactive) (byte-code "?Ac^AA!AA\"^C ^C ^Ec^C ^AEE#^EI!^I )+" [ada-package-name nil "package body " read-string "package name: " insert " is" ada-newline "begin" "end " ";" end-of-line -1 ada-tab] 9)) (defun ada-private nil "\ Undent and start a private section of a package spec. Reindent." (interactive) (byte-code "?A ^Ac^A ^A +" [nil ada-untab "private" ada-newline ada-tab] 4)) (defun ada-get-arg-list nil "\ Read from user a procedure or function argument list. Add parens unless arguments absent, and insert into buffer. Individual arguments are arranged vertically if entered one-at-a-time. Arguments ending with ';' are presumed single and stacked." (byte-code "Ac^iAA!A A\"f (defun ada-function-spec nil "\ Insert a function specification. Prompts for name and arguments." (interactive) (byte-code "?Ac^AA!c^A ^Ac^AA!c+" [nil "function " read-string "function name: " ada-get-arg-list " return " "result type: "] 4)) (defun ada-procedure-spec nil "\ Insert a procedure specification, prompting for its name and arguments." (interactive) (byte-code "?Ac^AA!c^A +" [nil "procedure " read-string "procedure name: " ada-get-arg-list] 3)) (defun get-ada-subprogram-name nil "\ Return (without moving point or mark) a pair whose CAR is the name of the function or procedure whose spec immediately precedes point, and whose CDR is the column nbr the procedure/function keyword was found at." (byte-code "SAAAAA#f4 (defun ada-subprogram-body nil "\ Insert frame for subprogram body. Invoke right after ada-function-spec or ada-procedure-spec." (interactive) (byte-code "?Ac^A A ^Aj^A ^Ac^A ^A ^CE@E#)^EE!^I +" [ada-subprogram-name-col nil " is" get-ada-subprogram-name newline ada-newline "begin" insert "end " ";" end-of-line -2 ada-tab] 9)) (defun ada-separate nil "\ Finish a body stub with 'is separate'." (interactive) (byte-code "?Ac^A ^A ^Ac^A ^A +" [nil " is" ada-newline ada-tab "separate;" ada-untab] 5)) (defun ada-record nil "\ Insert a skeleton record type declaration." (interactive) (byte-code "?Ac^A ^A ^Ac^AA!^A +" [nil "record" ada-newline "end record;" end-of-line 0 ada-tab] 5)) (defun ada-subtype nil "\ Start insertion of a subtype declaration, prompting for the subtype name." (interactive) (byte-code "?AAAA!A#^A ^CE!+" [nil insert "subtype " read-string "subtype name: " " is ;" backward-char message "insert subtype indication."] 5)) (defun ada-type nil "\ Start insertion of a type declaration, prompting for the type name." (interactive) (byte-code "?AAAA!\"^AA!CE\"?. (defun ada-while-loop nil (interactive) (byte-code "^Ac^AA!AC\"? .& (defun ada-paired-parens nil "\ Insert a pair of round parentheses, placing point between them." (interactive) (byte-code "?Ac^A +" [nil "()" backward-char] 2)) (defun ada-inline-comment nil "\ Start a comment after the end of the line, indented at least COMMENT-COLUMN. If starting after END-COMMENT-COLUMN, start a new line." (interactive) (byte-code "^A ^iV. (defun ada-display-comment nil "\ Inserts 3 comment lines, making a display comment." (interactive) (byte-code "?Ac^AA!+" [nil "-- -- --" end-of-line 0] 2)) (defvar ada-lib-dir-name "lib" "\ *Current ada program library directory.") (defvar ada-bind-opts "" "\ *Options to supply for binding.") (defun ada-library-name (ada-lib-name) "\ Specify name of ada library directory for later compilations." (interactive "Dname of ada library directory: ") (byte-code "^ %+" [ada-lib-dir-name ada-lib-name nil] 2)) (defun ada-options-for-bind nil "\ Specify options, such as -m and -i, needed for adabind." (byte-code "AA!%+" [ada-bind-opts read-string "-m and -i options for adabind: "] 3)) (defun ada-compile (ada-prefix-arg) "\ Save the current buffer and compile it into the current program library. Initialize the library if a prefix arg is given." (interactive "P") (byte-code "? ?f &!*+" [ada-init ada-prefix-arg ada-source-file ada-lib-dir-name nil "" "-n " buffer-name compile concat "adacomp " "-l " " "] 9)) (defun ada-find-listing nil "\ Find listing file for ada source in current buffer, using other window." (interactive) (byte-code "?AA AAOAP!^AC!+" [nil find-file-other-window buffer-name 0 -4 ".lis" search-forward "*** ERROR"] 5)) (defun ada-bind nil "\ Bind the current program library, using the current binding options." (interactive) (byte-code "^AAA R!+" [ada-bind-opts ada-lib-dir-name nil compile "adabind " " "] 5)) .