From ea767ef2b4255cb2180ccf9628307f53fdd05ba0 Mon Sep 17 00:00:00 2001 From: mariari <32526923+mariari@users.noreply.github.com> Date: Wed, 13 Jul 2022 21:49:06 +0800 Subject: [PATCH] Add Version number to the emacs mode (#1320) Add Juvix-version call to juvix-mode, and fixedup ending )'s --- juvix-mode/juvix-mode.el | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/juvix-mode/juvix-mode.el b/juvix-mode/juvix-mode.el index 4149e581b6..b4f0b022ed 100644 --- a/juvix-mode/juvix-mode.el +++ b/juvix-mode/juvix-mode.el @@ -18,12 +18,18 @@ ;;;###autoload (add-to-list 'auto-mode-alist '("\\.juvix\\'" . juvix-mode)) -(define-derived-mode juvix-mode prog-mode "Juvix-v0.2.1" +(defun juvix-version () + (let ((version (car (split-string (shell-command-to-string "juvix --version") + "\n")))) + (if (string-prefix-p "Juvix" version) + version + "Juvix"))) + +(define-derived-mode juvix-mode prog-mode (juvix-version) (font-lock-mode 0) (when juvix-auto-input-method - (set-input-method "juvix") - ) + (set-input-method "juvix")) (setq-local comment-start "--") (add-hook @@ -33,34 +39,33 @@ (evil-define-key 'normal juvix-mode-map (kbd "SPC m l") 'juvix-load) (evil-define-key 'normal juvix-mode-map (kbd "SPC m g") 'juvix-goto-definition) (evil-define-key 'normal juvix-mode-map (kbd "g d") 'juvix-goto-definition) - (evil-normalize-keymaps)))) - ) + (evil-normalize-keymaps))))) (defun juvix-clear-annotations () "Remove all annotations from the current buffer." (interactive) - (remove-list-of-text-properties (point-min) (point-max) - '(face)) - ) + (remove-list-of-text-properties (point-min) (point-max) '(face))) (defun juvix-load () "Load current buffer." (interactive) (save-buffer) (juvix-clear-annotations) - (eval (read (shell-command-to-string (concat "juvix internal highlight " (if juvix-disable-embedded-stdlib "--no-stdlib " "") (buffer-file-name))))) - (save-buffer) - ) + (eval (read (shell-command-to-string + (concat "juvix internal highlight " + (if juvix-disable-embedded-stdlib "--no-stdlib " "") + (buffer-file-name))))) + (save-buffer)) (defun juvix-goto-definition () "Go to the definition of the symbol at point." (interactive) (let ((goto-info (get-text-property (point) 'juvix-goto))) (if goto-info - (progn - (find-file (car goto-info)) - (juvix-load) - (goto-char (cdr goto-info))) + (progn + (find-file (car goto-info)) + (juvix-load) + (goto-char (cdr goto-info))) (message "No goto information found at cursor")))) (provide 'juvix-mode)