-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
For the last 7-8 weeks I've been trying to retrain myself to not use ctrl-k/ctrl-y. Apparently it cannot be done. I've spent more time undoing the crazy results of ctrl-k followed by ctrl-y than I care to talk about.
I've tried the macro route, and I now understand that macros have their own clipboards, which explains why the text that I cut inside the macro just dissappears forever.
As suggested by someone on this list earlier (back in November), I've created a macro to select to end of line, followed by a command that cats the selected text into a temp file, and I've put both of those little commands inside yet another macro bound to ctrl-k. I've bound ctrl-y to a macro that cats the file into the current buffer. The problem with this approach is that now ctrl-k / ctrl-y have their own private little clipboard. so ctrl-y can't paste anything from the system clipboard or a 'regular' cut/paste.
Does anybody have a better solution to this problem yet? I'm so happy with so many things about TextMate, and I have paid the license fee, but this morning I found myself trying out other editors again :-(
Thanks,
Brad
Brad Miller, PhD Assistant Professor Luther College http://www.cs.luther.edu/~bmiller jabber: bnmnetp@jabber.org
On Jan 18, 2005, at 16:49, Brad Miller wrote:
[...] so ctrl-y can't paste anything from the system clipboard or a 'regular' cut/paste.
You can get the contents of the clipboard with 'pbpaste' and store stuff on it with 'pbcopy' (they use stdin/stdout). Unfortunately they do not use UTF-8. But maybe you can make a better solution than your current (i.e. one that use/interact with the “real” clipboard) until I get around to native support for kill-buffers.
Thanks,
No I'm very confused.... I tried substituting
pbcopy for cat > "/tmp/fakeKill" and pbpaste for cat "/tmp/fakeKill"
in my two commands, which work fine except for the lack of compatibility with the clipboard. Sadly, when I run the pbpaste command I just get a spinning beach ball for about 30 seconds and then nothing gets pasted.
I tried running pbpaste from the command line, just to see if the pbcopy part was working, and the copy part appears to work when I create the macro, but when I test it it does not work anymore. It does not seem like the selectToEnd of line part is working....
Any ideas?
Thanks,
Brad
On Jan 18, 2005, at 10:08 AM, Allan Odgaard wrote:
On Jan 18, 2005, at 16:49, Brad Miller wrote:
[...] so ctrl-y can't paste anything from the system clipboard or a 'regular' cut/paste.
You can get the contents of the clipboard with 'pbpaste' and store stuff on it with 'pbcopy' (they use stdin/stdout). Unfortunately they do not use UTF-8. But maybe you can make a better solution than your current (i.e. one that use/interact with the “real” clipboard) until I get around to native support for kill-buffers.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brad Miller, PhD Assistant Professor Luther College http://www.cs.luther.edu/~bmiller jabber: bnmnetp@jabber.org
On Jan 19, 2005, at 1:29, Brad Miller wrote:
Sadly, when I run the pbpaste command I just get a spinning beach ball for about 30 seconds and then nothing gets pasted.
hmm... yes... problem is that when TextMate claims ownership of the clipboard, all others need to ask TM for the contents, but TM is busy asking pbpaste for the command result.
But if you make ctrl-k write to the normal clipboard, ctrl-y should just be re-bound to cmd-v!?!
I tried running pbpaste from the command line, just to see if the pbcopy part was working, and the copy part appears to work when I create the macro, but when I test it it does not work anymore. It does not seem like the selectToEnd of line part is working....
Come to think of it, the problem is probably the same as to when not using pbcopy (local clipboard in macros).
I did a little bit of experimenting, and I can make it work if I let the macro execute this command (input: selection, output: discard):
tmp=`mktemp -t tm_clip`; cat >$tmp; { sleep .2; pbcopy <$tmp; rm $tmp; } >/dev/null 2>&1 </dev/null &
What it does is first store selection in a file, then asynchronously sleep for .2 seconds and _then_ copy the file contents to the clipboard (so that should be after TM thinks the macro is done, and thus after TM resets the clipboard).
I admit, it's not very elegant...
Thank you! That does the trick as long as I'm not too fast between my ctrl-k and ctrl-y.
I think the option to disable the local clipboard for a macro would be handy, then I could go back to writing ctrl-k in the obvious way.
Here's another little gotcha to remember that caught me, that I bet is not obvious to other programmers. When you record a macro that calls a command (or another macro), you might expect that the command/macro would be called, by name, like a function call in a program... However, what really happens is the contents of the command/macro get inserted into the macro you are recording. So, when I changed out the contents of my command that puts the selected text on the clipboard I also had to go back and re-record the macro that calls it.
Could I avoid this if I edit the macro directly? Not sure how to call another command or macro from a macro.
Thanks for your help!
Brad
On Jan 19, 2005, at 4:16 AM, Allan Odgaard wrote:
On Jan 19, 2005, at 11:10, Allan Odgaard wrote:
I admit, it's not very elegant...
I may add an option to disable local clipboard on a per macro basis in b3 or b4, since I think this feature is probably too often the culprit of end-user customization.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brad Miller, PhD Assistant Professor Luther College http://www.cs.luther.edu/~bmiller jabber: bnmnetp@jabber.org
On Jan 19, 2005, at 13:59, Brad Miller wrote:
Here's another little gotcha to remember that caught me, that I bet is not obvious to other programmers. When you record a macro that calls a command (or another macro), you might expect that the command/macro would be called, by name, like a function call in a program... However, what really happens is the contents of the command/macro get inserted [...]
Also applies to snippets. This is on purpose, since for example the original command/snippet/macro could have been deleted, or it could have been changed w/o considering that there was a dependency on it.
Could I avoid this if I edit the macro directly? Not sure how to call another command or macro from a macro.
You can't call another command by name, but you could make the change in the macro (instead of the command). Formally though I do not support manual editing of macros, since there's no sanity checks on the validity of the macro (so if you screw up, you may screw up TM when it executes the macro).
In next beta there'll be the possibility to inspect the contents of macros to make them more transparent (but no edit from inside TM) -- in the future I intend to record macros in a real language so that they can be edited. Just not entirely ready to embrace AppleScript ;)