From f4d80ca8c619a56b301d189646a170f4b6962114 Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Tue, 3 Mar 2015 10:29:27 -0500 Subject: [PATCH 1/8] Added inferior-julia comint mode --- contrib/julia-mode.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index d3d5a2a3882af..9637d030aeed5 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3095,6 +3095,41 @@ end")) (puthash "\\mtteight" "𝟾" julia-latexsubs) (puthash "\\mttnine" "𝟿" julia-latexsubs) +;; Code for `inferior-julia-mode' +(require 'comint) + +(defvar julia-file-path "/usr/bin/julia" "Path to the program used by `inferior-julia'.") + +(defvar julia-arguments '() "Commandline arguments to pass to `julia'.") + +(defvar inferior-julia-prompt-regexp "julia>" + "Prompt for `inferior-julia'.") + +(defun inferior-julia () + "Run an inferior instance of `julia' inside Emacs." + (interactive) + (let ((julia-program julia-file-path) + (buffer (get-buffer-create "Julia"))) + (when (not (comint-check-proc "Julia")) + (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-process-echoes t) + (setq comint-use-prompt-regexp t)) + +(define-derived-mode inferior-julia-mode comint-mode "Julia" + "Major mode for `inferior-julia'." + nil "Julia" + (setq comint-prompt-regexp inferior-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) inferior-julia-prompt-regexp)) + +(add-hook 'inferior-julia-mode-hook 'inferior-julia--initialize) + (provide 'julia-mode) ;; Local Variables: From 75f0abd263d8c79ddb05fe07b007210730651ddf Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Tue, 3 Mar 2015 10:38:29 -0500 Subject: [PATCH 2/8] Changed inferior-julia function in contrib/julia-mode.el to apply make-comint-in-buffer instead of calling function directly --- contrib/julia-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 9637d030aeed5..08a90bbb88069 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3111,7 +3111,7 @@ end")) (let ((julia-program julia-file-path) (buffer (get-buffer-create "Julia"))) (when (not (comint-check-proc "Julia")) - (make-comint-in-buffer "Julia" "Julia" julia-program julia-arguments)) + (apply #'make-comint-in-buffer "Julia" "Julia" julia-program julia-arguments)) (pop-to-buffer-same-window "Julia") (inferior-julia-mode))) From 5fe7a73f137652e8786a7104c0efd08b2d9b2223 Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Tue, 3 Mar 2015 12:54:49 -0500 Subject: [PATCH 3/8] Changed input method for Julia Emacs buffer to TeX --- contrib/julia-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 08a90bbb88069..6c5e1d3cc2000 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3126,7 +3126,8 @@ end")) (setq comint-prompt-regexp inferior-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) inferior-julia-prompt-regexp)) + (set (make-local-variable 'paragraph-start) inferior-julia-prompt-regexp) + (set-input-method "TeX")) (add-hook 'inferior-julia-mode-hook 'inferior-julia--initialize) From 81e5f784d80db5c6506df7532e4e059e86423def Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Tue, 3 Mar 2015 13:52:30 -0500 Subject: [PATCH 4/8] Removed (setq comint-proccess-echoes t) from contrib/julia-mode.el --- contrib/julia-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 6c5e1d3cc2000..3e7f6205cc065 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3117,7 +3117,6 @@ end")) (defun inferior-julia--initialize () "Helper function to initialize `inferior-julia'." - (setq comint-process-echoes t) (setq comint-use-prompt-regexp t)) (define-derived-mode inferior-julia-mode comint-mode "Julia" @@ -3127,6 +3126,7 @@ end")) (setq comint-prompt-read-only t) (set (make-local-variable 'font-lock-defaults) '(julia-font-lock-keywords t)) (set (make-local-variable 'paragraph-start) inferior-julia-prompt-regexp) + (set (make-local-variable 'indent-line-function) 'julia-indent-line) (set-input-method "TeX")) (add-hook 'inferior-julia-mode-hook 'inferior-julia--initialize) From af3ccc48804a43612d79da0f08ad5c13bff8f135 Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Thu, 5 Mar 2015 12:03:09 -0500 Subject: [PATCH 5/8] Changed input from TeX mode to use Julia unicode input --- contrib/julia-mode.el | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 3e7f6205cc065..45ada8c51900d 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3102,6 +3102,13 @@ end")) (defvar julia-arguments '() "Commandline arguments to pass to `julia'.") +(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'.") + (defvar inferior-julia-prompt-regexp "julia>" "Prompt for `inferior-julia'.") @@ -3120,14 +3127,15 @@ end")) (setq comint-use-prompt-regexp t)) (define-derived-mode inferior-julia-mode comint-mode "Julia" - "Major mode for `inferior-julia'." + "Major mode for `inferior-julia'. + +\\" nil "Julia" (setq comint-prompt-regexp inferior-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) inferior-julia-prompt-regexp) - (set (make-local-variable 'indent-line-function) 'julia-indent-line) - (set-input-method "TeX")) + (set (make-local-variable 'indent-line-function) 'julia-indent-line)) (add-hook 'inferior-julia-mode-hook 'inferior-julia--initialize) From d9c79139e43108c0ec443692cafd9558819bae55 Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Thu, 5 Mar 2015 12:21:14 -0500 Subject: [PATCH 6/8] Added customization options --- contrib/julia-mode.el | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 45ada8c51900d..98e32a7d7e5b0 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3098,9 +3098,24 @@ end")) ;; Code for `inferior-julia-mode' (require 'comint) -(defvar julia-file-path "/usr/bin/julia" "Path to the program used by `inferior-julia'.") +(defgroup julia + '() + "Julia Programming Language." + :group 'languages + :prefix "julia-") -(defvar julia-arguments '() "Commandline arguments to pass to `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))) @@ -3109,13 +3124,10 @@ end")) map) "Basic mode map for `inferior-julia-mode'.") -(defvar inferior-julia-prompt-regexp "julia>" - "Prompt for `inferior-julia'.") - (defun inferior-julia () "Run an inferior instance of `julia' inside Emacs." (interactive) - (let ((julia-program julia-file-path) + (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)) @@ -3131,10 +3143,10 @@ end")) \\" nil "Julia" - (setq comint-prompt-regexp inferior-julia-prompt-regexp) + (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) inferior-julia-prompt-regexp) + (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) From b08aedee9e70fc1cc47ad05d37d02d4a66bcc118 Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Thu, 5 Mar 2015 12:23:51 -0500 Subject: [PATCH 7/8] Changed name of Emacs buffer to *Julia* --- contrib/julia-mode.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 98e32a7d7e5b0..ee16dd2b3e05f 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3128,10 +3128,10 @@ end")) "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") + (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 () From cdf17a46d669c0c4ff1b5ca747d8b14d454f0a0c Mon Sep 17 00:00:00 2001 From: Philip Woods Date: Fri, 6 Mar 2015 15:40:44 -0500 Subject: [PATCH 8/8] Added autoload cookie to inferior-julia function in contrib/julia-mode.el --- contrib/julia-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index ee16dd2b3e05f..c896870b85ee8 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -3124,6 +3124,7 @@ end")) map) "Basic mode map for `inferior-julia-mode'.") +;;;###autoload (defun inferior-julia () "Run an inferior instance of `julia' inside Emacs." (interactive)