>>>>> "Gerard" == Gerard Parlant <[log in to unmask]> writes:
Gerard> Bonjour! The f90 mode of emacs does not seem to properly indent
Gerard> the right-margin comments:
Gerard> indent-for-comment (M-;) starts a new comment (!) in
Gerard> comment-column as it should ^^^ but it does not tabulate an
Gerard> already existing comment to comment-column ^^^^^^^^
Gerard> same behaviour with f90-indent-line (TAB) which fails to shift the
Gerard> comment when it does not start in comment-column
If you read f90.el, there are several ways to choose indentation. Since most
of my comments are indented to the same level as code, I choose to use "!" for
code-level indentation. This can cause problems when there is an inline-style
comment with no code before it. So I use '!!', '!#' or '!*' for inline
comments. You can do this by putting
;;
;; set up style of indenting comments
;; "!" = code-indented comments,
;; "!!", "!#" or "!*" = inline comments,
(setq f90-indented-comment-re "![^!#*]")
into your f90-mode-hook. I enclose other settings I use as a guide -- don't
use them verbatim unless you understand what they are doing.
Alternatively, you could decide to use '!!' for code-level indenting, '!!!'
for no indenting, and '!' for inline comments. This also has advantages, and
is described in f90.el (look in
/usr/local/share/emacs/<version_number>/lisp/f90.el on most unix
installations).
;;
;; set personalizations for F90 mode
;;
(defun my-f90-mode-extras ()
(setq comment-column 40) ; inline comments at column 40
(setq abbrev-mode t) ; turn on abbreviation mode
(setq fill-column 78) ; at which column to split
; lines
;;
;; set up style of indenting comments
;; "!" = code-indented comments,
;; "!!", "!#" or "!*" = inline comments,
(setq f90-indented-comment-re "![^!#*]")
(defun f90-switch-comment-styles ()
"Switches comments from !! to ! + !#"
(interactive)
(beginning-of-buffer)
(query-replace-regexp "\\([^!]!\\)\\([^!D]\\)" "\\1#\\2" nil)
(beginning-of-buffer)
(query-replace-regexp "!!" "!" nil)
)
;;
;; handle multiple kinds of directives. We might have
;; !DEC$, !HPF$, or !????$. These comments are not to be indented.
;;
;; (setq f90-directive-comment-re "![a-z]+\\$")
;; uppercase keywords to distinguish in non-font-lock editors
(setq f90-auto-keyword-case 'upcase-word)
;; We don't want any tabs in f90 files:
(setq indent-tabs-mode nil)
;; Turn on auto-fill (automatic linebreaking)
(auto-fill-mode 1)
;; Turn on maximum font-lock decorations:
(f90-font-lock-4)
;;
;; Easier keymap settings. 'kbd' is a macro defined by default in emacs 20.
;;
(define-key f90-mode-map (kbd "C-<return>") 'f90-indent-new-line)
(define-key f90-mode-map (kbd "M-<return>") 'indent-new-comment-line)
(define-key f90-mode-map (kbd "LFD") 'newline)
(define-key f90-mode-map (kbd "M-LFD") 'f90-break-line)
;; (if f90-auto-keyword-case ; upcase all keywords on startup
;; (f90-change-keywords f90-auto-keyword-case))
;;
;; Add some more abbreviations:
;;
(define-abbrev f90-mode-abbrev-table "`mp" "module procedure" nil)
)
(add-hook 'f90-mode-hook 'my-f90-mode-extras)
--
Tera Computer Company, Merrill Place http://www.tera.com
411 First Avenue South, Suite 600 Direct 206/701-2182, Main 701-2000
Seattle, WA 98104-2860 Fax1 206/701-2205, Fax2 701-2500
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|