Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added inferior-julia comint mode #10389

Merged
merged 8 commits into from
Mar 9, 2015
57 changes: 57 additions & 0 deletions contrib/julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -3095,6 +3095,63 @@ end"))
(puthash "\\mtteight" "𝟾" julia-latexsubs)
(puthash "\\mttnine" "𝟿" julia-latexsubs)

;; Code for `inferior-julia-mode'
(require 'comint)

(defgroup julia
'()
"Julia Programming Language."
:group 'languages
:prefix "julia-")

(defcustom julia-program "julia"
"Path to the program used by `inferior-julia'."
:type 'string
:group 'julia)

(defcustom julia-arguments '()
"Commandline arguments to pass to `julia-program'."
:type 'string
:group 'julia)

(defvar julia-prompt-regexp "julia>"
"Regexp for matching `inferior-julia' prompt.")

(defvar inferior-julia-mode-map
(let ((map (nconc (make-sparse-keymap) comint-mode-map)))
;; example definition
(define-key map (kbd "TAB") 'julia-latexsub-or-indent)
map)
"Basic mode map for `inferior-julia-mode'.")

;;;###autoload
(defun inferior-julia ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding an ;;;###autoload cookie here.

"Run an inferior instance of `julia' inside Emacs."
(interactive)
(let ((julia-program julia-program)
(buffer (get-buffer-create "*Julia*")))
(when (not (comint-check-proc "*Julia*"))
(apply #'make-comint-in-buffer "Julia" "*Julia*" julia-program julia-arguments))
(pop-to-buffer-same-window "*Julia*")
(inferior-julia-mode)))

(defun inferior-julia--initialize ()
"Helper function to initialize `inferior-julia'."
(setq comint-use-prompt-regexp t))

(define-derived-mode inferior-julia-mode comint-mode "Julia"
"Major mode for `inferior-julia'.

\\<inferior-julia-mode-map>"
nil "Julia"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Emacs convention is to generally name interactive buffers with asterisks, so I'd use *Julia* here.

(setq comint-prompt-regexp julia-prompt-regexp)
(setq comint-prompt-read-only t)
(set (make-local-variable 'font-lock-defaults) '(julia-font-lock-keywords t))
(set (make-local-variable 'paragraph-start) julia-prompt-regexp)
(set (make-local-variable 'indent-line-function) 'julia-indent-line))

(add-hook 'inferior-julia-mode-hook 'inferior-julia--initialize)

(provide 'julia-mode)

;; Local Variables:
Expand Down