refactor(fortran): conform to conventions

This commit is contained in:
Henrik Lissner 2022-01-11 01:27:06 +01:00
parent 9cba28621f
commit 3a3a8dc240
2 changed files with 18 additions and 17 deletions

View file

@ -1,13 +1,25 @@
;;; lang/fortran/autoload.el -*- lexical-binding: t; -*-
;; --- GFORTRAN --- ;;
;;
;;; GFortran
(defun +fortran--std ()
"Which version of Fortran should we target?"
(pcase major-mode
(`fortran-mode "-std=legacy")
(_ "")))
;;;###autoload
(defun +fortran-compilation-buffer-name-fn (mode)
"The name of the buffer produced by `compile'."
"*fortran-compilation*")
;;;###autoload
(defun +fortran/gfortran-compile ()
"Compile the current buffer using gfortran."
(interactive)
(compile (format "gfortran %s %s"
(+fortran/fortran-std)
(+fortran--std)
buffer-file-name)))
;;;###autoload
@ -20,13 +32,9 @@
(sleep-for 1))
(compile "./a.out"))
(defun +fortran/fortran-std ()
"Which version of Fortran should we target?"
(cl-case major-mode
(fortran-mode "-std=legacy")
(t "")))
;; --- FPM --- ;;
;;
;;; FPM
;;;###autoload
(defun +fortran/fpm-build ()
@ -45,10 +53,3 @@
"Test the current project using fpm."
(interactive)
(compile "fpm test"))
;; --- MISC. --- ;;
;;;###autoload
(defun +fortran/compilation-buffer-name (mode)
"The name of the buffer produced by `compile'."
(interactive)
"*fortran-compilation*")

View file

@ -10,7 +10,7 @@
;; Used by `compile' (SPC c c)
(setq-hook! 'f90-mode-hook
compile-command "gfortran "
compilation-buffer-name-function #'+fortran/compilation-buffer-name)
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn)
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
;; --- LSP Configuration --- ;;
@ -41,7 +41,7 @@
;; Used by `compile' (SPC c c)
(setq-hook! 'fortran-mode-hook ; TODO These work for f90 but not for fortran.
compile-command "gfortran -std=legacy "
compilation-buffer-name-function #'+fortran/compilation-buffer-name)
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn)
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
;; --- LSP --- ;;