Hi,
I'm just beginning to like Python ;)
Caused by that issue here are some tiny suggestions:
Walter Dörwald had the idea to provide exit codes similar to Ruby's exit_codes.rb.
This could be integrate in tm_helpers.py à la:
def exit_discard(): sys.exit(200)
def exit_replace_text(out = ''): if out: print out sys.exit(201)
def exit_replace_document(out = ''): if out: print out sys.exit(202)
def exit_insert_text(out = ''): if out: print out sys.exit(203)
def exit_insert_snippet(out = ''): if out: print out sys.exit(204)
def exit_show_html(out = ''): if out: print out sys.exit(205)
def exit_show_tool_tip(out = ''): if out: print out sys.exit(206)
def exit_create_new_document(out = ''): if out: print out sys.exit(207)
Furthermore tm_helpers' sh(cmd) is not UTF-8 safe. If I'm using e.g. popen("grep 'ä' 'test.txt'") or tm_helpers.sh("grep 'ä' 'test.txt'") I have problems with the codec. I tried several things to encode/decode unicode but no success. Maybe some of you can fix this. I went the way to use popen2. Then I didn't have such problems (?)
The next issue is regarding dialog.py. Maybe one could the function 'menu' looking for DIALOG2. If there's DIALOG2 it uses that syntax, if not fall back to DIALOG1. This could also be done for Ruby's ui.rb.
Cheers,
--Hans
On 5 Jun 2008, at 19:29, Hans-Jörg Bibiko wrote:
Walter Dörwald had the idea to provide exit codes similar to Ruby's exit_codes.rb.
This could be integrate in tm_helpers.py à la: [...]
It’s about time Python saw some love with regard to TM convenience functions :)
One thing I have learned from all the work put into the ruby support stuff is the importance of style guides, and that one should use all the module/namespace support from the language to keep it clear what is what, which stuff uses what, etc.
So before piling stuff into tm_helpers.py, one should consider these things.
I will work out some style guides for ruby, though not sure exactly when, but that might serve as inspiration. For the curious, in TM 2 we will effectively create a new Support folder which has a more clear structure and less noise. Old commands will continue to see the old Support folder, but new commands will see the new one, so we can do a safe migration (technically this can be done by simple setting TM_SUPPORT_PATH based on the version found in the bundle item’s property list).
Furthermore tm_helpers' sh(cmd) is not UTF-8 safe. If I'm using e.g. popen("grep 'ä' 'test.txt'") or tm_helpers.sh("grep 'ä' 'test.txt'") I have problems with the codec.
If you embed non-ASCII in a python string, you must prefix it with u. That said, can you paste a more full example showing the problem?
On Jun 11, 2008, at 3:14 PM, Allan Odgaard wrote:
It’s about time Python saw some love with regard to TM convenience functions :)
One thing I have learned from all the work put into the ruby support stuff is the importance of style guides, and that one should use all the module/namespace support from the language to keep it clear what is what, which stuff uses what, etc.
So before piling stuff into tm_helpers.py, one should consider these things.
I will work out some style guides for ruby, though not sure exactly when, but that might serve as inspiration. For the curious, in TM 2 we will effectively create a new Support folder which has a more clear structure and less noise. Old commands will continue to see the old Support folder, but new commands will see the new one, so we can do a safe migration (technically this can be done by simple setting TM_SUPPORT_PATH based on the version found in the bundle item’s property list).
We can create a python module that mimics the ruby module for sure. We could even create a python module parallel to the TextMate module, even using the same directories since ruby should just ignore the python files and vice versa.
On 12 Jun 2008, at 01:06, Alex Ross wrote:
On Jun 11, 2008, at 3:14 PM, Allan Odgaard wrote:
It’s about time Python saw some love with regard to TM convenience functions :)
One thing I have learned from all the work put into the ruby support stuff is the importance of style guides, and that one should use all the module/namespace support from the language to keep it clear what is what, which stuff uses what, etc.
So before piling stuff into tm_helpers.py, one should consider these things.
I will work out some style guides for ruby, though not sure exactly when, but that might serve as inspiration. For the curious, in TM 2 we will effectively create a new Support folder which has a more clear structure and less noise. Old commands will continue to see the old Support folder, but new commands will see the new one, so we can do a safe migration (technically this can be done by simple setting TM_SUPPORT_PATH based on the version found in the bundle item’s property list).
We can create a python module that mimics the ruby module for sure. We could even create a python module parallel to the TextMate module, even using the same directories since ruby should just ignore the python files and vice versa.
I agree. It would be very helpful to be consistent of naming modules/ functions for Ruby/Python etc. above all if you are coding in these languages.
--Hans