diff options
| author | Stefan Monnier | 2002-06-20 17:40:38 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-06-20 17:40:38 +0000 |
| commit | 80d50f8814552e2e773416336579c308680d183b (patch) | |
| tree | b845ca780b102ccfde351e403dbfd7b27fdce94d | |
| parent | 93cdce2074cd594521e8e115687af06ab6531851 (diff) | |
| download | emacs-80d50f8814552e2e773416336579c308680d183b.tar.gz emacs-80d50f8814552e2e773416336579c308680d183b.zip | |
* progmodes/ada-mode.el: Update copyright notice.
Synchronize with GNAT release 3.15a1.
Do not attempt to load ada-support, which is only for compatibility
with older Emacs versions, and is not needed for Emacs 21.
(ada-continuation-indent): New variable.
New contextual menu: "List local reference", faster than "List References".
(ada-mode): New alignment rules provided by S. Leake.
(ada-mode): Add support for which-function-mode.
Fix various calls to count-lines, that didn't work correctly when the
buffer was narrowed.
(ada-get-current-indent): Fix indentation of named parameter lists and
nested boolean expressions.
(ada-indent-on-previous-lines): Fix indentation of labels.
(ada-search-prev-end-stmt): Fix searching of the previous end-statement,
specially with regards to nested subprograms.
(comment-region advice): Initially disabled, for better compatibility with
other modes.
(ada-fill-comment-paragraph): Fixed (no longer worked with Emacs 21).
* progmodes/ada-xref.el: Update copyright notice.
(ada-xref-create-ali): The default is now not to create automatically the
ALI files by compiling the unit, since this isn't always reliable and
requires an up-to-date project file.
(ada-prj-default-comp-cmd): No longer use gcc directly to compile
a file, but use gnatmake instead, since this gives access to the GNAT
project files.
(ada-xref-search-with-egrep): New variable, suggested by P. Waroquiers.
(ada-load-project-hook): New variable, for support of GNAT project files.
(ada-update-project-menu): Fix the detection of the project file name.
(ada-add-keymap): Change key binding for ada-find-file, that conflicted
with another binding in ada-mode.el.
(ada-add-menu): New menu "List Local References", to list the reference
to the entity only in the current file, instead of looking in the whole
project. Much faster.
(ada-find-references): New parameters arg and local-only.
(ada-find-any-references): New parameters local-only and append.
(ada-goto-declaration): Fix handling of predefined entities in xref.
(ada-get-all-references): Updated to the new xref format in GNAT 3.15,
still compatible with GNAT 3.14 of course. Fix various calls to
count-lines, that didn't work correctly when the buffer was narrowed.
| -rw-r--r-- | lisp/progmodes/ada-mode.el | 244 |
1 files changed, 168 insertions, 76 deletions
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el index 62c70da0c92..3e4d5baa9ba 100644 --- a/lisp/progmodes/ada-mode.el +++ b/lisp/progmodes/ada-mode.el | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | ;;; ada-mode.el --- major-mode for editing Ada sources | 1 | ;;; ada-mode.el --- major-mode for editing Ada sources |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994, 95, 97, 98, 99, 2000, 2001 | 3 | ;; Copyright (C) 1994, 95, 97, 98, 99, 2000, 2001, 2002 |
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; Free Software Foundation, Inc. |
| 5 | 5 | ||
| 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: Emmanuel Briot <briot@gnat.com> |
| 10 | ;; Ada Core Technologies's version: $Revision: 1.49 $ | 10 | ;; Ada Core Technologies's version: Revision: 1.164.2.2 (GNAT 3.15) |
| 11 | ;; Keywords: languages ada | 11 | ;; Keywords: languages ada |
| 12 | 12 | ||
| 13 | ;; This file is part of GNU Emacs. | 13 | ;; This file is part of GNU Emacs. |
| @@ -156,8 +156,8 @@ If IS-XEMACS is non-nil, check for XEmacs instead of Emacs." | |||
| 156 | 156 | ||
| 157 | ;; This call should not be made in the release that is done for the | 157 | ;; This call should not be made in the release that is done for the |
| 158 | ;; official Emacs, since it does nothing useful for the latest version | 158 | ;; official Emacs, since it does nothing useful for the latest version |
| 159 | (if (not (ada-check-emacs-version 21 1)) | 159 | ;; (if (not (ada-check-emacs-version 21 1)) |
| 160 | (require 'ada-support)) | 160 | ;; (require 'ada-support)) |
| 161 | 161 | ||
| 162 | (defvar ada-mode-hook nil | 162 | (defvar ada-mode-hook nil |
| 163 | "*List of functions to call when Ada mode is invoked. | 163 | "*List of functions to call when Ada mode is invoked. |
| @@ -192,6 +192,15 @@ An example is : | |||
| 192 | >>>>>>>>>Value); -- from ada-broken-indent" | 192 | >>>>>>>>>Value); -- from ada-broken-indent" |
| 193 | :type 'integer :group 'ada) | 193 | :type 'integer :group 'ada) |
| 194 | 194 | ||
| 195 | (defcustom ada-continuation-indent ada-broken-indent | ||
| 196 | "*Number of columns to indent the continuation of broken lines in | ||
| 197 | parenthesis. | ||
| 198 | |||
| 199 | An example is : | ||
| 200 | Func (Param1, | ||
| 201 | >>>>>Param2);" | ||
| 202 | :type 'integer :group 'ada) | ||
| 203 | |||
| 195 | (defcustom ada-case-attribute 'ada-capitalize-word | 204 | (defcustom ada-case-attribute 'ada-capitalize-word |
| 196 | "*Function to call to adjust the case of Ada attributes. | 205 | "*Function to call to adjust the case of Ada attributes. |
| 197 | It may be `downcase-word', `upcase-word', `ada-loose-case-word', | 206 | It may be `downcase-word', `upcase-word', `ada-loose-case-word', |
| @@ -349,7 +358,9 @@ with `ada-fill-comment-paragraph-postfix'." | |||
| 349 | An example is: | 358 | An example is: |
| 350 | procedure Foo is | 359 | procedure Foo is |
| 351 | begin | 360 | begin |
| 352 | >>>>>>>>>>>>Label: -- from ada-label-indent" | 361 | >>>>>>>>>>>>Label: -- from ada-label-indent |
| 362 | |||
| 363 | This is also used for <<..>> labels" | ||
| 353 | :type 'integer :group 'ada) | 364 | :type 'integer :group 'ada) |
| 354 | 365 | ||
| 355 | (defcustom ada-language-version 'ada95 | 366 | (defcustom ada-language-version 'ada95 |
| @@ -669,6 +680,8 @@ Modify this variable if you want to restore the point to another position.") | |||
| 669 | :included (functionp 'ada-xref-goto-previous-reference)] | 680 | :included (functionp 'ada-xref-goto-previous-reference)] |
| 670 | ["List References" ada-find-references | 681 | ["List References" ada-find-references |
| 671 | :included ada-contextual-menu-on-identifier] | 682 | :included ada-contextual-menu-on-identifier] |
| 683 | ["List Local References" ada-find-local-references | ||
| 684 | :included ada-contextual-menu-on-identifier] | ||
| 672 | ["-" nil nil] | 685 | ["-" nil nil] |
| 673 | ["Other File" ff-find-other-file] | 686 | ["Other File" ff-find-other-file] |
| 674 | ["Goto Parent Unit" ada-goto-parent] | 687 | ["Goto Parent Unit" ada-goto-parent] |
| @@ -699,6 +712,10 @@ Modify this variable if you want to restore the point to another position.") | |||
| 699 | '(menu-item "List References" | 712 | '(menu-item "List References" |
| 700 | ada-find-references | 713 | ada-find-references |
| 701 | :visible ada-contextual-menu-on-identifier) t) | 714 | :visible ada-contextual-menu-on-identifier) t) |
| 715 | (define-key-after map [List-Local] | ||
| 716 | '(menu-item "List Local References" | ||
| 717 | ada-find-local-references | ||
| 718 | :visible ada-contextual-menu-on-identifier) t) | ||
| 702 | (define-key-after map [-] '("-" nil) t) | 719 | (define-key-after map [-] '("-" nil) t) |
| 703 | )) | 720 | )) |
| 704 | (define-key-after map [Other] '("Other file" . ff-find-other-file) t) | 721 | (define-key-after map [Other] '("Other file" . ff-find-other-file) t) |
| @@ -940,6 +957,7 @@ as numbers instead of gnatprep comments." | |||
| 940 | ;; Setting this only if font-lock is not set won't work | 957 | ;; Setting this only if font-lock is not set won't work |
| 941 | ;; if the user activates or deactivates font-lock-mode, | 958 | ;; if the user activates or deactivates font-lock-mode, |
| 942 | ;; but will make things faster most of the time | 959 | ;; but will make things faster most of the time |
| 960 | (make-local-hook 'after-change-functions) | ||
| 943 | (add-hook 'after-change-functions 'ada-after-change-function nil t) | 961 | (add-hook 'after-change-functions 'ada-after-change-function nil t) |
| 944 | ))) | 962 | ))) |
| 945 | 963 | ||
| @@ -1085,7 +1103,7 @@ name" | |||
| 1085 | ;;;###autoload | 1103 | ;;;###autoload |
| 1086 | (defun ada-mode () | 1104 | (defun ada-mode () |
| 1087 | "Ada mode is the major mode for editing Ada code. | 1105 | "Ada mode is the major mode for editing Ada code. |
| 1088 | This version was built on $Date: 2002/04/09 18:50:17 $. | 1106 | This version was built on Date: 2002/05/21 11:58:02 . |
| 1089 | 1107 | ||
| 1090 | Bindings are as follows: (Note: 'LFD' is control-j.) | 1108 | Bindings are as follows: (Note: 'LFD' is control-j.) |
| 1091 | \\{ada-mode-map} | 1109 | \\{ada-mode-map} |
| @@ -1290,14 +1308,50 @@ If you use ada-xref.el: | |||
| 1290 | (progn | 1308 | (progn |
| 1291 | (add-to-list 'align-dq-string-modes 'ada-mode) | 1309 | (add-to-list 'align-dq-string-modes 'ada-mode) |
| 1292 | (add-to-list 'align-open-comment-modes 'ada-mode) | 1310 | (add-to-list 'align-open-comment-modes 'ada-mode) |
| 1293 | (set 'align-mode-rules-list ada-align-modes) | ||
| 1294 | (set (make-variable-buffer-local 'align-region-separate) | 1311 | (set (make-variable-buffer-local 'align-region-separate) |
| 1295 | ada-align-region-separate) | 1312 | ada-align-region-separate) |
| 1296 | )) | ||
| 1297 | 1313 | ||
| 1298 | ;; Support for which-function-mode is provided in ada-support (support | 1314 | ;; Exclude comments alone on line from alignment. |
| 1299 | ;; for nested subprograms) | 1315 | (add-to-list 'align-exclude-rules-list |
| 1316 | '(ada-solo-comment | ||
| 1317 | (regexp . "^\\(\\s-*\\)--") | ||
| 1318 | (modes . '(ada-mode)))) | ||
| 1319 | (add-to-list 'align-exclude-rules-list | ||
| 1320 | '(ada-solo-use | ||
| 1321 | (regexp . "^\\(\\s-*\\)\\<use\\>") | ||
| 1322 | (modes . '(ada-mode)))) | ||
| 1323 | |||
| 1324 | (setq ada-align-modes nil) | ||
| 1325 | |||
| 1326 | (add-to-list 'ada-align-modes | ||
| 1327 | '(ada-declaration-assign | ||
| 1328 | (regexp . "[^:]\\(\\s-*\\):[^:]") | ||
| 1329 | (valid . (lambda() (not (ada-in-comment-p)))) | ||
| 1330 | (repeat . t) | ||
| 1331 | (modes . '(ada-mode)))) | ||
| 1332 | (add-to-list 'ada-align-modes | ||
| 1333 | '(ada-associate | ||
| 1334 | (regexp . "[^=]\\(\\s-*\\)=>") | ||
| 1335 | (valid . (lambda() (not (ada-in-comment-p)))) | ||
| 1336 | (modes . '(ada-mode)))) | ||
| 1337 | (add-to-list 'ada-align-modes | ||
| 1338 | '(ada-comment | ||
| 1339 | (regexp . "\\(\\s-*\\)--") | ||
| 1340 | (modes . '(ada-mode)))) | ||
| 1341 | (add-to-list 'ada-align-modes | ||
| 1342 | '(ada-use | ||
| 1343 | (regexp . "\\(\\s-*\\)\\<use\\s-") | ||
| 1344 | (valid . (lambda() (not (ada-in-comment-p)))) | ||
| 1345 | (modes . '(ada-mode)))) | ||
| 1346 | (add-to-list 'ada-align-modes | ||
| 1347 | '(ada-at | ||
| 1348 | (regexp . "\\(\\s-+\\)at\\>") | ||
| 1349 | (modes . '(ada-mode)))) | ||
| 1300 | 1350 | ||
| 1351 | |||
| 1352 | (setq align-mode-rules-list ada-align-modes) | ||
| 1353 | )) | ||
| 1354 | |||
| 1301 | ;; Set up the contextual menu | 1355 | ;; Set up the contextual menu |
| 1302 | (if ada-popup-key | 1356 | (if ada-popup-key |
| 1303 | (define-key ada-mode-map ada-popup-key 'ada-popup-menu)) | 1357 | (define-key ada-mode-map ada-popup-key 'ada-popup-menu)) |
| @@ -1306,6 +1360,30 @@ If you use ada-xref.el: | |||
| 1306 | (define-abbrev-table 'ada-mode-abbrev-table ()) | 1360 | (define-abbrev-table 'ada-mode-abbrev-table ()) |
| 1307 | (setq local-abbrev-table ada-mode-abbrev-table) | 1361 | (setq local-abbrev-table ada-mode-abbrev-table) |
| 1308 | 1362 | ||
| 1363 | ;; Support for which-function mode | ||
| 1364 | ;; which-function-mode does not work with nested subprograms, since it is | ||
| 1365 | ;; based only on the regexps generated by imenu, and thus can only detect the | ||
| 1366 | ;; beginning of subprograms, not the end. | ||
| 1367 | ;; Fix is: redefine a new function ada-which-function, and call it when the | ||
| 1368 | ;; major-mode is ada-mode. | ||
| 1369 | |||
| 1370 | (unless ada-xemacs | ||
| 1371 | ;; This function do not require that we load which-func now. | ||
| 1372 | ;; This can be done by the user if he decides to use which-func-mode | ||
| 1373 | |||
| 1374 | (defadvice which-function (around ada-which-function activate) | ||
| 1375 | "In Ada buffers, should work with overloaded subprograms, and does not | ||
| 1376 | use imenu." | ||
| 1377 | (if (equal major-mode 'ada-mode) | ||
| 1378 | (set 'ad-return-value (ada-which-function)) | ||
| 1379 | ad-do-it)) | ||
| 1380 | |||
| 1381 | ;; So that we can activate which-func-modes for Ada mode | ||
| 1382 | (if (and (boundp 'which-func-modes) | ||
| 1383 | (listp which-func-modes)) | ||
| 1384 | (add-to-list 'which-func-modes 'ada-mode)) | ||
| 1385 | ) | ||
| 1386 | |||
| 1309 | ;; Support for indent-new-comment-line (Especially for XEmacs) | 1387 | ;; Support for indent-new-comment-line (Especially for XEmacs) |
| 1310 | (setq comment-multi-line nil) | 1388 | (setq comment-multi-line nil) |
| 1311 | 1389 | ||
| @@ -1321,7 +1399,7 @@ If you use ada-xref.el: | |||
| 1321 | (if ada-clean-buffer-before-saving | 1399 | (if ada-clean-buffer-before-saving |
| 1322 | (progn | 1400 | (progn |
| 1323 | ;; remove all spaces at the end of lines in the whole buffer. | 1401 | ;; remove all spaces at the end of lines in the whole buffer. |
| 1324 | (add-hook 'local-write-file-hooks 'delete-trailing-whitespace) | 1402 | (add-hook 'local-write-file-hooks 'delete-trailing-whitespace) |
| 1325 | ;; convert all tabs to the correct number of spaces. | 1403 | ;; convert all tabs to the correct number of spaces. |
| 1326 | (add-hook 'local-write-file-hooks | 1404 | (add-hook 'local-write-file-hooks |
| 1327 | (lambda () (untabify (point-min) (point-max)))))) | 1405 | (lambda () (untabify (point-min) (point-max)))))) |
| @@ -2137,7 +2215,7 @@ This function is intended to be bound to the \C-m and \C-j keys." | |||
| 2137 | 2215 | ||
| 2138 | (let ((line (save-excursion | 2216 | (let ((line (save-excursion |
| 2139 | (goto-char (car cur-indent)) | 2217 | (goto-char (car cur-indent)) |
| 2140 | (count-lines (point-min) (point))))) | 2218 | (count-lines 1 (point))))) |
| 2141 | 2219 | ||
| 2142 | (if (equal (cdr cur-indent) '(0)) | 2220 | (if (equal (cdr cur-indent) '(0)) |
| 2143 | (message (concat "same indentation as line " (number-to-string line))) | 2221 | (message (concat "same indentation as line " (number-to-string line))) |
| @@ -2289,26 +2367,25 @@ offset." | |||
| 2289 | ;; ??? Could use a different variable | 2367 | ;; ??? Could use a different variable |
| 2290 | (list column 'ada-broken-indent) | 2368 | (list column 'ada-broken-indent) |
| 2291 | 2369 | ||
| 2292 | ;; Correctly indent named parameter lists ("name => ...") for | 2370 | ;; We want all continuation lines to be indented the same |
| 2293 | ;; all the following lines | 2371 | ;; (ada-broken-line from the opening parenthesis. However, in |
| 2294 | (goto-char column) | 2372 | ;; parameter list, each new parameter should be indented at the |
| 2295 | (if (and (progn (forward-comment 1000) | 2373 | ;; column as the opening parenthesis. |
| 2296 | (looking-at "\\sw+\\s *=>")) | 2374 | |
| 2297 | (progn (goto-char orgpoint) | 2375 | ;; A special case to handle nested boolean expressions, as in |
| 2298 | (forward-comment 1000) | 2376 | ;; ((B |
| 2299 | (not (looking-at "\\sw+\\s *=>")))) | 2377 | ;; and then C) -- indented by ada-broken-indent |
| 2300 | (list column 'ada-broken-indent) | 2378 | ;; or else D) -- indenting this line. |
| 2301 | 2379 | ;; ??? This is really a hack, we should have a proper way to go to | |
| 2302 | ;; ??? Would be nice that lines like | 2380 | ;; ??? the beginning of the statement |
| 2303 | ;; A | 2381 | |
| 2304 | ;; (B, | 2382 | (if (= (char-before) ?\)) |
| 2305 | ;; C | 2383 | (backward-sexp)) |
| 2306 | ;; (E)); -- would be nice if this was correctly indented | 2384 | |
| 2307 | ; (if (= (char-before (1- orgpoint)) ?,) | 2385 | (if (memq (char-before) '(?, ?\; ?\( ?\))) |
| 2308 | (list column 0) | 2386 | (list column 0) |
| 2309 | ; (list column 'ada-broken-indent) | 2387 | (list column 'ada-continuation-indent) |
| 2310 | ; ) | 2388 | ))))) |
| 2311 | ))))) | ||
| 2312 | 2389 | ||
| 2313 | ;;--------------------------- | 2390 | ;;--------------------------- |
| 2314 | ;; at end of buffer | 2391 | ;; at end of buffer |
| @@ -2493,7 +2570,9 @@ offset." | |||
| 2493 | (list (progn (back-to-indentation) (point)) 'ada-indent)) | 2570 | (list (progn (back-to-indentation) (point)) 'ada-indent)) |
| 2494 | (save-excursion | 2571 | (save-excursion |
| 2495 | (ada-goto-stmt-start) | 2572 | (ada-goto-stmt-start) |
| 2496 | (list (progn (back-to-indentation) (point)) 'ada-stmt-end-indent)))) | 2573 | (if (looking-at "\\<package\\|procedure\\|function\\>") |
| 2574 | (list (progn (back-to-indentation) (point)) 0) | ||
| 2575 | (list (progn (back-to-indentation) (point)) 'ada-indent))))) | ||
| 2497 | 2576 | ||
| 2498 | ;;--------------------------- | 2577 | ;;--------------------------- |
| 2499 | ;; starting with r (return, renames) | 2578 | ;; starting with r (return, renames) |
| @@ -2733,6 +2812,12 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation." | |||
| 2733 | ;; | 2812 | ;; |
| 2734 | ((looking-at "separate\\>") | 2813 | ((looking-at "separate\\>") |
| 2735 | (ada-get-indent-nochange)) | 2814 | (ada-get-indent-nochange)) |
| 2815 | |||
| 2816 | ;; A label | ||
| 2817 | ((looking-at "<<") | ||
| 2818 | (list (+ (save-excursion (back-to-indentation) (point)) | ||
| 2819 | (- ada-label-indent)))) | ||
| 2820 | |||
| 2736 | ;; | 2821 | ;; |
| 2737 | ((looking-at "with\\>\\|use\\>") | 2822 | ((looking-at "with\\>\\|use\\>") |
| 2738 | ;; Are we still in that statement, or are we in fact looking at | 2823 | ;; Are we still in that statement, or are we in fact looking at |
| @@ -3346,26 +3431,35 @@ match." | |||
| 3346 | 3431 | ||
| 3347 | (goto-char (car match-dat)) | 3432 | (goto-char (car match-dat)) |
| 3348 | (unless (ada-in-open-paren-p) | 3433 | (unless (ada-in-open-paren-p) |
| 3349 | (if (and (looking-at | 3434 | (cond |
| 3350 | "\\<\\(record\\|loop\\|select\\|else\\|then\\)\\>") | 3435 | |
| 3351 | (save-excursion | 3436 | ((and (looking-at |
| 3352 | (ada-goto-previous-word) | 3437 | "\\<\\(record\\|loop\\|select\\|else\\|then\\)\\>") |
| 3353 | (looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]"))) | 3438 | (save-excursion |
| 3354 | (forward-word -1) | 3439 | (ada-goto-previous-word) |
| 3355 | 3440 | (looking-at "\\<\\(end\\|or\\|and\\)\\>[ \t]*[^;]"))) | |
| 3356 | (save-excursion | 3441 | (forward-word -1)) |
| 3357 | (goto-char (cdr match-dat)) | 3442 | |
| 3358 | (ada-goto-next-non-ws) | 3443 | ((looking-at "is") |
| 3359 | (looking-at "(") | 3444 | (setq found |
| 3360 | ;; words that can go after an 'is' | 3445 | (and (save-excursion (ada-goto-previous-word) |
| 3361 | (unless (looking-at | 3446 | (ada-goto-previous-word) |
| 3362 | (eval-when-compile | 3447 | (not (looking-at "subtype"))) |
| 3363 | (concat "\\<" | 3448 | |
| 3364 | (regexp-opt '("separate" "access" "array" | 3449 | (save-excursion (goto-char (cdr match-dat)) |
| 3365 | "abstract" "new") t) | 3450 | (ada-goto-next-non-ws) |
| 3366 | "\\>\\|("))) | 3451 | ;; words that can go after an 'is' |
| 3367 | (setq found t)))) | 3452 | (not (looking-at |
| 3368 | )) | 3453 | (eval-when-compile |
| 3454 | (concat "\\<" | ||
| 3455 | (regexp-opt | ||
| 3456 | '("separate" "access" "array" | ||
| 3457 | "abstract" "new") t) | ||
| 3458 | "\\>\\|(")))))))) | ||
| 3459 | |||
| 3460 | (t | ||
| 3461 | (setq found t)) | ||
| 3462 | ))) | ||
| 3369 | 3463 | ||
| 3370 | (if found | 3464 | (if found |
| 3371 | match-dat | 3465 | match-dat |
| @@ -3702,8 +3796,7 @@ If GOTOTHEN is non-nil, point moves to the 'then' following 'if'." | |||
| 3702 | (error (concat | 3796 | (error (concat |
| 3703 | "No matching 'is' or 'renames' for 'package' at" | 3797 | "No matching 'is' or 'renames' for 'package' at" |
| 3704 | " line " | 3798 | " line " |
| 3705 | (number-to-string (count-lines (point-min) | 3799 | (number-to-string (count-lines 1 (1+ current))))))) |
| 3706 | (1+ current))))))) | ||
| 3707 | (unless (looking-at "renames") | 3800 | (unless (looking-at "renames") |
| 3708 | (progn | 3801 | (progn |
| 3709 | (forward-word 1) | 3802 | (forward-word 1) |
| @@ -3814,7 +3907,7 @@ If NOERROR is non-nil, it only returns nil if found no matching start." | |||
| 3814 | ;; in the nesting loop below, so we just make sure we don't count it. | 3907 | ;; in the nesting loop below, so we just make sure we don't count it. |
| 3815 | ;; "declare" is a special case because we need to look after the "begin" | 3908 | ;; "declare" is a special case because we need to look after the "begin" |
| 3816 | ;; keyword | 3909 | ;; keyword |
| 3817 | (if (and (not first) (looking-at regex)) | 3910 | (if (looking-at "\\<if\\|loop\\|case\\>") |
| 3818 | (forward-char 1)) | 3911 | (forward-char 1)) |
| 3819 | 3912 | ||
| 3820 | ;; | 3913 | ;; |
| @@ -4306,9 +4399,10 @@ Moves to 'begin' if in a declarative part." | |||
| 4306 | (save-excursion | 4399 | (save-excursion |
| 4307 | 4400 | ||
| 4308 | (cond | 4401 | (cond |
| 4402 | ;; Go to the beginning of the current word, and check if we are | ||
| 4309 | ;; directly on 'begin' | 4403 | ;; directly on 'begin' |
| 4310 | ((save-excursion | 4404 | ((save-excursion |
| 4311 | (ada-goto-previous-word) | 4405 | (skip-syntax-backward "w") |
| 4312 | (looking-at "\\<begin\\>")) | 4406 | (looking-at "\\<begin\\>")) |
| 4313 | (ada-goto-matching-end 1)) | 4407 | (ada-goto-matching-end 1)) |
| 4314 | 4408 | ||
| @@ -4344,6 +4438,12 @@ Moves to 'begin' if in a declarative part." | |||
| 4344 | (setq decl-start (and (ada-goto-matching-decl-start t) (point))) | 4438 | (setq decl-start (and (ada-goto-matching-decl-start t) (point))) |
| 4345 | (and decl-start (looking-at "\\<package\\>"))) | 4439 | (and decl-start (looking-at "\\<package\\>"))) |
| 4346 | (ada-goto-matching-end 1)) | 4440 | (ada-goto-matching-end 1)) |
| 4441 | |||
| 4442 | ;; On a "declare" keyword | ||
| 4443 | ((save-excursion | ||
| 4444 | (skip-syntax-backward "w") | ||
| 4445 | (looking-at "\\<declare\\>")) | ||
| 4446 | (ada-goto-matching-end 0 t)) | ||
| 4347 | 4447 | ||
| 4348 | ;; inside a 'begin' ... 'end' block | 4448 | ;; inside a 'begin' ... 'end' block |
| 4349 | (decl-start | 4449 | (decl-start |
| @@ -4530,7 +4630,7 @@ can add its own items." | |||
| 4530 | ;; function for justifying the comments. | 4630 | ;; function for justifying the comments. |
| 4531 | ;; ------------------------------------------------------- | 4631 | ;; ------------------------------------------------------- |
| 4532 | 4632 | ||
| 4533 | (defadvice comment-region (before ada-uncomment-anywhere) | 4633 | (defadvice comment-region (before ada-uncomment-anywhere disable) |
| 4534 | (if (and arg | 4634 | (if (and arg |
| 4535 | (listp arg) ;; a prefix with \C-u is of the form '(4), whereas | 4635 | (listp arg) ;; a prefix with \C-u is of the form '(4), whereas |
| 4536 | ;; \C-u 2 sets arg to '2' (fixed by S.Leake) | 4636 | ;; \C-u 2 sets arg to '2' (fixed by S.Leake) |
| @@ -4553,7 +4653,8 @@ can add its own items." | |||
| 4553 | (ad-activate 'comment-region) | 4653 | (ad-activate 'comment-region) |
| 4554 | (comment-region beg end (- (or arg 2))) | 4654 | (comment-region beg end (- (or arg 2))) |
| 4555 | (ad-deactivate 'comment-region)) | 4655 | (ad-deactivate 'comment-region)) |
| 4556 | (comment-region beg end (list (- (or arg 2)))))) | 4656 | (comment-region beg end (list (- (or arg 2)))) |
| 4657 | (ada-indent-region beg end))) | ||
| 4557 | 4658 | ||
| 4558 | (defun ada-fill-comment-paragraph-justify () | 4659 | (defun ada-fill-comment-paragraph-justify () |
| 4559 | "Fills current comment paragraph and justifies each line as well." | 4660 | "Fills current comment paragraph and justifies each line as well." |
| @@ -4579,10 +4680,8 @@ The paragraph is indented on the first line." | |||
| 4579 | (not (looking-at "[ \t]*--"))) | 4680 | (not (looking-at "[ \t]*--"))) |
| 4580 | (error "not inside comment")) | 4681 | (error "not inside comment")) |
| 4581 | 4682 | ||
| 4582 | (let* ((indent) | 4683 | (let* (indent from to |
| 4583 | (from) | 4684 | (opos (point-marker)) |
| 4584 | (to) | ||
| 4585 | (opos (point-marker)) | ||
| 4586 | 4685 | ||
| 4587 | ;; Sets this variable to nil, otherwise it prevents | 4686 | ;; Sets this variable to nil, otherwise it prevents |
| 4588 | ;; fill-region-as-paragraph to work on Emacs <= 20.2 | 4687 | ;; fill-region-as-paragraph to work on Emacs <= 20.2 |
| @@ -4593,7 +4692,7 @@ The paragraph is indented on the first line." | |||
| 4593 | 4692 | ||
| 4594 | ;; Find end of paragraph | 4693 | ;; Find end of paragraph |
| 4595 | (back-to-indentation) | 4694 | (back-to-indentation) |
| 4596 | (while (and (not (eobp)) (looking-at "--[ \t]*[^ \t\n]")) | 4695 | (while (and (not (eobp)) (looking-at ".*--[ \t]*[^ \t\n]")) |
| 4597 | (forward-line 1) | 4696 | (forward-line 1) |
| 4598 | 4697 | ||
| 4599 | ;; If we were at the last line in the buffer, create a dummy empty | 4698 | ;; If we were at the last line in the buffer, create a dummy empty |
| @@ -4607,11 +4706,11 @@ The paragraph is indented on the first line." | |||
| 4607 | 4706 | ||
| 4608 | ;; Find beginning of paragraph | 4707 | ;; Find beginning of paragraph |
| 4609 | (back-to-indentation) | 4708 | (back-to-indentation) |
| 4610 | (while (and (not (bobp)) (looking-at "--[ \t]*[^ \t\n]")) | 4709 | (while (and (not (bobp)) (looking-at ".*--[ \t]*[^ \t\n]")) |
| 4611 | (forward-line -1) | 4710 | (forward-line -1) |
| 4612 | (back-to-indentation)) | 4711 | (back-to-indentation)) |
| 4613 | 4712 | ||
| 4614 | ;; We want one line to above the first one, unless we are at the beginning | 4713 | ;; We want one line above the first one, unless we are at the beginning |
| 4615 | ;; of the buffer | 4714 | ;; of the buffer |
| 4616 | (unless (bobp) | 4715 | (unless (bobp) |
| 4617 | (forward-line 1)) | 4716 | (forward-line 1)) |
| @@ -4629,13 +4728,6 @@ The paragraph is indented on the first line." | |||
| 4629 | (while (re-search-forward "--\n" to t) | 4728 | (while (re-search-forward "--\n" to t) |
| 4630 | (replace-match "\n")) | 4729 | (replace-match "\n")) |
| 4631 | 4730 | ||
| 4632 | ;; Remove the old prefixes (so that the number of spaces after -- is not | ||
| 4633 | ;; relevant), except on the first one since `fill-region-as-paragraph' | ||
| 4634 | ;; would not put it back on the first line. | ||
| 4635 | (goto-char (+ from 2)) | ||
| 4636 | (while (re-search-forward "^-- *" to t) | ||
| 4637 | (replace-match " ")) | ||
| 4638 | |||
| 4639 | (goto-char (1- to)) | 4731 | (goto-char (1- to)) |
| 4640 | (setq to (point-marker)) | 4732 | (setq to (point-marker)) |
| 4641 | 4733 | ||
| @@ -4777,10 +4869,10 @@ Redefines the function `ff-which-function-are-we-in'." | |||
| 4777 | (defun ada-which-function () | 4869 | (defun ada-which-function () |
| 4778 | "Returns the name of the function whose body the point is in. | 4870 | "Returns the name of the function whose body the point is in. |
| 4779 | This function works even in the case of nested subprograms, whereas the | 4871 | This function works even in the case of nested subprograms, whereas the |
| 4780 | standard Emacs function which-function does not. | 4872 | standard Emacs function `which-function' does not. |
| 4781 | Since the search can be long, the results are cached." | 4873 | Since the search can be long, the results are cached." |
| 4782 | 4874 | ||
| 4783 | (let ((line (count-lines (point-min) (point))) | 4875 | (let ((line (count-lines 1 (point))) |
| 4784 | (pos (point)) | 4876 | (pos (point)) |
| 4785 | end-pos | 4877 | end-pos |
| 4786 | func-name indent | 4878 | func-name indent |
| @@ -4798,7 +4890,7 @@ Since the search can be long, the results are cached." | |||
| 4798 | (skip-chars-forward " \t\n(") | 4890 | (skip-chars-forward " \t\n(") |
| 4799 | 4891 | ||
| 4800 | (condition-case nil | 4892 | (condition-case nil |
| 4801 | (up-list) | 4893 | (up-list 1) |
| 4802 | (error nil)) | 4894 | (error nil)) |
| 4803 | 4895 | ||
| 4804 | (skip-chars-forward " \t\n") | 4896 | (skip-chars-forward " \t\n") |