From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.devel Subject: Re: fortran indentation bug? Date: Tue, 10 Jun 2008 21:18:19 -0400 Message-ID: References: <218wxcrhdt.fsf@fencepost.gnu.org> <87prqou95q.fsf@catnip.gol.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213147234 7848 80.91.229.12 (11 Jun 2008 01:20:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Jun 2008 01:20:34 +0000 (UTC) Cc: emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 11 03:21:17 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K6F1Y-000461-Qz for ged-emacs-devel@m.gmane.org; Wed, 11 Jun 2008 03:21:17 +0200 Original-Received: from localhost ([127.0.0.1]:36081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6F0l-0005TW-3V for ged-emacs-devel@m.gmane.org; Tue, 10 Jun 2008 21:20:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K6F0g-0005RJ-Lk for emacs-devel@gnu.org; Tue, 10 Jun 2008 21:20:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K6F0f-0005Pc-7G for emacs-devel@gnu.org; Tue, 10 Jun 2008 21:20:22 -0400 Original-Received: from [199.232.76.173] (port=40974 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6F0f-0005PU-3N for emacs-devel@gnu.org; Tue, 10 Jun 2008 21:20:21 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]:34878) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K6F0f-0007Bi-14 for emacs-devel@gnu.org; Tue, 10 Jun 2008 21:20:21 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1K6Eyh-0002sp-Df; Tue, 10 Jun 2008 21:18:19 -0400 X-Spook: Albania Operation Iraqi Freedom rail gun IMF gamma X-Ran: bH5SN49yV,`=O%#F3ny=#C)(cGz{hyVQ/1aR}!4d;;o_:EzX647\\ List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:98912 Archived-At: 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