comint-mime icon indicating copy to clipboard operation
comint-mime copied to clipboard

Q: should ipython configurations from within emacs be encouraged?

Open pank opened this issue 1 year ago • 2 comments
trafficstars

If comint-mime-prefer-svg is non-nil, the ipython config might be overwritten (e.g. ~/.ipython/profile_default/ipython_config.py). Is it desirable for emacs to configure ipython? I guess it maybe is, since most other ipython consoles are "smarter" than emacs these days (e.g. the qtconsole) so maybe you want to reserve ipython_config.py for those? On the other hand, I would find it confusing if my ipython settings are "overwritten" via comint-mime.

Maybe it's fine to just have such config nil by default?
Or maybe it's better to point out how to configure ipython in reasonable ways in docstrings and the README?

pank avatar Jul 30 '24 10:07 pank

That's a tricky question. In principle I'd say the config file should be respected. That said, this file probably includes some "console-dependent" (such as supported image formats) and some "console-independent" settings (such as preferred color schemes), and it's also probably hard to tell the two classes of settings apart from each other.

I don't use an ipython config file, if you could give me some insight on what kind of settings people typically do there it might help with those design questions.

astoff avatar Aug 09 '24 09:08 astoff

I mostly use it to improve the output of matplotlib_inline tbh. I am not sure what they are generally used for but there's an introduction.

c = get_config()

c.TerminalInteractiveShell.confirm_exit = False
c.InteractiveShellApp.extensions = ["autoreload"]
c.InteractiveShellApp.exec_lines = ["%autoreload 2"]

c.InlineBackend.figure_formats = {"svg"}
c.InlineBackend.print_figure_kwargs = {'bbox_inches': None}
c.InteractiveShellApp.exec_lines = ["%matplotlib inline"]

pank avatar Aug 09 '24 13:08 pank

Maybe it's fine to just have such config nil by default? Or maybe it's better to point out how to configure ipython in reasonable ways in docstrings and the README?

For my use case, I think asking the user to configure IPython would make things harder:

  • I regularly use IPython inside Emacs, iTerm2 (with itermplot), and VSCode (via "Jupyter: Create interactive window"). Currently, all of these solutions inject the settings they need, so that I only have to put their common customizationa in my IPython config. If this feature is removed from comint-mime, I'd have to make a complex config file that detects whether IPython is running in Emacs.
  • Currently, comint-mime + tramp works excellent together – even to servers where I haven't pulled down my dotfiles. If this setting injection is removed from comint-mime, I'll have to start syncing my dotfiles to all servers to retain the SVG plot feature remotely. Part of the reason I like tramp is that it works well even for remotes that I haven't configured.

My opinion would therefore be that it's perhaps better to keep the current default, where the setting is nil by default but injects some IPython config if the user turns it on?

jabirali avatar Sep 05 '24 15:09 jabirali

Okay, I agree with your rationale, @jabirali. In fact, in dREPL I've taken the "settings injection" approach you described to set the shell prompt, and now I'm planning to expand this approach to allow submitting arbitrary configuration options. Of course if a configuration file exists, it will be presumably be read as well, and since the Emacs-injected configuration happens later, it will take precedence.

Since from my perspective everything is clear now (although not necessarily implemented), I will close the issue.

(By the way, if you guys like comint-mime you might like that other package as well ;-)).

astoff avatar Sep 21 '24 14:09 astoff