Hi Thomas,

Thanks for the quick reply.  That worked exactly the way I wanted!  I
had read the auto_arg Wiki page, but it didn't click that I had to
define a new list specifically for the command I wanted the tab
completion to work for (i.e. select).  I thought it applied to all

So, for anyone else who is trying to do this, the command to have tab
completion use only loaded and visible object names *during select
statements* is as follows:
cmd.auto_arg[0]['select'] = [ lambda:
cmd.Shortcut(cmd.get_names("objects", enabled_only=1)), 'visible
object name(s)', '']

If you want tab completion to pull up loaded objects (visible or not)
as well as PDB files in the current working directory, it would be:
cmd.auto_arg[0]['select'] = [ lambda: cmd.Shortcut(cmd.get_names() +
glob.glob('*.pdb')), 'PDB file and object name(s)', '']


On Wed, Oct 17, 2012 at 2:31 PM, Thomas Holder
<spel...@users.sourceforge.net> wrote:
> Hi Ron,
> tab completion is controlled by the cmd.auto_arg variable, which is a list
> of dictionaries.
> http://pymolwiki.org/index.php/auto_arg
> For all arguments which do not have an entry in auto_arg, the default is to
> auto-complete file names. For your purpose you need to define something like
> this:
> python
> import glob
> cmd.auto_arg[0]['save'] = [
>   lambda: cmd.Shortcut(cmd.get_names() + glob.glob('*')),
>   'filename or object name', '']
> python end
> Cheers,
>   Thomas
> Ron Jacak wrote, On 10/17/12 22:25:
>> PyMOL-users,
>> I'm wondering if there's a way to make the tab completion engine use
>> the currently loaded (or visible) object names rather than (or in
>> addition to) the files in the filesystem?  I usually have sessions
>> with very long object names that I want to include in custom selection
>> expressions and the tab completion doesn't work because oftentimes the
>> PDB files are not in the same directory as the session.  I found the
>> function complete() in modules/pymol/parsing.py that seems to be what
>> figures out how to complete the command that's been entered.  I think
>> if I just added a list of the currently loaded objects to the list
>> obtained by globbing the filesystem, it would do what I'm looking for.
>>  Any ideas on the best way to do that?
>> Best,
>> -Ron
> --
> Thomas Holder
> MPI for Developmental Biology
> Spemannstr. 35
> D-72076 Tübingen

Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to