diff --git a/modules/lang/fortran/autoload.el b/modules/lang/fortran/autoload.el index 8216c28fc..c0dc09df8 100644 --- a/modules/lang/fortran/autoload.el +++ b/modules/lang/fortran/autoload.el @@ -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*") diff --git a/modules/lang/fortran/config.el b/modules/lang/fortran/config.el index 129f0a17f..3a3c2abfa 100644 --- a/modules/lang/fortran/config.el +++ b/modules/lang/fortran/config.el @@ -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 --- ;;