From 0115885ae590135aee236839401b3a981772dae0 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 6 Jan 2020 20:09:13 -0800 Subject: [PATCH] Automatically load scheme-mode for scsh files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the interpreter contains scsh, load ‘scheme-mode’. --- oni-scheme.el | 3 ++- test/oni-scheme.bats | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/oni-scheme.bats diff --git a/oni-scheme.el b/oni-scheme.el index 817bab9..a53934f 100644 --- a/oni-scheme.el +++ b/oni-scheme.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2019.1210.231332 +;; Version: 2020.0106.200514 ;; Package-Requires: (oni-company oni-paredit oni-fci rainbow-delimiters) ;; This program is free software; you can redistribute it and/or modify @@ -37,6 +37,7 @@ (add-hook 'scheme-mode-hook 'rainbow-delimiters-mode) (add-hook 'scheme-mode-hook 'oni-scheme--auto-fill-mode) +;;;###autoload (add-to-list 'interpreter-mode-alist '("scsh" . scheme-mode)) ;;;###autoload(with-eval-after-load 'scheme (require 'oni-scheme)) diff --git a/test/oni-scheme.bats b/test/oni-scheme.bats new file mode 100644 index 0000000..acfa53d --- /dev/null +++ b/test/oni-scheme.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bats + +@test "Opening a scheme file loads oni-scheme" { + run emacs -batch -l package -f package-initialize \ + -visit test.scm \ + -eval "(prin1 (featurep 'oni-scheme))" + + [ "$output" = "t" ] +} + +@test "Opening a file with the SCSH interpreter loads scheme-mode" { + filename="$(mktemp)" + + echo "#!/usr/bin/scsh -s" > "$filename" + + run emacs -batch -l package -f package-initialize \ + -visit "$filename" \ + -eval "(prin1 major-mode)" + + rm "$filename" + + [ "$output" = "scheme-mode" ] +}