Mercurial > emacs
comparison lisp/progmodes/fortran.el @ 47767:1ad06cb931a9
(fortran-beginning-do): Ignore labelled DO loops altogether.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sun, 06 Oct 2002 14:56:29 +0000 |
parents | 0ea82abe061c |
children | 4d051ad4475f |
comparison
equal
deleted
inserted
replaced
47766:76b2ec66665d | 47767:1ad06cb931a9 |
---|---|
1102 ;; All pairs accounted for. | 1102 ;; All pairs accounted for. |
1103 (point))))))) | 1103 (point))))))) |
1104 | 1104 |
1105 (defun fortran-beginning-do () | 1105 (defun fortran-beginning-do () |
1106 "Search backwards for first unmatched DO [WHILE]. | 1106 "Search backwards for first unmatched DO [WHILE]. |
1107 Return point or nil." | 1107 Return point or nil. Ignores labelled DO loops (ie DO 10 ... 10 CONTINUE)." |
1108 (let ((case-fold-search t)) | 1108 (let ((case-fold-search t) |
1109 (dostart-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]")) | |
1109 (if (save-excursion | 1110 (if (save-excursion |
1110 (beginning-of-line) | 1111 (beginning-of-line) |
1111 (skip-chars-forward " \t0-9") | 1112 (skip-chars-forward " \t0-9") |
1112 (looking-at "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+")) | 1113 (looking-at dostart-re)) |
1113 ;; Sitting on one. | 1114 ;; Sitting on one. |
1114 (match-beginning 0) | 1115 (match-beginning 0) |
1115 ;; Search for one. | 1116 ;; Search for one. |
1116 (save-excursion | 1117 (save-excursion |
1117 (let ((count 1)) | 1118 (let ((count 1)) |
1119 (not (eq (fortran-previous-statement) 'first-statement)) | 1120 (not (eq (fortran-previous-statement) 'first-statement)) |
1120 ;; Keep local to subprogram | 1121 ;; Keep local to subprogram |
1121 (not (and (looking-at fortran-end-prog-re) | 1122 (not (and (looking-at fortran-end-prog-re) |
1122 (fortran-check-end-prog-re)))) | 1123 (fortran-check-end-prog-re)))) |
1123 (skip-chars-forward " \t0-9") | 1124 (skip-chars-forward " \t0-9") |
1124 (cond ((looking-at | 1125 (cond ((looking-at dostart-re) |
1125 "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+") | |
1126 (setq count (1- count))) | 1126 (setq count (1- count))) |
1127 ;; Note labelled loop ends not considered. | |
1127 ((looking-at "end[ \t]*do\\b") | 1128 ((looking-at "end[ \t]*do\\b") |
1128 (setq count (1+ count))))) | 1129 (setq count (1+ count))))) |
1129 (and (= count 0) | 1130 (and (= count 0) |
1130 ;; All pairs accounted for. | 1131 ;; All pairs accounted for. |
1131 (point))))))) | 1132 (point))))))) |