3 |
;; Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. |
;; Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Torbj\"orn Einarsson <Torbjorn.Einarsson@era.ericsson.se> |
;; Author: Torbj\"orn Einarsson <Torbjorn.Einarsson@era.ericsson.se> |
6 |
;; Maintainer: Dave Love <fx@gnu.org> |
;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk> |
7 |
;; Keywords: fortran, f90, languages |
;; Keywords: fortran, f90, languages |
8 |
|
|
9 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
89 |
;; f90-smart-end 'blink |
;; f90-smart-end 'blink |
90 |
;; f90-auto-keyword-case nil |
;; f90-auto-keyword-case nil |
91 |
;; f90-leave-line-no nil |
;; f90-leave-line-no nil |
|
;; f90-startup-message t |
|
92 |
;; indent-tabs-mode nil |
;; indent-tabs-mode nil |
93 |
;; f90-font-lock-keywords f90-font-lock-keywords-2 |
;; f90-font-lock-keywords f90-font-lock-keywords-2 |
94 |
;; ) |
;; ) |
229 |
:type 'boolean |
:type 'boolean |
230 |
:group 'f90) |
:group 'f90) |
231 |
|
|
|
(defcustom f90-startup-message t |
|
|
"*Non-nil displays a startup message when F90 mode is first called." |
|
|
:type 'boolean |
|
|
:group 'f90) |
|
|
|
|
232 |
(defconst f90-keywords-re |
(defconst f90-keywords-re |
233 |
;;("allocate" "allocatable" "assign" "assignment" "backspace" "block" |
;;("allocate" "allocatable" "assign" "assignment" "backspace" "block" |
234 |
;;"call" "case" "character" "close" "common" "complex" "contains" |
;;"call" "case" "character" "close" "common" "complex" "contains" |
358 |
|
|
359 |
(defvar f90-font-lock-keywords-1 |
(defvar f90-font-lock-keywords-1 |
360 |
(list |
(list |
361 |
|
;; Special highlighting of "module procedure foo-list" |
362 |
|
'("\\<\\(module[ \t]*procedure\\)\\>" (1 font-lock-keyword-face)) |
363 |
'("\\<\\(end[ \t]*\\(program\\|module\\|function\\|subroutine\\|type\\)\\)\\>[ \t]*\\(\\sw+\\)?" |
'("\\<\\(end[ \t]*\\(program\\|module\\|function\\|subroutine\\|type\\)\\)\\>[ \t]*\\(\\sw+\\)?" |
364 |
(1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) |
(1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) |
365 |
'("\\<\\(program\\|call\\|module\\|subroutine\\|function\\|use\\)\\>[ \t]*\\(\\sw+\\)?" |
'("\\<\\(program\\|type\\|call\\|module\\|subroutine\\|function\\|use\\)\\>[ \t]*\\(\\sw+\\)?" |
366 |
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) |
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) |
|
;; Special highlighting of "module procedure foo-list" |
|
|
'("\\<\\(module[ \t]*procedure\\)\\>" (1 font-lock-keyword-face t)) |
|
367 |
;; Highlight definition of new type |
;; Highlight definition of new type |
368 |
'("\\<\\(type\\)[ \t]*\\(.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)" |
;;; '("\\<\\(type\\)[ \t]*\\(.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)" |
369 |
(1 font-lock-keyword-face) (3 font-lock-function-name-face)) |
;;; (1 font-lock-keyword-face) (3 font-lock-function-name-face)) |
370 |
"\\<\\(\\(end[ \t]*\\)?\\(interface\\|block[ \t]*data\\)\\|contains\\)\\>") |
"\\<\\(\\(end[ \t]*\\)?\\(interface\\|block[ \t]*data\\)\\|contains\\)\\>") |
371 |
"This does fairly subdued highlighting of comments and function calls.") |
"This does fairly subdued highlighting of comments and function calls.") |
372 |
|
|
375 |
(list |
(list |
376 |
;; Variable declarations (avoid the real function call) |
;; Variable declarations (avoid the real function call) |
377 |
'("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)\\(.*::\\|[ \t]*(.*)\\)?\\([^!\n]*\\)" |
'("^[ \t0-9]*\\(real\\|integer\\|c\\(haracter\\|omplex\\)\\|logical\\|type[ \t]*(\\sw+)\\)\\(.*::\\|[ \t]*(.*)\\)?\\([^!\n]*\\)" |
378 |
(1 font-lock-type-face) (4 font-lock-variable-name-face)) |
(1 font-lock-type-face t) (4 font-lock-variable-name-face)) |
379 |
;; do, if, select, where, and forall constructs |
;; do, if, select, where, and forall constructs |
380 |
'("\\<\\(end[ \t]*\\(do\\|if\\|select\\|forall\\|where\\)\\)\\>\\([ \t]+\\(\\sw+\\)\\)?" |
'("\\<\\(end[ \t]*\\(do\\|if\\|select\\|forall\\|where\\)\\)\\>\\([ \t]+\\(\\sw+\\)\\)?" |
381 |
(1 font-lock-keyword-face) (3 font-lock-constant-face nil t)) |
(1 font-lock-keyword-face) (3 font-lock-constant-face nil t)) |
400 |
(list |
(list |
401 |
f90-keywords-level-3-re |
f90-keywords-level-3-re |
402 |
f90-operators-re |
f90-operators-re |
403 |
(list f90-procedures-re '(1 font-lock-keyword-face t)) |
(list f90-procedures-re '(1 font-lock-keyword-face keep)) |
404 |
"\\<real\\>" ; Avoid overwriting real defs. |
"\\<real\\>" ; Avoid overwriting real defs. |
405 |
)) |
)) |
406 |
"Highlights all F90 keywords and intrinsic procedures.") |
"Highlights all F90 keywords and intrinsic procedures.") |
824 |
The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word. |
The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word. |
825 |
f90-leave-line-no |
f90-leave-line-no |
826 |
Do not left-justify line numbers. (default nil) |
Do not left-justify line numbers. (default nil) |
|
f90-startup-message |
|
|
Set to nil to inhibit message first time F90 mode is used. (default t) |
|
827 |
f90-keywords-re |
f90-keywords-re |
828 |
List of keywords used for highlighting/upcase-keywords etc. |
List of keywords used for highlighting/upcase-keywords etc. |
829 |
|
|
877 |
(setq imenu-generic-expression f90-imenu-generic-expression) |
(setq imenu-generic-expression f90-imenu-generic-expression) |
878 |
(set (make-local-variable 'add-log-current-defun-function) |
(set (make-local-variable 'add-log-current-defun-function) |
879 |
#'f90-current-defun) |
#'f90-current-defun) |
880 |
(run-hooks 'f90-mode-hook) |
(run-hooks 'f90-mode-hook)) |
|
;; (if f90-startup-message |
|
|
;; (message "Emacs F90 mode; please report bugs to %s" bug-f90-mode)) |
|
|
(setq f90-startup-message nil)) |
|
881 |
|
|
882 |
;; inline-functions |
;; inline-functions |
883 |
(defsubst f90-get-beg-of-line () |
(defsubst f90-get-beg-of-line () |
902 |
|
|
903 |
(defsubst f90-line-continued () |
(defsubst f90-line-continued () |
904 |
(save-excursion |
(save-excursion |
905 |
|
(beginning-of-line) |
906 |
|
(while (and (looking-at "[ \t]*\\(!\\|$\\)") (zerop (forward-line -1)))) |
907 |
(let ((bol (f90-get-beg-of-line))) |
(let ((bol (f90-get-beg-of-line))) |
908 |
(end-of-line) |
(end-of-line) |
909 |
(while (f90-in-comment) |
(while (f90-in-comment) |
1024 |
(looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>")) |
(looking-at "\\(module\\)[ \t]+\\(\\sw+\\)\\>")) |
1025 |
(list (f90-match-piece 1) (f90-match-piece 2))) |
(list (f90-match-piece 1) (f90-match-piece 2))) |
1026 |
((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)")) |
((and (not (looking-at "end[ \t]*\\(function\\|subroutine\\)")) |
1027 |
(looking-at "[^!\"\&\n]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)")) |
(looking-at "[^!'\"\&\n]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)")) |
1028 |
(list (f90-match-piece 1) (f90-match-piece 2))))) |
(list (f90-match-piece 1) (f90-match-piece 2))))) |
1029 |
|
|
1030 |
(defsubst f90-looking-at-program-block-end () |
(defsubst f90-looking-at-program-block-end () |
1322 |
(if abbrev-mode (expand-abbrev)) |
(if abbrev-mode (expand-abbrev)) |
1323 |
(beginning-of-line) ; Reindent where likely to be needed. |
(beginning-of-line) ; Reindent where likely to be needed. |
1324 |
(f90-indent-line-no) |
(f90-indent-line-no) |
1325 |
(if (or (looking-at "\\(end\\|else\\|!\\)")) |
(f90-indent-line 'no-update) |
|
(f90-indent-line 'no-update)) |
|
1326 |
(end-of-line) |
(end-of-line) |
1327 |
(delete-horizontal-space) ;Destroy trailing whitespace |
(delete-horizontal-space) ;Destroy trailing whitespace |
1328 |
(setq string (f90-in-string)) |
(setq string (f90-in-string)) |
1374 |
(if struct (setq block-list (cons struct block-list))) |
(if struct (setq block-list (cons struct block-list))) |
1375 |
(while (and (f90-line-continued) (zerop (forward-line 1)) |
(while (and (f90-line-continued) (zerop (forward-line 1)) |
1376 |
(< (point) end-region-mark)) |
(< (point) end-region-mark)) |
1377 |
(if (not (zerop (- (current-indentation) |
(if (looking-at "[ \t]*!") |
1378 |
(+ ind-curr f90-continuation-indent)))) |
(f90-indent-to (f90-comment-indent)) |
1379 |
(f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no))) |
(if (not (zerop (- (current-indentation) |
1380 |
|
(+ ind-curr f90-continuation-indent)))) |
1381 |
|
(f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no)))) |
1382 |
;; process all following lines |
;; process all following lines |
1383 |
(while (and (zerop (forward-line 1)) (< (point) end-region-mark)) |
(while (and (zerop (forward-line 1)) (< (point) end-region-mark)) |
1384 |
(beginning-of-line) |
(beginning-of-line) |
1426 |
(f90-indent-to ind-curr)) |
(f90-indent-to ind-curr)) |
1427 |
(while (and (f90-line-continued) (zerop (forward-line 1)) |
(while (and (f90-line-continued) (zerop (forward-line 1)) |
1428 |
(< (point) end-region-mark)) |
(< (point) end-region-mark)) |
1429 |
(if (not (zerop (- (current-indentation) |
(if (looking-at "[ \t]*!") |
1430 |
(+ ind-curr f90-continuation-indent)))) |
(f90-indent-to (f90-comment-indent)) |
1431 |
(f90-indent-to (+ ind-curr f90-continuation-indent) 'no-line-no)))) |
(if (not (zerop (- (current-indentation) |
1432 |
|
(+ ind-curr f90-continuation-indent)))) |
1433 |
|
(f90-indent-to |
1434 |
|
(+ ind-curr f90-continuation-indent) 'no-line-no))))) |
1435 |
;; restore point etc |
;; restore point etc |
1436 |
(setq f90-cache-position nil) |
(setq f90-cache-position nil) |
1437 |
(goto-char save-point) |
(goto-char save-point) |