From 7fb56bf5832fd291cf5a71884faa7d91fa9076a6 Mon Sep 17 00:00:00 2001 From: Antonino Date: Tue, 5 May 2026 11:40:04 +0200 Subject: [PATCH 1/6] Added julia-repl--push-args, julia-repl-with-args and julia-repl-activate-parent-with-args --- julia-repl.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/julia-repl.el b/julia-repl.el index fb99ae2..e26ebd0 100644 --- a/julia-repl.el +++ b/julia-repl.el @@ -899,6 +899,23 @@ When called with a prefix argument, activate the home project." (expand-file-name (file-name-directory projectfile)) "\")"))) (message "could not find project file")))) + +(defun julia-repl--push-args (args) + (s-prepend + (s-prepend "push!(ARGS,\"" + (s-join"\",\"" (s-split " " args t))) "\")" )) + + +(defun julia-repl-with-args (args) + (interactive "s") + (julia-repl--send-string (julia-repl--push-args args))) + +(defun julia-repl-activate-parent-with-args (arg args) + (interactive "P\ns") + (julia-repl-activate-parent arg) + (julia-repl-with-args args)) + + (defun julia-repl-set-julia-editor (editor) "Set the JULIA_EDITOR environment variable." (interactive) From c4e036d301b2ebbad9fd9c1afb4263e038aa1467 Mon Sep 17 00:00:00 2001 From: Antonino Date: Tue, 5 May 2026 11:55:28 +0200 Subject: [PATCH 2/6] made julia-repl interatvie "P". when called with C-u C-c C-z it will ask for command line arguments --- julia-repl.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/julia-repl.el b/julia-repl.el index e26ebd0..39f8e3a 100644 --- a/julia-repl.el +++ b/julia-repl.el @@ -643,18 +643,22 @@ Valid keys are the first items in ‘julia-repl-executable-records’." inferior-buffer))))) ;;;###autoload -(defun julia-repl () +(defun julia-repl (args) "Raise the Julia REPL inferior buffer, creating one if it does not exist. This is the standard entry point for using this package." - (interactive) + (interactive "P") (let ((script-buffer (current-buffer)) (inferior-buffer (julia-repl-inferior-buffer))) (with-current-buffer inferior-buffer (setq julia-repl--script-buffer script-buffer)) (if julia-repl-pop-to-buffer (pop-to-buffer inferior-buffer) - (switch-to-buffer inferior-buffer)))) + (switch-to-buffer inferior-buffer))) + (if args + (julia-repl--send-string + (julia-repl--push-args + (read-from-minibuffer "Command line args: "))))) (defun julia-repl--switch-back () "Switch to the buffer that was active before last call to `julia-repl'." From 9baa37e7555d9d4895890b51557cdeb9f4476c07 Mon Sep 17 00:00:00 2001 From: Antonino Date: Tue, 5 May 2026 12:26:19 +0200 Subject: [PATCH 3/6] julia-repl-with-args now reads from mini-buffer --- julia-repl.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/julia-repl.el b/julia-repl.el index 39f8e3a..1905bfa 100644 --- a/julia-repl.el +++ b/julia-repl.el @@ -910,11 +910,13 @@ When called with a prefix argument, activate the home project." (s-join"\",\"" (s-split " " args t))) "\")" )) -(defun julia-repl-with-args (args) - (interactive "s") - (julia-repl--send-string (julia-repl--push-args args))) +(defun julia-repl-with-args () + (interactive) + (let ((str (read-from-minibuffer "Command line args: "))) + (if (s-present? str) + (julia-repl--send-string (julia-repl--push-args str))))) -(defun julia-repl-activate-parent-with-args (arg args) +(defun julia-repl-activate-parent-with-args (arg) (interactive "P\ns") (julia-repl-activate-parent arg) (julia-repl-with-args args)) From f995454da239ea2579054a9dc9bc122e89b27309 Mon Sep 17 00:00:00 2001 From: Antonino Date: Tue, 5 May 2026 12:28:06 +0200 Subject: [PATCH 4/6] julia-repl-with-args renamed to julia-repl--ask-for-args. julia-repl-activate-parent-with-args removed --- julia-repl.el | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/julia-repl.el b/julia-repl.el index 1905bfa..006bd7d 100644 --- a/julia-repl.el +++ b/julia-repl.el @@ -910,18 +910,11 @@ When called with a prefix argument, activate the home project." (s-join"\",\"" (s-split " " args t))) "\")" )) -(defun julia-repl-with-args () - (interactive) +(defun julia-repl--ask-for-args () (let ((str (read-from-minibuffer "Command line args: "))) (if (s-present? str) (julia-repl--send-string (julia-repl--push-args str))))) -(defun julia-repl-activate-parent-with-args (arg) - (interactive "P\ns") - (julia-repl-activate-parent arg) - (julia-repl-with-args args)) - - (defun julia-repl-set-julia-editor (editor) "Set the JULIA_EDITOR environment variable." (interactive) From 7b24ace4e6b833c6b91c31fa51f21a07dba99f18 Mon Sep 17 00:00:00 2001 From: Antonino Date: Tue, 5 May 2026 12:53:34 +0200 Subject: [PATCH 5/6] reorganized functions. C-u C-c C-z now uses julia-rel--ask-for-args. --- julia-repl.el | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/julia-repl.el b/julia-repl.el index 006bd7d..f50bf37 100644 --- a/julia-repl.el +++ b/julia-repl.el @@ -642,6 +642,16 @@ Valid keys are the first items in ‘julia-repl-executable-records’." (setq-local julia-repl--inferior-buffer-suffix suffix)) inferior-buffer))))) +(defun julia-repl--push-args (args) + (s-prepend + (s-prepend "push!(ARGS,\"" + (s-join"\",\"" (s-split " " args t))) "\")" )) + +(defun julia-repl--ask-for-args () + (let ((str (read-from-minibuffer "Command line args: "))) + (if (s-present? str) + (julia-repl--send-string (julia-repl--push-args str))))) + ;;;###autoload (defun julia-repl (args) "Raise the Julia REPL inferior buffer, creating one if it does not exist. @@ -655,10 +665,7 @@ This is the standard entry point for using this package." (if julia-repl-pop-to-buffer (pop-to-buffer inferior-buffer) (switch-to-buffer inferior-buffer))) - (if args - (julia-repl--send-string - (julia-repl--push-args - (read-from-minibuffer "Command line args: "))))) + (if args (julia-repl--ask-for-args))) (defun julia-repl--switch-back () "Switch to the buffer that was active before last call to `julia-repl'." @@ -903,18 +910,6 @@ When called with a prefix argument, activate the home project." (expand-file-name (file-name-directory projectfile)) "\")"))) (message "could not find project file")))) - -(defun julia-repl--push-args (args) - (s-prepend - (s-prepend "push!(ARGS,\"" - (s-join"\",\"" (s-split " " args t))) "\")" )) - - -(defun julia-repl--ask-for-args () - (let ((str (read-from-minibuffer "Command line args: "))) - (if (s-present? str) - (julia-repl--send-string (julia-repl--push-args str))))) - (defun julia-repl-set-julia-editor (editor) "Set the JULIA_EDITOR environment variable." (interactive) From cf0c9ff827762f352686cb835a400e2a77a3847e Mon Sep 17 00:00:00 2001 From: Antonino Date: Tue, 5 May 2026 13:03:23 +0200 Subject: [PATCH 6/6] Edited README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 54134b4..658dd94 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,15 @@ If you cannot edit your `startup.jl`, you can configure the editor in each repl ```elisp (add-hook 'julia-repl-hook #'julia-repl-use-emacsclient) ``` +## Passing command line arguments, i.e. `push!` to `ARGS` + +If you need to pass some command line arguments, you can raise the REPL with `C-u C-c C-z` and you will be promted to write you command line arguments. They will be sent to the REPL in a `push!(ARGS,[...])` call. + +This is equivalent of running in the terminal + +``` +$ julia -i .jl arg1 args2 ... +``` ## More colors