Commit graph

132 commits

Author SHA1 Message Date
Carl Worth
3e216ba60d notmuch-reply: Fix some whitespace issues.
No actual code change here. Just whitespace style, (mostly just my
preferred space before a left parenthesis, and a space after a comma).
2010-04-06 18:51:47 -07:00
Dirk Hohndel
4fd9ea05e8 guess From address from Received headers
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>
2010-04-06 18:47:40 -07:00
Carl Worth
4e5d2f22db lib: Rename iterator functions to prepare for reverse iteration.
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'.
2010-03-09 09:22:29 -08:00
Carl Worth
d111c720ba notmuch reply: Rename the mailing_list_munged_reply_to function
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).
2010-02-04 12:42:09 -08:00
Carl Worth
62379f3dee notmuch reply: Prevent GMIME assertion complaints for empty Reply-to header.
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.
2010-02-04 12:42:09 -08:00
Carl Worth
82e47ec92b notmuch reply: Use strstr instead of strcasestr for portability.
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.
2010-02-04 12:42:09 -08:00
Carl Worth
aea35aa5c6 notmuch reply: Fix the support for reply-to un-munging.
The condition was using a reversed sense for the test of the return
value of strcasestr, (perhaps confusing it with the usage of strcmp?).
2010-02-04 12:42:09 -08:00
Carl Worth
9953e9a5a8 notmuch-reply: Add missing whitespace.
Some recently-added functions were to hard for me to read without
the expected whitespace. Fix these.
2010-02-04 12:42:09 -08:00
Jed Brown
fddd3d831b notmuch-reply.c: Handle munged `Reply-To' headers.
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>
2010-02-04 12:10:43 -08:00
Jed Brown
fb50f31048 notmuch-reply.c: Factor adding recipients into common function
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>
2010-02-04 12:10:43 -08:00
Kan-Ru Chen
c8b50eee28 notmuch-reply: Display reply message part using UTF-8.
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>
2009-12-03 16:47:47 -08:00
Jed Brown
00b138ba2a reply --format=headers-only: set In-Reply-To header, with ID *last* in 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.
2009-11-27 16:56:51 -08:00
Jed Brown
f47e54bc51 notmuch-reply.c: implement notmuch_reply_format_headers_only
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>
2009-11-27 16:56:42 -08:00
Jed Brown
5d447f327f notmuch-reply.c: accept the --format=default default option.
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>
2009-11-27 16:56:23 -08:00
Carl Worth
94eb9aacd4 lib/query: Drop the first and max_messages arguments from search_messages.
These only existed to support the chunky-searching hack, but that
was recently dropped anyway.
2009-11-23 20:25:13 -08:00
Jed Brown
1e75f5f3a7 Make addresses case insensitive for the purpose of constructing replies.
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>
2009-11-23 18:35:01 -08:00
Carl Worth
637f99d8f3 Rename NOTMUCH_DATABASE_MODE_WRITABLE to NOTMUCH_DATABASE_MODE_READ_WRITE
And correspondingly, READONLY to READ_ONLY.
2009-11-21 22:10:18 +01:00
Chris Wilson
f379aa5284 Permit opening the notmuch database in read-only mode.
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>
2009-11-21 22:04:49 +01:00
Carl Worth
e94bd8506b notmuch reply: Include text parts in reply, even with disposition attachment.
If it's text, (such as a patch), then I want it quoted in my reply,
(so that I can comment on it).
2009-11-21 01:14:01 +01:00
Chris Wilson
f52528a344 reply: Pointer mismatch.
Apparently typeof (size_t) != unsigned int on my x86-64.
2009-11-19 00:20:24 +01:00
Keith Packard
394cb1c46d Make reply/show/tag all require at least one search term
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>
2009-11-18 23:37:35 +01:00
Keith Packard
6b135cae1e notmuch_message_file_get_header returns "" for missing headers, not NULL
This makes notmuch reply fail to add From: addresses to the list of
recipients.

Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-16 22:10:36 -08:00
Carl Worth
819f964d9a Minor whitespace touchup.
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.
2009-11-15 20:38:16 -08:00
Carl Worth
f9f897ae27 notmuch reply: Prefer "Reply-To" header over "From" for choosing recipient.
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).
2009-11-13 10:50:52 -08:00
Carl Worth
93dcc3b695 libnotmuch: Underlying support for doing partial-results searches.
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.
2009-11-12 16:47:27 -08:00
Carl Worth
077b8b2ac6 notmuch reply: Add Bcc to the user's primary email address.
The user really wants a copy of all outbound messages to come back
in.
2009-11-12 11:08:36 -08:00
Carl Worth
8f9bd26e62 notmuch reply: Fish out user's address from recipient list to use as From.
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.
2009-11-11 21:29:04 -08:00
Carl Worth
dbe41eab82 notmuch reply: Don't reply to address belonging to the user.
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.
2009-11-11 21:18:15 -08:00
Carl Worth
13569ad6c9 Unbreak several notmuch commands after the addition of configuration.
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).
2009-11-11 20:29:30 -08:00
Carl Worth
a9f3ad4fcb notmuch reply: Use GMime to construct the header for the reply.
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)).
2009-11-11 10:54:12 -08:00
Carl Worth
dfc0780cba notmuch reply: Process headers a bit more accurately.
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.
2009-11-10 18:46:26 -08:00
Keith Packard
357aba3ec8 notmuch reply: Add (incomplete) reply command
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).
2009-11-10 13:32:02 -08:00