From 54246aa75867d72648effd9cbb8d8b41a4d448e4 Mon Sep 17 00:00:00 2001 From: Troels Henriksen Date: Thu, 3 Oct 2024 20:21:52 +0200 Subject: [PATCH] Experimental "futhark fmt" integration. --- futhark-fmt.el | 45 +++++++++++++++++++++++++++++++++++++++++++++ futhark-mode.el | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 futhark-fmt.el diff --git a/futhark-fmt.el b/futhark-fmt.el new file mode 100644 index 0000000..2573747 --- /dev/null +++ b/futhark-fmt.el @@ -0,0 +1,45 @@ +;;; futhark-fmt.el --- Format SML source code using the "futhark fmt" program -*- lexical-binding: t -*- + +;; Copyright (C) DIKU 2013-2019, University of Copenhagen + +;; This file is not part of GNU Emacs. + +;;; License: +;; ICS + +;;; Commentary: +;; See futhark-mode.el. + +;;; Code: + +(require 'reformatter) + +(defgroup futhark-fmt nil + "Integration with the \"futhark fmt\" formatting program." + :prefix "futhark-fmt-" + :group 'sml) + +(defcustom futhark-fmt-extra-args '() + "Extra arguments to give to \"futhark fmt\"." + :group 'futhark-fmt + :type 'sexp + :safe #'listp) + +(defvar futhark-fmt-mode-map (make-sparse-keymap) + "Local keymap used for `futhark-fmt-format-on-save-mode`.") + +;;;###autoload (autoload 'futhark-fmt-format-buffer "futhark-fmt" nil t) +;;;###autoload (autoload 'futhark-fmt-format-region "futhark-fmt" nil t) +;;;###autoload (autoload 'futhark-fmt-format-on-save-mode "futhark-fmt" nil t) +(reformatter-define futhark-fmt + :program "futhark" + :args (cons "fmt" futhark-fmt-extra-args) + :group 'futhark-fmt + :lighter " Fmt" + :keymap futhark-fmt-mode-map) + +(defalias 'futhark-fmt 'futhark-fmt-format-buffer) + +(provide 'futhark-fmt) + +;;; futhark-fmt.el ends here diff --git a/futhark-mode.el b/futhark-mode.el index 1b28e37..14eb0f5 100644 --- a/futhark-mode.el +++ b/futhark-mode.el @@ -5,7 +5,7 @@ ;; URL: https://github.com/diku-dk/futhark-mode ;; Keywords: languages ;; Version: 0.2 -;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) +;; Package-Requires: ((emacs "24.3") (cl-lib "0.5") (reformatter "0.4")) ;; This file is not part of GNU Emacs.