I'm a new user and I don't have a Unix background, so I am struggling with Section 21.1. in the manual.
I am attempting to use TextMate as an external editor.
1. It works fine with my various Cocoa apps, with the shortcut showing up in the Edit menu. No problems here.
2. I need to use TextMate with Tinderbox (a non Cocoa app). Users on the Tinderbox forum have various ways of doing this, either using the "mate" command in Terminal, or using a variety of ways of calling this command.
However, my problem is that I cannot get commands via terminal to import text, or save it back. "mate -h" does bring up a menu of commands, so that much is working. Quite likely, this is owing to my lack of experience with the command line.
I have read and re-read section 21.1. but it assumes a familiarity with Unix and CL operation which is new ground to me.
I would really appreciate a *simple*, assuming-nothing, explanation of what I need to do to copy contents of a window from my non-Cocoa app (Tinderbox) into TextMate, and then back again -- presumably using some variant of the "mate" command via Terminal.
On Dec 31, 2010, at 7:13 AM, Ian Greig wrote:
However, my problem is that I cannot get commands via terminal to import text, or save it back. "mate -h" does bring up a menu of commands, so that much is working. Quite likely, this is owing to my lack of experience with the command line.
I have no idea what Tinderbox is doing, but I almost always need to use the `--wait` option to the `mate` command when external programs are calling it. In the part of the manual you referenced, it talks about making a link called `mate_wait` to trigger the wait option automatically. You might try that.
Ian Greig wrote:
- ...TextMate... works fine with my various Cocoa apps, with the shortcut
showing up in the Edit menu.
- ...My problem is that I [still] cannot get the "mate" or variants via
terminal to import text, or save it back. "
The CL "mate" -- with a window in the other app foremost and text selected -- brings up an empty window.
Sometimes I get the message in Terminal to enter ^D. That seems to freeze it.
Any further suggestions?
On 3 Jan 2011, at 21:25, Ian Greig wrote:
Ian Greig wrote:
- ...TextMate... works fine with my various Cocoa apps, with the shortcut
showing up in the Edit menu.
- ...My problem is that I [still] cannot get the "mate" or variants via
terminal to import text, or save it back. "
I did a quick Google to find out what Tinderbox is, and this application does not appear to support external editors, nor is it Cocoa, so our “hacks” (like Edit in TM) does not work with it.
One user basically has a copy/paste macro to move the content: http://www.eastgate.com/Tinderbox/forum/YaBB.pl?num=1267305035
I suggest you contact the Tinderbox authors to request support for external editors (e.g. via the ODB Editor Suite).
Allan Odgaard-4 wrote: ....our “hacks” (like Edit in TM) does not work with [Tinderbox]. One user basically has a copy/paste macro to move the content: http://www.eastgate.com/Tinderbox/forum/YaBB.pl?num=1267305035 I suggest you contact the Tinderbox authors to request support for external editors (e.g. via the ODB Editor Suite).
= = = = = =
I have initiated a fair amount of discussion on the Tinderbox forum, including the developer, who considers that this is a TextMate issue. I am aware that TextMate is not a Cocoa application.
Thanks for the link to Stephen Wu's post, which I had forgotten -- the copy and paste macros should work OK.
The "mate" command question Another way devised by Tinderbox users involves using a macro to call the "mate" command. That brings me full circle. I do not seem to be able to make this work, even by invoking the command line directly in Terminal. I would like some help with this please.
ODB Editor Suite question Could someone explain the ODB Editor Suite and whether this is a way forward for a non-Cocoa application?
On Jan 3, 2011, at 4:39 PM, Ian Greig wrote:
The "mate" command question Another way devised by Tinderbox users involves using a macro to call the "mate" command. That brings me full circle. I do not seem to be able to make this work, even by invoking the command line directly in Terminal. I would like some help with this please.
Are you just running `mate` with no options or anything? All that will do is launch TextMate (or bring it to the front if it's already running). To get anything useful, you'd do something like this on the command line:
mate filename.txt
or
some_other_command | mate
The second example will open a new document with the output from some_other_command as its contents, which is kinda what you want but not really. The initial command has no idea where the text went and isn't waiting to get it back modified.
ODB Editor Suite question Could someone explain the ODB Editor Suite and whether this is a way forward for a non-Cocoa application?
Allan would probably have a better answer, but I'll try. I believe it's become a de facto standard way for programs to send something to an editor, but also notice when the editor is done with the text so they can take further action. It's used almost exclusively by command line tools as far as I know. It's not related to Cocoa, but is definitely a way for non-Cocoa applications to make use of TextMate.
On 2011-01-03 16:39, Ian Greig wrote:
The "mate" command question Another way devised by Tinderbox users involves using a macro to call the "mate" command. That brings me full circle. I do not seem to be able to make this work, even by invoking the command line directly in Terminal. I would like some help with this please.
I know nothing about Tinderbox, but that's not going to keep me from jumping in here...
The very first thing you have to do is to install the 'mate' command. You say that you "do not seem to be able to make this work, even by invoking the command line directly in Terminal." That suggests to me that this first step has not been taken. Refer to the blog posting at http://blog.macromates.com/2005/textmate-shell-utility-tmmate/ for details, but you'll need to execute these commands:
mkdir ~/bin ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate
There are other niceties too, but that's the basics. Now type '~/bin/mate /tmp/test' at the Terminal command line. Does it open a new Textmate window editing the file /tmp/test? If so, congratulations! You're halfway there.
In general, there are two ways to invoke 'mate' as an external editor. The first is as described above, by having Tinderbox (or whatever other app) write a temporary file and calling 'mate' to edit it. You'll probably want to give 'mate' the '--wait' option. Without that option, the Textmate window is opened and control immediately returns to the caller. Unfortunately, that's the end of the transaction. There's no way for the calling program to know when you're done editing. The '--wait' option tells 'mate' not to return control to the caller until you've closed the window. This will signal the calling program that it's time to read the temp file back in to get your changes.
To do it this way you'll need to write a macro in Tinderbox that does this:
save to /tmp/filename mate --wait /tmp/filename load /tmp/filename
Since I don't know anything about Tinderbox I'm afraid I can't be any more specific.
The second way to use 'mate' as an external editor is similar, but instead of writing to a temporary file you feed the file to mate on its standard input and read the changes back from its standard output. "Standard input" (stdin) and "standard output" (stdout) are generic Unix terms meaning "what the program reads in from the Terminal" and "what it writes back to the Terminal". Only, "Terminal" doesn't have to literally be Terminal.app, it can be any other program. If you run the command 'ls | less' at the Terminal prompt you're using the pipe ("|") character to send the standard output of the 'ls' command to the standard input of the 'less' command, instead of sending the output of 'ls' directly back to the Terminal window. Piping stdout from one program to the stdin of another is the fundamental basis of almost all Unix command-line programing. You can chain any number of commands together this way. Try typing: 'echo "hello, world" | mate --wait | less' to see what I mean.
To apply this to Tinderbox you'll need to tell it to write to mate's standard input and read from mate's standard output. Again, I don't know what the syntax would be as a Tinderbox macro, but conceptually something like:
mate --wait write file to mate's stdin read file from mate's stdout
I can't give you cookie-cutter directions, but hopefully this gives you enough understanding of what's going on to figure the rest out yourself.
Another solution is now available. HogBay Software's QuickCursor 2 is in the app store. It uses the accessibility API to send text to a text editor and back. It works great with TextMate (and you can assign a keyboard shortcut for each text editor). I've tried it with Tinderbox, and the round trip between Tinderbox and TextMate works fine.
Penny
On Jan 3, 2011, at 3:57 PM, Allan Odgaard wrote:
On 3 Jan 2011, at 21:25, Ian Greig wrote:
Ian Greig wrote:
- ...TextMate... works fine with my various Cocoa apps, with the shortcut
showing up in the Edit menu.
- ...My problem is that I [still] cannot get the "mate" or variants via
terminal to import text, or save it back. "
I did a quick Google to find out what Tinderbox is, and this application does not appear to support external editors, nor is it Cocoa, so our “hacks” (like Edit in TM) does not work with it.
One user basically has a copy/paste macro to move the content: http://www.eastgate.com/Tinderbox/forum/YaBB.pl?num=1267305035
I suggest you contact the Tinderbox authors to request support for external editors (e.g. via the ODB Editor Suite).
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate