bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9553: 24.0.50; Suboptimal comment filling in f90-mode


From: Lawrence Mitchell
Subject: bug#9553: 24.0.50; Suboptimal comment filling in f90-mode
Date: Mon, 19 Sep 2011 17:37:30 +0100

If auto-fill-mode is on, when typing comments in an f90-mode
buffer successive lines receive more and more whitespace indent
after the comment prefix:

emacs -Q
C-x h C-w
M-x f90-mode RET
M-x auto-fill-mode RET

M-: (progn (insert "!!!") (dotimes (i 20) (insert " aaaa"))) RET

SPC

Results in:

!!! aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa
!!!  aaaa aaaa aaaa aaaa aaaa aaaa aaaa
    ^
  Note extra space here

Second issue.  f90-find-breakpoint doesn't do the correct thing
in comments.  It searches backwards for f90-break-delimiters
(defaulting to [-+\\*/><=,% \t]).  If one of these characters
happens to be at the appropriate point at the end of a line, it
is broken onto the next line.  This can leave (for example) a
comma detached from the preceeding word on its own.  In comments
this reads badly.

emacs -Q
C-x h C-w
M-x f90-mode RET
M-x auto-fill-mode RET

M-: (progn (insert "!!!") (dotimes (i 13) (insert " aaaa")) (insert "a, aaaa")) 
RET

SPC

Results in:

!!! aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaaa
!!! , aaaa
    ^
  Hanging comma

ChangeLog entry:

* progmodes/f90.el (f90-find-breakpoint): Only break at
whitespace inside a comment.
(f90-break-line): If breaking inside comment delete all
whitespace around breakpoint.

Patch for both issues:

diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index cdb5f2a..7d23973 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -2000,7 +2000,7 @@ is non-nil, call `f90-update-line' after inserting the 
continuation marker."
   (cond ((f90-in-string)
          (insert "&\n&"))
         ((f90-in-comment)
-         (delete-horizontal-space 'backwards) ; remove trailing whitespace
+         (delete-horizontal-space) ; remove trailing whitespace
          (insert "\n" (f90-get-present-comment-type)))
         (t (insert "&")
            (or no-update (f90-update-line))
@@ -2012,7 +2012,9 @@ is non-nil, call `f90-update-line' after inserting the 
continuation marker."
 
 (defun f90-find-breakpoint ()
   "From `fill-column', search backward for break-delimiter."
-  (re-search-backward f90-break-delimiters (line-beginning-position))
+  (if (f90-in-comment)
+      (re-search-backward "\\s-" (line-beginning-position))
+    (re-search-backward f90-break-delimiters (line-beginning-position)))
   (if (not f90-break-before-delimiters)
       (forward-char (if (looking-at f90-no-break-re) 2 1))
     (backward-char)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]