astoff / code-cells.el

Emacs utilities for code split into cells, including Jupyter notebooks
GNU General Public License v3.0
180 stars 11 forks source link

jupyter-eval-region signature has changed #22

Closed gmoutso closed 9 months ago

gmoutso commented 1 year ago

This is a great package! Thanks. jupyter-eval-region has changed signature and no longer is (beg end) but (insert beg end). I have made the following changes to make code-cells work with jupyter-emacs again

(defun gm/jupyter-eval-region (beg end)
  (jupyter-eval-region nil beg end))
(add-to-list 'code-cells-eval-region-commands '(jupyter-repl-interaction-mode . gm/jupyter-eval-region))
gmoutso commented 1 year ago

Changed function is here

astoff commented 1 year ago

This seems like a questionable API change. Do you know why they didn't make the new signature (beg end &optional insert), an perhaps this could still be changed in jupyter-emacs?

gmoutso commented 1 year ago

Sorry no, I don't know. But I do use both packages a lot... Should I open a bug on jupyter-emacs?

LarryLegend33 commented 1 year ago

Hi I've encountered the same problem with code-cells-eval calls yielding a "Wrong number of arguments" error. Where exactly did you place this new function to get code-cells and jupyter-emacs to work together again? Thanks!

gmoutso commented 11 months ago

Hi I've encountered the same problem with code-cells-eval calls yielding a "Wrong number of arguments" error. Where exactly did you place this new function to get code-cells and jupyter-emacs to work together again? Thanks!

Hi. All of the following can be placed in your init.el. First define a function like

(defun gm/jupyter-eval-region (beg end)
(jupyter-eval-region nil beg end))

Then add this to code-cells-eval-region-commands either using the customize interface or add this again in your init.el: (add-to-list 'code-cells-eval-region-commands '(jupyter-repl-interaction-mode . gm/jupyter-eval-region))

Once you have done this, eval-buffer while in your init.el or restart emacs.

chookity-pokk commented 9 months ago

It would be nice if this could be mentioned in the README somewhere to make it easier for people to find.

chookity-pokk commented 9 months ago

Hi I've encountered the same problem with code-cells-eval calls yielding a "Wrong number of arguments" error. Where exactly did you place this new function to get code-cells and jupyter-emacs to work together again? Thanks!

Hi. All of the following can be placed in your init.el. First define a function like

(defun gm/jupyter-eval-region (beg end)
(jupyter-eval-region nil beg end))

Then add this to code-cells-eval-region-commands either using the customize interface or add this again in your init.el: (add-to-list 'code-cells-eval-region-commands '(jupyter-repl-interaction-mode . gm/jupyter-eval-region))

Once you have done this, eval-buffer while in your init.el or restart emacs.

This doesn't work for me unless I first start a jupyter repl. Putting the function in my init works fine but it throws an error on the (add-to-list 'code-cells-eval-region-commands '(jupyter-repl-interaction-mode . gm/jupyter-eval-region)) part with the backtrace below.

Debugger entered--Lisp error: (void-variable code-cells-eval-region-commands)
  (member '(jupyter-repl-interaction-mode . gm/jupyter-eval-region) code-cells-eval-region-commands)
  (if (member '(jupyter-repl-interaction-mode . gm/jupyter-eval-region) code-cells-eval-region-commands) code-cells-eval-region-commands (setq code-cells-eval-region-commands (cons '(jupyter-repl-interaction-mode . gm/jupyter-eval-region) code-cells-eval-region-commands)))
  eval-buffer(#<buffer  *load*-206962> nil "/Users/hankgreenburg/.emacs.d/init.el" nil t)  ; Reading at buffer position 52141
  load-with-code-conversion("/Users/hankgreenburg/.emacs.d/init.el" "/Users/hankgreenburg/.emacs.d/init.el" nil nil)
  load("/Users/hankgreenburg/.emacs.d/init.el" nil nil t)
  load-file("/Users/hankgreenburg/.emacs.d/init.el")
  org-babel-load-file("/Users/hankgreenburg/.emacs.d/init.org")
  eval-buffer(#<buffer  *load*> nil "/Users/hankgreenburg/.emacs" nil t)  ; Reading at buffer position 410
  load-with-code-conversion("/Users/hankgreenburg/.emacs" "/Users/hankgreenburg/.emacs" t t)
  load("~/.emacs" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1552091b4c8cfd>) #f(compiled-function () #<bytecode -0x1f3c61addc0da035>) t)
  command-line()
  normal-top-level()
astoff commented 9 months ago

Since https://github.com/emacs-jupyter/jupyter/issues/490 was ignored, I reluctantly decided to add a workaround to code-cells. Let me know in case you still have trouble.