Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intelligent auto naming, or ask for name on first user.save #8378

Open
miraculixx opened this issue Apr 26, 2015 · 2 comments
Open

Intelligent auto naming, or ask for name on first user.save #8378

miraculixx opened this issue Apr 26, 2015 · 2 comments
Labels
Milestone

Comments

@miraculixx
Copy link

Currently ipython notebook saves new notebooks as "untitled #.ipynb" where # is a sequence number. That's nice because it safes you the hassle of thinking of saving in the first place. It is however not so nice because in a short amount of time you end up with a list of "untitled #.ipynb" files and it becomes hard to find a specific notebook, short of opening (and shutting down) each one. Of course, not renaming the notebook before closing it down is simply a sign of one being too lazy or forgetful, then again, it would be nice if ipython took the hassle out of this, too.

I suggest to improve naming with either of the following:

  • intelligent auto naming: take the first comment line of a code cell, the first literal name, or the first line of text in any other cell
  • on user's first explicit save (Ctrl-S), ask for a name
  • on closing the notebook, ask for a name

As one way to implement this, e.g. ipython_notebook_config.AUTOSAVE_NAMING could take a lambda that would receive the first cell's type and context and returns a name, so users can simply override it. The default implementation would do as shown below.

Consider these examples

# fun with fibonacci
def fib(n):
    ....

=> would be saved to 'fun with fibonacci.ipynb'

def numbers(N):
    for n in N:
        yield N

=> would be saved to numbers.ipynb

[markdown cell]
* great stuff
* and it has intelligent autonaming, too 

=> would be saved to great stuff.ipynb

@takluyver
Copy link
Member

This is a bit tricky, because the name is actually picked when you create a notebook, and used in the URL, so I'm not sure that we should be changing that automatically on save.

If we did do something like this, I think it would be reasonable to look for a title in the first markdown cell. Doing it from function names, comments etc. feels a bit too clever (and hard to do in a cross-language way).

@miraculixx
Copy link
Author

This is a bit tricky, because the name is actually picked when you create a notebook, and used in the URL

I see, however the user can choose to rename at any time, so we could just simulate a rename. And since he didn't pick the generated name in first place he will not mind if ipython does that automatically once it knows better (i.e. some content has been entered).

I think it would be reasonable to look for a title in the first markdown cell

I guess that would be a fair start. I'm not sure how this applies to most users, however most of my notebooks are for dev work and don't have a markdown cell. they generally all have a comment line at the top though...

anyhow, I considered it would be difficult to get this right in general/multiple languages, hence the idea for the lambda/callable in ipython_notebook_config.AUTOSAVE_NAMING, so it would be easy to adjust for one's own style. Or whatever better approach you see fit to achieve the same...

@takluyver takluyver added this to the not ipython milestone Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants