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 | |
| 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.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/f90.el | 33 | ||||
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/automated/f90.el | 18 |
4 files changed, 47 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) |
diff --git a/test/ChangeLog b/test/ChangeLog index 7633d974f57..142dfcb42fd 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-12-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * automated/f90.el (f90-test-bug13138): New test. | ||
| 4 | |||
| 1 | 2012-12-10 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> | 5 | 2012-12-10 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> |
| 2 | 6 | ||
| 3 | * automated/inotify-test.el: New test. | 7 | * automated/inotify-test.el: New test. |
diff --git a/test/automated/f90.el b/test/automated/f90.el index 25b77f07ad3..7f412568ae3 100644 --- a/test/automated/f90.el +++ b/test/automated/f90.el | |||
| @@ -154,5 +154,23 @@ end module modname") | |||
| 154 | (f90-indent-line) | 154 | (f90-indent-line) |
| 155 | (should (= 0 (current-indentation))))) | 155 | (should (= 0 (current-indentation))))) |
| 156 | 156 | ||
| 157 | (ert-deftest f90-test-bug13138 () | ||
| 158 | "Test for http://debbugs.gnu.org/13138 ." | ||
| 159 | (with-temp-buffer | ||
| 160 | (f90-mode) | ||
| 161 | (insert "program prog | ||
| 162 | integer :: i = & | ||
| 163 | #ifdef foo | ||
| 164 | & 1 | ||
| 165 | #else | ||
| 166 | & 2 | ||
| 167 | #endif | ||
| 168 | |||
| 169 | write(*,*) i | ||
| 170 | end program prog") | ||
| 171 | (goto-char (point-min)) | ||
| 172 | (forward-line 2) | ||
| 173 | (f90-indent-subprogram) | ||
| 174 | (should (= 0 (current-indentation))))) | ||
| 157 | 175 | ||
| 158 | ;;; f90.el ends here | 176 | ;;; f90.el ends here |