Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a GIF to illustrate the REPL workflow #573

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

egr95
Copy link

@egr95 egr95 commented Feb 18, 2025

Closes #535

@junghan0611
Copy link

This is the workflow I was looking for, thank you.

@junghan0611
Copy link

How did you set dotfiles up emacs-jupyter and code-cells?

@egr95
Copy link
Author

egr95 commented Feb 24, 2025

Glad you like it!

My config uses the awesome doom emacs, which I highly recommend (note that emacs-jupyter is shipped as part of the org module in doom, so you can choose between enabling that and installing manually). Other than that, I like to use (setq jupyter-repl-echo-eval-p t), which conveniently echoes the code you have run in the REPL, and I also define the following function for sending code chunks from my python files to the REPL (which I borrowed from Hank Greenburg):

(defun gm/jupyter-eval-region (beg end)
  "Evaluate the region between BEG and END."
  (interactive "r")
  (let* ((string (buffer-substring beg end))
         (string (replace-regexp-in-string "\\`[\n]*" "" string)) ; Remove leading empty lines
         (indent-length (string-match "[^ \t]" string)) ; Find indent length of the first line
         (unindented-string (replace-regexp-in-string (format "^%s" (make-string indent-length ?\ ))
                                                      "" string t t))) ; Remove exactly that amount of indentation
    (jupyter-eval-string unindented-string)))
(add-to-list 'code-cells-eval-region-commands '(jupyter-repl-interaction-mode . gm/jupyter-eval-region))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Increase visibility of the package
2 participants