diff options
| author | Simon Marshall | 1995-10-26 13:31:26 +0000 |
|---|---|---|
| committer | Simon Marshall | 1995-10-26 13:31:26 +0000 |
| commit | f408b02745a855076ef7266ccffca858f63441c6 (patch) | |
| tree | bcc841d5fbc54bb898693ba68d832c75234ac2bc | |
| parent | 9bfbb130d94c1f2a03bba82a8d46b19d4c879825 (diff) | |
| download | emacs-f408b02745a855076ef7266ccffca858f63441c6.tar.gz emacs-f408b02745a855076ef7266ccffca858f63441c6.zip | |
Fix to fortran-font-lock-keywords-* for new font-lock-keywords structure.
| -rw-r--r-- | lisp/progmodes/fortran.el | 142 |
1 files changed, 87 insertions, 55 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index 97940b00ea7..83e34991289 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el | |||
| @@ -188,27 +188,17 @@ This variable used in TAB format mode.") | |||
| 188 | ;; Regexps done by simon@gnu with help from Ulrik Dickow <dickow@nbi.dk> and | 188 | ;; Regexps done by simon@gnu with help from Ulrik Dickow <dickow@nbi.dk> and |
| 189 | ;; probably others Si's forgotten about (sorry). | 189 | ;; probably others Si's forgotten about (sorry). |
| 190 | 190 | ||
| 191 | (defconst fortran-font-lock-keywords-1 | 191 | (defconst fortran-font-lock-keywords-1 nil |
| 192 | (let ((comment-chars "c!*")) | ||
| 193 | (list | ||
| 194 | ;; | ||
| 195 | ;; Fontify comments and strings. We assume that strings cannot be quoted. | ||
| 196 | (cons (concat "^[" comment-chars "].*") 'font-lock-comment-face) | ||
| 197 | '(fortran-match-!-comment . font-lock-comment-face) | ||
| 198 | (list (concat "^[^" comment-chars "\t\n]" (make-string 71 ?.) "\\(.*\\)") | ||
| 199 | '(1 font-lock-comment-face)) | ||
| 200 | '("'[^'\n]*'?" . font-lock-string-face) | ||
| 201 | ;; | ||
| 202 | ;; Program, subroutine and function declarations, plus calls. | ||
| 203 | (list (concat "\\<\\(block[ \t]*data\\|call\\|entry\\|function\\|" | ||
| 204 | "program\\|subroutine\\)\\>[ \t]*\\(\\sw+\\)?") | ||
| 205 | '(1 font-lock-keyword-face) | ||
| 206 | '(2 font-lock-function-name-face nil t)))) | ||
| 207 | "Subdued level highlighting for Fortran mode.") | 192 | "Subdued level highlighting for Fortran mode.") |
| 208 | 193 | ||
| 209 | (defconst fortran-font-lock-keywords-2 | 194 | (defconst fortran-font-lock-keywords-2 nil |
| 210 | (append fortran-font-lock-keywords-1 | 195 | "Medium level highlighting for Fortran mode.") |
| 211 | (let ((type-types | 196 | |
| 197 | (defconst fortran-font-lock-keywords-3 nil | ||
| 198 | "Gaudy level highlighting for Fortran mode.") | ||
| 199 | |||
| 200 | (let ((comment-chars "c!*") | ||
| 201 | (fortran-type-types | ||
| 212 | ; (make-regexp | 202 | ; (make-regexp |
| 213 | ; (let ((simple-types '("character" "byte" "integer" "logical" | 203 | ; (let ((simple-types '("character" "byte" "integer" "logical" |
| 214 | ; "none" "real" "complex" | 204 | ; "none" "real" "complex" |
| @@ -234,7 +224,7 @@ This variable used in TAB format mode.") | |||
| 234 | "nt\\(eger\\|rinsic\\)\\)\\|" | 224 | "nt\\(eger\\|rinsic\\)\\)\\|" |
| 235 | "logical\\|map\\|none\\|parameter\\|re\\(al\\|cord\\)\\|" | 225 | "logical\\|map\\|none\\|parameter\\|re\\(al\\|cord\\)\\|" |
| 236 | "s\\(ave\\|tructure\\)\\|union")) | 226 | "s\\(ave\\|tructure\\)\\|union")) |
| 237 | (fkeywords | 227 | (fortran-keywords |
| 238 | ; ("continue" "format" "end" "enddo" "if" "then" "else" "endif" | 228 | ; ("continue" "format" "end" "enddo" "if" "then" "else" "endif" |
| 239 | ; "elseif" "while" "inquire" "stop" "return" "include" "open" | 229 | ; "elseif" "while" "inquire" "stop" "return" "include" "open" |
| 240 | ; "close" "read" "write" "format" "print") | 230 | ; "close" "read" "write" "format" "print") |
| @@ -242,46 +232,85 @@ This variable used in TAB format mode.") | |||
| 242 | "e\\(lse\\(\\|if\\)\\|nd\\(\\|do\\|if\\)\\)\\|format\\|" | 232 | "e\\(lse\\(\\|if\\)\\|nd\\(\\|do\\|if\\)\\)\\|format\\|" |
| 243 | "i\\(f\\|n\\(clude\\|quire\\)\\)\\|open\\|print\\|" | 233 | "i\\(f\\|n\\(clude\\|quire\\)\\)\\|open\\|print\\|" |
| 244 | "re\\(ad\\|turn\\)\\|stop\\|then\\|w\\(hile\\|rite\\)")) | 234 | "re\\(ad\\|turn\\)\\|stop\\|then\\|w\\(hile\\|rite\\)")) |
| 245 | (flogicals | 235 | (fortran-logicals |
| 246 | ; ("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne" "true" "false") | 236 | ; ("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne" "true" "false") |
| 247 | "and\\|eq\\|false\\|g[et]\\|l[et]\\|n\\(e\\|ot\\)\\|or\\|true")) | 237 | "and\\|eq\\|false\\|g[et]\\|l[et]\\|n\\(e\\|ot\\)\\|or\\|true")) |
| 248 | (list | ||
| 249 | ;; | ||
| 250 | ;; Fontify types and variable names (but not length specs or `/'s). | ||
| 251 | (list (concat "\\<\\(" type-types "\\)\\>[0-9 \t/*]*\\(\\sw+\\)?") | ||
| 252 | '(1 font-lock-type-face) | ||
| 253 | '(15 font-lock-variable-name-face nil t)) | ||
| 254 | ;; | ||
| 255 | ;; Fontify all builtin keywords (except logical, do and goto; see below). | ||
| 256 | (concat "\\<\\(" fkeywords "\\)\\>") | ||
| 257 | ;; | ||
| 258 | ;; Fontify all builtin operators. | ||
| 259 | (concat "\\.\\(" flogicals "\\)\\.") | ||
| 260 | ;; | ||
| 261 | ;; Fontify do/goto keywords and targets, and goto tags. | ||
| 262 | (list "\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)?" | ||
| 263 | '(1 font-lock-keyword-face) | ||
| 264 | '(2 font-lock-reference-face nil t)) | ||
| 265 | (cons "^ *\\([0-9]+\\)" 'font-lock-reference-face)))) | ||
| 266 | "Medium level highlighting for Fortran mode.") | ||
| 267 | 238 | ||
| 268 | (defconst fortran-font-lock-keywords-3 | 239 | (setq fortran-font-lock-keywords-1 |
| 269 | (append fortran-font-lock-keywords-2 | ||
| 270 | (list | 240 | (list |
| 271 | ;; | 241 | ;; |
| 272 | ;; Fontify goto-like `err=label'/`end=label' in read/write statements. | 242 | ;; Fontify syntactically (assuming strings cannot be quoted or span lines). |
| 273 | (list ", *\\(e\\(nd\\|rr\\)\\)\\> *\\(= *\\([0-9]+\\)\\)?" | 243 | (cons (concat "^[" comment-chars "].*") 'font-lock-comment-face) |
| 274 | '(1 font-lock-keyword-face) | 244 | '(fortran-match-!-comment . font-lock-comment-face) |
| 275 | '(4 font-lock-reference-face nil t)) | 245 | (list (concat "^[^" comment-chars "\t\n]" (make-string 71 ?.) "\\(.*\\)") |
| 246 | '(1 font-lock-comment-face)) | ||
| 247 | '("'[^'\n]*'?" . font-lock-string-face) | ||
| 276 | ;; | 248 | ;; |
| 277 | ;; Highlight a standard continuation character and in a TAB-formatted line. | 249 | ;; Program, subroutine and function declarations, plus calls. |
| 278 | '("^ \\([^ 0]\\)" 1 font-lock-string-face) | 250 | (list (concat "\\<\\(block[ \t]*data\\|call\\|entry\\|function\\|" |
| 279 | '("^\t\\([1-9]\\)" 1 font-lock-string-face))) | 251 | "program\\|subroutine\\)\\>[ \t]*\\(\\sw+\\)?") |
| 280 | "Gaudy level highlighting for Fortran mode.") | 252 | '(1 font-lock-keyword-face) |
| 253 | '(2 font-lock-function-name-face nil t)))) | ||
| 254 | |||
| 255 | (setq fortran-font-lock-keywords-2 | ||
| 256 | (append fortran-font-lock-keywords-1 | ||
| 257 | (list | ||
| 258 | ;; | ||
| 259 | ;; Fontify all type specifiers (must be first; see below). | ||
| 260 | (cons (concat "\\<\\(" fortran-type-types "\\)\\>") 'font-lock-type-face) | ||
| 261 | ;; | ||
| 262 | ;; Fontify all builtin keywords (except logical, do and goto; see below). | ||
| 263 | (concat "\\<\\(" fortran-keywords "\\)\\>") | ||
| 264 | ;; | ||
| 265 | ;; Fontify all builtin operators. | ||
| 266 | (concat "\\.\\(" fortran-logicals "\\)\\.") | ||
| 267 | ;; | ||
| 268 | ;; Fontify do/goto keywords and targets, and goto tags. | ||
| 269 | (list "\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)?" | ||
| 270 | '(1 font-lock-keyword-face) | ||
| 271 | '(2 font-lock-reference-face nil t)) | ||
| 272 | (cons "^ *\\([0-9]+\\)" 'font-lock-reference-face)))) | ||
| 273 | |||
| 274 | (setq fortran-font-lock-keywords-3 | ||
| 275 | (append | ||
| 276 | ;; | ||
| 277 | ;; The list `fortran-font-lock-keywords-1'. | ||
| 278 | fortran-font-lock-keywords-1 | ||
| 279 | ;; | ||
| 280 | ;; Fontify all type specifiers plus their declared items. | ||
| 281 | (list | ||
| 282 | (list (concat "\\<\\(" fortran-type-types "\\)\\>[ \t(/]*\\(*\\)?") | ||
| 283 | ;; Fontify the type specifier. | ||
| 284 | '(1 font-lock-type-face) | ||
| 285 | ;; Fontify each declaration item (or just the /.../ block name). | ||
| 286 | '(font-lock-match-c++-style-declaration-item-and-skip-to-next | ||
| 287 | ;; Start after any *(...) expression. | ||
| 288 | (and (match-beginning 15) (forward-sexp 1)) | ||
| 289 | ;; No need to clean up. | ||
| 290 | nil | ||
| 291 | ;; Fontify as a variable name, functions are fontified elsewhere. | ||
| 292 | (1 font-lock-variable-name-face nil t)))) | ||
| 293 | ;; | ||
| 294 | ;; Things extra to `fortran-font-lock-keywords-3' (must be done first). | ||
| 295 | (list | ||
| 296 | ;; | ||
| 297 | ;; Fontify goto-like `err=label'/`end=label' in read/write statements. | ||
| 298 | '(", *\\(e\\(nd\\|rr\\)\\)\\> *\\(= *\\([0-9]+\\)\\)?" | ||
| 299 | (1 font-lock-keyword-face) (4 font-lock-reference-face nil t)) | ||
| 300 | ;; | ||
| 301 | ;; Highlight standard continuation character and in a TAB-formatted line. | ||
| 302 | '("^ \\([^ 0]\\)" 1 font-lock-string-face) | ||
| 303 | '("^\t\\([1-9]\\)" 1 font-lock-string-face)) | ||
| 304 | ;; | ||
| 305 | ;; The list `fortran-font-lock-keywords-2' less that for types (see above). | ||
| 306 | (cdr (nthcdr (length fortran-font-lock-keywords-1) | ||
| 307 | fortran-font-lock-keywords-2)))) | ||
| 308 | ) | ||
| 281 | 309 | ||
| 282 | (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1 | 310 | (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1 |
| 283 | "Default expressions to highlight in Fortran mode.") | 311 | "Default expressions to highlight in Fortran mode.") |
| 284 | 312 | ||
| 313 | |||
| 285 | (defvar fortran-mode-map () | 314 | (defvar fortran-mode-map () |
| 286 | "Keymap used in Fortran mode.") | 315 | "Keymap used in Fortran mode.") |
| 287 | (if fortran-mode-map | 316 | (if fortran-mode-map |
| @@ -458,9 +487,12 @@ with no args, if that value is non-nil." | |||
| 458 | (setq local-abbrev-table fortran-mode-abbrev-table) | 487 | (setq local-abbrev-table fortran-mode-abbrev-table) |
| 459 | (set-syntax-table fortran-mode-syntax-table) | 488 | (set-syntax-table fortran-mode-syntax-table) |
| 460 | ;; Font Lock mode support. | 489 | ;; Font Lock mode support. |
| 461 | (set (make-local-variable 'font-lock-defaults) | 490 | (make-local-variable 'font-lock-defaults) |
| 462 | '((fortran-font-lock-keywords fortran-font-lock-keywords-1 | 491 | (setq font-lock-defaults '((fortran-font-lock-keywords |
| 463 | fortran-font-lock-keywords-2 fortran-font-lock-keywords-3) t t)) | 492 | fortran-font-lock-keywords-1 |
| 493 | fortran-font-lock-keywords-2 | ||
| 494 | fortran-font-lock-keywords-3) | ||
| 495 | t t ((?/ . "$/")))) | ||
| 464 | (make-local-variable 'fortran-break-before-delimiters) | 496 | (make-local-variable 'fortran-break-before-delimiters) |
| 465 | (setq fortran-break-before-delimiters t) | 497 | (setq fortran-break-before-delimiters t) |
| 466 | (make-local-variable 'indent-line-function) | 498 | (make-local-variable 'indent-line-function) |