We're ignoring prompt customizations #1075

Closed
fperez opened this Issue Dec 1, 2011 · 13 comments

Comments

Projects
None yet
5 participants
@fperez
Member

fperez commented Dec 1, 2011

Reported on the user list and I confirmed it:

This is with Python 2.7, IPython 0.12.beta (a checkout about an hour ago)

I have these following lines in my ipython_config.py

c.TerminalInteractiveShell.prompt_in1 = 'I\\# '
c.TerminalInteractiveShell.prompt_out = 'O\\# '

But IPython shows prompts in its way:

In [1]: a = 5

In [2]: a
Out[2]: 5

This is definitely a blocker, lots of people customize their prompts so we shouldn't release with this broken.

@gsever

This comment has been minimized.

Show comment
Hide comment
@gsever

gsever Dec 1, 2011

Thanks for carrying the email report here. Interestingly, changing the lines from /IPython/core/interactiveshell.py as

prompt_in1 = Unicode('I\\# ', config=True)
prompt_out = Unicode('O\\# ', config=True)

does not make any difference. I wonder where else IPython loading these defaults?

gsever commented Dec 1, 2011

Thanks for carrying the email report here. Interestingly, changing the lines from /IPython/core/interactiveshell.py as

prompt_in1 = Unicode('I\\# ', config=True)
prompt_out = Unicode('O\\# ', config=True)

does not make any difference. I wonder where else IPython loading these defaults?

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Dec 1, 2011

Member

Not sure; @takluyver, is it possible that the recent prompt reorg in #507 broke things here? I haven't bisected the problem yet, unfortunately I can't do it right now...

Member

fperez commented Dec 1, 2011

Not sure; @takluyver, is it possible that the recent prompt reorg in #507 broke things here? I haven't bisected the problem yet, unfortunately I can't do it right now...

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Dec 1, 2011

Member

Wasn't this the whole point of the PromptManager? prompts are not traits of the InteractiveShell anymore, they are now traits of the PromptManager:

c.PromptManager.in_template = 'I\\#'
c.PromptManager.out_template = 'O\\#'

The prompt_foo traits of the InteractiveShell shouldn't even exist anymore.

Member

minrk commented Dec 1, 2011

Wasn't this the whole point of the PromptManager? prompts are not traits of the InteractiveShell anymore, they are now traits of the PromptManager:

c.PromptManager.in_template = 'I\\#'
c.PromptManager.out_template = 'O\\#'

The prompt_foo traits of the InteractiveShell shouldn't even exist anymore.

@gsever

This comment has been minimized.

Show comment
Hide comment
@gsever

gsever Dec 1, 2011

These adds an extra tab before I and O characters. By the way, how to get config object from within IPython?

c = get_config()

Where is this get_config is imported from?

gsever commented Dec 1, 2011

These adds an extra tab before I and O characters. By the way, how to get config object from within IPython?

c = get_config()

Where is this get_config is imported from?

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Dec 1, 2011

Member

On Wed, Nov 30, 2011 at 8:21 PM, Min RK
reply@reply.github.com
wrote:

Wasn't this the whole point of the PromptManager? prompts are not traits of the InteractiveShell anymore, they are now traits of the PromptManager:

   c.PromptManager.in_template = 'I#'
   c.PromptManager.out_template = 'O#'

Yes, totally right; but the problem is (and this is what threw me off
track), that even now when we create new profiles, we still point to
the shell, and we're not generating config entries for the
PromptManager at all in the profile:

c.TerminalInteractiveShell.prompt_in2 = ' .\D.: '

c.TerminalInteractiveShell.separate_out = ''

c.TerminalInteractiveShell.prompt_in1 = 'In [#]: '

So before we close this issue, that needs to be addressed.

Member

fperez commented Dec 1, 2011

On Wed, Nov 30, 2011 at 8:21 PM, Min RK
reply@reply.github.com
wrote:

Wasn't this the whole point of the PromptManager? prompts are not traits of the InteractiveShell anymore, they are now traits of the PromptManager:

   c.PromptManager.in_template = 'I#'
   c.PromptManager.out_template = 'O#'

Yes, totally right; but the problem is (and this is what threw me off
track), that even now when we create new profiles, we still point to
the shell, and we're not generating config entries for the
PromptManager at all in the profile:

c.TerminalInteractiveShell.prompt_in2 = ' .\D.: '

c.TerminalInteractiveShell.separate_out = ''

c.TerminalInteractiveShell.prompt_in1 = 'In [#]: '

So before we close this issue, that needs to be addressed.

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Dec 1, 2011

Member

get_config is not imported from anywhere, it's defined interactively, but you can get the config object from the IPython instance with:

c = get_ipython().config

The extra indentation is because the PromptManager right-aligns all prompts to the longest one, so you either have to set PromptManager.justify=False, or make sure that none of the prompts are longer than your input (rewrite is the most likely to be too long).

There seem to be a few issues with the PromptManager. We should probably have had a transition plan in place for before merging a major reorganization of config like this.

Member

minrk commented Dec 1, 2011

get_config is not imported from anywhere, it's defined interactively, but you can get the config object from the IPython instance with:

c = get_ipython().config

The extra indentation is because the PromptManager right-aligns all prompts to the longest one, so you either have to set PromptManager.justify=False, or make sure that none of the prompts are longer than your input (rewrite is the most likely to be too long).

There seem to be a few issues with the PromptManager. We should probably have had a transition plan in place for before merging a major reorganization of config like this.

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Dec 1, 2011

Member

Yes, absolutely - there are a number of places this needs to be fixed. Should we leave the InteractiveShell.prompt traits with a deprecation warning, or just remove them and leave users to their own devices?

Member

minrk commented Dec 1, 2011

Yes, absolutely - there are a number of places this needs to be fixed. Should we leave the InteractiveShell.prompt traits with a deprecation warning, or just remove them and leave users to their own devices?

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Dec 1, 2011

Member

See #1078 for some fixes. The old traits still exist and work, but point to the new ones shouting about deprecation if you use them. Various references to the old traits in tests, docs, examples, etc. also fixed.

Member

minrk commented Dec 1, 2011

See #1078 for some fixes. The old traits still exist and work, but point to the new ones shouting about deprecation if you use them. Various references to the old traits in tests, docs, examples, etc. also fixed.

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Dec 1, 2011

Member

Thanks, I like the approach you took re. deprecation and trait redirection; see my comments in the PR regarding the indentation. I can't work on it tonight, but if you don't get to it or @takluyver doesn't do it, I can also help finish it and recover the behavior we had before. @gsever, we'll only close this issue when that's fully addressed.

Member

fperez commented Dec 1, 2011

Thanks, I like the approach you took re. deprecation and trait redirection; see my comments in the PR regarding the indentation. I can't work on it tonight, but if you don't get to it or @takluyver doesn't do it, I can also help finish it and recover the behavior we had before. @gsever, we'll only close this issue when that's fully addressed.

@gsever

This comment has been minimized.

Show comment
Hide comment
@gsever

gsever Dec 1, 2011

The solutions provided by @minrk fixes the I/O prompt customization problem for me. Thanks for the comments on the issue.

gsever commented Dec 1, 2011

The solutions provided by @minrk fixes the I/O prompt customization problem for me. Thanks for the comments on the issue.

@fperez fperez closed this in 4b8920a Dec 1, 2011

@stonebig

This comment has been minimized.

Show comment
Hide comment
@stonebig

stonebig Nov 2, 2014

Contributor

hi all,

I still see in the documentation
http://ipython.org/ipython-doc/dev/config/intro.html

c = get_config()

which does not work on my pc to the opposite of

c = get_ipython().config

is it normal ?

Contributor

stonebig commented Nov 2, 2014

hi all,

I still see in the documentation
http://ipython.org/ipython-doc/dev/config/intro.html

c = get_config()

which does not work on my pc to the opposite of

c = get_ipython().config

is it normal ?

@Carreau

This comment has been minimized.

Show comment
Hide comment
@Carreau

Carreau Nov 2, 2014

Member

No, this is not normal.
I suspect using get_ipython().config and setting attributes will not work in many cases.

In which file are you doing this ? ipython profile create should create the config files for you.

Jut to be clear c = get_config() will work only in config files.

Member

Carreau commented Nov 2, 2014

No, this is not normal.
I suspect using get_ipython().config and setting attributes will not work in many cases.

In which file are you doing this ? ipython profile create should create the config files for you.

Jut to be clear c = get_config() will work only in config files.

@stonebig

This comment has been minimized.

Show comment
Hide comment
@stonebig

stonebig Nov 2, 2014

Contributor

ok.
I was doing that in interactive mode.

Contributor

stonebig commented Nov 2, 2014

ok.
I was doing that in interactive mode.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

Merge pull request #1083 from takluyver/prompts
Fixes that finish up the recent PromptManager work:

* InteractiveShell.prompt_foo traits show deprecation warning, and map to new PromptManager traits
* PromptManager properly added to IPython App, so it will show up in config
* add helpstrings to PromptManager traits.
* Docs / embed references to Shell.prompt_foo also updated
* Prompt rewriting in autocall scenarios is now controlled by a boolean, `show_rewritten_input`, attribute of the InteractiveShell.

Closes #1075.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment