aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-04-07 21:40:06 -0700
committerGravatar Tom Willemse2020-04-07 21:40:06 -0700
commita8b95ba858abd996e8cea29a952a75c152d8802c (patch)
tree5f30013ec0d816b4da23a3cd52d04905a7116d8b
parent23a23d3c1b85b0ae5334e4571aad2648e6fdb0b5 (diff)
downloademacs-config-a8b95ba858abd996e8cea29a952a75c152d8802c.tar.gz
emacs-config-a8b95ba858abd996e8cea29a952a75c152d8802c.zip
Disable ‘shfmt-on-save-mode’ for ‘bats-mode’ buffers
-rw-r--r--oni-bats.el9
-rw-r--r--test/oni-bats-test.el8
2 files changed, 16 insertions, 1 deletions
diff --git a/oni-bats.el b/oni-bats.el
index f9d69d5..c4b49c1 100644
--- a/oni-bats.el
+++ b/oni-bats.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2020.0108.154614
+;; Version: 2020.0407.213908
;; Package-Requires: (bats-mode oni-sh)
;; This program is free software; you can redistribute it and/or modify
@@ -30,6 +30,13 @@
;;; Code:
(require 'autoinsert)
+(require 'oni-sh)
+
+(defun oni-bats-disable-shfmt-on-save-mode ()
+ "Disable ‘shfmt-on-save-mode’."
+ (shfmt-on-save-mode -1))
+
+(add-hook 'bats-mode-hook #'oni-bats-disable-shfmt-on-save-mode)
;;;###autoload
(with-eval-after-load 'autoinsert
diff --git a/test/oni-bats-test.el b/test/oni-bats-test.el
index 7414dc4..3e32460 100644
--- a/test/oni-bats-test.el
+++ b/test/oni-bats-test.el
@@ -1,3 +1,5 @@
+(require 'oni-bats)
+
(ert-deftest oni-bats-test-auto-insert ()
"Test that ‘auto-insert’ inserts the proper interpreter."
(with-temp-buffer
@@ -5,3 +7,9 @@
(let ((auto-insert-query nil))
(auto-insert))
(should (string= "#!/usr/bin/env bats\n\n" (buffer-string)))))
+
+(ert-deftest oni-bats-has-shfmt-on-save-mode-disabled ()
+ "Test that ‘shfmt-on-save-mode’ is disabled in a ‘bats-mode’ buffer."
+ (with-temp-buffer
+ (bats-mode)
+ (should-not shfmt-on-save-mode)))