aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2002-04-29 22:55:10 +0000
committerGlenn Morris2002-04-29 22:55:10 +0000
commitd14e6bbe1ba929a9f71d482a833c62c55f3225f0 (patch)
treeaaf58272587eedd9a0edd03af6b2e0423a6f2022
parentab8dbe67bbaa04e46e05d11fd5a924575d592b98 (diff)
downloademacs-d14e6bbe1ba929a9f71d482a833c62c55f3225f0.tar.gz
emacs-d14e6bbe1ba929a9f71d482a833c62c55f3225f0.zip
Add/change doc strings for many in-line functions.
(f90-indent-line-no, f90-update-line): Minor code changes.
-rw-r--r--lisp/progmodes/f90.el112
1 files changed, 67 insertions, 45 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index af8eed0ba62..bc6ee812931 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -396,8 +396,7 @@ The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil."
396(defvar f90-mode-syntax-table nil 396(defvar f90-mode-syntax-table nil
397 "Syntax table in use in F90 mode buffers.") 397 "Syntax table in use in F90 mode buffers.")
398 398
399(if f90-mode-syntax-table 399(unless f90-mode-syntax-table
400 ()
401 (setq f90-mode-syntax-table (make-syntax-table)) 400 (setq f90-mode-syntax-table (make-syntax-table))
402 (modify-syntax-entry ?\! "<" f90-mode-syntax-table) ; beg. comment 401 (modify-syntax-entry ?\! "<" f90-mode-syntax-table) ; beg. comment
403 (modify-syntax-entry ?\n ">" f90-mode-syntax-table) ; end comment 402 (modify-syntax-entry ?\n ">" f90-mode-syntax-table) ; end comment
@@ -417,8 +416,7 @@ The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil."
417(defvar f90-mode-map () 416(defvar f90-mode-map ()
418 "Keymap used in F90 mode.") 417 "Keymap used in F90 mode.")
419 418
420(if f90-mode-map 419(unless f90-mode-map
421 ()
422 (setq f90-mode-map (make-sparse-keymap)) 420 (setq f90-mode-map (make-sparse-keymap))
423 (define-key f90-mode-map "`" 'f90-abbrev-start) 421 (define-key f90-mode-map "`" 'f90-abbrev-start)
424 (define-key f90-mode-map "\C-c;" 'f90-comment-region) 422 (define-key f90-mode-map "\C-c;" 'f90-comment-region)
@@ -680,8 +678,7 @@ program\\|select\\|subroutine\\|type\\|where\\|forall\\)\\>")
680 678
681;; abbrevs have generally two letters, except standard types `c, `i, `r, `t 679;; abbrevs have generally two letters, except standard types `c, `i, `r, `t
682(defvar f90-mode-abbrev-table nil) 680(defvar f90-mode-abbrev-table nil)
683(if f90-mode-abbrev-table 681(unless f90-mode-abbrev-table
684 ()
685 (let ((ac abbrevs-changed)) 682 (let ((ac abbrevs-changed))
686 (define-abbrev-table 'f90-mode-abbrev-table ()) 683 (define-abbrev-table 'f90-mode-abbrev-table ())
687 (define-abbrev f90-mode-abbrev-table "`al" "allocate" nil 0 t) 684 (define-abbrev f90-mode-abbrev-table "`al" "allocate" nil 0 t)
@@ -854,6 +851,9 @@ with no args, if that value is non-nil."
854 851
855;; inline-functions 852;; inline-functions
856(defsubst f90-in-string () 853(defsubst f90-in-string ()
854 "Return non-nil if point is inside a string.
855Checks from point-min, or f90-cache-position, if that is non-nil
856and lies before point."
857 (let ((beg-pnt 857 (let ((beg-pnt
858 (if (and f90-cache-position (> (point) f90-cache-position)) 858 (if (and f90-cache-position (> (point) f90-cache-position))
859 f90-cache-position 859 f90-cache-position
@@ -861,6 +861,9 @@ with no args, if that value is non-nil."
861 (nth 3 (parse-partial-sexp beg-pnt (point))))) 861 (nth 3 (parse-partial-sexp beg-pnt (point)))))
862 862
863(defsubst f90-in-comment () 863(defsubst f90-in-comment ()
864 "Return non-nil if point is inside a comment.
865Checks from point-min, or f90-cache-position, if that is non-nil
866and lies before point."
864 (let ((beg-pnt 867 (let ((beg-pnt
865 (if (and f90-cache-position (> (point) f90-cache-position)) 868 (if (and f90-cache-position (> (point) f90-cache-position))
866 f90-cache-position 869 f90-cache-position
@@ -868,6 +871,9 @@ with no args, if that value is non-nil."
868 (nth 4 (parse-partial-sexp beg-pnt (point))))) 871 (nth 4 (parse-partial-sexp beg-pnt (point)))))
869 872
870(defsubst f90-line-continued () 873(defsubst f90-line-continued ()
874 "Return t if the current line is a continued one.
875This includes comment lines embedded in continued lines, but
876not the last line of a continued statement."
871 (save-excursion 877 (save-excursion
872 (beginning-of-line) 878 (beginning-of-line)
873 (while (and (looking-at "[ \t]*\\(!\\|$\\)") (zerop (forward-line -1)))) 879 (while (and (looking-at "[ \t]*\\(!\\|$\\)") (zerop (forward-line -1))))
@@ -887,16 +893,19 @@ Line-numbers are considered whitespace characters."
887 893
888(defsubst f90-indent-to (col &optional no-line-number) 894(defsubst f90-indent-to (col &optional no-line-number)
889 "Indent current line to column COL. 895 "Indent current line to column COL.
890If optional argument NO-LINE-NUMBER is nil, jump over a possible line-number." 896If optional argument NO-LINE-NUMBER is nil, jump over a possible
897line-number before indenting."
891 (beginning-of-line) 898 (beginning-of-line)
892 (if (not no-line-number) 899 (if (not no-line-number)
893 (skip-chars-forward " \t0-9")) 900 (skip-chars-forward " \t0-9"))
894 (delete-horizontal-space) 901 (delete-horizontal-space)
895 (if (zerop (current-column)) 902 (if (zerop (current-column))
896 (indent-to col) 903 (indent-to col)
897 (indent-to col 1))) 904 (indent-to col 1))) ; leave >= 1 space after line number
898 905
899(defsubst f90-get-present-comment-type () 906(defsubst f90-get-present-comment-type ()
907 "If point lies within a comment, return the string starting the comment.
908For example, \"!\" or \"!!\"."
900 (save-excursion 909 (save-excursion
901 (let ((type nil) (eol (line-end-position))) 910 (let ((type nil) (eol (line-end-position)))
902 (when (f90-in-comment) 911 (when (f90-in-comment)
@@ -917,8 +926,8 @@ If optional argument NO-LINE-NUMBER is nil, jump over a possible line-number."
917;; expression. Therefore, the next 2 functions are longer than necessary. 926;; expression. Therefore, the next 2 functions are longer than necessary.
918 927
919(defsubst f90-looking-at-do () 928(defsubst f90-looking-at-do ()
920 "Return (\"do\" name) if a do statement starts after point. 929 "Return (\"do\" NAME) if a do statement starts after point.
921Name is nil if the statement has no label." 930NAME is nil if the statement has no label."
922 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(do\\)\\>") 931 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(do\\)\\>")
923 (let (label 932 (let (label
924 (struct (match-string 3))) 933 (struct (match-string 3)))
@@ -927,9 +936,10 @@ Name is nil if the statement has no label."
927 (list struct label)))) 936 (list struct label))))
928 937
929(defsubst f90-looking-at-select-case () 938(defsubst f90-looking-at-select-case ()
930 "Return (\"select\" name) if a select-case statement starts after point. 939 "Return (\"select\" NAME) if a select-case statement starts after point.
931Name is nil if the statement has no label." 940NAME is nil if the statement has no label."
932 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(select\\)[ \t]*case[ \t]*(") 941 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\
942\\(select\\)[ \t]*case[ \t]*(")
933 (let (label 943 (let (label
934 (struct (match-string 3))) 944 (struct (match-string 3)))
935 (if (looking-at "\\(\\sw+\\)[ \t]*\:") 945 (if (looking-at "\\(\\sw+\\)[ \t]*\:")
@@ -937,8 +947,8 @@ Name is nil if the statement has no label."
937 (list struct label)))) 947 (list struct label))))
938 948
939(defsubst f90-looking-at-if-then () 949(defsubst f90-looking-at-if-then ()
940 "Return (\"if\" name) if an if () then statement starts after point. 950 "Return (\"if\" NAME) if an if () then statement starts after point.
941Name is nil if the statement has no label." 951NAME is nil if the statement has no label."
942 (save-excursion 952 (save-excursion
943 (let (struct (label nil)) 953 (let (struct (label nil))
944 (when (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(if\\)\\>") 954 (when (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(if\\)\\>")
@@ -956,9 +966,10 @@ Name is nil if the statement has no label."
956 (list struct label)))))) 966 (list struct label))))))
957 967
958(defsubst f90-looking-at-where-or-forall () 968(defsubst f90-looking-at-where-or-forall ()
959 "Return (kind name) if a where or forall block starts after point. 969 "Return (KIND NAME) if a where or forall block starts after point.
960Name is nil if the statement has no label." 970NAME is nil if the statement has no label."
961 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(where\\|forall\\)[ \t]*(.*)[ \t]*\\(!\\|$\\)") 971 (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\
972\\(where\\|forall\\)[ \t]*(.*)[ \t]*\\(!\\|$\\)")
962 (let (label 973 (let (label
963 (struct (match-string 3))) 974 (struct (match-string 3)))
964 (if (looking-at "\\(\\sw+\\)[ \t]*\:") 975 (if (looking-at "\\(\\sw+\\)[ \t]*\:")
@@ -966,8 +977,8 @@ Name is nil if the statement has no label."
966 (list struct label)))) 977 (list struct label))))
967 978
968(defsubst f90-looking-at-type-like () 979(defsubst f90-looking-at-type-like ()
969 "Return (kind name) at the start of a type/interface/block-data block. 980 "Return (KIND NAME) if a type/interface/block-data block starts after point.
970Name is non-nil only for type." 981NAME is non-nil only for type."
971 (cond 982 (cond
972 ((looking-at f90-type-def-re) 983 ((looking-at f90-type-def-re)
973 (list (match-string 1) (match-string 4))) 984 (list (match-string 1) (match-string 4)))
@@ -975,7 +986,7 @@ Name is non-nil only for type."
975 (list (match-string 1) nil)))) 986 (list (match-string 1) nil))))
976 987
977(defsubst f90-looking-at-program-block-start () 988(defsubst f90-looking-at-program-block-start ()
978 "Return (kind name) if a program block with name name starts after point." 989 "Return (KIND NAME) if a program block with name NAME starts after point."
979 (cond 990 (cond
980 ((looking-at "\\(program\\)[ \t]+\\(\\sw+\\)\\>") 991 ((looking-at "\\(program\\)[ \t]+\\(\\sw+\\)\\>")
981 (list (match-string 1) (match-string 2))) 992 (list (match-string 1) (match-string 2)))
@@ -983,11 +994,12 @@ Name is non-nil only for type."
983 (looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>")) 994 (looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>"))
984 (list (match-string 1) (match-string 2))) 995 (list (match-string 1) (match-string 2)))
985 ((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)")) 996 ((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)"))
986 (looking-at "[^!'\"\&\n]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)")) 997 (looking-at "[^!'\"\&\n]*\\(function\\|subroutine\\)\
998[ \t]+\\(\\sw+\\)"))
987 (list (match-string 1) (match-string 2))))) 999 (list (match-string 1) (match-string 2)))))
988 1000
989(defsubst f90-looking-at-program-block-end () 1001(defsubst f90-looking-at-program-block-end ()
990 "Return list of type and name of end of block." 1002 "Return (KIND NAME) if a block with name NAME ends after point."
991 (if (looking-at (concat "end[ \t]*" f90-blocks-re 1003 (if (looking-at (concat "end[ \t]*" f90-blocks-re
992 "?\\([ \t]+\\(\\sw+\\)\\)?\\>")) 1004 "?\\([ \t]+\\(\\sw+\\)\\)?\\>"))
993 (list (match-string 1) (match-string 3)))) 1005 (list (match-string 1) (match-string 3))))
@@ -1007,7 +1019,13 @@ Name is non-nil only for type."
1007 (max (if (bolp) 0 (1+ (current-column))) comment-column)))) 1019 (max (if (bolp) 0 (1+ (current-column))) comment-column))))
1008 1020
1009(defsubst f90-present-statement-cont () 1021(defsubst f90-present-statement-cont ()
1010 "Return continuation properties of present statement." 1022 "Return continuation properties of present statement.
1023Possible return values are:
1024single - statement is not continued.
1025begin - current line is the first in a continued statement.
1026end - current line is the last in a continued statement
1027middle - current line is neither first nor last in a continued statement.
1028Comment lines embedded amongst continued lines return 'middle."
1011 (let (pcont cont) 1029 (let (pcont cont)
1012 (save-excursion 1030 (save-excursion
1013 (setq pcont (if (f90-previous-statement) (f90-line-continued) nil))) 1031 (setq pcont (if (f90-previous-statement) (f90-line-continued) nil)))
@@ -1019,14 +1037,17 @@ Name is non-nil only for type."
1019 (t (error))))) 1037 (t (error)))))
1020 1038
1021(defsubst f90-indent-line-no () 1039(defsubst f90-indent-line-no ()
1022 (if f90-leave-line-no 1040 "If `f90-leave-line-no' is nil, left-justify a line number.
1023 () 1041Leaves point at the first non-blank character after the line number.
1024 (if (and (not (zerop (skip-chars-forward " \t"))) 1042Call from beginning of line."
1025 (looking-at "[0-9]")) 1043 (if (and (null f90-leave-line-no) (looking-at "[ \t]+[0-9]"))
1026 (delete-horizontal-space))) 1044 (delete-horizontal-space))
1027 (skip-chars-forward " \t0-9")) 1045 (skip-chars-forward " \t0-9"))
1028 1046
1029(defsubst f90-no-block-limit () 1047(defsubst f90-no-block-limit ()
1048 "Return nil if point is at the edge of a code block.
1049Searches line forward for \"function\" or \"subroutine\",
1050if all else fails."
1030 (let ((eol (line-end-position))) 1051 (let ((eol (line-end-position)))
1031 (save-excursion 1052 (save-excursion
1032 (not (or (looking-at "end") 1053 (not (or (looking-at "end")
@@ -1039,19 +1060,18 @@ block[ \t]*data\\)\\>")
1039 (re-search-forward "\\(function\\|subroutine\\)" eol t)))))) 1060 (re-search-forward "\\(function\\|subroutine\\)" eol t))))))
1040 1061
1041(defsubst f90-update-line () 1062(defsubst f90-update-line ()
1042 (let (bol eol) 1063 "Change case of current line as per `f90-auto-keyword-case'."
1043 (when f90-auto-keyword-case 1064 (if f90-auto-keyword-case
1044 (setq bol (line-beginning-position) 1065 (f90-change-keywords f90-auto-keyword-case
1045 eol (line-end-position)) 1066 (line-beginning-position) (line-end-position))))
1046 (if f90-auto-keyword-case
1047 (f90-change-keywords f90-auto-keyword-case bol eol)))))
1048 1067
1049(defun f90-electric-insert () 1068(defun f90-electric-insert ()
1050 "Call `f90-do-auto-fill' at each operator insertion." 1069 "Change keyword case and auto-fill line as operators are inserted."
1051 (interactive) 1070 (interactive)
1052 (self-insert-command 1) 1071 (self-insert-command 1)
1053 (f90-update-line) 1072 (if auto-fill-function (f90-do-auto-fill) ; also updates line
1054 (if auto-fill-function (f90-do-auto-fill))) 1073 (f90-update-line)))
1074
1055 1075
1056(defun f90-get-correct-indent () 1076(defun f90-get-correct-indent ()
1057 "Get correct indent for a line starting with line number. 1077 "Get correct indent for a line starting with line number.
@@ -1241,8 +1261,8 @@ Call again to remove the highlighting."
1241 1261
1242(defun f90-comment-region (beg-region end-region) 1262(defun f90-comment-region (beg-region end-region)
1243 "Comment/uncomment every line in the region. 1263 "Comment/uncomment every line in the region.
1244Insert f90-comment-region at the beginning of every line in the region 1264Insert the variable `f90-comment-region' at the start of every line
1245or, if already present, remove it." 1265in the region, or, if already present, remove it."
1246 (interactive "*r") 1266 (interactive "*r")
1247 (let ((end (make-marker))) 1267 (let ((end (make-marker)))
1248 (set-marker end end-region) 1268 (set-marker end end-region)
@@ -1281,8 +1301,9 @@ after indenting."
1281 ;; position after the indentation. Else stay at same point in text. 1301 ;; position after the indentation. Else stay at same point in text.
1282 (if (< (point) (marker-position pos)) 1302 (if (< (point) (marker-position pos))
1283 (goto-char (marker-position pos))) 1303 (goto-char (marker-position pos)))
1284 (if (not no-update) (f90-update-line)) 1304 (if auto-fill-function
1285 (if auto-fill-function (f90-do-auto-fill)) 1305 (f90-do-auto-fill) ; also updates line
1306 (if (not no-update) (f90-update-line)))
1286 (set-marker pos nil))) 1307 (set-marker pos nil)))
1287 1308
1288(defun f90-indent-new-line () 1309(defun f90-indent-new-line ()
@@ -1351,7 +1372,7 @@ If run in the middle of a line, the line is not broken."
1351 (+ ind-curr f90-continuation-indent)))) 1372 (+ ind-curr f90-continuation-indent))))
1352 (f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no))) 1373 (f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no)))
1353 ;; process all following lines 1374 ;; process all following lines
1354 (while (and (zerop (forward-line 1)) (< (point) end-region-mark)) 1375 (while (and (zerop (forward-line 1)) (< (point) end-region-mark))
1355 (beginning-of-line) 1376 (beginning-of-line)
1356 (f90-indent-line-no) 1377 (f90-indent-line-no)
1357 (setq f90-cache-position (point)) 1378 (setq f90-cache-position (point))
@@ -1458,7 +1479,8 @@ is non-nil, call `f90-update-line' after inserting the continuation marker."
1458 (forward-char))))) 1479 (forward-char)))))
1459 1480
1460(defun f90-do-auto-fill () 1481(defun f90-do-auto-fill ()
1461 "Break line if non-white characters beyond `fill-column'. Also, update line." 1482 "Break line if non-white characters beyond `fill-column'.
1483Update keyword case first."
1462 (interactive) 1484 (interactive)
1463 ;; Break the line before or after the last delimiter (non-word char) if 1485 ;; Break the line before or after the last delimiter (non-word char) if
1464 ;; position is beyond fill-column. 1486 ;; position is beyond fill-column.
@@ -1499,7 +1521,7 @@ is non-nil, call `f90-update-line' after inserting the continuation marker."
1499 t)))) 1521 t))))
1500 1522
1501(defun f90-fill-region (beg-region end-region) 1523(defun f90-fill-region (beg-region end-region)
1502 "Fill every line in region by forward parsing. Join lines if possible." 1524 "Fill every line in region by forward parsing. Join lines if possible."
1503 (interactive "*r") 1525 (interactive "*r")
1504 (let ((end-region-mark (make-marker)) 1526 (let ((end-region-mark (make-marker))
1505 (f90-smart-end nil) (f90-auto-keyword-case nil) (go-on t) 1527 (f90-smart-end nil) (f90-auto-keyword-case nil) (go-on t)