I've written a little command to help me grep the current file and copy matching lines to a new document. I've copied the example of "Search the TextMate Mailing List" for the CocaoDialog. However my implementation is stalling and I need to killall CocaoDialog to free it up.
Save: Nothing Input: Selection Output: Create new document
---
res=$(CocoaDialog inputbox \ --title "Find matching lines" \ --informative-text "Regular expression to match lines:" \ --button1 "Find" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard pattern=$(tail -n1 <<<"$res")
perl -ne "print if /$pattern/";
The only thing much different here from the "Search mailing list" code is the use of stdin.
Hmmmm?
Q
[...] However my implementation is stalling and I need to killall CocaoDialog to free it up.
It stalls before or after bringing up the dialog?
It stalls after the dialog box appears. But I think I forgot to mention it stalls only in two cases:
1. Trying to paste text into the dialog box: it locks up permanently.
2. If I try to browse other TextMate windows, open documents, etc (i.e. looking for the string I want to use) I get a beach ball preventing me from selecting text (although I can still move windows).
The "Search mailing list" command lets you go to other windows, copy some text, then go back to the dialog box and paste text in. It works perfect. Mind doesn't.
Q
On 29/3/2006, at 23:15, Quinn Comendant wrote:
[...] The "Search mailing list" command lets you go to other windows, copy some text, then go back to the dialog box and paste text in. It works perfect. Mind doesn't.
The difference is that the Search ML has output set as HTML. When that is the case, the command is running asynchronously. With New Document as output option, TM will stall until the command has completed.
You could make the command asynchronous by wrapping it in something like: { … } &>/dev/null &
But then the command itself should create the new document (and output should just be discard). For example one could (probably) use this:
{ res=$(CocoaDialog inputbox \ --title "Find matching lines" \ --informative-text "Regular expression to match lines:" \ --button1 "Find" --button2 "Cancel")
[[ $(head -n1 <<<"$res") == "2" ]] && exit_discard pattern=$(tail -n1 <<<"$res")
TMP="$(mktemp /tmp/tm_search_XXXXXXXX).${TM_FILENAME##*.}" perl >"$TMP" -ne "print if /$pattern/" mate "$TMP"
} &>/dev/null &
Btw: anyway to get your mailer to not enumerate the replies in the subject? it messes up the threading in Mail.
On Mar 30, 2006, at 4:35 AM, Allan Odgaard wrote:
Btw: anyway to get your mailer to not enumerate the replies in the subject? it messes up the threading in Mail.
It actually didn't mess it up on my system (Mail.app Version 2.0.5 (746/746.2)). His reply to your reply shows up in the same thread as both of your replies.
weird...
Haris
yeah, Mail messes up a lot of threads, but not this one for me.
Soryu
On 30.03.2006, at 14:34, Charilaos Skiadas wrote:
On Mar 30, 2006, at 4:35 AM, Allan Odgaard wrote:
Btw: anyway to get your mailer to not enumerate the replies in the subject? it messes up the threading in Mail.
It actually didn't mess it up on my system (Mail.app Version 2.0.5 (746/746.2)). His reply to your reply shows up in the same thread as both of your replies.
weird...
Haris
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
Btw: anyway to get your mailer to not enumerate the replies in the subject? it messes up the threading in Mail.
It actually didn't mess it up on my system (Mail.app Version 2.0.5 (746/746.2)). His reply to your reply shows up in the same thread as both of your replies.
Doesn't Mail.app use the In-Reply-To and References email headers to organize threads?
I'll turn off my Re: enumeration to see if that helps.
Q
On 30/3/2006, at 21:57, Quinn Comendant wrote:
Btw: anyway to get your mailer to not enumerate the replies in the subject? it messes up the threading in Mail.
It actually didn't mess it up on my system (Mail.app Version 2.0.5 (746/746.2)). His reply to your reply shows up in the same thread as both of your replies.
Doesn't Mail.app use the In-Reply-To and References email headers to organize threads?
I think Mail mainly groups based on subjects, spiced with some fuzzy logic, as threading seems to differ slightly from machine to machine -- and it’s really grouping, not threading… :/
I'll turn off my Re: enumeration to see if that helps.
Thanks!
Allan Odgaard wrote:
On 30/3/2006, at 21:57, Quinn Comendant wrote:
Btw: anyway to get your mailer to not enumerate the replies in the subject? it messes up the threading in Mail.
It actually didn't mess it up on my system (Mail.app Version 2.0.5 (746/746.2)). His reply to your reply shows up in the same thread as both of your replies.
Doesn't Mail.app use the In-Reply-To and References email headers to organize threads?
I think Mail mainly groups based on subjects, spiced with some fuzzy logic, as threading seems to differ slightly from machine to machine -- and it’s really grouping, not threading… :/
This is one of the few things I really dislike about Mail.app. As far as I know, there is open-source threading code that works almost perfectly and is free for any use. For the most part, I just turn Mail.app's threading off now, which is too bad, because threading is really useful when it's done right.
On Mar 30, 2006, at 3:25 PM, Jacob Rus wrote:
This is one of the few things I really dislike about Mail.app. As far as I know, there is open-source threading code that works almost perfectly and is free for any use. For the most part, I just turn Mail.app's threading off now, which is too bad, because threading is really useful when it's done right.
I don't know if it was intentional, but your reply broke the threading for me now. :) Do you have some reference for this code you mention?
I still find it gets it right most of the time in mailing lists, so that's mainly where I use it. Where it fails miserably is in email from friends with no subject, or maybe a common one word subject. Then it ends up putting together things that have nothing to do with each other.
Haris
On 30/3/2006, at 23:32, Charilaos Skiadas wrote:
I don't know if it was intentional, but your reply broke the threading for me now. :) Do you have some reference for this code you mention?
I think it’s because the: [TxMt] Re: «topic» turned into Re: [TxMt] «topic», which confirms that it’s just a subject grouping with one or two normalization rules.
I still find it gets it right most of the time in mailing lists, so that's mainly where I use it.
It could do better. Have a look at actual threading (the screen grab was taken by Jacob, hopefully he don’t mind my linking to it):
http://hcs.harvard.edu/~jrus/TextMate/gmane-thunderbird.png
For mailing lists this would be _so_ much better.
Where it fails miserably is in email from friends with no subject, or maybe a common one word subject. Then it ends up putting together things that have nothing to do with each other.
Imagine how much mail I get with topics such as TextMate, Suggestion, Feedback, etc. all nicely “threaded” by Mail ;)
Pre-Tiger Mail actually did use the in-reply-to header. Maybe Apple (also) had too many problems with people doing a reply to a mailing list letter when they should have selected New Letter instead.
Charilaos Skiadas wrote:
On Mar 30, 2006, at 3:25 PM, Jacob Rus wrote:
This is one of the few things I really dislike about Mail.app. As far as I know, there is open-source threading code that works almost perfectly and is free for any use.
I don't know if it was intentional, but your reply broke the threading for me now. :) Do you have some reference for this code you mention?
Hopefully this won't break your threading again :/. It's possible that it has something to do with me sending this to the gmane newsgroup instead of straight to the mailing list.
One good algorithm is described here:
http://www.jwz.org/doc/threading.html
I believe there are several open-source implementations of this algorithm, but it wouldn't be too hard for Apple to write one.
-Jacob
On 31/03/2006, at 0:02, Jacob Rus wrote:
One good algorithm is described here: http://www.jwz.org/doc/threading.html I believe there are several open-source implementations of this algorithm, but it wouldn't be too hard for Apple to write one.
Even just pairing up in-reply-to with message-id would be enough, most of the time. Hardly much algorithm in that, and Mail.app used to behave this way before Tiger, as Allan also noted. It sucks that they took that out (although some people claim it till works for them).
-- Sune.
On 30.03.2006, at 23:32, Charilaos Skiadas wrote:
I don't know if it was intentional, but your reply broke the threading for me now. :) Do you have some reference for this code you mention?
There must be some magic in this, as Allan said, because my grouping is not broken in this Thread, I use a Smart Mailbox which shows mails to "textmate@lists.macromates.com" from the last 7 days.
This keeps the number of mails down and decreases load times.
Soryu
You could make the command asynchronous by wrapping it in something like: { ... } &>/dev/null &
Yep, that works great. But I had to add a "cat - | " to the beginning to pass stdin. Here is the finished command:
cat - | { if [ -f /tmp/tm_saved_regex ]; then REGEX="`cat /tmp/tm_saved_regex`"; else REGEX="^\s*\w+.*$"; fi
res=$(CocoaDialog inputbox \ --title "Find matching lines" \ --informative-text "Regular expression to match lines:" \ --text "$REGEX" \ --button1 "Find" --button2 "Cancel") [[ $(head -n1 <<<"$res") == "2" ]] && exit_discard REGEX=$(tail -n1 <<<"$res");
echo "$REGEX" > /tmp/tm_saved_regex;
TMP="$(mktemp /tmp/tm_findmatchinglines_XXXXXXXX).${TM_FILENAME##*.}"; perl -ne "print if /$REGEX/" > "$TMP"; mate "$TMP" } &>/dev/null &
Q
On 30/3/2006, at 22:39, Quinn Comendant wrote:
Yep, that works great. But I had to add a "cat - | " to the beginning to pass stdin. Here is the finished command:
cat - | { if [ -f /tmp/tm_saved_regex ]; then REGEX="`cat /tmp/tm_saved_regex`";
Here’s a little trick I rarely gets to show off:
REGEX="$(< /tmp/tm_saved_regex)"
Syntactically not that much saved, but a process less to launch :)