Enable session name completion when opening a REPL

- Bump version to 0.22
This commit is contained in:
shg 2022-09-12 10:16:03 +09:00
parent a3ab6cef6c
commit e4d1c28935
2 changed files with 17 additions and 3 deletions

View file

@ -35,6 +35,10 @@ By default, the command named =julia= in your =PATH= is used. You can use a Juli
In a julia script buffer with =julia-vterm-mode= on, you can open a Julia REPL with =M-x julia-vterm-switch-to-repl-buffer= (or =C-c C-z=). See below for other commands.
Both of the above operations open a REPL with the default session name =main=. You can specify a different session name by using the prefix argument =C-u=. A new session will be created and opened if there is no REPL with that session name.
You can also specify a session name by defining a file local variable =julia-vterm-session= (or =julia-session= if no other packages pre-define it). If the variable is defined, =C-c C-z= will open a REPL with that session name.
** Key bindings
*** julia-vterm-mode

View file

@ -7,7 +7,7 @@
;; Created: March 11, 2020
;; URL: https://github.com/shg/julia-vterm.el
;; Package-Requires: ((emacs "25.1") (vterm "0.0.1"))
;; Version: 0.21
;; Version: 0.22
;; Keywords: languages, julia
;; This file is not part of GNU Emacs.
@ -96,6 +96,14 @@ If SESSION-NAME is not given, the default session name `main' is assumed."
(substring bn 7 -1)
nil)))
(defun julia-vterm-repl-list-sessions ()
"Return a list of existing Julia REPL sessions."
(mapcan (lambda (bn)
(if (string-match "\\*julia:\\(.*\\)\\*" bn)
(list (match-string 1 bn))
nil))
(mapcar #'buffer-name (buffer-list))))
(defun julia-vterm-repl-buffer (&optional session-name restart)
"Return an inferior Julia REPL buffer of the session name SESSION-NAME.
If there exists no such buffer, one is created and returned.
@ -124,7 +132,8 @@ If there's already an alive REPL buffer for the session, it will be opened."
(interactive "P")
(let* ((session-name
(cond ((null arg) nil)
(t (read-from-minibuffer "Session name: "))))
(t (completing-read "Session name: " (julia-vterm-repl-list-sessions) nil nil nil nil
(julia-vterm-repl-session-name (julia-vterm-fellow-repl-buffer))))))
(orig-buffer (current-buffer))
(repl-buffer (julia-vterm-repl-buffer session-name)))
(if (and (boundp 'julia-vterm-mode) julia-vterm-mode)
@ -240,7 +249,8 @@ With prefix ARG, prompt for session name."
(interactive "P")
(let* ((session-name
(cond ((null arg) nil)
(t (read-from-minibuffer "Session name: "))))
(t (completing-read "Session name: " (julia-vterm-repl-list-sessions) nil nil nil nil
(julia-vterm-repl-session-name (julia-vterm-fellow-repl-buffer))))))
(script-buffer (current-buffer))
(repl-buffer (julia-vterm-fellow-repl-buffer session-name)))
(setq julia-vterm-fellow-repl-buffer repl-buffer)