diff options
| author | Glenn Morris | 2012-12-10 20:42:49 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-12-10 20:42:49 -0800 |
| commit | a0099d31a646b16ee0bbc65c423f327066d59e54 (patch) | |
| tree | 8c4ac176e9900943133f83e62b44dc7d798925a3 /lisp | |
| parent | 8c21bef6d1a31b6a5f1879530f7dcb2525d942ca (diff) | |
| download | emacs-a0099d31a646b16ee0bbc65c423f327066d59e54.tar.gz emacs-a0099d31a646b16ee0bbc65c423f327066d59e54.zip | |
Fix for indentation of f90 preproc lines embedded in continuations
* lisp/progmodes/f90.el (f90-line-continued, f90-indent-region):
Treat preprocessor lines embedded in continuations like comments.
(f90-indent-line): Special-case preprocessor lines.
* test/automated/f90.el (f90-test-bug13138): New test.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/f90.el | 33 |
2 files changed, 25 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ebce9305f31..2aafbd758d7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-12-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/f90.el (f90-line-continued, f90-indent-region): | ||
| 4 | Treat preprocessor lines embedded in continuations like comments. | ||
| 5 | (f90-indent-line): Special-case preprocessor lines. (Bug#13138) | ||
| 6 | |||
| 1 | 2012-12-11 Jay Belanger <jay.p.belanger@gmail.com> | 7 | 2012-12-11 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 8 | ||
| 3 | * calc/calc.el (calc-standard-date-formats): Add more date | 9 | * calc/calc.el (calc-standard-date-formats): Add more date |
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index f42952685d0..59dda170b77 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -1178,11 +1178,11 @@ and lies before point." | |||
| 1178 | 1178 | ||
| 1179 | (defsubst f90-line-continued () | 1179 | (defsubst f90-line-continued () |
| 1180 | "Return t if the current line is a continued one. | 1180 | "Return t if the current line is a continued one. |
| 1181 | This includes comment lines embedded in continued lines, but | 1181 | This includes comment or preprocessor lines embedded in continued lines, |
| 1182 | not the last line of a continued statement." | 1182 | but not the last line of a continued statement." |
| 1183 | (save-excursion | 1183 | (save-excursion |
| 1184 | (beginning-of-line) | 1184 | (beginning-of-line) |
| 1185 | (while (and (looking-at "[ \t]*\\(!\\|$\\)") (zerop (forward-line -1)))) | 1185 | (while (and (looking-at "[ \t]*\\([!#]\\|$\\)") (zerop (forward-line -1)))) |
| 1186 | (end-of-line) | 1186 | (end-of-line) |
| 1187 | (while (f90-in-comment) | 1187 | (while (f90-in-comment) |
| 1188 | (search-backward "!" (line-beginning-position)) | 1188 | (search-backward "!" (line-beginning-position)) |
| @@ -1832,11 +1832,15 @@ after indenting." | |||
| 1832 | (f90-indent-line-no) | 1832 | (f90-indent-line-no) |
| 1833 | (setq no-line-number t) | 1833 | (setq no-line-number t) |
| 1834 | (skip-chars-forward " \t")) | 1834 | (skip-chars-forward " \t")) |
| 1835 | (if (looking-at "!") | 1835 | ;; FIXME This means f90-calculate-indent gives different answers |
| 1836 | (setq indent (f90-comment-indent)) | 1836 | ;; for comments and preprocessor lines to this function. |
| 1837 | (and f90-smart-end (looking-at "end") | 1837 | ;; Better to make f90-calculate-indent return the correct answer? |
| 1838 | (f90-match-end)) | 1838 | (cond ((looking-at "!") (setq indent (f90-comment-indent))) |
| 1839 | (setq indent (f90-calculate-indent))) | 1839 | ((looking-at "#") (setq indent 0)) |
| 1840 | (t | ||
| 1841 | (and f90-smart-end (looking-at "end") | ||
| 1842 | (f90-match-end)) | ||
| 1843 | (setq indent (f90-calculate-indent)))) | ||
| 1840 | (or (= indent (current-column)) | 1844 | (or (= indent (current-column)) |
| 1841 | (f90-indent-to indent no-line-number)) | 1845 | (f90-indent-to indent no-line-number)) |
| 1842 | ;; If initial point was within line's indentation, | 1846 | ;; If initial point was within line's indentation, |
| @@ -1973,12 +1977,13 @@ If run in the middle of a line, the line is not broken." | |||
| 1973 | (f90-indent-to ind-curr)) | 1977 | (f90-indent-to ind-curr)) |
| 1974 | (while (and (f90-line-continued) (zerop (forward-line 1)) | 1978 | (while (and (f90-line-continued) (zerop (forward-line 1)) |
| 1975 | (< (point) end-region-mark)) | 1979 | (< (point) end-region-mark)) |
| 1976 | (if (looking-at "[ \t]*!") | 1980 | (cond ((looking-at "[ \t]*#") (f90-indent-to 0)) |
| 1977 | (f90-indent-to (f90-comment-indent)) | 1981 | ((looking-at "[ \t]*!") (f90-indent-to (f90-comment-indent))) |
| 1978 | (or (= (current-indentation) | 1982 | (t |
| 1979 | (+ ind-curr f90-continuation-indent)) | 1983 | (or (= (current-indentation) |
| 1980 | (f90-indent-to | 1984 | (+ ind-curr f90-continuation-indent)) |
| 1981 | (+ ind-curr f90-continuation-indent) 'no-line-no))))) | 1985 | (f90-indent-to |
| 1986 | (+ ind-curr f90-continuation-indent) 'no-line-no)))))) | ||
| 1982 | ;; Restore point, etc. | 1987 | ;; Restore point, etc. |
| 1983 | (setq f90-cache-position nil) | 1988 | (setq f90-cache-position nil) |
| 1984 | (goto-char save-point) | 1989 | (goto-char save-point) |