notmuch.git
15 years agonotmuch show: Don't hide text parts, even with disposition attachment.
Carl Worth [Sat, 21 Nov 2009 00:09:36 +0000 (01:09 +0100)]
notmuch show: Don't hide text parts, even with disposition attachment.

If it's text, (such as a patch), then I want to see it.

15 years agonotmuch show: Don't hide a digital signature.
Carl Worth [Sat, 21 Nov 2009 00:00:41 +0000 (01:00 +0100)]
notmuch show: Don't hide a digital signature.

This was a bug that was introduced in copying the indexing code over
into notmuch-show.c. When indexing, we want to ignore the signature,
(it has no interesting terms). But when presenting the message, it's
important to present the signature to the user.

(And would be even better if we presented whether or not the signature
is good.)

15 years agonotmuch.el: Don't use end-of-buffer which is inappropriate from programs
Carl Worth [Fri, 20 Nov 2009 23:58:16 +0000 (00:58 +0100)]
notmuch.el: Don't use end-of-buffer which is inappropriate from programs

The documentation is quite clear about this case.

With this, we can now byte compile without warnings.

15 years agonotmuch.el: Fix stale reference to non-existing variable.
Carl Worth [Fri, 20 Nov 2009 23:53:27 +0000 (00:53 +0100)]
notmuch.el: Fix stale reference to non-existing variable.

We changed from "query" to "thread-id" a while ago, and broke this
error message at the time. Fix it now.

15 years agonotmuch.el: Add many missing defvar calls.
Carl Worth [Fri, 20 Nov 2009 23:52:23 +0000 (00:52 +0100)]
notmuch.el: Add many missing defvar calls.

Without these, emacs was complaining about "assignment to free variable",
(though only when byte compiling, which is why we didn't notice earlier).

15 years agoWhen a search query triggers a Xapian exception, log what the query was.
Eric Anholt [Fri, 20 Nov 2009 13:00:42 +0000 (14:00 +0100)]
When a search query triggers a Xapian exception, log what the query was.

In my script containing a series of queries to be run on new mail for
setting up tags, it's nice to see which query I typed wrong.

Signed-off-by: Eric Anholt <eric@anholt.net>
15 years agoMake bash completion directory configurable.
James Rowe [Fri, 20 Nov 2009 15:28:26 +0000 (15:28 +0000)]
Make bash completion directory configurable.

Some systems install completion scripts in /usr/share/bash-completion, make the
location configurable from Makefile.config.

15 years agoadd_message: Re-fix handling of non-mail files.
Carl Worth [Fri, 20 Nov 2009 20:46:37 +0000 (21:46 +0100)]
add_message: Re-fix handling of non-mail files.

More fallout from _get_header now returning "" for missing headers.

The bug here is that we would no longer detect that a file is not an
email message and give up on it like we should.

And this time, I actually audited all callers to
notmuch_message_get_header, so hopefully we're done fixing this
bug over and over.

15 years agonotmuch_database_add_message: Add missing error-value propagation.
Carl Worth [Fri, 20 Nov 2009 20:02:11 +0000 (21:02 +0100)]
notmuch_database_add_message: Add missing error-value propagation.

Thanks to Mike Hommey for doing the analysis that led to noticing that
this was missing.

15 years agoadd_message: Properly handle missing Message-ID once again.
Carl Worth [Fri, 20 Nov 2009 18:31:00 +0000 (19:31 +0100)]
add_message: Properly handle missing Message-ID once again.

There's been a fair amount of fallout from when we changed
message_file_get_header from returning NULL to returning "" for
missing headers. This is yet more fallout from that, (where we were
accepting an empty message-ID rather than generating one like we want
to).

15 years agoCheckin some command-only tcsh completions
Alexander Botero-Lowry [Thu, 19 Nov 2009 01:15:43 +0000 (17:15 -0800)]
Checkin some command-only tcsh completions

Modified-by Carl Worth <cworth@cworth.org>: Just moved the file down
into contrib where the other completion scripts are.

15 years agobash-completion: Move to contrib
Ingmar Vanhassel [Fri, 20 Nov 2009 13:36:14 +0000 (14:36 +0100)]
bash-completion: Move to contrib

Signed-off-by: Ingmar Vanhassel <ingmar@exherbo.org>
15 years agozsh-completion: Initial zsh-completion for notmuch
Ingmar Vanhassel [Fri, 20 Nov 2009 13:36:13 +0000 (14:36 +0100)]
zsh-completion: Initial zsh-completion for notmuch

Signed-off-by: Ingmar Vanhassel <ingmar@exherbo.org>
15 years agoAdd notmuch.1.gz to files to be cleaned
Mikhail Gusarov [Fri, 20 Nov 2009 12:58:39 +0000 (18:58 +0600)]
Add notmuch.1.gz to files to be cleaned

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
15 years agoTODO: Add a couple of notes about fixing the completion script.
Carl Worth [Fri, 20 Nov 2009 16:04:29 +0000 (17:04 +0100)]
TODO: Add a couple of notes about fixing the completion script.

I'm throwing away a half-finished fix of this now, and just want to
ensure I don't forget about it.

15 years agoMakefile: Make object targets depend on Makefiles
Jan Janak [Thu, 19 Nov 2009 00:37:25 +0000 (01:37 +0100)]
Makefile: Make object targets depend on Makefiles

All objects need to be recompiled when any of the Makefiles changes, so
we make them all depend on all the Makefiles.

Signed-off-by: Jan Janak <jan@ryngle.com>
15 years agoAllow to redefine notmuch binary name and path in elisp mode
Mikhail Gusarov [Fri, 20 Nov 2009 01:15:40 +0000 (07:15 +0600)]
Allow to redefine notmuch binary name and path in elisp mode

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
15 years agonotmuch.el: Don't use literal control characters in strings.
Carl Worth [Fri, 20 Nov 2009 12:09:58 +0000 (13:09 +0100)]
notmuch.el: Don't use literal control characters in strings.

Avoding these is nicer to users, text editors, and our poor little
notmuch.el code itself that would get confused when seeing a copy of
itself in email. (Of course, we should still fix that bug, but this
workaround is good nonetheless.)

15 years agoMakefile: Hard-code emacs_lispdir if emacs pkg-config file not available
Carl Worth [Fri, 20 Nov 2009 12:07:42 +0000 (13:07 +0100)]
Makefile: Hard-code emacs_lispdir if emacs pkg-config file not available

Using pkg-config to find this variable is nice if it works. Go back to
the previously used value if it doesn't.

15 years agoMakefile: Remove unused variable emacs_startdir
Carl Worth [Fri, 20 Nov 2009 11:58:42 +0000 (12:58 +0100)]
Makefile: Remove unused variable emacs_startdir

This was added in a prelimnary version of a previous commit that would
automatically load notmuch.el for anyone running emacs. It's not used
at all in the current Makefile.

15 years agoAvoid access of a Xapian iterator's object when there's nothing there.
Carl Worth [Fri, 20 Nov 2009 11:06:11 +0000 (12:06 +0100)]
Avoid access of a Xapian iterator's object when there's nothing there.

This eliminates a crash when a message (either corrupted or a non-mail
file that wasn't properly detected as not being mail) has no In-Reply-To
header, (and so few terms that trying to skip to the prefix of the
In-Reply-To terms actually brings us to the end of the termlist).

15 years agoRevert inadvertently committed code.
Carl Worth [Fri, 20 Nov 2009 10:12:42 +0000 (11:12 +0100)]
Revert inadvertently committed code.

This was accidentally included with commit:

ddac17343a30976cae82c9f57419c063e1585cc0

(It was a dirty chunk in my directory that I accidentally amended into
the submitted patch.)

15 years agonotmuch build: add a RPM spec file
Jeffrey C. Ollie [Wed, 18 Nov 2009 18:31:54 +0000 (12:31 -0600)]
notmuch build: add a RPM spec file

Add a spec file for building RPM packages.

Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
15 years agoAdd a .desktop file entry.
Jeffrey C. Ollie [Thu, 19 Nov 2009 21:20:02 +0000 (15:20 -0600)]
Add a .desktop file entry.

This will add an entry in your window manager's menus that will create
up a new emacs process and start notmuch.

Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
15 years agoImprove installation of emacs mode.
Jeffrey C. Ollie [Thu, 19 Nov 2009 21:20:01 +0000 (15:20 -0600)]
Improve installation of emacs mode.

1) Add a separate targets to build and install emacs mode.

2) Don't hardcode the installation directory, instead use emacs'
   pkg-config module.

3) Install a byte compiled version of the emacs mode.

4) Install the emacs mode in emacs' site-lisp directory.  Put
   "(require 'notmuch)" in your .emacs to load it automatically.

5) Ignore byte-compiled emacs files.

Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
Reviewed-by: Ingmar Vanhassel <ingmar@exherbo.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
15 years agoHave git ignore tags & cscope files
Rolland Santimano [Thu, 19 Nov 2009 05:16:58 +0000 (21:16 -0800)]
Have git ignore tags & cscope files

15 years agoPut $(LDFLAGS) after the list of object files.
Peter Wang [Thu, 19 Nov 2009 08:13:35 +0000 (19:13 +1100)]
Put $(LDFLAGS) after the list of object files.

Some linkers on some systems are particularly picky about the order of
arguments in order to properly linkt. So this fixes failures on some
systems.

15 years agonotmuch: Add search mode hook
Aneesh Kumar K.V [Thu, 19 Nov 2009 06:10:54 +0000 (11:40 +0530)]
notmuch: Add search mode hook

This patch add notmuch-search-hook that gets run when we
after displaying search results

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc:Keith Packard <keithp@keithp.com>

15 years agoMakefile: Create elisp install directory explicitly
Ingmar Vanhassel [Thu, 19 Nov 2009 01:45:44 +0000 (02:45 +0100)]
Makefile: Create elisp install directory explicitly

When doing a DESTDIR install, this directory likely won't exist, and
installing notmuch.el will fail.

See 0d4b5292

15 years agobash-completion: Complete options for notmuch search
Ingmar Vanhassel [Thu, 19 Nov 2009 02:18:20 +0000 (03:18 +0100)]
bash-completion: Complete options for notmuch search

15 years agobash-completion: Localize variables, use more consistent variable names
Ingmar Vanhassel [Thu, 19 Nov 2009 02:14:52 +0000 (03:14 +0100)]
bash-completion: Localize variables, use more consistent variable names

15 years agobash-completion: Whitespace fix
Ingmar Vanhassel [Thu, 19 Nov 2009 02:12:59 +0000 (03:12 +0100)]
bash-completion: Whitespace fix

Signed-off-by: Ingmar Vanhassel <ingmar@exherbo.org>
15 years agobash-completion: Bash has & should use [[ == ]]
Ingmar Vanhassel [Thu, 19 Nov 2009 01:58:42 +0000 (02:58 +0100)]
bash-completion: Bash has & should use [[ == ]]

Signed-off-by: Ingmar Vanhassel <ingmar@exherbo.org>
15 years agoAllow lone "not" search operators
Adrian Perez [Thu, 19 Nov 2009 00:07:22 +0000 (01:07 +0100)]
Allow lone "not" search operators

As suggested by Keith in FLAG_PURE_NOT allows for expressions like:

  notmuch search NOT tag:inbox

Note that this way a search like:

  notmuch search foobar NOT tag:inbox

should not be written instead:

  notmuch search foobar AND NOT tag:inbox

In my opinion, the latter feels more natural and is somewhat more explicit.
It gives a better clue of what the search is about instead of assuming that
an implicit AND operator is there.

15 years ago.gitignore: Add common editor droppings
Ingmar Vanhassel [Wed, 18 Nov 2009 22:51:31 +0000 (23:51 +0100)]
.gitignore: Add common editor droppings

15 years agonotmuch new: Restore printout of total files counted.
Carl Worth [Wed, 18 Nov 2009 23:32:21 +0000 (00:32 +0100)]
notmuch new: Restore printout of total files counted.

This was more fallout from the recent re-shuffling of this code.

15 years agonotmuch new: Fix countdown timer on first run.
Carl Worth [Wed, 18 Nov 2009 23:29:52 +0000 (00:29 +0100)]
notmuch new: Fix countdown timer on first run.

A recent shuffling of this code accidentally disabled the timer,
(making the time spent counting the files totally useless).

15 years agoMakefile: Actually install the emacs mode.
Carl Worth [Wed, 18 Nov 2009 23:27:34 +0000 (00:27 +0100)]
Makefile: Actually install the emacs mode.

Should have been doing this a long time ago.

15 years agonotmuch.el: Add a reply binding ('r') to search mode to reply to a whole thread.
Carl Worth [Wed, 18 Nov 2009 23:21:24 +0000 (00:21 +0100)]
notmuch.el: Add a reply binding ('r') to search mode to reply to a whole thread.

This is basically right, (I get a message buffer with all the mails
quoted), but somehow notmuch reply is reversing the messages. That's a
nuisance.

15 years agoreply: Pointer mismatch.
Chris Wilson [Wed, 18 Nov 2009 11:34:55 +0000 (11:34 +0000)]
reply: Pointer mismatch.

Apparently typeof (size_t) != unsigned int on my x86-64.

15 years agoMakefile: evaluate pkg-config once
Chris Wilson [Wed, 18 Nov 2009 11:34:54 +0000 (11:34 +0000)]
Makefile: evaluate pkg-config once

Currently the same `pkg-config ...` is executed for every target, so
just store the results in a variable.

15 years agoMake reply/show/tag all require at least one search term
Keith Packard [Wed, 18 Nov 2009 21:43:38 +0000 (13:43 -0800)]
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>
15 years agoHave git ignore etags file
Keith Packard [Wed, 18 Nov 2009 19:57:53 +0000 (11:57 -0800)]
Have git ignore etags file

15 years agoFilter out carriage-returns in show and reply output.
Keith Packard [Wed, 18 Nov 2009 19:55:18 +0000 (11:55 -0800)]
Filter out carriage-returns in show and reply output.

Thanks, windows mail clients.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 years agoWe use the message mail system for new mail, let emacs know.
Keith Packard [Wed, 18 Nov 2009 17:33:52 +0000 (09:33 -0800)]
We use the message mail system for new mail, let emacs know.

This makes things like the goto-address system bring up the right
message composition window.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 years agoCreate a default notmuch-show-hook that highlights URLs and uses word-wrap
Keith Packard [Wed, 18 Nov 2009 08:28:14 +0000 (00:28 -0800)]
Create a default notmuch-show-hook that highlights URLs and uses word-wrap

I created the notmuch-show-hook precisely so I could add these two
options, but I suspect most people will want them, so I just made them
the default. If you don't want them, you can use remove-hook to get
rid of this.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 years agoSet truncate-lines variable for search buffers.
Keith Packard [Wed, 18 Nov 2009 08:12:31 +0000 (00:12 -0800)]
Set truncate-lines variable for search buffers.

This keeps them from wrapping.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 years agoAdd notmuch-show-hook to allow customization of show windows
Keith Packard [Tue, 17 Nov 2009 06:06:49 +0000 (22:06 -0800)]
Add notmuch-show-hook to allow customization of show windows

I wanted to enable got-address-mode and visual-line-mode in my show
windows to make messages easier to read and URLs easier to
follow. This hook allows the user to run arbitrary code each time a
message is shown.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 years agocount_files: sort directory in inode order before statting
Stewart Smith [Wed, 18 Nov 2009 02:22:20 +0000 (13:22 +1100)]
count_files: sort directory in inode order before statting

Carl says: This has similar performance benefits as the previous
patch, and I fixed similar style issues here as well, (including
missing more of a commit message than the one-line summary).

15 years agoMinor style fixups for the previous fix.
Carl Worth [Wed, 18 Nov 2009 21:27:32 +0000 (22:27 +0100)]
Minor style fixups for the previous fix.

Use consistent whitespace, a slightly less abbreviated identifier, and
avoid a C99 declaration after statement.

15 years agoRead mail directory in inode number order
Stewart Smith [Wed, 18 Nov 2009 01:56:40 +0000 (12:56 +1100)]
Read mail directory in inode number order

This gives a rather decent reduction in number of seeks required when
reading a Maildir that isn't in pagecache.

Most filesystems give some locality on disk based on inode numbers.
In ext[234] this is the inode tables, in XFS groups of sequential inode
numbers are together on disk and the most significant bits indicate
allocation group (i.e inode 1,000,000 is always after inode 1,000).

With this patch, we read in the whole directory, sort by inode number
before stat()ing the contents.

Ideally, directory is sequential and then we make one scan through the
file system stat()ing.

Since the universe is not ideal, we'll probably seek during reading the
directory and a fair bit while reading the inodes themselves.

However... with readahead, and stat()ing in inode order, we should be
in the best place possible to hit the cache.

In a (not very good) benchmark of "how long does it take to find the first
15,000 messages in my Maildir after 'echo 3 > /proc/sys/vm/drop_caches'",
this patch consistently cut at least 8 seconds off the scan time.

Without patch: 50 seconds
With patch: 38-42 seconds.

(I did this in a previous maildir reading project and saw large improvements too)

15 years agoMake '?" bring up a list of bindings.
Carl Worth [Wed, 18 Nov 2009 18:12:13 +0000 (19:12 +0100)]
Make '?" bring up a list of bindings.

Just using describe-mode for now, (though something more specialized
would be better).

15 years agoFix linking with gcc to use g++ to link in C++ libs.
Stewart Smith [Wed, 18 Nov 2009 01:05:53 +0000 (12:05 +1100)]
Fix linking with gcc to use g++ to link in C++ libs.

Previously, Ubuntu 9.10, gcc 4.4.1 was getting:

/usr/bin/ld: lib/notmuch.a(database.o): in function global
constructors keyed to BOOLEAN_PREFIX_INTERNAL:database.cc(.text+0x3a):
error: undefined reference to 'std::ios_base::Init::Init()'

15 years agonotmuch main(): Remove stale comment.
Carl Worth [Wed, 18 Nov 2009 13:22:14 +0000 (05:22 -0800)]
notmuch main(): Remove stale comment.

The code this comment was referring to has since been deleted.

15 years agonotmuch help: Print to stdout, not to stderr.
Lars Kellogg-Stedman [Wed, 18 Nov 2009 01:01:16 +0000 (20:01 -0500)]
notmuch help: Print to stdout, not to stderr.

Let usage() take a FILE * argument so that you can output to stderr in
response to usage errors, and stdout in response to an explicit
request.

15 years agonotmuch search: Avoid infinite stream of exceptions from "notmuch search"
Carl Worth [Wed, 18 Nov 2009 11:29:30 +0000 (03:29 -0800)]
notmuch search: Avoid infinite stream of exceptions from "notmuch search"

That is, give a nice error message and exit if no search terms are
provided. Thanks to Priit Laes <plaes@plaes.org> for reporting the
error and providing an early version of the fix.

15 years agoREADME: Mention the actual mailing list address now that it exists.
Carl Worth [Wed, 18 Nov 2009 11:24:27 +0000 (03:24 -0800)]
README: Mention the actual mailing list address now that it exists.

Much better than telling people to mail me individually.

15 years agoTypsos
Ingmar Vanhassel [Tue, 17 Nov 2009 23:23:42 +0000 (00:23 +0100)]
Typsos

15 years agoOlder versions of install do not support -C.
Jan Janak [Tue, 17 Nov 2009 22:18:47 +0000 (23:18 +0100)]
Older versions of install do not support -C.

Do not use -C cmdline option of install, older versions, commonly found in
distributions like Debian, do not seem to support it. Running make install
on such systems (tested on Debian Lenny) fails.

Signed-off-by: Jan Janak <jan@ryngle.com>
15 years agolinke_message: Avoid segfault when In-Reply-to header is empty.
Carl Worth [Wed, 18 Nov 2009 09:36:30 +0000 (01:36 -0800)]
linke_message: Avoid segfault when In-Reply-to header is empty.

This was recently introduced in commit:

64c03ae97f2f5294c60ef25d7f41849864e6ebd3

which was adding extra checks to avoid adding a self-referencing
message.

How many times am I going to fix a dumb regression like this and say
"we really need a test suite" before I actually sit down and write the
test suite?

15 years agonotmuch-completion.bash: Update for new commands and help.
Carl Worth [Wed, 18 Nov 2009 09:29:19 +0000 (01:29 -0800)]
notmuch-completion.bash: Update for new commands and help.

Would be nice to add the options for "notmuch search" too.

15 years agonotmuch help: Update documentation (following recent text from notmuch.1)
Carl Worth [Wed, 18 Nov 2009 07:37:21 +0000 (23:37 -0800)]
notmuch help: Update documentation (following recent text from notmuch.1)

We take the recently created text from the notmuch manual page and
update the "notmuch help" command to use similar text. In particular,
we add a new "notmuch help search-terms" for documenting the search
syntax that is common to several commands.

15 years agonotmuch.1: Fix a couple of typos.
Carl Worth [Wed, 18 Nov 2009 07:36:44 +0000 (23:36 -0800)]
notmuch.1: Fix a couple of typos.

Little things I noticed while using this text as reference for the
"notmuch help" documentation.

15 years agoman.1: A big update of the notmuch manual page.
Carl Worth [Wed, 18 Nov 2009 06:16:35 +0000 (22:16 -0800)]
man.1: A big update of the notmuch manual page.

I set out merely to add documentation for the recently-added options
for "notmuch search" (--first, --max-threads, and --sort), but ended
up revamping a lot. A significant change is a new SEARCH SYNTAX
section separate from "notmuch search" that is referred to in the
documentation of search, show, reply, and tag.

Also many sections were updated to reflect recent changes, (such as
the dropping of the NOTMUCH_BASE environment variable, the addition of
the .notmuch-config file, etc.)

15 years agoMakefile: Fix missing dependency for notmuch.1 manual page.
Carl Worth [Wed, 18 Nov 2009 05:04:31 +0000 (21:04 -0800)]
Makefile: Fix missing dependency for notmuch.1 manual page.

The Makefile was failing to regnerate the notmuch.1.gz file when
notmuch.1 was updated, (so stale documentation could potentially be
installed).

15 years agonotmuch search: Change default search order to be newest messages first.
Carl Worth [Wed, 18 Nov 2009 04:52:09 +0000 (20:52 -0800)]
notmuch search: Change default search order to be newest messages first.

This is what most people want for a _search_ command. It's often
different for actually reading mail in an inbox, (where it makes more
sense to have results displayed in chronological order), but in such a
case, ther user is likely using an interface that can simply pass the
--sort=oldest-first option to "notmuch search".

Here we're also change the sort enum from NOTMUCH_SORT_DATE and
NOTMUCH_SORT_DATE_REVERSE to NOTMUCH_SORT_OLDEST_FIRST and
NOTMUCH_SORT_NEWEST_FIRST. Similarly we replace the --reverse option
to "notmuch search" with two options: --sort=oldest-first and
--sort=newest-first.

Finally, these changes are all tracked in the emacs interface, (which
has no change in its behavior).

15 years agonotmuch search: Return first 100 results as quickly as possible.
Carl Worth [Wed, 18 Nov 2009 03:11:05 +0000 (19:11 -0800)]
notmuch search: Return first 100 results as quickly as possible.

This is one of those cases where total time is not the metric of
interest. We increase the total time of the search, (by doing some
redundant work for the initial threads). But more significantly, we
give the user *some* results nearly instantaneously, (so that the user
might see the result of interest without ever even waiting for the
complete results to come in).

15 years agoAdd some const correctness to talloc 'ctx' parameter.
Carl Worth [Wed, 18 Nov 2009 03:10:37 +0000 (19:10 -0800)]
Add some const correctness to talloc 'ctx' parameter.

The tentacles of const just keep reaching out.

15 years agodatabase: Make _parse_message_id static once again.
Carl Worth [Wed, 18 Nov 2009 02:50:13 +0000 (18:50 -0800)]
database: Make _parse_message_id static once again.

We had exposed this to the internal implementation for a short time,
(only while we had the silly code fetching In-Reply-To values from
message files instead of from the database). Make this private again
as it should be.

15 years agodatabase: Add "replyto" to the database schema documentation.
Carl Worth [Wed, 18 Nov 2009 02:48:38 +0000 (18:48 -0800)]
database: Add "replyto" to the database schema documentation.

Maybe ths lack of this documentation is why I forgot we were actually
storing this and wrote the ugly code to fetch In-Reply-To from message
files rather than from the database.

15 years agodatabase: Rename "ref" prefix name to "reference"
Carl Worth [Wed, 18 Nov 2009 02:44:02 +0000 (18:44 -0800)]
database: Rename "ref" prefix name to "reference"

Which is more consistent with the XREFERENCE prefix used in the terms
in the database. Also remove some stale documentation describing the
removal of resolved references from the database (we no longer do
this).

15 years agomessage_file_get_header: Use break where more clear than continue.
Carl Worth [Wed, 18 Nov 2009 02:37:45 +0000 (18:37 -0800)]
message_file_get_header: Use break where more clear than continue.

Calling continue here worked only because we set a flag before the
continue, and, check the flag at the beginning of the loop, and *then*
break. It's much more clear to just break in the first place.

15 years agoFix "too many open files" bug by closing message files when done with them.
Keith Packard [Wed, 18 Nov 2009 02:33:42 +0000 (18:33 -0800)]
Fix "too many open files" bug by closing message files when done with them.

The message file header parsing code parses only enough of the file to
find the desired header fields, then it leaves the file open until the
next header parsing call or when the message is no longer in use. If a
large number of messages end up being active, this will quickly run
out of file descriptors.

Here, we add support to explicitly close the message file within a
message, (_notmuch_message_close) and call that from thread
construction code.

Signed-off-by: Keith Packard <keithp@keithp.com>
Edited-by: Carl Worth <cworth@cworth.org>:
Many portions of Keith's original patch have since been solved other
ways, (such as the code that changed the handling of the In-Reply-To
header). So the final version is clean enough that I think even Keith
would be happy to have his name on it.

15 years agonotmuch show: Detect an internal error if a thread has no messages.
Carl Worth [Wed, 18 Nov 2009 01:53:54 +0000 (17:53 -0800)]
notmuch show: Detect an internal error if a thread has no messages.

This really should be impossible---if there are no messages, then what
was the thread object created from? During recent debugging, it was
useful to have this error detected and reported.

15 years agoadd_message: Don't add any self-references to the database.
Carl Worth [Wed, 18 Nov 2009 01:20:32 +0000 (17:20 -0800)]
add_message: Don't add any self-references to the database.

In our scheme it's illegal for any message to refer to itself, (nor
would it be useful for anything anyway). Cut these self-references off
at the source, before they trip up any internal errors.

15 years agomessage_get_thread_id: Generate internal error if message has no thread ID.
Carl Worth [Tue, 17 Nov 2009 19:07:38 +0000 (11:07 -0800)]
message_get_thread_id: Generate internal error if message has no thread ID.

This case was happening when a message had its own message ID in its
In-Reply-To header. The thread-resolution code would find the
partially constructed message, (with no thread ID yet), get garbage
from this function, and then march right along with that garbage.

With this commit, a self-cyclic message like this will now trigger an
internal error rather than marching along silienty. (And a subsequent
commit will remove the call to this function in this case.)

15 years agoRemove the talloc_owner argument from create_for_message_id.
Carl Worth [Tue, 17 Nov 2009 19:02:33 +0000 (11:02 -0800)]
Remove the talloc_owner argument from create_for_message_id.

This function has only one caller, and that one caller was passing the
same value for both talloc_owner and the notmuch database. Dropping
the redundant argument simplifies the documentation of this function
considerably.

15 years agoget_in_reply_to: Implement via the database, not by opening mail file.
Carl Worth [Wed, 18 Nov 2009 01:40:19 +0000 (17:40 -0800)]
get_in_reply_to: Implement via the database, not by opening mail file.

This reduces our reliance on open message_file objects, (so is a step
toward fixing the "too many open files" bug), but more importantly, it
means we don't load a self-referencing in-reply-to header, (since we
weed those out before adding any replyto terms to the database).

15 years agoMakefile: Manual pages shouldn't be executable
Ingmar Vanhassel [Tue, 17 Nov 2009 21:04:07 +0000 (22:04 +0100)]
Makefile: Manual pages shouldn't be executable

15 years agoMakefile: Change default install prefix from /usr to /usr/local, really
Ingmar Vanhassel [Tue, 17 Nov 2009 21:10:18 +0000 (22:10 +0100)]
Makefile: Change default install prefix from /usr to /usr/local, really

15 years agoMakefile: Change default install prefix from /usr to /usr/local
Carl Worth [Tue, 17 Nov 2009 21:05:16 +0000 (13:05 -0800)]
Makefile: Change default install prefix from /usr to /usr/local

We'll be a much more polite package this way. And the user can change
the prefix by editing Makefile.config. Still to be done is to make
configure write out Makefile.config and to add a --prefix option to
configure.

15 years agoMakefile: Prefer directories as the target for install commands.
Carl Worth [Tue, 17 Nov 2009 20:50:46 +0000 (12:50 -0800)]
Makefile: Prefer directories as the target for install commands.

I was confusing myself with some rules installing to directories and
some installing to files. We do still install to a filename when
simultaneously renaming, (such as notmuch-completion.bash to notmuch).

15 years agoUpdate .gitignore, add objects and static archives
Ingmar Vanhassel [Tue, 17 Nov 2009 19:53:21 +0000 (20:53 +0100)]
Update .gitignore, add objects and static archives

15 years agoMakefile: Create installation directories explicitly
Ingmar Vanhassel [Tue, 17 Nov 2009 19:50:29 +0000 (20:50 +0100)]
Makefile: Create installation directories explicitly

Previously, notmuch.1.gz was installed as /usr/share/man/man1 (a file).

15 years agoDeal with situation where sysconf(_SC_GETPW_R_SIZE_MAX) returns -1
Alexander Botero-Lowry [Tue, 17 Nov 2009 19:30:39 +0000 (11:30 -0800)]
Deal with situation where sysconf(_SC_GETPW_R_SIZE_MAX) returns -1

15 years agoFix broken commit.
Carl Worth [Tue, 17 Nov 2009 17:04:14 +0000 (09:04 -0800)]
Fix broken commit.

Oops. I should have actually compiled before pushing.

15 years agoInclude <stdint.h> to get uint32_t in C++ file with gcc 4.4
Mikhail Gusarov [Tue, 17 Nov 2009 15:28:38 +0000 (21:28 +0600)]
Include <stdint.h> to get uint32_t in C++ file with gcc 4.4

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
15 years agoClose message file after parsing message headers
Mikhail Gusarov [Tue, 17 Nov 2009 15:28:37 +0000 (21:28 +0600)]
Close message file after parsing message headers

Keeping unused files open helps to see "Too many open files" often.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
15 years agoadd_message: Avoid a memory leak when user holds on to message return.
Carl Worth [Tue, 17 Nov 2009 16:50:14 +0000 (08:50 -0800)]
add_message: Avoid a memory leak when user holds on to message return.

When this function was originally written, the 'message' object was
always destroyed locally, so I thought it would be good to use a NULL
talloc context to make it more obvious if there was any leak.

Since then, however, this function has been changed to optionally
return the added message, and in that case we *don't* free the message
locally, so let's let the database be the talloc context.

15 years agonotmuch_message_file_get_header returns "" for missing headers, not NULL
Keith Packard [Tue, 17 Nov 2009 03:57:14 +0000 (19:57 -0800)]
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>
15 years agoUse 'forward-line' instead of 'next-line' while walking search display
Keith Packard [Tue, 17 Nov 2009 03:05:02 +0000 (19:05 -0800)]
Use 'forward-line' instead of 'next-line' while walking search display

The documentation for 'next-line' suggests that 'forward-line' is a
better choice for non-interactive usage. That appears to be the case
here; using next-line caused emacs to spin forever for me.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 years agonotmuch.el: Consider an entire line of underscores as a signature separator.
Carl Worth [Tue, 17 Nov 2009 00:39:59 +0000 (16:39 -0800)]
notmuch.el: Consider an entire line of underscores as a signature separator.

This is the default separator used by mailman, so there's a lot of
clutter in thread displays without this. Also, we not provide a nice
variable to the user (notmuch-show-signature-regexp) for configuring
this.

15 years agonotmuch.el: Insert a newline if the last line of a part is missing one.
Carl Worth [Mon, 16 Nov 2009 22:53:02 +0000 (14:53 -0800)]
notmuch.el: Insert a newline if the last line of a part is missing one.

I think there's a GMime bug that we're getting parts decoded without a
final newline (the encoded parts seem to have them just fine). We can
workaround the bug easily enough by finding a part-closing delimiter
that is not at the beginning of a line, and if so, just insert a
newline.

Without this, the one-line-summary of the next message would continue
on the same line as the last line of the previous message, (and this
would often happen for mailing-list messages where mailman would add
an extra part for its signature block).

15 years agonotmuch restore was skipping entries with no new tags
Keith Packard [Mon, 16 Nov 2009 19:53:35 +0000 (11:53 -0800)]
notmuch restore was skipping entries with no new tags

notmuch restore used to only add tags; now that it clears existing
tags, it needs to operate on messages even if the new tag list is empty.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Carl Worth <cworth@cworth.org>:
I fixed up the indentation here, (someday we might switch to 8-space
indents, but we haven't yet).

15 years agonotmuch.el: Display authors in a column separate from subject.
Carl Worth [Mon, 16 Nov 2009 19:57:05 +0000 (11:57 -0800)]
notmuch.el: Display authors in a column separate from subject.

This makes it much easier to actually read the subject lines.

The user can set notmuch-search-authors-width to control the width of
the column.

Two possible ideas for improving this support further:

  1. Make the excess authors invisible instead of removing them from
     the buffer, (which means that isearch could still find them).

  2. Have the user variable control a percentage of the window width
  rather than being a fixed number of columns.

15 years agonotmuch.el: Indent messages to show nested structure of thread.
Carl Worth [Mon, 16 Nov 2009 18:45:10 +0000 (10:45 -0800)]
notmuch.el: Indent messages to show nested structure of thread.

Now that we're actually adding text to the buffer for the indentation,
our old aproach of using positions to record regions to manipulate is
now longer correct. Fortunately, it's easy to switch from positions to
markers which are robust, (just call point-marker instead of point and
all relevant functions accept markers as well as points).

I also finally fixed the bug where the text "[6 line signature]" we
display was causing the one-line-summary of the next message to be on
its same line rather than at the beginning of the next line where it
belongs.

15 years agonotmuch show: Implement proper thread ordering/nesting of messages.
Carl Worth [Mon, 16 Nov 2009 04:39:25 +0000 (20:39 -0800)]
notmuch show: Implement proper thread ordering/nesting of messages.

We now properly analyze the in-reply-to headers to create a proper
tree representing the actual thread and present the messages in this
correct thread order. Also, there's a new "depth:" value added to the
"message{" header so that clients can format the thread as desired,
(such as by indenting replies).

15 years agoMinor whitespace touchup.
Carl Worth [Mon, 16 Nov 2009 04:38:16 +0000 (20:38 -0800)]
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.

15 years agoAdd _notmuch_message_get_in_reply_to.
Carl Worth [Mon, 16 Nov 2009 04:36:51 +0000 (20:36 -0800)]
Add _notmuch_message_get_in_reply_to.

The existing notmuch_message_get_header is *almost* good enough for
this, except that we also need to remove the '<' and '>'
delimiters. We'll probably want to implement this function with
database storage in the future rather than loading the email message.

15 years agoRemove obsolete notmuch_message_get_subject prototype.
Carl Worth [Mon, 16 Nov 2009 04:34:24 +0000 (20:34 -0800)]
Remove obsolete notmuch_message_get_subject prototype.

This prototype has been sitting around for a while with no function
implementing it. I wonder if there's a compiler warning I could turn
on to catch these things.