[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111184: Fix for indentation of f90 p
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111184: Fix for indentation of f90 preproc lines embedded in continuations |
Date: |
Mon, 10 Dec 2012 20:42:49 -0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111184
fixes bug: http://debbugs.gnu.org/13138
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Mon 2012-12-10 20:42:49 -0800
message:
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.
modified:
lisp/ChangeLog
lisp/progmodes/f90.el
test/ChangeLog
test/automated/f90.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-12-11 02:29:21 +0000
+++ b/lisp/ChangeLog 2012-12-11 04:42:49 +0000
@@ -1,3 +1,9 @@
+2012-12-11 Glenn Morris <address@hidden>
+
+ * 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 <address@hidden>
* calc/calc.el (calc-standard-date-formats): Add more date
=== modified file 'lisp/progmodes/f90.el'
--- a/lisp/progmodes/f90.el 2012-09-17 05:41:04 +0000
+++ b/lisp/progmodes/f90.el 2012-12-11 04:42:49 +0000
@@ -1178,11 +1178,11 @@
(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 @@
(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 @@
(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)
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2012-12-10 11:17:21 +0000
+++ b/test/ChangeLog 2012-12-11 04:42:49 +0000
@@ -1,3 +1,7 @@
+2012-12-11 Glenn Morris <address@hidden>
+
+ * automated/f90.el (f90-test-bug13138): New test.
+
2012-12-10 RĂ¼diger Sonderfeld <address@hidden>
* automated/inotify-test.el: New test.
=== modified file 'test/automated/f90.el'
--- a/test/automated/f90.el 2012-01-05 09:46:05 +0000
+++ b/test/automated/f90.el 2012-12-11 04:42:49 +0000
@@ -154,5 +154,23 @@
(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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111184: Fix for indentation of f90 preproc lines embedded in continuations,
Glenn Morris <=