Hi guys!
I bought TextMate a few days ago, but Python editing is giving me the creeps.
First, I disabled the Auto-pair characters option, but I still get the closing parenthesis and colon when I create a function ("def"). It ignores when I type the closing parenthesis, but it doesn't ignore the colon.
Second, it seems TextMate get really confused when you follow PEP8: If you use spaces instead of tabs, it doesn't do auto-indentation in the next line. In the same issue, it seems TextMate uses tabs instead of spaces (against the PEP8.)
Third, still in the PEP8-issues, I'm trying to find a way to make hard-breaks when going beyond column 78. TextMate have soft-breaks, but I'd really like to have it to automagically insert the break for me (and add an indentation to the next line.)
Fourth, PyCheckMate doesn't understand when you do an indentation when you do a hard-break and add the indentation (it complains about "unexpected indent".)
I guess most of it is easily fixable messing with the Bundle, but I still didn't grasp the whole concept of it. Any points would be really helpful.
On 19 Jun 2008, at 11:48, Julio Biason wrote:
First, I disabled the Auto-pair characters option, but I still get the closing parenthesis and colon when I create a function ("def"). It ignores when I type the closing parenthesis, but it doesn't ignore the colon.
Auto-pair characters works only on (), {}, "", ``, <>, etc. not on colons :.
What do you mean with "but I still get the closing parenthesis and colon when I create a function ("def")" ?
If you type "def" and press TAB it inserts:
def fname(): """docstring for fname""" pass
and with TAB you can jump through the code to modifiy it easily. This has nothing to do with auto-pairing.
I agree that if you are using a template to open a python script it uses TABs instead of SPACEs but this can be changed easily while editing these templates.
Second, it seems TextMate get really confused when you follow PEP8: If you use spaces instead of tabs, it doesn't do auto-indentation in the next line. In the same issue, it seems TextMate uses tabs instead of spaces (against the PEP8.)
Did you set up the doc to use "Soft Tabs"? (status bar > click on Tab size). Then TM does the job.
Third, still in the PEP8-issues, I'm trying to find a way to make hard-breaks when going beyond column 78. TextMate have soft-breaks, but I'd really like to have it to automagically insert the break for me (and add an indentation to the next line.)
To do this automatically while writing could be a bit tricky. But I think of having either a tidy function which will do this or a command like APPLE + \ which will do this for the current line. Up to now you can preset TM to "show the right margin indicator", set the Wrap Column to 79. If you are at the end, press \ and RETURN. TM will indent the next line automatically.
Fourth, PyCheckMate doesn't understand when you do an indentation when you do a hard-break and add the indentation (it complains about "unexpected indent".)
Not for me. Could you please give an example.
--Hans
On 19 Jun 2008, at 12:37, Hans-Joerg Bibiko wrote:
Third, still in the PEP8-issues, I'm trying to find a way to make hard-breaks when going beyond column 78. TextMate have soft-breaks, but I'd really like to have it to automagically insert the break for me (and add an indentation to the next line.)
To do this automatically while writing could be a bit tricky. But I think of having either a tidy function which will do this ...
I just found http://www.lacusveris.com/PythonTidy/PythonTidy-1.16.python which does it quite good. Maybe this could be a good starting point to set up a tidy function.
It can handle TABs, things like "import os, re" etc. The only thing is that it cannot handle long strings. But this can be addded.
--Hans
On Thu, Jun 19, 2008 at 6:37 AM, Hans-Joerg Bibiko bibiko@eva.mpg.de wrote:
On 19 Jun 2008, at 11:48, Julio Biason wrote:
Fourth, PyCheckMate doesn't understand when you do an indentation when you do a hard-break and add the indentation (it complains about "unexpected indent".)
Not for me. Could you please give an example.
I wonder if this was due to Julio mixing tabs and spaces? When editing Python I almost always leave "Show Invisibles" turned on -- I find TextMate's implementation non-intrusive and very helpful in a language where mixing the two can be problematic.
j.
On Thu, Jun 19, 2008 at 8:37 PM, Hans-Joerg Bibiko bibiko@eva.mpg.de wrote:
What do you mean with "but I still get the closing parenthesis and colon when I create a function ("def")" ?
On a Python source file, when I type "def function(" I get a "):" for free. ;)
It seems TextMate understand that it added the ")" automatically (so it just skips it when I press ")"), but not the ":".
If you type "def" and press TAB it inserts:
Well, I'm not using TAB in this case yet.
Did you set up the doc to use "Soft Tabs"? (status bar > click on Tab size). Then TM does the job.
No, I didn't. Well, I just did and it works fine now. Thanks heaps!
To do this automatically while writing could be a bit tricky.
I understand that. It's probably a pain to check strings and such, but I guess doing it with any other command should be fine (Python knows when to keep reading if you left an open bracket somewhere.)
Just to add some more information: Most of my source were edited on Vim on a Linux box. Vim does the hard-breaking stuff, but gets confused when you have a string (it actually breaks the string, which doesn't work as one would expect.)
Fourth, PyCheckMate doesn't understand when you do an indentation when you do a hard-break and add the indentation (it complains about "unexpected indent".)
Not for me. Could you please give an example.
Ok, that's totally my fault. It seems the code is using tabs and I added the line breaks using spaces. "Show invisibles" (as pointed by Jay) shows that yes, I did mix spaces and tabs. Can you guys just forgot that I mentioned that? ;)
On Jun 19, 2008, at 5:44 PM, Julio Biason wrote:
On Thu, Jun 19, 2008 at 8:37 PM, Hans-Joerg Bibiko bibiko@eva.mpg.de wrote:
What do you mean with "but I still get the closing parenthesis and colon when I create a function ("def")" ?
On a Python source file, when I type "def function(" I get a "):" for free. ;)
It seems TextMate understand that it added the ")" automatically (so it just skips it when I press ")"), but not the ":".
Hm... This is a bit strange. It should skip past both the ) and the : when you press ). Are you using the cutting edge version of textmate?
Also, you can just press ⌥ ↩ at any point in the line to go to the next line. So if you were intending to press enter after you pressed :, just type ⌥↩ and you'll save a couple of keystrokes.
On Fri, Jun 20, 2008 at 11:43 AM, Alex Ross ajross@cs.pdx.edu wrote:
Hm... This is a bit strange. It should skip past both the ) and the : when you press ). Are you using the cutting edge version of textmate?
I think so. About says "Version 1.5.7 (1464)" and the Auto-update is set to "Bleeding edge".
On Jun 19, 2008, at 8:25 PM, Julio Biason wrote:
On Fri, Jun 20, 2008 at 11:43 AM, Alex Ross ajross@cs.pdx.edu wrote:
Hm... This is a bit strange. It should skip past both the ) and the : when you press ). Are you using the cutting edge version of textmate?
I think so. About says "Version 1.5.7 (1464)" and the Auto-update is set to "Bleeding edge".
Is there a macro in the Python bundle called “Inside Parameter List: Overtype Closing ):”. This is the macro that should fire when you overtype the closing parenthesis in a parameter list.
It's possible that you have an old python bundle in ~/Library/ Application Support/TextMate/Bundles/. That could be overriding the python grammar, or this macro. If you have such a bundle, it is ok to move or delete it (though you'll lose any of your customizations to the bundle).
–Alex
On Fri, Jun 20, 2008 at 3:55 PM, Alex Ross ajross@cs.pdx.edu wrote:
Is there a macro in the Python bundle called "Inside Parameter List: Overtype Closing ):". This is the macro that should fire when you overtype the closing parenthesis in a parameter list.
It's possible that you have an old python bundle in ~/Library/ Application Support/TextMate/Bundles/.
Nope, nothing there. I have a "Pristine Copy" with a bundle for Bazaar and a "Themes" directory.
But I'll probably edit it and remove the macro ;)