rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.52k stars 195 forks source link

Modeline gets lost when using emacs ipython notebook #45

Closed peterewills closed 3 years ago

peterewills commented 3 years ago

Thanks for all the work on this, it's really beautiful. I'm working on getting it to play nice with all my tools.

I've noticed that in emacs ipython notebook, since that library also controls the top line of the buffer and uses it to display status (information about the notebook kernel), the modeline disappears. It would be great if it would appear at the top of the buffer, and the EIN status would appear one line below.

Screen Shot 2020-12-30 at 9 36 31 PM
rougier commented 3 years ago

Thanks for the report. If ein is using the header line, it will be necessary to tweak it a bit. This is what I did for elfeed. Do you think you can gie it a try based on nano-modeline.el ?

peterewills commented 3 years ago

Gave it a try, but I don't think we can change the modeline in EIN by just adding a case to the definition of nano-modeline. The header-line-format gets set each time the notebook is rendered; see ein:notification-setup, which sets the header-line-format and ultimately is called by ein:notebook--worksheet-render.

The header line in EIN is built via the ein:header-line function (which returns the header-line string) and so I think what we'd need to do to build the header-line is something like

(nano-modeline-compose (nano-modeline-status) "EIN" (ein:header-line) "")

but, as I said, I'm not sure how to set it up so that this takes precedence over the setting of the header line format done by EIN.

There is a variable ein:header-line-format which should allow the user to modify the function that builds the header line, but when I've changed it's definition the change doesn't seem to get picked up by my notebook buffers.

I'm quite inexperienced in elisp in general, so some of the fixes here might be very basic, and I'm just not seeing them.

rougier commented 3 years ago

Thanks fro all these information. I think the ein:header-line-format should be the way to go but it's strange that it doesn't work since it seems to have been designed for such purpose. What you can try is to set it while a notebook is running. For example, you can type: M-: (setq ein:header-line-format "Test") (M - : is for evaluating an expression)

peterewills commented 3 years ago

Okay! Progress. I don't know what I was doing before - maybe I was setting the header-line-format incorrectly. Anyways, I now can do

(defun nano-modeline-ein:notebook-mode ()
  (nano-modeline-compose (nano-modeline-status)
                         (ein:header-line)
                         ""
                         ""))

(setq ein:header-line-format '((:eval (nano-modeline-ein:notebook-mode))))

and it sets up the modeline as one would hope, with one exception - the status (in the upper left) doesn't change from RW to ** when I make changes to the notebook. If you know why this is off the top of your head, I'd be curious to hear. Otherwise, I'll have to dig in and see why the status of the notebook isn't getting passed through to nano-modeline-status.

Thanks again for all the help!

rougier commented 3 years ago

Great ! For the nano-modeline-status, I'm mostly using the status of the buffer but I suspect this might be different for the notebook. Best would be to check the code for the default ein modeline and see how they get the status for the notebook.