X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/49f70d46ea38ceb7a501594db7f6ea35e19681aa..ca717aa0fd048d3529ad8f5cedb37e0b31169b96:/lisp/progmodes/fortran.el diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index eff0c2c9ce..c0d4454c3e 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el @@ -1,8 +1,7 @@ ;;; fortran.el --- Fortran mode for GNU Emacs -;; Copyright (C) 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, -;; 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -;; Free Software Foundation, Inc. +;; Copyright (C) 1986, 1993-1995, 1997-2015 Free Software Foundation, +;; Inc. ;; Author: Michael D. Prange ;; Maintainer: Glenn Morris @@ -31,7 +30,7 @@ ;; form. For editing Fortran 90 free format source, use `f90-mode' ;; (f90.el). It is meant to support the GNU Fortran language ;; implemented by g77 (its extensions to Fortran77 and -;; interpretations, e.g. of blackslash in strings). +;; interpretations, e.g. of backslash in strings). ;;; History: @@ -167,7 +166,7 @@ allow trailing comments on a line." (defcustom fortran-directive-re "^[ \t]*#.*" "Regexp to match a directive line. -The matching text will be fontified with `font-lock-keyword-face'. +The matching text will be fontified with `font-lock-preprocessor-face'. The matching line will be given zero indentation." :version "22.1" :type 'regexp @@ -293,7 +292,7 @@ buffer). This corresponds to the g77 compiler option :type 'integer :safe 'integerp :initialize 'custom-initialize-default - :set (lambda (symbol value) + :set (lambda (_symbol value) ;; Do all fortran buffers, and the default. (fortran-line-length value t)) :version "23.1" @@ -454,7 +453,7 @@ The only difference is, it returns t in a case when the default returns nil." ;; Standard continuation character and in a TAB-formatted line. '("^ \\{5\\}\\([^ 0\n]\\)" 1 font-lock-string-face) '("^\t\\([1-9]\\)" 1 font-lock-string-face)) - `((,fortran-directive-re (0 font-lock-keyword-face t))) + `((,fortran-directive-re (0 font-lock-preprocessor-face t))) ;; `fortran-font-lock-keywords-2' without types (see above). (cdr (nthcdr (length fortran-font-lock-keywords-1) fortran-font-lock-keywords-2))) @@ -488,13 +487,22 @@ Consists of level 3 plus all other intrinsics not already highlighted.") ;; (We can do so for F90-style). Therefore an unmatched quote in a ;; standard comment will throw fontification off on the wrong track. ;; So we do syntactic fontification with regexps. -(defun fortran-font-lock-syntactic-keywords () - "Return a value for `font-lock-syntactic-keywords' in Fortran mode. -This varies according to the value of `fortran-line-length'. +(defun fortran-make-syntax-propertize-function (line-length) + "Return a value for `syntax-propertize-function' in Fortran mode. +This varies according to the value of LINE-LENGTH. This is used to fontify fixed-format Fortran comments." - `(("^[cd\\*]" 0 (11)) - (,(format "^[^cd\\*\t\n].\\{%d\\}\\([^\n]+\\)" (1- fortran-line-length)) - 1 (11)))) + ;; This results in a non-byte-compiled function. We could pass it through + ;; `byte-compile', but simple benchmarks indicate that it's probably not + ;; worth the trouble (about 0.5% of slow down). + (eval ;I hate `eval', but it's hard to avoid it here. + `(syntax-propertize-rules + ("^[cd\\*]" (0 "<")) + ;; We mark all chars after line-length as "comment-start", rather than + ;; just the first one. This is so that a closing ' that's past the + ;; line-length will indeed be ignored (and will result in a string that + ;; leaks into subsequent lines). + ((format "^[^cd\\*\t\n].\\{%d\\}\\(.+\\)" (1- line-length)) + (1 "<"))))) (defvar fortran-font-lock-keywords fortran-font-lock-keywords-1 "Default expressions to highlight in Fortran mode.") @@ -564,7 +572,7 @@ in the Fortran entry in `hs-special-modes-alist'.") ;; An alternative is to match on THEN at a line end, eg: ;; ".*)[ \t]*then[ \t]*\\($\\|!\\)" ;; This would also match ELSE branches, though. This does not seem - ;; right to me, because then one has neighbouring blocks that are + ;; right to me, because then one has neighboring blocks that are ;; not nested in each other. "\\(if[ \t]*(\\(.*\\|" ".*\n\\([^if]*\\([^i].\\|.[^f]\\|.\\>\\)\\)\\)\\