I would like to add a couple of things (at least), but I'm afraid I need some clarifications... I need a disassembler command, it's just import dis dis.dis(module)
or dis.dis(function) or dis.dis(object)
Maybe I need a menu to let it know what I want to disassemble..
I tried something like this:
MOD_NAME=${TM_FILENAME%.py} cd $TM_CURRENT_DIR && python -c "import dis; import os; os.chdir(os.environ['TM_CURRENT_DIR']); print "Now in", os.getcwd(); import $MOD_NAME; dis.dis($MOD_NAME)"; cd -
But it doesn't change dir at all, what am I missing?
Another nice command would be execute line/selection as python, should I use eval? I found that tm_helpers give me some nice functions, other sources of "helpers"?
Last command is pylint "integration", this is alreadly not too bad
pylint $TM_FILEPATH 2>/dev/null | tail -n 2
It just gives me the score of my source code, but a better rappresentation in html format could be better...
Thanks a lot
On 2008-Dec-29, at 5:45 AM, Andrea Crotti wrote:
I would like to add a couple of things (at least), but I'm afraid I need some clarifications... I need a disassembler command, it's just import dis dis.dis(module)
or dis.dis(function) or dis.dis(object)
Maybe I need a menu to let it know what I want to disassemble..
What about something based on current word, so you could select (or type) something then invoke the command? Note that commands don't have to be shell scripts. You can use Python directly, if that's the language that'll do the work. Assuming you had a command that took either Selection or Word as input, it could do something like this:
#!/usr/bin/env python import sys import dis module = [line.rstrip() for line in sys.stdin.readlines()][0] dis.dis(module)
You could also get environment variables using Python (os.environ['TM_BLAH']) if you prefer that to using STDIN.
But it doesn't change dir at all, what am I missing?
I don't see a TM_CURRENT_DIR, but I do see TM_DIRECTORY. Could that be it? In any case, aren't you just switching to the current directory which, by definition, won't change anything?
Another nice command would be execute line/selection as python, should I use eval?
What about a command that uses Selection or Line as input and just runs
${TM_PYTHON:-python}
This is equivalent to echoing the current line and piping it to python on the command line, which seems to work. Maybe you're wanting something fancier.
Rob McBroom wrote:
On 2008-Dec-29, at 5:45 AM, Andrea Crotti wrote:
I would like to add a couple of things (at least), but I'm afraid I need some clarifications... I need a disassembler command, it's just import dis dis.dis(module)
or dis.dis(function) or dis.dis(object)
Maybe I need a menu to let it know what I want to disassemble..
What about something based on current word, so you could select (or type) something then invoke the command? Note that commands don't have to be shell scripts. You can use Python directly, if that's the language that'll do the work. Assuming you had a command that took either Selection or Word as input, it could do something like this:
#!/usr/bin/env python import sys import dis module = [line.rstrip() for line in sys.stdin.readlines()][0] dis.dis(module)
You could also get environment variables using Python (os.environ['TM_BLAH']) if you prefer that to using STDIN.
But it doesn't change dir at all, what am I missing?
I don't see a TM_CURRENT_DIR, but I do see TM_DIRECTORY. Could that be it? In any case, aren't you just switching to the current directory which, by definition, won't change anything?
Another nice command would be execute line/selection as python, should I use eval?
What about a command that uses Selection or Line as input and just runs
${TM_PYTHON:-python}
This is equivalent to echoing the current line and piping it to python on the command line, which seems to work. Maybe you're wanting something fancier.
-- Rob McBroom http://www.skurfer.com/
Because it screws up the order in which people normally read text.
Original message:
Why is it bad to top-post your reply?
-- Rob McBroom http://www.skurfer.com/
Because it screws up the order in which people normally read text.
Original message:
Why is it bad to top-post your reply?
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Thanks a lot Rob, I have another problem, the thing #!/usr/bin/env python
import dis from os import environ mod = environ['TM_FILENAME'].split('.')[0] dis.dis(mod)
Doesn't work because I also need to import mod, but if I put also import mod, of course it doesn't work as it's not substituted the variable value in the import statement.
I also tried with python -c << EOF etc etc EOF but without success..
On 2008-Dec-29, at 3:41 PM, Andrea Crotti wrote:
Thanks a lot Rob, I have another problem, the thing #!/usr/bin/env python
import dis from os import environ mod = environ['TM_FILENAME'].split('.')[0] dis.dis(mod)
Doesn't work because I also need to import mod, but if I put also import mod, of course it doesn't work as it's not substituted the variable value in the import statement.
This seemed to work with the limited testing I did:
exec('import ' + mod)
Just insert that before the call to dis.dis().
You can avoid ugly exec()s if you use __import__: http://docs.python.org/library/functions.html#__import__
On Tue, Dec 30, 2008 at 10:55 AM, Rob McBroom textmate@skurfer.com wrote:
On 2008-Dec-29, at 3:41 PM, Andrea Crotti wrote:
Thanks a lot Rob, I have another problem, the thing #!/usr/bin/env python
import dis from os import environ mod = environ['TM_FILENAME'].split('.')[0] dis.dis(mod)
Doesn't work because I also need to import mod, but if I put also import mod, of course it doesn't work as it's not substituted the variable value in the import statement.
This seemed to work with the limited testing I did:
exec('import ' + mod)
Just insert that before the call to dis.dis().
-- Rob McBroom http://www.skurfer.com/
Because it screws up the order in which people normally read text.
Original message:
Why is it bad to top-post your reply?
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate