From 66d7d1beeffe65cab019c779894c5b2e64c57de7 Mon Sep 17 00:00:00 2001 From: Paul Cadman Date: Tue, 5 Jul 2022 17:55:19 +0100 Subject: [PATCH] Add emacs option `minijuvix-disable-embedded-stdlib` (#247) When developing the stdlib or any other project that doesn't use the embedded standard library, the `--no-stdlib` flag must be set on the compiler commands. This PR adds a config option `minijuvix-disable-embedded-stdlib` to set `--no-stdlib` for highlight and flycheck. --- minijuvix-mode/flycheck-minijuvix.el | 4 +++- minijuvix-mode/minijuvix-customize.el | 12 ++++++++++++ minijuvix-mode/minijuvix-mode.el | 8 ++------ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 minijuvix-mode/minijuvix-customize.el diff --git a/minijuvix-mode/flycheck-minijuvix.el b/minijuvix-mode/flycheck-minijuvix.el index de74c6afd..3158ea0a5 100644 --- a/minijuvix-mode/flycheck-minijuvix.el +++ b/minijuvix-mode/flycheck-minijuvix.el @@ -1,4 +1,5 @@ (require 'flycheck) +(require 'minijuvix-customize) (defgroup flycheck-minijuvix nil "MiniJuvix support for Flycheck." @@ -9,7 +10,8 @@ (flycheck-define-checker minijuvix "A MiniJuvix syntax checker." :command ("minijuvix" "microjuvix" "typecheck" "--only-errors" "--no-colors" - source-original) + (option-flag "--no-stdlib" minijuvix-disable-embedded-stdlib) + source-original) :error-patterns ( (error line-start (file-name) ":" line ":" column ": error:" (message (one-or-more (not "ת")))) diff --git a/minijuvix-mode/minijuvix-customize.el b/minijuvix-mode/minijuvix-customize.el new file mode 100644 index 000000000..c81e4019f --- /dev/null +++ b/minijuvix-mode/minijuvix-customize.el @@ -0,0 +1,12 @@ + +(defcustom minijuvix-auto-input-method t + "Automatically set the input method in minijuvix files." + :type 'boolean + :group 'minijuvix) + +(defcustom minijuvix-disable-embedded-stdlib nil + "Disable the embedded standard library." + :type 'boolean + :group 'minijuvix) + +(provide 'minijuvix-customize) diff --git a/minijuvix-mode/minijuvix-mode.el b/minijuvix-mode/minijuvix-mode.el index 0e129122c..42c568337 100644 --- a/minijuvix-mode/minijuvix-mode.el +++ b/minijuvix-mode/minijuvix-mode.el @@ -1,3 +1,4 @@ +(require 'minijuvix-customize) (require 'minijuvix-highlight) (require 'minijuvix-input) (require 'flycheck-minijuvix) @@ -17,11 +18,6 @@ ;;;###autoload (add-to-list 'auto-mode-alist '("\\.m?juvix\\'" . minijuvix-mode)) -(defcustom minijuvix-auto-input-method t - "Automatically set the input method in minijuvix files." - :type 'boolean - :group 'minijuvix) - (define-derived-mode minijuvix-mode prog-mode "MiniJuvix" (font-lock-mode 0) @@ -52,7 +48,7 @@ (interactive) (save-buffer) (minijuvix-clear-annotations) - (eval (read (shell-command-to-string (concat "minijuvix highlight " (buffer-file-name))))) + (eval (read (shell-command-to-string (concat "minijuvix highlight " (if minijuvix-disable-embedded-stdlib "--no-stdlib " "") (buffer-file-name))))) (save-buffer) )