• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:fortran +defs:start +defs:block +defs:re

0 ;;; fortran.el --- Fortran mode for GNU Emacs
8 ;; Keywords: fortran, languages
64 (defgroup fortran nil
70 (defgroup fortran-indent nil
72 :prefix "fortran-"
73 :group 'fortran)
75 (defgroup fortran-comment nil
77 :prefix "fortran-"
78 :group 'fortran)
82 (defcustom fortran-tab-mode-default nil
88 :group 'fortran-indent)
90 (defcustom fortran-tab-mode-string "/t"
93 :group 'fortran-indent)
95 (defcustom fortran-do-indent 3
98 :group 'fortran-indent)
100 (defcustom fortran-if-indent 3
103 :group 'fortran-indent)
105 (defcustom fortran-structure-indent 3
108 :group 'fortran-indent)
110 (defcustom fortran-continuation-indent 5
113 :group 'fortran-indent)
115 (defcustom fortran-comment-indent-style 'fixed
118 `fixed' indents to `fortran-comment-line-extra-indent' columns beyond
119 `fortran-minimum-statement-indent-fixed' (if `indent-tabs-mode' nil), or
120 `fortran-minimum-statement-indent-tab' (if `indent-tabs-mode' non-nil);
122 `fortran-comment-line-extra-indent'."
124 :group 'fortran-indent)
126 (defcustom fortran-comment-line-extra-indent 0
129 :group 'fortran-indent
130 :group 'fortran-comment)
132 (defcustom fortran-comment-line-start "C"
133 "*Delimiter inserted to start new full-line comment.
137 :group 'fortran-comment)
141 (defcustom fortran-comment-line-start-skip
143 "*Regexp to match the start of a full-line comment."
146 :group 'fortran-comment)
148 (defcustom fortran-directive-re
155 :group 'fortran-indent)
157 (defcustom fortran-minimum-statement-indent-fixed 6
160 :group 'fortran-indent)
162 (defcustom fortran-minimum-statement-indent-tab (max tab-width 6)
165 :group 'fortran-indent)
170 (defcustom fortran-comment-indent-char " "
174 :group 'fortran-comment)
176 (defcustom fortran-line-number-indent 1
180 :group 'fortran-indent)
182 (defcustom fortran-check-all-num-for-matching-do nil
185 :group 'fortran)
187 (defcustom fortran-blink-matching-if nil
188 "*Non-nil causes \\[fortran-indent-line] on ENDIF to blink on matching IF.
191 :group 'fortran)
193 (defcustom fortran-continuation-string "$"
196 column 6 by \\[fortran-split-line] to begin a continuation line.
197 Also, if \\[fortran-indent-line] finds this at the beginning of a
201 :group 'fortran)
203 (defcustom fortran-comment-region "c$$$"
204 "*String inserted by \\[fortran-comment-region] at start of each \
207 :group 'fortran-comment)
209 (defcustom fortran-electric-line-number t
212 :group 'fortran)
214 (defcustom fortran-column-ruler-fixed
219 "String displayed above current line by \\[fortran-column-ruler].
221 See the variable `fortran-column-ruler-tab' for TAB format mode."
223 :group 'fortran)
225 (defcustom fortran-column-ruler-tab
230 "String displayed above current line by \\[fortran-column-ruler].
232 See the variable `fortran-column-ruler-fixed' for fixed format mode."
234 :group 'fortran)
236 (defcustom fortran-analyze-depth 100
239 :group 'fortran)
241 (defcustom fortran-break-before-delimiters t
243 Delimiters are characters matching the regexp `fortran-break-delimiters-re'."
245 :group 'fortran)
247 (defconst fortran-break-delimiters-re "[-+*/><=, \t]"
251 specified by the constant `fortran-no-break-re'.")
254 (defconst fortran-no-break-re
258 characters matching the regexp `fortran-break-delimiters-re' that should
262 (defcustom fortran-mode-hook nil
265 :group 'fortran)
269 (defvar fortran-if-start-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?if[ \t]*("
270 "Regexp matching the start of an IF statement.")
272 (defvar fortran-end-prog-re1
274 \\([ \t]*\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\
278 (defvar fortran-end-prog-re
279 (concat "^[ \t0-9]*" fortran-end-prog-re1)
280 "Regexp possibly matching the end of a subprogram, from the line start.
281 See also `fortran-end-prog-re1'.")
283 (defconst fortran-type-types
308 (defvar fortran-font-lock-keywords-1
310 '(("\\<\\(block[ \t]*data\\|call\\|entry\\|function\\|\
316 (defvar fortran-font-lock-keywords-2
317 (append fortran-font-lock-keywords-1
320 (cons fortran-type-types 'font-lock-type-face)
343 (defvar fortran-font-lock-keywords-3
345 fortran-font-lock-keywords-1
348 (list (concat fortran-type-types "[ \t(/]*\\(*\\)?")
351 ;; Declaration item (or just /.../ block name).
356 fortran-type-types)))
364 ;; Things extra to `fortran-font-lock-keywords-3' (must be done first).
372 `((,fortran-directive-re (0 font-lock-keyword-face t)))
373 ;; `fortran-font-lock-keywords-2' without types (see above).
374 (cdr (nthcdr (length fortran-font-lock-keywords-1)
375 fortran-font-lock-keywords-2)))
378 (defvar fortran-font-lock-keywords-4
379 (append fortran-font-lock-keywords-3
406 (defvar fortran-font-lock-syntactic-keywords
412 (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1
415 (defvar fortran-imenu-generic-expression
429 "\\<function\\|subroutine\\|entry\\|block\\s-*data\\|program\\)"
431 "[ \t" fortran-continuation-string "]+"
435 ;; Un-named block data.
436 '(nil "^\\s-+\\(block\\s-*data\\)\\s-*$" 1))
442 (defconst fortran-blocks-re
443 (concat "block[ \t]*data\\|select[ \t]*case\\|"
446 "Regexp potentially indicating the start or end of a Fortran \"block\".
450 (defconst fortran-end-block-re
454 fortran-blocks-re
457 "Regexp matching the end of a Fortran \"block\", from the line start.
461 (defconst fortran-start-block-re
467 ;; IF ( ... ) foo is not a block, but a single statement.
476 ;; using a regexp - see the functions fortran-end-if,
477 ;; fortran-beginning-if for the hoops we have to go through.
488 "\\|block[ \t]*data\\)[ \t]*")
489 "Regexp matching the start of a Fortran \"block\", from the line start.
495 `(fortran-mode ,fortran-start-block-re ,fortran-end-block-re
496 "^[cC*!]" fortran-end-of-block nil))
500 (defvar fortran-mode-syntax-table
526 (defvar fortran-gud-syntax-table
527 (let ((st (make-syntax-table fortran-mode-syntax-table)))
532 (defvar fortran-mode-map
534 (define-key map ";" 'fortran-abbrev-start)
535 (define-key map "\C-c;" 'fortran-comment-region)
536 (define-key map "\M-;" 'fortran-indent-comment)
537 (define-key map "\M-\n" 'fortran-split-line)
538 (define-key map "\M-\C-n" 'fortran-end-of-block)
539 (define-key map "\M-\C-p" 'fortran-beginning-of-block)
540 (define-key map "\M-\C-q" 'fortran-indent-subprogram)
541 (define-key map "\C-c\C-w" 'fortran-window-create-momentarily)
542 (define-key map "\C-c\C-r" 'fortran-column-ruler)
543 (define-key map "\C-c\C-p" 'fortran-previous-statement)
544 (define-key map "\C-c\C-n" 'fortran-next-statement)
545 (define-key map "\C-c\C-d" 'fortran-join-line) ; like f90
546 (define-key map "\M-^" 'fortran-join-line) ; subvert delete-indentation
547 (define-key map "0" 'fortran-electric-line-number)
548 (define-key map "1" 'fortran-electric-line-number)
549 (define-key map "2" 'fortran-electric-line-number)
550 (define-key map "3" 'fortran-electric-line-number)
551 (define-key map "4" 'fortran-electric-line-number)
552 (define-key map "5" 'fortran-electric-line-number)
553 (define-key map "6" 'fortran-electric-line-number)
554 (define-key map "7" 'fortran-electric-line-number)
555 (define-key map "8" 'fortran-electric-line-number)
556 (define-key map "9" 'fortran-electric-line-number)
558 (easy-menu-define fortran-menu map "Menu for Fortran mode."
562 ,(custom-menu-create 'fortran)
570 ["Comment Region" fortran-comment-region mark-active]
572 (fortran-comment-region (region-beginning) (region-end) 1)
575 ["Indent Subprogram" fortran-indent-subprogram t]
577 ["Beginning of Subprogram" fortran-beginning-of-subprogram t]
578 ["End of Subprogram" fortran-end-of-subprogram t]
581 ["IF Block" fortran-mark-if t]
582 ["DO Block" fortran-mark-do t]
587 ["Temporary column ruler" fortran-column-ruler t]
588 ["72-column window" fortran-window-create t]
592 ["Momentary 72-column window" fortran-window-create-momentarily t]
594 ["Break Line at Point" fortran-split-line t]
595 ["Join Line" fortran-join-line t]
610 (defvar fortran-mode-abbrev-table
612 (define-abbrev-table 'fortran-mode-abbrev-table nil)
613 fortran-mode-abbrev-table)
622 (apply 'define-abbrev fortran-mode-abbrev-table
625 (apply 'define-abbrev fortran-mode-abbrev-table
629 (";bd" "block data" )
671 (";re" "real" )
689 (defun fortran-mode ()
693 \\[fortran-indent-line] indents the current Fortran line correctly.
700 \\{fortran-mode-map}
704 `fortran-comment-line-start'
706 `fortran-do-indent'
708 `fortran-if-indent'
710 `fortran-structure-indent'
713 `fortran-continuation-indent'
715 `fortran-comment-line-extra-indent'
717 `fortran-comment-indent-style'
720 fixed indent to `fortran-comment-line-extra-indent' beyond the
722 `fortran-minimum-statement-indent-fixed' (fixed format) or
723 `fortran-minimum-statement-indent-tab' (TAB format),
725 relative indent to `fortran-comment-line-extra-indent' beyond the
728 `fortran-comment-indent-char'
731 `fortran-minimum-statement-indent-fixed'
733 `fortran-minimum-statement-indent-tab'
735 `fortran-line-number-indent'
739 `fortran-check-all-num-for-matching-do'
742 `fortran-blink-matching-if'
743 Non-nil causes \\[fortran-indent-line] on an ENDIF (or ENDDO) statement
745 `fortran-continuation-string'
748 `fortran-comment-region'
749 String inserted by \\[fortran-comment-region] at start of each line in
751 `fortran-electric-line-number'
754 `fortran-break-before-delimiters'
757 Turning on Fortran mode calls the value of the variable `fortran-mode-hook'
761 (setq major-mode 'fortran-mode
763 local-abbrev-table fortran-mode-abbrev-table)
764 (set-syntax-table fortran-mode-syntax-table)
765 (use-local-map fortran-mode-map)
766 (set (make-local-variable 'indent-line-function) 'fortran-indent-line)
768 (lambda (start end)
769 (let (fortran-blink-matching-if ; avoid blinking delay
771 (indent-region start end nil))))
776 (set (make-local-variable 'comment-start) fortran-comment-line-start)
777 (set (make-local-variable 'comment-start-skip)
778 ;; We can't reuse `fortran-comment-line-start-skip' directly because
781 ;; (concat "\\(\\)\\(![ \t]*\\|" fortran-comment-line-start-skip "\\)")
783 (set (make-local-variable 'comment-indent-function) 'fortran-comment-indent)
785 (set (make-local-variable 'normal-auto-fill-function) 'fortran-auto-fill)
786 (set (make-local-variable 'indent-tabs-mode) (fortran-analyze-file-format))
787 (setq mode-line-process '(indent-tabs-mode fortran-tab-mode-string))
789 (set (make-local-variable 'fill-paragraph-function) 'fortran-fill-paragraph)
791 '((fortran-font-lock-keywords
792 fortran-font-lock-keywords-1
793 fortran-font-lock-keywords-2
794 fortran-font-lock-keywords-3
795 fortran-font-lock-keywords-4)
797 fortran-beginning-of-subprogram))
799 fortran-font-lock-syntactic-keywords)
802 fortran-imenu-generic-expression)
805 #'fortran-beginning-of-subprogram)
807 #'fortran-end-of-subprogram)
809 #'fortran-current-defun)
811 (set (make-local-variable 'gud-find-expr-function) 'fortran-gud-find-expr)
812 (run-mode-hooks 'fortran-mode-hook))
816 (defun fortran-gud-find-expr ()
818 (with-syntax-table fortran-gud-syntax-table
821 (defsubst fortran-comment-indent ()
823 This is 0 for a line matching `fortran-comment-line-start-skip', else
825 (if (looking-at fortran-comment-line-start-skip) 0
830 (defun fortran-indent-comment ()
834 if the value of `comment-start' is not nil and allows such comments.
840 (cond ((fortran-find-comment-start-skip 'all)
843 (fortran-indent-line)
844 (unless (= (current-column) (fortran-comment-indent))
846 (indent-to (fortran-comment-indent)))))
850 ((and comment-start (not (looking-at "[ \t]*$"))
851 (string-match comment-start-skip (concat " " comment-start)))
854 (indent-to (fortran-comment-indent))
855 (insert comment-start))
863 (insert fortran-comment-line-start)
864 (insert-char (if (stringp fortran-comment-indent-char)
865 (aref fortran-comment-indent-char 0)
866 fortran-comment-indent-char)
867 (- (fortran-calculate-indent) (current-column))))))
869 (defun fortran-comment-region (beg-region end-region arg)
871 Inserts the string variable `fortran-comment-region' at the beginning of
881 (let ((com (regexp-quote fortran-comment-region))) ; uncomment
888 (insert fortran-comment-region) ; comment
891 (insert fortran-comment-region)))
898 (defun fortran-abbrev-start ()
911 (fortran-abbrev-help)
914 (defun fortran-abbrev-help ()
918 (display-buffer (fortran-prepare-abbrev-list-buffer))
921 (defun fortran-prepare-abbrev-list-buffer ()
925 (insert-abbrev-table-description 'fortran-mode-abbrev-table t)
931 (defun fortran-column-ruler ()
933 The ruler is defined by the value of `fortran-column-ruler-fixed' in fixed
934 format mode, and `fortran-column-ruler-tab' in TAB format mode.
939 fortran-column-ruler-tab
940 fortran-column-ruler-fixed)
943 (if (eq (window-start (selected-window))
949 (defun fortran-window-create ()
951 See also `fortran-window-create-momentarily'."
963 (switch-to-buffer " fortran-window-extra" t)
966 (defun fortran-window-create-momentarily (&optional arg)
969 See also `fortran-window-create'."
976 (fortran-window-create)
982 (fortran-window-create)))
984 (defun fortran-split-line ()
991 (and (fortran-find-comment-start-skip 'all)
995 (insert ?\n ?\t (fortran-numerical-continuation-char))
996 (insert "\n " fortran-continuation-string))) ; space after \n important
997 (fortran-indent-line)) ; when cont string is C, c or *
999 (defun fortran-remove-continuation ()
1007 (defun fortran-join-line (arg)
1008 "Join current line to the previous one and re-indent.
1019 (or (fortran-remove-continuation)
1022 (fortran-indent-line)))
1024 (defun fortran-numerical-continuation-char ()
1034 (put 'fortran-electric-line-number 'delete-selection t)
1035 (defun fortran-electric-line-number (arg)
1039 (if (or arg (not fortran-electric-line-number))
1049 fortran-minimum-statement-indent-tab
1050 fortran-minimum-statement-indent-fixed) (current-column))
1053 (not (or (eq last-command 'fortran-indent-line)
1055 'fortran-indent-new-line))))
1057 (re-search-backward "[^ \t0-9]"
1064 (fortran-indent-line))))
1068 (defun fortran-check-end-prog-re ()
1069 "Check a preliminary match against `fortran-end-prog-re'."
1079 ;; case of un-marked main programs not at the start of the file.
1080 (defun fortran-beginning-of-subprogram ()
1087 (while (re-search-backward fortran-end-prog-re nil 'move)
1088 (if (fortran-check-end-prog-re)
1092 (defun fortran-end-of-subprogram ()
1099 (and (looking-at fortran-end-prog-re)
1100 (fortran-check-end-prog-re)))
1104 (while (re-search-forward fortran-end-prog-re nil 'move)
1105 (if (fortran-check-end-prog-re)
1110 (defun fortran-previous-statement ()
1120 (not (looking-at fortran-comment-line-start-skip))
1121 (not (looking-at fortran-directive-re))
1124 (regexp-quote fortran-continuation-string)))
1127 (or (looking-at fortran-comment-line-start-skip)
1128 (looking-at fortran-directive-re)
1131 (regexp-quote fortran-continuation-string)))
1133 (looking-at (concat "[ \t]*" comment-start-skip)))))
1138 (fortran-previous-statement))
1142 (defun fortran-next-statement ()
1153 (or (looking-at fortran-comment-line-start-skip)
1154 (looking-at fortran-directive-re)
1156 (looking-at (concat "[ \t]*" comment-start-skip)))))
1160 (defun fortran-looking-at-if-then ()
1161 "Return non-nil if at the start of a line with an IF ... THEN statement."
1164 (i (fortran-beginning-if)))
1172 (defun fortran-end-of-block (&optional num)
1173 "Move point forward to the end of the current code block.
1175 If NUM is negative, go backward to the start of a block. Does
1176 not check for consistency of block types. Interactively, pushes
1180 (and num (< num 0) (fortran-beginning-of-block (- num)))
1185 (re-search-forward
1186 (concat "\\(" fortran-blocks-re
1187 (if fortran-check-all-num-for-matching-do
1192 (if (if (looking-at (concat "^[0-9 \t]*" fortran-if-start-re))
1193 (fortran-looking-at-if-then)
1194 (looking-at fortran-start-block-re))
1196 (if (or (looking-at fortran-end-block-re)
1198 (and fortran-check-all-num-for-matching-do
1200 (fortran-check-for-matching-do)))
1203 (if (> count 0) (error "Missing block end"))))
1205 (defun fortran-beginning-of-block (&optional num)
1206 "Move point backwards to the start of the current code block.
1208 blocks. If NUM is negative, go forward to the end of a block.
1209 Does not check for consistency of block types. Interactively,
1213 (and num (< num 0) (fortran-end-of-block (- num)))
1218 (re-search-backward
1219 (concat "\\(" fortran-blocks-re
1220 (if fortran-check-all-num-for-matching-do
1225 (if (if (looking-at (concat "^[0-9 \t]*" fortran-if-start-re))
1226 (fortran-looking-at-if-then)
1227 (looking-at fortran-start-block-re))
1229 (if (or (looking-at fortran-end-block-re)
1231 (and fortran-check-all-num-for-matching-do
1233 (fortran-check-for-matching-do)))
1235 ;; Includes an un-named main program block.
1236 (if (> count 0) (error "Missing block start"))))
1240 (defun fortran-blink-match (regex keyword find-begin)
1243 (let ((top-of-window (window-start))
1268 (defun fortran-blink-matching-if ()
1270 (fortran-blink-match "e\\(nd[ \t]*if\\|lse\\([ \t]*if\\)?\\)\\b"
1271 "if" #'fortran-beginning-if))
1273 (defun fortran-blink-matching-do ()
1275 (fortran-blink-match "end[ \t]*do\\b" "do" #'fortran-beginning-do))
1277 (defun fortran-mark-do ()
1282 (if (setq enddo-point (fortran-end-do))
1283 (if (not (setq do-point (fortran-beginning-do)))
1289 (defun fortran-end-do ()
1302 (not (eq (fortran-next-statement) 'last-statement))
1304 (not (and (looking-at fortran-end-prog-re)
1305 (fortran-check-end-prog-re))))
1316 (defun fortran-beginning-do ()
1320 (dostart-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]"))
1324 (looking-at dostart-re))
1331 (not (eq (fortran-previous-statement) 'first-statement))
1333 (not (and (looking-at fortran-end-prog-re)
1334 (fortran-check-end-prog-re))))
1336 (cond ((looking-at dostart-re)
1345 (defun fortran-mark-if ()
1350 (if (setq endif-point (fortran-end-if))
1351 (if (not (setq if-point (fortran-beginning-if)))
1358 (defun fortran-end-if ()
1372 (not (eq (fortran-next-statement) 'last-statement))
1374 (not (and (looking-at fortran-end-prog-re)
1375 (fortran-check-end-prog-re))))
1379 ((looking-at fortran-if-start-re)
1399 (defun fortran-beginning-if ()
1406 ;; `fortran-previous-statement' moves to previous statement
1409 (if (not (eq (fortran-previous-statement) 'first-statement))
1410 (fortran-next-statement))
1413 (looking-at fortran-if-start-re)
1433 (not (eq (fortran-previous-statement) 'first-statement))
1435 (not (and (looking-at fortran-end-prog-re)
1436 (fortran-check-end-prog-re))))
1438 (cond ((looking-at fortran-if-start-re)
1463 (defun fortran-indent-line ()
1466 (let ((cfi (fortran-calculate-indent)))
1469 (if (or (not (= cfi (fortran-current-line-indentation)))
1470 (and (re-search-forward "^[ \t]*[0-9]+" (+ (point) 4) t)
1471 (not (fortran-line-number-indented-correctly-p))))
1472 (fortran-indent-to-column cfi)
1474 (if (fortran-find-comment-start-skip)
1475 (fortran-indent-comment))))
1484 (fortran-fill)))
1485 (when fortran-blink-matching-if
1486 (fortran-blink-matching-if)
1487 (fortran-blink-matching-do))))
1489 (defun fortran-auto-fill ()
1492 (let ((cfi (fortran-calculate-indent)))
1495 (if (or (not (= cfi (fortran-current-line-indentation)))
1496 (and (re-search-forward "^[ \t]*[0-9]+"
1498 (not (fortran-line-number-indented-correctly-p))))
1499 (fortran-indent-to-column cfi)
1501 (if (fortran-find-comment-start-skip)
1502 (fortran-indent-comment))))
1503 (fortran-fill)
1510 (defalias 'fortran-indent-new-line 'reindent-then-newline-and-indent)
1512 (defun fortran-indent-subprogram ()
1521 (defun fortran-calculate-indent ()
1524 (fortran-minimum-statement-indent
1526 fortran-minimum-statement-indent-tab
1527 fortran-minimum-statement-indent-fixed)))
1529 (setq first-statement (fortran-previous-statement))
1531 (setq icol fortran-minimum-statement-indent)
1533 (setq icol fortran-minimum-statement-indent)
1534 (setq icol (fortran-current-line-indentation)))
1547 (setq icol (+ icol fortran-if-indent))))
1549 (setq icol (+ icol fortran-if-indent)))
1551 (setq icol (+ icol fortran-if-indent)))
1553 (setq icol (+ icol fortran-if-indent)))
1555 (setq icol (+ icol fortran-if-indent)))
1557 (setq icol (+ icol fortran-if-indent)))
1559 (setq icol (+ icol fortran-if-indent)))
1561 (setq icol (+ icol fortran-do-indent)))
1565 (setq icol (+ icol fortran-structure-indent)))
1566 ((and (looking-at fortran-end-prog-re1)
1567 (fortran-check-end-prog-re))
1569 (setq icol fortran-minimum-statement-indent)))))
1574 ((looking-at fortran-directive-re)
1575 (setq fortran-minimum-statement-indent 0 icol 0))
1576 ((looking-at fortran-comment-line-start-skip)
1577 (cond ((eq fortran-comment-indent-style 'relative)
1578 (setq icol (+ icol fortran-comment-line-extra-indent)))
1579 ((eq fortran-comment-indent-style 'fixed)
1580 (setq icol (+ fortran-minimum-statement-indent
1581 fortran-comment-line-extra-indent))))
1582 (setq fortran-minimum-statement-indent 0))
1585 fortran-continuation-string)))
1590 (if (fortran-is-in-string-p (point))
1592 (+ icol fortran-continuation-indent))))
1594 ((and fortran-check-all-num-for-matching-do
1596 (fortran-check-for-matching-do))
1597 (setq icol (- icol fortran-do-indent)))
1601 (setq icol (- icol fortran-if-indent)))
1603 (setq icol (- icol fortran-if-indent)))
1605 (setq icol (- icol fortran-if-indent)))
1607 (setq icol (- icol fortran-if-indent)))
1609 (fortran-check-for-matching-do))
1610 (setq icol (- icol fortran-do-indent)))
1612 (setq icol (- icol fortran-do-indent)))
1615 (setq icol (- icol fortran-structure-indent)))
1616 ((and (looking-at fortran-end-prog-re1)
1617 (fortran-check-end-prog-re)
1618 (not (= icol fortran-minimum-statement-indent)))
1620 an unclosed block." fortran-minimum-statement-indent))))))
1621 (max fortran-minimum-statement-indent icol)))
1625 (defun fortran-current-line-indentation ()
1633 (cond ((looking-at fortran-comment-line-start-skip)
1636 (if (stringp fortran-comment-indent-char)
1637 fortran-comment-indent-char
1638 (char-to-string fortran-comment-indent-char))))
1648 (defun fortran-indent-to-column (col)
1652 2) If `fortran-continuation-string' is the first non-whitespace
1659 (if (looking-at fortran-comment-line-start-skip)
1660 (if fortran-comment-indent-style
1661 (let* ((char (if (stringp fortran-comment-indent-char)
1662 (aref fortran-comment-indent-char 0)
1663 fortran-comment-indent-char))
1675 (insert fortran-continuation-string))
1679 (insert ?\t (fortran-numerical-continuation-char) 1))
1685 ((looking-at (regexp-quote fortran-continuation-string))
1690 fortran-minimum-statement-indent-tab
1691 fortran-minimum-statement-indent-fixed))
1693 (insert-char (fortran-numerical-continuation-char) 1))
1700 (indent-to (min fortran-line-number-indent extra-space))))
1707 (when (fortran-find-comment-start-skip)
1709 (unless (= (current-column) (fortran-comment-indent))
1711 (indent-to (fortran-comment-indent)))))))
1713 (defun fortran-line-number-indented-correctly-p ()
1719 (and (<= (current-column) fortran-line-number-indent)
1720 (or (= (current-column) fortran-line-number-indent)
1724 (defun fortran-check-for-matching-do ()
1742 (and (re-search-backward
1752 (defun fortran-find-comment-start-skip (&optional all)
1753 "Move to past `comment-start-skip' found on current line.
1754 Return non-nil if `comment-start-skip' found, nil if not.
1755 If ALL is nil, only match comments that start in column > 0."
1758 (when (or all comment-start-skip)
1760 (css (if comment-start-skip
1761 (concat fortran-comment-line-start-skip
1762 "\\|" comment-start-skip)
1763 fortran-comment-line-start-skip)))
1764 (when (re-search-forward css (line-end-position) t)
1767 (not (fortran-is-in-string-p (match-beginning 0))))
1769 (fortran-find-comment-start-skip all)))
1776 (defun fortran-is-in-string-p (where)
1784 (looking-at fortran-comment-line-start-skip)) nil)
1786 (quoted-comment-start (if comment-start
1787 (regexp-quote comment-start)))
1790 ;; Move to start of current statement.
1791 (fortran-next-statement)
1792 (fortran-previous-statement)
1797 (looking-at fortran-comment-line-start-skip)
1800 ;; - not in a string and after comment-start?
1802 comment-start
1803 (equal comment-start
1814 (equal fortran-continuation-string
1820 ;; Parse max up to comment-start, if non-nil and in current line.
1821 (if comment-start
1823 (if (re-search-forward quoted-comment-start end-of-line t)
1834 (defalias 'fortran-auto-fill-mode 'auto-fill-mode)
1836 (defun fortran-fill ()
1838 (let* ((auto-fill-function #'fortran-auto-fill)
1842 (bos (min eol (+ bol (fortran-current-line-indentation))))
1849 (unless (looking-at fortran-comment-line-start-skip)
1850 (let (fcpoint start)
1852 (when (fortran-is-in-string-p (setq fcpoint (point)))
1854 (re-search-backward "\\S\"\\s\"\\S\"?" bol t)
1855 (setq start
1856 (if fortran-break-before-delimiters
1859 (if (re-search-forward "\\S\"\\s\"\\S\"" eol t)
1864 (if (> (- (point) start)
1865 (- fill-column 6 fortran-continuation-indent))
1867 start))))))
1876 (move-to-column (if fortran-break-before-delimiters
1883 (re-search-backward fortran-break-delimiters-re bol)
1884 (if (not fortran-break-before-delimiters)
1885 (if (looking-at fortran-no-break-re)
1888 ;; to start from (1- fill-column) above.
1894 (or (looking-at fortran-no-break-re)
1900 (or (re-search-forward "[\t\n,'+-/*)=]" eol t)
1903 (re-search-forward "[ \t]" opoint t))
1909 ;; Need to use fortran-find-comment-start-skip to make sure that
1913 (if (not (fortran-find-comment-start-skip))
1924 (+ (fortran-calculate-indent)
1925 fortran-continuation-indent))))
1927 (fortran-break-line)
1930 (defun fortran-break-line ()
1931 "Call `fortran-split-line'. Joins continuation lines first, then refills."
1935 (if (fortran-find-comment-start-skip)
1945 (fortran-fill))
1946 (fortran-split-line))
1952 (indent-to (fortran-comment-indent))
1955 (defun fortran-analyze-file-format ()
1957 Use `fortran-tab-mode-default' if no non-comment statements are found
1958 before the end or in the first `fortran-analyze-depth' lines."
1966 (> i fortran-analyze-depth)))
1972 (t fortran-tab-mode-default)))))
1974 (defun fortran-fill-paragraph (&optional justify)
1975 "Fill surrounding comment block as paragraphs, else fill statement.
1977 A comment block is filled by calling `fill-comment-paragraph' with
1978 argument JUSTIFY, otherwise `fortran-fill-statement' is called.
1982 (fortran-fill-statement)
1985 (defun fortran-fill-statement ()
1988 (let ((auto-fill-function #'fortran-auto-fill))
1992 (looking-at fortran-comment-line-start-skip)
1993 (and comment-start-skip
1994 (looking-at (concat "[ \t]*" comment-start-skip)))))
1997 (fortran-next-statement)
1998 (fortran-previous-statement)
2000 (fortran-indent-line)
2005 (fortran-remove-continuation)))
2006 (fortran-previous-statement)))
2007 (fortran-indent-line)))
2009 (defun fortran-strip-sequence-nos (&optional do-space)
2016 (while (re-search-forward "^.\\{72\\}\\(.*\\)" nil t)
2022 (defun fortran-current-defun ()
2026 (fortran-beginning-of-subprogram)
2028 ;; Search for fortran subprogram start.
2029 (if (re-search-forward
2032 "\\(block[ \t]*data\\)\\)")
2033 (save-excursion (fortran-end-of-subprogram)
2039 (if (re-search-forward "[(\n]" nil t)
2048 (provide 'fortran)
2051 ;;; fortran.el ends here