diff options
| author | Glenn Morris | 2002-05-12 13:31:31 +0000 |
|---|---|---|
| committer | Glenn Morris | 2002-05-12 13:31:31 +0000 |
| commit | 8edfcc7dddddc07cfc64ccd7c3950fc1e29a304d (patch) | |
| tree | 74229da456f62c7179b197a086872494b22b3fa6 | |
| parent | fe72c9047d54384e8853310f4232812ab67ade71 (diff) | |
| download | emacs-8edfcc7dddddc07cfc64ccd7c3950fc1e29a304d.tar.gz emacs-8edfcc7dddddc07cfc64ccd7c3950fc1e29a304d.zip | |
(fortran-preprocessor-re): New variable. Use it for font-locking.
(fortran-previous-statement, fortran-next-statement): Make them skip over
preprocessor lines as they do with comment lines.
(fortran-calculate-indent): Use fortran-preprocessor-re.
| -rw-r--r-- | lisp/progmodes/fortran.el | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index b172d1f325a..4e5e6144e68 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el | |||
| @@ -139,6 +139,13 @@ You might want to change this to \"*\", for instance." | |||
| 139 | :type 'regexp | 139 | :type 'regexp |
| 140 | :group 'fortran-comment) | 140 | :group 'fortran-comment) |
| 141 | 141 | ||
| 142 | (defcustom fortran-preprocessor-re | ||
| 143 | "^[ \t]*#.*" | ||
| 144 | "*Regexp to match the whole of a preprocessor line." | ||
| 145 | :version "21.3" | ||
| 146 | :type 'regexp | ||
| 147 | :group 'fortran-indent) | ||
| 148 | |||
| 142 | (defcustom fortran-minimum-statement-indent-fixed 6 | 149 | (defcustom fortran-minimum-statement-indent-fixed 6 |
| 143 | "*Minimum statement indentation for fixed format continuation style." | 150 | "*Minimum statement indentation for fixed format continuation style." |
| 144 | :type 'integer | 151 | :type 'integer |
| @@ -368,7 +375,8 @@ These get fixed-format comments fontified.") | |||
| 368 | '("^\t\\([1-9]\\)" 1 font-lock-string-face)) | 375 | '("^\t\\([1-9]\\)" 1 font-lock-string-face)) |
| 369 | (list | 376 | (list |
| 370 | ;; cpp stuff (ugh) | 377 | ;; cpp stuff (ugh) |
| 371 | '("^# *[a-z]+" . font-lock-keyword-face)) | 378 | ;;; '("^# *[a-z]+" . font-lock-keyword-face)) |
| 379 | `(,fortran-preprocessor-re (0 font-lock-keyword-face t))) | ||
| 372 | ;; The list `fortran-font-lock-keywords-2' less that for types | 380 | ;; The list `fortran-font-lock-keywords-2' less that for types |
| 373 | ;; (see above). | 381 | ;; (see above). |
| 374 | (cdr (nthcdr (length fortran-font-lock-keywords-1) | 382 | (cdr (nthcdr (length fortran-font-lock-keywords-1) |
| @@ -970,20 +978,23 @@ Auto-indent does not happen if a numeric ARG is used." | |||
| 970 | 978 | ||
| 971 | (defun fortran-previous-statement () | 979 | (defun fortran-previous-statement () |
| 972 | "Move point to beginning of the previous Fortran statement. | 980 | "Move point to beginning of the previous Fortran statement. |
| 973 | Returns `first-statement' if that statement is the first | 981 | Returns 'first-statement if that statement is the first |
| 974 | non-comment Fortran statement in the file, and nil otherwise." | 982 | non-comment Fortran statement in the file, and nil otherwise. |
| 983 | Preprocessor lines are treated as comments." | ||
| 975 | (interactive) | 984 | (interactive) |
| 976 | (let (not-first-statement continue-test) | 985 | (let (not-first-statement continue-test) |
| 977 | (beginning-of-line) | 986 | (beginning-of-line) |
| 978 | (setq continue-test | 987 | (setq continue-test |
| 979 | (and | 988 | (and |
| 980 | (not (looking-at fortran-comment-line-start-skip)) | 989 | (not (looking-at fortran-comment-line-start-skip)) |
| 990 | (not (looking-at fortran-preprocessor-re)) | ||
| 981 | (or (looking-at | 991 | (or (looking-at |
| 982 | (concat "[ \t]*" | 992 | (concat "[ \t]*" |
| 983 | (regexp-quote fortran-continuation-string))) | 993 | (regexp-quote fortran-continuation-string))) |
| 984 | (looking-at " \\{5\\}[^ 0\n]\\|\t[1-9]")))) | 994 | (looking-at " \\{5\\}[^ 0\n]\\|\t[1-9]")))) |
| 985 | (while (and (setq not-first-statement (= (forward-line -1) 0)) | 995 | (while (and (setq not-first-statement (= (forward-line -1) 0)) |
| 986 | (or (looking-at fortran-comment-line-start-skip) | 996 | (or (looking-at fortran-comment-line-start-skip) |
| 997 | (looking-at fortran-preprocessor-re) | ||
| 987 | (looking-at "[ \t]*$\\| \\{5\\}[^ 0\n]\\|\t[1-9]") | 998 | (looking-at "[ \t]*$\\| \\{5\\}[^ 0\n]\\|\t[1-9]") |
| 988 | (looking-at (concat "[ \t]*" comment-start-skip))))) | 999 | (looking-at (concat "[ \t]*" comment-start-skip))))) |
| 989 | (cond ((and continue-test | 1000 | (cond ((and continue-test |
| @@ -996,8 +1007,9 @@ non-comment Fortran statement in the file, and nil otherwise." | |||
| 996 | 1007 | ||
| 997 | (defun fortran-next-statement () | 1008 | (defun fortran-next-statement () |
| 998 | "Move point to beginning of the next Fortran statement. | 1009 | "Move point to beginning of the next Fortran statement. |
| 999 | Returns `last-statement' if that statement is the last | 1010 | Returns 'last-statement if that statement is the last |
| 1000 | non-comment Fortran statement in the file, and nil otherwise." | 1011 | non-comment Fortran statement in the file, and nil otherwise. |
| 1012 | Preprocessor lines are treated as comments." | ||
| 1001 | (interactive) | 1013 | (interactive) |
| 1002 | (let (not-last-statement) | 1014 | (let (not-last-statement) |
| 1003 | (beginning-of-line) | 1015 | (beginning-of-line) |
| @@ -1005,6 +1017,7 @@ non-comment Fortran statement in the file, and nil otherwise." | |||
| 1005 | (and (= (forward-line 1) 0) | 1017 | (and (= (forward-line 1) 0) |
| 1006 | (not (eobp)))) | 1018 | (not (eobp)))) |
| 1007 | (or (looking-at fortran-comment-line-start-skip) | 1019 | (or (looking-at fortran-comment-line-start-skip) |
| 1020 | (looking-at fortran-preprocessor-re) | ||
| 1008 | (looking-at "[ \t]*$\\| [^ 0\n]\\|\t[1-9]") | 1021 | (looking-at "[ \t]*$\\| [^ 0\n]\\|\t[1-9]") |
| 1009 | (looking-at (concat "[ \t]*" comment-start-skip))))) | 1022 | (looking-at (concat "[ \t]*" comment-start-skip))))) |
| 1010 | (if (not not-last-statement) | 1023 | (if (not not-last-statement) |
| @@ -1356,7 +1369,7 @@ Return point or nil." | |||
| 1356 | fortran-continuation-string))) | 1369 | fortran-continuation-string))) |
| 1357 | (looking-at " \\{5\\}[^ 0\n]\\|\t[1-9]")) | 1370 | (looking-at " \\{5\\}[^ 0\n]\\|\t[1-9]")) |
| 1358 | (setq icol (+ icol fortran-continuation-indent))) | 1371 | (setq icol (+ icol fortran-continuation-indent))) |
| 1359 | ((looking-at "[ \t]*#") ; Check for cpp directive. | 1372 | ((looking-at fortran-preprocessor-re) ; Check for cpp directive. |
| 1360 | (setq fortran-minimum-statement-indent 0 icol 0)) | 1373 | (setq fortran-minimum-statement-indent 0 icol 0)) |
| 1361 | (first-statement) | 1374 | (first-statement) |
| 1362 | ((and fortran-check-all-num-for-matching-do | 1375 | ((and fortran-check-all-num-for-matching-do |