Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to implement Python code-completion in TextMate?
    primarykey
    data
    text
    <p><a href="http://github.com/orestis/pysmell/tree/master" rel="nofollow noreferrer">PySmell</a> seems like a good starting point.</p> <p>I think it should be possible, PySmell's <code>idehelper.py</code> does a majority of the complex stuff, it should just be a case of giving it the current line, offering up the completions (the bit I am not sure about) and then replacing the line with the selected one.</p> <pre><code>&gt;&gt;&gt; import idehelper &gt;&gt;&gt; # The path is where my PYSMELLTAGS file is located: &gt;&gt;&gt; PYSMELLDICT = idehelper.findPYSMELLDICT("/Users/dbr/Desktop/pysmell/") &gt;&gt;&gt; options = idehelper.detectCompletionType("", "" 1, 2, "", PYSMELLDICT) &gt;&gt;&gt; completions = idehelper.findCompletions("proc", PYSMELLDICT, options) &gt;&gt;&gt; print completions [{'dup': '1', 'menu': 'pysmell.pysmell', 'kind': 'f', 'word': 'process', 'abbr': 'process(argList, excluded, output, verbose=False)'}] </code></pre> <p>It'll never be perfect, but it would be extremely useful (even if just for completing the stdlib modules, which should never change, so you wont have to constantly regenerate the PYSMELLTAGS file whenever you add a function)</p> <hr> <p>Progressing! I have the utter-basics of completion in place - barely works, but it's close..</p> <p>I ran <code>python pysmells.py /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/*.py -O /Library/Python/2.5/site-packages/pysmell/PYSMELLTAGS</code></p> <p>Place the following in a TextMate bundle script, set "input: entire document", "output: insert as text", "activation: key equivalent: alt+esc", "scope selector: source.python"</p> <pre><code>#!/usr/bin/env python import os import sys from pysmell import idehelper CUR_WORD = os.environ.get("TM_CURRENT_WORD") cur_file = os.environ.get("TM_FILEPATH") orig_source = sys.stdin.read() line_no = int(os.environ.get("TM_LINE_NUMBER")) cur_col = int(os.environ.get("TM_LINE_INDEX")) # PYSMELLS is currently in site-packages/pysmell/ PYSMELLDICT = idehelper.findPYSMELLDICT("/Library/Python/2.5/site-packages/pysmell/blah") options = idehelper.detectCompletionType(cur_file, orig_source, line_no, cur_col, "", PYSMELLDICT) completions = idehelper.findCompletions(CUR_WORD, PYSMELLDICT, options) if len(completions) &gt; 0: new_word = completions[0]['word'] new_word = new_word.replace(CUR_WORD, "", 1) # remove what user has already typed print new_word </code></pre> <p>Then I made a new python document, typed "import urll" and hit alt+escape, and it completed it to "import urllib"!</p> <p>As I said, it's entirely a work-in-progress, so don't use it yet..</p> <hr> <p><em>Last update:</em></p> <p>orestis has integrated this into the PySmell project's code! Any further fiddling will happen <a href="http://github.com/orestis/pysmell/tree/master" rel="nofollow noreferrer">on github</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload