aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-03-02 19:41:24 +0000
committerRichard M. Stallman1994-03-02 19:41:24 +0000
commitf6807db3d6c014362221f05dedb62499b9aeae2e (patch)
treebaa123d3e2da0b7745eb3ea6239f3261483c34d9
parentb493a9b2af805a3097fe53fd472884c268248146 (diff)
downloademacs-f6807db3d6c014362221f05dedb62499b9aeae2e.tar.gz
emacs-f6807db3d6c014362221f05dedb62499b9aeae2e.zip
(pascal-calculate-indent): Fixed indentation bug
in for-loops, with-structures and else-structures. (pascal-noindent-re): Add `else'.
-rw-r--r--lisp/progmodes/pascal.el21
1 files changed, 11 insertions, 10 deletions
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index 510c78f3b24..b225938ab92 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -113,7 +113,7 @@
113(defconst pascal-declaration-re "\\<\\(const\\|label\\|type\\|var\\)\\>") 113(defconst pascal-declaration-re "\\<\\(const\\|label\\|type\\|var\\)\\>")
114(defconst pascal-defun-re "\\<\\(function\\|procedure\\|program\\)\\>") 114(defconst pascal-defun-re "\\<\\(function\\|procedure\\|program\\)\\>")
115(defconst pascal-sub-block-re "\\<\\(if\\|else\\|for\\|while\\|with\\)\\>") 115(defconst pascal-sub-block-re "\\<\\(if\\|else\\|for\\|while\\|with\\)\\>")
116(defconst pascal-noindent-re "\\<\\(begin\\|end\\|until\\)\\>") 116(defconst pascal-noindent-re "\\<\\(begin\\|end\\|until\\|else\\)\\>")
117(defconst pascal-nosemi-re "\\<\\(begin\\|repeat\\|then\\|do\\|else\\)\\>") 117(defconst pascal-nosemi-re "\\<\\(begin\\|repeat\\|then\\|do\\|else\\)\\>")
118(defconst pascal-autoindent-lines-re 118(defconst pascal-autoindent-lines-re
119 "\\<\\(label\\|var\\|type\\|const\\|until\\|end\\|begin\\|repeat\\|else\\)\\>") 119 "\\<\\(label\\|var\\|type\\|const\\|until\\|end\\|begin\\|repeat\\|else\\)\\>")
@@ -668,7 +668,8 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
668 (save-excursion 668 (save-excursion
669 (let* ((oldpos (point)) 669 (let* ((oldpos (point))
670 (state (save-excursion (parse-partial-sexp (point-min) (point)))) 670 (state (save-excursion (parse-partial-sexp (point-min) (point))))
671 (nest 0) (par 0) (complete nil) (blocked nil) 671 (nest 0) (par 0) (complete nil)
672 (elsed (looking-at "[ \t]*else\\>"))
672 (type (catch 'nesting 673 (type (catch 'nesting
673 ;; Check if inside a string, comment or parenthesis 674 ;; Check if inside a string, comment or parenthesis
674 (cond ((nth 3 state) (throw 'nesting 'string)) 675 (cond ((nth 3 state) (throw 'nesting 'string))
@@ -683,15 +684,16 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
683 (looking-at pascal-beg-block-re) 684 (looking-at pascal-beg-block-re)
684 (if (= nest 0) 685 (if (= nest 0)
685 (cond ((looking-at "case\\>") 686 (cond ((looking-at "case\\>")
686 (setq blocked t)
687 (throw 'nesting 'case)) 687 (throw 'nesting 'case))
688 ((looking-at "record\\>") 688 ((looking-at "record\\>")
689 (throw 'nesting 'declaration)) 689 (throw 'nesting 'declaration))
690 (t (setq blocked t) 690 (t (throw 'nesting 'block)))
691 (throw 'nesting 'block)))
692 (setq nest (1- nest)))) 691 (setq nest (1- nest))))
693 (;--Nest block inwards 692 (;--Nest block inwards
694 (looking-at pascal-end-block-re) 693 (looking-at pascal-end-block-re)
694 (if (and (looking-at "end\\s ")
695 elsed (not complete))
696 (throw 'nesting 'block))
695 (setq complete t 697 (setq complete t
696 nest (1+ nest))) 698 nest (1+ nest)))
697 (;--Defun (or parameter list) 699 (;--Defun (or parameter list)
@@ -710,11 +712,10 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
710 (throw 'nesting 'paramlist))))) 712 (throw 'nesting 'paramlist)))))
711 (;--Declaration part 713 (;--Declaration part
712 (looking-at pascal-declaration-re) 714 (looking-at pascal-declaration-re)
713 (if (or blocked 715 (if (save-excursion
714 (save-excursion 716 (goto-char oldpos)
715 (goto-char oldpos) 717 (forward-line -1)
716 (forward-line -1) 718 (looking-at "^[ \t]*$"))
717 (looking-at "^[ \t]*$")))
718 (throw 'nesting 'unknown) 719 (throw 'nesting 'unknown)
719 (throw 'nesting 'declaration))) 720 (throw 'nesting 'declaration)))
720 (;--If, else or while statement 721 (;--If, else or while statement