Modify message after send...?
Hi, I use notmuch via Emacs. Here's what I want: When I hit C-c C-c to send a message, I'd like it to be passed to a script (likely a Python one, although I may consider an Elisp function if an external script is not possible) for modification of headers, before it is sent to the MTA (Postfix in my case). A bonus would be to have the modified message stored in the FCC location, instead of the original one. Is this possible? An alternative may be to modify the message /before/ it goes to message-send-and-exit. I'm inexperienced in Elisp - would this be via what's called "advising"? BTW, all I really want to do is modify the From: field based on the recipients (for every email, with no default From). I'll welcome suggestions for existing ways to do that. I Googled a little, but didn't find a clear good solution. Furthermore, I expect over time the rules by which I pick the From: field will get more complex than my knowledge of Elisp. Thanks. -- My sister opened a computer store in Hawaii. She sells C shells down by the seashore. /\ /\ /\ / / \/ \ u e e n / \/ a w a z >>mueen at nawaz.org<< anl
Searching for phrases in the body of an email
On Jul 18, 2015 6:32 PM, "Suvayu Ali" <fatkasuvayu+linux at gmail.com> wrote: > > Hi Xu, > > On Sat, Jul 18, 2015 at 10:54:30AM -0400, Xu Wang wrote: > > > > First note that I believe notmuch search is case insensitive by > > default, so your grep should be case insensitive as well. > > Good point, I tried that, didn't change the numbers much. The number of > matches from grep went up to 24, whereas notmuch count says 463. > > > More importantly, I'm not sure how 'no NEAR "plain text" ' syntax is > > parsed. Maybe it is parsed as {no NEAR plain} or {text}. > > > > Exactly, that's what I do not understand. > export NOTMUCH_DEBUG_QUERY=1 might help. > > You would like to search for the exact phrase, correct? How about the > > following? > > > > notmuch search no adj plain adj text > > Good suggestion. I tried it, and gives me very consistent numbers: > > $ notmuch count -- no ADJ plain ADJ text > 20 > $ notmuch show -- $(notmuch search --output=messages -- no NEAR \"plain\ text\") | \ > grep -c -iE 'plain[[:space:]/]+text' > 24 > > Of course this does not help me solve my original goal, but I guess now > I can try different queries based on your idea. > > Thanks a lot! > > -- > Suvayu > > Open source is the future. It sets us free. > ___ > notmuch mailing list > notmuch at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch -- next part -- An HTML attachment was scrubbed... URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20150718/f3603d9e/attachment.html>
Searching for phrases in the body of an email
Hi Xu, On Sat, Jul 18, 2015 at 10:54:30AM -0400, Xu Wang wrote: > > First note that I believe notmuch search is case insensitive by > default, so your grep should be case insensitive as well. Good point, I tried that, didn't change the numbers much. The number of matches from grep went up to 24, whereas notmuch count says 463. > More importantly, I'm not sure how 'no NEAR "plain text" ' syntax is > parsed. Maybe it is parsed as {no NEAR plain} or {text}. > Exactly, that's what I do not understand. > You would like to search for the exact phrase, correct? How about the > following? > > notmuch search no adj plain adj text Good suggestion. I tried it, and gives me very consistent numbers: $ notmuch count -- no ADJ plain ADJ text 20 $ notmuch show -- $(notmuch search --output=messages -- no NEAR \"plain\ text\") | \ grep -c -iE 'plain[[:space:]/]+text' 24 Of course this does not help me solve my original goal, but I guess now I can try different queries based on your idea. Thanks a lot! -- Suvayu Open source is the future. It sets us free.
Searching for phrases in the body of an email
On Sat, Jul 18, 2015 at 11:32 AM, Suvayu Aliwrote: > Of course this does not help me solve my original goal, but I guess now > I can try different queries based on your idea. Ah I see. Your goal is to search for phrases close to "no plain text". But if you use fuzzy searching but an exact grep, then it is normal that the numbers are not consistent, no? Because your grep is not fuzzy. Kind regards, Xu
Searching for phrases in the body of an email
Hi Lewis, On Fri, Jul 17, 2015 at 10:48:57AM -0500, J. Lewis Muir wrote: > > 1. Perhaps you are remembering the "no plain text" message incorrectly? >For example, the message could have referred to "text/plain" or >"plaintext" (no space). These would be sufficiently different to not >match your grep pattern. True, but my puzzlement is notmuch shouldn't return those results in the first place, since I provided a quoted string: "plain text", unless of course I need to escape the quotes. Okay, just checked it, doesn't make a difference in the number of hits from notmuch. > 2. Perhaps your email client rendered the "no plain text" message when >it encountered an email with only a "text/html" content type? In >this case, the "no plain text" (or whatever) message would not be >present in the email itself since it would be generated by the email >client when rendering the email. This is possible, but I use mutt. As far as I know, it doesn't do "smart" things like that. I also recall looking at the mime parts individually as I was surprised at the behaviour, and it was indeed a useless text/plain part with that message. > 3. A really long shot, but could a line wrap have occurred after "plain" >such that "text" appeared on the next line? Your grep pattern would >not match that. Good point, I tried grepping for this instead: 'plain[[:space:]/]+text', no luck. Thanks for your comments. Cheers, -- Suvayu Open source is the future. It sets us free.
Searching for phrases in the body of an email
On Sat, Jul 18, 2015 at 5:11 AM, Suvayu Aliwrote: > Hi Lewis, > > On Fri, Jul 17, 2015 at 10:48:57AM -0500, J. Lewis Muir wrote: >> >> 1. Perhaps you are remembering the "no plain text" message incorrectly? >>For example, the message could have referred to "text/plain" or >>"plaintext" (no space). These would be sufficiently different to not >>match your grep pattern. > > True, but my puzzlement is notmuch shouldn't return those results in the > first place, since I provided a quoted string: "plain text", unless of > course I need to escape the quotes. Okay, just checked it, doesn't make > a difference in the number of hits from notmuch. > >> 2. Perhaps your email client rendered the "no plain text" message when >>it encountered an email with only a "text/html" content type? In >>this case, the "no plain text" (or whatever) message would not be >>present in the email itself since it would be generated by the email >>client when rendering the email. > > This is possible, but I use mutt. As far as I know, it doesn't do > "smart" things like that. I also recall looking at the mime parts > individually as I was surprised at the behaviour, and it was indeed a > useless text/plain part with that message. > >> 3. A really long shot, but could a line wrap have occurred after "plain" >>such that "text" appeared on the next line? Your grep pattern would >>not match that. > > Good point, I tried grepping for this instead: 'plain[[:space:]/]+text', > no luck. > > Thanks for your comments. > > Cheers, > > -- > Suvayu Hi Suvayu, First note that I believe notmuch search is case insensitive by default, so your grep should be case insensitive as well. More importantly, I'm not sure how 'no NEAR "plain text" ' syntax is parsed. Maybe it is parsed as {no NEAR plain} or {text}. You would like to search for the exact phrase, correct? How about the following? notmuch search no adj plain adj text Best, Xu
Re: Searching for phrases in the body of an email
Hi Xu, On Sat, Jul 18, 2015 at 10:54:30AM -0400, Xu Wang wrote: First note that I believe notmuch search is case insensitive by default, so your grep should be case insensitive as well. Good point, I tried that, didn't change the numbers much. The number of matches from grep went up to 24, whereas notmuch count says 463. More importantly, I'm not sure how 'no NEAR plain text ' syntax is parsed. Maybe it is parsed as {no NEAR plain} or {text}. Exactly, that's what I do not understand. You would like to search for the exact phrase, correct? How about the following? notmuch search no adj plain adj text Good suggestion. I tried it, and gives me very consistent numbers: $ notmuch count -- no ADJ plain ADJ text 20 $ notmuch show -- $(notmuch search --output=messages -- no NEAR \plain\ text\) | \ grep -c -iE 'plain[[:space:]/]+text' 24 Of course this does not help me solve my original goal, but I guess now I can try different queries based on your idea. Thanks a lot! -- Suvayu Open source is the future. It sets us free. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Searching for phrases in the body of an email
On Sat, Jul 18, 2015 at 5:11 AM, Suvayu Ali fatkasuvayu+li...@gmail.com wrote: Hi Lewis, On Fri, Jul 17, 2015 at 10:48:57AM -0500, J. Lewis Muir wrote: 1. Perhaps you are remembering the no plain text message incorrectly? For example, the message could have referred to text/plain or plaintext (no space). These would be sufficiently different to not match your grep pattern. True, but my puzzlement is notmuch shouldn't return those results in the first place, since I provided a quoted string: plain text, unless of course I need to escape the quotes. Okay, just checked it, doesn't make a difference in the number of hits from notmuch. 2. Perhaps your email client rendered the no plain text message when it encountered an email with only a text/html content type? In this case, the no plain text (or whatever) message would not be present in the email itself since it would be generated by the email client when rendering the email. This is possible, but I use mutt. As far as I know, it doesn't do smart things like that. I also recall looking at the mime parts individually as I was surprised at the behaviour, and it was indeed a useless text/plain part with that message. 3. A really long shot, but could a line wrap have occurred after plain such that text appeared on the next line? Your grep pattern would not match that. Good point, I tried grepping for this instead: 'plain[[:space:]/]+text', no luck. Thanks for your comments. Cheers, -- Suvayu Hi Suvayu, First note that I believe notmuch search is case insensitive by default, so your grep should be case insensitive as well. More importantly, I'm not sure how 'no NEAR plain text ' syntax is parsed. Maybe it is parsed as {no NEAR plain} or {text}. You would like to search for the exact phrase, correct? How about the following? notmuch search no adj plain adj text Best, Xu ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Searching for phrases in the body of an email
On Jul 18, 2015 6:32 PM, Suvayu Ali fatkasuvayu+li...@gmail.com wrote: Hi Xu, On Sat, Jul 18, 2015 at 10:54:30AM -0400, Xu Wang wrote: First note that I believe notmuch search is case insensitive by default, so your grep should be case insensitive as well. Good point, I tried that, didn't change the numbers much. The number of matches from grep went up to 24, whereas notmuch count says 463. More importantly, I'm not sure how 'no NEAR plain text ' syntax is parsed. Maybe it is parsed as {no NEAR plain} or {text}. Exactly, that's what I do not understand. export NOTMUCH_DEBUG_QUERY=1 might help. You would like to search for the exact phrase, correct? How about the following? notmuch search no adj plain adj text Good suggestion. I tried it, and gives me very consistent numbers: $ notmuch count -- no ADJ plain ADJ text 20 $ notmuch show -- $(notmuch search --output=messages -- no NEAR \plain\ text\) | \ grep -c -iE 'plain[[:space:]/]+text' 24 Of course this does not help me solve my original goal, but I guess now I can try different queries based on your idea. Thanks a lot! -- Suvayu Open source is the future. It sets us free. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Searching for phrases in the body of an email
On Sat, Jul 18, 2015 at 12:34:16PM -0400, Xu Wang wrote: On Sat, Jul 18, 2015 at 11:32 AM, Suvayu Ali fatkasuvayu+li...@gmail.com wrote: Of course this does not help me solve my original goal, but I guess now I can try different queries based on your idea. Ah I see. Your goal is to search for phrases close to no plain text. But if you use fuzzy searching but an exact grep, then it is normal that the numbers are not consistent, no? Because your grep is not fuzzy. My grep was this (case insensitive): 'plain[[:space:]/]+text'. Since I thought I was searching for the _phrase_ plain text, that would be adequately fuzzy. However after following Jani's advice, I realise it wasn't always being treated as a phrase, neither was NEAR being treated as an operator. I wanted to combine a phrase (plain text) with the NEAR query (NEAR no), but maybe that combination is not possible. That's why I tried to combine NEAR and ADJ (as per your suggestion) by grouping them, that does not seem to work either! -- Suvayu Open source is the future. It sets us free. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: Searching for phrases in the body of an email
On Sat, Jul 18, 2015 at 11:32 AM, Suvayu Ali fatkasuvayu+li...@gmail.com wrote: Of course this does not help me solve my original goal, but I guess now I can try different queries based on your idea. Ah I see. Your goal is to search for phrases close to no plain text. But if you use fuzzy searching but an exact grep, then it is normal that the numbers are not consistent, no? Because your grep is not fuzzy. Kind regards, Xu ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Modify message after send...?
Hi, I use notmuch via Emacs. Here's what I want: When I hit C-c C-c to send a message, I'd like it to be passed to a script (likely a Python one, although I may consider an Elisp function if an external script is not possible) for modification of headers, before it is sent to the MTA (Postfix in my case). A bonus would be to have the modified message stored in the FCC location, instead of the original one. Is this possible? An alternative may be to modify the message /before/ it goes to message-send-and-exit. I'm inexperienced in Elisp - would this be via what's called advising? BTW, all I really want to do is modify the From: field based on the recipients (for every email, with no default From). I'll welcome suggestions for existing ways to do that. I Googled a little, but didn't find a clear good solution. Furthermore, I expect over time the rules by which I pick the From: field will get more complex than my knowledge of Elisp. Thanks. -- My sister opened a computer store in Hawaii. She sells C shells down by the seashore. /\ /\ /\ / / \/ \ u e e n / \/ a w a z mu...@nawaz.org anl ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch