diff options
| author | Juanma Barranquero | 2006-10-29 15:29:57 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2006-10-29 15:29:57 +0000 |
| commit | f70b58b0ca8f7fcc6ca66dbb62d3f7b8adb8d627 (patch) | |
| tree | f27cbb657d5254d160936d68185afc267acb3c4f | |
| parent | 8e7225a26292e10aff20e01c27d93fa9d5fa17a8 (diff) | |
| download | emacs-f70b58b0ca8f7fcc6ca66dbb62d3f7b8adb8d627.tar.gz emacs-f70b58b0ca8f7fcc6ca66dbb62d3f7b8adb8d627.zip | |
Change maintainer, apply whitespace-clean, checkdoc. Minor improvements to many
doc strings.
(ada-mode-version): New function.
(ada-create-menu): Menu operations are available for all supported compilers.
| -rw-r--r-- | lisp/progmodes/ada-mode.el | 2842 |
1 files changed, 1421 insertions, 1421 deletions
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el index d60746c5de8..7015a24ac01 100644 --- a/lisp/progmodes/ada-mode.el +++ b/lisp/progmodes/ada-mode.el | |||
| @@ -6,8 +6,7 @@ | |||
| 6 | ;; Author: Rolf Ebert <ebert@inf.enst.fr> | 6 | ;; Author: Rolf Ebert <ebert@inf.enst.fr> |
| 7 | ;; Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de> | 7 | ;; Markus Heritsch <Markus.Heritsch@studbox.uni-stuttgart.de> |
| 8 | ;; Emmanuel Briot <briot@gnat.com> | 8 | ;; Emmanuel Briot <briot@gnat.com> |
| 9 | ;; Maintainer: Emmanuel Briot <briot@gnat.com> | 9 | ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org> |
| 10 | ;; Ada Core Technologies's version: Revision: 1.188 | ||
| 11 | ;; Keywords: languages ada | 10 | ;; Keywords: languages ada |
| 12 | 11 | ||
| 13 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| @@ -30,7 +29,7 @@ | |||
| 30 | ;;; Commentary: | 29 | ;;; Commentary: |
| 31 | ;;; This mode is a major mode for editing Ada83 and Ada95 source code. | 30 | ;;; This mode is a major mode for editing Ada83 and Ada95 source code. |
| 32 | ;;; This is a major rewrite of the file packaged with Emacs-20. The | 31 | ;;; This is a major rewrite of the file packaged with Emacs-20. The |
| 33 | ;;; ada-mode is composed of four lisp files, ada-mode.el, ada-xref.el, | 32 | ;;; ada-mode is composed of four Lisp files, ada-mode.el, ada-xref.el, |
| 34 | ;;; ada-prj.el and ada-stmt.el. Only this file (ada-mode.el) is | 33 | ;;; ada-prj.el and ada-stmt.el. Only this file (ada-mode.el) is |
| 35 | ;;; completely independent from the GNU Ada compiler Gnat, distributed | 34 | ;;; completely independent from the GNU Ada compiler Gnat, distributed |
| 36 | ;;; by Ada Core Technologies. All the other files rely heavily on | 35 | ;;; by Ada Core Technologies. All the other files rely heavily on |
| @@ -79,14 +78,14 @@ | |||
| 79 | ;;; to his version. | 78 | ;;; to his version. |
| 80 | ;;; | 79 | ;;; |
| 81 | ;;; A complete rewrite for Emacs-20 / Gnat-3.11 has been done by Ada Core | 80 | ;;; A complete rewrite for Emacs-20 / Gnat-3.11 has been done by Ada Core |
| 82 | ;;; Technologies. Please send bugs to briot@gnat.com | 81 | ;;; Technologies. |
| 83 | 82 | ||
| 84 | ;;; Credits: | 83 | ;;; Credits: |
| 85 | ;;; Many thanks to John McCabe <john@assen.demon.co.uk> for sending so | 84 | ;;; Many thanks to John McCabe <john@assen.demon.co.uk> for sending so |
| 86 | ;;; many patches included in this package. | 85 | ;;; many patches included in this package. |
| 87 | ;;; Christian Egli <Christian.Egli@hcsd.hac.com>: | 86 | ;;; Christian Egli <Christian.Egli@hcsd.hac.com>: |
| 88 | ;;; ada-imenu-generic-expression | 87 | ;;; ada-imenu-generic-expression |
| 89 | ;;; Many thanks also to the following persons that have contributed one day | 88 | ;;; Many thanks also to the following persons that have contributed |
| 90 | ;;; to the ada-mode | 89 | ;;; to the ada-mode |
| 91 | ;;; Philippe Waroquiers (PW) <philippe@cfmu.eurocontrol.be> in particular, | 90 | ;;; Philippe Waroquiers (PW) <philippe@cfmu.eurocontrol.be> in particular, |
| 92 | ;;; woodruff@stc.llnl.gov (John Woodruff) | 91 | ;;; woodruff@stc.llnl.gov (John Woodruff) |
| @@ -142,12 +141,12 @@ | |||
| 142 | "Return t if Emacs's version is greater or equal to MAJOR.MINOR. | 141 | "Return t if Emacs's version is greater or equal to MAJOR.MINOR. |
| 143 | If IS-XEMACS is non-nil, check for XEmacs instead of Emacs." | 142 | If IS-XEMACS is non-nil, check for XEmacs instead of Emacs." |
| 144 | (let ((xemacs-running (or (string-match "Lucid" emacs-version) | 143 | (let ((xemacs-running (or (string-match "Lucid" emacs-version) |
| 145 | (string-match "XEmacs" emacs-version)))) | 144 | (string-match "XEmacs" emacs-version)))) |
| 146 | (and (or (and is-xemacs xemacs-running) | 145 | (and (or (and is-xemacs xemacs-running) |
| 147 | (not (or is-xemacs xemacs-running))) | 146 | (not (or is-xemacs xemacs-running))) |
| 148 | (or (> emacs-major-version major) | 147 | (or (> emacs-major-version major) |
| 149 | (and (= emacs-major-version major) | 148 | (and (= emacs-major-version major) |
| 150 | (>= emacs-minor-version minor))))))) | 149 | (>= emacs-minor-version minor))))))) |
| 151 | 150 | ||
| 152 | 151 | ||
| 153 | ;; This call should not be made in the release that is done for the | 152 | ;; This call should not be made in the release that is done for the |
| @@ -155,6 +154,14 @@ If IS-XEMACS is non-nil, check for XEmacs instead of Emacs." | |||
| 155 | ;;(if (not (ada-check-emacs-version 21 1)) | 154 | ;;(if (not (ada-check-emacs-version 21 1)) |
| 156 | ;; (require 'ada-support)) | 155 | ;; (require 'ada-support)) |
| 157 | 156 | ||
| 157 | (defun ada-mode-version () | ||
| 158 | "Return Ada mode version." | ||
| 159 | (interactive) | ||
| 160 | (let ((version-string "3.5")) | ||
| 161 | (if (interactive-p) | ||
| 162 | (message version-string) | ||
| 163 | version-string))) | ||
| 164 | |||
| 158 | (defvar ada-mode-hook nil | 165 | (defvar ada-mode-hook nil |
| 159 | "*List of functions to call when Ada mode is invoked. | 166 | "*List of functions to call when Ada mode is invoked. |
| 160 | This hook is automatically executed after the `ada-mode' is | 167 | This hook is automatically executed after the `ada-mode' is |
| @@ -162,7 +169,7 @@ fully loaded. | |||
| 162 | This is a good place to add Ada environment specific bindings.") | 169 | This is a good place to add Ada environment specific bindings.") |
| 163 | 170 | ||
| 164 | (defgroup ada nil | 171 | (defgroup ada nil |
| 165 | "Major mode for editing Ada source in Emacs." | 172 | "Major mode for editing and compiling Ada source in Emacs." |
| 166 | :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) | 173 | :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) |
| 167 | :group 'languages) | 174 | :group 'languages) |
| 168 | 175 | ||
| @@ -178,7 +185,7 @@ and `ada-case-attribute'." | |||
| 178 | An example is : | 185 | An example is : |
| 179 | declare | 186 | declare |
| 180 | A, | 187 | A, |
| 181 | >>>>>B : Integer; -- from ada-broken-decl-indent" | 188 | >>>>>B : Integer;" |
| 182 | :type 'integer :group 'ada) | 189 | :type 'integer :group 'ada) |
| 183 | 190 | ||
| 184 | (defcustom ada-broken-indent 2 | 191 | (defcustom ada-broken-indent 2 |
| @@ -186,7 +193,7 @@ An example is : | |||
| 186 | 193 | ||
| 187 | An example is : | 194 | An example is : |
| 188 | My_Var : My_Type := (Field1 => | 195 | My_Var : My_Type := (Field1 => |
| 189 | >>>>>>>>>Value); -- from ada-broken-indent" | 196 | >>>>>>>>>Value);" |
| 190 | :type 'integer :group 'ada) | 197 | :type 'integer :group 'ada) |
| 191 | 198 | ||
| 192 | (defcustom ada-continuation-indent ada-broken-indent | 199 | (defcustom ada-continuation-indent ada-broken-indent |
| @@ -194,7 +201,7 @@ An example is : | |||
| 194 | 201 | ||
| 195 | An example is : | 202 | An example is : |
| 196 | Func (Param1, | 203 | Func (Param1, |
| 197 | >>>>>Param2);" | 204 | >>>>>Param2);" |
| 198 | :type 'integer :group 'ada) | 205 | :type 'integer :group 'ada) |
| 199 | 206 | ||
| 200 | (defcustom ada-case-attribute 'ada-capitalize-word | 207 | (defcustom ada-case-attribute 'ada-capitalize-word |
| @@ -202,10 +209,10 @@ An example is : | |||
| 202 | It may be `downcase-word', `upcase-word', `ada-loose-case-word', | 209 | It may be `downcase-word', `upcase-word', `ada-loose-case-word', |
| 203 | `ada-capitalize-word' or `ada-no-auto-case'." | 210 | `ada-capitalize-word' or `ada-no-auto-case'." |
| 204 | :type '(choice (const downcase-word) | 211 | :type '(choice (const downcase-word) |
| 205 | (const upcase-word) | 212 | (const upcase-word) |
| 206 | (const ada-capitalize-word) | 213 | (const ada-capitalize-word) |
| 207 | (const ada-loose-case-word) | 214 | (const ada-loose-case-word) |
| 208 | (const ada-no-auto-case)) | 215 | (const ada-no-auto-case)) |
| 209 | :group 'ada) | 216 | :group 'ada) |
| 210 | 217 | ||
| 211 | (defcustom ada-case-exception-file | 218 | (defcustom ada-case-exception-file |
| @@ -228,10 +235,10 @@ by a comment." | |||
| 228 | It may be `downcase-word', `upcase-word', `ada-loose-case-word' or | 235 | It may be `downcase-word', `upcase-word', `ada-loose-case-word' or |
| 229 | `ada-capitalize-word'." | 236 | `ada-capitalize-word'." |
| 230 | :type '(choice (const downcase-word) | 237 | :type '(choice (const downcase-word) |
| 231 | (const upcase-word) | 238 | (const upcase-word) |
| 232 | (const ada-capitalize-word) | 239 | (const ada-capitalize-word) |
| 233 | (const ada-loose-case-word) | 240 | (const ada-loose-case-word) |
| 234 | (const ada-no-auto-case)) | 241 | (const ada-no-auto-case)) |
| 235 | :group 'ada) | 242 | :group 'ada) |
| 236 | 243 | ||
| 237 | (defcustom ada-case-identifier 'ada-loose-case-word | 244 | (defcustom ada-case-identifier 'ada-loose-case-word |
| @@ -239,10 +246,10 @@ It may be `downcase-word', `upcase-word', `ada-loose-case-word' or | |||
| 239 | It may be `downcase-word', `upcase-word', `ada-loose-case-word' or | 246 | It may be `downcase-word', `upcase-word', `ada-loose-case-word' or |
| 240 | `ada-capitalize-word'." | 247 | `ada-capitalize-word'." |
| 241 | :type '(choice (const downcase-word) | 248 | :type '(choice (const downcase-word) |
| 242 | (const upcase-word) | 249 | (const upcase-word) |
| 243 | (const ada-capitalize-word) | 250 | (const ada-capitalize-word) |
| 244 | (const ada-loose-case-word) | 251 | (const ada-loose-case-word) |
| 245 | (const ada-no-auto-case)) | 252 | (const ada-no-auto-case)) |
| 246 | :group 'ada) | 253 | :group 'ada) |
| 247 | 254 | ||
| 248 | (defcustom ada-clean-buffer-before-saving t | 255 | (defcustom ada-clean-buffer-before-saving t |
| @@ -255,7 +262,7 @@ It may be `downcase-word', `upcase-word', `ada-loose-case-word' or | |||
| 255 | An example is : | 262 | An example is : |
| 256 | procedure Foo is | 263 | procedure Foo is |
| 257 | begin | 264 | begin |
| 258 | >>>>>>>>>>null; -- from ada-indent" | 265 | >>>>>>>>>>null;" |
| 259 | :type 'integer :group 'ada) | 266 | :type 'integer :group 'ada) |
| 260 | 267 | ||
| 261 | (defcustom ada-indent-after-return t | 268 | (defcustom ada-indent-after-return t |
| @@ -269,7 +276,7 @@ Note that indentation is calculated only if `ada-indent-comment-as-code' is t. | |||
| 269 | 276 | ||
| 270 | For instance: | 277 | For instance: |
| 271 | A := 1; -- A multi-line comment | 278 | A := 1; -- A multi-line comment |
| 272 | -- aligned if ada-indent-align-comments is t" | 279 | -- aligned if ada-indent-align-comments is t" |
| 273 | :type 'boolean :group 'ada) | 280 | :type 'boolean :group 'ada) |
| 274 | 281 | ||
| 275 | (defcustom ada-indent-comment-as-code t | 282 | (defcustom ada-indent-comment-as-code t |
| @@ -308,7 +315,7 @@ type A is | |||
| 308 | 315 | ||
| 309 | An example is: | 316 | An example is: |
| 310 | type A is | 317 | type A is |
| 311 | >>>>>>>>>>>record -- from ada-indent-record-rel-type" | 318 | >>>>>>>>>>>record" |
| 312 | :type 'integer :group 'ada) | 319 | :type 'integer :group 'ada) |
| 313 | 320 | ||
| 314 | (defcustom ada-indent-renames ada-broken-indent | 321 | (defcustom ada-indent-renames ada-broken-indent |
| @@ -318,8 +325,8 @@ the open parenthesis (if there is no parenthesis, `ada-broken-indent' is used). | |||
| 318 | 325 | ||
| 319 | An example is: | 326 | An example is: |
| 320 | function A (B : Integer) | 327 | function A (B : Integer) |
| 321 | return C; -- from ada-indent-return | 328 | return C; |
| 322 | >>>renames Foo; -- from ada-indent-renames" | 329 | >>>renames Foo;" |
| 323 | :type 'integer :group 'ada) | 330 | :type 'integer :group 'ada) |
| 324 | 331 | ||
| 325 | (defcustom ada-indent-return 0 | 332 | (defcustom ada-indent-return 0 |
| @@ -329,7 +336,7 @@ the open parenthesis (if there is no parenthesis, `ada-broken-indent' is used). | |||
| 329 | 336 | ||
| 330 | An example is: | 337 | An example is: |
| 331 | function A (B : Integer) | 338 | function A (B : Integer) |
| 332 | >>>>>return C; -- from ada-indent-return" | 339 | >>>>>return C;" |
| 333 | :type 'integer :group 'ada) | 340 | :type 'integer :group 'ada) |
| 334 | 341 | ||
| 335 | (defcustom ada-indent-to-open-paren t | 342 | (defcustom ada-indent-to-open-paren t |
| @@ -353,7 +360,7 @@ Used by `ada-fill-comment-paragraph-postfix'." | |||
| 353 | An example is: | 360 | An example is: |
| 354 | procedure Foo is | 361 | procedure Foo is |
| 355 | begin | 362 | begin |
| 356 | >>>>>>>>>>>>Label: -- from ada-label-indent | 363 | >>>>Label: |
| 357 | 364 | ||
| 358 | This is also used for <<..>> labels" | 365 | This is also used for <<..>> labels" |
| 359 | :type 'integer :group 'ada) | 366 | :type 'integer :group 'ada) |
| @@ -363,8 +370,7 @@ This is also used for <<..>> labels" | |||
| 363 | :type '(choice (const ada83) (const ada95)) :group 'ada) | 370 | :type '(choice (const ada83) (const ada95)) :group 'ada) |
| 364 | 371 | ||
| 365 | (defcustom ada-move-to-declaration nil | 372 | (defcustom ada-move-to-declaration nil |
| 366 | "*Non-nil means `ada-move-to-start' moves point to the subprogram declaration, | 373 | "*Non-nil means `ada-move-to-start' moves to the subprogram declaration, not to 'begin'." |
| 367 | not to 'begin'." | ||
| 368 | :type 'boolean :group 'ada) | 374 | :type 'boolean :group 'ada) |
| 369 | 375 | ||
| 370 | (defcustom ada-popup-key '[down-mouse-3] | 376 | (defcustom ada-popup-key '[down-mouse-3] |
| @@ -378,13 +384,12 @@ If nil, no contextual menu is available." | |||
| 378 | (split-string (or (getenv "ADA_INCLUDE_PATH") "") ":") | 384 | (split-string (or (getenv "ADA_INCLUDE_PATH") "") ":") |
| 379 | '("/usr/adainclude" "/usr/local/adainclude" | 385 | '("/usr/adainclude" "/usr/local/adainclude" |
| 380 | "/opt/gnu/adainclude")) | 386 | "/opt/gnu/adainclude")) |
| 381 | "*List of directories to search for Ada files. | 387 | "*Default list of directories to search for Ada files. |
| 382 | See the description for the `ff-search-directories' variable. This variable | 388 | See the description for the `ff-search-directories' variable. This variable |
| 383 | is the initial value of this variable, and is copied and modified in | 389 | is the initial value of `ada-search-directories-internal'." |
| 384 | `ada-search-directories-internal'." | ||
| 385 | :type '(repeat (choice :tag "Directory" | 390 | :type '(repeat (choice :tag "Directory" |
| 386 | (const :tag "default" nil) | 391 | (const :tag "default" nil) |
| 387 | (directory :format "%v"))) | 392 | (directory :format "%v"))) |
| 388 | :group 'ada) | 393 | :group 'ada) |
| 389 | 394 | ||
| 390 | (defvar ada-search-directories-internal ada-search-directories | 395 | (defvar ada-search-directories-internal ada-search-directories |
| @@ -398,7 +403,7 @@ and the standard runtime location, and the value of the user-defined | |||
| 398 | 403 | ||
| 399 | An example is: | 404 | An example is: |
| 400 | if A = B | 405 | if A = B |
| 401 | >>>>>>>>>>>then -- from ada-stmt-end-indent" | 406 | >>>>then" |
| 402 | :type 'integer :group 'ada) | 407 | :type 'integer :group 'ada) |
| 403 | 408 | ||
| 404 | (defcustom ada-tab-policy 'indent-auto | 409 | (defcustom ada-tab-policy 'indent-auto |
| @@ -406,10 +411,10 @@ An example is: | |||
| 406 | Must be one of : | 411 | Must be one of : |
| 407 | `indent-rigidly' : always adds `ada-indent' blanks at the beginning of the line. | 412 | `indent-rigidly' : always adds `ada-indent' blanks at the beginning of the line. |
| 408 | `indent-auto' : use indentation functions in this file. | 413 | `indent-auto' : use indentation functions in this file. |
| 409 | `always-tab' : do indent-relative." | 414 | `always-tab' : do `indent-relative'." |
| 410 | :type '(choice (const indent-auto) | 415 | :type '(choice (const indent-auto) |
| 411 | (const indent-rigidly) | 416 | (const indent-rigidly) |
| 412 | (const always-tab)) | 417 | (const always-tab)) |
| 413 | :group 'ada) | 418 | :group 'ada) |
| 414 | 419 | ||
| 415 | (defcustom ada-use-indent ada-broken-indent | 420 | (defcustom ada-use-indent ada-broken-indent |
| @@ -417,7 +422,7 @@ Must be one of : | |||
| 417 | 422 | ||
| 418 | An example is: | 423 | An example is: |
| 419 | use Ada.Text_IO, | 424 | use Ada.Text_IO, |
| 420 | >>>>>Ada.Numerics; -- from ada-use-indent" | 425 | >>>>Ada.Numerics;" |
| 421 | :type 'integer :group 'ada) | 426 | :type 'integer :group 'ada) |
| 422 | 427 | ||
| 423 | (defcustom ada-when-indent 3 | 428 | (defcustom ada-when-indent 3 |
| @@ -425,7 +430,7 @@ An example is: | |||
| 425 | 430 | ||
| 426 | An example is: | 431 | An example is: |
| 427 | case A is | 432 | case A is |
| 428 | >>>>>>>>when B => -- from ada-when-indent" | 433 | >>>>when B =>" |
| 429 | :type 'integer :group 'ada) | 434 | :type 'integer :group 'ada) |
| 430 | 435 | ||
| 431 | (defcustom ada-with-indent ada-broken-indent | 436 | (defcustom ada-with-indent ada-broken-indent |
| @@ -433,7 +438,7 @@ An example is: | |||
| 433 | 438 | ||
| 434 | An example is: | 439 | An example is: |
| 435 | with Ada.Text_IO, | 440 | with Ada.Text_IO, |
| 436 | >>>>>Ada.Numerics; -- from ada-with-indent" | 441 | >>>>Ada.Numerics;" |
| 437 | :type 'integer :group 'ada) | 442 | :type 'integer :group 'ada) |
| 438 | 443 | ||
| 439 | (defcustom ada-which-compiler 'gnat | 444 | (defcustom ada-which-compiler 'gnat |
| @@ -444,7 +449,7 @@ The possible choices are: | |||
| 444 | features. | 449 | features. |
| 445 | `generic': Use a generic compiler." | 450 | `generic': Use a generic compiler." |
| 446 | :type '(choice (const gnat) | 451 | :type '(choice (const gnat) |
| 447 | (const generic)) | 452 | (const generic)) |
| 448 | :group 'ada) | 453 | :group 'ada) |
| 449 | 454 | ||
| 450 | 455 | ||
| @@ -511,7 +516,7 @@ See `ff-other-file-alist'.") | |||
| 511 | ("[^=]\\(\\s-+\\)=[^=]" 1 t) | 516 | ("[^=]\\(\\s-+\\)=[^=]" 1 t) |
| 512 | ("\\(\\s-*\\)use\\s-" 1) | 517 | ("\\(\\s-*\\)use\\s-" 1) |
| 513 | ("\\(\\s-*\\)--" 1)) | 518 | ("\\(\\s-*\\)--" 1)) |
| 514 | "Ada support for align.el <= 2.2 | 519 | "Ada support for align.el <= 2.2. |
| 515 | This variable provides regular expressions on which to align different lines. | 520 | This variable provides regular expressions on which to align different lines. |
| 516 | See `align-mode-alist' for more information.") | 521 | See `align-mode-alist' for more information.") |
| 517 | 522 | ||
| @@ -566,10 +571,10 @@ This variable defines several rules to use to align different lines.") | |||
| 566 | (defconst ada-95-keywords | 571 | (defconst ada-95-keywords |
| 567 | (eval-when-compile | 572 | (eval-when-compile |
| 568 | (concat "\\<" (regexp-opt | 573 | (concat "\\<" (regexp-opt |
| 569 | (append | 574 | (append |
| 570 | '("abstract" "aliased" "protected" "requeue" | 575 | '("abstract" "aliased" "protected" "requeue" |
| 571 | "tagged" "until") | 576 | "tagged" "until") |
| 572 | ada-83-string-keywords) t) "\\>")) | 577 | ada-83-string-keywords) t) "\\>")) |
| 573 | "Regular expression for looking at Ada95 keywords.") | 578 | "Regular expression for looking at Ada95 keywords.") |
| 574 | 579 | ||
| 575 | (defvar ada-keywords ada-95-keywords | 580 | (defvar ada-keywords ada-95-keywords |
| @@ -605,42 +610,42 @@ This variable defines several rules to use to align different lines.") | |||
| 605 | (defvar ada-block-start-re | 610 | (defvar ada-block-start-re |
| 606 | (eval-when-compile | 611 | (eval-when-compile |
| 607 | (concat "\\<\\(" (regexp-opt '("begin" "declare" "else" | 612 | (concat "\\<\\(" (regexp-opt '("begin" "declare" "else" |
| 608 | "exception" "generic" "loop" "or" | 613 | "exception" "generic" "loop" "or" |
| 609 | "private" "select" )) | 614 | "private" "select" )) |
| 610 | "\\|\\(\\(limited\\|abstract\\|tagged\\)[ \t\n]+\\)*record\\)\\>")) | 615 | "\\|\\(\\(limited\\|abstract\\|tagged\\)[ \t\n]+\\)*record\\)\\>")) |
| 611 | "Regexp for keywords starting Ada blocks.") | 616 | "Regexp for keywords starting Ada blocks.") |
| 612 | 617 | ||
| 613 | (defvar ada-end-stmt-re | 618 | (defvar ada-end-stmt-re |
| 614 | (eval-when-compile | 619 | (eval-when-compile |
| 615 | (concat "\\(" | 620 | (concat "\\(" |
| 616 | ";" "\\|" | 621 | ";" "\\|" |
| 617 | "=>[ \t]*$" "\\|" | 622 | "=>[ \t]*$" "\\|" |
| 618 | "^[ \t]*separate[ \t]*(\\(\\sw\\|[_.]\\)+)" "\\|" | 623 | "^[ \t]*separate[ \t]*(\\(\\sw\\|[_.]\\)+)" "\\|" |
| 619 | "\\<" (regexp-opt '("begin" "declare" "is" "do" "else" "generic" | 624 | "\\<" (regexp-opt '("begin" "declare" "is" "do" "else" "generic" |
| 620 | "loop" "private" "record" "select" | 625 | "loop" "private" "record" "select" |
| 621 | "then abort" "then") t) "\\>" "\\|" | 626 | "then abort" "then") t) "\\>" "\\|" |
| 622 | "^[ \t]*" (regexp-opt '("function" "package" "procedure") | 627 | "^[ \t]*" (regexp-opt '("function" "package" "procedure") |
| 623 | t) "\\>\\(\\sw\\|[ \t_.]\\)+\\<is\\>" "\\|" | 628 | t) "\\>\\(\\sw\\|[ \t_.]\\)+\\<is\\>" "\\|" |
| 624 | "^[ \t]*exception\\>" | 629 | "^[ \t]*exception\\>" |
| 625 | "\\)") ) | 630 | "\\)") ) |
| 626 | "Regexp of possible ends for a non-broken statement. | 631 | "Regexp of possible ends for a non-broken statement. |
| 627 | A new statement starts after these.") | 632 | A new statement starts after these.") |
| 628 | 633 | ||
| 629 | (defvar ada-matching-start-re | 634 | (defvar ada-matching-start-re |
| 630 | (eval-when-compile | 635 | (eval-when-compile |
| 631 | (concat "\\<" | 636 | (concat "\\<" |
| 632 | (regexp-opt | 637 | (regexp-opt |
| 633 | '("end" "loop" "select" "begin" "case" "do" | 638 | '("end" "loop" "select" "begin" "case" "do" |
| 634 | "if" "task" "package" "record" "protected") t) | 639 | "if" "task" "package" "record" "protected") t) |
| 635 | "\\>")) | 640 | "\\>")) |
| 636 | "Regexp used in `ada-goto-matching-start'.") | 641 | "Regexp used in `ada-goto-matching-start'.") |
| 637 | 642 | ||
| 638 | (defvar ada-matching-decl-start-re | 643 | (defvar ada-matching-decl-start-re |
| 639 | (eval-when-compile | 644 | (eval-when-compile |
| 640 | (concat "\\<" | 645 | (concat "\\<" |
| 641 | (regexp-opt | 646 | (regexp-opt |
| 642 | '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t) | 647 | '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t) |
| 643 | "\\>")) | 648 | "\\>")) |
| 644 | "Regexp used in `ada-goto-matching-decl-start'.") | 649 | "Regexp used in `ada-goto-matching-decl-start'.") |
| 645 | 650 | ||
| 646 | (defvar ada-loop-start-re | 651 | (defvar ada-loop-start-re |
| @@ -650,7 +655,7 @@ A new statement starts after these.") | |||
| 650 | (defvar ada-subprog-start-re | 655 | (defvar ada-subprog-start-re |
| 651 | (eval-when-compile | 656 | (eval-when-compile |
| 652 | (concat "\\<" (regexp-opt '("accept" "entry" "function" "package" "procedure" | 657 | (concat "\\<" (regexp-opt '("accept" "entry" "function" "package" "procedure" |
| 653 | "protected" "task") t) "\\>")) | 658 | "protected" "task") t) "\\>")) |
| 654 | "Regexp for the start of a subprogram.") | 659 | "Regexp for the start of a subprogram.") |
| 655 | 660 | ||
| 656 | (defvar ada-named-block-re | 661 | (defvar ada-named-block-re |
| @@ -706,13 +711,13 @@ displaying the menu if point was on an identifier." | |||
| 706 | (list | 711 | (list |
| 707 | (list nil ada-imenu-subprogram-menu-re 2) | 712 | (list nil ada-imenu-subprogram-menu-re 2) |
| 708 | (list "*Specs*" | 713 | (list "*Specs*" |
| 709 | (concat | 714 | (concat |
| 710 | "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)" | 715 | "^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)" |
| 711 | "\\(" | 716 | "\\(" |
| 712 | "\\(" ada-imenu-comment-re "[ \t\n]+\\|[ \t\n]*([^)]+)" | 717 | "\\(" ada-imenu-comment-re "[ \t\n]+\\|[ \t\n]*([^)]+)" |
| 713 | ada-imenu-comment-re "\\)";; parameter list or simple space | 718 | ada-imenu-comment-re "\\)";; parameter list or simple space |
| 714 | "\\([ \t\n]*return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?" | 719 | "\\([ \t\n]*return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?" |
| 715 | "\\)?;") 2) | 720 | "\\)?;") 2) |
| 716 | '("*Tasks*" "^[ \t]*task[ \t]+\\(type[ \t]+\\)?\\(\\(body[ \t]+\\)?\\(\\sw\\|_\\)+\\)" 2) | 721 | '("*Tasks*" "^[ \t]*task[ \t]+\\(type[ \t]+\\)?\\(\\(body[ \t]+\\)?\\(\\sw\\|_\\)+\\)" 2) |
| 717 | '("*Type Defs*" "^[ \t]*\\(sub\\)?type[ \t]+\\(\\(\\sw\\|_\\)+\\)" 2) | 722 | '("*Type Defs*" "^[ \t]*\\(sub\\)?type[ \t]+\\(\\(\\sw\\|_\\)+\\)" 2) |
| 718 | '("*Protected*" | 723 | '("*Protected*" |
| @@ -738,9 +743,10 @@ each type of entity that can be found in an Ada file.") | |||
| 738 | "Replace `compile-goto-error' from compile.el. | 743 | "Replace `compile-goto-error' from compile.el. |
| 739 | If POS is on a file and line location, go to this position. It adds | 744 | If POS is on a file and line location, go to this position. It adds |
| 740 | to compile.el the capacity to go to a reference in an error message. | 745 | to compile.el the capacity to go to a reference in an error message. |
| 741 | For instance, on this line: | 746 | For instance, on these lines: |
| 742 | foo.adb:61:11: [...] in call to size declared at foo.ads:11 | 747 | foo.adb:61:11: [...] in call to size declared at foo.ads:11 |
| 743 | both file locations can be clicked on and jumped to." | 748 | foo.adb:61:11: [...] in call to local declared at line 20 |
| 749 | the 4 file locations can be clicked on and jumped to." | ||
| 744 | (interactive "d") | 750 | (interactive "d") |
| 745 | (goto-char pos) | 751 | (goto-char pos) |
| 746 | 752 | ||
| @@ -748,34 +754,34 @@ both file locations can be clicked on and jumped to." | |||
| 748 | (cond | 754 | (cond |
| 749 | ;; special case: looking at a filename:line not at the beginning of a line | 755 | ;; special case: looking at a filename:line not at the beginning of a line |
| 750 | ((and (not (bolp)) | 756 | ((and (not (bolp)) |
| 751 | (looking-at | 757 | (looking-at |
| 752 | "\\([-_.a-zA-Z0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?")) | 758 | "\\([-_.a-zA-Z0-9]+\\):\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?")) |
| 753 | (let ((line (match-string 2)) | 759 | (let ((line (match-string 2)) |
| 754 | file | 760 | file |
| 755 | (error-pos (point-marker)) | 761 | (error-pos (point-marker)) |
| 756 | source) | 762 | source) |
| 757 | (save-excursion | 763 | (save-excursion |
| 758 | (save-restriction | 764 | (save-restriction |
| 759 | (widen) | 765 | (widen) |
| 760 | ;; Use funcall so as to prevent byte-compiler warnings | 766 | ;; Use funcall so as to prevent byte-compiler warnings |
| 761 | ;; `ada-find-file' is not defined if ada-xref wasn't loaded. But | 767 | ;; `ada-find-file' is not defined if ada-xref wasn't loaded. But |
| 762 | ;; if we can find it, we should use it instead of | 768 | ;; if we can find it, we should use it instead of |
| 763 | ;; `compilation-find-file', since the latter doesn't know anything | 769 | ;; `compilation-find-file', since the latter doesn't know anything |
| 764 | ;; about source path. | 770 | ;; about source path. |
| 765 | 771 | ||
| 766 | (if (functionp 'ada-find-file) | 772 | (if (functionp 'ada-find-file) |
| 767 | (setq file (funcall (symbol-function 'ada-find-file) | 773 | (setq file (funcall (symbol-function 'ada-find-file) |
| 768 | (match-string 1))) | 774 | (match-string 1))) |
| 769 | (setq file (funcall (symbol-function 'compilation-find-file) | 775 | (setq file (funcall (symbol-function 'compilation-find-file) |
| 770 | (point-marker) (match-string 1) | 776 | (point-marker) (match-string 1) |
| 771 | "./"))) | 777 | "./"))) |
| 772 | (set-buffer file) | 778 | (set-buffer file) |
| 773 | 779 | ||
| 774 | (if (stringp line) | 780 | (if (stringp line) |
| 775 | (goto-line (string-to-number line))) | 781 | (goto-line (string-to-number line))) |
| 776 | (setq source (point-marker)))) | 782 | (setq source (point-marker)))) |
| 777 | (funcall (symbol-function 'compilation-goto-locus) | 783 | (funcall (symbol-function 'compilation-goto-locus) |
| 778 | (cons source error-pos)) | 784 | (cons source error-pos)) |
| 779 | )) | 785 | )) |
| 780 | 786 | ||
| 781 | ;; otherwise, default behavior | 787 | ;; otherwise, default behavior |
| @@ -879,31 +885,31 @@ declares it as a word constituent." | |||
| 879 | (defadvice parse-partial-sexp (around parse-partial-sexp-protect-constants) | 885 | (defadvice parse-partial-sexp (around parse-partial-sexp-protect-constants) |
| 880 | "Handles special character constants and gnatprep statements." | 886 | "Handles special character constants and gnatprep statements." |
| 881 | (let (change) | 887 | (let (change) |
| 882 | (if (< to from) | 888 | (if (< to from) |
| 883 | (let ((tmp from)) | 889 | (let ((tmp from)) |
| 884 | (setq from to to tmp))) | 890 | (setq from to to tmp))) |
| 885 | (save-excursion | 891 | (save-excursion |
| 886 | (goto-char from) | 892 | (goto-char from) |
| 887 | (while (re-search-forward "'\\([(\")#]\\)'" to t) | 893 | (while (re-search-forward "'\\([(\")#]\\)'" to t) |
| 888 | (setq change (cons (list (match-beginning 1) | 894 | (setq change (cons (list (match-beginning 1) |
| 889 | 1 | 895 | 1 |
| 890 | (match-string 1)) | 896 | (match-string 1)) |
| 891 | change)) | 897 | change)) |
| 892 | (replace-match "'A'")) | 898 | (replace-match "'A'")) |
| 893 | (goto-char from) | 899 | (goto-char from) |
| 894 | (while (re-search-forward "\\(#[0-9a-fA-F]*#\\)" to t) | 900 | (while (re-search-forward "\\(#[0-9a-fA-F]*#\\)" to t) |
| 895 | (setq change (cons (list (match-beginning 1) | 901 | (setq change (cons (list (match-beginning 1) |
| 896 | (length (match-string 1)) | 902 | (length (match-string 1)) |
| 897 | (match-string 1)) | 903 | (match-string 1)) |
| 898 | change)) | 904 | change)) |
| 899 | (replace-match (make-string (length (match-string 1)) ?@)))) | 905 | (replace-match (make-string (length (match-string 1)) ?@)))) |
| 900 | ad-do-it | 906 | ad-do-it |
| 901 | (save-excursion | 907 | (save-excursion |
| 902 | (while change | 908 | (while change |
| 903 | (goto-char (caar change)) | 909 | (goto-char (caar change)) |
| 904 | (delete-char (cadar change)) | 910 | (delete-char (cadar change)) |
| 905 | (insert (caddar change)) | 911 | (insert (caddar change)) |
| 906 | (setq change (cdr change))))))) | 912 | (setq change (cdr change))))))) |
| 907 | 913 | ||
| 908 | (defun ada-deactivate-properties () | 914 | (defun ada-deactivate-properties () |
| 909 | "Deactivate Ada mode's properties handling. | 915 | "Deactivate Ada mode's properties handling. |
| @@ -919,12 +925,12 @@ as numbers instead of gnatprep comments." | |||
| 919 | (widen) | 925 | (widen) |
| 920 | (goto-char (point-min)) | 926 | (goto-char (point-min)) |
| 921 | (while (re-search-forward "'.'" nil t) | 927 | (while (re-search-forward "'.'" nil t) |
| 922 | (add-text-properties (match-beginning 0) (match-end 0) | 928 | (add-text-properties (match-beginning 0) (match-end 0) |
| 923 | '(syntax-table ("'" . ?\")))) | 929 | '(syntax-table ("'" . ?\")))) |
| 924 | (goto-char (point-min)) | 930 | (goto-char (point-min)) |
| 925 | (while (re-search-forward "^[ \t]*#" nil t) | 931 | (while (re-search-forward "^[ \t]*#" nil t) |
| 926 | (add-text-properties (match-beginning 0) (match-end 0) | 932 | (add-text-properties (match-beginning 0) (match-end 0) |
| 927 | '(syntax-table (11 . 10)))) | 933 | '(syntax-table (11 . 10)))) |
| 928 | (set-buffer-modified-p nil) | 934 | (set-buffer-modified-p nil) |
| 929 | 935 | ||
| 930 | ;; Setting this only if font-lock is not set won't work | 936 | ;; Setting this only if font-lock is not set won't work |
| @@ -937,41 +943,43 @@ as numbers instead of gnatprep comments." | |||
| 937 | "Called when the region between BEG and END was changed in the buffer. | 943 | "Called when the region between BEG and END was changed in the buffer. |
| 938 | OLD-LEN indicates what the length of the replaced text was." | 944 | OLD-LEN indicates what the length of the replaced text was." |
| 939 | (let ((inhibit-point-motion-hooks t) | 945 | (let ((inhibit-point-motion-hooks t) |
| 940 | (eol (point))) | 946 | (eol (point))) |
| 941 | (save-excursion | 947 | (save-excursion |
| 942 | (save-match-data | 948 | (save-match-data |
| 943 | (beginning-of-line) | 949 | (beginning-of-line) |
| 944 | (remove-text-properties (point) eol '(syntax-table nil)) | 950 | (remove-text-properties (point) eol '(syntax-table nil)) |
| 945 | (while (re-search-forward "'.'" eol t) | 951 | (while (re-search-forward "'.'" eol t) |
| 946 | (add-text-properties (match-beginning 0) (match-end 0) | 952 | (add-text-properties (match-beginning 0) (match-end 0) |
| 947 | '(syntax-table ("'" . ?\")))) | 953 | '(syntax-table ("'" . ?\")))) |
| 948 | (beginning-of-line) | 954 | (beginning-of-line) |
| 949 | (if (looking-at "^[ \t]*#") | 955 | (if (looking-at "^[ \t]*#") |
| 950 | (add-text-properties (match-beginning 0) (match-end 0) | 956 | (add-text-properties (match-beginning 0) (match-end 0) |
| 951 | '(syntax-table (11 . 10)))))))) | 957 | '(syntax-table (11 . 10)))))))) |
| 952 | 958 | ||
| 953 | ;;------------------------------------------------------------------ | 959 | ;;------------------------------------------------------------------ |
| 954 | ;; Testing the grammatical context | 960 | ;; Testing the grammatical context |
| 955 | ;;------------------------------------------------------------------ | 961 | ;;------------------------------------------------------------------ |
| 956 | 962 | ||
| 957 | (defsubst ada-in-comment-p (&optional parse-result) | 963 | (defsubst ada-in-comment-p (&optional parse-result) |
| 958 | "Return t if inside a comment." | 964 | "Return t if inside a comment. |
| 965 | If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'." | ||
| 959 | (nth 4 (or parse-result | 966 | (nth 4 (or parse-result |
| 960 | (parse-partial-sexp | 967 | (parse-partial-sexp |
| 961 | (line-beginning-position) (point))))) | 968 | (line-beginning-position) (point))))) |
| 962 | 969 | ||
| 963 | (defsubst ada-in-string-p (&optional parse-result) | 970 | (defsubst ada-in-string-p (&optional parse-result) |
| 964 | "Return t if point is inside a string. | 971 | "Return t if point is inside a string. |
| 965 | If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'." | 972 | If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'." |
| 966 | (nth 3 (or parse-result | 973 | (nth 3 (or parse-result |
| 967 | (parse-partial-sexp | 974 | (parse-partial-sexp |
| 968 | (line-beginning-position) (point))))) | 975 | (line-beginning-position) (point))))) |
| 969 | 976 | ||
| 970 | (defsubst ada-in-string-or-comment-p (&optional parse-result) | 977 | (defsubst ada-in-string-or-comment-p (&optional parse-result) |
| 971 | "Return t if inside a comment or string." | 978 | "Return t if inside a comment or string. |
| 979 | If PARSE-RESULT is non-nil, use it instead of calling `parse-partial-sexp'." | ||
| 972 | (setq parse-result (or parse-result | 980 | (setq parse-result (or parse-result |
| 973 | (parse-partial-sexp | 981 | (parse-partial-sexp |
| 974 | (line-beginning-position) (point)))) | 982 | (line-beginning-position) (point)))) |
| 975 | (or (ada-in-string-p parse-result) (ada-in-comment-p parse-result))) | 983 | (or (ada-in-string-p parse-result) (ada-in-comment-p parse-result))) |
| 976 | 984 | ||
| 977 | 985 | ||
| @@ -990,7 +998,7 @@ It forces Emacs to change the cursor position." | |||
| 990 | (interactive) | 998 | (interactive) |
| 991 | (funcall function) | 999 | (funcall function) |
| 992 | (setq ada-contextual-menu-last-point | 1000 | (setq ada-contextual-menu-last-point |
| 993 | (list (point) (current-buffer)))) | 1001 | (list (point) (current-buffer)))) |
| 994 | 1002 | ||
| 995 | (defun ada-popup-menu (position) | 1003 | (defun ada-popup-menu (position) |
| 996 | "Pops up a contextual menu, depending on where the user clicked. | 1004 | "Pops up a contextual menu, depending on where the user clicked. |
| @@ -1005,23 +1013,23 @@ point is where the mouse button was clicked." | |||
| 1005 | ;; transient-mark-mode. | 1013 | ;; transient-mark-mode. |
| 1006 | (let ((deactivate-mark nil)) | 1014 | (let ((deactivate-mark nil)) |
| 1007 | (setq ada-contextual-menu-last-point | 1015 | (setq ada-contextual-menu-last-point |
| 1008 | (list (point) (current-buffer))) | 1016 | (list (point) (current-buffer))) |
| 1009 | (mouse-set-point last-input-event) | 1017 | (mouse-set-point last-input-event) |
| 1010 | 1018 | ||
| 1011 | (setq ada-contextual-menu-on-identifier | 1019 | (setq ada-contextual-menu-on-identifier |
| 1012 | (and (char-after) | 1020 | (and (char-after) |
| 1013 | (or (= (char-syntax (char-after)) ?w) | 1021 | (or (= (char-syntax (char-after)) ?w) |
| 1014 | (= (char-after) ?_)) | 1022 | (= (char-after) ?_)) |
| 1015 | (not (ada-in-string-or-comment-p)) | 1023 | (not (ada-in-string-or-comment-p)) |
| 1016 | (save-excursion (skip-syntax-forward "w") | 1024 | (save-excursion (skip-syntax-forward "w") |
| 1017 | (not (ada-after-keyword-p))) | 1025 | (not (ada-after-keyword-p))) |
| 1018 | )) | 1026 | )) |
| 1019 | (if (fboundp 'popup-menu) | 1027 | (if (fboundp 'popup-menu) |
| 1020 | (funcall (symbol-function 'popup-menu) ada-contextual-menu) | 1028 | (funcall (symbol-function 'popup-menu) ada-contextual-menu) |
| 1021 | (let (choice) | 1029 | (let (choice) |
| 1022 | (setq choice (x-popup-menu position ada-contextual-menu)) | 1030 | (setq choice (x-popup-menu position ada-contextual-menu)) |
| 1023 | (if choice | 1031 | (if choice |
| 1024 | (funcall (lookup-key ada-contextual-menu (vector (car choice))))))) | 1032 | (funcall (lookup-key ada-contextual-menu (vector (car choice))))))) |
| 1025 | 1033 | ||
| 1026 | (set-buffer (cadr ada-contextual-menu-last-point)) | 1034 | (set-buffer (cadr ada-contextual-menu-last-point)) |
| 1027 | (goto-char (car ada-contextual-menu-last-point)) | 1035 | (goto-char (car ada-contextual-menu-last-point)) |
| @@ -1040,15 +1048,15 @@ extensions. | |||
| 1040 | SPEC and BODY are two regular expressions that must match against | 1048 | SPEC and BODY are two regular expressions that must match against |
| 1041 | the file name." | 1049 | the file name." |
| 1042 | (let* ((reg (concat (regexp-quote body) "$")) | 1050 | (let* ((reg (concat (regexp-quote body) "$")) |
| 1043 | (tmp (assoc reg ada-other-file-alist))) | 1051 | (tmp (assoc reg ada-other-file-alist))) |
| 1044 | (if tmp | 1052 | (if tmp |
| 1045 | (setcdr tmp (list (cons spec (cadr tmp)))) | 1053 | (setcdr tmp (list (cons spec (cadr tmp)))) |
| 1046 | (add-to-list 'ada-other-file-alist (list reg (list spec))))) | 1054 | (add-to-list 'ada-other-file-alist (list reg (list spec))))) |
| 1047 | 1055 | ||
| 1048 | (let* ((reg (concat (regexp-quote spec) "$")) | 1056 | (let* ((reg (concat (regexp-quote spec) "$")) |
| 1049 | (tmp (assoc reg ada-other-file-alist))) | 1057 | (tmp (assoc reg ada-other-file-alist))) |
| 1050 | (if tmp | 1058 | (if tmp |
| 1051 | (setcdr tmp (list (cons body (cadr tmp)))) | 1059 | (setcdr tmp (list (cons body (cadr tmp)))) |
| 1052 | (add-to-list 'ada-other-file-alist (list reg (list body))))) | 1060 | (add-to-list 'ada-other-file-alist (list reg (list body))))) |
| 1053 | 1061 | ||
| 1054 | (add-to-list 'auto-mode-alist | 1062 | (add-to-list 'auto-mode-alist |
| @@ -1063,10 +1071,10 @@ the file name." | |||
| 1063 | ;; speedbar) | 1071 | ;; speedbar) |
| 1064 | (if (fboundp 'speedbar-add-supported-extension) | 1072 | (if (fboundp 'speedbar-add-supported-extension) |
| 1065 | (progn | 1073 | (progn |
| 1066 | (funcall (symbol-function 'speedbar-add-supported-extension) | 1074 | (funcall (symbol-function 'speedbar-add-supported-extension) |
| 1067 | spec) | 1075 | spec) |
| 1068 | (funcall (symbol-function 'speedbar-add-supported-extension) | 1076 | (funcall (symbol-function 'speedbar-add-supported-extension) |
| 1069 | body))) | 1077 | body))) |
| 1070 | ) | 1078 | ) |
| 1071 | 1079 | ||
| 1072 | 1080 | ||
| @@ -1105,14 +1113,14 @@ If you use imenu.el: | |||
| 1105 | 1113 | ||
| 1106 | If you use find-file.el: | 1114 | If you use find-file.el: |
| 1107 | Switch to other file (Body <-> Spec) '\\[ff-find-other-file]' | 1115 | Switch to other file (Body <-> Spec) '\\[ff-find-other-file]' |
| 1108 | or '\\[ff-mouse-find-other-file] | 1116 | or '\\[ff-mouse-find-other-file] |
| 1109 | Switch to other file in other window '\\[ada-ff-other-window]' | 1117 | Switch to other file in other window '\\[ada-ff-other-window]' |
| 1110 | or '\\[ff-mouse-find-other-file-other-window] | 1118 | or '\\[ff-mouse-find-other-file-other-window] |
| 1111 | If you use this function in a spec and no body is available, it gets created with body stubs. | 1119 | If you use this function in a spec and no body is available, it gets created with body stubs. |
| 1112 | 1120 | ||
| 1113 | If you use ada-xref.el: | 1121 | If you use ada-xref.el: |
| 1114 | Goto declaration: '\\[ada-point-and-xref]' on the identifier | 1122 | Goto declaration: '\\[ada-point-and-xref]' on the identifier |
| 1115 | or '\\[ada-goto-declaration]' with point on the identifier | 1123 | or '\\[ada-goto-declaration]' with point on the identifier |
| 1116 | Complete identifier: '\\[ada-complete-identifier]'." | 1124 | Complete identifier: '\\[ada-complete-identifier]'." |
| 1117 | 1125 | ||
| 1118 | (interactive) | 1126 | (interactive) |
| @@ -1139,7 +1147,7 @@ If you use ada-xref.el: | |||
| 1139 | ;; aligned under the latest parameter, not under the declaration start). | 1147 | ;; aligned under the latest parameter, not under the declaration start). |
| 1140 | (set (make-local-variable 'comment-line-break-function) | 1148 | (set (make-local-variable 'comment-line-break-function) |
| 1141 | (lambda (&optional soft) (let ((fill-prefix nil)) | 1149 | (lambda (&optional soft) (let ((fill-prefix nil)) |
| 1142 | (indent-new-comment-line soft)))) | 1150 | (indent-new-comment-line soft)))) |
| 1143 | 1151 | ||
| 1144 | (set (make-local-variable 'indent-line-function) | 1152 | (set (make-local-variable 'indent-line-function) |
| 1145 | 'ada-indent-current-function) | 1153 | 'ada-indent-current-function) |
| @@ -1152,9 +1160,9 @@ If you use ada-xref.el: | |||
| 1152 | (unless (featurep 'xemacs) | 1160 | (unless (featurep 'xemacs) |
| 1153 | (progn | 1161 | (progn |
| 1154 | (if (ada-check-emacs-version 20 3) | 1162 | (if (ada-check-emacs-version 20 3) |
| 1155 | (progn | 1163 | (progn |
| 1156 | (set (make-local-variable 'parse-sexp-ignore-comments) t) | 1164 | (set (make-local-variable 'parse-sexp-ignore-comments) t) |
| 1157 | (set (make-local-variable 'comment-padding) 0))) | 1165 | (set (make-local-variable 'comment-padding) 0))) |
| 1158 | (set (make-local-variable 'parse-sexp-lookup-properties) t) | 1166 | (set (make-local-variable 'parse-sexp-lookup-properties) t) |
| 1159 | )) | 1167 | )) |
| 1160 | 1168 | ||
| @@ -1171,7 +1179,7 @@ If you use ada-xref.el: | |||
| 1171 | ;; Support for compile.el | 1179 | ;; Support for compile.el |
| 1172 | ;; We just substitute our own functions to go to the error. | 1180 | ;; We just substitute our own functions to go to the error. |
| 1173 | (add-hook 'compilation-mode-hook | 1181 | (add-hook 'compilation-mode-hook |
| 1174 | (lambda() | 1182 | (lambda() |
| 1175 | (set (make-local-variable 'compile-auto-highlight) 40) | 1183 | (set (make-local-variable 'compile-auto-highlight) 40) |
| 1176 | ;; FIXME: This has global impact! -stef | 1184 | ;; FIXME: This has global impact! -stef |
| 1177 | (define-key compilation-minor-mode-map [mouse-2] | 1185 | (define-key compilation-minor-mode-map [mouse-2] |
| @@ -1188,15 +1196,15 @@ If you use ada-xref.el: | |||
| 1188 | (if (featurep 'xemacs) | 1196 | (if (featurep 'xemacs) |
| 1189 | ;; XEmacs | 1197 | ;; XEmacs |
| 1190 | (put 'ada-mode 'font-lock-defaults | 1198 | (put 'ada-mode 'font-lock-defaults |
| 1191 | '(ada-font-lock-keywords | 1199 | '(ada-font-lock-keywords |
| 1192 | nil t ((?\_ . "w") (?# . ".")) beginning-of-line)) | 1200 | nil t ((?\_ . "w") (?# . ".")) beginning-of-line)) |
| 1193 | ;; Emacs | 1201 | ;; Emacs |
| 1194 | (set (make-local-variable 'font-lock-defaults) | 1202 | (set (make-local-variable 'font-lock-defaults) |
| 1195 | '(ada-font-lock-keywords | 1203 | '(ada-font-lock-keywords |
| 1196 | nil t | 1204 | nil t |
| 1197 | ((?\_ . "w") (?# . ".")) | 1205 | ((?\_ . "w") (?# . ".")) |
| 1198 | beginning-of-line | 1206 | beginning-of-line |
| 1199 | (font-lock-syntactic-keywords . ada-font-lock-syntactic-keywords))) | 1207 | (font-lock-syntactic-keywords . ada-font-lock-syntactic-keywords))) |
| 1200 | ) | 1208 | ) |
| 1201 | 1209 | ||
| 1202 | ;; Set up support for find-file.el. | 1210 | ;; Set up support for find-file.el. |
| @@ -1205,39 +1213,39 @@ If you use ada-xref.el: | |||
| 1205 | (set (make-local-variable 'ff-search-directories) | 1213 | (set (make-local-variable 'ff-search-directories) |
| 1206 | 'ada-search-directories-internal) | 1214 | 'ada-search-directories-internal) |
| 1207 | (setq ff-post-load-hook 'ada-set-point-accordingly | 1215 | (setq ff-post-load-hook 'ada-set-point-accordingly |
| 1208 | ff-file-created-hook 'ada-make-body) | 1216 | ff-file-created-hook 'ada-make-body) |
| 1209 | (add-hook 'ff-pre-load-hook 'ada-which-function-are-we-in) | 1217 | (add-hook 'ff-pre-load-hook 'ada-which-function-are-we-in) |
| 1210 | 1218 | ||
| 1211 | ;; Some special constructs for find-file.el. | 1219 | ;; Some special constructs for find-file.el. |
| 1212 | (make-local-variable 'ff-special-constructs) | 1220 | (make-local-variable 'ff-special-constructs) |
| 1213 | (mapc (lambda (pair) | 1221 | (mapc (lambda (pair) |
| 1214 | (add-to-list 'ff-special-constructs pair)) | 1222 | (add-to-list 'ff-special-constructs pair)) |
| 1215 | `( | 1223 | `( |
| 1216 | ;; Go to the parent package. | 1224 | ;; Go to the parent package. |
| 1217 | (,(eval-when-compile | 1225 | (,(eval-when-compile |
| 1218 | (concat "^\\(private[ \t]\\)?[ \t]*package[ \t]+" | 1226 | (concat "^\\(private[ \t]\\)?[ \t]*package[ \t]+" |
| 1219 | "\\(body[ \t]+\\)?" | 1227 | "\\(body[ \t]+\\)?" |
| 1220 | "\\(\\(\\sw\\|[_.]\\)+\\)\\.\\(\\sw\\|_\\)+[ \t\n]+is")) | 1228 | "\\(\\(\\sw\\|[_.]\\)+\\)\\.\\(\\sw\\|_\\)+[ \t\n]+is")) |
| 1221 | . ,(lambda () | 1229 | . ,(lambda () |
| 1222 | (ff-get-file | 1230 | (ff-get-file |
| 1223 | ada-search-directories-internal | 1231 | ada-search-directories-internal |
| 1224 | (ada-make-filename-from-adaname (match-string 3)) | 1232 | (ada-make-filename-from-adaname (match-string 3)) |
| 1225 | ada-spec-suffixes))) | 1233 | ada-spec-suffixes))) |
| 1226 | ;; A "separate" clause. | 1234 | ;; A "separate" clause. |
| 1227 | ("^separate[ \t\n]*(\\(\\(\\sw\\|[_.]\\)+\\))" | 1235 | ("^separate[ \t\n]*(\\(\\(\\sw\\|[_.]\\)+\\))" |
| 1228 | . ,(lambda () | 1236 | . ,(lambda () |
| 1229 | (ff-get-file | 1237 | (ff-get-file |
| 1230 | ada-search-directories-internal | 1238 | ada-search-directories-internal |
| 1231 | (ada-make-filename-from-adaname (match-string 1)) | 1239 | (ada-make-filename-from-adaname (match-string 1)) |
| 1232 | ada-spec-suffixes))) | 1240 | ada-spec-suffixes))) |
| 1233 | ;; A "with" clause. | 1241 | ;; A "with" clause. |
| 1234 | ("^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)" | 1242 | ("^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)" |
| 1235 | . ,(lambda () | 1243 | . ,(lambda () |
| 1236 | (ff-get-file | 1244 | (ff-get-file |
| 1237 | ada-search-directories-internal | 1245 | ada-search-directories-internal |
| 1238 | (ada-make-filename-from-adaname (match-string 1)) | 1246 | (ada-make-filename-from-adaname (match-string 1)) |
| 1239 | ada-spec-suffixes))) | 1247 | ada-spec-suffixes))) |
| 1240 | )) | 1248 | )) |
| 1241 | 1249 | ||
| 1242 | ;; Support for outline-minor-mode | 1250 | ;; Support for outline-minor-mode |
| 1243 | (set (make-local-variable 'outline-regexp) | 1251 | (set (make-local-variable 'outline-regexp) |
| @@ -1336,11 +1344,11 @@ If you use ada-xref.el: | |||
| 1336 | 1344 | ||
| 1337 | (if ada-clean-buffer-before-saving | 1345 | (if ada-clean-buffer-before-saving |
| 1338 | (progn | 1346 | (progn |
| 1339 | ;; remove all spaces at the end of lines in the whole buffer. | 1347 | ;; remove all spaces at the end of lines in the whole buffer. |
| 1340 | (add-hook 'local-write-file-hooks 'delete-trailing-whitespace) | 1348 | (add-hook 'local-write-file-hooks 'delete-trailing-whitespace) |
| 1341 | ;; convert all tabs to the correct number of spaces. | 1349 | ;; convert all tabs to the correct number of spaces. |
| 1342 | (add-hook 'local-write-file-hooks | 1350 | (add-hook 'local-write-file-hooks |
| 1343 | (lambda () (untabify (point-min) (point-max)))))) | 1351 | (lambda () (untabify (point-min) (point-max)))))) |
| 1344 | 1352 | ||
| 1345 | (set (make-local-variable 'skeleton-further-elements) | 1353 | (set (make-local-variable 'skeleton-further-elements) |
| 1346 | '((< '(backward-delete-char-untabify | 1354 | '((< '(backward-delete-char-untabify |
| @@ -1366,12 +1374,12 @@ If you use ada-xref.el: | |||
| 1366 | 1374 | ||
| 1367 | ;; the following has to be done after running the ada-mode-hook | 1375 | ;; the following has to be done after running the ada-mode-hook |
| 1368 | ;; because users might want to set the values of these variable | 1376 | ;; because users might want to set the values of these variable |
| 1369 | ;; inside the hook (MH) | 1377 | ;; inside the hook |
| 1370 | 1378 | ||
| 1371 | (cond ((eq ada-language-version 'ada83) | 1379 | (cond ((eq ada-language-version 'ada83) |
| 1372 | (setq ada-keywords ada-83-keywords)) | 1380 | (setq ada-keywords ada-83-keywords)) |
| 1373 | ((eq ada-language-version 'ada95) | 1381 | ((eq ada-language-version 'ada95) |
| 1374 | (setq ada-keywords ada-95-keywords))) | 1382 | (setq ada-keywords ada-95-keywords))) |
| 1375 | 1383 | ||
| 1376 | (if ada-auto-case | 1384 | (if ada-auto-case |
| 1377 | (ada-activate-keys-for-case))) | 1385 | (ada-activate-keys-for-case))) |
| @@ -1408,18 +1416,16 @@ If you use ada-xref.el: | |||
| 1408 | ;;----------------------------------------------------------------- | 1416 | ;;----------------------------------------------------------------- |
| 1409 | 1417 | ||
| 1410 | (defun ada-save-exceptions-to-file (file-name) | 1418 | (defun ada-save-exceptions-to-file (file-name) |
| 1411 | "Save the exception lists `ada-case-exception' and | 1419 | "Save the casing exception lists to the file FILE-NAME. |
| 1412 | `ada-case-exception-substring' to the file FILE-NAME." | 1420 | Casing exception lists are `ada-case-exception' and `ada-case-exception-substring'." |
| 1413 | |||
| 1414 | ;; Save the list in the file | ||
| 1415 | (find-file (expand-file-name file-name)) | 1421 | (find-file (expand-file-name file-name)) |
| 1416 | (erase-buffer) | 1422 | (erase-buffer) |
| 1417 | (mapcar (lambda (x) (insert (car x) "\n")) | 1423 | (mapcar (lambda (x) (insert (car x) "\n")) |
| 1418 | (sort (copy-sequence ada-case-exception) | 1424 | (sort (copy-sequence ada-case-exception) |
| 1419 | (lambda(a b) (string< (car a) (car b))))) | 1425 | (lambda(a b) (string< (car a) (car b))))) |
| 1420 | (mapcar (lambda (x) (insert "*" (car x) "\n")) | 1426 | (mapcar (lambda (x) (insert "*" (car x) "\n")) |
| 1421 | (sort (copy-sequence ada-case-exception-substring) | 1427 | (sort (copy-sequence ada-case-exception-substring) |
| 1422 | (lambda(a b) (string< (car a) (car b))))) | 1428 | (lambda(a b) (string< (car a) (car b))))) |
| 1423 | (save-buffer) | 1429 | (save-buffer) |
| 1424 | (kill-buffer nil) | 1430 | (kill-buffer nil) |
| 1425 | ) | 1431 | ) |
| @@ -1431,23 +1437,23 @@ The new words is added to the first file in `ada-case-exception-file'. | |||
| 1431 | The standard casing rules will no longer apply to this word." | 1437 | The standard casing rules will no longer apply to this word." |
| 1432 | (interactive) | 1438 | (interactive) |
| 1433 | (let ((previous-syntax-table (syntax-table)) | 1439 | (let ((previous-syntax-table (syntax-table)) |
| 1434 | file-name | 1440 | file-name |
| 1435 | ) | 1441 | ) |
| 1436 | 1442 | ||
| 1437 | (cond ((stringp ada-case-exception-file) | 1443 | (cond ((stringp ada-case-exception-file) |
| 1438 | (setq file-name ada-case-exception-file)) | 1444 | (setq file-name ada-case-exception-file)) |
| 1439 | ((listp ada-case-exception-file) | 1445 | ((listp ada-case-exception-file) |
| 1440 | (setq file-name (car ada-case-exception-file))) | 1446 | (setq file-name (car ada-case-exception-file))) |
| 1441 | (t | 1447 | (t |
| 1442 | (error (concat "No exception file specified. " | 1448 | (error (concat "No exception file specified. " |
| 1443 | "See variable ada-case-exception-file")))) | 1449 | "See variable ada-case-exception-file")))) |
| 1444 | 1450 | ||
| 1445 | (set-syntax-table ada-mode-symbol-syntax-table) | 1451 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 1446 | (unless word | 1452 | (unless word |
| 1447 | (save-excursion | 1453 | (save-excursion |
| 1448 | (skip-syntax-backward "w") | 1454 | (skip-syntax-backward "w") |
| 1449 | (setq word (buffer-substring-no-properties | 1455 | (setq word (buffer-substring-no-properties |
| 1450 | (point) (save-excursion (forward-word 1) (point)))))) | 1456 | (point) (save-excursion (forward-word 1) (point)))))) |
| 1451 | (set-syntax-table previous-syntax-table) | 1457 | (set-syntax-table previous-syntax-table) |
| 1452 | 1458 | ||
| 1453 | ;; Reread the exceptions file, in case it was modified by some other, | 1459 | ;; Reread the exceptions file, in case it was modified by some other, |
| @@ -1456,8 +1462,8 @@ The standard casing rules will no longer apply to this word." | |||
| 1456 | ;; If the word is already in the list, even with a different casing | 1462 | ;; If the word is already in the list, even with a different casing |
| 1457 | ;; we simply want to replace it. | 1463 | ;; we simply want to replace it. |
| 1458 | (if (and (not (equal ada-case-exception '())) | 1464 | (if (and (not (equal ada-case-exception '())) |
| 1459 | (assoc-string word ada-case-exception t)) | 1465 | (assoc-string word ada-case-exception t)) |
| 1460 | (setcar (assoc-string word ada-case-exception t) word) | 1466 | (setcar (assoc-string word ada-case-exception t) word) |
| 1461 | (add-to-list 'ada-case-exception (cons word t)) | 1467 | (add-to-list 'ada-case-exception (cons word t)) |
| 1462 | ) | 1468 | ) |
| 1463 | 1469 | ||
| @@ -1509,8 +1515,8 @@ word itself has a special casing." | |||
| 1509 | ;; If the word is already in the list, even with a different casing | 1515 | ;; If the word is already in the list, even with a different casing |
| 1510 | ;; we simply want to replace it. | 1516 | ;; we simply want to replace it. |
| 1511 | (if (and (not (equal ada-case-exception-substring '())) | 1517 | (if (and (not (equal ada-case-exception-substring '())) |
| 1512 | (assoc-string word ada-case-exception-substring t)) | 1518 | (assoc-string word ada-case-exception-substring t)) |
| 1513 | (setcar (assoc-string word ada-case-exception-substring t) word) | 1519 | (setcar (assoc-string word ada-case-exception-substring t) word) |
| 1514 | (add-to-list 'ada-case-exception-substring (cons word t)) | 1520 | (add-to-list 'ada-case-exception-substring (cons word t)) |
| 1515 | ) | 1521 | ) |
| 1516 | 1522 | ||
| @@ -1522,17 +1528,17 @@ word itself has a special casing." | |||
| 1522 | "Read the content of the casing exception file FILE-NAME." | 1528 | "Read the content of the casing exception file FILE-NAME." |
| 1523 | (if (file-readable-p (expand-file-name file-name)) | 1529 | (if (file-readable-p (expand-file-name file-name)) |
| 1524 | (let ((buffer (current-buffer))) | 1530 | (let ((buffer (current-buffer))) |
| 1525 | (find-file (expand-file-name file-name)) | 1531 | (find-file (expand-file-name file-name)) |
| 1526 | (set-syntax-table ada-mode-symbol-syntax-table) | 1532 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 1527 | (widen) | 1533 | (widen) |
| 1528 | (goto-char (point-min)) | 1534 | (goto-char (point-min)) |
| 1529 | (while (not (eobp)) | 1535 | (while (not (eobp)) |
| 1530 | 1536 | ||
| 1531 | ;; If the item is already in the list, even with an other casing, | 1537 | ;; If the item is already in the list, even with an other casing, |
| 1532 | ;; do not add it again. This way, the user can easily decide which | 1538 | ;; do not add it again. This way, the user can easily decide which |
| 1533 | ;; priority should be applied to each casing exception | 1539 | ;; priority should be applied to each casing exception |
| 1534 | (let ((word (buffer-substring-no-properties | 1540 | (let ((word (buffer-substring-no-properties |
| 1535 | (point) (save-excursion (forward-word 1) (point))))) | 1541 | (point) (save-excursion (forward-word 1) (point))))) |
| 1536 | 1542 | ||
| 1537 | ;; Handling a substring ? | 1543 | ;; Handling a substring ? |
| 1538 | (if (char-equal (string-to-char word) ?*) | 1544 | (if (char-equal (string-to-char word) ?*) |
| @@ -1543,9 +1549,9 @@ word itself has a special casing." | |||
| 1543 | (unless (assoc-string word ada-case-exception t) | 1549 | (unless (assoc-string word ada-case-exception t) |
| 1544 | (add-to-list 'ada-case-exception (cons word t))))) | 1550 | (add-to-list 'ada-case-exception (cons word t))))) |
| 1545 | 1551 | ||
| 1546 | (forward-line 1)) | 1552 | (forward-line 1)) |
| 1547 | (kill-buffer nil) | 1553 | (kill-buffer nil) |
| 1548 | (set-buffer buffer))) | 1554 | (set-buffer buffer))) |
| 1549 | ) | 1555 | ) |
| 1550 | 1556 | ||
| 1551 | (defun ada-case-read-exceptions () | 1557 | (defun ada-case-read-exceptions () |
| @@ -1557,11 +1563,11 @@ word itself has a special casing." | |||
| 1557 | ada-case-exception-substring '()) | 1563 | ada-case-exception-substring '()) |
| 1558 | 1564 | ||
| 1559 | (cond ((stringp ada-case-exception-file) | 1565 | (cond ((stringp ada-case-exception-file) |
| 1560 | (ada-case-read-exceptions-from-file ada-case-exception-file)) | 1566 | (ada-case-read-exceptions-from-file ada-case-exception-file)) |
| 1561 | 1567 | ||
| 1562 | ((listp ada-case-exception-file) | 1568 | ((listp ada-case-exception-file) |
| 1563 | (mapcar 'ada-case-read-exceptions-from-file | 1569 | (mapcar 'ada-case-read-exceptions-from-file |
| 1564 | ada-case-exception-file)))) | 1570 | ada-case-exception-file)))) |
| 1565 | 1571 | ||
| 1566 | (defun ada-adjust-case-substring () | 1572 | (defun ada-adjust-case-substring () |
| 1567 | "Adjust case of substrings in the previous word." | 1573 | "Adjust case of substrings in the previous word." |
| @@ -1597,26 +1603,26 @@ The auto-casing is done according to the value of `ada-case-identifier' | |||
| 1597 | and the exceptions defined in `ada-case-exception-file'." | 1603 | and the exceptions defined in `ada-case-exception-file'." |
| 1598 | (interactive) | 1604 | (interactive) |
| 1599 | (if (or (equal ada-case-exception '()) | 1605 | (if (or (equal ada-case-exception '()) |
| 1600 | (equal (char-after) ?_)) | 1606 | (equal (char-after) ?_)) |
| 1601 | (progn | 1607 | (progn |
| 1602 | (funcall ada-case-identifier -1) | 1608 | (funcall ada-case-identifier -1) |
| 1603 | (ada-adjust-case-substring)) | 1609 | (ada-adjust-case-substring)) |
| 1604 | 1610 | ||
| 1605 | (progn | 1611 | (progn |
| 1606 | (let ((end (point)) | 1612 | (let ((end (point)) |
| 1607 | (start (save-excursion (skip-syntax-backward "w") | 1613 | (start (save-excursion (skip-syntax-backward "w") |
| 1608 | (point))) | 1614 | (point))) |
| 1609 | match) | 1615 | match) |
| 1610 | ;; If we have an exception, replace the word by the correct casing | 1616 | ;; If we have an exception, replace the word by the correct casing |
| 1611 | (if (setq match (assoc-string (buffer-substring start end) | 1617 | (if (setq match (assoc-string (buffer-substring start end) |
| 1612 | ada-case-exception t)) | 1618 | ada-case-exception t)) |
| 1613 | 1619 | ||
| 1614 | (progn | 1620 | (progn |
| 1615 | (delete-region start end) | 1621 | (delete-region start end) |
| 1616 | (insert (car match))) | 1622 | (insert (car match))) |
| 1617 | 1623 | ||
| 1618 | ;; Else simply re-case the word | 1624 | ;; Else simply re-case the word |
| 1619 | (funcall ada-case-identifier -1) | 1625 | (funcall ada-case-identifier -1) |
| 1620 | (ada-adjust-case-substring)))))) | 1626 | (ada-adjust-case-substring)))))) |
| 1621 | 1627 | ||
| 1622 | (defun ada-after-keyword-p () | 1628 | (defun ada-after-keyword-p () |
| @@ -1624,9 +1630,9 @@ and the exceptions defined in `ada-case-exception-file'." | |||
| 1624 | (save-excursion | 1630 | (save-excursion |
| 1625 | (forward-word -1) | 1631 | (forward-word -1) |
| 1626 | (and (not (and (char-before) | 1632 | (and (not (and (char-before) |
| 1627 | (or (= (char-before) ?_) | 1633 | (or (= (char-before) ?_) |
| 1628 | (= (char-before) ?'))));; unless we have a _ or ' | 1634 | (= (char-before) ?'))));; unless we have a _ or ' |
| 1629 | (looking-at (concat ada-keywords "[^_]"))))) | 1635 | (looking-at (concat ada-keywords "[^_]"))))) |
| 1630 | 1636 | ||
| 1631 | (defun ada-adjust-case (&optional force-identifier) | 1637 | (defun ada-adjust-case (&optional force-identifier) |
| 1632 | "Adjust the case of the word before the character just typed. | 1638 | "Adjust the case of the word before the character just typed. |
| @@ -1665,7 +1671,7 @@ ARG is the prefix the user entered with \\[universal-argument]." | |||
| 1665 | 1671 | ||
| 1666 | (if ada-auto-case | 1672 | (if ada-auto-case |
| 1667 | (let ((lastk last-command-char) | 1673 | (let ((lastk last-command-char) |
| 1668 | (previous-syntax-table (syntax-table))) | 1674 | (previous-syntax-table (syntax-table))) |
| 1669 | 1675 | ||
| 1670 | (unwind-protect | 1676 | (unwind-protect |
| 1671 | (progn | 1677 | (progn |
| @@ -1685,7 +1691,7 @@ ARG is the prefix the user entered with \\[universal-argument]." | |||
| 1685 | (funcall ada-ret-binding)))) | 1691 | (funcall ada-ret-binding)))) |
| 1686 | ((eq lastk ?\C-i) (ada-tab)) | 1692 | ((eq lastk ?\C-i) (ada-tab)) |
| 1687 | ;; Else just insert the character | 1693 | ;; Else just insert the character |
| 1688 | ((self-insert-command (prefix-numeric-value arg)))) | 1694 | ((self-insert-command (prefix-numeric-value arg)))) |
| 1689 | ;; if there is a keyword in front of the underscore | 1695 | ;; if there is a keyword in front of the underscore |
| 1690 | ;; then it should be part of an identifier (MH) | 1696 | ;; then it should be part of an identifier (MH) |
| 1691 | (if (eq lastk ?_) | 1697 | (if (eq lastk ?_) |
| @@ -1694,7 +1700,7 @@ ARG is the prefix the user entered with \\[universal-argument]." | |||
| 1694 | ) | 1700 | ) |
| 1695 | ;; Restore the syntax table | 1701 | ;; Restore the syntax table |
| 1696 | (set-syntax-table previous-syntax-table)) | 1702 | (set-syntax-table previous-syntax-table)) |
| 1697 | ) | 1703 | ) |
| 1698 | 1704 | ||
| 1699 | ;; Else, no auto-casing | 1705 | ;; Else, no auto-casing |
| 1700 | (cond | 1706 | (cond |
| @@ -1718,11 +1724,11 @@ ARG is the prefix the user entered with \\[universal-argument]." | |||
| 1718 | 1724 | ||
| 1719 | ;; Call case modifying function after certain keys. | 1725 | ;; Call case modifying function after certain keys. |
| 1720 | (mapcar (function (lambda(key) (define-key | 1726 | (mapcar (function (lambda(key) (define-key |
| 1721 | ada-mode-map | 1727 | ada-mode-map |
| 1722 | (char-to-string key) | 1728 | (char-to-string key) |
| 1723 | 'ada-adjust-case-interactive))) | 1729 | 'ada-adjust-case-interactive))) |
| 1724 | '( ?` ?_ ?# ?% ?& ?* ?( ?) ?- ?= ?+ | 1730 | '( ?` ?_ ?# ?% ?& ?* ?( ?) ?- ?= ?+ |
| 1725 | ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?/ ?\n 32 ?\r ))) | 1731 | ?| ?\; ?: ?' ?\" ?< ?, ?. ?> ?/ ?\n 32 ?\r ))) |
| 1726 | 1732 | ||
| 1727 | (defun ada-loose-case-word (&optional arg) | 1733 | (defun ada-loose-case-word (&optional arg) |
| 1728 | "Upcase first letter and letters following `_' in the following word. | 1734 | "Upcase first letter and letters following `_' in the following word. |
| @@ -1731,18 +1737,18 @@ ARG is ignored, and is there for compatibility with `capitalize-word' only." | |||
| 1731 | (interactive) | 1737 | (interactive) |
| 1732 | (save-excursion | 1738 | (save-excursion |
| 1733 | (let ((end (save-excursion (skip-syntax-forward "w") (point))) | 1739 | (let ((end (save-excursion (skip-syntax-forward "w") (point))) |
| 1734 | (first t)) | 1740 | (first t)) |
| 1735 | (skip-syntax-backward "w") | 1741 | (skip-syntax-backward "w") |
| 1736 | (while (and (or first (search-forward "_" end t)) | 1742 | (while (and (or first (search-forward "_" end t)) |
| 1737 | (< (point) end)) | 1743 | (< (point) end)) |
| 1738 | (and first | 1744 | (and first |
| 1739 | (setq first nil)) | 1745 | (setq first nil)) |
| 1740 | (insert-char (upcase (following-char)) 1) | 1746 | (insert-char (upcase (following-char)) 1) |
| 1741 | (delete-char 1))))) | 1747 | (delete-char 1))))) |
| 1742 | 1748 | ||
| 1743 | (defun ada-no-auto-case (&optional arg) | 1749 | (defun ada-no-auto-case (&optional arg) |
| 1744 | "Do nothing. | 1750 | "Do nothing. ARG is ignored. |
| 1745 | This function can be used for the auto-casing variables in the Ada mode, to | 1751 | This function can be used for the auto-casing variables in Ada mode, to |
| 1746 | adapt to unusal auto-casing schemes. Since it does nothing, you can for | 1752 | adapt to unusal auto-casing schemes. Since it does nothing, you can for |
| 1747 | instance use it for `ada-case-identifier' if you don't want any special | 1753 | instance use it for `ada-case-identifier' if you don't want any special |
| 1748 | auto-casing for identifiers, whereas keywords have to be lower-cased. | 1754 | auto-casing for identifiers, whereas keywords have to be lower-cased. |
| @@ -1754,7 +1760,7 @@ See also `ada-auto-case' to disable auto casing altogether." | |||
| 1754 | ARG is ignored, and is there for compatibility with `capitalize-word' only." | 1760 | ARG is ignored, and is there for compatibility with `capitalize-word' only." |
| 1755 | (interactive) | 1761 | (interactive) |
| 1756 | (let ((end (save-excursion (skip-syntax-forward "w") (point))) | 1762 | (let ((end (save-excursion (skip-syntax-forward "w") (point))) |
| 1757 | (begin (save-excursion (skip-syntax-backward "w") (point)))) | 1763 | (begin (save-excursion (skip-syntax-backward "w") (point)))) |
| 1758 | (modify-syntax-entry ?_ "_") | 1764 | (modify-syntax-entry ?_ "_") |
| 1759 | (capitalize-region begin end) | 1765 | (capitalize-region begin end) |
| 1760 | (modify-syntax-entry ?_ "w"))) | 1766 | (modify-syntax-entry ?_ "w"))) |
| @@ -1764,45 +1770,45 @@ ARG is ignored, and is there for compatibility with `capitalize-word' only." | |||
| 1764 | Attention: This function might take very long for big regions!" | 1770 | Attention: This function might take very long for big regions!" |
| 1765 | (interactive "*r") | 1771 | (interactive "*r") |
| 1766 | (let ((begin nil) | 1772 | (let ((begin nil) |
| 1767 | (end nil) | 1773 | (end nil) |
| 1768 | (keywordp nil) | 1774 | (keywordp nil) |
| 1769 | (attribp nil) | 1775 | (attribp nil) |
| 1770 | (previous-syntax-table (syntax-table))) | 1776 | (previous-syntax-table (syntax-table))) |
| 1771 | (message "Adjusting case ...") | 1777 | (message "Adjusting case ...") |
| 1772 | (unwind-protect | 1778 | (unwind-protect |
| 1773 | (save-excursion | 1779 | (save-excursion |
| 1774 | (set-syntax-table ada-mode-symbol-syntax-table) | 1780 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 1775 | (goto-char to) | 1781 | (goto-char to) |
| 1776 | ;; | 1782 | ;; |
| 1777 | ;; loop: look for all identifiers, keywords, and attributes | 1783 | ;; loop: look for all identifiers, keywords, and attributes |
| 1778 | ;; | 1784 | ;; |
| 1779 | (while (re-search-backward "\\<\\(\\sw+\\)\\>" from t) | 1785 | (while (re-search-backward "\\<\\(\\sw+\\)\\>" from t) |
| 1780 | (setq end (match-end 1)) | 1786 | (setq end (match-end 1)) |
| 1781 | (setq attribp | 1787 | (setq attribp |
| 1782 | (and (> (point) from) | 1788 | (and (> (point) from) |
| 1783 | (save-excursion | 1789 | (save-excursion |
| 1784 | (forward-char -1) | 1790 | (forward-char -1) |
| 1785 | (setq attribp (looking-at "'.[^']"))))) | 1791 | (setq attribp (looking-at "'.[^']"))))) |
| 1786 | (or | 1792 | (or |
| 1787 | ;; do nothing if it is a string or comment | 1793 | ;; do nothing if it is a string or comment |
| 1788 | (ada-in-string-or-comment-p) | 1794 | (ada-in-string-or-comment-p) |
| 1789 | (progn | 1795 | (progn |
| 1790 | ;; | 1796 | ;; |
| 1791 | ;; get the identifier or keyword or attribute | 1797 | ;; get the identifier or keyword or attribute |
| 1792 | ;; | 1798 | ;; |
| 1793 | (setq begin (point)) | 1799 | (setq begin (point)) |
| 1794 | (setq keywordp (looking-at ada-keywords)) | 1800 | (setq keywordp (looking-at ada-keywords)) |
| 1795 | (goto-char end) | 1801 | (goto-char end) |
| 1796 | ;; | 1802 | ;; |
| 1797 | ;; casing according to user-option | 1803 | ;; casing according to user-option |
| 1798 | ;; | 1804 | ;; |
| 1799 | (if attribp | 1805 | (if attribp |
| 1800 | (funcall ada-case-attribute -1) | 1806 | (funcall ada-case-attribute -1) |
| 1801 | (if keywordp | 1807 | (if keywordp |
| 1802 | (funcall ada-case-keyword -1) | 1808 | (funcall ada-case-keyword -1) |
| 1803 | (ada-adjust-case-identifier))) | 1809 | (ada-adjust-case-identifier))) |
| 1804 | (goto-char begin)))) | 1810 | (goto-char begin)))) |
| 1805 | (message "Adjusting case ... Done")) | 1811 | (message "Adjusting case ... Done")) |
| 1806 | (set-syntax-table previous-syntax-table)))) | 1812 | (set-syntax-table previous-syntax-table)))) |
| 1807 | 1813 | ||
| 1808 | (defun ada-adjust-case-buffer () | 1814 | (defun ada-adjust-case-buffer () |
| @@ -1832,44 +1838,44 @@ ATTENTION: This function might take very long for big buffers!" | |||
| 1832 | "Reformat the parameter list point is in." | 1838 | "Reformat the parameter list point is in." |
| 1833 | (interactive) | 1839 | (interactive) |
| 1834 | (let ((begin nil) | 1840 | (let ((begin nil) |
| 1835 | (end nil) | 1841 | (end nil) |
| 1836 | (delend nil) | 1842 | (delend nil) |
| 1837 | (paramlist nil) | 1843 | (paramlist nil) |
| 1838 | (previous-syntax-table (syntax-table))) | 1844 | (previous-syntax-table (syntax-table))) |
| 1839 | (unwind-protect | 1845 | (unwind-protect |
| 1840 | (progn | 1846 | (progn |
| 1841 | (set-syntax-table ada-mode-symbol-syntax-table) | 1847 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 1842 | |||
| 1843 | ;; check if really inside parameter list | ||
| 1844 | (or (ada-in-paramlist-p) | ||
| 1845 | (error "Not in parameter list")) | ||
| 1846 | 1848 | ||
| 1847 | ;; find start of current parameter-list | 1849 | ;; check if really inside parameter list |
| 1848 | (ada-search-ignore-string-comment | 1850 | (or (ada-in-paramlist-p) |
| 1849 | (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil) | 1851 | (error "Not in parameter list")) |
| 1850 | (down-list 1) | ||
| 1851 | (backward-char 1) | ||
| 1852 | (setq begin (point)) | ||
| 1853 | 1852 | ||
| 1854 | ;; find end of parameter-list | 1853 | ;; find start of current parameter-list |
| 1855 | (forward-sexp 1) | 1854 | (ada-search-ignore-string-comment |
| 1856 | (setq delend (point)) | 1855 | (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil) |
| 1857 | (delete-char -1) | 1856 | (down-list 1) |
| 1858 | (insert "\n") | 1857 | (backward-char 1) |
| 1858 | (setq begin (point)) | ||
| 1859 | |||
| 1860 | ;; find end of parameter-list | ||
| 1861 | (forward-sexp 1) | ||
| 1862 | (setq delend (point)) | ||
| 1863 | (delete-char -1) | ||
| 1864 | (insert "\n") | ||
| 1859 | 1865 | ||
| 1860 | ;; find end of last parameter-declaration | 1866 | ;; find end of last parameter-declaration |
| 1861 | (forward-comment -1000) | 1867 | (forward-comment -1000) |
| 1862 | (setq end (point)) | 1868 | (setq end (point)) |
| 1863 | 1869 | ||
| 1864 | ;; build a list of all elements of the parameter-list | 1870 | ;; build a list of all elements of the parameter-list |
| 1865 | (setq paramlist (ada-scan-paramlist (1+ begin) end)) | 1871 | (setq paramlist (ada-scan-paramlist (1+ begin) end)) |
| 1866 | 1872 | ||
| 1867 | ;; delete the original parameter-list | 1873 | ;; delete the original parameter-list |
| 1868 | (delete-region begin delend) | 1874 | (delete-region begin delend) |
| 1869 | 1875 | ||
| 1870 | ;; insert the new parameter-list | 1876 | ;; insert the new parameter-list |
| 1871 | (goto-char begin) | 1877 | (goto-char begin) |
| 1872 | (ada-insert-paramlist paramlist)) | 1878 | (ada-insert-paramlist paramlist)) |
| 1873 | 1879 | ||
| 1874 | ;; restore syntax-table | 1880 | ;; restore syntax-table |
| 1875 | (set-syntax-table previous-syntax-table) | 1881 | (set-syntax-table previous-syntax-table) |
| @@ -1879,12 +1885,12 @@ ATTENTION: This function might take very long for big buffers!" | |||
| 1879 | "Scan the parameter list found in between BEGIN and END. | 1885 | "Scan the parameter list found in between BEGIN and END. |
| 1880 | Return the equivalent internal parameter list." | 1886 | Return the equivalent internal parameter list." |
| 1881 | (let ((paramlist (list)) | 1887 | (let ((paramlist (list)) |
| 1882 | (param (list)) | 1888 | (param (list)) |
| 1883 | (notend t) | 1889 | (notend t) |
| 1884 | (apos nil) | 1890 | (apos nil) |
| 1885 | (epos nil) | 1891 | (epos nil) |
| 1886 | (semipos nil) | 1892 | (semipos nil) |
| 1887 | (match-cons nil)) | 1893 | (match-cons nil)) |
| 1888 | 1894 | ||
| 1889 | (goto-char begin) | 1895 | (goto-char begin) |
| 1890 | 1896 | ||
| @@ -1897,11 +1903,11 @@ Return the equivalent internal parameter list." | |||
| 1897 | 1903 | ||
| 1898 | ;; find last character of parameter-declaration | 1904 | ;; find last character of parameter-declaration |
| 1899 | (if (setq match-cons | 1905 | (if (setq match-cons |
| 1900 | (ada-search-ignore-string-comment "[ \t\n]*;" nil end t)) | 1906 | (ada-search-ignore-string-comment "[ \t\n]*;" nil end t)) |
| 1901 | (progn | 1907 | (progn |
| 1902 | (setq epos (car match-cons)) | 1908 | (setq epos (car match-cons)) |
| 1903 | (setq semipos (cdr match-cons))) | 1909 | (setq semipos (cdr match-cons))) |
| 1904 | (setq epos end)) | 1910 | (setq epos end)) |
| 1905 | 1911 | ||
| 1906 | ;; read name(s) of parameter(s) | 1912 | ;; read name(s) of parameter(s) |
| 1907 | (goto-char apos) | 1913 | (goto-char apos) |
| @@ -1913,76 +1919,76 @@ Return the equivalent internal parameter list." | |||
| 1913 | ;; look for 'in' | 1919 | ;; look for 'in' |
| 1914 | (setq apos (point)) | 1920 | (setq apos (point)) |
| 1915 | (setq param | 1921 | (setq param |
| 1916 | (append param | 1922 | (append param |
| 1917 | (list | 1923 | (list |
| 1918 | (consp | 1924 | (consp |
| 1919 | (ada-search-ignore-string-comment | 1925 | (ada-search-ignore-string-comment |
| 1920 | "in" nil epos t 'word-search-forward))))) | 1926 | "in" nil epos t 'word-search-forward))))) |
| 1921 | 1927 | ||
| 1922 | ;; look for 'out' | 1928 | ;; look for 'out' |
| 1923 | (goto-char apos) | 1929 | (goto-char apos) |
| 1924 | (setq param | 1930 | (setq param |
| 1925 | (append param | 1931 | (append param |
| 1926 | (list | 1932 | (list |
| 1927 | (consp | 1933 | (consp |
| 1928 | (ada-search-ignore-string-comment | 1934 | (ada-search-ignore-string-comment |
| 1929 | "out" nil epos t 'word-search-forward))))) | 1935 | "out" nil epos t 'word-search-forward))))) |
| 1930 | 1936 | ||
| 1931 | ;; look for 'access' | 1937 | ;; look for 'access' |
| 1932 | (goto-char apos) | 1938 | (goto-char apos) |
| 1933 | (setq param | 1939 | (setq param |
| 1934 | (append param | 1940 | (append param |
| 1935 | (list | 1941 | (list |
| 1936 | (consp | 1942 | (consp |
| 1937 | (ada-search-ignore-string-comment | 1943 | (ada-search-ignore-string-comment |
| 1938 | "access" nil epos t 'word-search-forward))))) | 1944 | "access" nil epos t 'word-search-forward))))) |
| 1939 | 1945 | ||
| 1940 | ;; skip 'in'/'out'/'access' | 1946 | ;; skip 'in'/'out'/'access' |
| 1941 | (goto-char apos) | 1947 | (goto-char apos) |
| 1942 | (ada-goto-next-non-ws) | 1948 | (ada-goto-next-non-ws) |
| 1943 | (while (looking-at "\\<\\(in\\|out\\|access\\)\\>") | 1949 | (while (looking-at "\\<\\(in\\|out\\|access\\)\\>") |
| 1944 | (forward-word 1) | 1950 | (forward-word 1) |
| 1945 | (ada-goto-next-non-ws)) | 1951 | (ada-goto-next-non-ws)) |
| 1946 | 1952 | ||
| 1947 | ;; read type of parameter | 1953 | ;; read type of parameter |
| 1948 | ;; We accept spaces in the name, since some software like Rose | 1954 | ;; We accept spaces in the name, since some software like Rose |
| 1949 | ;; generates something like: "A : B 'Class" | 1955 | ;; generates something like: "A : B 'Class" |
| 1950 | (looking-at "\\<\\(\\sw\\|[_.' \t]\\)+\\>") | 1956 | (looking-at "\\<\\(\\sw\\|[_.' \t]\\)+\\>") |
| 1951 | (setq param | 1957 | (setq param |
| 1952 | (append param | 1958 | (append param |
| 1953 | (list (match-string 0)))) | 1959 | (list (match-string 0)))) |
| 1954 | 1960 | ||
| 1955 | ;; read default-expression, if there is one | 1961 | ;; read default-expression, if there is one |
| 1956 | (goto-char (setq apos (match-end 0))) | 1962 | (goto-char (setq apos (match-end 0))) |
| 1957 | (setq param | 1963 | (setq param |
| 1958 | (append param | 1964 | (append param |
| 1959 | (list | 1965 | (list |
| 1960 | (if (setq match-cons | 1966 | (if (setq match-cons |
| 1961 | (ada-search-ignore-string-comment | 1967 | (ada-search-ignore-string-comment |
| 1962 | ":=" nil epos t 'search-forward)) | 1968 | ":=" nil epos t 'search-forward)) |
| 1963 | (buffer-substring (car match-cons) epos) | 1969 | (buffer-substring (car match-cons) epos) |
| 1964 | nil)))) | 1970 | nil)))) |
| 1965 | 1971 | ||
| 1966 | ;; add this parameter-declaration to the list | 1972 | ;; add this parameter-declaration to the list |
| 1967 | (setq paramlist (append paramlist (list param))) | 1973 | (setq paramlist (append paramlist (list param))) |
| 1968 | 1974 | ||
| 1969 | ;; check if it was the last parameter | 1975 | ;; check if it was the last parameter |
| 1970 | (if (eq epos end) | 1976 | (if (eq epos end) |
| 1971 | (setq notend nil) | 1977 | (setq notend nil) |
| 1972 | (goto-char semipos)) | 1978 | (goto-char semipos)) |
| 1973 | ) | 1979 | ) |
| 1974 | (reverse paramlist))) | 1980 | (reverse paramlist))) |
| 1975 | 1981 | ||
| 1976 | (defun ada-insert-paramlist (paramlist) | 1982 | (defun ada-insert-paramlist (paramlist) |
| 1977 | "Insert a formatted PARAMLIST in the buffer." | 1983 | "Insert a formatted PARAMLIST in the buffer." |
| 1978 | (let ((i (length paramlist)) | 1984 | (let ((i (length paramlist)) |
| 1979 | (parlen 0) | 1985 | (parlen 0) |
| 1980 | (typlen 0) | 1986 | (typlen 0) |
| 1981 | (inp nil) | 1987 | (inp nil) |
| 1982 | (outp nil) | 1988 | (outp nil) |
| 1983 | (accessp nil) | 1989 | (accessp nil) |
| 1984 | (column nil) | 1990 | (column nil) |
| 1985 | (firstcol nil)) | 1991 | (firstcol nil)) |
| 1986 | 1992 | ||
| 1987 | ;; loop until last parameter | 1993 | ;; loop until last parameter |
| 1988 | (while (not (zerop i)) | 1994 | (while (not (zerop i)) |
| @@ -2006,23 +2012,23 @@ Return the equivalent internal parameter list." | |||
| 2006 | 2012 | ||
| 2007 | ;; does paramlist already start on a separate line ? | 2013 | ;; does paramlist already start on a separate line ? |
| 2008 | (if (save-excursion | 2014 | (if (save-excursion |
| 2009 | (re-search-backward "^.\\|[^ \t]" nil t) | 2015 | (re-search-backward "^.\\|[^ \t]" nil t) |
| 2010 | (looking-at "^.")) | 2016 | (looking-at "^.")) |
| 2011 | ;; yes => re-indent it | 2017 | ;; yes => re-indent it |
| 2012 | (progn | 2018 | (progn |
| 2013 | (ada-indent-current) | 2019 | (ada-indent-current) |
| 2014 | (save-excursion | 2020 | (save-excursion |
| 2015 | (if (looking-at "\\(is\\|return\\)") | 2021 | (if (looking-at "\\(is\\|return\\)") |
| 2016 | (replace-match " \\1")))) | 2022 | (replace-match " \\1")))) |
| 2017 | 2023 | ||
| 2018 | ;; no => insert it where we are after removing any whitespace | 2024 | ;; no => insert it where we are after removing any whitespace |
| 2019 | (fixup-whitespace) | 2025 | (fixup-whitespace) |
| 2020 | (save-excursion | 2026 | (save-excursion |
| 2021 | (cond | 2027 | (cond |
| 2022 | ((looking-at "[ \t]*\\(\n\\|;\\)") | 2028 | ((looking-at "[ \t]*\\(\n\\|;\\)") |
| 2023 | (replace-match "\\1")) | 2029 | (replace-match "\\1")) |
| 2024 | ((looking-at "[ \t]*\\(is\\|return\\)") | 2030 | ((looking-at "[ \t]*\\(is\\|return\\)") |
| 2025 | (replace-match " \\1")))) | 2031 | (replace-match " \\1")))) |
| 2026 | (insert " ")) | 2032 | (insert " ")) |
| 2027 | 2033 | ||
| 2028 | (insert "(") | 2034 | (insert "(") |
| @@ -2044,42 +2050,42 @@ Return the equivalent internal parameter list." | |||
| 2044 | 2050 | ||
| 2045 | ;; insert 'in' or space | 2051 | ;; insert 'in' or space |
| 2046 | (if (nth 1 (nth i paramlist)) | 2052 | (if (nth 1 (nth i paramlist)) |
| 2047 | (insert "in ") | 2053 | (insert "in ") |
| 2048 | (if (and | 2054 | (if (and |
| 2049 | (or inp | 2055 | (or inp |
| 2050 | accessp) | 2056 | accessp) |
| 2051 | (not (nth 3 (nth i paramlist)))) | 2057 | (not (nth 3 (nth i paramlist)))) |
| 2052 | (insert " "))) | 2058 | (insert " "))) |
| 2053 | 2059 | ||
| 2054 | ;; insert 'out' or space | 2060 | ;; insert 'out' or space |
| 2055 | (if (nth 2 (nth i paramlist)) | 2061 | (if (nth 2 (nth i paramlist)) |
| 2056 | (insert "out ") | 2062 | (insert "out ") |
| 2057 | (if (and | 2063 | (if (and |
| 2058 | (or outp | 2064 | (or outp |
| 2059 | accessp) | 2065 | accessp) |
| 2060 | (not (nth 3 (nth i paramlist)))) | 2066 | (not (nth 3 (nth i paramlist)))) |
| 2061 | (insert " "))) | 2067 | (insert " "))) |
| 2062 | 2068 | ||
| 2063 | ;; insert 'access' | 2069 | ;; insert 'access' |
| 2064 | (if (nth 3 (nth i paramlist)) | 2070 | (if (nth 3 (nth i paramlist)) |
| 2065 | (insert "access ")) | 2071 | (insert "access ")) |
| 2066 | 2072 | ||
| 2067 | (setq column (current-column)) | 2073 | (setq column (current-column)) |
| 2068 | 2074 | ||
| 2069 | ;; insert type-name and, if necessary, space and default-expression | 2075 | ;; insert type-name and, if necessary, space and default-expression |
| 2070 | (insert (nth 4 (nth i paramlist))) | 2076 | (insert (nth 4 (nth i paramlist))) |
| 2071 | (if (nth 5 (nth i paramlist)) | 2077 | (if (nth 5 (nth i paramlist)) |
| 2072 | (progn | 2078 | (progn |
| 2073 | (indent-to (+ column typlen 1)) | 2079 | (indent-to (+ column typlen 1)) |
| 2074 | (insert (nth 5 (nth i paramlist))))) | 2080 | (insert (nth 5 (nth i paramlist))))) |
| 2075 | 2081 | ||
| 2076 | ;; check if it was the last parameter | 2082 | ;; check if it was the last parameter |
| 2077 | (if (zerop i) | 2083 | (if (zerop i) |
| 2078 | (insert ")") | 2084 | (insert ")") |
| 2079 | ;; no => insert ';' and newline and indent | 2085 | ;; no => insert ';' and newline and indent |
| 2080 | (insert ";") | 2086 | (insert ";") |
| 2081 | (newline) | 2087 | (newline) |
| 2082 | (indent-to firstcol)) | 2088 | (indent-to firstcol)) |
| 2083 | ) | 2089 | ) |
| 2084 | 2090 | ||
| 2085 | ;; if anything follows, except semicolon, newline, is or return | 2091 | ;; if anything follows, except semicolon, newline, is or return |
| @@ -2123,19 +2129,19 @@ Return the equivalent internal parameter list." | |||
| 2123 | (interactive "*r") | 2129 | (interactive "*r") |
| 2124 | (goto-char beg) | 2130 | (goto-char beg) |
| 2125 | (let ((block-done 0) | 2131 | (let ((block-done 0) |
| 2126 | (lines-remaining (count-lines beg end)) | 2132 | (lines-remaining (count-lines beg end)) |
| 2127 | (msg (format "%%4d out of %4d lines remaining ..." | 2133 | (msg (format "%%4d out of %4d lines remaining ..." |
| 2128 | (count-lines beg end))) | 2134 | (count-lines beg end))) |
| 2129 | (endmark (copy-marker end))) | 2135 | (endmark (copy-marker end))) |
| 2130 | ;; catch errors while indenting | 2136 | ;; catch errors while indenting |
| 2131 | (while (< (point) endmark) | 2137 | (while (< (point) endmark) |
| 2132 | (if (> block-done 39) | 2138 | (if (> block-done 39) |
| 2133 | (progn | 2139 | (progn |
| 2134 | (setq lines-remaining (- lines-remaining block-done) | 2140 | (setq lines-remaining (- lines-remaining block-done) |
| 2135 | block-done 0) | 2141 | block-done 0) |
| 2136 | (message msg lines-remaining))) | 2142 | (message msg lines-remaining))) |
| 2137 | (if (= (char-after) ?\n) nil | 2143 | (if (= (char-after) ?\n) nil |
| 2138 | (ada-indent-current)) | 2144 | (ada-indent-current)) |
| 2139 | (forward-line 1) | 2145 | (forward-line 1) |
| 2140 | (setq block-done (1+ block-done))) | 2146 | (setq block-done (1+ block-done))) |
| 2141 | (message "Indenting ... done"))) | 2147 | (message "Indenting ... done"))) |
| @@ -2149,8 +2155,7 @@ Return the equivalent internal parameter list." | |||
| 2149 | 2155 | ||
| 2150 | (defun ada-indent-newline-indent-conditional () | 2156 | (defun ada-indent-newline-indent-conditional () |
| 2151 | "Insert a newline and indent it. | 2157 | "Insert a newline and indent it. |
| 2152 | The original line is indented first if `ada-indent-after-return' is non-nil. | 2158 | The original line is indented first if `ada-indent-after-return' is non-nil." |
| 2153 | This function is intended to be bound to the C-m and C-j keys." | ||
| 2154 | (interactive "*") | 2159 | (interactive "*") |
| 2155 | (if ada-indent-after-return (ada-indent-current)) | 2160 | (if ada-indent-after-return (ada-indent-current)) |
| 2156 | (newline) | 2161 | (newline) |
| @@ -2211,65 +2216,65 @@ Return the calculation that was done, including the reference point and the | |||
| 2211 | offset." | 2216 | offset." |
| 2212 | (interactive) | 2217 | (interactive) |
| 2213 | (let ((previous-syntax-table (syntax-table)) | 2218 | (let ((previous-syntax-table (syntax-table)) |
| 2214 | (orgpoint (point-marker)) | 2219 | (orgpoint (point-marker)) |
| 2215 | cur-indent tmp-indent | 2220 | cur-indent tmp-indent |
| 2216 | prev-indent) | 2221 | prev-indent) |
| 2217 | 2222 | ||
| 2218 | (unwind-protect | 2223 | (unwind-protect |
| 2219 | (progn | 2224 | (progn |
| 2220 | (set-syntax-table ada-mode-symbol-syntax-table) | 2225 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 2221 | 2226 | ||
| 2222 | ;; This need to be done here so that the advice is not always | 2227 | ;; This need to be done here so that the advice is not always |
| 2223 | ;; activated (this might interact badly with other modes) | 2228 | ;; activated (this might interact badly with other modes) |
| 2224 | (if (featurep 'xemacs) | 2229 | (if (featurep 'xemacs) |
| 2225 | (ad-activate 'parse-partial-sexp t)) | 2230 | (ad-activate 'parse-partial-sexp t)) |
| 2226 | 2231 | ||
| 2227 | (save-excursion | 2232 | (save-excursion |
| 2228 | (setq cur-indent | 2233 | (setq cur-indent |
| 2229 | 2234 | ||
| 2230 | ;; Not First line in the buffer ? | 2235 | ;; Not First line in the buffer ? |
| 2231 | (if (save-excursion (zerop (forward-line -1))) | 2236 | (if (save-excursion (zerop (forward-line -1))) |
| 2232 | (progn | 2237 | (progn |
| 2233 | (back-to-indentation) | 2238 | (back-to-indentation) |
| 2234 | (ada-get-current-indent)) | 2239 | (ada-get-current-indent)) |
| 2235 | 2240 | ||
| 2236 | ;; first line in the buffer | 2241 | ;; first line in the buffer |
| 2237 | (list (point-min) 0)))) | 2242 | (list (point-min) 0)))) |
| 2238 | 2243 | ||
| 2239 | ;; Evaluate the list to get the column to indent to | 2244 | ;; Evaluate the list to get the column to indent to |
| 2240 | ;; prev-indent contains the column to indent to | 2245 | ;; prev-indent contains the column to indent to |
| 2241 | (if cur-indent | 2246 | (if cur-indent |
| 2242 | (setq prev-indent (save-excursion (goto-char (car cur-indent)) | 2247 | (setq prev-indent (save-excursion (goto-char (car cur-indent)) |
| 2243 | (current-column)) | 2248 | (current-column)) |
| 2244 | tmp-indent (cdr cur-indent)) | 2249 | tmp-indent (cdr cur-indent)) |
| 2245 | (setq prev-indent 0 tmp-indent '())) | 2250 | (setq prev-indent 0 tmp-indent '())) |
| 2246 | 2251 | ||
| 2247 | (while (not (null tmp-indent)) | 2252 | (while (not (null tmp-indent)) |
| 2248 | (cond | 2253 | (cond |
| 2249 | ((numberp (car tmp-indent)) | 2254 | ((numberp (car tmp-indent)) |
| 2250 | (setq prev-indent (+ prev-indent (car tmp-indent)))) | 2255 | (setq prev-indent (+ prev-indent (car tmp-indent)))) |
| 2251 | (t | 2256 | (t |
| 2252 | (setq prev-indent (+ prev-indent (eval (car tmp-indent))))) | 2257 | (setq prev-indent (+ prev-indent (eval (car tmp-indent))))) |
| 2253 | ) | 2258 | ) |
| 2254 | (setq tmp-indent (cdr tmp-indent))) | 2259 | (setq tmp-indent (cdr tmp-indent))) |
| 2255 | 2260 | ||
| 2256 | ;; only re-indent if indentation is different then the current | 2261 | ;; only re-indent if indentation is different then the current |
| 2257 | (if (= (save-excursion (back-to-indentation) (current-column)) prev-indent) | 2262 | (if (= (save-excursion (back-to-indentation) (current-column)) prev-indent) |
| 2258 | nil | 2263 | nil |
| 2259 | (beginning-of-line) | 2264 | (beginning-of-line) |
| 2260 | (delete-horizontal-space) | 2265 | (delete-horizontal-space) |
| 2261 | (indent-to prev-indent)) | 2266 | (indent-to prev-indent)) |
| 2262 | ;; | 2267 | ;; |
| 2263 | ;; restore position of point | 2268 | ;; restore position of point |
| 2264 | ;; | 2269 | ;; |
| 2265 | (goto-char orgpoint) | 2270 | (goto-char orgpoint) |
| 2266 | (if (< (current-column) (current-indentation)) | 2271 | (if (< (current-column) (current-indentation)) |
| 2267 | (back-to-indentation))) | 2272 | (back-to-indentation))) |
| 2268 | 2273 | ||
| 2269 | ;; restore syntax-table | 2274 | ;; restore syntax-table |
| 2270 | (set-syntax-table previous-syntax-table) | 2275 | (set-syntax-table previous-syntax-table) |
| 2271 | (if (featurep 'xemacs) | 2276 | (if (featurep 'xemacs) |
| 2272 | (ad-deactivate 'parse-partial-sexp)) | 2277 | (ad-deactivate 'parse-partial-sexp)) |
| 2273 | ) | 2278 | ) |
| 2274 | 2279 | ||
| 2275 | cur-indent | 2280 | cur-indent |
| @@ -2278,14 +2283,14 @@ offset." | |||
| 2278 | (defun ada-get-current-indent () | 2283 | (defun ada-get-current-indent () |
| 2279 | "Return the indentation to use for the current line." | 2284 | "Return the indentation to use for the current line." |
| 2280 | (let (column | 2285 | (let (column |
| 2281 | pos | 2286 | pos |
| 2282 | match-cons | 2287 | match-cons |
| 2283 | result | 2288 | result |
| 2284 | (orgpoint (save-excursion | 2289 | (orgpoint (save-excursion |
| 2285 | (beginning-of-line) | 2290 | (beginning-of-line) |
| 2286 | (forward-comment -10000) | 2291 | (forward-comment -10000) |
| 2287 | (forward-line 1) | 2292 | (forward-line 1) |
| 2288 | (point)))) | 2293 | (point)))) |
| 2289 | 2294 | ||
| 2290 | (setq result | 2295 | (setq result |
| 2291 | (cond | 2296 | (cond |
| @@ -2411,7 +2416,7 @@ offset." | |||
| 2411 | 2416 | ||
| 2412 | ((looking-at "else\\>") | 2417 | ((looking-at "else\\>") |
| 2413 | (if (save-excursion (ada-goto-previous-word) | 2418 | (if (save-excursion (ada-goto-previous-word) |
| 2414 | (looking-at "\\<or\\>")) | 2419 | (looking-at "\\<or\\>")) |
| 2415 | (ada-indent-on-previous-lines nil orgpoint orgpoint) | 2420 | (ada-indent-on-previous-lines nil orgpoint orgpoint) |
| 2416 | (save-excursion | 2421 | (save-excursion |
| 2417 | (ada-goto-matching-start 1 nil t) | 2422 | (ada-goto-matching-start 1 nil t) |
| @@ -2461,16 +2466,16 @@ offset." | |||
| 2461 | (looking-at "loop\\>")) | 2466 | (looking-at "loop\\>")) |
| 2462 | (setq pos (point)) | 2467 | (setq pos (point)) |
| 2463 | (save-excursion | 2468 | (save-excursion |
| 2464 | (goto-char (match-end 0)) | 2469 | (goto-char (match-end 0)) |
| 2465 | (ada-goto-stmt-start) | 2470 | (ada-goto-stmt-start) |
| 2466 | (if (looking-at "\\<\\(loop\\|if\\)\\>") | 2471 | (if (looking-at "\\<\\(loop\\|if\\)\\>") |
| 2467 | (ada-indent-on-previous-lines nil orgpoint orgpoint) | 2472 | (ada-indent-on-previous-lines nil orgpoint orgpoint) |
| 2468 | (unless (looking-at ada-loop-start-re) | 2473 | (unless (looking-at ada-loop-start-re) |
| 2469 | (ada-search-ignore-string-comment ada-loop-start-re | 2474 | (ada-search-ignore-string-comment ada-loop-start-re |
| 2470 | nil pos)) | 2475 | nil pos)) |
| 2471 | (if (looking-at "\\<loop\\>") | 2476 | (if (looking-at "\\<loop\\>") |
| 2472 | (ada-indent-on-previous-lines nil orgpoint orgpoint) | 2477 | (ada-indent-on-previous-lines nil orgpoint orgpoint) |
| 2473 | (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))))) | 2478 | (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))))) |
| 2474 | 2479 | ||
| 2475 | ;;---------------------------- | 2480 | ;;---------------------------- |
| 2476 | ;; starting with l (limited) or r (record) | 2481 | ;; starting with l (limited) or r (record) |
| @@ -2497,9 +2502,9 @@ offset." | |||
| 2497 | ((and (= (downcase (char-after)) ?b) | 2502 | ((and (= (downcase (char-after)) ?b) |
| 2498 | (looking-at "begin\\>")) | 2503 | (looking-at "begin\\>")) |
| 2499 | (save-excursion | 2504 | (save-excursion |
| 2500 | (if (ada-goto-matching-decl-start t) | 2505 | (if (ada-goto-matching-decl-start t) |
| 2501 | (list (progn (back-to-indentation) (point)) 0) | 2506 | (list (progn (back-to-indentation) (point)) 0) |
| 2502 | (ada-indent-on-previous-lines nil orgpoint orgpoint)))) | 2507 | (ada-indent-on-previous-lines nil orgpoint orgpoint)))) |
| 2503 | 2508 | ||
| 2504 | ;;--------------------------- | 2509 | ;;--------------------------- |
| 2505 | ;; starting with i (is) | 2510 | ;; starting with i (is) |
| @@ -2509,16 +2514,16 @@ offset." | |||
| 2509 | (looking-at "is\\>")) | 2514 | (looking-at "is\\>")) |
| 2510 | 2515 | ||
| 2511 | (if (and ada-indent-is-separate | 2516 | (if (and ada-indent-is-separate |
| 2512 | (save-excursion | 2517 | (save-excursion |
| 2513 | (goto-char (match-end 0)) | 2518 | (goto-char (match-end 0)) |
| 2514 | (ada-goto-next-non-ws (save-excursion (end-of-line) | 2519 | (ada-goto-next-non-ws (save-excursion (end-of-line) |
| 2515 | (point))) | 2520 | (point))) |
| 2516 | (looking-at "\\<abstract\\>\\|\\<separate\\>"))) | 2521 | (looking-at "\\<abstract\\>\\|\\<separate\\>"))) |
| 2517 | (save-excursion | 2522 | (save-excursion |
| 2518 | (ada-goto-stmt-start) | 2523 | (ada-goto-stmt-start) |
| 2519 | (list (progn (back-to-indentation) (point)) 'ada-indent)) | 2524 | (list (progn (back-to-indentation) (point)) 'ada-indent)) |
| 2520 | (save-excursion | 2525 | (save-excursion |
| 2521 | (ada-goto-stmt-start) | 2526 | (ada-goto-stmt-start) |
| 2522 | (if (looking-at "\\<package\\|procedure\\|function\\>") | 2527 | (if (looking-at "\\<package\\|procedure\\|function\\>") |
| 2523 | (list (progn (back-to-indentation) (point)) 0) | 2528 | (list (progn (back-to-indentation) (point)) 0) |
| 2524 | (list (progn (back-to-indentation) (point)) 'ada-indent))))) | 2529 | (list (progn (back-to-indentation) (point)) 'ada-indent))))) |
| @@ -2599,8 +2604,8 @@ offset." | |||
| 2599 | ((and (= (downcase (char-after)) ?d) | 2604 | ((and (= (downcase (char-after)) ?d) |
| 2600 | (looking-at "do\\>")) | 2605 | (looking-at "do\\>")) |
| 2601 | (save-excursion | 2606 | (save-excursion |
| 2602 | (ada-goto-stmt-start) | 2607 | (ada-goto-stmt-start) |
| 2603 | (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))) | 2608 | (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent))) |
| 2604 | 2609 | ||
| 2605 | ;;-------------------------------- | 2610 | ;;-------------------------------- |
| 2606 | ;; starting with '-' (comment) | 2611 | ;; starting with '-' (comment) |
| @@ -2632,7 +2637,7 @@ offset." | |||
| 2632 | (ada-indent-on-previous-lines nil orgpoint orgpoint))) | 2637 | (ada-indent-on-previous-lines nil orgpoint orgpoint))) |
| 2633 | 2638 | ||
| 2634 | ;; Else same indentation as the previous line | 2639 | ;; Else same indentation as the previous line |
| 2635 | (list (save-excursion (back-to-indentation) (point)) 0))) | 2640 | (list (save-excursion (back-to-indentation) (point)) 0))) |
| 2636 | 2641 | ||
| 2637 | ;;-------------------------------- | 2642 | ;;-------------------------------- |
| 2638 | ;; starting with '#' (preprocessor line) | 2643 | ;; starting with '#' (preprocessor line) |
| @@ -2640,7 +2645,7 @@ offset." | |||
| 2640 | 2645 | ||
| 2641 | ((and (= (char-after) ?#) | 2646 | ((and (= (char-after) ?#) |
| 2642 | (equal ada-which-compiler 'gnat) | 2647 | (equal ada-which-compiler 'gnat) |
| 2643 | (looking-at "#[ \t]*\\(if\\|els\\(e\\|if\\)\\|end[ \t]*if\\)")) | 2648 | (looking-at "#[ \t]*\\(if\\|els\\(e\\|if\\)\\|end[ \t]*if\\)")) |
| 2644 | (list (save-excursion (beginning-of-line) (point)) 0)) | 2649 | (list (save-excursion (beginning-of-line) (point)) 0)) |
| 2645 | 2650 | ||
| 2646 | ;;-------------------------------- | 2651 | ;;-------------------------------- |
| @@ -2649,9 +2654,9 @@ offset." | |||
| 2649 | 2654 | ||
| 2650 | ((and (not (eobp)) (= (char-after) ?\))) | 2655 | ((and (not (eobp)) (= (char-after) ?\))) |
| 2651 | (save-excursion | 2656 | (save-excursion |
| 2652 | (forward-char 1) | 2657 | (forward-char 1) |
| 2653 | (backward-sexp 1) | 2658 | (backward-sexp 1) |
| 2654 | (list (point) 0))) | 2659 | (list (point) 0))) |
| 2655 | 2660 | ||
| 2656 | ;;--------------------------------- | 2661 | ;;--------------------------------- |
| 2657 | ;; new/abstract/separate | 2662 | ;; new/abstract/separate |
| @@ -2689,9 +2694,9 @@ offset." | |||
| 2689 | 2694 | ||
| 2690 | ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]") | 2695 | ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]") |
| 2691 | (if (ada-in-decl-p) | 2696 | (if (ada-in-decl-p) |
| 2692 | (ada-indent-on-previous-lines nil orgpoint orgpoint) | 2697 | (ada-indent-on-previous-lines nil orgpoint orgpoint) |
| 2693 | (append (ada-indent-on-previous-lines nil orgpoint orgpoint) | 2698 | (append (ada-indent-on-previous-lines nil orgpoint orgpoint) |
| 2694 | '(ada-label-indent)))) | 2699 | '(ada-label-indent)))) |
| 2695 | 2700 | ||
| 2696 | )) | 2701 | )) |
| 2697 | 2702 | ||
| @@ -2711,60 +2716,60 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation." | |||
| 2711 | 2716 | ||
| 2712 | ;; Is inside a parameter-list ? | 2717 | ;; Is inside a parameter-list ? |
| 2713 | (if (ada-in-paramlist-p) | 2718 | (if (ada-in-paramlist-p) |
| 2714 | (ada-get-indent-paramlist) | 2719 | (ada-get-indent-paramlist) |
| 2715 | 2720 | ||
| 2716 | ;; move to beginning of current statement | 2721 | ;; move to beginning of current statement |
| 2717 | (unless nomove | 2722 | (unless nomove |
| 2718 | (ada-goto-stmt-start)) | 2723 | (ada-goto-stmt-start)) |
| 2719 | 2724 | ||
| 2720 | ;; no beginning found => don't change indentation | 2725 | ;; no beginning found => don't change indentation |
| 2721 | (if (and (eq oldpoint (point)) | 2726 | (if (and (eq oldpoint (point)) |
| 2722 | (not nomove)) | 2727 | (not nomove)) |
| 2723 | (ada-get-indent-nochange) | 2728 | (ada-get-indent-nochange) |
| 2724 | 2729 | ||
| 2725 | (cond | 2730 | (cond |
| 2726 | ;; | 2731 | ;; |
| 2727 | ((and | 2732 | ((and |
| 2728 | ada-indent-to-open-paren | 2733 | ada-indent-to-open-paren |
| 2729 | (ada-in-open-paren-p)) | 2734 | (ada-in-open-paren-p)) |
| 2730 | (ada-get-indent-open-paren)) | 2735 | (ada-get-indent-open-paren)) |
| 2731 | ;; | 2736 | ;; |
| 2732 | ((looking-at "end\\>") | 2737 | ((looking-at "end\\>") |
| 2733 | (ada-get-indent-end orgpoint)) | 2738 | (ada-get-indent-end orgpoint)) |
| 2734 | ;; | 2739 | ;; |
| 2735 | ((looking-at ada-loop-start-re) | 2740 | ((looking-at ada-loop-start-re) |
| 2736 | (ada-get-indent-loop orgpoint)) | 2741 | (ada-get-indent-loop orgpoint)) |
| 2737 | ;; | 2742 | ;; |
| 2738 | ((looking-at ada-subprog-start-re) | 2743 | ((looking-at ada-subprog-start-re) |
| 2739 | (ada-get-indent-subprog orgpoint)) | 2744 | (ada-get-indent-subprog orgpoint)) |
| 2740 | ;; | 2745 | ;; |
| 2741 | ((looking-at ada-block-start-re) | 2746 | ((looking-at ada-block-start-re) |
| 2742 | (ada-get-indent-block-start orgpoint)) | 2747 | (ada-get-indent-block-start orgpoint)) |
| 2743 | ;; | 2748 | ;; |
| 2744 | ((looking-at "\\(sub\\)?type\\>") | 2749 | ((looking-at "\\(sub\\)?type\\>") |
| 2745 | (ada-get-indent-type orgpoint)) | 2750 | (ada-get-indent-type orgpoint)) |
| 2746 | ;; | 2751 | ;; |
| 2747 | ;; "then" has to be included in the case of "select...then abort" | 2752 | ;; "then" has to be included in the case of "select...then abort" |
| 2748 | ;; statements, since (goto-stmt-start) at the beginning of | 2753 | ;; statements, since (goto-stmt-start) at the beginning of |
| 2749 | ;; the current function would leave the cursor on that position | 2754 | ;; the current function would leave the cursor on that position |
| 2750 | ((looking-at "\\(\\(els\\)?if\\>\\)\\|then abort\\\>") | 2755 | ((looking-at "\\(\\(els\\)?if\\>\\)\\|then abort\\\>") |
| 2751 | (ada-get-indent-if orgpoint)) | 2756 | (ada-get-indent-if orgpoint)) |
| 2752 | ;; | 2757 | ;; |
| 2753 | ((looking-at "case\\>") | 2758 | ((looking-at "case\\>") |
| 2754 | (ada-get-indent-case orgpoint)) | 2759 | (ada-get-indent-case orgpoint)) |
| 2755 | ;; | 2760 | ;; |
| 2756 | ((looking-at "when\\>") | 2761 | ((looking-at "when\\>") |
| 2757 | (ada-get-indent-when orgpoint)) | 2762 | (ada-get-indent-when orgpoint)) |
| 2758 | ;; | 2763 | ;; |
| 2759 | ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]") | 2764 | ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]") |
| 2760 | (ada-get-indent-label orgpoint)) | 2765 | (ada-get-indent-label orgpoint)) |
| 2761 | ;; | 2766 | ;; |
| 2762 | ((looking-at "separate\\>") | 2767 | ((looking-at "separate\\>") |
| 2763 | (ada-get-indent-nochange)) | 2768 | (ada-get-indent-nochange)) |
| 2764 | 2769 | ||
| 2765 | ;; A label | 2770 | ;; A label |
| 2766 | ((looking-at "<<") | 2771 | ((looking-at "<<") |
| 2767 | (list (+ (save-excursion (back-to-indentation) (point)) | 2772 | (list (+ (save-excursion (back-to-indentation) (point)) |
| 2768 | (- ada-label-indent)))) | 2773 | (- ada-label-indent)))) |
| 2769 | 2774 | ||
| 2770 | ;; | 2775 | ;; |
| @@ -2777,8 +2782,8 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation." | |||
| 2777 | 'ada-with-indent | 2782 | 'ada-with-indent |
| 2778 | 'ada-use-indent)))) | 2783 | 'ada-use-indent)))) |
| 2779 | ;; | 2784 | ;; |
| 2780 | (t | 2785 | (t |
| 2781 | (ada-get-indent-noindent orgpoint))))) | 2786 | (ada-get-indent-noindent orgpoint))))) |
| 2782 | )) | 2787 | )) |
| 2783 | 2788 | ||
| 2784 | (defun ada-get-indent-open-paren () | 2789 | (defun ada-get-indent-open-paren () |
| @@ -2824,146 +2829,146 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation." | |||
| 2824 | "Calculate the indentation when point is just before an end statement. | 2829 | "Calculate the indentation when point is just before an end statement. |
| 2825 | ORGPOINT is the limit position used in the calculation." | 2830 | ORGPOINT is the limit position used in the calculation." |
| 2826 | (let ((defun-name nil) | 2831 | (let ((defun-name nil) |
| 2827 | (indent nil)) | 2832 | (indent nil)) |
| 2828 | 2833 | ||
| 2829 | ;; is the line already terminated by ';' ? | 2834 | ;; is the line already terminated by ';' ? |
| 2830 | (if (save-excursion | 2835 | (if (save-excursion |
| 2831 | (ada-search-ignore-string-comment ";" nil orgpoint nil | 2836 | (ada-search-ignore-string-comment ";" nil orgpoint nil |
| 2832 | 'search-forward)) | 2837 | 'search-forward)) |
| 2833 | 2838 | ||
| 2834 | ;; yes, look what's following 'end' | 2839 | ;; yes, look what's following 'end' |
| 2835 | (progn | 2840 | (progn |
| 2836 | (forward-word 1) | 2841 | (forward-word 1) |
| 2837 | (ada-goto-next-non-ws) | 2842 | (ada-goto-next-non-ws) |
| 2838 | (cond | 2843 | (cond |
| 2839 | ((looking-at "\\<\\(loop\\|select\\|if\\|case\\)\\>") | 2844 | ((looking-at "\\<\\(loop\\|select\\|if\\|case\\)\\>") |
| 2840 | (save-excursion (ada-check-matching-start (match-string 0))) | 2845 | (save-excursion (ada-check-matching-start (match-string 0))) |
| 2841 | (list (save-excursion (back-to-indentation) (point)) 0)) | 2846 | (list (save-excursion (back-to-indentation) (point)) 0)) |
| 2842 | 2847 | ||
| 2843 | ;; | 2848 | ;; |
| 2844 | ;; loop/select/if/case/record/select | 2849 | ;; loop/select/if/case/record/select |
| 2845 | ;; | 2850 | ;; |
| 2846 | ((looking-at "\\<record\\>") | 2851 | ((looking-at "\\<record\\>") |
| 2847 | (save-excursion | 2852 | (save-excursion |
| 2848 | (ada-check-matching-start (match-string 0)) | 2853 | (ada-check-matching-start (match-string 0)) |
| 2849 | ;; we are now looking at the matching "record" statement | 2854 | ;; we are now looking at the matching "record" statement |
| 2850 | (forward-word 1) | 2855 | (forward-word 1) |
| 2851 | (ada-goto-stmt-start) | 2856 | (ada-goto-stmt-start) |
| 2852 | ;; now on the matching type declaration, or use clause | 2857 | ;; now on the matching type declaration, or use clause |
| 2853 | (unless (looking-at "\\(for\\|type\\)\\>") | 2858 | (unless (looking-at "\\(for\\|type\\)\\>") |
| 2854 | (ada-search-ignore-string-comment "\\<type\\>" t)) | 2859 | (ada-search-ignore-string-comment "\\<type\\>" t)) |
| 2855 | (list (progn (back-to-indentation) (point)) 0))) | 2860 | (list (progn (back-to-indentation) (point)) 0))) |
| 2856 | ;; | 2861 | ;; |
| 2857 | ;; a named block end | 2862 | ;; a named block end |
| 2858 | ;; | 2863 | ;; |
| 2859 | ((looking-at ada-ident-re) | 2864 | ((looking-at ada-ident-re) |
| 2860 | (setq defun-name (match-string 0)) | 2865 | (setq defun-name (match-string 0)) |
| 2861 | (save-excursion | 2866 | (save-excursion |
| 2862 | (ada-goto-matching-start 0) | 2867 | (ada-goto-matching-start 0) |
| 2863 | (ada-check-defun-name defun-name)) | 2868 | (ada-check-defun-name defun-name)) |
| 2864 | (list (progn (back-to-indentation) (point)) 0)) | 2869 | (list (progn (back-to-indentation) (point)) 0)) |
| 2865 | ;; | 2870 | ;; |
| 2866 | ;; a block-end without name | 2871 | ;; a block-end without name |
| 2867 | ;; | 2872 | ;; |
| 2868 | ((= (char-after) ?\;) | 2873 | ((= (char-after) ?\;) |
| 2869 | (save-excursion | 2874 | (save-excursion |
| 2870 | (ada-goto-matching-start 0) | 2875 | (ada-goto-matching-start 0) |
| 2871 | (if (looking-at "\\<begin\\>") | 2876 | (if (looking-at "\\<begin\\>") |
| 2872 | (progn | 2877 | (progn |
| 2873 | (setq indent (list (point) 0)) | 2878 | (setq indent (list (point) 0)) |
| 2874 | (if (ada-goto-matching-decl-start t) | 2879 | (if (ada-goto-matching-decl-start t) |
| 2875 | (list (progn (back-to-indentation) (point)) 0) | 2880 | (list (progn (back-to-indentation) (point)) 0) |
| 2876 | indent)) | 2881 | indent)) |
| 2877 | (list (progn (back-to-indentation) (point)) 0) | 2882 | (list (progn (back-to-indentation) (point)) 0) |
| 2878 | ))) | 2883 | ))) |
| 2879 | ;; | 2884 | ;; |
| 2880 | ;; anything else - should maybe signal an error ? | 2885 | ;; anything else - should maybe signal an error ? |
| 2881 | ;; | 2886 | ;; |
| 2882 | (t | 2887 | (t |
| 2883 | (list (save-excursion (back-to-indentation) (point)) | 2888 | (list (save-excursion (back-to-indentation) (point)) |
| 2884 | 'ada-broken-indent)))) | 2889 | 'ada-broken-indent)))) |
| 2885 | 2890 | ||
| 2886 | (list (save-excursion (back-to-indentation) (point)) | 2891 | (list (save-excursion (back-to-indentation) (point)) |
| 2887 | 'ada-broken-indent)))) | 2892 | 'ada-broken-indent)))) |
| 2888 | 2893 | ||
| 2889 | (defun ada-get-indent-case (orgpoint) | 2894 | (defun ada-get-indent-case (orgpoint) |
| 2890 | "Calculate the indentation when point is just before a case statement. | 2895 | "Calculate the indentation when point is just before a case statement. |
| 2891 | ORGPOINT is the limit position used in the calculation." | 2896 | ORGPOINT is the limit position used in the calculation." |
| 2892 | (let ((match-cons nil) | 2897 | (let ((match-cons nil) |
| 2893 | (opos (point))) | 2898 | (opos (point))) |
| 2894 | (cond | 2899 | (cond |
| 2895 | ;; | 2900 | ;; |
| 2896 | ;; case..is..when..=> | 2901 | ;; case..is..when..=> |
| 2897 | ;; | 2902 | ;; |
| 2898 | ((save-excursion | 2903 | ((save-excursion |
| 2899 | (setq match-cons (and | 2904 | (setq match-cons (and |
| 2900 | ;; the `=>' must be after the keyword `is'. | 2905 | ;; the `=>' must be after the keyword `is'. |
| 2901 | (ada-search-ignore-string-comment | 2906 | (ada-search-ignore-string-comment |
| 2902 | "is" nil orgpoint nil 'word-search-forward) | 2907 | "is" nil orgpoint nil 'word-search-forward) |
| 2903 | (ada-search-ignore-string-comment | 2908 | (ada-search-ignore-string-comment |
| 2904 | "[ \t\n]+=>" nil orgpoint)))) | 2909 | "[ \t\n]+=>" nil orgpoint)))) |
| 2905 | (save-excursion | 2910 | (save-excursion |
| 2906 | (goto-char (car match-cons)) | 2911 | (goto-char (car match-cons)) |
| 2907 | (unless (ada-search-ignore-string-comment "when" t opos) | 2912 | (unless (ada-search-ignore-string-comment "when" t opos) |
| 2908 | (error "Missing 'when' between 'case' and '=>'")) | 2913 | (error "Missing 'when' between 'case' and '=>'")) |
| 2909 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent))) | 2914 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent))) |
| 2910 | ;; | 2915 | ;; |
| 2911 | ;; case..is..when | 2916 | ;; case..is..when |
| 2912 | ;; | 2917 | ;; |
| 2913 | ((save-excursion | 2918 | ((save-excursion |
| 2914 | (setq match-cons (ada-search-ignore-string-comment | 2919 | (setq match-cons (ada-search-ignore-string-comment |
| 2915 | "when" nil orgpoint nil 'word-search-forward))) | 2920 | "when" nil orgpoint nil 'word-search-forward))) |
| 2916 | (goto-char (cdr match-cons)) | 2921 | (goto-char (cdr match-cons)) |
| 2917 | (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent)) | 2922 | (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent)) |
| 2918 | ;; | 2923 | ;; |
| 2919 | ;; case..is | 2924 | ;; case..is |
| 2920 | ;; | 2925 | ;; |
| 2921 | ((save-excursion | 2926 | ((save-excursion |
| 2922 | (setq match-cons (ada-search-ignore-string-comment | 2927 | (setq match-cons (ada-search-ignore-string-comment |
| 2923 | "is" nil orgpoint nil 'word-search-forward))) | 2928 | "is" nil orgpoint nil 'word-search-forward))) |
| 2924 | (list (save-excursion (back-to-indentation) (point)) 'ada-when-indent)) | 2929 | (list (save-excursion (back-to-indentation) (point)) 'ada-when-indent)) |
| 2925 | ;; | 2930 | ;; |
| 2926 | ;; incomplete case | 2931 | ;; incomplete case |
| 2927 | ;; | 2932 | ;; |
| 2928 | (t | 2933 | (t |
| 2929 | (list (save-excursion (back-to-indentation) (point)) | 2934 | (list (save-excursion (back-to-indentation) (point)) |
| 2930 | 'ada-broken-indent))))) | 2935 | 'ada-broken-indent))))) |
| 2931 | 2936 | ||
| 2932 | (defun ada-get-indent-when (orgpoint) | 2937 | (defun ada-get-indent-when (orgpoint) |
| 2933 | "Calculate the indentation when point is just before a when statement. | 2938 | "Calculate the indentation when point is just before a when statement. |
| 2934 | ORGPOINT is the limit position used in the calculation." | 2939 | ORGPOINT is the limit position used in the calculation." |
| 2935 | (let ((cur-indent (save-excursion (back-to-indentation) (point)))) | 2940 | (let ((cur-indent (save-excursion (back-to-indentation) (point)))) |
| 2936 | (if (ada-search-ignore-string-comment "[ \t\n]*=>" nil orgpoint) | 2941 | (if (ada-search-ignore-string-comment "[ \t\n]*=>" nil orgpoint) |
| 2937 | (list cur-indent 'ada-indent) | 2942 | (list cur-indent 'ada-indent) |
| 2938 | (list cur-indent 'ada-broken-indent)))) | 2943 | (list cur-indent 'ada-broken-indent)))) |
| 2939 | 2944 | ||
| 2940 | (defun ada-get-indent-if (orgpoint) | 2945 | (defun ada-get-indent-if (orgpoint) |
| 2941 | "Calculate the indentation when point is just before an if statement. | 2946 | "Calculate the indentation when point is just before an if statement. |
| 2942 | ORGPOINT is the limit position used in the calculation." | 2947 | ORGPOINT is the limit position used in the calculation." |
| 2943 | (let ((cur-indent (save-excursion (back-to-indentation) (point))) | 2948 | (let ((cur-indent (save-excursion (back-to-indentation) (point))) |
| 2944 | (match-cons nil)) | 2949 | (match-cons nil)) |
| 2945 | ;; | 2950 | ;; |
| 2946 | ;; Move to the correct then (ignore all "and then") | 2951 | ;; Move to the correct then (ignore all "and then") |
| 2947 | ;; | 2952 | ;; |
| 2948 | (while (and (setq match-cons (ada-search-ignore-string-comment | 2953 | (while (and (setq match-cons (ada-search-ignore-string-comment |
| 2949 | "\\<\\(then\\|and[ \t]*then\\)\\>" | 2954 | "\\<\\(then\\|and[ \t]*then\\)\\>" |
| 2950 | nil orgpoint)) | 2955 | nil orgpoint)) |
| 2951 | (= (downcase (char-after (car match-cons))) ?a))) | 2956 | (= (downcase (char-after (car match-cons))) ?a))) |
| 2952 | ;; If "then" was found (we are looking at it) | 2957 | ;; If "then" was found (we are looking at it) |
| 2953 | (if match-cons | 2958 | (if match-cons |
| 2954 | (progn | 2959 | (progn |
| 2955 | ;; | 2960 | ;; |
| 2956 | ;; 'then' first in separate line ? | 2961 | ;; 'then' first in separate line ? |
| 2957 | ;; => indent according to 'then', | 2962 | ;; => indent according to 'then', |
| 2958 | ;; => else indent according to 'if' | 2963 | ;; => else indent according to 'if' |
| 2959 | ;; | 2964 | ;; |
| 2960 | (if (save-excursion | 2965 | (if (save-excursion |
| 2961 | (back-to-indentation) | 2966 | (back-to-indentation) |
| 2962 | (looking-at "\\<then\\>")) | 2967 | (looking-at "\\<then\\>")) |
| 2963 | (setq cur-indent (save-excursion (back-to-indentation) (point)))) | 2968 | (setq cur-indent (save-excursion (back-to-indentation) (point)))) |
| 2964 | ;; skip 'then' | 2969 | ;; skip 'then' |
| 2965 | (forward-word 1) | 2970 | (forward-word 1) |
| 2966 | (list cur-indent 'ada-indent)) | 2971 | (list cur-indent 'ada-indent)) |
| 2967 | 2972 | ||
| 2968 | (list cur-indent 'ada-broken-indent)))) | 2973 | (list cur-indent 'ada-broken-indent)))) |
| 2969 | 2974 | ||
| @@ -2973,11 +2978,11 @@ ORGPOINT is the limit position used in the calculation." | |||
| 2973 | (let ((pos nil)) | 2978 | (let ((pos nil)) |
| 2974 | (cond | 2979 | (cond |
| 2975 | ((save-excursion | 2980 | ((save-excursion |
| 2976 | (forward-word 1) | 2981 | (forward-word 1) |
| 2977 | (setq pos (ada-goto-next-non-ws orgpoint))) | 2982 | (setq pos (ada-goto-next-non-ws orgpoint))) |
| 2978 | (goto-char pos) | 2983 | (goto-char pos) |
| 2979 | (save-excursion | 2984 | (save-excursion |
| 2980 | (ada-indent-on-previous-lines t orgpoint))) | 2985 | (ada-indent-on-previous-lines t orgpoint))) |
| 2981 | 2986 | ||
| 2982 | ;; Special case for record types, for instance for: | 2987 | ;; Special case for record types, for instance for: |
| 2983 | ;; type A is (B : Integer; | 2988 | ;; type A is (B : Integer; |
| @@ -3004,27 +3009,27 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3004 | "Calculate the indentation when point is just before a subprogram. | 3009 | "Calculate the indentation when point is just before a subprogram. |
| 3005 | ORGPOINT is the limit position used in the calculation." | 3010 | ORGPOINT is the limit position used in the calculation." |
| 3006 | (let ((match-cons nil) | 3011 | (let ((match-cons nil) |
| 3007 | (cur-indent (save-excursion (back-to-indentation) (point))) | 3012 | (cur-indent (save-excursion (back-to-indentation) (point))) |
| 3008 | (foundis nil)) | 3013 | (foundis nil)) |
| 3009 | ;; | 3014 | ;; |
| 3010 | ;; is there an 'is' in front of point ? | 3015 | ;; is there an 'is' in front of point ? |
| 3011 | ;; | 3016 | ;; |
| 3012 | (if (save-excursion | 3017 | (if (save-excursion |
| 3013 | (setq match-cons | 3018 | (setq match-cons |
| 3014 | (ada-search-ignore-string-comment | 3019 | (ada-search-ignore-string-comment |
| 3015 | "\\<\\(is\\|do\\)\\>" nil orgpoint))) | 3020 | "\\<\\(is\\|do\\)\\>" nil orgpoint))) |
| 3016 | ;; | 3021 | ;; |
| 3017 | ;; yes, then skip to its end | 3022 | ;; yes, then skip to its end |
| 3018 | ;; | 3023 | ;; |
| 3019 | (progn | 3024 | (progn |
| 3020 | (setq foundis t) | 3025 | (setq foundis t) |
| 3021 | (goto-char (cdr match-cons))) | 3026 | (goto-char (cdr match-cons))) |
| 3022 | ;; | 3027 | ;; |
| 3023 | ;; no, then goto next non-ws, if there is one in front of point | 3028 | ;; no, then goto next non-ws, if there is one in front of point |
| 3024 | ;; | 3029 | ;; |
| 3025 | (progn | 3030 | (progn |
| 3026 | (unless (ada-goto-next-non-ws orgpoint) | 3031 | (unless (ada-goto-next-non-ws orgpoint) |
| 3027 | (goto-char orgpoint)))) | 3032 | (goto-char orgpoint)))) |
| 3028 | 3033 | ||
| 3029 | (cond | 3034 | (cond |
| 3030 | ;; | 3035 | ;; |
| @@ -3033,8 +3038,8 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3033 | ((and | 3038 | ((and |
| 3034 | foundis | 3039 | foundis |
| 3035 | (save-excursion | 3040 | (save-excursion |
| 3036 | (not (ada-search-ignore-string-comment | 3041 | (not (ada-search-ignore-string-comment |
| 3037 | "[^ \t\n]" nil orgpoint t)))) | 3042 | "[^ \t\n]" nil orgpoint t)))) |
| 3038 | (list cur-indent 'ada-indent)) | 3043 | (list cur-indent 'ada-indent)) |
| 3039 | ;; | 3044 | ;; |
| 3040 | ;; is abstract/separate/new ... | 3045 | ;; is abstract/separate/new ... |
| @@ -3042,10 +3047,10 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3042 | ((and | 3047 | ((and |
| 3043 | foundis | 3048 | foundis |
| 3044 | (save-excursion | 3049 | (save-excursion |
| 3045 | (setq match-cons | 3050 | (setq match-cons |
| 3046 | (ada-search-ignore-string-comment | 3051 | (ada-search-ignore-string-comment |
| 3047 | "\\<\\(separate\\|new\\|abstract\\)\\>" | 3052 | "\\<\\(separate\\|new\\|abstract\\)\\>" |
| 3048 | nil orgpoint)))) | 3053 | nil orgpoint)))) |
| 3049 | (goto-char (car match-cons)) | 3054 | (goto-char (car match-cons)) |
| 3050 | (ada-search-ignore-string-comment ada-subprog-start-re t) | 3055 | (ada-search-ignore-string-comment ada-subprog-start-re t) |
| 3051 | (ada-get-indent-noindent orgpoint)) | 3056 | (ada-get-indent-noindent orgpoint)) |
| @@ -3061,7 +3066,7 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3061 | ;; no 'is' but ';' | 3066 | ;; no 'is' but ';' |
| 3062 | ;; | 3067 | ;; |
| 3063 | ((save-excursion | 3068 | ((save-excursion |
| 3064 | (ada-search-ignore-string-comment ";" nil orgpoint nil 'search-forward)) | 3069 | (ada-search-ignore-string-comment ";" nil orgpoint nil 'search-forward)) |
| 3065 | (list cur-indent 0)) | 3070 | (list cur-indent 0)) |
| 3066 | ;; | 3071 | ;; |
| 3067 | ;; no 'is' or ';' | 3072 | ;; no 'is' or ';' |
| @@ -3082,74 +3087,74 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3082 | ;; subprogram declaration (in that case, we are at this point inside | 3087 | ;; subprogram declaration (in that case, we are at this point inside |
| 3083 | ;; the parameter declaration list) | 3088 | ;; the parameter declaration list) |
| 3084 | ((ada-in-paramlist-p) | 3089 | ((ada-in-paramlist-p) |
| 3085 | (ada-previous-procedure) | 3090 | (ada-previous-procedure) |
| 3086 | (list (save-excursion (back-to-indentation) (point)) 0)) | 3091 | (list (save-excursion (back-to-indentation) (point)) 0)) |
| 3087 | 3092 | ||
| 3088 | ;; This one is called when indenting the second line of a multi-line | 3093 | ;; This one is called when indenting the second line of a multi-line |
| 3089 | ;; declaration section, in a declare block or a record declaration | 3094 | ;; declaration section, in a declare block or a record declaration |
| 3090 | ((looking-at "[ \t]*\\(\\sw\\|_\\)*[ \t]*,[ \t]*$") | 3095 | ((looking-at "[ \t]*\\(\\sw\\|_\\)*[ \t]*,[ \t]*$") |
| 3091 | (list (save-excursion (back-to-indentation) (point)) | 3096 | (list (save-excursion (back-to-indentation) (point)) |
| 3092 | 'ada-broken-decl-indent)) | 3097 | 'ada-broken-decl-indent)) |
| 3093 | 3098 | ||
| 3094 | ;; This one is called in every over case when indenting a line at the | 3099 | ;; This one is called in every over case when indenting a line at the |
| 3095 | ;; top level | 3100 | ;; top level |
| 3096 | (t | 3101 | (t |
| 3097 | (if (looking-at ada-named-block-re) | 3102 | (if (looking-at ada-named-block-re) |
| 3098 | (setq label (- ada-label-indent)) | 3103 | (setq label (- ada-label-indent)) |
| 3099 | 3104 | ||
| 3100 | (let (p) | 3105 | (let (p) |
| 3101 | 3106 | ||
| 3102 | ;; "with private" or "null record" cases | 3107 | ;; "with private" or "null record" cases |
| 3103 | (if (or (save-excursion | 3108 | (if (or (save-excursion |
| 3104 | (and (ada-search-ignore-string-comment "\\<private\\>" nil orgpoint) | 3109 | (and (ada-search-ignore-string-comment "\\<private\\>" nil orgpoint) |
| 3105 | (setq p (point)) | 3110 | (setq p (point)) |
| 3106 | (save-excursion (forward-char -7);; skip back "private" | 3111 | (save-excursion (forward-char -7);; skip back "private" |
| 3107 | (ada-goto-previous-word) | 3112 | (ada-goto-previous-word) |
| 3108 | (looking-at "with")))) | 3113 | (looking-at "with")))) |
| 3109 | (save-excursion | 3114 | (save-excursion |
| 3110 | (and (ada-search-ignore-string-comment "\\<record\\>" nil orgpoint) | 3115 | (and (ada-search-ignore-string-comment "\\<record\\>" nil orgpoint) |
| 3111 | (setq p (point)) | 3116 | (setq p (point)) |
| 3112 | (save-excursion (forward-char -6);; skip back "record" | 3117 | (save-excursion (forward-char -6);; skip back "record" |
| 3113 | (ada-goto-previous-word) | 3118 | (ada-goto-previous-word) |
| 3114 | (looking-at "null"))))) | 3119 | (looking-at "null"))))) |
| 3115 | (progn | 3120 | (progn |
| 3116 | (goto-char p) | 3121 | (goto-char p) |
| 3117 | (re-search-backward "\\<\\(type\\|subtype\\)\\>" nil t) | 3122 | (re-search-backward "\\<\\(type\\|subtype\\)\\>" nil t) |
| 3118 | (list (save-excursion (back-to-indentation) (point)) 0))))) | 3123 | (list (save-excursion (back-to-indentation) (point)) 0))))) |
| 3119 | (if (save-excursion | 3124 | (if (save-excursion |
| 3120 | (ada-search-ignore-string-comment ";" nil orgpoint nil | 3125 | (ada-search-ignore-string-comment ";" nil orgpoint nil |
| 3121 | 'search-forward)) | 3126 | 'search-forward)) |
| 3122 | (list (+ (save-excursion (back-to-indentation) (point)) label) 0) | 3127 | (list (+ (save-excursion (back-to-indentation) (point)) label) 0) |
| 3123 | (list (+ (save-excursion (back-to-indentation) (point)) label) | 3128 | (list (+ (save-excursion (back-to-indentation) (point)) label) |
| 3124 | 'ada-broken-indent))))))) | 3129 | 'ada-broken-indent))))))) |
| 3125 | 3130 | ||
| 3126 | (defun ada-get-indent-label (orgpoint) | 3131 | (defun ada-get-indent-label (orgpoint) |
| 3127 | "Calculate the indentation when before a label or variable declaration. | 3132 | "Calculate the indentation when before a label or variable declaration. |
| 3128 | ORGPOINT is the limit position used in the calculation." | 3133 | ORGPOINT is the limit position used in the calculation." |
| 3129 | (let ((match-cons nil) | 3134 | (let ((match-cons nil) |
| 3130 | (cur-indent (save-excursion (back-to-indentation) (point)))) | 3135 | (cur-indent (save-excursion (back-to-indentation) (point)))) |
| 3131 | (ada-search-ignore-string-comment ":" nil) | 3136 | (ada-search-ignore-string-comment ":" nil) |
| 3132 | (cond | 3137 | (cond |
| 3133 | ;; loop label | 3138 | ;; loop label |
| 3134 | ((save-excursion | 3139 | ((save-excursion |
| 3135 | (setq match-cons (ada-search-ignore-string-comment | 3140 | (setq match-cons (ada-search-ignore-string-comment |
| 3136 | ada-loop-start-re nil orgpoint))) | 3141 | ada-loop-start-re nil orgpoint))) |
| 3137 | (goto-char (car match-cons)) | 3142 | (goto-char (car match-cons)) |
| 3138 | (ada-get-indent-loop orgpoint)) | 3143 | (ada-get-indent-loop orgpoint)) |
| 3139 | 3144 | ||
| 3140 | ;; declare label | 3145 | ;; declare label |
| 3141 | ((save-excursion | 3146 | ((save-excursion |
| 3142 | (setq match-cons (ada-search-ignore-string-comment | 3147 | (setq match-cons (ada-search-ignore-string-comment |
| 3143 | "\\<declare\\|begin\\>" nil orgpoint))) | 3148 | "\\<declare\\|begin\\>" nil orgpoint))) |
| 3144 | (goto-char (car match-cons)) | 3149 | (goto-char (car match-cons)) |
| 3145 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent)) | 3150 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent)) |
| 3146 | 3151 | ||
| 3147 | ;; variable declaration | 3152 | ;; variable declaration |
| 3148 | ((ada-in-decl-p) | 3153 | ((ada-in-decl-p) |
| 3149 | (if (save-excursion | 3154 | (if (save-excursion |
| 3150 | (ada-search-ignore-string-comment ";" nil orgpoint)) | 3155 | (ada-search-ignore-string-comment ";" nil orgpoint)) |
| 3151 | (list cur-indent 0) | 3156 | (list cur-indent 0) |
| 3152 | (list cur-indent 'ada-broken-indent))) | 3157 | (list cur-indent 'ada-broken-indent))) |
| 3153 | 3158 | ||
| 3154 | ;; nothing follows colon | 3159 | ;; nothing follows colon |
| 3155 | (t | 3160 | (t |
| @@ -3159,14 +3164,14 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3159 | "Calculate the indentation when just before a loop or a for ... use. | 3164 | "Calculate the indentation when just before a loop or a for ... use. |
| 3160 | ORGPOINT is the limit position used in the calculation." | 3165 | ORGPOINT is the limit position used in the calculation." |
| 3161 | (let ((match-cons nil) | 3166 | (let ((match-cons nil) |
| 3162 | (pos (point)) | 3167 | (pos (point)) |
| 3163 | 3168 | ||
| 3164 | ;; If looking at a named block, skip the label | 3169 | ;; If looking at a named block, skip the label |
| 3165 | (label (save-excursion | 3170 | (label (save-excursion |
| 3166 | (beginning-of-line) | 3171 | (beginning-of-line) |
| 3167 | (if (looking-at ada-named-block-re) | 3172 | (if (looking-at ada-named-block-re) |
| 3168 | (- ada-label-indent) | 3173 | (- ada-label-indent) |
| 3169 | 0)))) | 3174 | 0)))) |
| 3170 | 3175 | ||
| 3171 | (cond | 3176 | (cond |
| 3172 | 3177 | ||
| @@ -3174,8 +3179,8 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3174 | ;; statement complete | 3179 | ;; statement complete |
| 3175 | ;; | 3180 | ;; |
| 3176 | ((save-excursion | 3181 | ((save-excursion |
| 3177 | (ada-search-ignore-string-comment ";" nil orgpoint nil | 3182 | (ada-search-ignore-string-comment ";" nil orgpoint nil |
| 3178 | 'search-forward)) | 3183 | 'search-forward)) |
| 3179 | (list (+ (save-excursion (back-to-indentation) (point)) label) 0)) | 3184 | (list (+ (save-excursion (back-to-indentation) (point)) label) 0)) |
| 3180 | ;; | 3185 | ;; |
| 3181 | ;; simple loop | 3186 | ;; simple loop |
| @@ -3183,8 +3188,8 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3183 | ((looking-at "loop\\>") | 3188 | ((looking-at "loop\\>") |
| 3184 | (setq pos (ada-get-indent-block-start orgpoint)) | 3189 | (setq pos (ada-get-indent-block-start orgpoint)) |
| 3185 | (if (equal label 0) | 3190 | (if (equal label 0) |
| 3186 | pos | 3191 | pos |
| 3187 | (list (+ (car pos) label) (cdr pos)))) | 3192 | (list (+ (car pos) label) (cdr pos)))) |
| 3188 | 3193 | ||
| 3189 | ;; | 3194 | ;; |
| 3190 | ;; 'for'- loop (or also a for ... use statement) | 3195 | ;; 'for'- loop (or also a for ... use statement) |
| @@ -3195,21 +3200,21 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3195 | ;; for ... use | 3200 | ;; for ... use |
| 3196 | ;; | 3201 | ;; |
| 3197 | ((save-excursion | 3202 | ((save-excursion |
| 3198 | (and | 3203 | (and |
| 3199 | (goto-char (match-end 0)) | 3204 | (goto-char (match-end 0)) |
| 3200 | (ada-goto-next-non-ws orgpoint) | 3205 | (ada-goto-next-non-ws orgpoint) |
| 3201 | (forward-word 1) | 3206 | (forward-word 1) |
| 3202 | (if (= (char-after) ?') (forward-word 1) t) | 3207 | (if (= (char-after) ?') (forward-word 1) t) |
| 3203 | (ada-goto-next-non-ws orgpoint) | 3208 | (ada-goto-next-non-ws orgpoint) |
| 3204 | (looking-at "\\<use\\>") | 3209 | (looking-at "\\<use\\>") |
| 3205 | ;; | 3210 | ;; |
| 3206 | ;; check if there is a 'record' before point | 3211 | ;; check if there is a 'record' before point |
| 3207 | ;; | 3212 | ;; |
| 3208 | (progn | 3213 | (progn |
| 3209 | (setq match-cons (ada-search-ignore-string-comment | 3214 | (setq match-cons (ada-search-ignore-string-comment |
| 3210 | "record" nil orgpoint nil 'word-search-forward)) | 3215 | "record" nil orgpoint nil 'word-search-forward)) |
| 3211 | t))) | 3216 | t))) |
| 3212 | (if match-cons | 3217 | (if match-cons |
| 3213 | (progn | 3218 | (progn |
| 3214 | (goto-char (car match-cons)) | 3219 | (goto-char (car match-cons)) |
| 3215 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent)) | 3220 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent)) |
| @@ -3220,25 +3225,25 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3220 | ;; for..loop | 3225 | ;; for..loop |
| 3221 | ;; | 3226 | ;; |
| 3222 | ((save-excursion | 3227 | ((save-excursion |
| 3223 | (setq match-cons (ada-search-ignore-string-comment | 3228 | (setq match-cons (ada-search-ignore-string-comment |
| 3224 | "loop" nil orgpoint nil 'word-search-forward))) | 3229 | "loop" nil orgpoint nil 'word-search-forward))) |
| 3225 | (goto-char (car match-cons)) | 3230 | (goto-char (car match-cons)) |
| 3226 | ;; | 3231 | ;; |
| 3227 | ;; indent according to 'loop', if it's first in the line; | 3232 | ;; indent according to 'loop', if it's first in the line; |
| 3228 | ;; otherwise to 'for' | 3233 | ;; otherwise to 'for' |
| 3229 | ;; | 3234 | ;; |
| 3230 | (unless (save-excursion | 3235 | (unless (save-excursion |
| 3231 | (back-to-indentation) | 3236 | (back-to-indentation) |
| 3232 | (looking-at "\\<loop\\>")) | 3237 | (looking-at "\\<loop\\>")) |
| 3233 | (goto-char pos)) | 3238 | (goto-char pos)) |
| 3234 | (list (+ (save-excursion (back-to-indentation) (point)) label) | 3239 | (list (+ (save-excursion (back-to-indentation) (point)) label) |
| 3235 | 'ada-indent)) | 3240 | 'ada-indent)) |
| 3236 | ;; | 3241 | ;; |
| 3237 | ;; for-statement is broken | 3242 | ;; for-statement is broken |
| 3238 | ;; | 3243 | ;; |
| 3239 | (t | 3244 | (t |
| 3240 | (list (+ (save-excursion (back-to-indentation) (point)) label) | 3245 | (list (+ (save-excursion (back-to-indentation) (point)) label) |
| 3241 | 'ada-broken-indent)))) | 3246 | 'ada-broken-indent)))) |
| 3242 | 3247 | ||
| 3243 | ;; | 3248 | ;; |
| 3244 | ;; 'while'-loop | 3249 | ;; 'while'-loop |
| @@ -3248,24 +3253,24 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3248 | ;; while..loop ? | 3253 | ;; while..loop ? |
| 3249 | ;; | 3254 | ;; |
| 3250 | (if (save-excursion | 3255 | (if (save-excursion |
| 3251 | (setq match-cons (ada-search-ignore-string-comment | 3256 | (setq match-cons (ada-search-ignore-string-comment |
| 3252 | "loop" nil orgpoint nil 'word-search-forward))) | 3257 | "loop" nil orgpoint nil 'word-search-forward))) |
| 3253 | 3258 | ||
| 3254 | (progn | 3259 | (progn |
| 3255 | (goto-char (car match-cons)) | 3260 | (goto-char (car match-cons)) |
| 3256 | ;; | 3261 | ;; |
| 3257 | ;; indent according to 'loop', if it's first in the line; | 3262 | ;; indent according to 'loop', if it's first in the line; |
| 3258 | ;; otherwise to 'while'. | 3263 | ;; otherwise to 'while'. |
| 3259 | ;; | 3264 | ;; |
| 3260 | (unless (save-excursion | 3265 | (unless (save-excursion |
| 3261 | (back-to-indentation) | 3266 | (back-to-indentation) |
| 3262 | (looking-at "\\<loop\\>")) | 3267 | (looking-at "\\<loop\\>")) |
| 3263 | (goto-char pos)) | 3268 | (goto-char pos)) |
| 3264 | (list (+ (save-excursion (back-to-indentation) (point)) label) | 3269 | (list (+ (save-excursion (back-to-indentation) (point)) label) |
| 3265 | 'ada-indent)) | 3270 | 'ada-indent)) |
| 3266 | 3271 | ||
| 3267 | (list (+ (save-excursion (back-to-indentation) (point)) label) | 3272 | (list (+ (save-excursion (back-to-indentation) (point)) label) |
| 3268 | 'ada-broken-indent)))))) | 3273 | 'ada-broken-indent)))))) |
| 3269 | 3274 | ||
| 3270 | (defun ada-get-indent-type (orgpoint) | 3275 | (defun ada-get-indent-type (orgpoint) |
| 3271 | "Calculate the indentation when before a type statement. | 3276 | "Calculate the indentation when before a type statement. |
| @@ -3276,46 +3281,46 @@ ORGPOINT is the limit position used in the calculation." | |||
| 3276 | ;; complete record declaration | 3281 | ;; complete record declaration |
| 3277 | ;; | 3282 | ;; |
| 3278 | ((save-excursion | 3283 | ((save-excursion |
| 3279 | (and | 3284 | (and |
| 3280 | (setq match-dat (ada-search-ignore-string-comment | 3285 | (setq match-dat (ada-search-ignore-string-comment |
| 3281 | "end" nil orgpoint nil 'word-search-forward)) | 3286 | "end" nil orgpoint nil 'word-search-forward)) |
| 3282 | (ada-goto-next-non-ws) | 3287 | (ada-goto-next-non-ws) |
| 3283 | (looking-at "\\<record\\>") | 3288 | (looking-at "\\<record\\>") |
| 3284 | (forward-word 1) | 3289 | (forward-word 1) |
| 3285 | (ada-goto-next-non-ws) | 3290 | (ada-goto-next-non-ws) |
| 3286 | (= (char-after) ?\;))) | 3291 | (= (char-after) ?\;))) |
| 3287 | (goto-char (car match-dat)) | 3292 | (goto-char (car match-dat)) |
| 3288 | (list (save-excursion (back-to-indentation) (point)) 0)) | 3293 | (list (save-excursion (back-to-indentation) (point)) 0)) |
| 3289 | ;; | 3294 | ;; |
| 3290 | ;; record type | 3295 | ;; record type |
| 3291 | ;; | 3296 | ;; |
| 3292 | ((save-excursion | 3297 | ((save-excursion |
| 3293 | (setq match-dat (ada-search-ignore-string-comment | 3298 | (setq match-dat (ada-search-ignore-string-comment |
| 3294 | "record" nil orgpoint nil 'word-search-forward))) | 3299 | "record" nil orgpoint nil 'word-search-forward))) |
| 3295 | (goto-char (car match-dat)) | 3300 | (goto-char (car match-dat)) |
| 3296 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent)) | 3301 | (list (save-excursion (back-to-indentation) (point)) 'ada-indent)) |
| 3297 | ;; | 3302 | ;; |
| 3298 | ;; complete type declaration | 3303 | ;; complete type declaration |
| 3299 | ;; | 3304 | ;; |
| 3300 | ((save-excursion | 3305 | ((save-excursion |
| 3301 | (ada-search-ignore-string-comment ";" nil orgpoint nil | 3306 | (ada-search-ignore-string-comment ";" nil orgpoint nil |
| 3302 | 'search-forward)) | 3307 | 'search-forward)) |
| 3303 | (list (save-excursion (back-to-indentation) (point)) 0)) | 3308 | (list (save-excursion (back-to-indentation) (point)) 0)) |
| 3304 | ;; | 3309 | ;; |
| 3305 | ;; "type ... is", but not "type ... is ...", which is broken | 3310 | ;; "type ... is", but not "type ... is ...", which is broken |
| 3306 | ;; | 3311 | ;; |
| 3307 | ((save-excursion | 3312 | ((save-excursion |
| 3308 | (and | 3313 | (and |
| 3309 | (ada-search-ignore-string-comment "is" nil orgpoint nil | 3314 | (ada-search-ignore-string-comment "is" nil orgpoint nil |
| 3310 | 'word-search-forward) | 3315 | 'word-search-forward) |
| 3311 | (not (ada-goto-next-non-ws orgpoint)))) | 3316 | (not (ada-goto-next-non-ws orgpoint)))) |
| 3312 | (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent)) | 3317 | (list (save-excursion (back-to-indentation) (point)) 'ada-broken-indent)) |
| 3313 | ;; | 3318 | ;; |
| 3314 | ;; broken statement | 3319 | ;; broken statement |
| 3315 | ;; | 3320 | ;; |
| 3316 | (t | 3321 | (t |
| 3317 | (list (save-excursion (back-to-indentation) (point)) | 3322 | (list (save-excursion (back-to-indentation) (point)) |
| 3318 | 'ada-broken-indent))))) | 3323 | 'ada-broken-indent))))) |
| 3319 | 3324 | ||
| 3320 | 3325 | ||
| 3321 | ;; ----------------------------------------------------------- | 3326 | ;; ----------------------------------------------------------- |
| @@ -3328,7 +3333,7 @@ Return the new position of point. | |||
| 3328 | As a special case, if we are looking at a closing parenthesis, skip to the | 3333 | As a special case, if we are looking at a closing parenthesis, skip to the |
| 3329 | open parenthesis." | 3334 | open parenthesis." |
| 3330 | (let ((match-dat nil) | 3335 | (let ((match-dat nil) |
| 3331 | (orgpoint (point))) | 3336 | (orgpoint (point))) |
| 3332 | 3337 | ||
| 3333 | (setq match-dat (ada-search-prev-end-stmt)) | 3338 | (setq match-dat (ada-search-prev-end-stmt)) |
| 3334 | (if match-dat | 3339 | (if match-dat |
| @@ -3373,14 +3378,14 @@ open parenthesis." | |||
| 3373 | Return a cons cell whose car is the beginning and whose cdr | 3378 | Return a cons cell whose car is the beginning and whose cdr |
| 3374 | is the end of the match." | 3379 | is the end of the match." |
| 3375 | (let ((match-dat nil) | 3380 | (let ((match-dat nil) |
| 3376 | (found nil)) | 3381 | (found nil)) |
| 3377 | 3382 | ||
| 3378 | ;; search until found or beginning-of-buffer | 3383 | ;; search until found or beginning-of-buffer |
| 3379 | (while | 3384 | (while |
| 3380 | (and | 3385 | (and |
| 3381 | (not found) | 3386 | (not found) |
| 3382 | (setq match-dat (ada-search-ignore-string-comment | 3387 | (setq match-dat (ada-search-ignore-string-comment |
| 3383 | ada-end-stmt-re t))) | 3388 | ada-end-stmt-re t))) |
| 3384 | 3389 | ||
| 3385 | (goto-char (car match-dat)) | 3390 | (goto-char (car match-dat)) |
| 3386 | (unless (ada-in-open-paren-p) | 3391 | (unless (ada-in-open-paren-p) |
| @@ -3395,27 +3400,27 @@ is the end of the match." | |||
| 3395 | 3400 | ||
| 3396 | ((looking-at "is") | 3401 | ((looking-at "is") |
| 3397 | (setq found | 3402 | (setq found |
| 3398 | (and (save-excursion (ada-goto-previous-word) | 3403 | (and (save-excursion (ada-goto-previous-word) |
| 3399 | (ada-goto-previous-word) | 3404 | (ada-goto-previous-word) |
| 3400 | (not (looking-at "subtype"))) | 3405 | (not (looking-at "subtype"))) |
| 3401 | 3406 | ||
| 3402 | (save-excursion (goto-char (cdr match-dat)) | 3407 | (save-excursion (goto-char (cdr match-dat)) |
| 3403 | (ada-goto-next-non-ws) | 3408 | (ada-goto-next-non-ws) |
| 3404 | ;; words that can go after an 'is' | 3409 | ;; words that can go after an 'is' |
| 3405 | (not (looking-at | 3410 | (not (looking-at |
| 3406 | (eval-when-compile | 3411 | (eval-when-compile |
| 3407 | (concat "\\<" | 3412 | (concat "\\<" |
| 3408 | (regexp-opt | 3413 | (regexp-opt |
| 3409 | '("separate" "access" "array" | 3414 | '("separate" "access" "array" |
| 3410 | "abstract" "new") t) | 3415 | "abstract" "new") t) |
| 3411 | "\\>\\|(")))))))) | 3416 | "\\>\\|(")))))))) |
| 3412 | 3417 | ||
| 3413 | (t | 3418 | (t |
| 3414 | (setq found t)) | 3419 | (setq found t)) |
| 3415 | ))) | 3420 | ))) |
| 3416 | 3421 | ||
| 3417 | (if found | 3422 | (if found |
| 3418 | match-dat | 3423 | match-dat |
| 3419 | nil))) | 3424 | nil))) |
| 3420 | 3425 | ||
| 3421 | 3426 | ||
| @@ -3426,11 +3431,11 @@ Do not call this function from within a string." | |||
| 3426 | (unless limit | 3431 | (unless limit |
| 3427 | (setq limit (point-max))) | 3432 | (setq limit (point-max))) |
| 3428 | (while (and (<= (point) limit) | 3433 | (while (and (<= (point) limit) |
| 3429 | (progn (forward-comment 10000) | 3434 | (progn (forward-comment 10000) |
| 3430 | (if (and (not (eobp)) | 3435 | (if (and (not (eobp)) |
| 3431 | (save-excursion (forward-char 1) | 3436 | (save-excursion (forward-char 1) |
| 3432 | (ada-in-string-p))) | 3437 | (ada-in-string-p))) |
| 3433 | (progn (forward-sexp 1) t))))) | 3438 | (progn (forward-sexp 1) t))))) |
| 3434 | (if (< (point) limit) | 3439 | (if (< (point) limit) |
| 3435 | (point) | 3440 | (point) |
| 3436 | nil) | 3441 | nil) |
| @@ -3451,22 +3456,22 @@ Stop the search at LIMIT." | |||
| 3451 | If BACKWARD is non-nil, jump to the beginning of the previous word. | 3456 | If BACKWARD is non-nil, jump to the beginning of the previous word. |
| 3452 | Return the new position of point or nil if not found." | 3457 | Return the new position of point or nil if not found." |
| 3453 | (let ((match-cons nil) | 3458 | (let ((match-cons nil) |
| 3454 | (orgpoint (point)) | 3459 | (orgpoint (point)) |
| 3455 | (old-syntax (char-to-string (char-syntax ?_)))) | 3460 | (old-syntax (char-to-string (char-syntax ?_)))) |
| 3456 | (modify-syntax-entry ?_ "w") | 3461 | (modify-syntax-entry ?_ "w") |
| 3457 | (unless backward | 3462 | (unless backward |
| 3458 | (skip-syntax-forward "w")) | 3463 | (skip-syntax-forward "w")) |
| 3459 | (if (setq match-cons | 3464 | (if (setq match-cons |
| 3460 | (if backward | 3465 | (if backward |
| 3461 | (ada-search-ignore-string-comment "\\w" t nil t) | 3466 | (ada-search-ignore-string-comment "\\w" t nil t) |
| 3462 | (ada-search-ignore-string-comment "\\w" nil nil t))) | 3467 | (ada-search-ignore-string-comment "\\w" nil nil t))) |
| 3463 | ;; | 3468 | ;; |
| 3464 | ;; move to the beginning of the word found | 3469 | ;; move to the beginning of the word found |
| 3465 | ;; | 3470 | ;; |
| 3466 | (progn | 3471 | (progn |
| 3467 | (goto-char (car match-cons)) | 3472 | (goto-char (car match-cons)) |
| 3468 | (skip-syntax-backward "w") | 3473 | (skip-syntax-backward "w") |
| 3469 | (point)) | 3474 | (point)) |
| 3470 | ;; | 3475 | ;; |
| 3471 | ;; if not found, restore old position of point | 3476 | ;; if not found, restore old position of point |
| 3472 | ;; | 3477 | ;; |
| @@ -3491,8 +3496,8 @@ Moves point to the beginning of the declaration." | |||
| 3491 | 3496 | ||
| 3492 | ;; named block without a `declare' | 3497 | ;; named block without a `declare' |
| 3493 | (if (save-excursion | 3498 | (if (save-excursion |
| 3494 | (ada-goto-previous-word) | 3499 | (ada-goto-previous-word) |
| 3495 | (looking-at (concat "\\<" defun-name "\\> *:"))) | 3500 | (looking-at (concat "\\<" defun-name "\\> *:"))) |
| 3496 | t ; do nothing | 3501 | t ; do nothing |
| 3497 | ;; | 3502 | ;; |
| 3498 | ;; 'accept' or 'package' ? | 3503 | ;; 'accept' or 'package' ? |
| @@ -3507,27 +3512,27 @@ Moves point to the beginning of the declaration." | |||
| 3507 | ;; a named 'declare'-block ? | 3512 | ;; a named 'declare'-block ? |
| 3508 | ;; | 3513 | ;; |
| 3509 | (if (looking-at "\\<declare\\>") | 3514 | (if (looking-at "\\<declare\\>") |
| 3510 | (ada-goto-stmt-start) | 3515 | (ada-goto-stmt-start) |
| 3511 | ;; | 3516 | ;; |
| 3512 | ;; no, => 'procedure'/'function'/'task'/'protected' | 3517 | ;; no, => 'procedure'/'function'/'task'/'protected' |
| 3513 | ;; | 3518 | ;; |
| 3514 | (progn | 3519 | (progn |
| 3515 | (forward-word 2) | 3520 | (forward-word 2) |
| 3516 | (backward-word 1) | 3521 | (backward-word 1) |
| 3517 | ;; | 3522 | ;; |
| 3518 | ;; skip 'body' 'type' | 3523 | ;; skip 'body' 'type' |
| 3519 | ;; | 3524 | ;; |
| 3520 | (if (looking-at "\\<\\(body\\|type\\)\\>") | 3525 | (if (looking-at "\\<\\(body\\|type\\)\\>") |
| 3521 | (forward-word 1)) | 3526 | (forward-word 1)) |
| 3522 | (forward-sexp 1) | 3527 | (forward-sexp 1) |
| 3523 | (backward-sexp 1))) | 3528 | (backward-sexp 1))) |
| 3524 | ;; | 3529 | ;; |
| 3525 | ;; should be looking-at the correct name | 3530 | ;; should be looking-at the correct name |
| 3526 | ;; | 3531 | ;; |
| 3527 | (unless (looking-at (concat "\\<" defun-name "\\>")) | 3532 | (unless (looking-at (concat "\\<" defun-name "\\>")) |
| 3528 | (error "Matching defun has different name: %s" | 3533 | (error "Matching defun has different name: %s" |
| 3529 | (buffer-substring (point) | 3534 | (buffer-substring (point) |
| 3530 | (progn (forward-sexp 1) (point)))))))) | 3535 | (progn (forward-sexp 1) (point)))))))) |
| 3531 | 3536 | ||
| 3532 | (defun ada-goto-matching-decl-start (&optional noerror recursive) | 3537 | (defun ada-goto-matching-decl-start (&optional noerror recursive) |
| 3533 | "Move point to the matching declaration start of the current 'begin'. | 3538 | "Move point to the matching declaration start of the current 'begin'. |
| @@ -3536,10 +3541,10 @@ If NOERROR is non-nil, it only returns nil if no match was found." | |||
| 3536 | 3541 | ||
| 3537 | ;; first should be set to t if we should stop at the first | 3542 | ;; first should be set to t if we should stop at the first |
| 3538 | ;; "begin" we encounter. | 3543 | ;; "begin" we encounter. |
| 3539 | (first (not recursive)) | 3544 | (first (not recursive)) |
| 3540 | (count-generic nil) | 3545 | (count-generic nil) |
| 3541 | (stop-at-when nil) | 3546 | (stop-at-when nil) |
| 3542 | ) | 3547 | ) |
| 3543 | 3548 | ||
| 3544 | ;; Ignore "when" most of the time, except if we are looking at the | 3549 | ;; Ignore "when" most of the time, except if we are looking at the |
| 3545 | ;; beginning of a block (structure: case .. is | 3550 | ;; beginning of a block (structure: case .. is |
| @@ -3547,65 +3552,65 @@ If NOERROR is non-nil, it only returns nil if no match was found." | |||
| 3547 | ;; begin ... | 3552 | ;; begin ... |
| 3548 | ;; exception ... ) | 3553 | ;; exception ... ) |
| 3549 | (if (looking-at "begin") | 3554 | (if (looking-at "begin") |
| 3550 | (setq stop-at-when t)) | 3555 | (setq stop-at-when t)) |
| 3551 | 3556 | ||
| 3552 | (if (or | 3557 | (if (or |
| 3553 | (looking-at "\\<\\(package\\|procedure\\|function\\)\\>") | 3558 | (looking-at "\\<\\(package\\|procedure\\|function\\)\\>") |
| 3554 | (save-excursion | 3559 | (save-excursion |
| 3555 | (ada-search-ignore-string-comment | 3560 | (ada-search-ignore-string-comment |
| 3556 | "\\<\\(package\\|procedure\\|function\\|generic\\)\\>" t) | 3561 | "\\<\\(package\\|procedure\\|function\\|generic\\)\\>" t) |
| 3557 | (looking-at "generic"))) | 3562 | (looking-at "generic"))) |
| 3558 | (setq count-generic t)) | 3563 | (setq count-generic t)) |
| 3559 | 3564 | ||
| 3560 | ;; search backward for interesting keywords | 3565 | ;; search backward for interesting keywords |
| 3561 | (while (and | 3566 | (while (and |
| 3562 | (not (zerop nest-count)) | 3567 | (not (zerop nest-count)) |
| 3563 | (ada-search-ignore-string-comment ada-matching-decl-start-re t)) | 3568 | (ada-search-ignore-string-comment ada-matching-decl-start-re t)) |
| 3564 | ;; | 3569 | ;; |
| 3565 | ;; calculate nest-depth | 3570 | ;; calculate nest-depth |
| 3566 | ;; | 3571 | ;; |
| 3567 | (cond | 3572 | (cond |
| 3568 | ;; | 3573 | ;; |
| 3569 | ((looking-at "end") | 3574 | ((looking-at "end") |
| 3570 | (ada-goto-matching-start 1 noerror) | 3575 | (ada-goto-matching-start 1 noerror) |
| 3571 | 3576 | ||
| 3572 | ;; In some case, two begin..end block can follow each other closely, | 3577 | ;; In some case, two begin..end block can follow each other closely, |
| 3573 | ;; which we have to detect, as in | 3578 | ;; which we have to detect, as in |
| 3574 | ;; procedure P is | 3579 | ;; procedure P is |
| 3575 | ;; procedure Q is | 3580 | ;; procedure Q is |
| 3576 | ;; begin | 3581 | ;; begin |
| 3577 | ;; end; | 3582 | ;; end; |
| 3578 | ;; begin -- here we should go to procedure, not begin | 3583 | ;; begin -- here we should go to procedure, not begin |
| 3579 | ;; end | 3584 | ;; end |
| 3580 | 3585 | ||
| 3581 | (if (looking-at "begin") | 3586 | (if (looking-at "begin") |
| 3582 | (let ((loop-again t)) | 3587 | (let ((loop-again t)) |
| 3583 | (save-excursion | 3588 | (save-excursion |
| 3584 | (while loop-again | 3589 | (while loop-again |
| 3585 | ;; If begin was just there as the beginning of a block | 3590 | ;; If begin was just there as the beginning of a block |
| 3586 | ;; (with no declare) then do nothing, otherwise just | 3591 | ;; (with no declare) then do nothing, otherwise just |
| 3587 | ;; register that we have to find the statement that | 3592 | ;; register that we have to find the statement that |
| 3588 | ;; required the begin | 3593 | ;; required the begin |
| 3589 | 3594 | ||
| 3590 | (ada-search-ignore-string-comment | 3595 | (ada-search-ignore-string-comment |
| 3591 | "\\<\\(declare\\|begin\\|end\\|procedure\\|function\\|task\\|package\\)\\>" | 3596 | "\\<\\(declare\\|begin\\|end\\|procedure\\|function\\|task\\|package\\)\\>" |
| 3592 | t) | 3597 | t) |
| 3593 | 3598 | ||
| 3594 | (if (looking-at "end") | 3599 | (if (looking-at "end") |
| 3595 | (ada-goto-matching-start 1 noerror t) | 3600 | (ada-goto-matching-start 1 noerror t) |
| 3596 | ;; (ada-goto-matching-decl-start noerror t) | 3601 | ;; (ada-goto-matching-decl-start noerror t) |
| 3597 | 3602 | ||
| 3598 | (setq loop-again nil) | 3603 | (setq loop-again nil) |
| 3599 | (unless (looking-at "begin") | 3604 | (unless (looking-at "begin") |
| 3600 | (setq nest-count (1+ nest-count)))) | 3605 | (setq nest-count (1+ nest-count)))) |
| 3601 | )) | 3606 | )) |
| 3602 | ))) | 3607 | ))) |
| 3603 | ;; | 3608 | ;; |
| 3604 | ((looking-at "generic") | 3609 | ((looking-at "generic") |
| 3605 | (if count-generic | 3610 | (if count-generic |
| 3606 | (progn | 3611 | (progn |
| 3607 | (setq first nil) | 3612 | (setq first nil) |
| 3608 | (setq nest-count (1- nest-count))))) | 3613 | (setq nest-count (1- nest-count))))) |
| 3609 | ;; | 3614 | ;; |
| 3610 | ((looking-at "if") | 3615 | ((looking-at "if") |
| 3611 | (save-excursion | 3616 | (save-excursion |
| @@ -3617,49 +3622,49 @@ If NOERROR is non-nil, it only returns nil if no match was found." | |||
| 3617 | 3622 | ||
| 3618 | ;; | 3623 | ;; |
| 3619 | ((looking-at "declare\\|generic") | 3624 | ((looking-at "declare\\|generic") |
| 3620 | (setq nest-count (1- nest-count)) | 3625 | (setq nest-count (1- nest-count)) |
| 3621 | (setq first t)) | 3626 | (setq first t)) |
| 3622 | ;; | 3627 | ;; |
| 3623 | ((looking-at "is") | 3628 | ((looking-at "is") |
| 3624 | ;; check if it is only a type definition, but not a protected | 3629 | ;; check if it is only a type definition, but not a protected |
| 3625 | ;; type definition, which should be handled like a procedure. | 3630 | ;; type definition, which should be handled like a procedure. |
| 3626 | (if (or (looking-at "is[ \t]+<>") | 3631 | (if (or (looking-at "is[ \t]+<>") |
| 3627 | (save-excursion | 3632 | (save-excursion |
| 3628 | (forward-comment -10000) | 3633 | (forward-comment -10000) |
| 3629 | (forward-char -1) | 3634 | (forward-char -1) |
| 3630 | 3635 | ||
| 3631 | ;; Detect if we have a closing parenthesis (Could be | 3636 | ;; Detect if we have a closing parenthesis (Could be |
| 3632 | ;; either the end of subprogram parameters or (<>) | 3637 | ;; either the end of subprogram parameters or (<>) |
| 3633 | ;; in a type definition | 3638 | ;; in a type definition |
| 3634 | (if (= (char-after) ?\)) | 3639 | (if (= (char-after) ?\)) |
| 3635 | (progn | 3640 | (progn |
| 3636 | (forward-char 1) | 3641 | (forward-char 1) |
| 3637 | (backward-sexp 1) | 3642 | (backward-sexp 1) |
| 3638 | (forward-comment -10000) | 3643 | (forward-comment -10000) |
| 3639 | )) | 3644 | )) |
| 3640 | (skip-chars-backward "a-zA-Z0-9_.'") | 3645 | (skip-chars-backward "a-zA-Z0-9_.'") |
| 3641 | (ada-goto-previous-word) | 3646 | (ada-goto-previous-word) |
| 3642 | (and | 3647 | (and |
| 3643 | (looking-at "\\<\\(sub\\)?type\\|case\\>") | 3648 | (looking-at "\\<\\(sub\\)?type\\|case\\>") |
| 3644 | (save-match-data | 3649 | (save-match-data |
| 3645 | (ada-goto-previous-word) | 3650 | (ada-goto-previous-word) |
| 3646 | (not (looking-at "\\<protected\\>")))) | 3651 | (not (looking-at "\\<protected\\>")))) |
| 3647 | )) ; end of `or' | 3652 | )) ; end of `or' |
| 3648 | (goto-char (match-beginning 0)) | 3653 | (goto-char (match-beginning 0)) |
| 3649 | (progn | 3654 | (progn |
| 3650 | (setq nest-count (1- nest-count)) | 3655 | (setq nest-count (1- nest-count)) |
| 3651 | (setq first nil)))) | 3656 | (setq first nil)))) |
| 3652 | 3657 | ||
| 3653 | ;; | 3658 | ;; |
| 3654 | ((looking-at "new") | 3659 | ((looking-at "new") |
| 3655 | (if (save-excursion | 3660 | (if (save-excursion |
| 3656 | (ada-goto-previous-word) | 3661 | (ada-goto-previous-word) |
| 3657 | (looking-at "is")) | 3662 | (looking-at "is")) |
| 3658 | (goto-char (match-beginning 0)))) | 3663 | (goto-char (match-beginning 0)))) |
| 3659 | ;; | 3664 | ;; |
| 3660 | ((and first | 3665 | ((and first |
| 3661 | (looking-at "begin")) | 3666 | (looking-at "begin")) |
| 3662 | (setq nest-count 0)) | 3667 | (setq nest-count 0)) |
| 3663 | ;; | 3668 | ;; |
| 3664 | ((looking-at "when") | 3669 | ((looking-at "when") |
| 3665 | (save-excursion | 3670 | (save-excursion |
| @@ -3674,20 +3679,20 @@ If NOERROR is non-nil, it only returns nil if no match was found." | |||
| 3674 | (setq first nil)) | 3679 | (setq first nil)) |
| 3675 | ;; | 3680 | ;; |
| 3676 | (t | 3681 | (t |
| 3677 | (setq nest-count (1+ nest-count)) | 3682 | (setq nest-count (1+ nest-count)) |
| 3678 | (setq first nil))) | 3683 | (setq first nil))) |
| 3679 | 3684 | ||
| 3680 | );; end of loop | 3685 | );; end of loop |
| 3681 | 3686 | ||
| 3682 | ;; check if declaration-start is really found | 3687 | ;; check if declaration-start is really found |
| 3683 | (if (and | 3688 | (if (and |
| 3684 | (zerop nest-count) | 3689 | (zerop nest-count) |
| 3685 | (if (looking-at "is") | 3690 | (if (looking-at "is") |
| 3686 | (ada-search-ignore-string-comment ada-subprog-start-re t) | 3691 | (ada-search-ignore-string-comment ada-subprog-start-re t) |
| 3687 | (looking-at "declare\\|generic"))) | 3692 | (looking-at "declare\\|generic"))) |
| 3688 | t | 3693 | t |
| 3689 | (if noerror nil | 3694 | (if noerror nil |
| 3690 | (error "No matching proc/func/task/declare/package/protected"))) | 3695 | (error "No matching proc/func/task/declare/package/protected"))) |
| 3691 | )) | 3696 | )) |
| 3692 | 3697 | ||
| 3693 | (defun ada-goto-matching-start (&optional nest-level noerror gotothen) | 3698 | (defun ada-goto-matching-start (&optional nest-level noerror gotothen) |
| @@ -3696,110 +3701,103 @@ Which block depends on the value of NEST-LEVEL, which defaults to zero. | |||
| 3696 | If NOERROR is non-nil, it only returns nil if no matching start was found. | 3701 | If NOERROR is non-nil, it only returns nil if no matching start was found. |
| 3697 | If GOTOTHEN is non-nil, point moves to the 'then' following 'if'." | 3702 | If GOTOTHEN is non-nil, point moves to the 'then' following 'if'." |
| 3698 | (let ((nest-count (if nest-level nest-level 0)) | 3703 | (let ((nest-count (if nest-level nest-level 0)) |
| 3699 | (found nil) | 3704 | (found nil) |
| 3700 | (pos nil)) | 3705 | (pos nil)) |
| 3701 | 3706 | ||
| 3702 | ;; | ||
| 3703 | ;; search backward for interesting keywords | 3707 | ;; search backward for interesting keywords |
| 3704 | ;; | ||
| 3705 | (while (and | 3708 | (while (and |
| 3706 | (not found) | 3709 | (not found) |
| 3707 | (ada-search-ignore-string-comment ada-matching-start-re t)) | 3710 | (ada-search-ignore-string-comment ada-matching-start-re t)) |
| 3708 | 3711 | ||
| 3709 | (unless (and (looking-at "\\<record\\>") | 3712 | (unless (and (looking-at "\\<record\\>") |
| 3710 | (save-excursion | 3713 | (save-excursion |
| 3711 | (forward-word -1) | 3714 | (forward-word -1) |
| 3712 | (looking-at "\\<null\\>"))) | 3715 | (looking-at "\\<null\\>"))) |
| 3713 | (progn | 3716 | (progn |
| 3714 | ;; | 3717 | ;; calculate nest-depth |
| 3715 | ;; calculate nest-depth | 3718 | (cond |
| 3716 | ;; | 3719 | ;; found block end => increase nest depth |
| 3717 | (cond | 3720 | ((looking-at "end") |
| 3718 | ;; found block end => increase nest depth | 3721 | (setq nest-count (1+ nest-count))) |
| 3719 | ((looking-at "end") | 3722 | |
| 3720 | (setq nest-count (1+ nest-count))) | 3723 | ;; found loop/select/record/case/if => check if it starts or |
| 3721 | 3724 | ;; ends a block | |
| 3722 | ;; found loop/select/record/case/if => check if it starts or | 3725 | ((looking-at "loop\\|select\\|record\\|case\\|if") |
| 3723 | ;; ends a block | 3726 | (setq pos (point)) |
| 3724 | ((looking-at "loop\\|select\\|record\\|case\\|if") | 3727 | (save-excursion |
| 3725 | (setq pos (point)) | 3728 | ;; check if keyword follows 'end' |
| 3726 | (save-excursion | 3729 | (ada-goto-previous-word) |
| 3727 | ;; | 3730 | (if (looking-at "\\<end\\>[ \t]*[^;]") |
| 3728 | ;; check if keyword follows 'end' | 3731 | ;; it ends a block => increase nest depth |
| 3729 | ;; | ||
| 3730 | (ada-goto-previous-word) | ||
| 3731 | (if (looking-at "\\<end\\>[ \t]*[^;]") | ||
| 3732 | ;; it ends a block => increase nest depth | ||
| 3733 | (setq nest-count (1+ nest-count) | 3732 | (setq nest-count (1+ nest-count) |
| 3734 | pos (point)) | 3733 | pos (point)) |
| 3735 | 3734 | ||
| 3736 | ;; it starts a block => decrease nest depth | 3735 | ;; it starts a block => decrease nest depth |
| 3737 | (setq nest-count (1- nest-count)))) | 3736 | (setq nest-count (1- nest-count)))) |
| 3738 | (goto-char pos)) | 3737 | (goto-char pos)) |
| 3739 | 3738 | ||
| 3740 | ;; found package start => check if it really is a block | 3739 | ;; found package start => check if it really is a block |
| 3741 | ((looking-at "package") | 3740 | ((looking-at "package") |
| 3742 | (save-excursion | 3741 | (save-excursion |
| 3743 | ;; ignore if this is just a renames statement | 3742 | ;; ignore if this is just a renames statement |
| 3744 | (let ((current (point)) | 3743 | (let ((current (point)) |
| 3745 | (pos (ada-search-ignore-string-comment | 3744 | (pos (ada-search-ignore-string-comment |
| 3746 | "\\<\\(is\\|renames\\|;\\)\\>" nil))) | 3745 | "\\<\\(is\\|renames\\|;\\)\\>" nil))) |
| 3747 | (if pos | 3746 | (if pos |
| 3748 | (goto-char (car pos)) | 3747 | (goto-char (car pos)) |
| 3749 | (error (concat | 3748 | (error (concat |
| 3750 | "No matching 'is' or 'renames' for 'package' at" | 3749 | "No matching 'is' or 'renames' for 'package' at" |
| 3751 | " line " | 3750 | " line " |
| 3752 | (number-to-string (count-lines 1 (1+ current))))))) | 3751 | (number-to-string (count-lines 1 (1+ current))))))) |
| 3753 | (unless (looking-at "renames") | 3752 | (unless (looking-at "renames") |
| 3754 | (progn | 3753 | (progn |
| 3755 | (forward-word 1) | 3754 | (forward-word 1) |
| 3756 | (ada-goto-next-non-ws) | 3755 | (ada-goto-next-non-ws) |
| 3757 | ;; ignore it if it is only a declaration with 'new' | 3756 | ;; ignore it if it is only a declaration with 'new' |
| 3758 | ;; We could have package Foo is new .... | 3757 | ;; We could have package Foo is new .... |
| 3759 | ;; or package Foo is separate; | 3758 | ;; or package Foo is separate; |
| 3760 | ;; or package Foo is begin null; end Foo | 3759 | ;; or package Foo is begin null; end Foo |
| 3761 | ;; for elaboration code (elaboration) | 3760 | ;; for elaboration code (elaboration) |
| 3762 | (if (not (looking-at "\\<\\(new\\|separate\\|begin\\)\\>")) | 3761 | (if (not (looking-at "\\<\\(new\\|separate\\|begin\\)\\>")) |
| 3763 | (setq nest-count (1- nest-count))))))) | 3762 | (setq nest-count (1- nest-count))))))) |
| 3764 | ;; found task start => check if it has a body | 3763 | ;; found task start => check if it has a body |
| 3765 | ((looking-at "task") | 3764 | ((looking-at "task") |
| 3766 | (save-excursion | 3765 | (save-excursion |
| 3767 | (forward-word 1) | 3766 | (forward-word 1) |
| 3768 | (ada-goto-next-non-ws) | 3767 | (ada-goto-next-non-ws) |
| 3769 | (cond | 3768 | (cond |
| 3770 | ((looking-at "\\<body\\>")) | 3769 | ((looking-at "\\<body\\>")) |
| 3771 | ((looking-at "\\<type\\>") | 3770 | ((looking-at "\\<type\\>") |
| 3772 | ;; In that case, do nothing if there is a "is" | 3771 | ;; In that case, do nothing if there is a "is" |
| 3773 | (forward-word 2);; skip "type" | 3772 | (forward-word 2);; skip "type" |
| 3774 | (ada-goto-next-non-ws);; skip type name | 3773 | (ada-goto-next-non-ws);; skip type name |
| 3775 | 3774 | ||
| 3776 | ;; Do nothing if we are simply looking at a simple | 3775 | ;; Do nothing if we are simply looking at a simple |
| 3777 | ;; "task type name;" statement with no block | 3776 | ;; "task type name;" statement with no block |
| 3778 | (unless (looking-at ";") | 3777 | (unless (looking-at ";") |
| 3779 | (progn | 3778 | (progn |
| 3780 | ;; Skip the parameters | 3779 | ;; Skip the parameters |
| 3781 | (if (looking-at "(") | 3780 | (if (looking-at "(") |
| 3782 | (ada-search-ignore-string-comment ")" nil)) | 3781 | (ada-search-ignore-string-comment ")" nil)) |
| 3783 | (let ((tmp (ada-search-ignore-string-comment | 3782 | (let ((tmp (ada-search-ignore-string-comment |
| 3784 | "\\<\\(is\\|;\\)\\>" nil))) | 3783 | "\\<\\(is\\|;\\)\\>" nil))) |
| 3785 | (if tmp | 3784 | (if tmp |
| 3786 | (progn | 3785 | (progn |
| 3787 | (goto-char (car tmp)) | 3786 | (goto-char (car tmp)) |
| 3788 | (if (looking-at "is") | 3787 | (if (looking-at "is") |
| 3789 | (setq nest-count (1- nest-count))))))))) | 3788 | (setq nest-count (1- nest-count))))))))) |
| 3790 | (t | 3789 | (t |
| 3791 | ;; Check if that task declaration had a block attached to | 3790 | ;; Check if that task declaration had a block attached to |
| 3792 | ;; it (i.e do nothing if we have just "task name;") | 3791 | ;; it (i.e do nothing if we have just "task name;") |
| 3793 | (unless (progn (forward-word 1) | 3792 | (unless (progn (forward-word 1) |
| 3794 | (looking-at "[ \t]*;")) | 3793 | (looking-at "[ \t]*;")) |
| 3795 | (setq nest-count (1- nest-count))))))) | 3794 | (setq nest-count (1- nest-count))))))) |
| 3796 | ;; all the other block starts | 3795 | ;; all the other block starts |
| 3797 | (t | 3796 | (t |
| 3798 | (setq nest-count (1- nest-count)))) ; end of 'cond' | 3797 | (setq nest-count (1- nest-count)))) ; end of 'cond' |
| 3799 | 3798 | ||
| 3800 | ;; match is found, if nest-depth is zero | 3799 | ;; match is found, if nest-depth is zero |
| 3801 | ;; | 3800 | (setq found (zerop nest-count))))) ; end of loop |
| 3802 | (setq found (zerop nest-count))))) ; end of loop | ||
| 3803 | 3801 | ||
| 3804 | (if (bobp) | 3802 | (if (bobp) |
| 3805 | (point) | 3803 | (point) |
| @@ -3850,7 +3848,7 @@ If NOERROR is non-nil, it only returns nil if no matching start found." | |||
| 3850 | "procedure" "function") t) | 3848 | "procedure" "function") t) |
| 3851 | "\\>"))) | 3849 | "\\>"))) |
| 3852 | found | 3850 | found |
| 3853 | pos | 3851 | pos |
| 3854 | 3852 | ||
| 3855 | ;; First is used for subprograms: they are generally handled | 3853 | ;; First is used for subprograms: they are generally handled |
| 3856 | ;; recursively, but of course we do not want to do that the | 3854 | ;; recursively, but of course we do not want to do that the |
| @@ -3868,8 +3866,8 @@ If NOERROR is non-nil, it only returns nil if no matching start found." | |||
| 3868 | ;; search forward for interesting keywords | 3866 | ;; search forward for interesting keywords |
| 3869 | ;; | 3867 | ;; |
| 3870 | (while (and | 3868 | (while (and |
| 3871 | (not found) | 3869 | (not found) |
| 3872 | (ada-search-ignore-string-comment regex nil)) | 3870 | (ada-search-ignore-string-comment regex nil)) |
| 3873 | 3871 | ||
| 3874 | ;; | 3872 | ;; |
| 3875 | ;; calculate nest-depth | 3873 | ;; calculate nest-depth |
| @@ -3907,9 +3905,9 @@ If NOERROR is non-nil, it only returns nil if no matching start found." | |||
| 3907 | 3905 | ||
| 3908 | ;; found block end => decrease nest depth | 3906 | ;; found block end => decrease nest depth |
| 3909 | ((looking-at "\\<end\\>") | 3907 | ((looking-at "\\<end\\>") |
| 3910 | (setq nest-count (1- nest-count) | 3908 | (setq nest-count (1- nest-count) |
| 3911 | found (<= nest-count 0)) | 3909 | found (<= nest-count 0)) |
| 3912 | ;; skip the following keyword | 3910 | ;; skip the following keyword |
| 3913 | (if (progn | 3911 | (if (progn |
| 3914 | (skip-chars-forward "end") | 3912 | (skip-chars-forward "end") |
| 3915 | (ada-goto-next-non-ws) | 3913 | (ada-goto-next-non-ws) |
| @@ -3919,13 +3917,13 @@ If NOERROR is non-nil, it only returns nil if no matching start found." | |||
| 3919 | ;; found package start => check if it really starts a block, and is not | 3917 | ;; found package start => check if it really starts a block, and is not |
| 3920 | ;; in fact a generic instantiation for instance | 3918 | ;; in fact a generic instantiation for instance |
| 3921 | ((looking-at "\\<package\\>") | 3919 | ((looking-at "\\<package\\>") |
| 3922 | (ada-search-ignore-string-comment "is" nil nil nil | 3920 | (ada-search-ignore-string-comment "is" nil nil nil |
| 3923 | 'word-search-forward) | 3921 | 'word-search-forward) |
| 3924 | (ada-goto-next-non-ws) | 3922 | (ada-goto-next-non-ws) |
| 3925 | ;; ignore and skip it if it is only a 'new' package | 3923 | ;; ignore and skip it if it is only a 'new' package |
| 3926 | (if (looking-at "\\<new\\>") | 3924 | (if (looking-at "\\<new\\>") |
| 3927 | (goto-char (match-end 0)) | 3925 | (goto-char (match-end 0)) |
| 3928 | (setq nest-count (1+ nest-count) | 3926 | (setq nest-count (1+ nest-count) |
| 3929 | found (<= nest-count 0)))) | 3927 | found (<= nest-count 0)))) |
| 3930 | 3928 | ||
| 3931 | ;; all the other block starts | 3929 | ;; all the other block starts |
| @@ -3933,34 +3931,35 @@ If NOERROR is non-nil, it only returns nil if no matching start found." | |||
| 3933 | (if (not first) | 3931 | (if (not first) |
| 3934 | (setq nest-count (1+ nest-count))) | 3932 | (setq nest-count (1+ nest-count))) |
| 3935 | (setq found (<= nest-count 0)) | 3933 | (setq found (<= nest-count 0)) |
| 3936 | (forward-word 1))) ; end of 'cond' | 3934 | (forward-word 1))) ; end of 'cond' |
| 3937 | 3935 | ||
| 3938 | (setq first nil)) | 3936 | (setq first nil)) |
| 3939 | 3937 | ||
| 3940 | (if found | 3938 | (if found |
| 3941 | t | 3939 | t |
| 3942 | (if noerror | 3940 | (if noerror |
| 3943 | nil | 3941 | nil |
| 3944 | (error "No matching end"))) | 3942 | (error "No matching end"))) |
| 3945 | )) | 3943 | )) |
| 3946 | 3944 | ||
| 3947 | 3945 | ||
| 3948 | (defun ada-search-ignore-string-comment | 3946 | (defun ada-search-ignore-string-comment |
| 3949 | (search-re &optional backward limit paramlists search-func) | 3947 | (search-re &optional backward limit paramlists search-func) |
| 3950 | "Regexp-search for SEARCH-RE, ignoring comments, strings. | 3948 | "Regexp-search for SEARCH-RE, ignoring comments, strings. |
| 3951 | If PARAMLISTS is nil, ignore parameter lists. Returns a cons cell of | 3949 | Returns a cons cell of begin and end of match data or nil, if not found. |
| 3952 | begin and end of match data or nil, if not found. | 3950 | If BACKWARD is non-nil, search backward; search forward otherwise. |
| 3953 | The search is done using SEARCH-FUNC, which should search backward if | ||
| 3954 | BACKWARD is non-nil, forward otherwise. SEARCH-FUNC can be optimized | ||
| 3955 | in case we are searching for a constant string. | ||
| 3956 | The search stops at pos LIMIT. | 3951 | The search stops at pos LIMIT. |
| 3952 | If PARAMLISTS is nil, ignore parameter lists. | ||
| 3953 | The search is done using SEARCH-FUNC. SEARCH-FUNC can be optimized | ||
| 3954 | in case we are searching for a constant string. | ||
| 3957 | Point is moved at the beginning of the SEARCH-RE." | 3955 | Point is moved at the beginning of the SEARCH-RE." |
| 3958 | (let (found | 3956 | (let (found |
| 3959 | begin | 3957 | begin |
| 3960 | end | 3958 | end |
| 3961 | parse-result | 3959 | parse-result |
| 3962 | (previous-syntax-table (syntax-table))) | 3960 | (previous-syntax-table (syntax-table))) |
| 3963 | 3961 | ||
| 3962 | ;; FIXME: need to pass BACKWARD to search-func! | ||
| 3964 | (unless search-func | 3963 | (unless search-func |
| 3965 | (setq search-func (if backward 're-search-backward 're-search-forward))) | 3964 | (setq search-func (if backward 're-search-backward 're-search-forward))) |
| 3966 | 3965 | ||
| @@ -3970,68 +3969,68 @@ Point is moved at the beginning of the SEARCH-RE." | |||
| 3970 | ;; | 3969 | ;; |
| 3971 | (set-syntax-table ada-mode-symbol-syntax-table) | 3970 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 3972 | (while (and (not found) | 3971 | (while (and (not found) |
| 3973 | (or (not limit) | 3972 | (or (not limit) |
| 3974 | (or (and backward (<= limit (point))) | 3973 | (or (and backward (<= limit (point))) |
| 3975 | (>= limit (point)))) | 3974 | (>= limit (point)))) |
| 3976 | (funcall search-func search-re limit 1)) | 3975 | (funcall search-func search-re limit 1)) |
| 3977 | (setq begin (match-beginning 0)) | 3976 | (setq begin (match-beginning 0)) |
| 3978 | (setq end (match-end 0)) | 3977 | (setq end (match-end 0)) |
| 3979 | 3978 | ||
| 3980 | (setq parse-result (parse-partial-sexp | 3979 | (setq parse-result (parse-partial-sexp |
| 3981 | (save-excursion (beginning-of-line) (point)) | 3980 | (save-excursion (beginning-of-line) (point)) |
| 3982 | (point))) | 3981 | (point))) |
| 3983 | 3982 | ||
| 3984 | (cond | 3983 | (cond |
| 3985 | ;; | 3984 | ;; |
| 3986 | ;; If inside a string, skip it (and the following comments) | 3985 | ;; If inside a string, skip it (and the following comments) |
| 3987 | ;; | 3986 | ;; |
| 3988 | ((ada-in-string-p parse-result) | 3987 | ((ada-in-string-p parse-result) |
| 3989 | (if (featurep 'xemacs) | 3988 | (if (featurep 'xemacs) |
| 3990 | (search-backward "\"" nil t) | 3989 | (search-backward "\"" nil t) |
| 3991 | (goto-char (nth 8 parse-result))) | 3990 | (goto-char (nth 8 parse-result))) |
| 3992 | (unless backward (forward-sexp 1))) | 3991 | (unless backward (forward-sexp 1))) |
| 3993 | ;; | 3992 | ;; |
| 3994 | ;; If inside a comment, skip it (and the following comments) | 3993 | ;; If inside a comment, skip it (and the following comments) |
| 3995 | ;; There is a special code for comments at the end of the file | 3994 | ;; There is a special code for comments at the end of the file |
| 3996 | ;; | 3995 | ;; |
| 3997 | ((ada-in-comment-p parse-result) | 3996 | ((ada-in-comment-p parse-result) |
| 3998 | (if (featurep 'xemacs) | 3997 | (if (featurep 'xemacs) |
| 3999 | (progn | 3998 | (progn |
| 4000 | (forward-line 1) | 3999 | (forward-line 1) |
| 4001 | (beginning-of-line) | 4000 | (beginning-of-line) |
| 4002 | (forward-comment -1)) | 4001 | (forward-comment -1)) |
| 4003 | (goto-char (nth 8 parse-result))) | 4002 | (goto-char (nth 8 parse-result))) |
| 4004 | (unless backward | 4003 | (unless backward |
| 4005 | ;; at the end of the file, it is not possible to skip a comment | 4004 | ;; at the end of the file, it is not possible to skip a comment |
| 4006 | ;; so we just go at the end of the line | 4005 | ;; so we just go at the end of the line |
| 4007 | (if (forward-comment 1) | 4006 | (if (forward-comment 1) |
| 4008 | (progn | 4007 | (progn |
| 4009 | (forward-comment 1000) | 4008 | (forward-comment 1000) |
| 4010 | (beginning-of-line)) | 4009 | (beginning-of-line)) |
| 4011 | (end-of-line)))) | 4010 | (end-of-line)))) |
| 4012 | ;; | 4011 | ;; |
| 4013 | ;; directly in front of a comment => skip it, if searching forward | 4012 | ;; directly in front of a comment => skip it, if searching forward |
| 4014 | ;; | 4013 | ;; |
| 4015 | ((and (= (char-after begin) ?-) (= (char-after (1+ begin)) ?-)) | 4014 | ((and (= (char-after begin) ?-) (= (char-after (1+ begin)) ?-)) |
| 4016 | (unless backward (progn (forward-char -1) (forward-comment 1000)))) | 4015 | (unless backward (progn (forward-char -1) (forward-comment 1000)))) |
| 4017 | 4016 | ||
| 4018 | ;; | 4017 | ;; |
| 4019 | ;; found a parameter-list but should ignore it => skip it | 4018 | ;; found a parameter-list but should ignore it => skip it |
| 4020 | ;; | 4019 | ;; |
| 4021 | ((and (not paramlists) (ada-in-paramlist-p)) | 4020 | ((and (not paramlists) (ada-in-paramlist-p)) |
| 4022 | (if backward | 4021 | (if backward |
| 4023 | (search-backward "(" nil t) | 4022 | (search-backward "(" nil t) |
| 4024 | (search-forward ")" nil t))) | 4023 | (search-forward ")" nil t))) |
| 4025 | ;; | 4024 | ;; |
| 4026 | ;; found what we were looking for | 4025 | ;; found what we were looking for |
| 4027 | ;; | 4026 | ;; |
| 4028 | (t | 4027 | (t |
| 4029 | (setq found t)))) ; end of loop | 4028 | (setq found t)))) ; end of loop |
| 4030 | 4029 | ||
| 4031 | (set-syntax-table previous-syntax-table) | 4030 | (set-syntax-table previous-syntax-table) |
| 4032 | 4031 | ||
| 4033 | (if found | 4032 | (if found |
| 4034 | (cons begin end) | 4033 | (cons begin end) |
| 4035 | nil))) | 4034 | nil))) |
| 4036 | 4035 | ||
| 4037 | ;; ------------------------------------------------------- | 4036 | ;; ------------------------------------------------------- |
| @@ -4043,17 +4042,17 @@ Point is moved at the beginning of the SEARCH-RE." | |||
| 4043 | Assumes point to be at the end of a statement." | 4042 | Assumes point to be at the end of a statement." |
| 4044 | (or (ada-in-paramlist-p) | 4043 | (or (ada-in-paramlist-p) |
| 4045 | (save-excursion | 4044 | (save-excursion |
| 4046 | (ada-goto-matching-decl-start t)))) | 4045 | (ada-goto-matching-decl-start t)))) |
| 4047 | 4046 | ||
| 4048 | 4047 | ||
| 4049 | (defun ada-looking-at-semi-or () | 4048 | (defun ada-looking-at-semi-or () |
| 4050 | "Return t if looking at an 'or' following a semicolon." | 4049 | "Return t if looking at an 'or' following a semicolon." |
| 4051 | (save-excursion | 4050 | (save-excursion |
| 4052 | (and (looking-at "\\<or\\>") | 4051 | (and (looking-at "\\<or\\>") |
| 4053 | (progn | 4052 | (progn |
| 4054 | (forward-word 1) | 4053 | (forward-word 1) |
| 4055 | (ada-goto-stmt-start) | 4054 | (ada-goto-stmt-start) |
| 4056 | (looking-at "\\<or\\>"))))) | 4055 | (looking-at "\\<or\\>"))))) |
| 4057 | 4056 | ||
| 4058 | 4057 | ||
| 4059 | (defun ada-looking-at-semi-private () | 4058 | (defun ada-looking-at-semi-private () |
| @@ -4062,7 +4061,7 @@ Return nil if the private is part of the package name, as in | |||
| 4062 | 'private package A is...' (this can only happen at top level)." | 4061 | 'private package A is...' (this can only happen at top level)." |
| 4063 | (save-excursion | 4062 | (save-excursion |
| 4064 | (and (looking-at "\\<private\\>") | 4063 | (and (looking-at "\\<private\\>") |
| 4065 | (not (looking-at "\\<private[ \t]*\\(package\\|generic\\)")) | 4064 | (not (looking-at "\\<private[ \t]*\\(package\\|generic\\)")) |
| 4066 | 4065 | ||
| 4067 | ;; Make sure this is the start of a private section (ie after | 4066 | ;; Make sure this is the start of a private section (ie after |
| 4068 | ;; a semicolon or just after the package declaration, but not | 4067 | ;; a semicolon or just after the package declaration, but not |
| @@ -4093,8 +4092,8 @@ Return nil if the private is part of the package name, as in | |||
| 4093 | (progn | 4092 | (progn |
| 4094 | (skip-chars-backward " \t\n") | 4093 | (skip-chars-backward " \t\n") |
| 4095 | (if (= (char-before) ?\") | 4094 | (if (= (char-before) ?\") |
| 4096 | (backward-char 3) | 4095 | (backward-char 3) |
| 4097 | (backward-word 1)) | 4096 | (backward-word 1)) |
| 4098 | t) | 4097 | t) |
| 4099 | 4098 | ||
| 4100 | ;; and now over the second one | 4099 | ;; and now over the second one |
| @@ -4111,17 +4110,17 @@ Return nil if the private is part of the package name, as in | |||
| 4111 | ;; right keyword two words before parenthesis ? | 4110 | ;; right keyword two words before parenthesis ? |
| 4112 | ;; Type is in this list because of discriminants | 4111 | ;; Type is in this list because of discriminants |
| 4113 | (looking-at (eval-when-compile | 4112 | (looking-at (eval-when-compile |
| 4114 | (concat "\\<\\(" | 4113 | (concat "\\<\\(" |
| 4115 | "procedure\\|function\\|body\\|" | 4114 | "procedure\\|function\\|body\\|" |
| 4116 | "task\\|entry\\|accept\\|" | 4115 | "task\\|entry\\|accept\\|" |
| 4117 | "access[ \t]+procedure\\|" | 4116 | "access[ \t]+procedure\\|" |
| 4118 | "access[ \t]+function\\|" | 4117 | "access[ \t]+function\\|" |
| 4119 | "pragma\\|" | 4118 | "pragma\\|" |
| 4120 | "type\\)\\>")))))) | 4119 | "type\\)\\>")))))) |
| 4121 | 4120 | ||
| 4122 | (defun ada-search-ignore-complex-boolean (regexp backwardp) | 4121 | (defun ada-search-ignore-complex-boolean (regexp backwardp) |
| 4123 | "Like `ada-search-ignore-string-comment', except that it also ignores | 4122 | "Search for REGEXP, ignoring comments, strings, 'and then', 'or else'. |
| 4124 | boolean expressions 'and then' and 'or else'." | 4123 | If BACKWARDP is non-nil, search backward; search forward otherwise." |
| 4125 | (let (result) | 4124 | (let (result) |
| 4126 | (while (and (setq result (ada-search-ignore-string-comment regexp backwardp)) | 4125 | (while (and (setq result (ada-search-ignore-string-comment regexp backwardp)) |
| 4127 | (save-excursion (forward-word -1) | 4126 | (save-excursion (forward-word -1) |
| @@ -4129,19 +4128,20 @@ boolean expressions 'and then' and 'or else'." | |||
| 4129 | result)) | 4128 | result)) |
| 4130 | 4129 | ||
| 4131 | (defun ada-in-open-paren-p () | 4130 | (defun ada-in-open-paren-p () |
| 4132 | "Return the position of the first non-ws behind the last unclosed | 4131 | "Non-nil if in an open parenthesis. |
| 4132 | Return value is the position of the first non-ws behind the last unclosed | ||
| 4133 | parenthesis, or nil." | 4133 | parenthesis, or nil." |
| 4134 | (save-excursion | 4134 | (save-excursion |
| 4135 | (let ((parse (parse-partial-sexp | 4135 | (let ((parse (parse-partial-sexp |
| 4136 | (point) | 4136 | (point) |
| 4137 | (or (car (ada-search-ignore-complex-boolean | 4137 | (or (car (ada-search-ignore-complex-boolean |
| 4138 | "\\<\\(;\\|is\\|then\\|loop\\|begin\\|else\\)\\>" | 4138 | "\\<\\(;\\|is\\|then\\|loop\\|begin\\|else\\)\\>" |
| 4139 | t)) | 4139 | t)) |
| 4140 | (point-min))))) | 4140 | (point-min))))) |
| 4141 | 4141 | ||
| 4142 | (if (nth 1 parse) | 4142 | (if (nth 1 parse) |
| 4143 | (progn | 4143 | (progn |
| 4144 | (goto-char (1+ (nth 1 parse))) | 4144 | (goto-char (1+ (nth 1 parse))) |
| 4145 | 4145 | ||
| 4146 | ;; Skip blanks, if they are not followed by a comment | 4146 | ;; Skip blanks, if they are not followed by a comment |
| 4147 | ;; See: | 4147 | ;; See: |
| @@ -4152,9 +4152,9 @@ parenthesis, or nil." | |||
| 4152 | 4152 | ||
| 4153 | (if (or (not ada-indent-handle-comment-special) | 4153 | (if (or (not ada-indent-handle-comment-special) |
| 4154 | (not (looking-at "[ \t]+--"))) | 4154 | (not (looking-at "[ \t]+--"))) |
| 4155 | (skip-chars-forward " \t")) | 4155 | (skip-chars-forward " \t")) |
| 4156 | 4156 | ||
| 4157 | (point)))))) | 4157 | (point)))))) |
| 4158 | 4158 | ||
| 4159 | 4159 | ||
| 4160 | ;; ----------------------------------------------------------- | 4160 | ;; ----------------------------------------------------------- |
| @@ -4167,20 +4167,21 @@ In Transient Mark mode, if the mark is active, operate on the contents | |||
| 4167 | of the region. Otherwise, operate only on the current line." | 4167 | of the region. Otherwise, operate only on the current line." |
| 4168 | (interactive) | 4168 | (interactive) |
| 4169 | (cond ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard)) | 4169 | (cond ((eq ada-tab-policy 'indent-rigidly) (ada-tab-hard)) |
| 4170 | ((eq ada-tab-policy 'indent-auto) | 4170 | ((eq ada-tab-policy 'indent-auto) |
| 4171 | (if (ada-region-selected) | 4171 | (if (ada-region-selected) |
| 4172 | (ada-indent-region (region-beginning) (region-end)) | 4172 | (ada-indent-region (region-beginning) (region-end)) |
| 4173 | (ada-indent-current))) | 4173 | (ada-indent-current))) |
| 4174 | ((eq ada-tab-policy 'always-tab) (error "Not implemented")) | 4174 | ((eq ada-tab-policy 'always-tab) (error "Not implemented")) |
| 4175 | )) | 4175 | )) |
| 4176 | 4176 | ||
| 4177 | (defun ada-untab (arg) | 4177 | (defun ada-untab (arg) |
| 4178 | "Delete leading indenting according to `ada-tab-policy'." | 4178 | "Delete leading indenting according to `ada-tab-policy'." |
| 4179 | ;; FIXME: ARG is ignored | ||
| 4179 | (interactive "P") | 4180 | (interactive "P") |
| 4180 | (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard)) | 4181 | (cond ((eq ada-tab-policy 'indent-rigidly) (ada-untab-hard)) |
| 4181 | ((eq ada-tab-policy 'indent-auto) (error "Not implemented")) | 4182 | ((eq ada-tab-policy 'indent-auto) (error "Not implemented")) |
| 4182 | ((eq ada-tab-policy 'always-tab) (error "Not implemented")) | 4183 | ((eq ada-tab-policy 'always-tab) (error "Not implemented")) |
| 4183 | )) | 4184 | )) |
| 4184 | 4185 | ||
| 4185 | (defun ada-indent-current-function () | 4186 | (defun ada-indent-current-function () |
| 4186 | "Ada mode version of the `indent-line-function'." | 4187 | "Ada mode version of the `indent-line-function'." |
| @@ -4189,7 +4190,7 @@ of the region. Otherwise, operate only on the current line." | |||
| 4189 | (beginning-of-line) | 4190 | (beginning-of-line) |
| 4190 | (ada-tab) | 4191 | (ada-tab) |
| 4191 | (if (< (point) starting-point) | 4192 | (if (< (point) starting-point) |
| 4192 | (goto-char starting-point)) | 4193 | (goto-char starting-point)) |
| 4193 | (set-marker starting-point nil) | 4194 | (set-marker starting-point nil) |
| 4194 | )) | 4195 | )) |
| 4195 | 4196 | ||
| @@ -4206,7 +4207,7 @@ of the region. Otherwise, operate only on the current line." | |||
| 4206 | "Indent current line to previous tab stop." | 4207 | "Indent current line to previous tab stop." |
| 4207 | (interactive) | 4208 | (interactive) |
| 4208 | (let ((bol (save-excursion (progn (beginning-of-line) (point)))) | 4209 | (let ((bol (save-excursion (progn (beginning-of-line) (point)))) |
| 4209 | (eol (save-excursion (progn (end-of-line) (point))))) | 4210 | (eol (save-excursion (progn (end-of-line) (point))))) |
| 4210 | (indent-rigidly bol eol (- 0 ada-indent)))) | 4211 | (indent-rigidly bol eol (- 0 ada-indent)))) |
| 4211 | 4212 | ||
| 4212 | 4213 | ||
| @@ -4223,10 +4224,10 @@ of the region. Otherwise, operate only on the current line." | |||
| 4223 | (save-match-data | 4224 | (save-match-data |
| 4224 | (save-excursion | 4225 | (save-excursion |
| 4225 | (save-restriction | 4226 | (save-restriction |
| 4226 | (widen) | 4227 | (widen) |
| 4227 | (goto-char (point-min)) | 4228 | (goto-char (point-min)) |
| 4228 | (while (re-search-forward "[ \t]+$" (point-max) t) | 4229 | (while (re-search-forward "[ \t]+$" (point-max) t) |
| 4229 | (replace-match "" nil nil)))))) | 4230 | (replace-match "" nil nil)))))) |
| 4230 | 4231 | ||
| 4231 | (defun ada-gnat-style () | 4232 | (defun ada-gnat-style () |
| 4232 | "Clean up comments, `(' and `,' for GNAT style checking switch." | 4233 | "Clean up comments, `(' and `,' for GNAT style checking switch." |
| @@ -4308,40 +4309,40 @@ of the region. Otherwise, operate only on the current line." | |||
| 4308 | "Move point to the matching start of the current Ada structure." | 4309 | "Move point to the matching start of the current Ada structure." |
| 4309 | (interactive) | 4310 | (interactive) |
| 4310 | (let ((pos (point)) | 4311 | (let ((pos (point)) |
| 4311 | (previous-syntax-table (syntax-table))) | 4312 | (previous-syntax-table (syntax-table))) |
| 4312 | (unwind-protect | 4313 | (unwind-protect |
| 4313 | (progn | 4314 | (progn |
| 4314 | (set-syntax-table ada-mode-symbol-syntax-table) | 4315 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 4315 | 4316 | ||
| 4316 | (save-excursion | 4317 | (save-excursion |
| 4317 | ;; | 4318 | ;; |
| 4318 | ;; do nothing if in string or comment or not on 'end ...;' | 4319 | ;; do nothing if in string or comment or not on 'end ...;' |
| 4319 | ;; or if an error occurs during processing | 4320 | ;; or if an error occurs during processing |
| 4320 | ;; | 4321 | ;; |
| 4321 | (or | 4322 | (or |
| 4322 | (ada-in-string-or-comment-p) | 4323 | (ada-in-string-or-comment-p) |
| 4323 | (and (progn | 4324 | (and (progn |
| 4324 | (or (looking-at "[ \t]*\\<end\\>") | 4325 | (or (looking-at "[ \t]*\\<end\\>") |
| 4325 | (backward-word 1)) | 4326 | (backward-word 1)) |
| 4326 | (or (looking-at "[ \t]*\\<end\\>") | 4327 | (or (looking-at "[ \t]*\\<end\\>") |
| 4327 | (backward-word 1)) | 4328 | (backward-word 1)) |
| 4328 | (or (looking-at "[ \t]*\\<end\\>") | 4329 | (or (looking-at "[ \t]*\\<end\\>") |
| 4329 | (error "Not on end ...;"))) | 4330 | (error "Not on end ...;"))) |
| 4330 | (ada-goto-matching-start 1) | 4331 | (ada-goto-matching-start 1) |
| 4331 | (setq pos (point)) | 4332 | (setq pos (point)) |
| 4332 | 4333 | ||
| 4333 | ;; | 4334 | ;; |
| 4334 | ;; on 'begin' => go on, according to user option | 4335 | ;; on 'begin' => go on, according to user option |
| 4335 | ;; | 4336 | ;; |
| 4336 | ada-move-to-declaration | 4337 | ada-move-to-declaration |
| 4337 | (looking-at "\\<begin\\>") | 4338 | (looking-at "\\<begin\\>") |
| 4338 | (ada-goto-matching-decl-start) | 4339 | (ada-goto-matching-decl-start) |
| 4339 | (setq pos (point)))) | 4340 | (setq pos (point)))) |
| 4340 | 4341 | ||
| 4341 | ) ; end of save-excursion | 4342 | ) ; end of save-excursion |
| 4342 | 4343 | ||
| 4343 | ;; now really move to the found position | 4344 | ;; now really move to the found position |
| 4344 | (goto-char pos)) | 4345 | (goto-char pos)) |
| 4345 | 4346 | ||
| 4346 | ;; restore syntax-table | 4347 | ;; restore syntax-table |
| 4347 | (set-syntax-table previous-syntax-table)))) | 4348 | (set-syntax-table previous-syntax-table)))) |
| @@ -4352,16 +4353,16 @@ Moves to 'begin' if in a declarative part." | |||
| 4352 | (interactive) | 4353 | (interactive) |
| 4353 | (let ((pos (point)) | 4354 | (let ((pos (point)) |
| 4354 | decl-start | 4355 | decl-start |
| 4355 | (previous-syntax-table (syntax-table))) | 4356 | (previous-syntax-table (syntax-table))) |
| 4356 | (unwind-protect | 4357 | (unwind-protect |
| 4357 | (progn | 4358 | (progn |
| 4358 | (set-syntax-table ada-mode-symbol-syntax-table) | 4359 | (set-syntax-table ada-mode-symbol-syntax-table) |
| 4359 | 4360 | ||
| 4360 | (save-excursion | 4361 | (save-excursion |
| 4361 | 4362 | ||
| 4362 | (cond | 4363 | (cond |
| 4363 | ;; Go to the beginning of the current word, and check if we are | 4364 | ;; Go to the beginning of the current word, and check if we are |
| 4364 | ;; directly on 'begin' | 4365 | ;; directly on 'begin' |
| 4365 | ((save-excursion | 4366 | ((save-excursion |
| 4366 | (skip-syntax-backward "w") | 4367 | (skip-syntax-backward "w") |
| 4367 | (looking-at "\\<begin\\>")) | 4368 | (looking-at "\\<begin\\>")) |
| @@ -4375,31 +4376,31 @@ Moves to 'begin' if in a declarative part." | |||
| 4375 | ((save-excursion | 4376 | ((save-excursion |
| 4376 | (and (skip-syntax-backward "w") | 4377 | (and (skip-syntax-backward "w") |
| 4377 | (looking-at "\\<function\\>\\|\\<procedure\\>" ) | 4378 | (looking-at "\\<function\\>\\|\\<procedure\\>" ) |
| 4378 | (ada-search-ignore-string-comment "is\\|;") | 4379 | (ada-search-ignore-string-comment "is\\|;") |
| 4379 | (not (= (char-before) ?\;)) | 4380 | (not (= (char-before) ?\;)) |
| 4380 | )) | 4381 | )) |
| 4381 | (skip-syntax-backward "w") | 4382 | (skip-syntax-backward "w") |
| 4382 | (ada-goto-matching-end 0 t)) | 4383 | (ada-goto-matching-end 0 t)) |
| 4383 | 4384 | ||
| 4384 | ;; on first line of task declaration | 4385 | ;; on first line of task declaration |
| 4385 | ((save-excursion | 4386 | ((save-excursion |
| 4386 | (and (ada-goto-stmt-start) | 4387 | (and (ada-goto-stmt-start) |
| 4387 | (looking-at "\\<task\\>" ) | 4388 | (looking-at "\\<task\\>" ) |
| 4388 | (forward-word 1) | 4389 | (forward-word 1) |
| 4389 | (ada-goto-next-non-ws) | 4390 | (ada-goto-next-non-ws) |
| 4390 | (looking-at "\\<body\\>"))) | 4391 | (looking-at "\\<body\\>"))) |
| 4391 | (ada-search-ignore-string-comment "begin" nil nil nil | 4392 | (ada-search-ignore-string-comment "begin" nil nil nil |
| 4392 | 'word-search-forward)) | 4393 | 'word-search-forward)) |
| 4393 | ;; accept block start | 4394 | ;; accept block start |
| 4394 | ((save-excursion | 4395 | ((save-excursion |
| 4395 | (and (ada-goto-stmt-start) | 4396 | (and (ada-goto-stmt-start) |
| 4396 | (looking-at "\\<accept\\>" ))) | 4397 | (looking-at "\\<accept\\>" ))) |
| 4397 | (ada-goto-matching-end 0)) | 4398 | (ada-goto-matching-end 0)) |
| 4398 | ;; package start | 4399 | ;; package start |
| 4399 | ((save-excursion | 4400 | ((save-excursion |
| 4400 | (setq decl-start (and (ada-goto-matching-decl-start t) (point))) | 4401 | (setq decl-start (and (ada-goto-matching-decl-start t) (point))) |
| 4401 | (and decl-start (looking-at "\\<package\\>"))) | 4402 | (and decl-start (looking-at "\\<package\\>"))) |
| 4402 | (ada-goto-matching-end 1)) | 4403 | (ada-goto-matching-end 1)) |
| 4403 | 4404 | ||
| 4404 | ;; On a "declare" keyword | 4405 | ;; On a "declare" keyword |
| 4405 | ((save-excursion | 4406 | ((save-excursion |
| @@ -4407,19 +4408,19 @@ Moves to 'begin' if in a declarative part." | |||
| 4407 | (looking-at "\\<declare\\>")) | 4408 | (looking-at "\\<declare\\>")) |
| 4408 | (ada-goto-matching-end 0 t)) | 4409 | (ada-goto-matching-end 0 t)) |
| 4409 | 4410 | ||
| 4410 | ;; inside a 'begin' ... 'end' block | 4411 | ;; inside a 'begin' ... 'end' block |
| 4411 | (decl-start | 4412 | (decl-start |
| 4412 | (goto-char decl-start) | 4413 | (goto-char decl-start) |
| 4413 | (ada-goto-matching-end 0 t)) | 4414 | (ada-goto-matching-end 0 t)) |
| 4414 | 4415 | ||
| 4415 | ;; (hopefully ;-) everything else | 4416 | ;; (hopefully ;-) everything else |
| 4416 | (t | 4417 | (t |
| 4417 | (ada-goto-matching-end 1))) | 4418 | (ada-goto-matching-end 1))) |
| 4418 | (setq pos (point)) | 4419 | (setq pos (point)) |
| 4419 | ) | 4420 | ) |
| 4420 | 4421 | ||
| 4421 | ;; now really move to the position found | 4422 | ;; now really move to the position found |
| 4422 | (goto-char pos)) | 4423 | (goto-char pos)) |
| 4423 | 4424 | ||
| 4424 | ;; restore syntax-table | 4425 | ;; restore syntax-table |
| 4425 | (set-syntax-table previous-syntax-table)))) | 4426 | (set-syntax-table previous-syntax-table)))) |
| @@ -4511,8 +4512,8 @@ Moves to 'begin' if in a declarative part." | |||
| 4511 | ;; and activated only if the right compiler is used | 4512 | ;; and activated only if the right compiler is used |
| 4512 | (if (featurep 'xemacs) | 4513 | (if (featurep 'xemacs) |
| 4513 | (progn | 4514 | (progn |
| 4514 | (define-key ada-mode-map '(shift button3) 'ada-point-and-xref) | 4515 | (define-key ada-mode-map '(shift button3) 'ada-point-and-xref) |
| 4515 | (define-key ada-mode-map '(control tab) 'ada-complete-identifier)) | 4516 | (define-key ada-mode-map '(control tab) 'ada-complete-identifier)) |
| 4516 | (define-key ada-mode-map [C-tab] 'ada-complete-identifier) | 4517 | (define-key ada-mode-map [C-tab] 'ada-complete-identifier) |
| 4517 | (define-key ada-mode-map [S-mouse-3] 'ada-point-and-xref)) | 4518 | (define-key ada-mode-map [S-mouse-3] 'ada-point-and-xref)) |
| 4518 | 4519 | ||
| @@ -4607,15 +4608,13 @@ Moves to 'begin' if in a declarative part." | |||
| 4607 | :included (string-match "gvd" ada-prj-default-debugger)]) | 4608 | :included (string-match "gvd" ada-prj-default-debugger)]) |
| 4608 | ["Customize" (customize-group 'ada) | 4609 | ["Customize" (customize-group 'ada) |
| 4609 | :included (fboundp 'customize-group)] | 4610 | :included (fboundp 'customize-group)] |
| 4610 | ["Check file" ada-check-current (eq ada-which-compiler 'gnat)] | 4611 | ["Check file" ada-check-current t] |
| 4611 | ["Compile file" ada-compile-current (eq ada-which-compiler 'gnat)] | 4612 | ["Compile file" ada-compile-current t] |
| 4612 | ["Build" ada-compile-application | 4613 | ["Build" ada-compile-application t] |
| 4613 | (eq ada-which-compiler 'gnat)] | ||
| 4614 | ["Run" ada-run-application t] | 4614 | ["Run" ada-run-application t] |
| 4615 | ["Debug" ada-gdb-application (eq ada-which-compiler 'gnat)] | 4615 | ["Debug" ada-gdb-application (eq ada-which-compiler 'gnat)] |
| 4616 | ["------" nil nil] | 4616 | ["------" nil nil] |
| 4617 | ("Project" | 4617 | ("Project" |
| 4618 | :included (eq ada-which-compiler 'gnat) | ||
| 4619 | ["Load..." ada-set-default-project-file t] | 4618 | ["Load..." ada-set-default-project-file t] |
| 4620 | ["New..." ada-prj-new t] | 4619 | ["New..." ada-prj-new t] |
| 4621 | ["Edit..." ada-prj-edit t]) | 4620 | ["Edit..." ada-prj-edit t]) |
| @@ -4678,7 +4677,7 @@ Moves to 'begin' if in a declarative part." | |||
| 4678 | ["----" nil nil] | 4677 | ["----" nil nil] |
| 4679 | ["Make body for subprogram" ada-make-subprogram-body t] | 4678 | ["Make body for subprogram" ada-make-subprogram-body t] |
| 4680 | ["-----" nil nil] | 4679 | ["-----" nil nil] |
| 4681 | ["Narrow to subprogram" ada-narrow-to-defun t]) | 4680 | ["Narrow to subprogram" ada-narrow-to-defun t]) |
| 4682 | ("Templates" | 4681 | ("Templates" |
| 4683 | :included (eq major-mode 'ada-mode) | 4682 | :included (eq major-mode 'ada-mode) |
| 4684 | ["Header" ada-header t] | 4683 | ["Header" ada-header t] |
| @@ -4741,18 +4740,19 @@ Moves to 'begin' if in a declarative part." | |||
| 4741 | 4740 | ||
| 4742 | (defadvice comment-region (before ada-uncomment-anywhere disable) | 4741 | (defadvice comment-region (before ada-uncomment-anywhere disable) |
| 4743 | (if (and arg | 4742 | (if (and arg |
| 4744 | (listp arg) ;; a prefix with \C-u is of the form '(4), whereas | 4743 | (listp arg) ;; a prefix with \C-u is of the form '(4), whereas |
| 4745 | ;; \C-u 2 sets arg to '2' (fixed by S.Leake) | 4744 | ;; \C-u 2 sets arg to '2' (fixed by S.Leake) |
| 4746 | (string= mode-name "Ada")) | 4745 | (string= mode-name "Ada")) |
| 4747 | (save-excursion | 4746 | (save-excursion |
| 4748 | (let ((cs (concat "^[ \t]*" (regexp-quote comment-start)))) | 4747 | (let ((cs (concat "^[ \t]*" (regexp-quote comment-start)))) |
| 4749 | (goto-char beg) | 4748 | (goto-char beg) |
| 4750 | (while (re-search-forward cs end t) | 4749 | (while (re-search-forward cs end t) |
| 4751 | (replace-match comment-start)) | 4750 | (replace-match comment-start)) |
| 4752 | )))) | 4751 | )))) |
| 4753 | 4752 | ||
| 4754 | (defun ada-uncomment-region (beg end &optional arg) | 4753 | (defun ada-uncomment-region (beg end &optional arg) |
| 4755 | "Delete `comment-start' at the beginning of a line in the region." | 4754 | "Uncomment region BEG .. END. |
| 4755 | ARG gives number of comment characters." | ||
| 4756 | (interactive "r\nP") | 4756 | (interactive "r\nP") |
| 4757 | 4757 | ||
| 4758 | ;; This advice is not needed anymore with Emacs21. However, for older | 4758 | ;; This advice is not needed anymore with Emacs21. However, for older |
| @@ -4786,18 +4786,18 @@ The paragraph is indented on the first line." | |||
| 4786 | 4786 | ||
| 4787 | ;; check if inside comment or just in front a comment | 4787 | ;; check if inside comment or just in front a comment |
| 4788 | (if (and (not (ada-in-comment-p)) | 4788 | (if (and (not (ada-in-comment-p)) |
| 4789 | (not (looking-at "[ \t]*--"))) | 4789 | (not (looking-at "[ \t]*--"))) |
| 4790 | (error "Not inside comment")) | 4790 | (error "Not inside comment")) |
| 4791 | 4791 | ||
| 4792 | (let* (indent from to | 4792 | (let* (indent from to |
| 4793 | (opos (point-marker)) | 4793 | (opos (point-marker)) |
| 4794 | 4794 | ||
| 4795 | ;; Sets this variable to nil, otherwise it prevents | 4795 | ;; Sets this variable to nil, otherwise it prevents |
| 4796 | ;; fill-region-as-paragraph to work on Emacs <= 20.2 | 4796 | ;; fill-region-as-paragraph to work on Emacs <= 20.2 |
| 4797 | (parse-sexp-lookup-properties nil) | 4797 | (parse-sexp-lookup-properties nil) |
| 4798 | 4798 | ||
| 4799 | fill-prefix | 4799 | fill-prefix |
| 4800 | (fill-column (current-fill-column))) | 4800 | (fill-column (current-fill-column))) |
| 4801 | 4801 | ||
| 4802 | ;; Find end of paragraph | 4802 | ;; Find end of paragraph |
| 4803 | (back-to-indentation) | 4803 | (back-to-indentation) |
| @@ -4844,32 +4844,32 @@ The paragraph is indented on the first line." | |||
| 4844 | (setq fill-prefix ada-fill-comment-prefix) | 4844 | (setq fill-prefix ada-fill-comment-prefix) |
| 4845 | (set-left-margin from to indent) | 4845 | (set-left-margin from to indent) |
| 4846 | (if postfix | 4846 | (if postfix |
| 4847 | (setq fill-column (- fill-column (length ada-fill-comment-postfix)))) | 4847 | (setq fill-column (- fill-column (length ada-fill-comment-postfix)))) |
| 4848 | 4848 | ||
| 4849 | (fill-region-as-paragraph from to justify) | 4849 | (fill-region-as-paragraph from to justify) |
| 4850 | 4850 | ||
| 4851 | ;; Add the postfixes if required | 4851 | ;; Add the postfixes if required |
| 4852 | (if postfix | 4852 | (if postfix |
| 4853 | (save-restriction | 4853 | (save-restriction |
| 4854 | (goto-char from) | 4854 | (goto-char from) |
| 4855 | (narrow-to-region from to) | 4855 | (narrow-to-region from to) |
| 4856 | (while (not (eobp)) | 4856 | (while (not (eobp)) |
| 4857 | (end-of-line) | 4857 | (end-of-line) |
| 4858 | (insert-char ? (- fill-column (current-column))) | 4858 | (insert-char ? (- fill-column (current-column))) |
| 4859 | (insert ada-fill-comment-postfix) | 4859 | (insert ada-fill-comment-postfix) |
| 4860 | (forward-line)) | 4860 | (forward-line)) |
| 4861 | )) | 4861 | )) |
| 4862 | 4862 | ||
| 4863 | ;; In Emacs <= 20.2 and XEmacs <=20.4, there is a bug, and a newline is | 4863 | ;; In Emacs <= 20.2 and XEmacs <=20.4, there is a bug, and a newline is |
| 4864 | ;; inserted at the end. Delete it | 4864 | ;; inserted at the end. Delete it |
| 4865 | (if (or (featurep 'xemacs) | 4865 | (if (or (featurep 'xemacs) |
| 4866 | (<= emacs-major-version 19) | 4866 | (<= emacs-major-version 19) |
| 4867 | (and (= emacs-major-version 20) | 4867 | (and (= emacs-major-version 20) |
| 4868 | (<= emacs-minor-version 2))) | 4868 | (<= emacs-minor-version 2))) |
| 4869 | (progn | 4869 | (progn |
| 4870 | (goto-char to) | 4870 | (goto-char to) |
| 4871 | (end-of-line) | 4871 | (end-of-line) |
| 4872 | (delete-char 1))) | 4872 | (delete-char 1))) |
| 4873 | 4873 | ||
| 4874 | (goto-char opos))) | 4874 | (goto-char opos))) |
| 4875 | 4875 | ||
| @@ -4890,7 +4890,8 @@ The paragraph is indented on the first line." | |||
| 4890 | ;; Overriden when we work with GNAT, to use gnatkrunch | 4890 | ;; Overriden when we work with GNAT, to use gnatkrunch |
| 4891 | (defun ada-make-filename-from-adaname (adaname) | 4891 | (defun ada-make-filename-from-adaname (adaname) |
| 4892 | "Determine the filename in which ADANAME is found. | 4892 | "Determine the filename in which ADANAME is found. |
| 4893 | This is a generic function, independent from any compiler." | 4893 | This matches the GNAT default naming convention, except for |
| 4894 | pre-defined units." | ||
| 4894 | (while (string-match "\\." adaname) | 4895 | (while (string-match "\\." adaname) |
| 4895 | (setq adaname (replace-match "-" t t adaname))) | 4896 | (setq adaname (replace-match "-" t t adaname))) |
| 4896 | (downcase adaname) | 4897 | (downcase adaname) |
| @@ -4962,8 +4963,8 @@ Redefines the function `ff-which-function-are-we-in'." | |||
| 4962 | (save-excursion | 4963 | (save-excursion |
| 4963 | (end-of-line);; make sure we get the complete name | 4964 | (end-of-line);; make sure we get the complete name |
| 4964 | (if (or (re-search-backward ada-procedure-start-regexp nil t) | 4965 | (if (or (re-search-backward ada-procedure-start-regexp nil t) |
| 4965 | (re-search-backward ada-package-start-regexp nil t)) | 4966 | (re-search-backward ada-package-start-regexp nil t)) |
| 4966 | (setq ff-function-name (match-string 0))) | 4967 | (setq ff-function-name (match-string 0))) |
| 4967 | )) | 4968 | )) |
| 4968 | 4969 | ||
| 4969 | 4970 | ||
| @@ -4982,18 +4983,18 @@ standard Emacs function `which-function' does not. | |||
| 4982 | Since the search can be long, the results are cached." | 4983 | Since the search can be long, the results are cached." |
| 4983 | 4984 | ||
| 4984 | (let ((line (count-lines 1 (point))) | 4985 | (let ((line (count-lines 1 (point))) |
| 4985 | (pos (point)) | 4986 | (pos (point)) |
| 4986 | end-pos | 4987 | end-pos |
| 4987 | func-name indent | 4988 | func-name indent |
| 4988 | found) | 4989 | found) |
| 4989 | 4990 | ||
| 4990 | ;; If this is the same line as before, simply return the same result | 4991 | ;; If this is the same line as before, simply return the same result |
| 4991 | (if (= line ada-last-which-function-line) | 4992 | (if (= line ada-last-which-function-line) |
| 4992 | ada-last-which-function-subprog | 4993 | ada-last-which-function-subprog |
| 4993 | 4994 | ||
| 4994 | (save-excursion | 4995 | (save-excursion |
| 4995 | ;; In case the current line is also the beginning of the body | 4996 | ;; In case the current line is also the beginning of the body |
| 4996 | (end-of-line) | 4997 | (end-of-line) |
| 4997 | 4998 | ||
| 4998 | ;; Are we looking at "function Foo\n (paramlist)" | 4999 | ;; Are we looking at "function Foo\n (paramlist)" |
| 4999 | (skip-chars-forward " \t\n(") | 5000 | (skip-chars-forward " \t\n(") |
| @@ -5009,39 +5010,39 @@ Since the search can be long, the results are cached." | |||
| 5009 | (skip-chars-forward " \t\n") | 5010 | (skip-chars-forward " \t\n") |
| 5010 | (skip-chars-forward "a-zA-Z0-9_'"))) | 5011 | (skip-chars-forward "a-zA-Z0-9_'"))) |
| 5011 | 5012 | ||
| 5012 | ;; Can't simply do forward-word, in case the "is" is not on the | 5013 | ;; Can't simply do forward-word, in case the "is" is not on the |
| 5013 | ;; same line as the closing parenthesis | 5014 | ;; same line as the closing parenthesis |
| 5014 | (skip-chars-forward "is \t\n") | 5015 | (skip-chars-forward "is \t\n") |
| 5015 | 5016 | ||
| 5016 | ;; No look for the closest subprogram body that has not ended yet. | 5017 | ;; No look for the closest subprogram body that has not ended yet. |
| 5017 | ;; Not that we expect all the bodies to be finished by "end <name>", | 5018 | ;; Not that we expect all the bodies to be finished by "end <name>", |
| 5018 | ;; or a simple "end;" indented in the same column as the start of | 5019 | ;; or a simple "end;" indented in the same column as the start of |
| 5019 | ;; the subprogram. The goal is to be as efficient as possible. | 5020 | ;; the subprogram. The goal is to be as efficient as possible. |
| 5020 | 5021 | ||
| 5021 | (while (and (not found) | 5022 | (while (and (not found) |
| 5022 | (re-search-backward ada-imenu-subprogram-menu-re nil t)) | 5023 | (re-search-backward ada-imenu-subprogram-menu-re nil t)) |
| 5023 | 5024 | ||
| 5024 | ;; Get the function name, but not the properties, or this changes | 5025 | ;; Get the function name, but not the properties, or this changes |
| 5025 | ;; the face in the modeline on Emacs 21 | 5026 | ;; the face in the modeline on Emacs 21 |
| 5026 | (setq func-name (match-string-no-properties 2)) | 5027 | (setq func-name (match-string-no-properties 2)) |
| 5027 | (if (and (not (ada-in-comment-p)) | 5028 | (if (and (not (ada-in-comment-p)) |
| 5028 | (not (save-excursion | 5029 | (not (save-excursion |
| 5029 | (goto-char (match-end 0)) | 5030 | (goto-char (match-end 0)) |
| 5030 | (looking-at "[ \t\n]*new")))) | 5031 | (looking-at "[ \t\n]*new")))) |
| 5031 | (save-excursion | 5032 | (save-excursion |
| 5032 | (back-to-indentation) | 5033 | (back-to-indentation) |
| 5033 | (setq indent (current-column)) | 5034 | (setq indent (current-column)) |
| 5034 | (if (ada-search-ignore-string-comment | 5035 | (if (ada-search-ignore-string-comment |
| 5035 | (concat "end[ \t]+" func-name "[ \t]*;\\|^" | 5036 | (concat "end[ \t]+" func-name "[ \t]*;\\|^" |
| 5036 | (make-string indent ? ) "end;")) | 5037 | (make-string indent ? ) "end;")) |
| 5037 | (setq end-pos (point)) | 5038 | (setq end-pos (point)) |
| 5038 | (setq end-pos (point-max))) | 5039 | (setq end-pos (point-max))) |
| 5039 | (if (>= end-pos pos) | 5040 | (if (>= end-pos pos) |
| 5040 | (setq found func-name)))) | 5041 | (setq found func-name)))) |
| 5041 | ) | 5042 | ) |
| 5042 | (setq ada-last-which-function-line line | 5043 | (setq ada-last-which-function-line line |
| 5043 | ada-last-which-function-subprog found) | 5044 | ada-last-which-function-subprog found) |
| 5044 | found)))) | 5045 | found)))) |
| 5045 | 5046 | ||
| 5046 | (defun ada-ff-other-window () | 5047 | (defun ada-ff-other-window () |
| 5047 | "Find other file in other window using `ff-find-other-file'." | 5048 | "Find other file in other window using `ff-find-other-file'." |
| @@ -5050,14 +5051,13 @@ Since the search can be long, the results are cached." | |||
| 5050 | (ff-find-other-file t))) | 5051 | (ff-find-other-file t))) |
| 5051 | 5052 | ||
| 5052 | (defun ada-set-point-accordingly () | 5053 | (defun ada-set-point-accordingly () |
| 5053 | "Move to the function declaration that was set by | 5054 | "Move to the function declaration that was set by `ff-which-function-are-we-in'." |
| 5054 | `ff-which-function-are-we-in'." | ||
| 5055 | (if ff-function-name | 5055 | (if ff-function-name |
| 5056 | (progn | 5056 | (progn |
| 5057 | (goto-char (point-min)) | 5057 | (goto-char (point-min)) |
| 5058 | (unless (ada-search-ignore-string-comment | 5058 | (unless (ada-search-ignore-string-comment |
| 5059 | (concat ff-function-name "\\b") nil) | 5059 | (concat ff-function-name "\\b") nil) |
| 5060 | (goto-char (point-min)))))) | 5060 | (goto-char (point-min)))))) |
| 5061 | 5061 | ||
| 5062 | (defun ada-get-body-name (&optional spec-name) | 5062 | (defun ada-get-body-name (&optional spec-name) |
| 5063 | "Return the file name for the body of SPEC-NAME. | 5063 | "Return the file name for the body of SPEC-NAME. |
| @@ -5082,15 +5082,15 @@ Return nil if no body was found." | |||
| 5082 | ;; If find-file.el was available, use its functions | 5082 | ;; If find-file.el was available, use its functions |
| 5083 | (if (fboundp 'ff-get-file-name) | 5083 | (if (fboundp 'ff-get-file-name) |
| 5084 | (ff-get-file-name ada-search-directories-internal | 5084 | (ff-get-file-name ada-search-directories-internal |
| 5085 | (ada-make-filename-from-adaname | 5085 | (ada-make-filename-from-adaname |
| 5086 | (file-name-nondirectory | 5086 | (file-name-nondirectory |
| 5087 | (file-name-sans-extension spec-name))) | 5087 | (file-name-sans-extension spec-name))) |
| 5088 | ada-body-suffixes) | 5088 | ada-body-suffixes) |
| 5089 | ;; Else emulate it very simply | 5089 | ;; Else emulate it very simply |
| 5090 | (concat (ada-make-filename-from-adaname | 5090 | (concat (ada-make-filename-from-adaname |
| 5091 | (file-name-nondirectory | 5091 | (file-name-nondirectory |
| 5092 | (file-name-sans-extension spec-name))) | 5092 | (file-name-sans-extension spec-name))) |
| 5093 | ".adb"))) | 5093 | ".adb"))) |
| 5094 | 5094 | ||
| 5095 | 5095 | ||
| 5096 | ;; --------------------------------------------------- | 5096 | ;; --------------------------------------------------- |
| @@ -5130,44 +5130,44 @@ Return nil if no body was found." | |||
| 5130 | ;; accept, entry, function, package (body), protected (body|type), | 5130 | ;; accept, entry, function, package (body), protected (body|type), |
| 5131 | ;; pragma, procedure, task (body) plus name. | 5131 | ;; pragma, procedure, task (body) plus name. |
| 5132 | (list (concat | 5132 | (list (concat |
| 5133 | "\\<\\(" | 5133 | "\\<\\(" |
| 5134 | "accept\\|" | 5134 | "accept\\|" |
| 5135 | "entry\\|" | 5135 | "entry\\|" |
| 5136 | "function\\|" | 5136 | "function\\|" |
| 5137 | "package[ \t]+body\\|" | 5137 | "package[ \t]+body\\|" |
| 5138 | "package\\|" | 5138 | "package\\|" |
| 5139 | "pragma\\|" | 5139 | "pragma\\|" |
| 5140 | "procedure\\|" | 5140 | "procedure\\|" |
| 5141 | "protected[ \t]+body\\|" | 5141 | "protected[ \t]+body\\|" |
| 5142 | "protected[ \t]+type\\|" | 5142 | "protected[ \t]+type\\|" |
| 5143 | "protected\\|" | 5143 | "protected\\|" |
| 5144 | "task[ \t]+body\\|" | 5144 | "task[ \t]+body\\|" |
| 5145 | "task[ \t]+type\\|" | 5145 | "task[ \t]+type\\|" |
| 5146 | "task" | 5146 | "task" |
| 5147 | "\\)\\>[ \t]*" | 5147 | "\\)\\>[ \t]*" |
| 5148 | "\\(\\sw+\\(\\.\\sw*\\)*\\)?") | 5148 | "\\(\\sw+\\(\\.\\sw*\\)*\\)?") |
| 5149 | '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t)) | 5149 | '(1 font-lock-keyword-face) '(2 font-lock-function-name-face nil t)) |
| 5150 | ;; | 5150 | ;; |
| 5151 | ;; Optional keywords followed by a type name. | 5151 | ;; Optional keywords followed by a type name. |
| 5152 | (list (concat ; ":[ \t]*" | 5152 | (list (concat ; ":[ \t]*" |
| 5153 | "\\<\\(access[ \t]+all\\|access[ \t]+constant\\|access\\|constant\\|in[ \t]+reverse\\|\\|in[ \t]+out\\|in\\|out\\)\\>" | 5153 | "\\<\\(access[ \t]+all\\|access[ \t]+constant\\|access\\|constant\\|in[ \t]+reverse\\|\\|in[ \t]+out\\|in\\|out\\)\\>" |
| 5154 | "[ \t]*" | 5154 | "[ \t]*" |
| 5155 | "\\(\\sw+\\(\\.\\sw*\\)*\\)?") | 5155 | "\\(\\sw+\\(\\.\\sw*\\)*\\)?") |
| 5156 | '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t)) | 5156 | '(1 font-lock-keyword-face nil t) '(2 font-lock-type-face nil t)) |
| 5157 | 5157 | ||
| 5158 | ;; | 5158 | ;; |
| 5159 | ;; Main keywords, except those treated specially below. | 5159 | ;; Main keywords, except those treated specially below. |
| 5160 | (concat "\\<" | 5160 | (concat "\\<" |
| 5161 | (regexp-opt | 5161 | (regexp-opt |
| 5162 | '("abort" "abs" "abstract" "accept" "access" "aliased" "all" | 5162 | '("abort" "abs" "abstract" "accept" "access" "aliased" "all" |
| 5163 | "and" "array" "at" "begin" "case" "declare" "delay" "delta" | 5163 | "and" "array" "at" "begin" "case" "declare" "delay" "delta" |
| 5164 | "digits" "do" "else" "elsif" "entry" "exception" "exit" "for" | 5164 | "digits" "do" "else" "elsif" "entry" "exception" "exit" "for" |
| 5165 | "generic" "if" "in" "is" "limited" "loop" "mod" "not" | 5165 | "generic" "if" "in" "is" "limited" "loop" "mod" "not" |
| 5166 | "null" "or" "others" "private" "protected" "raise" | 5166 | "null" "or" "others" "private" "protected" "raise" |
| 5167 | "range" "record" "rem" "renames" "requeue" "return" "reverse" | 5167 | "range" "record" "rem" "renames" "requeue" "return" "reverse" |
| 5168 | "select" "separate" "tagged" "task" "terminate" "then" "until" | 5168 | "select" "separate" "tagged" "task" "terminate" "then" "until" |
| 5169 | "when" "while" "with" "xor") t) | 5169 | "when" "while" "with" "xor") t) |
| 5170 | "\\>") | 5170 | "\\>") |
| 5171 | ;; | 5171 | ;; |
| 5172 | ;; Anything following end and not already fontified is a body name. | 5172 | ;; Anything following end and not already fontified is a body name. |
| 5173 | '("\\<\\(end\\)\\>\\([ \t]+\\)?\\(\\(\\sw\\|[_.]\\)+\\)?" | 5173 | '("\\<\\(end\\)\\>\\([ \t]+\\)?\\(\\(\\sw\\|[_.]\\)+\\)?" |
| @@ -5175,19 +5175,19 @@ Return nil if no body was found." | |||
| 5175 | ;; | 5175 | ;; |
| 5176 | ;; Keywords followed by a type or function name. | 5176 | ;; Keywords followed by a type or function name. |
| 5177 | (list (concat "\\<\\(" | 5177 | (list (concat "\\<\\(" |
| 5178 | "new\\|of\\|subtype\\|type" | 5178 | "new\\|of\\|subtype\\|type" |
| 5179 | "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?[ \t]*\\((\\)?") | 5179 | "\\)\\>[ \t]*\\(\\sw+\\(\\.\\sw*\\)*\\)?[ \t]*\\((\\)?") |
| 5180 | '(1 font-lock-keyword-face) | 5180 | '(1 font-lock-keyword-face) |
| 5181 | '(2 (if (match-beginning 4) | 5181 | '(2 (if (match-beginning 4) |
| 5182 | font-lock-function-name-face | 5182 | font-lock-function-name-face |
| 5183 | font-lock-type-face) nil t)) | 5183 | font-lock-type-face) nil t)) |
| 5184 | ;; | 5184 | ;; |
| 5185 | ;; Keywords followed by a (comma separated list of) reference. | 5185 | ;; Keywords followed by a (comma separated list of) reference. |
| 5186 | ;; Note that font-lock only works on single lines, thus we can not | 5186 | ;; Note that font-lock only works on single lines, thus we can not |
| 5187 | ;; correctly highlight a with_clause that spans multiple lines. | 5187 | ;; correctly highlight a with_clause that spans multiple lines. |
| 5188 | (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)" | 5188 | (list (concat "\\<\\(goto\\|raise\\|use\\|with\\)" |
| 5189 | "[ \t]+\\([a-zA-Z0-9_., \t]+\\)\\W") | 5189 | "[ \t]+\\([a-zA-Z0-9_., \t]+\\)\\W") |
| 5190 | '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t)) | 5190 | '(1 font-lock-keyword-face) '(2 font-lock-reference-face nil t)) |
| 5191 | 5191 | ||
| 5192 | ;; | 5192 | ;; |
| 5193 | ;; Goto tags. | 5193 | ;; Goto tags. |
| @@ -5233,8 +5233,8 @@ Use \\[widen] to go back to the full visibility for the buffer." | |||
| 5233 | (ada-previous-procedure) | 5233 | (ada-previous-procedure) |
| 5234 | 5234 | ||
| 5235 | (save-excursion | 5235 | (save-excursion |
| 5236 | (beginning-of-line) | 5236 | (beginning-of-line) |
| 5237 | (setq end (point))) | 5237 | (setq end (point))) |
| 5238 | 5238 | ||
| 5239 | (ada-move-to-end) | 5239 | (ada-move-to-end) |
| 5240 | (end-of-line) | 5240 | (end-of-line) |
| @@ -5260,7 +5260,7 @@ for `ada-procedure-start-regexp'." | |||
| 5260 | (let (func-found procname functype) | 5260 | (let (func-found procname functype) |
| 5261 | (cond | 5261 | (cond |
| 5262 | ((or (looking-at "^[ \t]*procedure") | 5262 | ((or (looking-at "^[ \t]*procedure") |
| 5263 | (setq func-found (looking-at "^[ \t]*function"))) | 5263 | (setq func-found (looking-at "^[ \t]*function"))) |
| 5264 | ;; treat it as a proc/func | 5264 | ;; treat it as a proc/func |
| 5265 | (forward-word 2) | 5265 | (forward-word 2) |
| 5266 | (forward-word -1) | 5266 | (forward-word -1) |
| @@ -5271,56 +5271,56 @@ for `ada-procedure-start-regexp'." | |||
| 5271 | 5271 | ||
| 5272 | ;; skip over parameterlist | 5272 | ;; skip over parameterlist |
| 5273 | (unless (looking-at "[ \t\n]*\\(;\\|return\\)") | 5273 | (unless (looking-at "[ \t\n]*\\(;\\|return\\)") |
| 5274 | (forward-sexp)) | 5274 | (forward-sexp)) |
| 5275 | 5275 | ||
| 5276 | ;; if function, skip over 'return' and result type. | 5276 | ;; if function, skip over 'return' and result type. |
| 5277 | (if func-found | 5277 | (if func-found |
| 5278 | (progn | 5278 | (progn |
| 5279 | (forward-word 1) | 5279 | (forward-word 1) |
| 5280 | (skip-chars-forward " \t\n") | 5280 | (skip-chars-forward " \t\n") |
| 5281 | (setq functype (buffer-substring (point) | 5281 | (setq functype (buffer-substring (point) |
| 5282 | (progn | 5282 | (progn |
| 5283 | (skip-chars-forward | 5283 | (skip-chars-forward |
| 5284 | "a-zA-Z0-9_\.") | 5284 | "a-zA-Z0-9_\.") |
| 5285 | (point)))))) | 5285 | (point)))))) |
| 5286 | ;; look for next non WS | 5286 | ;; look for next non WS |
| 5287 | (cond | 5287 | (cond |
| 5288 | ((looking-at "[ \t]*;") | 5288 | ((looking-at "[ \t]*;") |
| 5289 | (delete-region (match-beginning 0) (match-end 0));; delete the ';' | 5289 | (delete-region (match-beginning 0) (match-end 0));; delete the ';' |
| 5290 | (ada-indent-newline-indent) | 5290 | (ada-indent-newline-indent) |
| 5291 | (insert "is") | 5291 | (insert "is") |
| 5292 | (ada-indent-newline-indent) | 5292 | (ada-indent-newline-indent) |
| 5293 | (if func-found | 5293 | (if func-found |
| 5294 | (progn | 5294 | (progn |
| 5295 | (insert "Result : " functype ";") | 5295 | (insert "Result : " functype ";") |
| 5296 | (ada-indent-newline-indent))) | 5296 | (ada-indent-newline-indent))) |
| 5297 | (insert "begin") | 5297 | (insert "begin") |
| 5298 | (ada-indent-newline-indent) | 5298 | (ada-indent-newline-indent) |
| 5299 | (if func-found | 5299 | (if func-found |
| 5300 | (insert "return Result;") | 5300 | (insert "return Result;") |
| 5301 | (insert "null;")) | 5301 | (insert "null;")) |
| 5302 | (ada-indent-newline-indent) | 5302 | (ada-indent-newline-indent) |
| 5303 | (insert "end " procname ";") | 5303 | (insert "end " procname ";") |
| 5304 | (ada-indent-newline-indent) | 5304 | (ada-indent-newline-indent) |
| 5305 | ) | 5305 | ) |
| 5306 | ;; else | 5306 | ;; else |
| 5307 | ((looking-at "[ \t\n]*is") | 5307 | ((looking-at "[ \t\n]*is") |
| 5308 | ;; do nothing | 5308 | ;; do nothing |
| 5309 | ) | 5309 | ) |
| 5310 | ((looking-at "[ \t\n]*rename") | 5310 | ((looking-at "[ \t\n]*rename") |
| 5311 | ;; do nothing | 5311 | ;; do nothing |
| 5312 | ) | 5312 | ) |
| 5313 | (t | 5313 | (t |
| 5314 | (message "unknown syntax")))) | 5314 | (message "unknown syntax")))) |
| 5315 | (t | 5315 | (t |
| 5316 | (if (looking-at "^[ \t]*task") | 5316 | (if (looking-at "^[ \t]*task") |
| 5317 | (progn | 5317 | (progn |
| 5318 | (message "Task conversion is not yet implemented") | 5318 | (message "Task conversion is not yet implemented") |
| 5319 | (forward-word 2) | 5319 | (forward-word 2) |
| 5320 | (if (looking-at "[ \t]*;") | 5320 | (if (looking-at "[ \t]*;") |
| 5321 | (forward-line) | 5321 | (forward-line) |
| 5322 | (ada-move-to-end)) | 5322 | (ada-move-to-end)) |
| 5323 | )))))) | 5323 | )))))) |
| 5324 | 5324 | ||
| 5325 | (defun ada-make-body () | 5325 | (defun ada-make-body () |
| 5326 | "Create an Ada package body in the current buffer. | 5326 | "Create an Ada package body in the current buffer. |
| @@ -5335,63 +5335,63 @@ This function typically is to be hooked into `ff-file-created-hooks'." | |||
| 5335 | 5335 | ||
| 5336 | (let (found ada-procedure-or-package-start-regexp) | 5336 | (let (found ada-procedure-or-package-start-regexp) |
| 5337 | (if (setq found | 5337 | (if (setq found |
| 5338 | (ada-search-ignore-string-comment ada-package-start-regexp nil)) | 5338 | (ada-search-ignore-string-comment ada-package-start-regexp nil)) |
| 5339 | (progn (goto-char (cdr found)) | 5339 | (progn (goto-char (cdr found)) |
| 5340 | (insert " body") | 5340 | (insert " body") |
| 5341 | ) | 5341 | ) |
| 5342 | (error "No package")) | 5342 | (error "No package")) |
| 5343 | 5343 | ||
| 5344 | (setq ada-procedure-or-package-start-regexp | 5344 | (setq ada-procedure-or-package-start-regexp |
| 5345 | (concat ada-procedure-start-regexp | 5345 | (concat ada-procedure-start-regexp |
| 5346 | "\\|" | 5346 | "\\|" |
| 5347 | ada-package-start-regexp)) | 5347 | ada-package-start-regexp)) |
| 5348 | 5348 | ||
| 5349 | (while (setq found | 5349 | (while (setq found |
| 5350 | (ada-search-ignore-string-comment | 5350 | (ada-search-ignore-string-comment |
| 5351 | ada-procedure-or-package-start-regexp nil)) | 5351 | ada-procedure-or-package-start-regexp nil)) |
| 5352 | (progn | 5352 | (progn |
| 5353 | (goto-char (car found)) | 5353 | (goto-char (car found)) |
| 5354 | (if (looking-at ada-package-start-regexp) | 5354 | (if (looking-at ada-package-start-regexp) |
| 5355 | (progn (goto-char (cdr found)) | 5355 | (progn (goto-char (cdr found)) |
| 5356 | (insert " body")) | 5356 | (insert " body")) |
| 5357 | (ada-gen-treat-proc found)))))) | 5357 | (ada-gen-treat-proc found)))))) |
| 5358 | 5358 | ||
| 5359 | 5359 | ||
| 5360 | (defun ada-make-subprogram-body () | 5360 | (defun ada-make-subprogram-body () |
| 5361 | "Make one dummy subprogram body from spec surrounding point." | 5361 | "Make one dummy subprogram body from spec surrounding point." |
| 5362 | (interactive) | 5362 | (interactive) |
| 5363 | (let* ((found (re-search-backward ada-procedure-start-regexp nil t)) | 5363 | (let* ((found (re-search-backward ada-procedure-start-regexp nil t)) |
| 5364 | (spec (match-beginning 0)) | 5364 | (spec (match-beginning 0)) |
| 5365 | body-file) | 5365 | body-file) |
| 5366 | (if found | 5366 | (if found |
| 5367 | (progn | 5367 | (progn |
| 5368 | (goto-char spec) | 5368 | (goto-char spec) |
| 5369 | (if (and (re-search-forward "(\\|;" nil t) | 5369 | (if (and (re-search-forward "(\\|;" nil t) |
| 5370 | (= (char-before) ?\()) | 5370 | (= (char-before) ?\()) |
| 5371 | (progn | 5371 | (progn |
| 5372 | (ada-search-ignore-string-comment ")" nil) | 5372 | (ada-search-ignore-string-comment ")" nil) |
| 5373 | (ada-search-ignore-string-comment ";" nil))) | 5373 | (ada-search-ignore-string-comment ";" nil))) |
| 5374 | (setq spec (buffer-substring spec (point))) | 5374 | (setq spec (buffer-substring spec (point))) |
| 5375 | 5375 | ||
| 5376 | ;; If find-file.el was available, use its functions | 5376 | ;; If find-file.el was available, use its functions |
| 5377 | (setq body-file (ada-get-body-name)) | 5377 | (setq body-file (ada-get-body-name)) |
| 5378 | (if body-file | 5378 | (if body-file |
| 5379 | (find-file body-file) | 5379 | (find-file body-file) |
| 5380 | (error "No body found for the package. Create it first")) | 5380 | (error "No body found for the package. Create it first")) |
| 5381 | 5381 | ||
| 5382 | (save-restriction | 5382 | (save-restriction |
| 5383 | (widen) | 5383 | (widen) |
| 5384 | (goto-char (point-max)) | 5384 | (goto-char (point-max)) |
| 5385 | (forward-comment -10000) | 5385 | (forward-comment -10000) |
| 5386 | (re-search-backward "\\<end\\>" nil t) | 5386 | (re-search-backward "\\<end\\>" nil t) |
| 5387 | ;; Move to the beginning of the elaboration part, if any | 5387 | ;; Move to the beginning of the elaboration part, if any |
| 5388 | (re-search-backward "^begin" nil t) | 5388 | (re-search-backward "^begin" nil t) |
| 5389 | (newline) | 5389 | (newline) |
| 5390 | (forward-char -1) | 5390 | (forward-char -1) |
| 5391 | (insert spec) | 5391 | (insert spec) |
| 5392 | (re-search-backward ada-procedure-start-regexp nil t) | 5392 | (re-search-backward ada-procedure-start-regexp nil t) |
| 5393 | (ada-gen-treat-proc (cons (match-beginning 0) (match-end 0))) | 5393 | (ada-gen-treat-proc (cons (match-beginning 0) (match-end 0))) |
| 5394 | )) | 5394 | )) |
| 5395 | (error "Not in subprogram spec")))) | 5395 | (error "Not in subprogram spec")))) |
| 5396 | 5396 | ||
| 5397 | ;; -------------------------------------------------------- | 5397 | ;; -------------------------------------------------------- |