Hi,
I 'finished' the recoding of TMTOOLS. If someone has a bit time please give me a feedback about the functionality, bugs, wishes, etc. Please note: The version 0.9 is still beta, i.e. please be careful while testing it. By myself I use it every day while working, and it helps me a lot; at least for me ;)
I also wrote a tentative help file for it very quickly.
To install the plug-in download it, uncompress it, and double-click it.
http://email.eva.mpg.de/~bibiko/downloads/textmate/ TMTools.tmplugin.zip (111kB)
(it should be universal - if not please give me a hint)
For help have a look at this page (utf-8 encoded!)
http://email.eva.mpg.de/~bibiko/downloads/textmate/tmtoolshelp.html
or type in an empty TM document (after installing ;):
"$TMTOOLS" help me
and press CTRL+R
A short demo: http://www.bibiko.de/TMTOOLS_demo_01.mov (10MB)
Up to now TMTOOLS contains 106 shell commands which interact with TM.
some examples: "$TMTOOLS" get windowOriginAndSize "$TMTOOLS" get currentWord '{only=tail;delimiter=" ():.";}' "$TMTOOLS" set spellCheckerLanguage '{to=en_GB;}' "$TMTOOLS" set windowSize '{width=100;height=200;}' "$TMTOOLS" set grammar '{to="Ruby";}' "$TMTOOLS" call template '{name="From Clipboard";}' "$TMTOOLS" show projectDrawer '{onEdge=0;}' "$TMTOOLS" complete usingDictionary '{lang="da";showInternalListFirst=yes;}' "$TMTOOLS" use nsstring '{initWith="たてもの"; toGet="canBeConvertedToEncoding:"; with="8"; }'
The command "$TMTOOLS" do onKeyDownAfterDelay is still experimental. I tested it a lot, and it works. This command installs an event manager which will execute any shell command after a delay of X seconds if no other keyDown event occurs within X seconds. The following example will save the current document in /tmp after 5sec if there is no further key pressed. (A kind of AutoSave function while non-typing) If one presses ESC (stopkey=53) one destroys that event handler. For more details see help. Furthermore it can be used to display suggestions for the code completion à la XCODE (see demo).
"$TMTOOLS" do onKeyDownAfterDelay "{ delay="5"; repeat=no; startAtCall=no; shell='"$TMTOOLS" get textString > /tmp/"$TM_FILENAME ".txmtbkp;say "document was saved"'; stopkey=53; }"
Best,
Hans
On Oct 9, 2007, at 12:34 PM, Hans-Jörg Bibiko wrote:
I 'finished' the recoding of TMTOOLS. If someone has a bit time please give me a feedback about the functionality, bugs, wishes, etc. Please note: The version 0.9 is still beta, i.e. please be careful while testing it. By myself I use it every day while working, and it helps me a lot; at least for me ;)
Wow, This is incredible! I can hardly wait to start fiddling with this puppy.
Do you have this under subversion or anything yet? I would love this to be a part of bundleforge.
Do you have some commands and stuff that you've created to work with your plugin? I'd love to see how you're using this thing in real life.
Also, is there anything in here for handling selections? Or something to do a regex search? I'd love to be able to initiate a regex search in textmate with a dynamically generated search string. I could then do some fancy footwork to intelligently set your selection.
Thanks!!1!
—Thomas Aylott – subtleGradient—
On 09.10.2007, at 23:21, Thomas Aylott wrote:
On Oct 9, 2007, at 12:34 PM, Hans-Jörg Bibiko wrote:
I 'finished' the recoding of TMTOOLS. If someone has a bit time please give me a feedback about the functionality, bugs, wishes, etc. Please note: The version 0.9 is still beta, i.e. please be careful while testing it. By myself I use it every day while working, and it helps me a lot; at least for me ;)
Wow, This is incredible! I can hardly wait to start fiddling with this puppy. Do you have this under subversion or anything yet? I would love this to be a part of bundleforge.
Not yet. I want to wait a bit for the very first feedbacks (bug fixing) and maybe for TM 2.0 (syntax fixing).
Do you have some commands and stuff that you've created to work with your plugin?
Yes.
You saw in the demo a window showing the current scopes. It's quite useful for writing a grammar and for linguistic stuff.
Then the command (bound to TAB): "$TMTOOLS" goto nextSnippetField "$TMTOOLS" call command '{name="showAsList";}'
whereby showAsList is a normal bundle command which does from a selected string à la 'yes|no' an inline menu. E.g. the XSL bundle snippets are written in such a style to give an hint for possible values etc.
For me it is often the case that I have to deal with 3 or 4 files at same time and I want to see all files at my screen. So I wrote a tmCommand which opens these files and resize/locate them on my screen automatically.
My favorite is the "$TMTOOLS" complete ... stuff (Many thanks to Joachim Mårtensson)
or
-call the tmCommand "Create HTML From Document / Selection" -replace the font-size:xxpt with my font size in the HTML code by using a macro -showWebPreview
and and and and ... Maybe it would be the best that I put some of my stuff as examples in a TMTOOLSexamples bundle.
Also, is there anything in here for handling selections?
Yes: 1) set the caret to a specific point "$TMTOOLS" set caretTo '{line=2;index=4;}' 2) from the set caret location you can select to the end of line 3 "$TMTOOLS" set selectionTo '{line=3;column=end;}'
or use a dynamic generated macro for that à la: "$TMTOOLS" call macro '{ commands = ( {command = "moveWordRight:"; }, {command = "moveWordLeftAndModifySelection:"; }, {command = "moveWordLeftAndModifySelection:"; }, {command = "moveWordLeftAndModifySelection:"; } ); }'
and read the help file additionally. Remember you can create each PLIST content dynamically by using Ruby, bash, Perl etc. and you can call a system command with "$TMTOOLS" from inside of each Ruby, Perl, ... script!
Or something to do a regex search? I'd love to be able to initiate a regex search in textmate with a dynamically generated search string. I could then do some fancy footwork to intelligently set your selection.
This is quite easy. Have a look at TMTOOLS help file - item 3.5.4 "$TMTOOLS" call macro PLIST second example. Generate a plist and pipe it to $TMTOOLS" call macro - [the hyphen is important to read on STDIN; look at item 3.1.1 second example for the syntax] The best starting point is to record a macro for a regexp search and have a look at this macro. Then you can use it as template for "$TMTOOLS" call macro PLIST.
Hans
On 09.10.2007, at 23:55, Piero D'Ancona wrote:
Hans-Jörg Bibiko <bibiko@...> writes:
Hi,
I 'finished' the recoding of TMTOOLS...
Unbelievable! Thank you
In my tests the caret (and selection) moving commands are quite slow (1 sec), is it the regular behaviour?
I'm still working on that. 'Slow' is maybe not the correct term for it. To set the caret and selection works quite fast but you see it a bit later caused by the refresh (I guess). If you try the tmCommand e.g.:
"$TMTOOLS" set caretTo '{line=2;index=4;}' "$TMTOOLS" set selectionTo '{line=20;column=3;}' echo "BBB"
output: replace selected text
you should see that it works faster than without echo "BBB".
Give me a bit time, maybe I find a way to speed up the refreshing.
Hans
Concerning onKeyDownAfterDelay: how difficult would it be to add a command which intercepts KeyDown and also understands what key has been pressed? i.e. returns the key pressed, or performs an action only if the key belongs to a certain list
Piero
On 10 Oct 2007, at 13:45, Piero D'Ancona wrote:
Concerning onKeyDownAfterDelay: how difficult would it be to add a command which intercepts KeyDown and also understands what key has been pressed? i.e. returns the key pressed, or performs an action only if the key belongs to a certain list
In principal is this possible. Maybe à la
"$TMTOOLS" do onKeyDownAfterDelay '{ keylist={ a=A_SHELLCOMMAND; b=AN_OTHER_SHELLCOMMAND; }; passEvent=yes;}'
One question would be: Why only on a single keyDown event? What do you want to do?
The only thing I have in my mind is a kind of input method editor to simplify the typing of accented characters for instance. I write 'fac' ; I wait a bit and than I see a list of all 'c' with diacritics: çćĉċčƈɕḉ⒞ⓒc̷
On the other hand I could image that it would be useful to look for the current word and depending on it to do something. Example: the do onKeyDownAfterDelay command checks TM_CURRENT_WORD; if TM_CURRENT_WORD is 'btw' it will fire a shell script which replaces 'btw' by 'by the way' automatically. -> if I type fluently 'btw I want ...' -> nothing happens, but if I type 'btw' and waits for the given time it replaces 'btw' with 'by the way'.
Hans
Hans-Joerg Bibiko <bibiko@...> writes:
Maybe à la
"$TMTOOLS" do onKeyDownAfterDelay '{ keylist={ a=A_SHELLCOMMAND; b=AN_OTHER_SHELLCOMMAND; }; passEvent=yes;}'
Exactly. I was thinking of a triggering mechanism where you can use multiple key combos: e.g. CTRL-R in LaTeX means 'run', when I press it a drop down menu appears (after a delay) like b = bibtex l = latex p = plain x = xetex so for instance CTRL-R + B runs bibtex. If I press CTRL-R+B quickly the menu does not appear and bibtex runs directly.
A better example: CTRL-D = delimiters When I press CTRL-D the command waits for a delimiter (menu after a delay). CTRL-D + ( -> a menu with a list of sizes appears: 1 = \left(...\right) 2 = \bigl(...\bigr) So in the end CTRL-D + ( + 2 produces \bigl(...\bigr)
Ok, just an idea... Piero
On 10 Oct 2007, at 19:29, Piero D'Ancona wrote:
I was thinking of a triggering mechanism where you can use multiple key combos: e.g. CTRL-R in LaTeX means 'run', when I press it a drop down menu appears (after a delay) like b = bibtex l = latex p = plain x = xetex so for instance CTRL-R + B runs bibtex. If I press CTRL-R+B quickly the menu does not appear and bibtex runs directly.
A better example: CTRL-D = delimiters When I press CTRL-D the command waits for a delimiter (menu after a delay). CTRL-D + ( -> a menu with a list of sizes appears: 1 = \left(...\right) 2 = \bigl(...\bigr) So in the end CTRL-D + ( + 2 produces \bigl(...\bigr)
Well, in principal would it be possible to write such a command. A general approach would be to write a normal tmCommand which is bound to e.g. CTRL-R. In that tmCommand one could write a TMTOOLS command "do waitForNextKeyDown '{time=2;}' ". waitForNextKeyDown waits for the next key and gives back the pressed key code. If no key was pressed for 2 seconds it gives you back -1. After having the pressed key code you can dispatch the task in the normal tmCommand. One thing is missing: a inline menu which will listen to a key and 'not only' for numbers 1 to 9.
But I don't know whether this feature is an issue for a plug-in. If one write such a command for e.g. the LaTex bundle and other users wants to use it they have to install that plug-in for invoking a command. I want to say the key binding stuff is an internal TM issue, not a circumferential one, at least by my opinion.
Hans
Hans-Joerg Bibiko wrote:
Well, in principal would it be possible to write such a command. A general approach would be to write a normal tmCommand which is bound to e.g. CTRL-R. In that tmCommand one could write a TMTOOLS command "do waitForNextKeyDown '{time=2;}' ". waitForNextKeyDown waits for the next key and gives back the pressed key code. If no key was pressed for 2 seconds it gives you back -1. After having the pressed key code you can dispatch the task in the normal tmCommand. One thing is missing: a inline menu which will listen to a key and 'not only' for numbers 1 to 9.
But I don't know whether this feature is an issue for a plug-in. If one write such a command for e.g. the LaTex bundle and other users wants to use it they have to install that plug-in for invoking a command. I want to say the key binding stuff is an internal TM issue, not a circumferential one, at least by my opinion.
You can do this with the Cocoa text key binding system, fairly easily, and the result will be usable in all Cocoa apps (without the menu though).