aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-07-18 20:48:04 +0000
committerRichard M. Stallman1995-07-18 20:48:04 +0000
commit276c1210470be9cef7d09469c4a43d2af9a5341d (patch)
tree8345445d321e0f1b49cb09e884152719e5dc9997
parent0099c05af1b0f93b03d806d057b520fe33b57369 (diff)
downloademacs-276c1210470be9cef7d09469c4a43d2af9a5341d.tar.gz
emacs-276c1210470be9cef7d09469c4a43d2af9a5341d.zip
(ada-ident-re): Doc fix.
(ada-end-stmt-re): Corrected serious pb of wrong parentheses. (ada-subprog-start-re): Removed 'body' from the list. (ada-format-paramlist): Simplified a regexp. (ada-indent-current): On first line of the buffer, indent to column 0. Don't reindent if new position is the same as the old one. Thus, a correcly indended line is not modified. (ada-get-indent-subprog): Simplified a regexp. (ada-goto-matching-decl-start): Distinguish between normal type declaration and protected types, which are more like procedures. (ada-remove-trailing-spaces): Use save-match-data, save-restriction and widen when removing whitespace. (ada-font-lock-keywords-1): Add 'pragma' as keyword. (ada-font-lock-keywords-2): Allow *qualified* idents after 'end'.
-rw-r--r--lisp/progmodes/ada-mode.el93
1 files changed, 35 insertions, 58 deletions
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el
index 404f4c7657b..2014f8e8b02 100644
--- a/lisp/progmodes/ada-mode.el
+++ b/lisp/progmodes/ada-mode.el
@@ -62,23 +62,8 @@
62;;; 62;;;
63;;; In the presence of comments and/or incorrect syntax 63;;; In the presence of comments and/or incorrect syntax
64;;; ada-format-paramlist produces weird results. 64;;; ada-format-paramlist produces weird results.
65;;;
66;;; Indenting of some tasking constructs is still buggy.
67;;; ------------------- 65;;; -------------------
68;;; For tagged types the problem comes from the keyword abstract: 66;;; Indenting of some tasking constructs is still buggy.
69
70;;; type T2 is abstract tagged record
71;;; X : Integer;
72;;; Y : Float;
73;;; end record;
74;;; -------------------
75;;; In Emacs FSF 19.28, ada-mode will correctly indent comments at the
76;;; very beginning of the buffer (_before_ any code) when I go M-; but
77;;; when I press TAB I'd expect the comments to be placed at the beginning
78;;; of the line, just as the first line of _code_ would be indented.
79
80;;; This does not happen but the comment stays put :-( I end up going
81;;; M-; C-a M-\
82;;; ------------------- 67;;; -------------------
83;;; package Test is 68;;; package Test is
84;;; -- If I hit return on the "type" line it will indent the next line 69;;; -- If I hit return on the "type" line it will indent the next line
@@ -86,27 +71,6 @@
86;;; -- tab or return it reindents the line correctly but does not initially. 71;;; -- tab or return it reindents the line correctly but does not initially.
87;;; type Wait_Return is (Read_Success, Read_Timeout, Wait_Timeout, 72;;; type Wait_Return is (Read_Success, Read_Timeout, Wait_Timeout,
88;;; Nothing_To_Wait_For_In_Wait_List); 73;;; Nothing_To_Wait_For_In_Wait_List);
89;;;
90;;; -- The following line will be wrongly reindented after typing it in after
91;;; -- the initial indent for the line was correct after type return after
92;;; -- this line. Subsequent lines will show the same problem.
93;;; Unused: constant Queue_ID := 0;
94;;; -------------------
95;;; -- If I do the following I get
96;;; -- "no matching procedure/function/task/declare/package"
97;;; -- when I do return (I reverse the mappings of ^j and ^m) after "private".
98;;; package Package1 is
99;;; package Package1_1 is
100;;; type The_Type is private;
101;;; private
102;;; -------------------
103;;; -- But what about this:
104;;; package G is
105;;; type T1 is new Integer;
106;;; type T2 is new Integer; --< incorrect, correct if subtype
107;;; package H is
108;;; type T3 is new Integer;
109;;; type --< Indentation is incorrect
110;;; ------------------- 74;;; -------------------
111 75
112 76
@@ -279,7 +243,7 @@ type\\|until\\|use\\|when\\|while\\|with\\|xor\\)\\>"
279 243
280(defconst ada-ident-re 244(defconst ada-ident-re
281 "[a-zA-Z0-9_\\.]+" 245 "[a-zA-Z0-9_\\.]+"
282 "Regexp matching Ada identifiers.") 246 "Regexp matching Ada (qualified) identifiers.")
283 247
284(defvar ada-procedure-start-regexp 248(defvar ada-procedure-start-regexp
285 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)" 249 "^[ \t]*\\(procedure\\|function\\|task\\)[ \t\n]+\\([a-zA-Z0-9_\\.]+\\)"
@@ -301,8 +265,9 @@ exception\\|loop\\|else\\|\
301(defvar ada-end-stmt-re 265(defvar ada-end-stmt-re
302 "\\(;\\|=>\\|^[ \t]*separate[ \t]+([a-zA-Z0-9_\\.]+)\\|\ 266 "\\(;\\|=>\\|^[ \t]*separate[ \t]+([a-zA-Z0-9_\\.]+)\\|\
303\\<\\(begin\\|else\\|record\\|loop\\|select\\|do\\|\ 267\\<\\(begin\\|else\\|record\\|loop\\|select\\|do\\|\
304^[ \t]*package[ \ta-zA-Z0-9_\\.]+is\\|\ 268declare\\|generic\\|private\\)\\>\\|\
305^[ \t]*exception\\|declare\\|generic\\|private\\)\\>\\)" 269^[ \t]*\\(package\\|procedure\\|function\\)[ \ta-zA-Z0-9_\\.]+is\\|\
270^[ \t]*exception\\>\\)"
306 "Regexp of possible ends for a non-broken statement. 271 "Regexp of possible ends for a non-broken statement.
307'end' means that there has to start a new statement after these.") 272'end' means that there has to start a new statement after these.")
308 273
@@ -311,7 +276,7 @@ exception\\|loop\\|else\\|\
311 "Regexp for the start of a loop.") 276 "Regexp for the start of a loop.")
312 277
313(defvar ada-subprog-start-re 278(defvar ada-subprog-start-re
314 "\\<\\(procedure\\|protected\\|package[ \t]+body\\|function\\|\ 279 "\\<\\(procedure\\|protected\\|package\\|function\\|\
315task\\|accept\\|entry\\)\\>" 280task\\|accept\\|entry\\)\\>"
316 "Regexp for the start of a subprogram.") 281 "Regexp for the start of a subprogram.")
317 282
@@ -924,9 +889,7 @@ In such a case, use 'undo', correct the syntax and try again."
924 ;; find start of current parameter-list 889 ;; find start of current parameter-list
925 ;; 890 ;;
926 (ada-search-ignore-string-comment 891 (ada-search-ignore-string-comment
927 (concat "\\<\\(" 892 (concat ada-subprog-start-re "\\|\\<body\\>" ) t nil)
928 "procedure\\|function\\|body\\|package\\|task\\|entry\\|accept"
929 "\\)\\>") t nil)
930 (ada-search-ignore-string-comment "(" nil nil t) 893 (ada-search-ignore-string-comment "(" nil nil t)
931 (backward-char 1) 894 (backward-char 1)
932 (setq begin (point)) 895 (setq begin (point))
@@ -1504,7 +1467,10 @@ This works by two steps:
1504 (setq prev-indent 1467 (setq prev-indent
1505 (save-excursion 1468 (save-excursion
1506 (funcall (ada-indent-function) line-end)))) 1469 (funcall (ada-indent-function) line-end))))
1507 (setq prevline nil))) 1470 (progn ; first line of buffer -> set indent
1471 (beginning-of-line) ; to 0
1472 (delete-horizontal-space)
1473 (setq prevline nil))))
1508 1474
1509 (if prevline 1475 (if prevline
1510 ;; 1476 ;;
@@ -1516,9 +1482,11 @@ This works by two steps:
1516 ;; 1482 ;;
1517 (back-to-indentation) 1483 (back-to-indentation)
1518 (setq cur-indent (ada-get-current-indent prev-indent)) 1484 (setq cur-indent (ada-get-current-indent prev-indent))
1485 ;; only reindent if indentation is different then the current
1486 (if (= (current-column) cur-indent)
1487 nil
1519 (delete-horizontal-space) 1488 (delete-horizontal-space)
1520 (indent-to cur-indent) 1489 (indent-to cur-indent))
1521
1522 ;; 1490 ;;
1523 ;; restore position of point 1491 ;; restore position of point
1524 ;; 1492 ;;
@@ -2130,8 +2098,7 @@ This works by two steps:
2130 "\\<\\(separate\\|new\\|abstract\\)\\>" 2098 "\\<\\(separate\\|new\\|abstract\\)\\>"
2131 nil orgpoint)))) 2099 nil orgpoint))))
2132 (goto-char (car match-cons)) 2100 (goto-char (car match-cons))
2133 (ada-search-ignore-string-comment (concat ada-subprog-start-re 2101 (ada-search-ignore-string-comment ada-subprog-start-re t)
2134 "\\|\\<package\\>") t)
2135 (ada-get-indent-noindent orgpoint)) 2102 (ada-get-indent-noindent orgpoint))
2136 ;; 2103 ;;
2137 ;; something follows 'is' 2104 ;; something follows 'is'
@@ -2421,6 +2388,7 @@ This works by two steps:
2421 ;; End-statements are defined by 'ada-end-stmt-re'. Checks for 2388 ;; End-statements are defined by 'ada-end-stmt-re'. Checks for
2422 ;; certain keywords if they follow 'end', which means they are no 2389 ;; certain keywords if they follow 'end', which means they are no
2423 ;; end-statement there. 2390 ;; end-statement there.
2391 (interactive) ;; DEBUG
2424 (let ((match-dat nil) 2392 (let ((match-dat nil)
2425 (pos nil) 2393 (pos nil)
2426 (found nil)) 2394 (found nil))
@@ -2447,7 +2415,7 @@ This works by two steps:
2447 (looking-at "\\<end\\>")))) 2415 (looking-at "\\<end\\>"))))
2448 (setq found t) 2416 (setq found t)
2449 2417
2450 (backward-word 1)))) ; end of loop 2418 (forward-word -1)))) ; end of loop
2451 2419
2452 (if found 2420 (if found
2453 match-dat 2421 match-dat
@@ -2477,7 +2445,7 @@ This works by two steps:
2477 2445
2478 2446
2479(defun ada-goto-previous-word () 2447(defun ada-goto-previous-word ()
2480 ;; Moves point to the beginning of the previous word of ada-code. 2448 ;; Moves point to the beginning of the previous word of Ada code.
2481 ;; Returns the new position of point or nil if not found. 2449 ;; Returns the new position of point or nil if not found.
2482 (let ((match-cons nil) 2450 (let ((match-cons nil)
2483 (orgpoint (point))) 2451 (orgpoint (point)))
@@ -2557,6 +2525,7 @@ This works by two steps:
2557(defun ada-goto-matching-decl-start (&optional noerror nogeneric) 2525(defun ada-goto-matching-decl-start (&optional noerror nogeneric)
2558 ;; Moves point to the matching declaration start of the current 'begin'. 2526 ;; Moves point to the matching declaration start of the current 'begin'.
2559 ;; If NOERROR is non-nil, it only returns nil if no match was found. 2527 ;; If NOERROR is non-nil, it only returns nil if no match was found.
2528 (interactive) ;; DEBUG
2560 (let ((nest-count 1) 2529 (let ((nest-count 1)
2561 (pos nil) 2530 (pos nil)
2562 (first t) 2531 (first t)
@@ -2585,7 +2554,8 @@ This works by two steps:
2585 (setq first nil)) 2554 (setq first nil))
2586 ;; 2555 ;;
2587 ((looking-at "is") 2556 ((looking-at "is")
2588 ;; check if it is only a type definition 2557 ;; check if it is only a type definition, but not a protected
2558 ;; type definition, which should be handled like a procedure.
2589 (if (save-excursion 2559 (if (save-excursion
2590 (ada-goto-previous-word) 2560 (ada-goto-previous-word)
2591 (skip-chars-backward "a-zA-Z0-9_.'") 2561 (skip-chars-backward "a-zA-Z0-9_.'")
@@ -2598,7 +2568,12 @@ This works by two steps:
2598 (skip-chars-backward "a-zA-Z0-9_.'") 2568 (skip-chars-backward "a-zA-Z0-9_.'")
2599 )) 2569 ))
2600 (ada-goto-previous-word) 2570 (ada-goto-previous-word)
2601 (looking-at "\\<type\\>")) ; end of save-excursion 2571 (and
2572 (looking-at "\\<type\\>")
2573 (save-match-data
2574 (ada-goto-previous-word)
2575 (not (looking-at "\\<protected\\>"))))
2576 ); end of save-excursion
2602 (goto-char (match-beginning 0)) 2577 (goto-char (match-beginning 0))
2603 (progn 2578 (progn
2604 (setq nest-count (1- nest-count)) 2579 (setq nest-count (1- nest-count))
@@ -2633,7 +2608,7 @@ This works by two steps:
2633 ada-subprog-start-re t) 2608 ada-subprog-start-re t)
2634 (looking-at "declare\\|generic"))))) 2609 (looking-at "declare\\|generic")))))
2635 (if noerror nil 2610 (if noerror nil
2636 (error "no matching procedure/function/task/declare/package")) 2611 (error "no matching proc/func/task/declare/package/protected"))
2637 t))) 2612 t)))
2638 2613
2639 2614
@@ -3202,13 +3177,15 @@ This works by two steps:
3202;;;---------------;;; 3177;;;---------------;;;
3203 3178
3204(defun ada-remove-trailing-spaces () 3179(defun ada-remove-trailing-spaces ()
3205;; remove all trailing spaces at the end of lines.
3206 "remove trailing spaces in the whole buffer." 3180 "remove trailing spaces in the whole buffer."
3207 (interactive) 3181 (interactive)
3182 (save-match-data
3208 (save-excursion 3183 (save-excursion
3184 (save-restriction
3185 (widen)
3209 (goto-char (point-min)) 3186 (goto-char (point-min))
3210 (while (re-search-forward "[ \t]+$" nil t) 3187 (while (re-search-forward "[ \t]+$" (point-max) t)
3211 (replace-match "" nil nil)))) 3188 (replace-match "" nil nil))))))
3212 3189
3213 3190
3214(defun ada-untabify-buffer () 3191(defun ada-untabify-buffer ()
@@ -3580,7 +3557,7 @@ This does fairly subdued highlighting.")
3580 "\\)\\>") 3557 "\\)\\>")
3581 ;; 3558 ;;
3582 ;; Anything following end and not already fontified is a body name. 3559 ;; Anything following end and not already fontified is a body name.
3583 '("\\<\\(end\\)\\>[ \t]+\\(\\sw+\\)?" 3560 '("\\<\\(end\\)\\>[ \t]+\\([a-zA-Z0-9_\\.]+\\)?"
3584 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) 3561 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
3585 ;; 3562 ;;
3586 ;; Variable name plus optional keywords followed by a type name. Slow. 3563 ;; Variable name plus optional keywords followed by a type name. Slow.