py-vterm-interaction.el/README.org

93 lines
4.4 KiB
Org Mode
Raw Normal View History

2020-10-04 14:57:18 +09:00
# -*- eval: (visual-line-mode 1) -*-
#+STARTUP: showall
[[https://melpa.org/#/julia-vterm][file:https://melpa.org/packages/julia-vterm-badge.svg]] [[https://stable.melpa.org/#/julia-vterm][file:https://stable.melpa.org/packages/julia-vterm-badge.svg]]
2020-10-04 14:57:18 +09:00
* julia-vterm
2022-07-06 19:38:00 +09:00
Julia-vterm provides a major-mode for an inferior Julia process (or REPL) that runs in vterm, and a minor-mode that extends julia-mode with the ability to interact with the inferior Julia process.
2020-10-04 14:57:18 +09:00
2022-07-07 08:21:15 +09:00
The functionalities required for typical REPL interaction have been implemented. While I would like to keep this package simple, suggestions are always welcome.
2020-10-04 14:57:18 +09:00
2022-07-06 19:38:00 +09:00
If you want to use Julia with [[https://orgmode.org/worg/org-contrib/babel/][Org Babel]], please consider trying [[https://github.com/shg/ob-julia-vterm.el][ob-julia-vterm]]. It uses Julia-vterm and provides a solid babel development experience with session and asynchronous execution support.
2020-10-04 14:57:18 +09:00
2020-10-07 19:26:30 +09:00
** Installation
2022-07-07 14:40:25 +09:00
You can install this package from MELPA. The package name is “julia-vterm”.
2022-07-07 08:21:15 +09:00
For manual installation, download =julia-vterm.el= into somewhere in your local directory and use =package-install-file= command. Please make sure [[https://github.com/JuliaEditorSupport/julia-emacs][julia-mode]] and [[https://github.com/akermu/emacs-libvterm][emacs-libvterm]] are installed and configured correctly.
2020-10-09 10:05:26 +09:00
2022-07-07 08:21:15 +09:00
Turn on =julia-vterm-mode= in a =julia-mode= buffer to use this package. A symbol “⁂” in the mode line indicates that the julia-mode buffer is ready to interact with the julia-vterm REPL. Add the following line to your init file to enable =julia-vterm-mode= in =julia-mode= buffers automatically.
2020-10-09 10:05:26 +09:00
#+BEGIN_SRC emacs-lisp
2022-07-06 19:38:00 +09:00
(add-hook 'julia-mode-hook #'julia-vterm-mode)
2020-10-07 19:26:30 +09:00
#+END_SRC
2022-07-07 08:21:15 +09:00
By default, the command named =julia= in your =PATH= is used. You can use a Julia executable in any path by setting the =julia-vterm-repl-program= variable to its absolute path. The variable can contain switches for the =julia= command. For example, you can use a =julia= executable at a certain path, with 4 threads enabled, by the line like the following.
2021-04-28 01:30:38 -06:00
#+BEGIN_SRC emacs-lisp
(setq julia-vterm-repl-program "/path/to/julia -t 4")
2021-04-28 01:30:38 -06:00
#+END_SRC
2020-10-07 19:26:30 +09:00
** How to use
2022-07-07 08:21:15 +09:00
=M-x julia-vterm-repl= (or =M-x julia= if no other packages define it before julia-vterm is loaded) opens an inferior Julia REPL buffer.
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.
2020-10-07 19:26:30 +09:00
** Key bindings
2022-07-06 19:38:00 +09:00
*** julia-vterm-mode
#+begin_example
Key Command / Description
------------------------------------------------------------------------------------------------
C-c C-z julia-vterm-switch-to-repl-buffer
Switch to the paired REPL buffer or to the one with a specified session name.
With prefix ARG, prompt for session name.
C-<return> julia-vterm-send-region-or-current-line
Send the content of the region if the region is active, or send the current line.
C-c C-b julia-vterm-send-buffer
Send the whole content of the script buffer to the Julia REPL line by line.
C-c C-i julia-vterm-send-include-buffer-file
Send a line to evaluate the buffer's file using include() to the Julia REPL.
With prefix ARG, Revise.includet() is used instead.
C-c C-d julia-vterm-send-cd-to-buffer-directory
Send cd() function call to the Julia REPL to change the current working directory of
REPL to the buffer's directory.
#+end_example
*** julia-vterm-repl-mode
#+begin_example
Key Command / Description
------------------------------------------------------------------------------------------------
C-c C-z julia-vterm-repl-switch-to-script-buffer
Switch to the script buffer that is paired with the current Julia REPL buffer.
M-k julia-vterm-repl-clear-buffer
Clear the content of the Julia REPL buffer.
2020-10-07 19:26:30 +09:00
2022-07-06 19:38:00 +09:00
C-c C-t julia-vterm-repl-copy-mode
Enter copy mode.
#+end_example
2020-10-07 19:26:30 +09:00
2022-07-06 19:38:00 +09:00
*** julia-vterm-repl-mode (copy mode)
2020-10-07 19:26:30 +09:00
2022-07-06 19:38:00 +09:00
#+begin_example
Key Command / Description
------------------------------------------------------------------------------------------------
C-c C-t julia-vterm-repl-copy-mode
Exit copy mode.
2020-10-07 19:26:30 +09:00
2022-07-06 19:38:00 +09:00
<return> julia-vterm-repl-copy-mode-done
Copy the region to the kill ring and exit copy mode.
2020-10-07 19:26:30 +09:00
2022-07-06 19:38:00 +09:00
C-c C-r vterm-reset-cursor-point
Call the vterm command that moves point to where it should be.
#+end_example