From a8b95ba858abd996e8cea29a952a75c152d8802c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 7 Apr 2020 21:40:06 -0700 Subject: Disable ‘shfmt-on-save-mode’ for ‘bats-mode’ buffers --- oni-bats.el | 9 ++++++++- test/oni-bats-test.el | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 ;; 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))) -- cgit v1.2.3-54-g00ecf