emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fortran indentation bug?


From: Glenn Morris
Subject: Re: fortran indentation bug?
Date: Tue, 10 Jun 2008 21:18:19 -0400
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Miles Bader wrote:

> There's lots of achingly old fortran code around though. :-)

Yes, but no sane man should actually try to edit it any more. :)

> Anyway, it would seem simple to special-case "continue".

Try this, which includes an anti-inflooping patch.


*** fortran.el  17 May 2008 20:08:37 -0000      1.148
--- fortran.el  11 Jun 2008 01:16:22 -0000
***************
*** 1187,1198 ****
                   (fortran-check-end-prog-re)))
            (forward-line)
          (beginning-of-line 2)
!         (catch 'ok
            (while (re-search-forward fortran-end-prog-re nil 'move)
              (if (fortran-check-end-prog-re)
                  (throw 'ok t))))
          (goto-char (match-beginning 0))
!         (forward-line)))))
  
  (defun fortran-previous-statement ()
    "Move point to beginning of the previous Fortran statement.
--- 1187,1198 ----
                   (fortran-check-end-prog-re)))
            (forward-line)
          (beginning-of-line 2)
!         (when (catch 'ok
                  (while (re-search-forward fortran-end-prog-re nil 'move)
                    (if (fortran-check-end-prog-re)
                        (throw 'ok t))))
            (goto-char (match-beginning 0))
!           (forward-line))))))
  
  (defun fortran-previous-statement ()
    "Move point to beginning of the previous Fortran statement.
***************
*** 1651,1657 ****
                ((and (looking-at fortran-end-prog-re1)
                      (fortran-check-end-prog-re))
                 ;; Previous END resets indent to minimum.
!                (setq icol fortran-minimum-statement-indent)))))
      (save-excursion
        (beginning-of-line)
        (cond ((looking-at "[ \t]*$"))
--- 1651,1667 ----
                ((and (looking-at fortran-end-prog-re1)
                      (fortran-check-end-prog-re))
                 ;; Previous END resets indent to minimum.
!                (setq icol fortran-minimum-statement-indent))
!               ;; Previous statement was a numbered DO loop without a
!               ;; closing CONTINUE or END DO, so we indented the
!               ;; terminator like the loop body.
!               ((and fortran-check-all-num-for-matching-do
!                     (not (looking-at "\\(continue\\|end[ \t]*do\\)\\>"))
!                     (progn
!                       (beginning-of-line)
!                       (and (looking-at "[ \t]*[0-9]+")
!                            (fortran-check-for-matching-do))))
!                (setq icol (- icol fortran-do-indent))))))
      (save-excursion
        (beginning-of-line)
        (cond ((looking-at "[ \t]*$"))
***************
*** 1676,1683 ****
                         6
                       (+ icol fortran-continuation-indent))))
              (first-statement)
              ((and fortran-check-all-num-for-matching-do
!                   (looking-at "[ \t]*[0-9]+")
                    (fortran-check-for-matching-do))
               (setq icol (- icol fortran-do-indent)))
              (t
--- 1686,1697 ----
                         6
                       (+ icol fortran-continuation-indent))))
              (first-statement)
+             ;; The terminating statement is actually part of the
+             ;; loop body, so unless it is a CONTINUE or END DO, we
+             ;; indent it like the loop body (see above).
              ((and fortran-check-all-num-for-matching-do
!                   (looking-at "[ \t]*[0-9]+[ \t]*\
! \\(continue\\|end[ \t]*do\\)\\>")
                    (fortran-check-for-matching-do))
               (setq icol (- icol fortran-do-indent)))
              (t






reply via email to

[Prev in Thread] Current Thread [Next in Thread]