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.
This commit is contained in:
parent
8c21bef6d1
commit
a0099d31a6
4 changed files with 47 additions and 14 deletions
|
@ -1,3 +1,9 @@
|
|||
2012-12-11 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* progmodes/f90.el (f90-line-continued, f90-indent-region):
|
||||
Treat preprocessor lines embedded in continuations like comments.
|
||||
(f90-indent-line): Special-case preprocessor lines. (Bug#13138)
|
||||
|
||||
2012-12-11 Jay Belanger <jay.p.belanger@gmail.com>
|
||||
|
||||
* calc/calc.el (calc-standard-date-formats): Add more date
|
||||
|
|
|
@ -1178,11 +1178,11 @@ and lies before point."
|
|||
|
||||
(defsubst f90-line-continued ()
|
||||
"Return t if the current line is a continued one.
|
||||
This includes comment lines embedded in continued lines, but
|
||||
not the last line of a continued statement."
|
||||
This includes comment or preprocessor lines embedded in continued lines,
|
||||
but not the last line of a continued statement."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(while (and (looking-at "[ \t]*\\(!\\|$\\)") (zerop (forward-line -1))))
|
||||
(while (and (looking-at "[ \t]*\\([!#]\\|$\\)") (zerop (forward-line -1))))
|
||||
(end-of-line)
|
||||
(while (f90-in-comment)
|
||||
(search-backward "!" (line-beginning-position))
|
||||
|
@ -1832,11 +1832,15 @@ after indenting."
|
|||
(f90-indent-line-no)
|
||||
(setq no-line-number t)
|
||||
(skip-chars-forward " \t"))
|
||||
(if (looking-at "!")
|
||||
(setq indent (f90-comment-indent))
|
||||
(and f90-smart-end (looking-at "end")
|
||||
(f90-match-end))
|
||||
(setq indent (f90-calculate-indent)))
|
||||
;; FIXME This means f90-calculate-indent gives different answers
|
||||
;; for comments and preprocessor lines to this function.
|
||||
;; Better to make f90-calculate-indent return the correct answer?
|
||||
(cond ((looking-at "!") (setq indent (f90-comment-indent)))
|
||||
((looking-at "#") (setq indent 0))
|
||||
(t
|
||||
(and f90-smart-end (looking-at "end")
|
||||
(f90-match-end))
|
||||
(setq indent (f90-calculate-indent))))
|
||||
(or (= indent (current-column))
|
||||
(f90-indent-to indent no-line-number))
|
||||
;; 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."
|
|||
(f90-indent-to ind-curr))
|
||||
(while (and (f90-line-continued) (zerop (forward-line 1))
|
||||
(< (point) end-region-mark))
|
||||
(if (looking-at "[ \t]*!")
|
||||
(f90-indent-to (f90-comment-indent))
|
||||
(or (= (current-indentation)
|
||||
(+ ind-curr f90-continuation-indent))
|
||||
(f90-indent-to
|
||||
(+ ind-curr f90-continuation-indent) 'no-line-no)))))
|
||||
(cond ((looking-at "[ \t]*#") (f90-indent-to 0))
|
||||
((looking-at "[ \t]*!") (f90-indent-to (f90-comment-indent)))
|
||||
(t
|
||||
(or (= (current-indentation)
|
||||
(+ ind-curr f90-continuation-indent))
|
||||
(f90-indent-to
|
||||
(+ ind-curr f90-continuation-indent) 'no-line-no))))))
|
||||
;; Restore point, etc.
|
||||
(setq f90-cache-position nil)
|
||||
(goto-char save-point)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2012-12-11 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* automated/f90.el (f90-test-bug13138): New test.
|
||||
|
||||
2012-12-10 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
|
||||
|
||||
* automated/inotify-test.el: New test.
|
||||
|
|
|
@ -154,5 +154,23 @@ end module modname")
|
|||
(f90-indent-line)
|
||||
(should (= 0 (current-indentation)))))
|
||||
|
||||
(ert-deftest f90-test-bug13138 ()
|
||||
"Test for http://debbugs.gnu.org/13138 ."
|
||||
(with-temp-buffer
|
||||
(f90-mode)
|
||||
(insert "program prog
|
||||
integer :: i = &
|
||||
#ifdef foo
|
||||
& 1
|
||||
#else
|
||||
& 2
|
||||
#endif
|
||||
|
||||
write(*,*) i
|
||||
end program prog")
|
||||
(goto-char (point-min))
|
||||
(forward-line 2)
|
||||
(f90-indent-subprogram)
|
||||
(should (= 0 (current-indentation)))))
|
||||
|
||||
;;; f90.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue