aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorEli Zaretskii2010-01-22 15:40:56 -0500
committerEli Zaretskii2010-01-22 15:40:56 -0500
commitcf206f28eb11467aed7f5e03f3e4df7724fd98d2 (patch)
tree2f5695e6a774a918874b82c286f140abd052d860 /lisp/progmodes
parent5a876cd5f810b611f78dd4cf7a1673bffeea19a9 (diff)
parentc893016b07f33eb8d56e1011245fe59a67cb4ee0 (diff)
downloademacs-cf206f28eb11467aed7f5e03f3e4df7724fd98d2.tar.gz
emacs-cf206f28eb11467aed7f5e03f3e4df7724fd98d2.zip
Merge from mainline.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/ada-mode.el227
-rw-r--r--lisp/progmodes/cc-defs.el6
-rw-r--r--lisp/progmodes/cc-engine.el11
3 files changed, 150 insertions, 94 deletions
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el
index 2b94fdb25ff..3694de23f88 100644
--- a/lisp/progmodes/ada-mode.el
+++ b/lisp/progmodes/ada-mode.el
@@ -590,8 +590,25 @@ This variable defines several rules to use to align different lines.")
590;; FIXME: make this customizable 590;; FIXME: make this customizable
591 591
592(defconst ada-ident-re 592(defconst ada-ident-re
593 "\\(\\sw\\|[_.]\\)+" 593 "[[:alpha:]]\\(?:[_[:alnum:]]\\)*"
594 "Regexp matching Ada (qualified) identifiers.") 594 ;; [:alnum:] matches any multibyte word constituent, as well as
595 ;; Latin-1 letters and numbers. This allows __ and trailing _;
596 ;; someone (emacs bug#1919) proposed [^\W_] to fix that, but \W does
597 ;; _not_ mean "not word constituent" inside a character alternative.
598 "Regexp matching an Ada identifier.")
599
600(defconst ada-goto-label-re
601 (concat "<<" ada-ident-re ">>")
602 "Regexp matching a goto label.")
603
604(defconst ada-block-label-re
605 (concat ada-ident-re "[ \t\n]*:[^=]")
606 "Regexp matching a block label.
607Note that this also matches a variable declaration.")
608
609(defconst ada-label-re
610 (concat "\\(?:" ada-block-label-re "\\)\\|\\(?:" ada-goto-label-re "\\)")
611 "Regexp matching a goto or block label.")
595 612
596;; "with" needs to be included in the regexp, to match generic subprogram parameters 613;; "with" needs to be included in the regexp, to match generic subprogram parameters
597;; Similarly, we put '[not] overriding' on the same line with 'procedure' etc. 614;; Similarly, we put '[not] overriding' on the same line with 'procedure' etc.
@@ -660,14 +677,6 @@ A new statement starts after these.")
660 "\\>")) 677 "\\>"))
661 "Regexp used in `ada-goto-matching-start'.") 678 "Regexp used in `ada-goto-matching-start'.")
662 679
663(defvar ada-matching-decl-start-re
664 (eval-when-compile
665 (concat "\\<"
666 (regexp-opt
667 '("is" "separate" "end" "declare" "if" "new" "begin" "generic" "when") t)
668 "\\>"))
669 "Regexp used in `ada-goto-matching-decl-start'.")
670
671(defvar ada-loop-start-re 680(defvar ada-loop-start-re
672 "\\<\\(for\\|while\\|loop\\)\\>" 681 "\\<\\(for\\|while\\|loop\\)\\>"
673 "Regexp for the start of a loop.") 682 "Regexp for the start of a loop.")
@@ -678,10 +687,6 @@ A new statement starts after these.")
678 "protected" "task") t) "\\>")) 687 "protected" "task") t) "\\>"))
679 "Regexp for the start of a subprogram.") 688 "Regexp for the start of a subprogram.")
680 689
681(defvar ada-named-block-re
682 "[ \t]*\\(\\sw\\|_\\)+[ \t]*:[^=]"
683 "Regexp of the name of a block or loop.")
684
685(defvar ada-contextual-menu-on-identifier nil 690(defvar ada-contextual-menu-on-identifier nil
686 "Set to true when the right mouse button was clicked on an identifier.") 691 "Set to true when the right mouse button was clicked on an identifier.")
687 692
@@ -2108,10 +2113,18 @@ Return the equivalent internal parameter list."
2108 2113
2109(defun ada-indent-newline-indent-conditional () 2114(defun ada-indent-newline-indent-conditional ()
2110 "Insert a newline and indent it. 2115 "Insert a newline and indent it.
2111The original line is indented first if `ada-indent-after-return' is non-nil." 2116The original line is re-indented if `ada-indent-after-return' is non-nil."
2112 (interactive "*") 2117 (interactive "*")
2113 (if ada-indent-after-return (ada-indent-current)) 2118 ;; If at end of buffer (entering brand new code), some indentation
2119 ;; fails. For example, a block label requires whitespace following
2120 ;; the : to be recognized. So we do the newline first, then
2121 ;; go back and indent the original line.
2114 (newline) 2122 (newline)
2123 (if ada-indent-after-return
2124 (progn
2125 (forward-char -1)
2126 (ada-indent-current)
2127 (forward-char 1)))
2115 (ada-indent-current)) 2128 (ada-indent-current))
2116 2129
2117(defun ada-justified-indent-current () 2130(defun ada-justified-indent-current ()
@@ -2335,8 +2348,8 @@ and the offset."
2335 (progn 2348 (progn
2336 (goto-char (car match-cons)) 2349 (goto-char (car match-cons))
2337 (save-excursion 2350 (save-excursion
2338 (beginning-of-line) 2351 (back-to-indentation)
2339 (if (looking-at ada-named-block-re) 2352 (if (looking-at ada-block-label-re)
2340 (setq label (- ada-label-indent)))))))) 2353 (setq label (- ada-label-indent))))))))
2341 2354
2342 ;; found 'record' => 2355 ;; found 'record' =>
@@ -2455,7 +2468,7 @@ and the offset."
2455 ((and (= (downcase (char-after)) ?b) 2468 ((and (= (downcase (char-after)) ?b)
2456 (looking-at "begin\\>")) 2469 (looking-at "begin\\>"))
2457 (save-excursion 2470 (save-excursion
2458 (if (ada-goto-matching-decl-start t) 2471 (if (ada-goto-decl-start t)
2459 (list (progn (back-to-indentation) (point)) 0) 2472 (list (progn (back-to-indentation) (point)) 0)
2460 (ada-indent-on-previous-lines nil orgpoint orgpoint)))) 2473 (ada-indent-on-previous-lines nil orgpoint orgpoint))))
2461 2474
@@ -2648,8 +2661,9 @@ and the offset."
2648 ;; label 2661 ;; label
2649 ;;--------------------------------- 2662 ;;---------------------------------
2650 2663
2651 ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]") 2664 ((looking-at ada-label-re)
2652 (if (ada-in-decl-p) 2665 (if (ada-in-decl-p)
2666 ;; ada-block-label-re matches variable declarations
2653 (ada-indent-on-previous-lines nil orgpoint orgpoint) 2667 (ada-indent-on-previous-lines nil orgpoint orgpoint)
2654 (append (ada-indent-on-previous-lines nil orgpoint orgpoint) 2668 (append (ada-indent-on-previous-lines nil orgpoint orgpoint)
2655 '(ada-label-indent)))) 2669 '(ada-label-indent))))
@@ -2674,9 +2688,10 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation."
2674 (if (ada-in-paramlist-p) 2688 (if (ada-in-paramlist-p)
2675 (ada-get-indent-paramlist) 2689 (ada-get-indent-paramlist)
2676 2690
2677 ;; move to beginning of current statement 2691 ;; Move to beginning of current statement. If already at a
2692 ;; statement start, move to beginning of enclosing statement.
2678 (unless nomove 2693 (unless nomove
2679 (ada-goto-stmt-start)) 2694 (ada-goto-stmt-start t))
2680 2695
2681 ;; no beginning found => don't change indentation 2696 ;; no beginning found => don't change indentation
2682 (if (and (eq oldpoint (point)) 2697 (if (and (eq oldpoint (point))
@@ -2702,6 +2717,12 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation."
2702 ((looking-at ada-block-start-re) 2717 ((looking-at ada-block-start-re)
2703 (ada-get-indent-block-start orgpoint)) 2718 (ada-get-indent-block-start orgpoint))
2704 ;; 2719 ;;
2720 ((looking-at ada-block-label-re) ; also variable declaration
2721 (ada-get-indent-block-label orgpoint))
2722 ;;
2723 ((looking-at ada-goto-label-re)
2724 (ada-get-indent-goto-label orgpoint))
2725 ;;
2705 ((looking-at "\\(sub\\)?type\\>") 2726 ((looking-at "\\(sub\\)?type\\>")
2706 (ada-get-indent-type orgpoint)) 2727 (ada-get-indent-type orgpoint))
2707 ;; 2728 ;;
@@ -2717,17 +2738,8 @@ if INITIAL-POS is non-nil, moves point to INITIAL-POS before calculation."
2717 ((looking-at "when\\>") 2738 ((looking-at "when\\>")
2718 (ada-get-indent-when orgpoint)) 2739 (ada-get-indent-when orgpoint))
2719 ;; 2740 ;;
2720 ((looking-at "\\(\\sw\\|_\\)+[ \t\n]*:[^=]")
2721 (ada-get-indent-label orgpoint))
2722 ;;
2723 ((looking-at "separate\\>") 2741 ((looking-at "separate\\>")
2724 (ada-get-indent-nochange)) 2742 (ada-get-indent-nochange))
2725
2726 ;; A label
2727 ((looking-at "<<")
2728 (list (+ (save-excursion (back-to-indentation) (point))
2729 (- ada-label-indent))))
2730
2731 ;; 2743 ;;
2732 ((looking-at "with\\>\\|use\\>") 2744 ((looking-at "with\\>\\|use\\>")
2733 ;; Are we still in that statement, or are we in fact looking at 2745 ;; Are we still in that statement, or are we in fact looking at
@@ -2835,7 +2847,7 @@ ORGPOINT is the limit position used in the calculation."
2835 (if (looking-at "\\<begin\\>") 2847 (if (looking-at "\\<begin\\>")
2836 (progn 2848 (progn
2837 (setq indent (list (point) 0)) 2849 (setq indent (list (point) 0))
2838 (if (ada-goto-matching-decl-start t) 2850 (if (ada-goto-decl-start t)
2839 (list (progn (back-to-indentation) (point)) 0) 2851 (list (progn (back-to-indentation) (point)) 0)
2840 indent)) 2852 indent))
2841 (list (progn (back-to-indentation) (point)) 0) 2853 (list (progn (back-to-indentation) (point)) 0)
@@ -2960,6 +2972,10 @@ ORGPOINT is the limit position used in the calculation."
2960 (car (ada-search-ignore-string-comment "\\<type\\>" t))) 2972 (car (ada-search-ignore-string-comment "\\<type\\>" t)))
2961 'ada-indent))) 2973 'ada-indent)))
2962 2974
2975 ;; Special case for label:
2976 ((looking-at ada-block-label-re)
2977 (list (- (save-excursion (back-to-indentation) (point)) ada-label-indent) 'ada-indent))
2978
2963 ;; nothing follows the block-start 2979 ;; nothing follows the block-start
2964 (t 2980 (t
2965 (list (save-excursion (back-to-indentation) (point)) 'ada-indent))))) 2981 (list (save-excursion (back-to-indentation) (point)) 'ada-indent)))))
@@ -3055,10 +3071,10 @@ ORGPOINT is the limit position used in the calculation."
3055 (list (save-excursion (back-to-indentation) (point)) 3071 (list (save-excursion (back-to-indentation) (point))
3056 'ada-broken-decl-indent)) 3072 'ada-broken-decl-indent))
3057 3073
3058 ;; This one is called in every over case when indenting a line at the 3074 ;; This one is called in every other case when indenting a line at the
3059 ;; top level 3075 ;; top level
3060 (t 3076 (t
3061 (if (looking-at ada-named-block-re) 3077 (if (looking-at (concat "[ \t]*" ada-block-label-re))
3062 (setq label (- ada-label-indent)) 3078 (setq label (- ada-label-indent))
3063 3079
3064 (let (p) 3080 (let (p)
@@ -3087,7 +3103,7 @@ ORGPOINT is the limit position used in the calculation."
3087 (list (+ (save-excursion (back-to-indentation) (point)) label) 3103 (list (+ (save-excursion (back-to-indentation) (point)) label)
3088 'ada-broken-indent))))))) 3104 'ada-broken-indent)))))))
3089 3105
3090(defun ada-get-indent-label (orgpoint) 3106(defun ada-get-indent-block-label (orgpoint)
3091 "Calculate the indentation when before a label or variable declaration. 3107 "Calculate the indentation when before a label or variable declaration.
3092ORGPOINT is the limit position used in the calculation." 3108ORGPOINT is the limit position used in the calculation."
3093 (let ((match-cons nil) 3109 (let ((match-cons nil)
@@ -3119,6 +3135,16 @@ ORGPOINT is the limit position used in the calculation."
3119 (t 3135 (t
3120 (list cur-indent '(- ada-label-indent)))))) 3136 (list cur-indent '(- ada-label-indent))))))
3121 3137
3138(defun ada-get-indent-goto-label (orgpoint)
3139 "Calculate the indentation when at a goto label."
3140 (search-forward ">>")
3141 (ada-goto-next-non-ws)
3142 (if (>= (point) orgpoint)
3143 ;; labeled statement is the one we need to indent
3144 (list (- (point) ada-label-indent))
3145 ;; else indentation is indent for labeled statement
3146 (ada-indent-on-previous-lines t orgpoint)))
3147
3122(defun ada-get-indent-loop (orgpoint) 3148(defun ada-get-indent-loop (orgpoint)
3123 "Calculate the indentation when just before a loop or a for ... use. 3149 "Calculate the indentation when just before a loop or a for ... use.
3124ORGPOINT is the limit position used in the calculation." 3150ORGPOINT is the limit position used in the calculation."
@@ -3127,8 +3153,8 @@ ORGPOINT is the limit position used in the calculation."
3127 3153
3128 ;; If looking at a named block, skip the label 3154 ;; If looking at a named block, skip the label
3129 (label (save-excursion 3155 (label (save-excursion
3130 (beginning-of-line) 3156 (back-to-indentation)
3131 (if (looking-at ada-named-block-re) 3157 (if (looking-at ada-block-label-re)
3132 (- ada-label-indent) 3158 (- ada-label-indent)
3133 0)))) 3159 0))))
3134 3160
@@ -3286,7 +3312,7 @@ ORGPOINT is the limit position used in the calculation."
3286;; -- searching and matching 3312;; -- searching and matching
3287;; ----------------------------------------------------------- 3313;; -----------------------------------------------------------
3288 3314
3289(defun ada-goto-stmt-start () 3315(defun ada-goto-stmt-start (&optional ignore-goto-label)
3290 "Move point to the beginning of the statement that point is in or after. 3316 "Move point to the beginning of the statement that point is in or after.
3291Return the new position of point. 3317Return the new position of point.
3292As a special case, if we are looking at a closing parenthesis, skip to the 3318As a special case, if we are looking at a closing parenthesis, skip to the
@@ -3304,7 +3330,7 @@ open parenthesis."
3304 (progn 3330 (progn
3305 (unless (save-excursion 3331 (unless (save-excursion
3306 (goto-char (cdr match-dat)) 3332 (goto-char (cdr match-dat))
3307 (ada-goto-next-non-ws orgpoint)) 3333 (ada-goto-next-non-ws orgpoint ignore-goto-label))
3308 ;; 3334 ;;
3309 ;; nothing follows => it's the end-statement directly in 3335 ;; nothing follows => it's the end-statement directly in
3310 ;; front of point => search again 3336 ;; front of point => search again
@@ -3326,7 +3352,7 @@ open parenthesis."
3326 (goto-char (point-min)) 3352 (goto-char (point-min))
3327 ;; 3353 ;;
3328 ;; skip to the very first statement, if there is one 3354 ;; skip to the very first statement, if there is one
3329 ;; 3355 ;;
3330 (unless (ada-goto-next-non-ws orgpoint) 3356 (unless (ada-goto-next-non-ws orgpoint)
3331 (goto-char orgpoint)))) 3357 (goto-char orgpoint))))
3332 (point))) 3358 (point)))
@@ -3387,19 +3413,25 @@ is the end of the match."
3387 match-dat 3413 match-dat
3388 nil))) 3414 nil)))
3389 3415
3390 3416(defun ada-goto-next-non-ws (&optional limit skip-goto-label)
3391(defun ada-goto-next-non-ws (&optional limit) 3417 "Skip to next non-whitespace character.
3392 "Skip white spaces, newlines and comments to next non-ws character. 3418Skips spaces, newlines and comments, and possibly goto labels.
3419Return `point' if moved, nil if not.
3393Stop the search at LIMIT. 3420Stop the search at LIMIT.
3394Do not call this function from within a string." 3421Do not call this function from within a string."
3395 (unless limit 3422 (unless limit
3396 (setq limit (point-max))) 3423 (setq limit (point-max)))
3397 (while (and (<= (point) limit) 3424 (while (and (<= (point) limit)
3398 (progn (forward-comment 10000) 3425 (or (progn (forward-comment 10000)
3399 (if (and (not (eobp)) 3426 (if (and (not (eobp))
3400 (save-excursion (forward-char 1) 3427 (save-excursion (forward-char 1)
3401 (ada-in-string-p))) 3428 (ada-in-string-p)))
3402 (progn (forward-sexp 1) t))))) 3429 (progn (forward-sexp 1) t)))
3430 (and skip-goto-label
3431 (looking-at ada-goto-label-re)
3432 (progn
3433 (goto-char (match-end 0))
3434 t)))))
3403 (if (< (point) limit) 3435 (if (< (point) limit)
3404 (point) 3436 (point)
3405 nil) 3437 nil)
@@ -3426,9 +3458,7 @@ Return the new position of point or nil if not found."
3426 (unless backward 3458 (unless backward
3427 (skip-syntax-forward "w")) 3459 (skip-syntax-forward "w"))
3428 (if (setq match-cons 3460 (if (setq match-cons
3429 (if backward 3461 (ada-search-ignore-string-comment "\\w" backward nil t))
3430 (ada-search-ignore-string-comment "\\w" t nil t)
3431 (ada-search-ignore-string-comment "\\w" nil nil t)))
3432 ;; 3462 ;;
3433 ;; move to the beginning of the word found 3463 ;; move to the beginning of the word found
3434 ;; 3464 ;;
@@ -3463,13 +3493,13 @@ Moves point to the beginning of the declaration."
3463 (if (save-excursion 3493 (if (save-excursion
3464 (ada-goto-previous-word) 3494 (ada-goto-previous-word)
3465 (looking-at (concat "\\<" defun-name "\\> *:"))) 3495 (looking-at (concat "\\<" defun-name "\\> *:")))
3466 t ; do nothing 3496 t ; name matches
3467 ;; else 3497 ;; else
3468 ;; 3498 ;;
3469 ;; 'accept' or 'package' ? 3499 ;; 'accept' or 'package' ?
3470 ;; 3500 ;;
3471 (unless (looking-at ada-subprog-start-re) 3501 (unless (looking-at ada-subprog-start-re)
3472 (ada-goto-matching-decl-start)) 3502 (ada-goto-decl-start))
3473 ;; 3503 ;;
3474 ;; 'begin' of 'procedure'/'function'/'task' or 'declare' 3504 ;; 'begin' of 'procedure'/'function'/'task' or 'declare'
3475 ;; 3505 ;;
@@ -3502,14 +3532,20 @@ Moves point to the beginning of the declaration."
3502 (buffer-substring (point) 3532 (buffer-substring (point)
3503 (progn (forward-sexp 1) (point)))))))) 3533 (progn (forward-sexp 1) (point))))))))
3504 3534
3505(defun ada-goto-matching-decl-start (&optional noerror recursive) 3535(defun ada-goto-decl-start (&optional noerror)
3506 "Move point to the matching declaration start of the current 'begin'. 3536 "Move point to the declaration start of the current construct.
3507If 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."
3508 (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 "\\>")))
3509 3545
3510 ;; 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
3511 ;; "begin" we encounter. 3547 ;; "begin" we encounter.
3512 (first (not recursive)) 3548 (first t)
3513 (count-generic nil) 3549 (count-generic nil)
3514 (stop-at-when nil) 3550 (stop-at-when nil)
3515 ) 3551 )
@@ -3533,7 +3569,7 @@ If NOERROR is non-nil, it only returns nil if no match was found."
3533 ;; search backward for interesting keywords 3569 ;; search backward for interesting keywords
3534 (while (and 3570 (while (and
3535 (not (zerop nest-count)) 3571 (not (zerop nest-count))
3536 (ada-search-ignore-string-comment ada-matching-decl-start-re t)) 3572 (ada-search-ignore-string-comment regexp t))
3537 ;; 3573 ;;
3538 ;; calculate nest-depth 3574 ;; calculate nest-depth
3539 ;; 3575 ;;
@@ -3566,7 +3602,6 @@ If NOERROR is non-nil, it only returns nil if no match was found."
3566 3602
3567 (if (looking-at "end") 3603 (if (looking-at "end")
3568 (ada-goto-matching-start 1 noerror t) 3604 (ada-goto-matching-start 1 noerror t)
3569 ;; (ada-goto-matching-decl-start noerror t)
3570 3605
3571 (setq loop-again nil) 3606 (setq loop-again nil)
3572 (unless (looking-at "begin") 3607 (unless (looking-at "begin")
@@ -3594,34 +3629,50 @@ If NOERROR is non-nil, it only returns nil if no match was found."
3594 (setq first t)) 3629 (setq first t))
3595 ;; 3630 ;;
3596 ((looking-at "is") 3631 ((looking-at "is")
3597 ;; check if it is only a type definition, but not a protected 3632 ;; look for things to ignore
3598 ;; type definition, which should be handled like a procedure. 3633 (if
3599 (if (or (looking-at "is[ \t]+<>") 3634 (or
3600 (save-excursion 3635 ;; generic formal parameter
3601 (forward-comment -10000) 3636 (looking-at "is[ t]+<>")
3602 (forward-char -1) 3637
3603 3638 ;; A type definition, or a case statement. Note that the
3604 ;; Detect if we have a closing parenthesis (Could be 3639 ;; goto-matching-start above on 'end record' leaves us at
3605 ;; either the end of subprogram parameters or (<>) 3640 ;; 'record', not at 'type'.
3606 ;; in a type definition 3641 ;;
3607 (if (= (char-after) ?\)) 3642 ;; We get to a case statement here by calling
3608 (progn 3643 ;; 'ada-move-to-end' from inside a case statement; then
3609 (forward-char 1) 3644 ;; we are not ignoring 'when'.
3610 (backward-sexp 1) 3645 (save-excursion
3611 (forward-comment -10000) 3646 ;; Skip type discriminants or case argument function call param list
3612 )) 3647 (forward-comment -10000)
3613 (skip-chars-backward "a-zA-Z0-9_.'") 3648 (forward-char -1)
3614 (ada-goto-previous-word) 3649 (if (= (char-after) ?\))
3615 (and 3650 (progn
3616 (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\\>")
3617 (save-match-data 3663 (save-match-data
3618 (ada-goto-previous-word) 3664 (ada-goto-previous-word)
3619 (not (looking-at "\\<protected\\>")))) 3665 (not (looking-at "\\<protected\\>"))))
3620 )) ; end of `or' 3666 ) ; end of type definition p
3621 (goto-char (match-beginning 0)) 3667
3622 (progn 3668 ;; null procedure declaration
3623 (setq nest-count (1- nest-count)) 3669 (save-excursion (ada-goto-next-word) (looking-at "\\<null\\>"))
3624 (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)))
3625 3676
3626 ;; 3677 ;;
3627 ((looking-at "new") 3678 ((looking-at "new")
@@ -4076,7 +4127,7 @@ Point is moved at the beginning of the SEARCH-RE."
4076Assumes point to be at the end of a statement." 4127Assumes point to be at the end of a statement."
4077 (or (ada-in-paramlist-p) 4128 (or (ada-in-paramlist-p)
4078 (save-excursion 4129 (save-excursion
4079 (ada-goto-matching-decl-start t)))) 4130 (ada-goto-decl-start t))))
4080 4131
4081 4132
4082(defun ada-looking-at-semi-or () 4133(defun ada-looking-at-semi-or ()
@@ -4370,7 +4421,7 @@ of the region. Otherwise, operate only on the current line."
4370 ;; 4421 ;;
4371 ada-move-to-declaration 4422 ada-move-to-declaration
4372 (looking-at "\\<begin\\>") 4423 (looking-at "\\<begin\\>")
4373 (ada-goto-matching-decl-start) 4424 (ada-goto-decl-start)
4374 (setq pos (point)))) 4425 (setq pos (point))))
4375 4426
4376 ) ; end of save-excursion 4427 ) ; end of save-excursion
@@ -4382,7 +4433,7 @@ of the region. Otherwise, operate only on the current line."
4382 (set-syntax-table previous-syntax-table)))) 4433 (set-syntax-table previous-syntax-table))))
4383 4434
4384(defun ada-move-to-end () 4435(defun ada-move-to-end ()
4385 "Move point to the matching end of the block around point. 4436 "Move point to the end of the block around point.
4386Moves to 'begin' if in a declarative part." 4437Moves to 'begin' if in a declarative part."
4387 (interactive) 4438 (interactive)
4388 (let ((pos (point)) 4439 (let ((pos (point))
@@ -4432,7 +4483,7 @@ Moves to 'begin' if in a declarative part."
4432 (ada-goto-matching-end 0)) 4483 (ada-goto-matching-end 0))
4433 ;; package start 4484 ;; package start
4434 ((save-excursion 4485 ((save-excursion
4435 (setq decl-start (and (ada-goto-matching-decl-start t) (point))) 4486 (setq decl-start (and (ada-goto-decl-start t) (point)))
4436 (and decl-start (looking-at "\\<package\\>"))) 4487 (and decl-start (looking-at "\\<package\\>")))
4437 (ada-goto-matching-end 1)) 4488 (ada-goto-matching-end 1))
4438 4489
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index de0cd896b8e..bb91dee6ce8 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -1217,12 +1217,14 @@ been put there by c-put-char-property. POINT remains unchanged."
1217 ;; This macro does a hidden buffer change. 1217 ;; This macro does a hidden buffer change.
1218 `(progn 1218 `(progn
1219 (c-put-char-property ,beg 'category 'c-cpp-delimiter) 1219 (c-put-char-property ,beg 'category 'c-cpp-delimiter)
1220 (c-put-char-property ,end 'category 'c-cpp-delimiter))) 1220 (if (< ,end (point-max))
1221 (c-put-char-property ,end 'category 'c-cpp-delimiter))))
1221(defmacro c-clear-cpp-delimiters (beg end) 1222(defmacro c-clear-cpp-delimiters (beg end)
1222 ;; This macro does a hidden buffer change. 1223 ;; This macro does a hidden buffer change.
1223 `(progn 1224 `(progn
1224 (c-clear-char-property ,beg 'category) 1225 (c-clear-char-property ,beg 'category)
1225 (c-clear-char-property ,end 'category))) 1226 (if (< ,end (point-max))
1227 (c-clear-char-property ,end 'category))))
1226 1228
1227(defsubst c-comment-out-cpps () 1229(defsubst c-comment-out-cpps ()
1228 ;; Render all preprocessor constructs syntactically commented out. 1230 ;; Render all preprocessor constructs syntactically commented out.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 0e6358aeee1..9d0af1d53ce 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2996,9 +2996,11 @@ comment at the start of cc-engine.el for more info."
2996 ;; containing point. We can then call `c-invalidate-state-cache-1' without 2996 ;; containing point. We can then call `c-invalidate-state-cache-1' without
2997 ;; worrying further about macros and template delimiters. 2997 ;; worrying further about macros and template delimiters.
2998 (c-with-<->-as-parens-suppressed 2998 (c-with-<->-as-parens-suppressed
2999 (if c-state-old-cpp-beg 2999 (if (and c-state-old-cpp-beg
3000 (< c-state-old-cpp-beg here))
3000 (c-with-all-but-one-cpps-commented-out 3001 (c-with-all-but-one-cpps-commented-out
3001 c-state-old-cpp-beg c-state-old-cpp-end 3002 c-state-old-cpp-beg
3003 (min c-state-old-cpp-end here)
3002 (c-invalidate-state-cache-1 here)) 3004 (c-invalidate-state-cache-1 here))
3003 (c-with-cpps-commented-out 3005 (c-with-cpps-commented-out
3004 (c-invalidate-state-cache-1 here))))) 3006 (c-invalidate-state-cache-1 here)))))
@@ -3029,8 +3031,9 @@ comment at the start of cc-engine.el for more info."
3029 (c-parse-state-1)) 3031 (c-parse-state-1))
3030 (c-with-cpps-commented-out 3032 (c-with-cpps-commented-out
3031 (c-parse-state-1)))) 3033 (c-parse-state-1))))
3032 (setq c-state-old-cpp-beg here-cpp-beg 3034 (setq c-state-old-cpp-beg (and here-cpp-beg (copy-marker here-cpp-beg t))
3033 c-state-old-cpp-end here-cpp-end)))) 3035 c-state-old-cpp-end (and here-cpp-end (copy-marker here-cpp-end t)))
3036 )))
3034 3037
3035;; Debug tool to catch cache inconsistencies. This is called from 3038;; Debug tool to catch cache inconsistencies. This is called from
3036;; 000tests.el. 3039;; 000tests.el.