Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

clear In[] prompt numbers on "Clear All Output" #1621

Merged
merged 1 commit into from

4 participants

@ivanov
Owner

For more version-control-friendly .ipynb files, I've found it useful to strip the In[] prompt numbers when doing a "Clear all output".

I noted in the commit here that this should be a configurable behavior, and would love a pointer for how to proceed with making it configurable (using some javascript checkbox widget?)

I'm equally happy with amending this commit to just be the default, and punting on the configurability until a later date.

@fperez
Owner

Let's punt on configurability for now: I think that should be the default behavior, since once output has been removed, the input numbers don't mean much anymore. We'll need to revisit the configuration problem for the web client later on, but we shouldn't stall good updates because of not having that done yet.

@ivanov
Owner

ok, so should i just replace my comments with just something like "Make all In[ ] prompts blank. TODO: make this configurable in the future" ?

@fperez
Owner

sounds good

@ivanov
Owner

ok, updated the comment, now it's ready to be merged

@fperez
Owner

I'm +1 on merging this, let's give it a day or so in case anyone else wants to have a look. Thanks!

@minrk
Owner

This seems sensible to me, though it does discard some information about execution if you continue to use the notebook in the same session after clearing it (as opposed to saving immediately and re-opening later on a fresh kernel).

It seems like a combined 'fresh start == restart kernel + clear_all_output' would be a useful and more clearly consistent action, though I suppose clicking two buttons is not too much to ask.

@minrk
Owner

Oh, in case that meandering wasn't clear, I am +1 to merge as well.

@fperez
Owner

OK, let's merge it then. @minrk, you're right in that a full 'fresh start' option would probably be a good idea, but even with the points you mention, I think in practice for the purposes of saving for version control, this is a big improvement.

@fperez fperez merged commit 187d009 into from
@fperez
Owner

All merged, thanks again @ivanov for the work!!

@ivanov
Owner

thanks for the feedback and the merging. what can I say, i'm very fond of one-liner fixes :)

@highlando

I tend to forget about this from time to time. Would be nice to have the option to do this automatically on save...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2012
  1. @ivanov
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  IPython/frontend/html/notebook/static/js/notebook.js
View
3  IPython/frontend/html/notebook/static/js/notebook.js
@@ -874,6 +874,9 @@ var IPython = (function (IPython) {
for (var i=0; i<ncells; i++) {
if (cells[i] instanceof IPython.CodeCell) {
cells[i].clear_output(true,true,true);
+ // Make all In[] prompts blank, as well
+ // TODO: make this configurable (via checkbox?)
+ cells[i].set_input_prompt();
}
};
this.dirty = true;
Something went wrong with that request. Please try again.