Does anyone (maybe Jeroen van der Ham, or some other Applescript maven) know how to make BBAutoComplete ( http://c-command.com/bbautocomplete/ ) work with TextMate? (For broad spectrum text autocompletion.)
Thanks!
On 07-08-2005 21:05, Jim Woolum wrote:
Does anyone (maybe Jeroen van der Ham, or some other Applescript maven)
Erm, thanks for that compliment, but I know next to nothing about Applescript ;) I only did a small script for python autocompletion that I still intend to improve.
know how to make BBAutoComplete ( http://c-command.com/bbautocomplete/ ) work with TextMate? (For broad spectrum text autocompletion.)
I haven't tried out this app, it might work with TextMate eventually, but it seems a bit odd to implement this with a seperate (closed source) application. TextMate has almost everything needed in place to make it a breeze to implement this kind of thing, using standard command-line tools or a simple script in your favourite language.
TM already does completion based on the content of the current document. I think this can be overloaded by disabling the default completion and using a command bound to <esc>. We just need to build a small script which generates the candidates and can loop through them. My Python script already has some bits that can do that.
If I have some time I'd like to improve the script and do some better candidate selection from the current document (it only works on the current *saved* document now) and expand that to the documents that are open or part of the project.
Jeroen.
On 7 Aug 2005, at 21:30, Jeroen van der Ham wrote:
On 07-08-2005 21:05, Jim Woolum wrote:
Does anyone know how to make BBAutoComplete (http://c-command.com/ bbautocomplete/ ) work with TextMate? (For broad spectrum text autocompletion.)
I haven't tried out this app, it might work with TextMate eventually, but it seems a bit odd to implement this with a seperate (closed source) application. TextMate has almost everything needed in place to make it a breeze to implement this kind of thing, using standard command- line tools or a simple script in your favourite language.
Exactly, I've never used BBAutoComplete, but TM already has completion support within it, albeit not exactly ideal in every aspect so far. However, it's very much in the planned stage of implementation and improvements. (My words, but I hope Allan would say the same ;-) )
I wrote a version of this for PHP [ www.imediatec.co.uk/tm/phpcc/ ] and the main issues I had, and I guess you will have with creating your own CC stuff are very much collecting and structuring the completion code, and creating a fluid UI for that process.
However, this is an area where I have been hoping that we can all put our brain cells together and devise a single uniformed storage format and code solution that can be reused in any and all bundles/ languages, rather than each language group having their own version. I did my PHPCC stuff in PHP, but is looking more at Ruby & YAML at the moment. I don't really now, but the ideal would be a solution done in a default OS X installed language (PHP/Ruby/Perl/Bash/ Python?) that is fast, lightweight and works with a simple to understand and edit format. Ideally something along the lines of the SVN bundle in sophistication.
If I have some time I'd like to improve the script and do some better candidate selection from the current document (it only works on the current *saved* document now) and expand that to the documents that are open or part of the project.
Soryou (on the IRC) wrote a php completions solution that scanned your current code for class/function declarations - even in included project files, so you might want to check that one out for ideas. Don't remember the URL at the moment.
Kind regards,
Mats
---- "TextMate, coding with an incredible sense of joy and ease" - www.macromates.com -
On 07-08-2005 23:38, Mats Persson wrote:
However, this is an area where I have been hoping that we can all put our brain cells together and devise a single uniformed storage format and code solution that can be reused in any and all bundles/ languages, rather than each language group having their own version. I did my PHPCC stuff in PHP, but is looking more at Ruby & YAML at the moment. I don't really now, but the ideal would be a solution done in a default OS X installed language (PHP/Ruby/Perl/Bash/ Python?) that is fast, lightweight and works with a simple to understand and edit format. Ideally something along the lines of the SVN bundle in sophistication.
For Python it would work best if the script that generates the candidates is written in Python, because of the easy introspection that is possibly within Python. And in general (or at least for higher level programming languages), I think it is easier to generate completion candidates using a program written in that language itself.
What would be beneficial to everyone is a tool that takes a list of candidates and presents these to the user, either one by one using esc or as a popup menu, in which you can select something (or a combination of both).
And perhaps this tool could also be used to select the "standard" candidates, i.e. do some smart grepping of the current file, all open files using extra information such as the location of the cursor. The language specific tools just would need to provide the language specific matches that can't be found using the above grepping technique (such as searching included packages/libraries).
Maybe the standard grepping tool should be the one currently in TM, I don't know.
Jeroen.
On 09/08/2005, at 9.55, Jeroen van der Ham wrote:
For Python it would work best if the script that generates the candidates is written in Python, because of the easy introspection that is possibly within Python.
Except that introspection usually (always?) works with the _current_ program, so the completer would need to somehow load the completee in order to gain any advantage from introspection; unless there is some magic in Python I don't know about. In ruby it would be like this, at least.
-- Sune.
On 09-08-2005 15:35, Sune Foldager wrote:
On 09/08/2005, at 9.55, Jeroen van der Ham wrote:
For Python it would work best if the script that generates the candidates is written in Python, because of the easy introspection that is possibly within Python.
Except that introspection usually (always?) works with the _current_ program, so the completer would need to somehow load the completee in order to gain any advantage from introspection; unless there is some magic in Python I don't know about. In ruby it would be like this, at least.
That's true. What I do in the python completion currently is grab the current line and the import statements. Using that it figures out if the match should come from a library and uses introspection on that library to generate candidates.
Which reminds me, I'd like to be able to provide candidates for 'empty' words as well. The usage scenario would be that someone types the name of the library, followed by a period and then uses <esc> to loop through all the functions defined in there. (if you're too lazy to remember what the name started with, but still know what library it came from).
This currently is not possible because the '.' is a word delimiter and therefore "sys.|" is considered an empty word, while lots of candidates can easily be provided for it.
Jeroen.
Soryou (on the IRC) wrote a php completions solution that scanned your current code for class/function declarations - even in included project files, so you might want to check that one out for ideas. Don't remember the URL at the moment.
http://public.serenity.de/php2/ is the link for this providing the zipped bundle and the readme. I wrote this to complete function names of user defined functions in the same and all included files. (See the readme for details, it works project wide, too)
For the parsing of source files, I use ctags which is able to extract things like function definitions for a variety of programming languages. ctags evolved with vi/vim I believe to jump to certain functions definitions and such in the source code. My command uses it for that purpose, too. ctags in included in osx, at least in Tiger, otherwise it is a sourceforge project.
My code to call and parse the php input and the ctags output is also written in php.
If this thread was mainly about completions of source code for programming, then ctags provides a way to use it across different programming languages. Though I waited to port it any further for tm's plugin architecture and Allan's own planned completion engine.
Except that introspection usually (always?) works with the _current_ program, so the completer would need to somehow load the completee in order to gain any advantage from introspection; unless there is some magic in Python I don't know about. In ruby it would be like this, at least.
One of the 'problems' I had for my php completions is that a user always can do things like include($HOME_DIR."/this.php"). We surely cannot cope with this because the variable is only available at runtime. And I don't know about your ruby or python magic…
Soryu
On 09-08-2005 19:38, soryu2@gmail.com wrote:
One of the 'problems' I had for my php completions is that a user always can do things like include($HOME_DIR."/this.php"). We surely cannot cope with this because the variable is only available at runtime. And I don't know about your ruby or python magic…
This isn't possible in Python. And because the completion command is a python script itself, it has the same environment as the script that is run (if it is run in the same directory, which I make sure it does).
Jeroen.