changeset 6153:40e4038bd544

(pascal-calculate-indent): Fixed indentation bug in for-loops, with-structures and else-structures. (pascal-noindent-re): Add `else'.
author Richard M. Stallman <rms@gnu.org>
date Wed, 02 Mar 1994 19:41:24 +0000
parents 34d9a0aa80d1
children 385d5fe1c95c
files lisp/progmodes/pascal.el
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/pascal.el	Wed Mar 02 16:55:16 1994 +0000
+++ b/lisp/progmodes/pascal.el	Wed Mar 02 19:41:24 1994 +0000
@@ -113,7 +113,7 @@
 (defconst pascal-declaration-re "\\<\\(const\\|label\\|type\\|var\\)\\>")
 (defconst pascal-defun-re       "\\<\\(function\\|procedure\\|program\\)\\>")
 (defconst pascal-sub-block-re   "\\<\\(if\\|else\\|for\\|while\\|with\\)\\>")
-(defconst pascal-noindent-re    "\\<\\(begin\\|end\\|until\\)\\>")
+(defconst pascal-noindent-re    "\\<\\(begin\\|end\\|until\\|else\\)\\>")
 (defconst pascal-nosemi-re      "\\<\\(begin\\|repeat\\|then\\|do\\|else\\)\\>")
 (defconst pascal-autoindent-lines-re
   "\\<\\(label\\|var\\|type\\|const\\|until\\|end\\|begin\\|repeat\\|else\\)\\>")
@@ -668,7 +668,8 @@
   (save-excursion
     (let* ((oldpos (point))
 	   (state (save-excursion (parse-partial-sexp (point-min) (point))))
-	   (nest 0) (par 0) (complete nil) (blocked nil)
+	   (nest 0) (par 0) (complete nil)
+	   (elsed (looking-at "[ \t]*else\\>"))
 	   (type (catch 'nesting
 		   ;; Check if inside a string, comment or parenthesis
 		   (cond ((nth 3 state) (throw 'nesting 'string))
@@ -683,15 +684,16 @@
 			    (looking-at pascal-beg-block-re)
 			    (if (= nest 0)
 				(cond ((looking-at "case\\>")
-				       (setq blocked t)
 				       (throw 'nesting 'case))
 				      ((looking-at "record\\>")
 				       (throw 'nesting 'declaration))
-				      (t (setq blocked t)
-					 (throw 'nesting 'block)))
+				      (t (throw 'nesting 'block)))
 			      (setq nest (1- nest))))
 			   (;--Nest block inwards
 			    (looking-at pascal-end-block-re)
+			    (if (and (looking-at "end\\s ")
+				     elsed (not complete))
+				(throw 'nesting 'block))
 			    (setq complete t
 				  nest (1+ nest)))
 			   (;--Defun (or parameter list)
@@ -710,11 +712,10 @@
 				  (throw 'nesting 'paramlist)))))
 			   (;--Declaration part
 			    (looking-at pascal-declaration-re)
-			    (if (or blocked
-				    (save-excursion
-				      (goto-char oldpos)
-				      (forward-line -1)
-				      (looking-at "^[ \t]*$")))
+			    (if (save-excursion
+				  (goto-char oldpos)
+				  (forward-line -1)
+				  (looking-at "^[ \t]*$"))
 				(throw 'nesting 'unknown)
 			      (throw 'nesting 'declaration)))
 			   (;--If, else or while statement