aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Leake2010-01-19 00:10:57 +0100
committerJuanma Barranquero2010-01-19 00:10:57 +0100
commit6a47c86a180882432ea34fcb0f7da8f4c27dd61e (patch)
tree1ae8bb5af16cfe8e79b023504e4ec45e924aff00
parente90d57c003fef970d36024fc2605f0ec23f699c0 (diff)
downloademacs-6a47c86a180882432ea34fcb0f7da8f4c27dd61e.tar.gz
emacs-6a47c86a180882432ea34fcb0f7da8f4c27dd61e.zip
* ada-mode.el: Really fix bug#5400 (comment in 2010-01-17T19:15:32Z!lekktu@gmail.com was erroneous).
(ada-matching-decl-start-re): Move into ada-goto-decl-start. (ada-goto-decl-start): Rename from ada-goto-matching-decl-start; callers changed. Delete RECURSIVE parameter; never used. Improve doc string. Improve comments in "is" portion. Handle null procedure declaration. (ada-move-to-end): Improve doc string.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/progmodes/ada-mode.el108
2 files changed, 70 insertions, 49 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cc4c40668fd..f9e55700c10 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12010-01-18 Stephen Leake <stephen_leake@member.fsf.org>
2
3 * lisp/progmodes/ada-mode.el: Fix bug#5400.
4 (ada-matching-decl-start-re): Move into ada-goto-decl-start.
5 (ada-goto-decl-start): Rename from ada-goto-matching-decl-start; callers
6 changed. Delete RECURSIVE parameter; never used. Improve doc string.
7 Improve comments in "is" portion. Handle null procedure declaration.
8 (ada-move-to-end): Improve doc string.
9
12010-01-18 Óscar Fuentes <ofv@wanadoo.es> 102010-01-18 Óscar Fuentes <ofv@wanadoo.es>
2 11
3 * ido.el (ido-cur-list): Initialize to nil. 12 * ido.el (ido-cur-list): Initialize to nil.
@@ -108,7 +117,7 @@
108 117
1092010-01-17 Stephen Leake <stephen_leake@member.fsf.org> 1182010-01-17 Stephen Leake <stephen_leake@member.fsf.org>
110 119
111 * progmodes/ada-mode.el: Fix bug#1920, bug#5400. 120 * progmodes/ada-mode.el: Fix bug#1920.
112 (ada-ident-re): Delete ., allow multibyte characters. 121 (ada-ident-re): Delete ., allow multibyte characters.
113 (ada-goto-label-re): New; matches goto labels. 122 (ada-goto-label-re): New; matches goto labels.
114 (ada-block-label-re): New; matches block labels. 123 (ada-block-label-re): New; matches block labels.
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el
index 03fec1beb77..3694de23f88 100644
--- a/lisp/progmodes/ada-mode.el
+++ b/lisp/progmodes/ada-mode.el
@@ -677,14 +677,6 @@ A new statement starts after these.")
677 "\\>")) 677 "\\>"))
678 "Regexp used in `ada-goto-matching-start'.") 678 "Regexp used in `ada-goto-matching-start'.")
679 679
680(defvar ada-matching-decl-start-re
681 (eval-when-compile
682 (concat "\\<"
683 (regexp-opt
684 '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t)
685 "\\>"))
686 "Regexp used in `ada-goto-matching-decl-start'.")
687
688(defvar ada-loop-start-re 680(defvar ada-loop-start-re
689 "\\<\\(for\\|while\\|loop\\)\\>" 681 "\\<\\(for\\|while\\|loop\\)\\>"
690 "Regexp for the start of a loop.") 682 "Regexp for the start of a loop.")
@@ -2476,7 +2468,7 @@ and the offset."
2476 ((and (= (downcase (char-after)) ?b) 2468 ((and (= (downcase (char-after)) ?b)
2477 (looking-at "begin\\>")) 2469 (looking-at "begin\\>"))
2478 (save-excursion 2470 (save-excursion
2479 (if (ada-goto-matching-decl-start t) 2471 (if (ada-goto-decl-start t)
2480 (list (progn (back-to-indentation) (point)) 0) 2472 (list (progn (back-to-indentation) (point)) 0)
2481 (ada-indent-on-previous-lines nil orgpoint orgpoint)))) 2473 (ada-indent-on-previous-lines nil orgpoint orgpoint))))
2482 2474
@@ -2855,7 +2847,7 @@ ORGPOINT is the limit position used in the calculation."
2855 (if (looking-at "\\<begin\\>") 2847 (if (looking-at "\\<begin\\>")
2856 (progn 2848 (progn
2857 (setq indent (list (point) 0)) 2849 (setq indent (list (point) 0))
2858 (if (ada-goto-matching-decl-start t) 2850 (if (ada-goto-decl-start t)
2859 (list (progn (back-to-indentation) (point)) 0) 2851 (list (progn (back-to-indentation) (point)) 0)
2860 indent)) 2852 indent))
2861 (list (progn (back-to-indentation) (point)) 0) 2853 (list (progn (back-to-indentation) (point)) 0)
@@ -3421,7 +3413,6 @@ is the end of the match."
3421 match-dat 3413 match-dat
3422 nil))) 3414 nil)))
3423 3415
3424
3425(defun ada-goto-next-non-ws (&optional limit skip-goto-label) 3416(defun ada-goto-next-non-ws (&optional limit skip-goto-label)
3426 "Skip to next non-whitespace character. 3417 "Skip to next non-whitespace character.
3427Skips spaces, newlines and comments, and possibly goto labels. 3418Skips spaces, newlines and comments, and possibly goto labels.
@@ -3502,13 +3493,13 @@ Moves point to the beginning of the declaration."
3502 (if (save-excursion 3493 (if (save-excursion
3503 (ada-goto-previous-word) 3494 (ada-goto-previous-word)
3504 (looking-at (concat "\\<" defun-name "\\> *:"))) 3495 (looking-at (concat "\\<" defun-name "\\> *:")))
3505 t ; do nothing 3496 t ; name matches
3506 ;; else 3497 ;; else
3507 ;; 3498 ;;
3508 ;; 'accept' or 'package' ? 3499 ;; 'accept' or 'package' ?
3509 ;; 3500 ;;
3510 (unless (looking-at ada-subprog-start-re) 3501 (unless (looking-at ada-subprog-start-re)
3511 (ada-goto-matching-decl-start)) 3502 (ada-goto-decl-start))
3512 ;; 3503 ;;
3513 ;; 'begin' of 'procedure'/'function'/'task' or 'declare' 3504 ;; 'begin' of 'procedure'/'function'/'task' or 'declare'
3514 ;; 3505 ;;
@@ -3541,14 +3532,20 @@ Moves point to the beginning of the declaration."
3541 (buffer-substring (point) 3532 (buffer-substring (point)
3542 (progn (forward-sexp 1) (point)))))))) 3533 (progn (forward-sexp 1) (point))))))))
3543 3534
3544(defun ada-goto-matching-decl-start (&optional noerror recursive) 3535(defun ada-goto-decl-start (&optional noerror)
3545 "Move point to the matching declaration start of the current 'begin'. 3536 "Move point to the declaration start of the current construct.
3546If NOERROR is non-nil, it only returns nil if no match was found." 3537If NOERROR is non-nil, return nil if no match was found;
3538otherwise throw error."
3547 (let ((nest-count 1) 3539 (let ((nest-count 1)
3540 (regexp (eval-when-compile
3541 (concat "\\<"
3542 (regexp-opt
3543 '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t)
3544 "\\>")))
3548 3545
3549 ;; first should be set to t if we should stop at the first 3546 ;; first should be set to t if we should stop at the first
3550 ;; "begin" we encounter. 3547 ;; "begin" we encounter.
3551 (first (not recursive)) 3548 (first t)
3552 (count-generic nil) 3549 (count-generic nil)
3553 (stop-at-when nil) 3550 (stop-at-when nil)
3554 ) 3551 )
@@ -3572,7 +3569,7 @@ If NOERROR is non-nil, it only returns nil if no match was found."
3572 ;; search backward for interesting keywords 3569 ;; search backward for interesting keywords
3573 (while (and 3570 (while (and
3574 (not (zerop nest-count)) 3571 (not (zerop nest-count))
3575 (ada-search-ignore-string-comment ada-matching-decl-start-re t)) 3572 (ada-search-ignore-string-comment regexp t))
3576 ;; 3573 ;;
3577 ;; calculate nest-depth 3574 ;; calculate nest-depth
3578 ;; 3575 ;;
@@ -3605,7 +3602,6 @@ If NOERROR is non-nil, it only returns nil if no match was found."
3605 3602
3606 (if (looking-at "end") 3603 (if (looking-at "end")
3607 (ada-goto-matching-start 1 noerror t) 3604 (ada-goto-matching-start 1 noerror t)
3608 ;; (ada-goto-matching-decl-start noerror t)
3609 3605
3610 (setq loop-again nil) 3606 (setq loop-again nil)
3611 (unless (looking-at "begin") 3607 (unless (looking-at "begin")
@@ -3633,34 +3629,50 @@ If NOERROR is non-nil, it only returns nil if no match was found."
3633 (setq first t)) 3629 (setq first t))
3634 ;; 3630 ;;
3635 ((looking-at "is") 3631 ((looking-at "is")
3636 ;; check if it is only a type definition, but not a protected 3632 ;; look for things to ignore
3637 ;; type definition, which should be handled like a procedure. 3633 (if
3638 (if (or (looking-at "is[ \t]+<>") 3634 (or
3639 (save-excursion 3635 ;; generic formal parameter
3640 (forward-comment -10000) 3636 (looking-at "is[ t]+<>")
3641 (forward-char -1) 3637
3642 3638 ;; A type definition, or a case statement. Note that the
3643 ;; Detect if we have a closing parenthesis (Could be 3639 ;; goto-matching-start above on 'end record' leaves us at
3644 ;; either the end of subprogram parameters or (<>) 3640 ;; 'record', not at 'type'.
3645 ;; in a type definition 3641 ;;
3646 (if (= (char-after) ?\)) 3642 ;; We get to a case statement here by calling
3647 (progn 3643 ;; 'ada-move-to-end' from inside a case statement; then
3648 (forward-char 1) 3644 ;; we are not ignoring 'when'.
3649 (backward-sexp 1) 3645 (save-excursion
3650 (forward-comment -10000) 3646 ;; Skip type discriminants or case argument function call param list
3651 )) 3647 (forward-comment -10000)
3652 (skip-chars-backward "a-zA-Z0-9_.'") 3648 (forward-char -1)
3653 (ada-goto-previous-word) 3649 (if (= (char-after) ?\))
3654 (and 3650 (progn
3655 (looking-at "\\<\\(sub\\)?type\\|case\\>") 3651 (forward-char 1)
3652 (backward-sexp 1)
3653 (forward-comment -10000)
3654 ))
3655 ;; skip type or case argument name
3656 (skip-chars-backward "a-zA-Z0-9_.'")
3657 (ada-goto-previous-word)
3658 (and
3659 ;; if it's a protected type, it's the decl start we
3660 ;; are looking for; since we didn't see the 'end'
3661 ;; above, we are inside it.
3662 (looking-at "\\<\\(sub\\)?type\\|case\\>")
3656 (save-match-data 3663 (save-match-data
3657 (ada-goto-previous-word) 3664 (ada-goto-previous-word)
3658 (not (looking-at "\\<protected\\>")))) 3665 (not (looking-at "\\<protected\\>"))))
3659 )) ; end of `or' 3666 ) ; end of type definition p
3660 (goto-char (match-beginning 0)) 3667
3661 (progn 3668 ;; null procedure declaration
3662 (setq nest-count (1- nest-count)) 3669 (save-excursion (ada-goto-next-word) (looking-at "\\<null\\>"))
3663 (setq first nil)))) 3670 );; end or
3671 ;; skip this construct
3672 nil
3673 ;; this is the right "is"
3674 (setq nest-count (1- nest-count))
3675 (setq first nil)))
3664 3676
3665 ;; 3677 ;;
3666 ((looking-at "new") 3678 ((looking-at "new")
@@ -4115,7 +4127,7 @@ Point is moved at the beginning of the SEARCH-RE."
4115Assumes point to be at the end of a statement." 4127Assumes point to be at the end of a statement."
4116 (or (ada-in-paramlist-p) 4128 (or (ada-in-paramlist-p)
4117 (save-excursion 4129 (save-excursion
4118 (ada-goto-matching-decl-start t)))) 4130 (ada-goto-decl-start t))))
4119 4131
4120 4132
4121(defun ada-looking-at-semi-or () 4133(defun ada-looking-at-semi-or ()
@@ -4409,7 +4421,7 @@ of the region. Otherwise, operate only on the current line."
4409 ;; 4421 ;;
4410 ada-move-to-declaration 4422 ada-move-to-declaration
4411 (looking-at "\\<begin\\>") 4423 (looking-at "\\<begin\\>")
4412 (ada-goto-matching-decl-start) 4424 (ada-goto-decl-start)
4413 (setq pos (point)))) 4425 (setq pos (point))))
4414 4426
4415 ) ; end of save-excursion 4427 ) ; end of save-excursion
@@ -4421,7 +4433,7 @@ of the region. Otherwise, operate only on the current line."
4421 (set-syntax-table previous-syntax-table)))) 4433 (set-syntax-table previous-syntax-table))))
4422 4434
4423(defun ada-move-to-end () 4435(defun ada-move-to-end ()
4424 "Move point to the matching end of the block around point. 4436 "Move point to the end of the block around point.
4425Moves to 'begin' if in a declarative part." 4437Moves to 'begin' if in a declarative part."
4426 (interactive) 4438 (interactive)
4427 (let ((pos (point)) 4439 (let ((pos (point))
@@ -4471,7 +4483,7 @@ Moves to 'begin' if in a declarative part."
4471 (ada-goto-matching-end 0)) 4483 (ada-goto-matching-end 0))
4472 ;; package start 4484 ;; package start
4473 ((save-excursion 4485 ((save-excursion
4474 (setq decl-start (and (ada-goto-matching-decl-start t) (point))) 4486 (setq decl-start (and (ada-goto-decl-start t) (point)))
4475 (and decl-start (looking-at "\\<package\\>"))) 4487 (and decl-start (looking-at "\\<package\\>")))
4476 (ada-goto-matching-end 1)) 4488 (ada-goto-matching-end 1))
4477 4489