This Emacs minor mode allows provides you with some minor convenience functionality when editing .jl files compatible with Pluto.jl.
Note that this is an independent piece of work and is in no way connected to the Pluto.jl project.
Warning!!! This project is still in early development, and so any use is at your own risk.
Before installing the Pluto.jl mode, please make sure you have the following dependencies installed:
To install the Pluto.jl Notebook Mode using straight.el, follow these steps:
-
Open your Emacs configuration file (usually
~/.emacs.d/init.elor~/.emacs) and add the following code:(use-package plutojl-mode :straight (plutojl-mode :type git :host github :repo "torfjelde/plutojl-mode.el"))
It's recommended to activate
auto-revert-modewheneverplutojl-modeis activated, since Pluto.jl might make changes to the notebook upon saving the.jlfile, such as rearranging cells the to respect the depdencies between cells. To activateauto-revert-modewheneverplutojl-modeis activated,(use-package plutojl-mode :straight (plutojl-mode :type git :host github :repo "torfjelde/plutojl-mode.el") :hook (plutojl-mode . auto-revert-mode))
(Note that
plutojl-modealways tries to preserve the cursor position when the notebook is updated even in scenarios where Pluto.jl rearranges the ordering.) -
Restart Emacs or evaluate the configuration by running
M-x eval-buffer.
Once you have installed the plutojl-mode, you can start editing Pluto.jl notebooks using Emacs.
To enable the Pluto.jl mode, you can just call
(plutojl-mode)Alternatively, you can conditionally enable plutojs-mode upon activation of, say, julia-mode, using the provided convenience method plutojl-maybe-enable-plutojl-mode:
(add-hook 'julia-mode-hook #'plutojl-maybe-enable-plutojl-mode)plutojl-insert-cell-at-point(C-c C-c): Insert a new Pluto.jl notebook cell at the current point.plutojl-delete-cell-at-point(C-c C-d): Delete the Pluto.jl notebook cell at the current point.plutojl-goto-previous-cell(C-c C-p): Move to the previous Pluto.jl notebook cell.plutojl-goto-next-cell(C-c C-n): Move to the next Pluto.jl notebook cell.plutojl-toggle-fold-cell(C-c C-f): Toggle folding of the Pluto.jl notebook cell at the current point.
If you are going to be editing Pluto notebooks in Emacs, then it's generally a good idea to start the Pluto.jl server with auto_reload_from_file=true, for example starting server using the following
Pluto.run(Pluto.Configuration.from_flat_kwargs(auto_reload_from_file=true))Then the notebook will update whenever you save changes in the .jl file.
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
Please make sure to follow the contribution guidelines when submitting pull requests.
This project is licensed under the MIT License.