summaryrefslogtreecommitdiff
path: root/lisp/progmodes/fortran.el
diff options
context:
space:
mode:
authorSimon Marshall <simon@gnu.org>1994-10-12 08:24:50 +0000
committerSimon Marshall <simon@gnu.org>1994-10-12 08:24:50 +0000
commite5b15acf678587dab666575ba75fd9d69b7997bd (patch)
tree7502ca4ca8d3b962f9eb330ad637283759982baf /lisp/progmodes/fortran.el
parent6776d3b0c5eaaa98876ca802a9f59aeb87cfea0b (diff)
downloademacs-e5b15acf678587dab666575ba75fd9d69b7997bd.tar.gz
* fortran.el: (fortran-mode-syntax-table): Made `!' be a comment.
(fortran-font-lock-keywords-1, fortran-font-lock-keywords-2, fortran-font-lock-keywords): New variables. (fortran-mode): Set font-lock-defaults.
Diffstat (limited to 'lisp/progmodes/fortran.el')
-rw-r--r--lisp/progmodes/fortran.el67
1 files changed, 67 insertions, 0 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index 1ea86503aae..f177afee57a 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -177,8 +177,73 @@ This variable used in TAB format mode.")
(modify-syntax-entry ?\\ "/" fortran-mode-syntax-table)
(modify-syntax-entry ?. "w" fortran-mode-syntax-table)
(modify-syntax-entry ?_ "w" fortran-mode-syntax-table)
+ (modify-syntax-entry ?\! "<" fortran-mode-syntax-table)
(modify-syntax-entry ?\n ">" fortran-mode-syntax-table))
+;; Comments are real pain in Fortran because there is no way to represent the
+;; standard comment syntax in an Emacs syntax table (we can for VAX-style).
+;; Therefore an unmatched quote in a standard comment will throw fontification
+;; off on the wrong track. But to make it clear(er) to the programmer what is
+;; happening, we don't override string fontification when fontifying, by the
+;; keyword regexp, a standard comment.
+
+(defconst fortran-font-lock-keywords-1
+ '(;; Fontify comments.
+; ("^[Cc*].*$" 0 font-lock-comment-face t)
+ ("^[Cc*].*$" . font-lock-comment-face)
+ ;; Program, subroutine and function declarations, plus calls.
+ ("\\<\\(call\\|function\\|program\\|subroutine\\)\\>[ \t]*\\(\\sw+\\)?"
+ (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)))
+ "For consideration as a value of `fortran-font-lock-keywords'.
+This does fairly subdued highlighting.")
+
+(defconst fortran-font-lock-keywords-2
+ (append fortran-font-lock-keywords-1
+ (let ((type-types
+; ("integer" "logical" "real" "complex" "dimension" "double" "map"
+; "precision" "character" "parameter" "common" "save" "external"
+; "implicit" "intrinsic" "data" "equivalence" "structure" "union")
+ (concat "c\\(haracter\\|om\\(mon\\|plex\\)\\)\\|"
+ "d\\(ata\\|imension\\|ouble\\)\\|"
+ "e\\(quivalence\\|xternal\\)\\|"
+ "i\\(mplicit\\|nt\\(eger\\|rinsic\\)\\)\\|logical\\|map\\|"
+ "p\\(arameter\\|recision\\)\\|re\\(al\\|cord\\)\\|"
+ "s\\(ave\\|tructure\\)\\|union"))
+ (fkeywords
+; ("continue" "format" "end" "enddo" "if" "then" "else" "endif"
+; "elseif" "while" "inquire" "stop" "return" "include" "open"
+; "close" "read" "write" "format" "print")
+ (concat "c\\(lose\\|ontinue\\)\\|"
+ "e\\(lse\\(\\|if\\)\\|nd\\(\\|do\\|if\\)\\)\\|format\\|"
+ "i\\(f\\|n\\(clude\\|quire\\)\\)\\|open\\|print\\|"
+ "re\\(ad\\|turn\\)\\|stop\\|then\\|w\\(hile\\|rite\\)"))
+ (flogicals
+; ("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne" "true" "false")
+ "and\\|eq\\|false\\|g[et]\\|l[et]\\|n\\(e\\|ot\\)\\|or\\|true"))
+ (list
+ ;;
+ ;; Fontify types and variable names (but not length specs or `/'s).
+ (list (concat "\\<\\(" type-types "\\)\\>[0-9 \t/*]*\\(\\sw+\\)?")
+ '(1 font-lock-type-face)
+ '(11 font-lock-variable-name-face nil t))
+ ;;
+ ;; Fontify all builtin keywords (except logical, do and goto; see below).
+ (concat "\\<\\(" fkeywords "\\)\\>")
+ ;;
+ ;; Fontify all builtin operators.
+ (concat "\\.\\(" flogicals "\\)\\.")
+ ;;
+ ;; Fontify do/goto keywords and targets, and goto tags.
+ (list "\\<\\(do\\|go[ \t]*to\\)\\>[ \t]*\\([0-9]+\\)?"
+ '(1 font-lock-keyword-face)
+ '(2 font-lock-reference-face nil t))
+ (cons "^[ \t]*\\([0-9]+\\)" 'font-lock-reference-face))))
+ "For consideration as a value of `fortran-font-lock-keywords'.
+This does a lot more highlighting.")
+
+(defconst fortran-font-lock-keywords fortran-font-lock-keywords-1
+ "Additional expressions to highlight in Fortran mode.")
+
(defvar fortran-mode-map ()
"Keymap used in Fortran mode.")
(if fortran-mode-map
@@ -354,6 +419,8 @@ with no args, if that value is non-nil."
(setq fortran-startup-message nil)
(setq local-abbrev-table fortran-mode-abbrev-table)
(set-syntax-table fortran-mode-syntax-table)
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '(fortran-font-lock-keywords nil t))
(make-local-variable 'fortran-break-before-delimiters)
(setq fortran-break-before-delimiters t)
(make-local-variable 'indent-line-function)