[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
f90-mode - auto-fill and font-lock
From: |
Glenn Morris |
Subject: |
f90-mode - auto-fill and font-lock |
Date: |
03 Dec 2001 23:19:33 +0000 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 on i686-pc-linux-gnu |
Hi,
Three issues (and two possible solutions) with f90.el as supplied with
Emacs 21.1.
(1) The e-mail address specified in the variable `bug-f90-mode' appears to
be invalid.
(2) There is a bug in f90-mode's handling of auto-fill.
This was reported in this newsgroup in May 2000 but still exists. I guess
if Fortran was as sexy as C this wouldn't be the case, sigh. ;)
To reproduce it:
emacs -q --no-site-file
M-x f90-mode
M-x auto-fill-mode
Now type a long line, such that one is in the middle of a string (ie inside
'' quotes) when passing fill-column. One gets rows and rows of `&' inserted
until '(Variable binding depth exceeds max-specpdl-size)' puts an end to
it. It works OK if one is not inside a string. The problem is that the
function `f90-break-line' uses (newline) to insert a newline. But plain
(newline) without a numeric argument auto-fills the line if necessary, so
one gets into an infinite loop of filling. It does not happen when filling
on a non-string, because then the function `f90-find-breakpoint' is called
first to move point to a suitable position to break the line, which usually
carries it safely to the left of fill-column.
(3) A minor issue with font-locking. `module procedure' and all members of
the variable `f90-procedures-re' are font-locked inside comments. So for
example in this comment:
!!! Must use a big range (say 10000 or so) for this array.
the "range" gets fontified as if it were the intrinsic function called
range.
A very simple patch that seems to fix (2) and (3) is attached. Not sure if
the solution to the "module procedure" thing is any good.
Not much I can do about (1) I'm afraid! :)
Regards,
Glenn
PS. Blatant ingratiation - can I just take a moment to say that I *love*
Emacs 21! Thanks for all the hard work!
--- Patch for f90.el follows this line ---
--- f90.el.ORIG Sat Dec 1 19:14:16 2001
+++ f90.el Sat Dec 1 19:15:55 2001
@@ -372,7 +372,8 @@
'("\\<\\(program\\|call\\|module\\|subroutine\\|function\\|use\\)\\>[
\t]*\\(\\sw+\\)?"
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
;; Special highlighting of "module procedure foo-list"
- '("\\<\\(module[ \t]*procedure\\)\\>" (1 font-lock-keyword-face t))
+ '("\\<\\(module[ \t]*procedure\\)\\>"
+ (1 (if (f90-in-comment) font-lock-comment-face font-lock-keyword-face)
t))
;; Highlight definition of new type
'("\\<\\(type\\)[ \t]*\\(.*::[ \t]*\\|[ \t]+\\)\\(\\sw+\\)"
(1 font-lock-keyword-face) (3 font-lock-function-name-face))
@@ -409,7 +410,7 @@
(list
f90-keywords-level-3-re
f90-operators-re
- (list f90-procedures-re '(1 font-lock-keyword-face t))
+ (list f90-procedures-re '(1 font-lock-keyword-face keep))
"\\<real\\>" ; Avoid overwriting real defs.
))
"Highlights all F90 keywords and intrinsic procedures.")
@@ -1472,14 +1473,14 @@
(interactive)
(let (ctype)
(cond ((f90-in-string)
- (insert "&") (newline) (insert "&"))
+ (insert "&") (newline 1) (insert "&"))
((f90-in-comment)
(setq ctype (f90-get-present-comment-type))
- (newline)
+ (newline 1)
(insert ctype))
(t (insert "&")
(if (not no-update) (f90-update-line))
- (newline)
+ (newline 1)
(if f90-beginning-ampersand (insert "&")))))
(f90-indent-line))
- f90-mode - auto-fill and font-lock,
Glenn Morris <=
Re: f90-mode - auto-fill and font-lock, Dave Love, 2001/12/07