summaryrefslogtreecommitdiff
path: root/notmuch-reply.c
Commit message (Collapse)AuthorAge
* Rearchitect From: header guessing code for repliesDirk Hohndel2010-04-26
| | | | | | | | | | | | | | | | | | | | | We want to be able to correctly guess the best From: header to use when replying to emails. This is what we are looking at now: 1 is one of the users' mail addresses in the To: or Cc: header 2 check for an Envelope-to: header 3 check for an X-Original-To: header 4 check for a (for <email@add.res>) clause in Received: headers 5 check for the domain part of known email addresses in the 'by' part of Received headers 6 fall back to the primary email address This patch changes the algorithm for steps 2-5 of this process. Prior to this patch we had a first attempt to implement only step 5 - but this broke in many email setups where mail delivery to the local machine added additional Received: lines. Steps 2-4 are new, step 5 now analyzes the concatenated Received: header (this was in the previous patch) to do this analysis. Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* notmuch reply: Handle notmuch_message_get_header returning NULL.Carl Worth2010-04-24
| | | | | | | | This seems a rather unlikely case, (replying to a message that disappears out from under us half way through the reply), but notmuch_message_get_header is documented to return NULL in error cases, so we might as well deal sanely with that (rather than just crashing).
* Decode headers in replyMichal Sojka2010-04-13
| | | | | | | | | | | | | | When headers contain non-ASCII characters, they are encoded according to rfc2047. Nomtuch reply command emits the headers in the encoded form, which makes them hard to read by humans who compose the reply. For example instead of "Subject: Re: Rozlučka" one currently sees "Subject: Re: =?iso-8859-2?q?Rozlu=E8ka?=". This patch adds a new GMime filter which is used to decode headers to UTF-8 and uses this filter when notmuch reply outputs headers. Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
* Fix code extracting the MTA from Received: headersDirk Hohndel2010-04-07
| | | | | | | | The previous code made too many assumptions about the (sadly not standardized) format of the Received headers. This version should be more robust to deal with different variations. Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* notmuch-reply: Remove stray brace.Carl Worth2010-04-07
| | | | That was breaking the build.
* notmuch-reply: Remove a useless level of nesting.Carl Worth2010-04-06
| | | | Making the code a tiny bit easier to read (in my opinion at least).
* notmuch-reply: Fix some whitespace issues.Carl Worth2010-04-06
| | | | | No actual code change here. Just whitespace style, (mostly just my preferred space before a left parenthesis, and a space after a comma).
* guess From address from Received headersDirk Hohndel2010-04-06
| | | | | | | | | | | | | When replying to a message notmuch tries to pick the correct From address by looking which one of a user's configured email addresses were included in To or Cc headers of the email that is being replied to. If none of the users email addresses are in the To or Cc headers we now try to guess from the first (chronologically, last) Received header which domain this email was received in and therefore which of the email addresses to use in a reply If that fails we still use the primary email as From email Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* lib: Rename iterator functions to prepare for reverse iteration.Carl Worth2010-03-09
| | | | | | | | We rename 'has_more' to 'valid' so that it can function whether iterating in a forward or reverse direction. We also rename 'advance' to 'move_to_next' to setup parallel naming with the proposed functions 'move_to_first', 'move_to_last', and 'move_to_previous'.
* notmuch reply: Rename the mailing_list_munged_reply_to functionCarl Worth2010-02-04
| | | | | | | | | This function detects whether the address in the Reply-To header already appears in either To or Cc. So give it a name that reflects what it does (reply_to_header_is_redundant) rather than the old name which described one possible use of the function, (as a simple heuristic for detecting whether a mailing list had applied reply-to munging).
* notmuch reply: Prevent GMIME assertion complaints for empty Reply-to header.Carl Worth2010-02-04
| | | | | | Apparently, GMime doesn't want to create a valid address list object for an empty string. That's annoying, but it's easy enough to test for the empty string and avoid the problem.
* notmuch reply: Use strstr instead of strcasestr for portability.Carl Worth2010-02-04
| | | | | | | | This change was already recommended in a comment in the original implementation of this patch. If someone really wants to support un-munging in the case of To: and Reply-To: having the same address but different case, then they can provide a portable approach for that.
* notmuch reply: Fix the support for reply-to un-munging.Carl Worth2010-02-04
| | | | | The condition was using a reversed sense for the test of the return value of strcasestr, (perhaps confusing it with the usage of strcmp?).
* notmuch-reply: Add missing whitespace.Carl Worth2010-02-04
| | | | | Some recently-added functions were to hard for me to read without the expected whitespace. Fix these.
* notmuch-reply.c: Handle munged `Reply-To' headers.Jed Brown2010-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | Some mailing lists engage in the evil practice of changing the Reply-To header so that replies from all mailers go to the list by default, at the expense of not responding to the person who actually sent the message. When this is detected, we reply to `From' and remove the duplicate response to the mailing list. Consider a reply to the following message. From: Some User <some.user@example.com> To: Sample users list <sample-users@sample.org> Reply-To: Sample users list <sample-users@sample.org> Prior to this patch, `notmuch reply' produces To: Sample users list <sample-users@sample.org>, Sample users list <sample-users@sample.org> and after the patch, To: Some User <some.user@example.com>, Sample users list <sample-users@sample.org> Signed-off-by: Jed Brown <jed@59A2.org>
* notmuch-reply.c: Factor adding recipients into common functionJed Brown2010-02-04
| | | | | | | | This code was already duplicated. We move it to a new, shared add_recipients_from_message function, in preparation for more sophisticated mailing list logic. Signed-off-by: Jed Brown <jed@59A2.org>
* notmuch-reply: Display reply message part using UTF-8.Kan-Ru Chen2009-12-03
| | | | | | | Pass the message through the charset filter so that we can view messages wrote in different charset encoding. Signed-off-by: Kan-Ru Chen <kanru@kanru.info>
* reply --format=headers-only: set In-Reply-To header, with ID *last* in ↵Jed Brown2009-11-27
| | | | | | | References Apparently this is actually the correct way to do it, it's silly to do it wrong just to conform to one of git's internal data structures.
* notmuch-reply.c: implement notmuch_reply_format_headers_onlyJed Brown2009-11-27
| | | | | | | | | | | | This command only generates References, To, and Cc headers. The purpose is primarily for use in git send-email --notmuch id:<MESSAGE-ID> to get proper threading and address the relevant parties. Hooks for other SCMs may come later. Signed-off-by: Jed Brown <jed@59A2.org>
* notmuch-reply.c: accept the --format=default default option.Jed Brown2009-11-27
| | | | | | | | This factors actual generation of the reply out of notmuch_reply_command into notmuch_reply_format_default(), in preparation for other --format= options. Signed-off-by: Jed Brown <jed@59A2.org>
* lib/query: Drop the first and max_messages arguments from search_messages.Carl Worth2009-11-23
| | | | | These only existed to support the chunky-searching hack, but that was recently dropped anyway.
* Make addresses case insensitive for the purpose of constructing replies.Jed Brown2009-11-23
| | | | | | | | | | The domain is alway case insensitive, but in principle the username is case sensitive. Few systems actually enforce this so I think a good default is to treat the entire address as case insensitive, it will eliminate a lot of superfluous self-addressed messages and reply from the correct address in these cases. Signed-off-by: Jed Brown <jed@59A2.org>
* Rename NOTMUCH_DATABASE_MODE_WRITABLE to NOTMUCH_DATABASE_MODE_READ_WRITECarl Worth2009-11-21
| | | | And correspondingly, READONLY to READ_ONLY.
* Permit opening the notmuch database in read-only mode.Chris Wilson2009-11-21
| | | | | | | | | We only rarely need to actually open the database for writing, but we always create a Xapian::WritableDatabase. This has the effect of preventing searches and like whilst updating the index. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Carl Worth <cworth@cworth.org>
* notmuch reply: Include text parts in reply, even with disposition attachment.Carl Worth2009-11-21
| | | | | If it's text, (such as a patch), then I want it quoted in my reply, (so that I can comment on it).
* reply: Pointer mismatch.Chris Wilson2009-11-19
| | | | Apparently typeof (size_t) != unsigned int on my x86-64.
* Make reply/show/tag all require at least one search termKeith Packard2009-11-18
| | | | | | | | In particular, notmuch tag -inbox "" tended to take a long time to run, happened if you hit 'a' on a blank line in the search view and probably didn't have the desired effect. Signed-off-by: Keith Packard <keithp@keithp.com>
* notmuch_message_file_get_header returns "" for missing headers, not NULLKeith Packard2009-11-16
| | | | | | | This makes notmuch reply fail to add From: addresses to the list of recipients. Signed-off-by: Keith Packard <keithp@keithp.com>
* Minor whitespace touchup.Carl Worth2009-11-15
| | | | | | It's funny that I picked up the habit of always including a space before a left parenthesis from Keith, and now he's in the habit of contributing code without it.
* notmuch reply: Prefer "Reply-To" header over "From" for choosing recipient.Carl Worth2009-11-13
| | | | | | There are still open questions about how to correctly compute the intended list of recipients. We'll probably need separate "reply to sender" and "reply to all" commands at some point (unfortunately).
* libnotmuch: Underlying support for doing partial-results searches.Carl Worth2009-11-12
| | | | | | The library interface now allows the caller to do incremental searches, (such as one page of results at a time). Next we'll just need to hook this up to "notmuch search" and the emacs interface.
* notmuch reply: Add Bcc to the user's primary email address.Carl Worth2009-11-12
| | | | | The user really wants a copy of all outbound messages to come back in.
* notmuch reply: Fish out user's address from recipient list to use as From.Carl Worth2009-11-11
| | | | | | That is, if mail was addresses to one of the "other" addresses in the configuration file, then the reply will have its "From" header set to that same address rather than the primary address.
* notmuch reply: Don't reply to address belonging to the user.Carl Worth2009-11-11
| | | | | | Here's our first real advantage of having a configuration system. We get to omit our own addresses from the recipient list of any replies.
* Unbreak several notmuch commands after the addition of configuration.Carl Worth2009-11-11
| | | | | | | | | | | | | | | | | | | | | | All of the following commands: notmuch dump notmuch reply notmuch restore notmuch search notmuch show notmuch tag were calling notmuch_database_open with an argument of NULL. This was a legitimate call until the recent addition of configuration, after which it is expected that all commands will lookup the correct path in the configuration file. So fix all these commands to do that. Also, while touching all of these commands, we fix them to use the talloc context that is passed in rather than creating a local talloc context. We also switch from using goto for return values, to doing direct returns as soon as an error is detected, (which can be leak free thanks to talloc).
* notmuch reply: Use GMime to construct the header for the reply.Carl Worth2009-11-11
| | | | | | | | | The advantage here is that we actually get the necessary folding of long headers, (particularly the References header, but also things like Subject). This also gives us parsed recipient addresses so that we can easily elide the sender's address(es) from the recipient list (just as soon as we have a configured value for the recipient's address(es)).
* notmuch reply: Process headers a bit more accurately.Carl Worth2009-11-10
| | | | | | We know take the original From: and all recipients and put them on the To: line. We also add a "Re: " to the subject, and we add In-Reply-To: and References: headers.
* notmuch reply: Add (incomplete) reply commandKeith Packard2009-11-10
Reviewed-by: Carl Worth <cworth@cworth.org> Keith wrote all the code here against notmuch before notmuch.c was split up into multiple files. So I've pushed the code around in various ways to match the new code structure, but have generally tried to avoid making any changes to the behavior of the code. I did fix one bug---a missing call to g_mime_stream_file_set_owner in show_part which would cause "notmuch show" to go off into the weeds when trying to show multiple messages, (since the first stream would fclose stdout).