1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-07 16:22:14 +03:00

Add Version number to the emacs mode (#1320)

Add Juvix-version call to juvix-mode, and fixedup ending )'s
This commit is contained in:
mariari 2022-07-13 21:49:06 +08:00 committed by GitHub
parent 8f216a590f
commit ea767ef2b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,12 +18,18 @@
;;;###autoload ;;;###autoload
(add-to-list 'auto-mode-alist '("\\.juvix\\'" . juvix-mode)) (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) (font-lock-mode 0)
(when juvix-auto-input-method (when juvix-auto-input-method
(set-input-method "juvix") (set-input-method "juvix"))
)
(setq-local comment-start "--") (setq-local comment-start "--")
(add-hook (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 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 "SPC m g") 'juvix-goto-definition)
(evil-define-key 'normal juvix-mode-map (kbd "g d") '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 () (defun juvix-clear-annotations ()
"Remove all annotations from the current buffer." "Remove all annotations from the current buffer."
(interactive) (interactive)
(remove-list-of-text-properties (point-min) (point-max) (remove-list-of-text-properties (point-min) (point-max) '(face)))
'(face))
)
(defun juvix-load () (defun juvix-load ()
"Load current buffer." "Load current buffer."
(interactive) (interactive)
(save-buffer) (save-buffer)
(juvix-clear-annotations) (juvix-clear-annotations)
(eval (read (shell-command-to-string (concat "juvix internal highlight " (if juvix-disable-embedded-stdlib "--no-stdlib " "") (buffer-file-name))))) (eval (read (shell-command-to-string
(save-buffer) (concat "juvix internal highlight "
) (if juvix-disable-embedded-stdlib "--no-stdlib " "")
(buffer-file-name)))))
(save-buffer))
(defun juvix-goto-definition () (defun juvix-goto-definition ()
"Go to the definition of the symbol at point." "Go to the definition of the symbol at point."
(interactive) (interactive)
(let ((goto-info (get-text-property (point) 'juvix-goto))) (let ((goto-info (get-text-property (point) 'juvix-goto)))
(if goto-info (if goto-info
(progn (progn
(find-file (car goto-info)) (find-file (car goto-info))
(juvix-load) (juvix-load)
(goto-char (cdr goto-info))) (goto-char (cdr goto-info)))
(message "No goto information found at cursor")))) (message "No goto information found at cursor"))))
(provide 'juvix-mode) (provide 'juvix-mode)