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

Send code in cells #60

Open
nbrantut opened this issue Jun 3, 2019 · 5 comments
Open

Send code in cells #60

nbrantut opened this issue Jun 3, 2019 · 5 comments

Comments

@nbrantut
Copy link

nbrantut commented Jun 3, 2019

Would it be possible to evaluate (i.e., send code to repl) code as cells (like juno, or matlab-style), for instance whatever is between ## or equivalent?

This might be linked to implementing issues reported in #19 (optionnally together with #18), but there might be an additional job for regexp tracking the cell separation symbols (maybe even highlight cells, ideally...)

I was looking to implement this myself, but my elisp is not good at all. I'll give it a go but this might look horrible.

@tpapp
Copy link
Owner

tpapp commented Jun 3, 2019

I think Jupyter notebook interfaces already handle this kind of workflow very well and there doesn't seem to be a lot of payoff from duplicating this. You may find eg

https://github.com/millejoh/emacs-ipython-notebook

useful.

@nbrantut
Copy link
Author

nbrantut commented Jun 3, 2019

Thanks for the answer; I have used the notebooks in emacs using the package you point to, but found it unecessarily cumbersome, especially for short codes. I was just thinking of doing a extremely stripped down version of cells by having a simple syntax marker that lets me evaluate a bunch of lines without having to mark the region by moving the cursor around.

But yes if that's not something you think is of interest fair enough!

@recri
Copy link

recri commented Nov 20, 2019

You might look at the literate programming support in emacs org-mode, it lists a contributed julia package already. https://orgmode.org/manual/Working-with-source-code.html

@ghost
Copy link

ghost commented Feb 2, 2021

the ob-julia module in org-mode depends on ess, the EIN or emacs-jupyter packages require...a jupyter server, there is a ob-julia-vterm package but it is synchronous and now julia-repl has vterm support anyway..
this is what I am using currently, to execute code blocks in the repl, same as https://github.com/diadochos/org-babel-eval-in-repl

(defun org-babel-execute:julia (body params)
    (interactive)
    (setq
     julia-repl-inferior-buffer-name-suffix
     (intern (rest (assoc :session params))))
    (julia-repl--send-string
     (org-babel-expand-body:julia body params)))

However I have also to redefine julia-repl--inferior-buffer-name otherwise the session isn't picked up...not sure why

@jonasseglare
Copy link

jonasseglare commented May 2, 2022

There is a library for Emacs that does this for Python source code: https://github.com/thisch/python-cell.el

I actually took this code and modified it to work for Clojure instead. And it would probably also be easy to adapt it for Julia.

Edit: I got it working for Julia with just very few changes :-)

juliacell

This is what I did:

  1. Downloaded python-cell.py and to the file ~/.emacs.d/julia-cell/julia-cell.el
  2. Replaced line (require 'python) by (require 'julia-repl) in that file.
  3. Replaced line (python-shell-send-region start end) by (julia-repl--send-string (buffer-substring-no-properties start end)).
  4. Did search/replace from python to julia in that file.
  5. Added the necessary commands to load the julia-cell.el code in my init.el file:
(add-to-list 'load-path "~/.emacs.d/julia-cell")
(require 'julia-cell)
(add-hook 'julia-mode-hook 'julia-cell-mode)

I think it would be cool to have this kind of functionality being part of julia-repl. Another option would be to extend the python-cell repo to generalize for Julia, not sure what is best.

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

No branches or pull requests

4 participants