Created
May 17, 2017 19:42
-
-
Save aradi/68a4ff8430a735de13f13393213f0ea8 to your computer and use it in GitHub Desktop.
Emacs Fortran settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; Add this settings to your ~/.emacs file | |
;; | |
;; Fortran settings | |
(setq fortran-continuation-string "&") | |
(setq fortran-do-indent 2) | |
(setq fortran-if-indent 2) | |
(setq fortran-structure-indent 2) | |
;; Fortran 90 settings | |
(setq f90-do-indent 2) | |
(setq f90-if-indent 2) | |
(setq f90-type-indent 2) | |
(setq f90-program-indent 2) | |
(setq f90-continuation-indent 4) | |
(setq f90-smart-end 'blink) | |
;; Set Fortran and Fortran 90 mode for appropriate extensions | |
(setq auto-mode-alist | |
(cons '("\\.F90$" . f90-mode) auto-mode-alist)) | |
(setq auto-mode-alist | |
(cons '("\\.pf$" . f90-mode) auto-mode-alist)) | |
(setq auto-mode-alist | |
(cons '("\\.fpp$" . f90-mode) auto-mode-alist)) | |
(setq auto-mode-alist | |
(cons '("\\.F$" . fortran-mode) auto-mode-alist)) | |
;; Swap Return and C-j in Fortran 90 mode | |
(add-hook 'f90-mode-hook | |
'(lambda () | |
(define-key f90-mode-map [return] 'f90-indent-new-line) | |
(define-key f90-mode-map "\C-j" 'newline) | |
(setq fill-column 100) | |
(abbrev-mode) | |
(setq-default indent-tabs-mode nil) | |
(setq whitespace-line-column 100) | |
(setq whitespace-style '(face tabs lines-tail empty)) | |
(whitespace-mode) | |
;; (add-to-list 'write-file-functions 'delete-trailing-whitespace) | |
) | |
) | |
;; Read in handy abbreviations for Fortran | |
(quietly-read-abbrev-file "~/.emacs_abbrevs") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; Store this file as ~/.emacs_abbrevs | |
;; | |
(define-abbrev-table 'f90-mode-abbrev-table '( | |
("im$" "implicit none" nil 0) | |
("po$" "pointer" nil 1) | |
("wr$" "write" nil 0) | |
("pm$" "program" nil 0) | |
("al$" "allocate" nil 0) | |
("bd$" "block data" nil 0) | |
("if$" "interface" nil 0) | |
("pv$" "private" nil 0) | |
("op$" "optional" nil 0) | |
("ba$" "backspace" nil 0) | |
("nu$" "nullify" nil 0) | |
("wh$" "where" nil 0) | |
("pa$" "parameter" nil 0) | |
("elw$" "elsewhere" nil 0) | |
("ab$" "allocatable" nil 0) | |
("fu$" "function" nil 0) | |
("ey$" "entry" nil 0) | |
("ex$" "external" nil 0) | |
("fo$" "format" nil 0) | |
("fl$" "forall" nil 0) | |
("mo$" "module" nil 1) | |
("tr$" ".true." nil 0) | |
("eq$" "equivalence" nil 0) | |
("eli$" "else if" nil 0) | |
("dw$" "do while" nil 0) | |
("sub$" "subroutine" nil 0) | |
("na$" "namelist" nil 0) | |
("el$" "else" nil 0) | |
("lo$" "logical" nil 0) | |
("sq$" "sequence" nil 0) | |
("cy$" "cycle" nil 0) | |
("fa$" ".false." nil 0) | |
("rw$" "rewind" nil 0) | |
("cx$" "complex" nil 0) | |
("rt$" "return" nil 0) | |
("t$" "type" nil 0) | |
("ta$" "target" nil 0) | |
("r$" "real" nil 0) | |
("di$" "dimension" nil 0) | |
("se$" "select" nil 0) | |
("cn$" "contains" nil 0) | |
("df$" "define" nil 0) | |
("cm$" "common" nil 0) | |
("de$" "deallocate" nil 0) | |
("cl$" "close" nil 0) | |
("i$" "integer" nil 0) | |
("in$" "intent" nil 0) | |
("ini$" "intent(in)" nil 0) | |
("ino$" "intent(out)" nil 0) | |
("inio$" "intent(inout)" nil 0) | |
("pu$" "public" nil 0) | |
("rc$" "recursive" nil 0) | |
("pr$" "print" nil 0) | |
("c$" "character" nil 0) | |
("as$" "assignment" nil 0) | |
("mp$" "module procedure" nil 0) | |
("ps$" "present" nil 0) | |
("wrs$" "write(*,*)" nil 0) | |
("prs$" "print *," nil 0) | |
("rwp$" "real(wp)" nil 0) | |
("cdp$" "complex(dp)" nil 0) | |
("pn$" "=> null()" nil 0) | |
("p$" "procedure" nil 0) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment