Skip to content

Commit

Permalink
Add Version number to the emacs mode (#1320)
Browse files Browse the repository at this point in the history
Add Juvix-version call to juvix-mode, and fixedup ending )'s
  • Loading branch information
mariari authored Jul 13, 2022
1 parent 8f216a5 commit ea767ef
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions juvix-mode/juvix-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

0 comments on commit ea767ef

Please sign in to comment.