aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman1996-10-15 02:58:27 +0000
committerRichard M. Stallman1996-10-15 02:58:27 +0000
commit7cae52cffc11eda8b3b890f7be5b99c89256481c (patch)
tree54f8f4944f4338a950bacef7906f3425ddbaf11a /lisp
parent57a6e758e20875fa0301c3ae0ec033aeb890f7f8 (diff)
downloademacs-7cae52cffc11eda8b3b890f7be5b99c89256481c.tar.gz
emacs-7cae52cffc11eda8b3b890f7be5b99c89256481c.zip
(f90-no-block-limit): Fixed bug for indentation of
elsewhere and elseif. (f90-looking-at-where-or-forall): Now allows for labelled forall and where statements. (f90-font-lock-keywords-2): New highlighting for labelled where and forall. Fixed small bug with else highlighting. (f90-fill-region): Moved indentation to f90-break-line. (f90-break-line): Will now always indent the second line. (f90-indent-line): Simpler test for auto-fill. (f90-auto-fill-mode): Removed. (f90-electric-insert): Added for possibility of auto-filling of lines without spaces, as well as early updating of line. (f90-mode-map): Added bindings of operators to f90-electric-insert. (f90-do-auto-fill): Now also updates line (changes case).
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/f90.el73
1 files changed, 38 insertions, 35 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index ec1ac0c6597..ada277ffc05 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -3,7 +3,7 @@
3;; Copyright (C) 1995, 1996 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4 4
5;; Author: Torbj\"orn Einarsson <T.Einarsson@clab.ericsson.se> 5;; Author: Torbj\"orn Einarsson <T.Einarsson@clab.ericsson.se>
6;; Last Change: Aug. 12, 1996 6;; Last Change: Oct. 14, 1996
7;; Keywords: fortran, f90, languages 7;; Keywords: fortran, f90, languages
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
@@ -344,16 +344,15 @@ whether to blink the matching beginning.")
344 ;; Variable declarations (avoid the real function call) 344 ;; Variable declarations (avoid the real function call)
345 '("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)\\(.*::\\|[ \t]*(.*)\\)?\\([^!\n]*\\)" 345 '("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)\\(.*::\\|[ \t]*(.*)\\)?\\([^!\n]*\\)"
346 (1 font-lock-type-face) (4 font-lock-variable-name-face)) 346 (1 font-lock-type-face) (4 font-lock-variable-name-face))
347 ;; do, if and select constructs 347 ;; do, if, select, where, and forall constructs
348 '("\\<\\(end[ \t]*\\(do\\|if\\|select\\)\\)\\>\\([ \t]+\\(\\sw+\\)\\)?" 348 '("\\<\\(end[ \t]*\\(do\\|if\\|select\\|forall\\|where\\)\\)\\>\\([ \t]+\\(\\sw+\\)\\)?"
349 (1 font-lock-keyword-face) (3 font-lock-reference-face nil t)) 349 (1 font-lock-keyword-face) (3 font-lock-reference-face nil t))
350 '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|do\\([ \t]*while\\)?\\|select[ \t]*case\\)\\)\\>" 350 '("^[ \t0-9]*\\(\\(\\sw+\\)[ \t]*:[ \t]*\\)?\\(\\(if\\|do\\([ \t]*while\\)?\\|select[ \t]*case\\|where\\|forall\\)\\)\\>"
351 (2 font-lock-reference-face nil t) (3 font-lock-keyword-face)) 351 (2 font-lock-reference-face nil t) (3 font-lock-keyword-face))
352 ;; implicit declaration 352 ;; implicit declaration
353 '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\|none\\)\\>" (1 font-lock-keyword-face) (2 font-lock-type-face)) 353 '("\\<\\(implicit\\)[ \t]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\|none\\)\\>" (1 font-lock-keyword-face) (2 font-lock-type-face))
354 '("\\<\\(namelist\\|common\\)[ \t]*\/\\(\\sw+\\)?\/" (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)) 354 '("\\<\\(namelist\\|common\\)[ \t]*\/\\(\\sw+\\)?\/" (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
355 '("\\<\\(where\\|forall\\)[ \t]*(" . 1) 355 "\\<else\\([ \t]*if\\|where\\)?\\>"
356 "\\<e\\(lse\\([ \t]*if\\|where\\)?\\|nd[ \t]*\\(where\\|forall\\)\\)\\>"
357 "\\<\\(then\\|continue\\|format\\|include\\|stop\\|return\\)\\>" 356 "\\<\\(then\\|continue\\|format\\|include\\|stop\\|return\\)\\>"
358 '("\\<\\(exit\\|cycle\\)[ \t]*\\(\\sw+\\)?\\>" 357 '("\\<\\(exit\\|cycle\\)[ \t]*\\(\\sw+\\)?\\>"
359 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)) 358 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
@@ -428,7 +427,12 @@ whether to blink the matching beginning.")
428 (define-key f90-mode-map "\C-c\C-p" 'f90-previous-statement) 427 (define-key f90-mode-map "\C-c\C-p" 'f90-previous-statement)
429 (define-key f90-mode-map "\C-c\C-n" 'f90-next-statement) 428 (define-key f90-mode-map "\C-c\C-n" 'f90-next-statement)
430 (define-key f90-mode-map "\C-c\C-w" 'f90-insert-end) 429 (define-key f90-mode-map "\C-c\C-w" 'f90-insert-end)
431 (define-key f90-mode-map "\t" 'f90-indent-line)) 430 (define-key f90-mode-map "\t" 'f90-indent-line)
431 (define-key f90-mode-map "," 'f90-electric-insert)
432 (define-key f90-mode-map "+" 'f90-electric-insert)
433 (define-key f90-mode-map "-" 'f90-electric-insert)
434 (define-key f90-mode-map "*" 'f90-electric-insert)
435 (define-key f90-mode-map "/" 'f90-electric-insert))
432 436
433 437
434;; menus 438;; menus
@@ -816,7 +820,7 @@ with no args, if that value is non-nil."
816 (setq normal-auto-fill-function 'f90-do-auto-fill) 820 (setq normal-auto-fill-function 'f90-do-auto-fill)
817 (setq indent-tabs-mode nil) 821 (setq indent-tabs-mode nil)
818 ;; Setting up things for font-lock 822 ;; Setting up things for font-lock
819 (if (string-match "Xemacs" emacs-version) 823 (if (string-match "XEmacs" emacs-version)
820 (progn 824 (progn
821 (put 'f90-mode 'font-lock-keywords-case-fold-search t) 825 (put 'f90-mode 'font-lock-keywords-case-fold-search t)
822 (if (and current-menubar 826 (if (and current-menubar
@@ -953,16 +957,14 @@ Name is nil if the statement has no label."
953 (list struct label))))))) 957 (list struct label)))))))
954 958
955(defsubst f90-looking-at-where-or-forall () 959(defsubst f90-looking-at-where-or-forall ()
956 "Return (kind nil) if where/forall...end starts after point." 960 "Return (kind name) if a where or forall statement starts after point.
957 (save-excursion 961Name is nil if the statement has no label."
958 (let (command) 962 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(where\\|forall\\)[ \t]*(")
959 (if (looking-at "\\(where\\|forall\\)[ \t]*(") 963 (let (label
960 (progn 964 (struct (f90-match-piece 3)))
961 (setq command (list (f90-match-piece 1) nil)) 965 (if (looking-at "\\(\\sw+\\)[ \t]*\:")
962 (goto-char (scan-lists (point) 1 0)) 966 (setq label (f90-match-piece 1)))
963 (skip-chars-forward " \t") 967 (list struct label))))
964 (if (looking-at "\\(!\\|$\\)")
965 command))))))
966 968
967(defsubst f90-looking-at-type-like () 969(defsubst f90-looking-at-type-like ()
968 "Return (kind name) at the start of a type/interface/block-data block. 970 "Return (kind name) at the start of a type/interface/block-data block.
@@ -1025,8 +1027,8 @@ Name is non-nil only for type."
1025 (let ((eol (f90-get-end-of-line))) 1027 (let ((eol (f90-get-end-of-line)))
1026 (save-excursion 1028 (save-excursion
1027 (not (or (looking-at "end") 1029 (not (or (looking-at "end")
1028 (looking-at "\\(do\\|if\\|else\\|select[ \t]*case\\|\ 1030 (looking-at "\\(do\\|if\\|else\\(if\\|where\\)?\
1029case\\|where\\|forall\\)\\>") 1031\\|select[ \t]*case\\|case\\|where\\|forall\\)\\>")
1030 (looking-at "\\(program\\|module\\|interface\\|\ 1032 (looking-at "\\(program\\|module\\|interface\\|\
1031block[ \t]*data\\)\\>") 1033block[ \t]*data\\)\\>")
1032 (looking-at "\\(contains\\|\\sw+[ \t]*:\\)") 1034 (looking-at "\\(contains\\|\\sw+[ \t]*:\\)")
@@ -1041,6 +1043,13 @@ block[ \t]*data\\)\\>")
1041 (if f90-auto-keyword-case 1043 (if f90-auto-keyword-case
1042 (f90-change-keywords f90-auto-keyword-case bol eol)))))) 1044 (f90-change-keywords f90-auto-keyword-case bol eol))))))
1043 1045
1046(defun f90-electric-insert ()
1047 (interactive)
1048 "Calls f90-do-auto-fill at each operator insertion."
1049 (self-insert-command 1)
1050 (f90-update-line)
1051 (if auto-fill-function (f90-do-auto-fill)))
1052
1044(defun f90-get-correct-indent () 1053(defun f90-get-correct-indent ()
1045 "Get correct indent for a line starting with line number. 1054 "Get correct indent for a line starting with line number.
1046Does not check type and subprogram indentation." 1055Does not check type and subprogram indentation."
@@ -1257,9 +1266,7 @@ or, if already present, remove it."
1257 (if (< (point) (marker-position pos)) 1266 (if (< (point) (marker-position pos))
1258 (goto-char (marker-position pos))) 1267 (goto-char (marker-position pos)))
1259 (if (not no-update) (f90-update-line)) 1268 (if (not no-update) (f90-update-line))
1260 (if (and auto-fill-function 1269 (if auto-fill-function (f90-do-auto-fill))
1261 (> (save-excursion (end-of-line) (current-column)) fill-column))
1262 (save-excursion (f90-do-auto-fill)))
1263 (set-marker pos nil))) 1270 (set-marker pos nil)))
1264 1271
1265(defun f90-indent-new-line () 1272(defun f90-indent-new-line ()
@@ -1418,7 +1425,7 @@ If run in the middle of a line, the line is not broken."
1418 (if (not no-update) (f90-update-line)) 1425 (if (not no-update) (f90-update-line))
1419 (newline) 1426 (newline)
1420 (if f90-beginning-ampersand (insert "&"))))) 1427 (if f90-beginning-ampersand (insert "&")))))
1421 (if (not no-update) (f90-indent-line))) 1428 (f90-indent-line))
1422 1429
1423(defun f90-find-breakpoint () 1430(defun f90-find-breakpoint ()
1424 "From fill-column, search backward for break-delimiter." 1431 "From fill-column, search backward for break-delimiter."
@@ -1433,11 +1440,12 @@ If run in the middle of a line, the line is not broken."
1433 (forward-char))))) 1440 (forward-char)))))
1434 1441
1435(defun f90-do-auto-fill () 1442(defun f90-do-auto-fill ()
1436 "Break line if non-white characters beyond fill-column." 1443 "Break line if non-white characters beyond fill-column. Also, update line. "
1437 (interactive) 1444 (interactive)
1438 ;; Break the line before or after the last delimiter (non-word char) if 1445 ;; Break the line before or after the last delimiter (non-word char) if
1439 ;; position is beyond fill-column. 1446 ;; position is beyond fill-column.
1440 ;; Will not break **, //, or => (specified by f90-no-break-re). 1447 ;; Will not break **, //, or => (specified by f90-no-break-re).
1448 (f90-update-line)
1441 (while (> (current-column) fill-column) 1449 (while (> (current-column) fill-column)
1442 (let ((pos-mark (point-marker))) 1450 (let ((pos-mark (point-marker)))
1443 (move-to-column fill-column) 1451 (move-to-column fill-column)
@@ -1475,27 +1483,22 @@ If run in the middle of a line, the line is not broken."
1475 "Fill every line in region by forward parsing. Join lines if possible." 1483 "Fill every line in region by forward parsing. Join lines if possible."
1476 (interactive "*r") 1484 (interactive "*r")
1477 (let ((end-region-mark (make-marker)) 1485 (let ((end-region-mark (make-marker))
1478 (f90-smart-end nil) (f90-auto-keyword-case nil) indent (go-on t) 1486 (f90-smart-end nil) (f90-auto-keyword-case nil) (go-on t)
1479 (af-function auto-fill-function) (auto-fill-function nil)) 1487 (auto-fill-function nil))
1480 (set-marker end-region-mark end-region) 1488 (set-marker end-region-mark end-region)
1481 (goto-char beg-region) 1489 (goto-char beg-region)
1482 (while go-on 1490 (while go-on
1483 ;; join as much as possible 1491 ;; join as much as possible
1484 (while (f90-join-lines)); 1492 (while (f90-join-lines))
1485 (setq indent (+ (f90-current-indentation) f90-continuation-indent))
1486 ;; chop the line if necessary 1493 ;; chop the line if necessary
1487 (while (> (save-excursion (end-of-line) (current-column)) 1494 (while (> (save-excursion (end-of-line) (current-column))
1488 fill-column) 1495 fill-column)
1489 (move-to-column fill-column) 1496 (move-to-column fill-column)
1490 (if (and (looking-at "[ \t]*$") (not (f90-in-string))) 1497 (f90-find-breakpoint)
1491 (delete-horizontal-space) 1498 (f90-break-line 'no-update))
1492 (f90-find-breakpoint)
1493 (f90-break-line 'no-update)
1494 (f90-indent-to indent 'no-line-no)))
1495 (setq go-on (and (< (point) (marker-position end-region-mark)) 1499 (setq go-on (and (< (point) (marker-position end-region-mark))
1496 (zerop (forward-line 1)))) 1500 (zerop (forward-line 1))))
1497 (setq f90-cache-position (point))) 1501 (setq f90-cache-position (point)))
1498 (setq auto-fill-function af-function)
1499 (setq f90-cache-position nil) 1502 (setq f90-cache-position nil)
1500 (if (string-match "XEmacs" emacs-version) 1503 (if (string-match "XEmacs" emacs-version)
1501 (zmacs-deactivate-region) 1504 (zmacs-deactivate-region)