433 |
(define-key map "\r" 'newline) |
(define-key map "\r" 'newline) |
434 |
(define-key map "\C-c\r" 'f90-break-line) |
(define-key map "\C-c\r" 'f90-break-line) |
435 |
;;; (define-key map [M-return] 'f90-break-line) |
;;; (define-key map [M-return] 'f90-break-line) |
436 |
(define-key map "\C-c\C-a" 'f90-previous-block-start) |
(define-key map "\C-c\C-a" 'f90-previous-block) |
437 |
(define-key map "\C-c\C-e" 'f90-next-block-end) |
(define-key map "\C-c\C-e" 'f90-next-block) |
438 |
(define-key map "\C-c\C-d" 'f90-join-lines) |
(define-key map "\C-c\C-d" 'f90-join-lines) |
439 |
(define-key map "\C-c\C-f" 'f90-fill-region) |
(define-key map "\C-c\C-f" 'f90-fill-region) |
440 |
(define-key map "\C-c\C-p" 'f90-previous-statement) |
(define-key map "\C-c\C-p" 'f90-previous-statement) |
1189 |
not-last-statement)) |
not-last-statement)) |
1190 |
|
|
1191 |
(defun f90-beginning-of-subprogram () |
(defun f90-beginning-of-subprogram () |
1192 |
"Move point to the beginning of subprogram. |
"Move point to the beginning of the current subprogram. |
1193 |
Return (TYPE NAME), or nil if not found." |
Return (TYPE NAME), or nil if not found." |
1194 |
(interactive) |
(interactive) |
1195 |
(let ((count 1) (case-fold-search t) matching-beg) |
(let ((count 1) (case-fold-search t) matching-beg) |
1196 |
(beginning-of-line) |
(beginning-of-line) |
1197 |
(skip-chars-forward " \t0-9") |
(while (and (> count 0) |
|
(if (setq matching-beg (f90-looking-at-program-block-start)) |
|
|
(setq count (1- count))) |
|
|
(while (and (not (zerop count)) |
|
1198 |
(re-search-backward f90-program-block-re nil 'move)) |
(re-search-backward f90-program-block-re nil 'move)) |
1199 |
(beginning-of-line) |
(beginning-of-line) |
1200 |
(skip-chars-forward " \t0-9") |
(skip-chars-forward " \t0-9") |
1209 |
nil))) |
nil))) |
1210 |
|
|
1211 |
(defun f90-end-of-subprogram () |
(defun f90-end-of-subprogram () |
1212 |
"Move point to the end of subprogram. |
"Move point to the end of the current subprogram. |
1213 |
Return (TYPE NAME), or nil if not found." |
Return (TYPE NAME), or nil if not found." |
1214 |
(interactive) |
(interactive) |
1215 |
(let ((count 1) (case-fold-search t) matching-end) |
(let ((count 1) (case-fold-search t) matching-end) |
|
(beginning-of-line) |
|
|
(skip-chars-forward " \t0-9") |
|
|
(if (setq matching-end (f90-looking-at-program-block-end)) |
|
|
(setq count (1- count))) |
|
1216 |
(end-of-line) |
(end-of-line) |
1217 |
(while (and (not (zerop count)) |
(while (and (> count 0) |
1218 |
(re-search-forward f90-program-block-re nil 'move)) |
(re-search-forward f90-program-block-re nil 'move)) |
1219 |
(beginning-of-line) |
(beginning-of-line) |
1220 |
(skip-chars-forward " \t0-9") |
(skip-chars-forward " \t0-9") |
1278 |
(error "End label `%s' does not match start label `%s'" |
(error "End label `%s' does not match start label `%s'" |
1279 |
end-label start-label))))) |
end-label start-label))))) |
1280 |
(end-of-line)) |
(end-of-line)) |
1281 |
(if (> count 0) (error "Unterminated block")) |
(if (> count 0) (error "Missing block end")) |
1282 |
;; Check outermost block. |
;; Check outermost block. |
1283 |
(if (interactive-p) |
(if (interactive-p) |
1284 |
(save-excursion |
(save-excursion |
1333 |
start-label end-label)))))) |
start-label end-label)))))) |
1334 |
(if (> count 0) (error "Missing block start")))) |
(if (> count 0) (error "Missing block start")))) |
1335 |
|
|
1336 |
(defun f90-next-block-end (&optional num) |
(defun f90-next-block (&optional num) |
1337 |
"Move point forward to the next block end. |
"Move point forward to the next end or start of a code block. |
1338 |
With optional argument NUM, go forward that many block ends. |
With optional argument NUM, go forward that many blocks. |
1339 |
If NUM is negative, go backward to the start of a block." |
If NUM is negative, go backwards. |
1340 |
|
A block is a subroutine, if-endif, etc." |
1341 |
(interactive "p") |
(interactive "p") |
1342 |
(if (and num (< num 0)) (f90-previous-block-start (- num))) |
(let ((case-fold-search t) |
1343 |
(let ((count (or num 1)) |
(count (if num (abs num) 1))) |
1344 |
(end-re (concat "end[ \t]*" f90-blocks-re))) |
(while (and (> count 0) |
1345 |
(while (and (> count 0) (re-search-forward end-re nil 'move)) |
(if (> num 0) (re-search-forward f90-blocks-re nil 'move) |
1346 |
|
(re-search-backward f90-blocks-re nil 'move))) |
1347 |
(beginning-of-line) |
(beginning-of-line) |
1348 |
(skip-chars-forward " \t0-9") |
(skip-chars-forward " \t0-9") |
1349 |
(or (f90-in-string) (f90-in-comment) |
(cond ((or (f90-in-string) (f90-in-comment))) |
1350 |
(setq count (1- count))) |
((or |
1351 |
(end-of-line)))) |
(looking-at "end[ \t]*") |
1352 |
|
(f90-looking-at-do) |
1353 |
(defun f90-previous-block-start (&optional num) |
(f90-looking-at-select-case) |
1354 |
"Move point backward to the previous block start. |
(f90-looking-at-type-like) |
1355 |
With optional argument NUM, go backward that many block starts. |
(f90-looking-at-program-block-start) |
1356 |
If NUM is negative, go forward to the end of a block." |
(f90-looking-at-if-then) |
1357 |
|
(f90-looking-at-where-or-forall)) |
1358 |
|
(setq count (1- count)))) |
1359 |
|
(if (> num 0) (end-of-line) |
1360 |
|
(beginning-of-line))))) |
1361 |
|
|
1362 |
|
|
1363 |
|
(defun f90-previous-block (&optional num) |
1364 |
|
"Move point backward to the previous end or start of a code block. |
1365 |
|
With optional argument NUM, go backward that many blocks. |
1366 |
|
If NUM is negative, go forwards. |
1367 |
|
A block is a subroutine, if-endif, etc." |
1368 |
(interactive "p") |
(interactive "p") |
1369 |
(if (and num (< num 0)) (f90-next-block-end (- num))) |
(f90-next-block (- (or num 1)))) |
|
(let ((count (or num 1))) |
|
|
(while (and (> count 0) (re-search-backward f90-blocks-re nil 'move)) |
|
|
(beginning-of-line) |
|
|
(skip-chars-forward " \t0-9") |
|
|
(or (f90-in-string) (f90-in-comment) |
|
|
(and (or (f90-looking-at-do) |
|
|
(f90-looking-at-select-case) |
|
|
(f90-looking-at-type-like) |
|
|
(f90-looking-at-program-block-start) |
|
|
(f90-looking-at-if-then) |
|
|
(f90-looking-at-where-or-forall)) |
|
|
(setq count (1- count))))))) |
|
1370 |
|
|
1371 |
|
|
1372 |
(defvar f90-mark-subprogram-overlay nil |
(defvar f90-mark-subprogram-overlay nil |