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

rlcompleter tab completion in pdb #44493

Closed
stephenemslie mannequin opened this issue Jan 22, 2007 · 4 comments
Closed

rlcompleter tab completion in pdb #44493

stephenemslie mannequin opened this issue Jan 22, 2007 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@stephenemslie
Copy link
Mannequin

stephenemslie mannequin commented Jan 22, 2007

BPO 1641544
Nosy @birkenfeld
Files
  • pdb-51745-tabcomplete.patch: tab completion patch for pdb rev. 51745
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-04-01.05:52:51.242>
    created_at = <Date 2007-01-22.11:52:40.000>
    labels = ['type-feature', 'library']
    title = 'rlcompleter tab completion in pdb'
    updated_at = <Date 2012-04-01.05:52:51.241>
    user = 'https://bugs.python.org/stephenemslie'

    bugs.python.org fields:

    activity = <Date 2012-04-01.05:52:51.241>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-04-01.05:52:51.242>
    closer = 'georg.brandl'
    components = ['Library (Lib)']
    creation = <Date 2007-01-22.11:52:40.000>
    creator = 'stephenemslie'
    dependencies = []
    files = ['7732']
    hgrepos = []
    issue_num = 1641544
    keywords = ['patch']
    message_count = 4.0
    messages = ['51775', '51776', '51777', '157256']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'rockyb', 'stephenemslie', 'tshepang']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1641544'
    versions = ['Python 3.3']

    @stephenemslie
    Copy link
    Mannequin Author

    stephenemslie mannequin commented Jan 22, 2007

    By default, Pdb and other instances of Cmd complete names for their commands. However in the context of pdb, I think it is more useful to complete identifiers and keywords in its current scope than to complete names of commands (most of which have single letter abbreviations). I believe this makes pdb a far more usable introspection tool.

    I have discussed this proposal on the python-ideas list:
    http://mail.python.org/pipermail/python-ideas/2007-January/000084.html

    This patch implements the following:

    • creates an rlcompleter instance on Pdb if readline is available
    • adds a 'complete' method to the Pdb class. The only difference with rlcompleter's default behaviour is that is also updates rlcompleter's namespace to reflect the current local and global namespace, which is necessary because pdb changes scope as it steps through a program

    This is a patch against python/Lib/pdb.py rev. 51745

    @stephenemslie stephenemslie mannequin added stdlib Python modules in the Lib dir labels Jan 22, 2007
    @rockyb
    Copy link
    Mannequin

    rockyb mannequin commented Jan 28, 2007

    I experimented with this a little in the pydb variant (http://bashdb.sf.net/pydb). Some observations. First, one can include the debugger commands into the namespace without too much trouble. See what's checked into CVS for pydb; In particular look at the complete method of pydbbdb. (Personally, I think adding debugger commands to the list of completions is a little more honest.)

    The second problem I have is that completion is not all that sensitive to the preceding context. If the line begins "step" or "1 + ", is it really correct to list all valid symbols?

    @stephenemslie
    Copy link
    Mannequin Author

    stephenemslie mannequin commented Feb 2, 2007

    Thanks for your comments, and thanks for pointing out pydb

    I agree that debugger commands should also belong in the completion namespace. I'll have a look at adding that to the patch.

    The second problem I have is that completion is not all that sensitive to the preceding context.

    The idea is that the namespace that is available to the completer at any time will be the same as the local and global identifiers and keywords that are available in the same scope. I think it makes sense to complete everything that is valid in the current scope because that makes for a more useful introspection tool. Thats what frame.f_locals and frame.f_globals are about (if foo and bar are available in the current scope, and you step into a function outside of that scope then foo and bar will no longer be available in the completer's namespace). I notice this is also used in pydb's complete method under certain circumstances.

    I'll definitely take a closer look at pydb. I probably wouldn't have needed to write this if I'd known about it before :)

    @devdanzin devdanzin mannequin added type-feature A feature request or enhancement labels Mar 30, 2009
    @birkenfeld
    Copy link
    Member

    Meanwhile I've added more comprehensive tab-completion to 3.3 for bpo-14210.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant