tab completion in pdb

I make frequent use of the python's built-in debugger, which I think is brilliant in its simplicity. However an important feature seems to be missing: bash-like tab completion similar to that provided by the rlcompleter module. By default, Pdb and other instances of Cmd complete names for commands only. 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. Implementation: I've attached a patch to pdb.py (on Python 2.4.4c1). The only real difference to rlcompleter's default complete method is that because pdb changes scope as you step through a program, rlcompleter's namespace is updated to reflect the current local and global namespace. This is my first attempt at a python patch. Any suggestions or improvements are welcome. Stephen Emslie

On Fri, Jan 19, 2007, stephen emslie wrote:
Please go ahead and upload this patch to SourceForge to make sure it doesn't get lost. Thanks! -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ Help a hearing-impaired person: http://rule6.info/hearing.html

Thanks for taking a look. I've created a patch relative to pdb.py in svn and submitted it to sourceforge here: http://sourceforge.net/tracker/index.php?func=detail&aid=1641544&group_id=5470&atid=305470 On 1/19/07, Aahz <aahz@pythoncraft.com> wrote:

There has been some discussion about this off-list. Most of the discussion has centered around what appropriate tab completion should be in different cases (what should be offered in the completion namespace and when). pydb has been dealt with a number of these issues already (thanks Rocky Bernstein). I would like to continue the discussion here. Here's a quick summary: - when a line is blank, pdb commands and valid identifiers and keywords should be included in the namespace. - if a line does not start with a pdb command, then it is a python expression and can be completed by rlcompleter, with all valid identifiers and keywords available in the namespace. - if a line does start with a pdb command then we should decide on the best way to complete each pdb command. for example: " "[complete] -> all possible commands, identifiers and keywords "b"[complete] -> "basestring bool break buffer" "basestring."[complete] -> "basestring.__base__ basestring.__delattr__ ... etc." "break "[complete] -> whatever the pdb completer will offer currently, the submitted patch only attempts to complete python expressions with rlcompleter. I think it would be useful (and more honest, as Rocky puts it) to offer completion for pdb commands as well. Apart from general comments, what would be great are suggestions on what sort of completion should follow the various pdb commands. Stephen Emslie On 1/22/07, stephen emslie <stephenemslie@gmail.com> wrote:

On Fri, Jan 19, 2007, stephen emslie wrote:
Please go ahead and upload this patch to SourceForge to make sure it doesn't get lost. Thanks! -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ Help a hearing-impaired person: http://rule6.info/hearing.html

Thanks for taking a look. I've created a patch relative to pdb.py in svn and submitted it to sourceforge here: http://sourceforge.net/tracker/index.php?func=detail&aid=1641544&group_id=5470&atid=305470 On 1/19/07, Aahz <aahz@pythoncraft.com> wrote:

There has been some discussion about this off-list. Most of the discussion has centered around what appropriate tab completion should be in different cases (what should be offered in the completion namespace and when). pydb has been dealt with a number of these issues already (thanks Rocky Bernstein). I would like to continue the discussion here. Here's a quick summary: - when a line is blank, pdb commands and valid identifiers and keywords should be included in the namespace. - if a line does not start with a pdb command, then it is a python expression and can be completed by rlcompleter, with all valid identifiers and keywords available in the namespace. - if a line does start with a pdb command then we should decide on the best way to complete each pdb command. for example: " "[complete] -> all possible commands, identifiers and keywords "b"[complete] -> "basestring bool break buffer" "basestring."[complete] -> "basestring.__base__ basestring.__delattr__ ... etc." "break "[complete] -> whatever the pdb completer will offer currently, the submitted patch only attempts to complete python expressions with rlcompleter. I think it would be useful (and more honest, as Rocky puts it) to offer completion for pdb commands as well. Apart from general comments, what would be great are suggestions on what sort of completion should follow the various pdb commands. Stephen Emslie On 1/22/07, stephen emslie <stephenemslie@gmail.com> wrote:
participants (2)
-
Aahz
-
stephen emslie