unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: Miles Bader <miles@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: fortran indentation bug?
Date: Tue, 10 Jun 2008 21:18:19 -0400	[thread overview]
Message-ID: <vhlk1cpy5g.fsf@fencepost.gnu.org> (raw)
In-Reply-To: 87prqou95q.fsf@catnip.gol.com

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	other threads:[~2008-06-11  1:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10  6:09 fortran indentation bug? Miles Bader
2008-06-10 23:37 ` Glenn Morris
2008-06-11  0:06   ` Miles Bader
2008-06-11  1:18     ` Glenn Morris [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vhlk1cpy5g.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).