From 3a01faed49f12c491d9bf499f0532e9660caafc6 Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Fri, 8 Sep 2023 15:33:05 +0900 Subject: [PATCH] feat(fortran): `SPC m f o` opens project config --- modules/lang/fortran/autoload.el | 12 +++++++++++- modules/lang/fortran/config.el | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/lang/fortran/autoload.el b/modules/lang/fortran/autoload.el index 8bf4443a6..f3d4d4488 100644 --- a/modules/lang/fortran/autoload.el +++ b/modules/lang/fortran/autoload.el @@ -63,7 +63,7 @@ or gfortran, depending on what feature flags are set." (_ ""))) ;;;###autoload -(defun +fortran-compilation-buffer-name-fn (mode) +(defun +fortran-compilation-buffer-name-fn (_mode) "The name of the buffer produced by `compile'." "*fortran-compilation*") @@ -115,3 +115,13 @@ or gfortran, depending on what feature flags are set." "Test the current project using fpm." (interactive) (compile "fpm test")) + +;;;###autoload +(defun +fortran/fpm-open-project-toml (project-root) + "Open fpm.toml at PROJECT-ROOT (defaults to the open project)." + (interactive (list (doom-project-root))) + (let ((file (file-name-concat project-root "fpm.toml"))) + (cond ((file-exists-p file) (find-file file)) + ((null project-root) (user-error "Not in a project")) + (t (user-error "No fpm.toml found at project root (%s)" + (abbreviate-file-name project-root)))))) diff --git a/modules/lang/fortran/config.el b/modules/lang/fortran/config.el index 310ee4b10..906808e5e 100644 --- a/modules/lang/fortran/config.el +++ b/modules/lang/fortran/config.el @@ -27,7 +27,8 @@ (:prefix ("f" . "fpm") :desc "fpm build" "b" #'+fortran/fpm-build :desc "fpm run" "r" #'+fortran/fpm-run - :desc "fpm test" "t" #'+fortran/fpm-test) + :desc "fpm test" "t" #'+fortran/fpm-test + :desc "Open project config" "o" #'+fortran/fpm-open-project-toml) (:prefix ("g" . "gfortran") :desc "compile" "c" #'+fortran/gfortran-compile :desc "run" "r" #'+fortran/gfortran-run)