Skip to main content

EMACS

Goal

Integrate codee format with EMACS to format Fortran code.

Prerequisites​

You should have a init.el file on your .emacs or .emacs.d directory. Make sure codee is accesable from EMACS shell. You can add the codee path to your configuration file.

Configure EMACS for codee format​

Add the following configuration to your .init.el configuration file:

(defun codee-format-buffer ()
"Format Fortran code of current buffer using codee format.
Buffer is saved first."
(interactive)
(let ((fPath (buffer-file-name)))
(save-buffer)
(shell-command
(format "codee format %s" (shell-quote-argument fPath)))
(revert-buffer t t t)))

(add-hook 'before-save-hook 'codee-format-buffer)

This file will be autodetected by EMACS and will apply the Codee format changes each time you save a file using the before-save-hook option.