aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2003-04-16 11:08:58 +0000
committerGlenn Morris2003-04-16 11:08:58 +0000
commit748dd5a8afe96f03066ebba52509c9a1775c720d (patch)
tree9bf092c971d46f8f2e1eab0b6394f36f695b3f5a
parentc5c3d778cc874e6734e7d5a6bed0ea037b599dec (diff)
downloademacs-748dd5a8afe96f03066ebba52509c9a1775c720d.tar.gz
emacs-748dd5a8afe96f03066ebba52509c9a1775c720d.zip
(f90-indent-to, f90-indent-line-no)
(f90-no-block-limit, f90-end-of-block, f90-beginning-of-block) (f90-comment-region, f90-indent-line, f90-indent-region) (f90-find-breakpoint, f90-block-match): Trivial simplifications. (f90-looking-at-do, f90-looking-at-select-case) (f90-looking-at-if-then, f90-looking-at-where-or-forall): Drop XEmacs 19 support and simplify. (f90-indent-new-line): No need for case-fold-search. Simplify. (f90-fill-region): Make marker nil when done. Simplify.
-rw-r--r--lisp/progmodes/f90.el206
1 files changed, 103 insertions, 103 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index 8384dfdcf6e..47e200ee357 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -770,7 +770,6 @@ with no args, if that value is non-nil."
770 f90-font-lock-keywords-3 770 f90-font-lock-keywords-3
771 f90-font-lock-keywords-4) 771 f90-font-lock-keywords-4)
772 nil t)) 772 nil t))
773 ;; Tell imenu how to handle f90.
774 (set (make-local-variable 'imenu-case-fold-search) t) 773 (set (make-local-variable 'imenu-case-fold-search) t)
775 (set (make-local-variable 'imenu-generic-expression) 774 (set (make-local-variable 'imenu-generic-expression)
776 f90-imenu-generic-expression) 775 f90-imenu-generic-expression)
@@ -817,6 +816,9 @@ not the last line of a continued statement."
817 (skip-chars-backward " \t") 816 (skip-chars-backward " \t")
818 (= (preceding-char) ?&))) 817 (= (preceding-char) ?&)))
819 818
819;; GM this is not right, eg a continuation line starting with a number.
820;; Need f90-code-start-position function.
821;; And yet, things seems to work with this...
820(defsubst f90-current-indentation () 822(defsubst f90-current-indentation ()
821 "Return indentation of current line. 823 "Return indentation of current line.
822Line-numbers are considered whitespace characters." 824Line-numbers are considered whitespace characters."
@@ -827,12 +829,11 @@ Line-numbers are considered whitespace characters."
827If optional argument NO-LINE-NUMBER is nil, jump over a possible 829If optional argument NO-LINE-NUMBER is nil, jump over a possible
828line-number before indenting." 830line-number before indenting."
829 (beginning-of-line) 831 (beginning-of-line)
830 (if (not no-line-number) 832 (or no-line-number
831 (skip-chars-forward " \t0-9")) 833 (skip-chars-forward " \t0-9"))
832 (delete-horizontal-space) 834 (delete-horizontal-space)
833 (if (zerop (current-column)) 835 ;; Leave >= 1 space after line number.
834 (indent-to col) 836 (indent-to col (if (zerop (current-column)) 0 1)))
835 (indent-to col 1))) ; leave >= 1 space after line number
836 837
837(defsubst f90-get-present-comment-type () 838(defsubst f90-get-present-comment-type ()
838 "If point lies within a comment, return the string starting the comment. 839 "If point lies within a comment, return the string starting the comment.
@@ -850,22 +851,18 @@ For example, \"!\" or \"!!\"."
850 (equal (if a (downcase a) nil) 851 (equal (if a (downcase a) nil)
851 (if b (downcase b) nil))) 852 (if b (downcase b) nil)))
852 853
853;; XEmacs 19.11 & 19.12 return a single char when matching an empty regexp.
854;; The next 2 functions are therefore longer than necessary.
855(defsubst f90-looking-at-do () 854(defsubst f90-looking-at-do ()
856 "Return (\"do\" NAME) if a do statement starts after point. 855 "Return (\"do\" NAME) if a do statement starts after point.
857NAME is nil if the statement has no label." 856NAME is nil if the statement has no label."
858 (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(do\\)\\>") 857 (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(do\\)\\>")
859 (list (match-string 3) 858 (list (match-string 3) (match-string 2)))
860 (if (looking-at "\\(\\sw+\\)[ \t]*:") (match-string 1)))))
861 859
862(defsubst f90-looking-at-select-case () 860(defsubst f90-looking-at-select-case ()
863 "Return (\"select\" NAME) if a select-case statement starts after point. 861 "Return (\"select\" NAME) if a select-case statement starts after point.
864NAME is nil if the statement has no label." 862NAME is nil if the statement has no label."
865 (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\ 863 (if (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\
866\\(select\\)[ \t]*case[ \t]*(") 864\\(select\\)[ \t]*case[ \t]*(")
867 (list (match-string 3) 865 (list (match-string 3) (match-string 2))))
868 (if (looking-at "\\(\\sw+\\)[ \t]*:") (match-string 1)))))
869 866
870(defsubst f90-looking-at-if-then () 867(defsubst f90-looking-at-if-then ()
871 "Return (\"if\" NAME) if an if () then statement starts after point. 868 "Return (\"if\" NAME) if an if () then statement starts after point.
@@ -873,7 +870,7 @@ NAME is nil if the statement has no label."
873 (save-excursion 870 (save-excursion
874 (when (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(if\\)\\>") 871 (when (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\\(if\\)\\>")
875 (let ((struct (match-string 3)) 872 (let ((struct (match-string 3))
876 (label (if (looking-at "\\(\\sw+\\)[ \t]*:") (match-string 1))) 873 (label (match-string 2))
877 (pos (scan-lists (point) 1 0))) 874 (pos (scan-lists (point) 1 0)))
878 (and pos (goto-char pos)) 875 (and pos (goto-char pos))
879 (skip-chars-forward " \t") 876 (skip-chars-forward " \t")
@@ -891,7 +888,7 @@ NAME is nil if the statement has no label."
891 (when (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\ 888 (when (looking-at "\\(\\(\\sw+\\)[ \t]*:\\)?[ \t]*\
892\\(where\\|forall\\)\\>") 889\\(where\\|forall\\)\\>")
893 (let ((struct (match-string 3)) 890 (let ((struct (match-string 3))
894 (label (if (looking-at "\\(\\sw+\\)[ \t]*:") (match-string 1))) 891 (label (match-string 2))
895 (pos (scan-lists (point) 1 0))) 892 (pos (scan-lists (point) 1 0)))
896 (and pos (goto-char pos)) 893 (and pos (goto-char pos))
897 (skip-chars-forward " \t") 894 (skip-chars-forward " \t")
@@ -915,8 +912,8 @@ NAME is non-nil only for type."
915 (looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>")) 912 (looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>"))
916 (list (match-string 1) (match-string 2))) 913 (list (match-string 1) (match-string 2)))
917 ((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)")) 914 ((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)"))
918 (looking-at "[^!'\"\&\n]*\\(function\\|subroutine\\)\ 915 (looking-at "[^!'\"\&\n]*\\(function\\|subroutine\\)[ \t]+\
919[ \t]+\\(\\sw+\\)")) 916\\(\\sw+\\)"))
920 (list (match-string 1) (match-string 2))))) 917 (list (match-string 1) (match-string 2)))))
921 918
922(defsubst f90-looking-at-program-block-end () 919(defsubst f90-looking-at-program-block-end ()
@@ -966,24 +963,24 @@ Comment lines embedded amongst continued lines return 'middle."
966 "If `f90-leave-line-no' is nil, left-justify a line number. 963 "If `f90-leave-line-no' is nil, left-justify a line number.
967Leaves point at the first non-blank character after the line number. 964Leaves point at the first non-blank character after the line number.
968Call from beginning of line." 965Call from beginning of line."
969 (if (and (null f90-leave-line-no) (looking-at "[ \t]+[0-9]")) 966 (and (null f90-leave-line-no) (looking-at "[ \t]+[0-9]")
970 (delete-horizontal-space)) 967 (delete-horizontal-space))
971 (skip-chars-forward " \t0-9")) 968 (skip-chars-forward " \t0-9"))
972 969
973(defsubst f90-no-block-limit () 970(defsubst f90-no-block-limit ()
974 "Return nil if point is at the edge of a code block. 971 "Return nil if point is at the edge of a code block.
975Searches line forward for \"function\" or \"subroutine\", 972Searches line forward for \"function\" or \"subroutine\",
976if all else fails." 973if all else fails."
977 (let ((eol (line-end-position))) 974 (save-excursion
978 (save-excursion 975 (not (or (looking-at "end")
979 (not (or (looking-at "end") 976 (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\
980 (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\
981\\|select[ \t]*case\\|case\\|where\\|forall\\)\\>") 977\\|select[ \t]*case\\|case\\|where\\|forall\\)\\>")
982 (looking-at "\\(program\\|module\\|interface\\|\ 978 (looking-at "\\(program\\|module\\|interface\\|\
983block[ \t]*data\\)\\>") 979block[ \t]*data\\)\\>")
984 (looking-at "\\(contains\\|\\sw+[ \t]*:\\)") 980 (looking-at "\\(contains\\|\\sw+[ \t]*:\\)")
985 (looking-at f90-type-def-re) 981 (looking-at f90-type-def-re)
986 (re-search-forward "\\(function\\|subroutine\\)" eol t)))))) 982 (re-search-forward "\\(function\\|subroutine\\)"
983 (line-end-position) t)))))
987 984
988(defsubst f90-update-line () 985(defsubst f90-update-line ()
989 "Change case of current line as per `f90-auto-keyword-case'." 986 "Change case of current line as per `f90-auto-keyword-case'."
@@ -1196,10 +1193,10 @@ and completes outermost block if necessary."
1196 start-list (cdr start-list) 1193 start-list (cdr start-list)
1197 start-type (car start-this) 1194 start-type (car start-this)
1198 start-label (cadr start-this)) 1195 start-label (cadr start-this))
1199 (if (not (f90-equal-symbols start-type end-type)) 1196 (or (f90-equal-symbols start-type end-type)
1200 (error "End type `%s' does not match start type `%s'" 1197 (error "End type `%s' does not match start type `%s'"
1201 end-type start-type)) 1198 end-type start-type))
1202 (if (not (f90-equal-symbols start-label end-label)) 1199 (or (f90-equal-symbols start-label end-label)
1203 (error "End label `%s' does not match start label `%s'" 1200 (error "End label `%s' does not match start label `%s'"
1204 end-label start-label))))) 1201 end-label start-label)))))
1205 (end-of-line)) 1202 (end-of-line))
@@ -1221,7 +1218,8 @@ Does not check the outermost block, because it may be incomplete."
1221 (if (and num (< num 0)) (f90-end-of-block (- num))) 1218 (if (and num (< num 0)) (f90-end-of-block (- num)))
1222 (let ((case-fold-search t) 1219 (let ((case-fold-search t)
1223 (count (or num 1)) 1220 (count (or num 1))
1224 end-list end-this end-type end-label start-this start-type start-label) 1221 end-list end-this end-type end-label
1222 start-this start-type start-label)
1225 (if (interactive-p) (push-mark (point) t)) 1223 (if (interactive-p) (push-mark (point) t))
1226 (beginning-of-line) ; probably want this 1224 (beginning-of-line) ; probably want this
1227 (while (and (> count 0) (re-search-backward f90-blocks-re nil 'move)) 1225 (while (and (> count 0) (re-search-backward f90-blocks-re nil 'move))
@@ -1250,10 +1248,10 @@ Does not check the outermost block, because it may be incomplete."
1250 end-list (cdr end-list) 1248 end-list (cdr end-list)
1251 end-type (car end-this) 1249 end-type (car end-this)
1252 end-label (cadr end-this)) 1250 end-label (cadr end-this))
1253 (if (not (f90-equal-symbols start-type end-type)) 1251 (or (f90-equal-symbols start-type end-type)
1254 (error "Start type `%s' does not match end type `%s'" 1252 (error "Start type `%s' does not match end type `%s'"
1255 start-type end-type)) 1253 start-type end-type))
1256 (if (not (f90-equal-symbols start-label end-label)) 1254 (or (f90-equal-symbols start-label end-label)
1257 (error "Start label `%s' does not match end label `%s'" 1255 (error "Start label `%s' does not match end label `%s'"
1258 start-label end-label)))))) 1256 start-label end-label))))))
1259 (if (> count 0) (error "Missing block start")))) 1257 (if (> count 0) (error "Missing block start"))))
@@ -1313,15 +1311,14 @@ A block is a subroutine, if-endif, etc."
1313Insert the variable `f90-comment-region' at the start of every line 1311Insert the variable `f90-comment-region' at the start of every line
1314in the region, or, if already present, remove it." 1312in the region, or, if already present, remove it."
1315 (interactive "*r") 1313 (interactive "*r")
1316 (let ((end (make-marker))) 1314 (let ((end (copy-marker end-region)))
1317 (set-marker end end-region)
1318 (goto-char beg-region) 1315 (goto-char beg-region)
1319 (beginning-of-line) 1316 (beginning-of-line)
1320 (if (looking-at (regexp-quote f90-comment-region)) 1317 (if (looking-at (regexp-quote f90-comment-region))
1321 (delete-region (point) (match-end 0)) 1318 (delete-region (point) (match-end 0))
1322 (insert f90-comment-region)) 1319 (insert f90-comment-region))
1323 (while (and (zerop (forward-line 1)) 1320 (while (and (zerop (forward-line 1))
1324 (< (point) (marker-position end))) 1321 (< (point) end))
1325 (if (looking-at (regexp-quote f90-comment-region)) 1322 (if (looking-at (regexp-quote f90-comment-region))
1326 (delete-region (point) (match-end 0)) 1323 (delete-region (point) (match-end 0))
1327 (insert f90-comment-region))) 1324 (insert f90-comment-region)))
@@ -1332,26 +1329,29 @@ in the region, or, if already present, remove it."
1332Unless optional argument NO-UPDATE is non-nil, call `f90-update-line' 1329Unless optional argument NO-UPDATE is non-nil, call `f90-update-line'
1333after indenting." 1330after indenting."
1334 (interactive "*P") 1331 (interactive "*P")
1335 (let (indent no-line-number (pos (make-marker)) (case-fold-search t)) 1332 (let ((case-fold-search t)
1336 (set-marker pos (point)) 1333 (pos (point-marker))
1337 (beginning-of-line) ; digits after & \n are not line-nos 1334 indent no-line-number)
1338 (if (save-excursion (and (f90-previous-statement) (f90-line-continued))) 1335 (beginning-of-line) ; digits after & \n are not line-nos
1339 (progn (setq no-line-number t) (skip-chars-forward " \t")) 1336 (if (not (save-excursion (and (f90-previous-statement)
1340 (f90-indent-line-no)) 1337 (f90-line-continued))))
1338 (f90-indent-line-no)
1339 (setq no-line-number t)
1340 (skip-chars-forward " \t"))
1341 (if (looking-at "!") 1341 (if (looking-at "!")
1342 (setq indent (f90-comment-indent)) 1342 (setq indent (f90-comment-indent))
1343 (if (and (looking-at "end") f90-smart-end) 1343 (and f90-smart-end (looking-at "end")
1344 (f90-match-end)) 1344 (f90-match-end))
1345 (setq indent (f90-calculate-indent))) 1345 (setq indent (f90-calculate-indent)))
1346 (if (not (zerop (- indent (current-column)))) 1346 (or (= indent (current-column))
1347 (f90-indent-to indent no-line-number)) 1347 (f90-indent-to indent no-line-number))
1348 ;; If initial point was within line's indentation, 1348 ;; If initial point was within line's indentation,
1349 ;; position after the indentation. Else stay at same point in text. 1349 ;; position after the indentation. Else stay at same point in text.
1350 (if (< (point) (marker-position pos)) 1350 (and (< (point) pos)
1351 (goto-char (marker-position pos))) 1351 (goto-char pos))
1352 (if auto-fill-function 1352 (if auto-fill-function
1353 (f90-do-auto-fill) ; also updates line 1353 (f90-do-auto-fill) ; also updates line
1354 (if (not no-update) (f90-update-line))) 1354 (or no-update (f90-update-line)))
1355 (set-marker pos nil))) 1355 (set-marker pos nil)))
1356 1356
1357(defun f90-indent-new-line () 1357(defun f90-indent-new-line ()
@@ -1359,30 +1359,27 @@ after indenting."
1359An abbrev before point is expanded if the variable `abbrev-mode' is non-nil. 1359An abbrev before point is expanded if the variable `abbrev-mode' is non-nil.
1360If run in the middle of a line, the line is not broken." 1360If run in the middle of a line, the line is not broken."
1361 (interactive "*") 1361 (interactive "*")
1362 (let (string cont (case-fold-search t)) 1362 (if abbrev-mode (expand-abbrev))
1363 (if abbrev-mode (expand-abbrev)) 1363 (beginning-of-line) ; reindent where likely to be needed
1364 (beginning-of-line) ; reindent where likely to be needed 1364 (f90-indent-line-no)
1365 (f90-indent-line-no) 1365 (f90-indent-line 'no-update)
1366 (f90-indent-line 'no-update) 1366 (end-of-line)
1367 (end-of-line) 1367 (delete-horizontal-space) ; destroy trailing whitespace
1368 (delete-horizontal-space) ; destroy trailing whitespace 1368 (let ((string (f90-in-string))
1369 (setq string (f90-in-string) 1369 (cont (f90-line-continued)))
1370 cont (f90-line-continued)) 1370 (and string (not cont) (insert "&"))
1371 (if (and string (not cont)) (insert "&"))
1372 (f90-update-line) 1371 (f90-update-line)
1373 (newline) 1372 (newline)
1374 (if (or string (and cont f90-beginning-ampersand)) (insert "&")) 1373 (if (or string (and cont f90-beginning-ampersand)) (insert "&")))
1375 (f90-indent-line 'no-update))) 1374 (f90-indent-line 'no-update))
1376 1375
1377 1376
1378(defun f90-indent-region (beg-region end-region) 1377(defun f90-indent-region (beg-region end-region)
1379 "Indent every line in region by forward parsing." 1378 "Indent every line in region by forward parsing."
1380 (interactive "*r") 1379 (interactive "*r")
1381 (let ((end-region-mark (make-marker)) 1380 (let ((end-region-mark (copy-marker end-region))
1382 (save-point (point-marker)) 1381 (save-point (point-marker))
1383 block-list ind-lev ind-curr ind-b cont 1382 block-list ind-lev ind-curr ind-b cont struct beg-struct end-struct)
1384 struct beg-struct end-struct)
1385 (set-marker end-region-mark end-region)
1386 (goto-char beg-region) 1383 (goto-char beg-region)
1387 ;; First find a line which is not a continuation line or comment. 1384 ;; First find a line which is not a continuation line or comment.
1388 (beginning-of-line) 1385 (beginning-of-line)
@@ -1419,8 +1416,8 @@ If run in the middle of a line, the line is not broken."
1419 (< (point) end-region-mark)) 1416 (< (point) end-region-mark))
1420 (if (looking-at "[ \t]*!") 1417 (if (looking-at "[ \t]*!")
1421 (f90-indent-to (f90-comment-indent)) 1418 (f90-indent-to (f90-comment-indent))
1422 (if (not (zerop (- (current-indentation) 1419 (or (= (current-indentation)
1423 (+ ind-curr f90-continuation-indent)))) 1420 (+ ind-curr f90-continuation-indent))
1424 (f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no)))) 1421 (f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no))))
1425 ;; Process all following lines. 1422 ;; Process all following lines.
1426 (while (and (zerop (forward-line 1)) (< (point) end-region-mark)) 1423 (while (and (zerop (forward-line 1)) (< (point) end-region-mark))
@@ -1465,14 +1462,14 @@ If run in the middle of a line, the line is not broken."
1465 (setq ind-curr ind-lev)) 1462 (setq ind-curr ind-lev))
1466 (t (setq ind-curr ind-lev))) 1463 (t (setq ind-curr ind-lev)))
1467 ;; Do the indentation if necessary. 1464 ;; Do the indentation if necessary.
1468 (if (not (zerop (- ind-curr (current-column)))) 1465 (or (= ind-curr (current-column))
1469 (f90-indent-to ind-curr)) 1466 (f90-indent-to ind-curr))
1470 (while (and (f90-line-continued) (zerop (forward-line 1)) 1467 (while (and (f90-line-continued) (zerop (forward-line 1))
1471 (< (point) end-region-mark)) 1468 (< (point) end-region-mark))
1472 (if (looking-at "[ \t]*!") 1469 (if (looking-at "[ \t]*!")
1473 (f90-indent-to (f90-comment-indent)) 1470 (f90-indent-to (f90-comment-indent))
1474 (if (not (zerop (- (current-indentation) 1471 (or (= (current-indentation)
1475 (+ ind-curr f90-continuation-indent)))) 1472 (+ ind-curr f90-continuation-indent))
1476 (f90-indent-to 1473 (f90-indent-to
1477 (+ ind-curr f90-continuation-indent) 'no-line-no))))) 1474 (+ ind-curr f90-continuation-indent) 'no-line-no)))))
1478 ;; Restore point, etc. 1475 ;; Restore point, etc.
@@ -1517,15 +1514,12 @@ is non-nil, call `f90-update-line' after inserting the continuation marker."
1517 1514
1518(defun f90-find-breakpoint () 1515(defun f90-find-breakpoint ()
1519 "From `fill-column', search backward for break-delimiter." 1516 "From `fill-column', search backward for break-delimiter."
1520 (let ((bol (line-beginning-position))) 1517 (re-search-backward f90-break-delimiters (line-beginning-position))
1521 (re-search-backward f90-break-delimiters bol) 1518 (if (not f90-break-before-delimiters)
1522 (if (not f90-break-before-delimiters) 1519 (forward-char (if (looking-at f90-no-break-re) 2 1))
1523 (if (looking-at f90-no-break-re) 1520 (backward-char)
1524 (forward-char 2) 1521 (or (looking-at f90-no-break-re)
1525 (forward-char)) 1522 (forward-char)))))
1526 (backward-char)
1527 (if (not (looking-at f90-no-break-re))
1528 (forward-char)))))
1529 1523
1530(defun f90-do-auto-fill () 1524(defun f90-do-auto-fill ()
1531 "Break line if non-white characters beyond `fill-column'. 1525 "Break line if non-white characters beyond `fill-column'.
@@ -1570,10 +1564,9 @@ Like `join-line', but handles F90 syntax."
1570(defun f90-fill-region (beg-region end-region) 1564(defun f90-fill-region (beg-region end-region)
1571 "Fill every line in region by forward parsing. Join lines if possible." 1565 "Fill every line in region by forward parsing. Join lines if possible."
1572 (interactive "*r") 1566 (interactive "*r")
1573 (let ((end-region-mark (make-marker)) 1567 (let ((end-region-mark (copy-marker end-region))
1574 (go-on t) 1568 (go-on t)
1575 f90-smart-end f90-auto-keyword-case auto-fill-function) 1569 f90-smart-end f90-auto-keyword-case auto-fill-function)
1576 (set-marker end-region-mark end-region)
1577 (goto-char beg-region) 1570 (goto-char beg-region)
1578 (while go-on 1571 (while go-on
1579 ;; Join as much as possible. 1572 ;; Join as much as possible.
@@ -1588,10 +1581,11 @@ Like `join-line', but handles F90 syntax."
1588 (move-to-column fill-column) 1581 (move-to-column fill-column)
1589 (f90-find-breakpoint) 1582 (f90-find-breakpoint)
1590 (f90-break-line 'no-update)) 1583 (f90-break-line 'no-update))
1591 (setq go-on (and (< (point) (marker-position end-region-mark)) 1584 (setq go-on (and (< (point) end-region-mark)
1592 (zerop (forward-line 1))) 1585 (zerop (forward-line 1)))
1593 f90-cache-position (point))) 1586 f90-cache-position (point)))
1594 (setq f90-cache-position nil) 1587 (setq f90-cache-position nil)
1588 (set-marker end-region-mark nil)
1595 (if (fboundp 'zmacs-deactivate-region) 1589 (if (fboundp 'zmacs-deactivate-region)
1596 (zmacs-deactivate-region) 1590 (zmacs-deactivate-region)
1597 (deactivate-mark)))) 1591 (deactivate-mark))))
@@ -1605,35 +1599,37 @@ END-NAME is the block end name (may be nil).
1605Leave point at the end of line." 1599Leave point at the end of line."
1606 (search-forward "end" (line-end-position)) 1600 (search-forward "end" (line-end-position))
1607 (catch 'no-match 1601 (catch 'no-match
1608 (if (not (f90-equal-symbols beg-block end-block)) 1602 (if (f90-equal-symbols beg-block end-block)
1609 (if end-block 1603 (search-forward end-block)
1610 (progn 1604 (if end-block
1611 (message "END %s does not match %s." end-block beg-block) 1605 (progn
1612 (end-of-line) 1606 (message "END %s does not match %s." end-block beg-block)
1613 (throw 'no-match nil)) 1607 (end-of-line)
1614 (message "Inserting %s." beg-block) 1608 (throw 'no-match nil))
1615 (insert (concat " " beg-block))) 1609 (message "Inserting %s." beg-block)
1616 (search-forward end-block)) 1610 (insert (concat " " beg-block))))
1617 (if (not (f90-equal-symbols beg-name end-name)) 1611 (if (f90-equal-symbols beg-name end-name)
1618 (cond ((and beg-name (not end-name)) 1612 (and end-name (search-forward end-name))
1619 (message "Inserting %s." beg-name) 1613 (cond ((and beg-name (not end-name))
1620 (insert (concat " " beg-name))) 1614 (message "Inserting %s." beg-name)
1621 ((and beg-name end-name) 1615 (insert (concat " " beg-name)))
1622 (message "Replacing %s with %s." end-name beg-name) 1616 ((and beg-name end-name)
1623 (search-forward end-name) 1617 (message "Replacing %s with %s." end-name beg-name)
1624 (replace-match beg-name)) 1618 (search-forward end-name)
1625 ((and (not beg-name) end-name) 1619 (replace-match beg-name))
1626 (message "Deleting %s." end-name) 1620 ((and (not beg-name) end-name)
1627 (search-forward end-name) 1621 (message "Deleting %s." end-name)
1628 (replace-match ""))) 1622 (search-forward end-name)
1629 (if end-name (search-forward end-name))) 1623 (replace-match ""))))
1630 (if (not (looking-at "[ \t]*!")) (delete-horizontal-space)))) 1624 (or (looking-at "[ \t]*!") (delete-horizontal-space))))
1631 1625
1632(defun f90-match-end () 1626(defun f90-match-end ()
1633 "From an end block statement, find the corresponding block and name." 1627 "From an end block statement, find the corresponding block and name."
1634 (interactive) 1628 (interactive)
1635 (let ((count 1) (top-of-window (window-start)) 1629 (let ((count 1)
1636 (end-point (point)) (case-fold-search t) 1630 (top-of-window (window-start))
1631 (end-point (point))
1632 (case-fold-search t)
1637 matching-beg beg-name end-name beg-block end-block end-struct) 1633 matching-beg beg-name end-name beg-block end-block end-struct)
1638 (when (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9") 1634 (when (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9")
1639 (setq end-struct (f90-looking-at-program-block-end))) 1635 (setq end-struct (f90-looking-at-program-block-end)))
@@ -1643,6 +1639,9 @@ Leave point at the end of line."
1643 (beginning-of-line) 1639 (beginning-of-line)
1644 (while (and (> count 0) (re-search-backward f90-blocks-re nil t)) 1640 (while (and (> count 0) (re-search-backward f90-blocks-re nil t))
1645 (beginning-of-line) 1641 (beginning-of-line)
1642 ;; GM not a line number if continued line.
1643;;; (skip-chars-forward " \t")
1644;;; (skip-chars-forward "0-9")
1646 (skip-chars-forward " \t0-9") 1645 (skip-chars-forward " \t0-9")
1647 (cond ((or (f90-in-string) (f90-in-comment))) 1646 (cond ((or (f90-in-string) (f90-in-comment)))
1648 ((setq matching-beg 1647 ((setq matching-beg
@@ -1764,6 +1763,7 @@ CHANGE-WORD should be one of 'upcase-word, 'downcase-word, 'capitalize-word."
1764 (unless (progn 1763 (unless (progn
1765 (setq state (parse-partial-sexp ref-point (point))) 1764 (setq state (parse-partial-sexp ref-point (point)))
1766 (or (nth 3 state) (nth 4 state) 1765 (or (nth 3 state) (nth 4 state)
1766 ;; GM f90-directive-comment-re?
1767 (save-excursion ; check for cpp directive 1767 (save-excursion ; check for cpp directive
1768 (beginning-of-line) 1768 (beginning-of-line)
1769 (skip-chars-forward " \t0-9") 1769 (skip-chars-forward " \t0-9")