aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2002-05-24 22:00:21 +0000
committerGlenn Morris2002-05-24 22:00:21 +0000
commit6f1d50da8340f9060f0be59b84e85b045c5832ed (patch)
treedff3ec63c1b3c9ceee74b2e90d0cf820295002a4
parent6ca4a60d8d36b8967ccee2e1d54cdbba00cbe052 (diff)
downloademacs-6f1d50da8340f9060f0be59b84e85b045c5832ed.tar.gz
emacs-6f1d50da8340f9060f0be59b84e85b045c5832ed.zip
(f90-end-of-subprogram): Remove the final (forward-line 1).
(f90-end-of-block, f90-beginning-of-block, f90-next-block-end, f90-previous-block-start): New navigation commands.
-rw-r--r--lisp/progmodes/f90.el145
1 files changed, 144 insertions, 1 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index 0e6eed254d0..eac1737382e 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -426,11 +426,15 @@ do\\([ \t]*while\\)?\\|select[ \t]*case\\|where\\|forall\\)\\)\\>"
426 (define-key map "\C-\M-a" 'f90-beginning-of-subprogram) 426 (define-key map "\C-\M-a" 'f90-beginning-of-subprogram)
427 (define-key map "\C-\M-e" 'f90-end-of-subprogram) 427 (define-key map "\C-\M-e" 'f90-end-of-subprogram)
428 (define-key map "\C-\M-h" 'f90-mark-subprogram) 428 (define-key map "\C-\M-h" 'f90-mark-subprogram)
429 (define-key map "\C-\M-n" 'f90-end-of-block)
430 (define-key map "\C-\M-p" 'f90-beginning-of-block)
429 (define-key map "\C-\M-q" 'f90-indent-subprogram) 431 (define-key map "\C-\M-q" 'f90-indent-subprogram)
430 (define-key map "\C-j" 'f90-indent-new-line) ; LFD equals C-j 432 (define-key map "\C-j" 'f90-indent-new-line) ; LFD equals C-j
431 (define-key map "\r" 'newline) 433 (define-key map "\r" 'newline)
432 (define-key map "\C-c\r" 'f90-break-line) 434 (define-key map "\C-c\r" 'f90-break-line)
433;;; (define-key map [M-return] 'f90-break-line) 435;;; (define-key map [M-return] 'f90-break-line)
436 (define-key map "\C-c\C-a" 'f90-previous-block-start)
437 (define-key map "\C-c\C-e" 'f90-next-block-end)
434 (define-key map "\C-c\C-d" 'f90-join-lines) 438 (define-key map "\C-c\C-d" 'f90-join-lines)
435 (define-key map "\C-c\C-f" 'f90-fill-region) 439 (define-key map "\C-c\C-f" 'f90-fill-region)
436 (define-key map "\C-c\C-p" 'f90-previous-statement) 440 (define-key map "\C-c\C-p" 'f90-previous-statement)
@@ -1226,12 +1230,151 @@ Return (TYPE NAME), or nil if not found."
1226 ((setq matching-end (f90-looking-at-program-block-end)) 1230 ((setq matching-end (f90-looking-at-program-block-end))
1227 (setq count (1- count)))) 1231 (setq count (1- count))))
1228 (end-of-line)) 1232 (end-of-line))
1229 (forward-line 1) 1233 ;; This means f90-end-of-subprogram followed by f90-start-of-subprogram
1234 ;; has a net non-zero effect, which seems odd.
1235;;; (forward-line 1)
1230 (if (zerop count) 1236 (if (zerop count)
1231 matching-end 1237 matching-end
1232 (message "No end found.") 1238 (message "No end found.")
1233 nil))) 1239 nil)))
1234 1240
1241
1242(defun f90-end-of-block (&optional num)
1243 "Move point forward to the end of the current code block.
1244With optional argument NUM, go forward that many balanced blocks.
1245If NUM is negative, go backward to the start of a block.
1246Checks for consistency of block types and labels (if present),
1247and completes outermost block if necessary."
1248 (interactive "p")
1249 (if (and num (< num 0)) (f90-beginning-of-block (- num)))
1250 (let ((f90-smart-end nil) ; for the final `f90-match-end'
1251 (case-fold-search t)
1252 (count (or num 1))
1253 start-list start-this start-type start-label end-type end-label)
1254 (if (interactive-p) (push-mark (point) t))
1255 (end-of-line) ; probably want this
1256 (while (and (> count 0) (re-search-forward f90-blocks-re nil 'move))
1257 (beginning-of-line)
1258 (skip-chars-forward " \t0-9")
1259 (cond ((or (f90-in-string) (f90-in-comment)))
1260 ((setq start-this
1261 (or
1262 (f90-looking-at-do)
1263 (f90-looking-at-select-case)
1264 (f90-looking-at-type-like)
1265 (f90-looking-at-program-block-start)
1266 (f90-looking-at-if-then)
1267 (f90-looking-at-where-or-forall)))
1268 (setq start-list (cons start-this start-list) ; not add-to-list!
1269 count (1+ count)))
1270 ((looking-at (concat "end[ \t]*" f90-blocks-re
1271 "[ \t]*\\(\\sw+\\)?"))
1272 (setq end-type (match-string 1)
1273 end-label (match-string 2)
1274 count (1- count))
1275 ;; Check any internal blocks.
1276 (when start-list
1277 (setq start-this (car start-list)
1278 start-list (cdr start-list)
1279 start-type (car start-this)
1280 start-label (cadr start-this))
1281 (if (not (f90-equal-symbols start-type end-type))
1282 (error "End type `%s' does not match start type `%s'"
1283 end-type start-type))
1284 (if (not (f90-equal-symbols start-label end-label))
1285 (error "End label `%s' does not match start label `%s'"
1286 end-label start-label)))))
1287 (end-of-line))
1288 (if (> count 0) (error "Unterminated block"))
1289 ;; Check outermost block.
1290 (if (interactive-p)
1291 (save-excursion
1292 (beginning-of-line)
1293 (skip-chars-forward " \t0-9")
1294 (f90-match-end)))))
1295
1296(defun f90-beginning-of-block (&optional num)
1297 "Move point backwards to the start of the current code block.
1298With optional argument NUM, go backward that many balanced blocks.
1299If NUM is negative, go forward to the end of a block.
1300Checks for consistency of block types and labels (if present).
1301Does not check the outermost block, because it may be incomplete."
1302 (interactive "p")
1303 (if (and num (< num 0)) (f90-end-of-block (- num)))
1304 (let ((case-fold-search t)
1305 (count (or num 1))
1306 end-list end-this end-type end-label start-this start-type start-label)
1307 (if (interactive-p) (push-mark (point) t))
1308 (beginning-of-line) ; probably want this
1309 (while (and (> count 0) (re-search-backward f90-blocks-re nil 'move))
1310 (beginning-of-line)
1311 (skip-chars-forward " \t0-9")
1312 (cond ((or (f90-in-string) (f90-in-comment)))
1313 ((looking-at (concat "end[ \t]*" f90-blocks-re
1314 "[ \t]*\\(\\sw+\\)?"))
1315 (setq end-list (cons (list (match-string 1) (match-string 2))
1316 end-list)
1317 count (1+ count)))
1318 ((setq start-this
1319 (or
1320 (f90-looking-at-do)
1321 (f90-looking-at-select-case)
1322 (f90-looking-at-type-like)
1323 (f90-looking-at-program-block-start)
1324 (f90-looking-at-if-then)
1325 (f90-looking-at-where-or-forall)))
1326 (setq start-type (car start-this)
1327 start-label (cadr start-this)
1328 count (1- count))
1329 ;; Check any internal blocks.
1330 (when end-list
1331 (setq end-this (car end-list)
1332 end-list (cdr end-list)
1333 end-type (car end-this)
1334 end-label (cadr end-this))
1335 (if (not (f90-equal-symbols start-type end-type))
1336 (error "Start type `%s' does not match end type `%s'"
1337 start-type end-type))
1338 (if (not (f90-equal-symbols start-label end-label))
1339 (error "Start label `%s' does not match end label `%s'"
1340 start-label end-label))))))
1341 (if (> count 0) (error "Missing block start"))))
1342
1343(defun f90-next-block-end (&optional num)
1344 "Move point forward to the next block end.
1345With optional argument NUM, go forward that many block ends.
1346If NUM is negative, go backward to the start of a block."
1347 (interactive "p")
1348 (if (and num (< num 0)) (f90-previous-block-start (- num)))
1349 (let ((count (or num 1))
1350 (end-re (concat "end[ \t]*" f90-blocks-re)))
1351 (while (and (> count 0) (re-search-forward end-re nil 'move))
1352 (beginning-of-line)
1353 (skip-chars-forward " \t0-9")
1354 (or (f90-in-string) (f90-in-comment)
1355 (setq count (1- count)))
1356 (end-of-line))))
1357
1358(defun f90-previous-block-start (&optional num)
1359 "Move point backward to the previous block start.
1360With optional argument NUM, go backward that many block starts.
1361If NUM is negative, go forward to the end of a block."
1362 (interactive "p")
1363 (if (and num (< num 0)) (f90-next-block-end (- num)))
1364 (let ((count (or num 1)))
1365 (while (and (> count 0) (re-search-backward f90-blocks-re nil 'move))
1366 (beginning-of-line)
1367 (skip-chars-forward " \t0-9")
1368 (or (f90-in-string) (f90-in-comment)
1369 (and (or (f90-looking-at-do)
1370 (f90-looking-at-select-case)
1371 (f90-looking-at-type-like)
1372 (f90-looking-at-program-block-start)
1373 (f90-looking-at-if-then)
1374 (f90-looking-at-where-or-forall))
1375 (setq count (1- count)))))))
1376
1377
1235(defvar f90-mark-subprogram-overlay nil 1378(defvar f90-mark-subprogram-overlay nil
1236 "Used internally by `f90-mark-subprogram' to highlight the subprogram.") 1379 "Used internally by `f90-mark-subprogram' to highlight the subprogram.")
1237(make-variable-buffer-local 'f90-mark-subprogram-overlay) 1380(make-variable-buffer-local 'f90-mark-subprogram-overlay)