X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/45e9f7da84c1bd3fc0d36d05c5708ed3b2d3a193..6ccb9cab43613632ece4f62d9ee28d694bc1d666:/lisp/progmodes/ada-mode.el diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el index 33ff4645a7..805444d08b 100644 --- a/lisp/progmodes/ada-mode.el +++ b/lisp/progmodes/ada-mode.el @@ -1,6 +1,6 @@ ;;; ada-mode.el --- major-mode for editing Ada sources -;; Copyright (C) 1994-1995, 1997-2012 Free Software Foundation, Inc. +;; Copyright (C) 1994-1995, 1997-2013 Free Software Foundation, Inc. ;; Author: Rolf Ebert ;; Markus Heritsch @@ -105,7 +105,7 @@ ;; should be loaded before the ada-mode, which will then setup some variables ;; to improve the support for Ada code. ;; Here is the list of these modes: -;; `which-function-mode': Display in the modeline the name of the subprogram +;; `which-function-mode': Display in the mode line the name of the subprogram ;; the cursor is in. ;; `outline-mode': Provides the capability to collapse or expand the code ;; for specific language constructs, for instance if you want to hide the @@ -457,15 +457,8 @@ The extensions should include a `.' if needed.") (defvar ada-mode-extra-prefix "\C-c\C-q" "Prefix key to access `ada-mode-extra-map' functions.") -(defvar ada-mode-abbrev-table nil +(define-abbrev-table 'ada-mode-abbrev-table () "Local abbrev table for Ada mode.") -(define-abbrev-table 'ada-mode-abbrev-table ()) - -(defvar ada-mode-syntax-table nil - "Syntax table to be used for editing Ada source code.") - -(defvar ada-mode-symbol-syntax-table nil - "Syntax table for Ada, where `_' is a word constituent.") (eval-when-compile ;; These values are used in eval-when-compile expressions. @@ -845,61 +838,58 @@ the 4 file locations can be clicked on and jumped to." ;; better is available on XEmacs. ;;------------------------------------------------------------------------- -(defun ada-create-syntax-table () - "Create the two syntax tables use in the Ada mode. -The standard table declares `_' as a symbol constituent, the second one -declares it as a word constituent." - (interactive) - (setq ada-mode-syntax-table (make-syntax-table)) - - ;; define string brackets (`%' is alternative string bracket, but - ;; almost never used as such and throws font-lock and indentation - ;; off the track.) - (modify-syntax-entry ?% "$" ada-mode-syntax-table) - (modify-syntax-entry ?\" "\"" ada-mode-syntax-table) - - (modify-syntax-entry ?: "." ada-mode-syntax-table) - (modify-syntax-entry ?\; "." ada-mode-syntax-table) - (modify-syntax-entry ?& "." ada-mode-syntax-table) - (modify-syntax-entry ?\| "." ada-mode-syntax-table) - (modify-syntax-entry ?+ "." ada-mode-syntax-table) - (modify-syntax-entry ?* "." ada-mode-syntax-table) - (modify-syntax-entry ?/ "." ada-mode-syntax-table) - (modify-syntax-entry ?= "." ada-mode-syntax-table) - (modify-syntax-entry ?< "." ada-mode-syntax-table) - (modify-syntax-entry ?> "." ada-mode-syntax-table) - (modify-syntax-entry ?$ "." ada-mode-syntax-table) - (modify-syntax-entry ?\[ "." ada-mode-syntax-table) - (modify-syntax-entry ?\] "." ada-mode-syntax-table) - (modify-syntax-entry ?\{ "." ada-mode-syntax-table) - (modify-syntax-entry ?\} "." ada-mode-syntax-table) - (modify-syntax-entry ?. "." ada-mode-syntax-table) - (modify-syntax-entry ?\\ "." ada-mode-syntax-table) - (modify-syntax-entry ?\' "." ada-mode-syntax-table) - - ;; a single hyphen is punctuation, but a double hyphen starts a comment - (modify-syntax-entry ?- ". 12" ada-mode-syntax-table) - - ;; See the comment above on grammar related function for the special - ;; setup for '#'. - (if (featurep 'xemacs) - (modify-syntax-entry ?# "<" ada-mode-syntax-table) - (modify-syntax-entry ?# "$" ada-mode-syntax-table)) - - ;; and \f and \n end a comment - (modify-syntax-entry ?\f "> " ada-mode-syntax-table) - (modify-syntax-entry ?\n "> " ada-mode-syntax-table) - - ;; define what belongs in Ada symbols - (modify-syntax-entry ?_ "_" ada-mode-syntax-table) - - ;; define parentheses to match - (modify-syntax-entry ?\( "()" ada-mode-syntax-table) - (modify-syntax-entry ?\) ")(" ada-mode-syntax-table) - - (setq ada-mode-symbol-syntax-table (copy-syntax-table ada-mode-syntax-table)) - (modify-syntax-entry ?_ "w" ada-mode-symbol-syntax-table) - ) +(defvar ada-mode-syntax-table + (let ((st (make-syntax-table))) + ;; Define string brackets (`%' is alternative string bracket, but + ;; almost never used as such and throws font-lock and indentation + ;; off the track.) + (modify-syntax-entry ?% "$" st) + (modify-syntax-entry ?\" "\"" st) + + (modify-syntax-entry ?: "." st) + (modify-syntax-entry ?\; "." st) + (modify-syntax-entry ?& "." st) + (modify-syntax-entry ?\| "." st) + (modify-syntax-entry ?+ "." st) + (modify-syntax-entry ?* "." st) + (modify-syntax-entry ?/ "." st) + (modify-syntax-entry ?= "." st) + (modify-syntax-entry ?< "." st) + (modify-syntax-entry ?> "." st) + (modify-syntax-entry ?$ "." st) + (modify-syntax-entry ?\[ "." st) + (modify-syntax-entry ?\] "." st) + (modify-syntax-entry ?\{ "." st) + (modify-syntax-entry ?\} "." st) + (modify-syntax-entry ?. "." st) + (modify-syntax-entry ?\\ "." st) + (modify-syntax-entry ?\' "." st) + + ;; A single hyphen is punctuation, but a double hyphen starts a comment. + (modify-syntax-entry ?- ". 12" st) + + ;; See the comment above on grammar related function for the special + ;; setup for '#'. + (modify-syntax-entry ?# (if (featurep 'xemacs) "<" "$") st) + + ;; And \f and \n end a comment. + (modify-syntax-entry ?\f "> " st) + (modify-syntax-entry ?\n "> " st) + + ;; Define what belongs in Ada symbols. + (modify-syntax-entry ?_ "_" st) + + ;; Define parentheses to match. + (modify-syntax-entry ?\( "()" st) + (modify-syntax-entry ?\) ")(" st) + st) + "Syntax table to be used for editing Ada source code.") + +(defvar ada-mode-symbol-syntax-table + (let ((st (make-syntax-table ada-mode-syntax-table))) + (modify-syntax-entry ?_ "w" st) + st) + "Syntax table for Ada, where `_' is a word constituent.") ;; Support of special characters in XEmacs (see the comments at the beginning ;; of the section on Grammar related functions). @@ -1293,7 +1283,7 @@ the file name." (if ada-popup-key (define-key ada-mode-map ada-popup-key 'ada-popup-menu)) - ;; Support for Abbreviations (the user still need to "M-x abbrev-mode" + ;; Support for Abbreviations (the user still needs to "M-x abbrev-mode"). (setq local-abbrev-table ada-mode-abbrev-table) ;; Support for which-function mode @@ -1625,9 +1615,8 @@ ARG is the prefix the user entered with \\[universal-argument]." (let ((lastk last-command-event)) (with-syntax-table ada-mode-symbol-syntax-table - (cond ((or (eq lastk ?\n) - (eq lastk ?\r)) - ;; horrible kludge + (cond ((memq lastk '(?\n ?\r)) + ;; Horrible kludge. (insert " ") (ada-adjust-case) ;; horrible dekludge @@ -1706,9 +1695,7 @@ ARG is ignored, and is there for compatibility with `capitalize-word' only." (interactive) (let ((end (save-excursion (skip-syntax-forward "w") (point))) (begin (save-excursion (skip-syntax-backward "w") (point)))) - (modify-syntax-entry ?_ "_") - (capitalize-region begin end) - (modify-syntax-entry ?_ "w"))) + (capitalize-region begin end))) (defun ada-adjust-case-region (from to) "Adjust the case of all words in the region between FROM and TO. @@ -2165,7 +2152,7 @@ and the offset." (unwind-protect (with-syntax-table ada-mode-symbol-syntax-table - ;; This need to be done here so that the advice is not always + ;; This needs to be done here so that the advice is not always ;; activated (this might interact badly with other modes) (if (featurep 'xemacs) (ad-activate 'parse-partial-sexp t)) @@ -3419,27 +3406,23 @@ Stop the search at LIMIT." If BACKWARD is non-nil, jump to the beginning of the previous word. Return the new position of point or nil if not found." (let ((match-cons nil) - (orgpoint (point)) - (old-syntax (char-to-string (char-syntax ?_)))) - (modify-syntax-entry ?_ "w") + (orgpoint (point))) (unless backward - (skip-syntax-forward "w")) + (skip-syntax-forward "w_")) (if (setq match-cons - (ada-search-ignore-string-comment "\\w" backward nil t)) + (ada-search-ignore-string-comment "\\sw\\|\\s_" backward nil t)) ;; ;; move to the beginning of the word found ;; (progn (goto-char (car match-cons)) - (skip-syntax-backward "w") + (skip-syntax-backward "w_") (point)) ;; ;; if not found, restore old position of point ;; (goto-char orgpoint) - 'nil) - (modify-syntax-entry ?_ old-syntax)) - ) + 'nil))) (defun ada-check-matching-start (keyword) @@ -5055,7 +5038,7 @@ Since the search can be long, the results are cached." (re-search-backward ada-imenu-subprogram-menu-re nil t)) ;; Get the function name, but not the properties, or this changes - ;; the face in the modeline on Emacs 21 + ;; the face in the mode line on Emacs 21 (setq func-name (match-string-no-properties 3)) (if (and (not (ada-in-comment-p)) (not (save-excursion @@ -5218,11 +5201,11 @@ Return nil if no body was found." ;; correctly highlight a with_clause that spans multiple lines. (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)" "[ \t]+\\([a-zA-Z0-9_., \t]+\\)\\W") - '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t)) + '(1 font-lock-keyword-face) '(2 font-lock-constant-face nil t)) ;; ;; Goto tags. - '("<<\\(\\sw+\\)>>" 1 font-lock-reference-face) + '("<<\\(\\sw+\\)>>" 1 font-lock-constant-face) ;; Highlight based-numbers (R. Reagan ) (list "\\([0-9]+#[0-9a-fA-F_]+#\\)" '(1 font-lock-constant-face t)) @@ -5431,9 +5414,6 @@ This function typically is to be hooked into `ff-file-created-hook'." (ada-create-keymap) (ada-create-menu) -;; Create the syntax tables, but do not activate them -(ada-create-syntax-table) - ;; Add the default extensions (and set up speedbar) (ada-add-extensions ".ads" ".adb") ;; This two files are generated by GNAT when running with -gnatD