1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +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
(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)