[notmuch] [PATCH 6/9] Reply to individual messages using message library

2009-11-28 Thread Keith Amidon
{-- Fri, 27 Nov 2009 21:22:36 -0800: Carl  wrote: --}


  Carl> On Fri, 27 Nov 2009 05:30:12 -0800, camalot at picnicpark.org wrote:
  >> From: Keith Amidon 
  >> 
  >> As an alternative to creating a reply from the current thread, this
  >> commit provides functions to create replies directly in emacs using
  >> the message library.
  >> 
  >> A future commit will provide keybindings so that they are easy to
  >> change if a different set is preferred.

  Carl> Can you fill me in a little bit here? The message-mode
  Carl> documentation is quite thin on what the distinctions are between
  Carl> "reply", "wide-reply", and "followup".

Roughly this is my understanding of the
differences:

   reply: reply only to the sender and no other recipients
   wide reply: reply to all recipients (removing self)
   followup: mainly intended for replying to news articles I believe is
the trigger for the Mail-Followup-To behavior.  See:


http://www.gnu.org/software/emacs/manual/html_node/message/Mailing-Lists.html#Mailing-Lists

  Carl> Meanwhile, I don't think we have any need to support different
  Carl> implementations of reply, (that is---I don't want one binding
  Carl> for a "notmuch-based reply" and another for a
  Carl> "message-mode-based reply" without any functional difference in
  Carl> the result).

I agree.  It wasn't clear to me when each type of behavior was useful
and so I erred on the side of making everything available with long
key bindings with the idea that as it became clear what was most useful
the common short key bindings could get those functions.

  Carl> Instead I'd like to define what the functionality is that we
  Carl> want here, and then provide that. I do like taking advantage of
  Carl> things like message-mode functionality wherever it exists, so
  Carl> I'm happy to have the default reply button do
  Carl> (with-current-notmuch-show-message (message-reply)) or whatever.

  Carl> But meanwhile, I'll *also* want to understand what the
  Carl> variations are here so that we can *also* implement them inside
  Carl> of "notmuch reply" so that non-emacs-based interfaces can easily
  Carl> get at similar functionality.

  Carl> So I'm holding off on pushing this patch until I understand it
  Carl> better, (and documentation strings for the new functions might
  Carl> help for that---provided they have more detail than the
  Carl> corresponding documentation strings for the message-mode
  Carl> functions being called).

I'll try to improve my docstings next time around.  Sorry about that!

--- Keith


[notmuch] [PATCH] More portable and easier to read regex in notmuch-search-operate-all

2009-11-28 Thread Jed Brown
The former one worked in 23.1.50.1 but not in 23.1.1.

Signed-off-by: Jed Brown 
---
 notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 96c5d96..65473ba 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1152,7 +1152,7 @@ characters as well as `_.+-'.
 (let ((words action-split))
   (when (null words) (error "No operation given"))
   (while words
-   (unless (string-match-p "^[\+\-][_\+\-\\w]+$" (car words))
+   (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
  (error "Action must be of the form `+thistag -that_tag'"))
(setq words (cdr words
 (apply 'notmuch-call-notmuch-process "tag"
-- 
1.6.5.3



[notmuch] [PATCH] notmuch-reply: Display reply message part using UTF-8.

2009-11-28 Thread Kan-Ru Chen

Same problem as notmuch-show before. Noticed this when I intend to
reply a Chinese mail...


Cheers,
 Kanru


[notmuch] Mailing list Reply-To munging and notmuch reply

2009-11-28 Thread Jed Brown
On Sat, 28 Nov 2009 09:55:43 -0800, Carl Worth  wrote:
> On Sat, 28 Nov 2009 17:05:06 +0100, Jed Brown  wrote:
> > Handling this is a bit messy, I think we want the current behavior
> > unless To matches Reply-To, in which case we use From and Reply-To.  If
> > this is indeed the least bad behavior, I will make a patch for it.
> 
> Oh, I really like that. The condition there avoids breaking legitimate
> uses of Reply-To, (such as the cairo lists I run, where cairo-commit@
> has no user-generated From:---just a single automated address, but has
> Reply-To: set to the cairo@ list instead so that replies to committed
> patches go to the right place).

I'm not sure I follow (at least not when comparing to the sanitized
headers shown in the online archives).  Could you send me one of these
headers?

When mailing lists munge, do they ever just add to that field (RFC-2822
says Reply-To may contain multiple addresses)?

Jed
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/c82be920/attachment.pgp>


[notmuch] [PATCH] notmuch-reply: Display reply message part using UTF-8.

2009-11-28 Thread Kan-Ru Chen
Pass the message through the charset filter so that we can view
messages wrote in different charset encoding.

Signed-off-by: Kan-Ru Chen 
---
 notmuch-reply.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 9ca1236..0cda72d 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -39,11 +39,17 @@ reply_part_content (GMimeObject *part)
 {
 GMimeStream *stream_stdout = NULL, *stream_filter = NULL;
 GMimeDataWrapper *wrapper;
+const char *charset;

+charset = g_mime_object_get_content_type_parameter (part, "charset");
 stream_stdout = g_mime_stream_file_new (stdout);
 if (stream_stdout) {
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
stream_filter = g_mime_stream_filter_new(stream_stdout);
+if (charset) {
+  g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
+   g_mime_filter_charset_new(charset, 
"UTF-8"));
+}
 }
 g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
 g_mime_filter_reply_new(TRUE));
-- 
1.6.5.3



[notmuch] [PATCH 3/3] fix Makefile.local to install bash completion definitions as not executable

2009-11-28 Thread Jameson Graef Rollins
---
 Makefile.local |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 1744747..b818627 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -36,7 +36,7 @@ install: all notmuch.1.gz
done ;
install notmuch $(DESTDIR)$(prefix)/bin/
install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
-   install contrib/notmuch-completion.bash \
+   install -m0644 contrib/notmuch-completion.bash \
$(DESTDIR)$(bash_completion_dir)/notmuch

 install-emacs: install emacs
-- 
1.6.5



[notmuch] [PATCH 2/3] add checking for zlib development libraries to configure script

2009-11-28 Thread Jameson Graef Rollins
---
 configure |   14 +-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index ab28fa3..1010799 100755
--- a/configure
+++ b/configure
@@ -63,6 +63,15 @@ else
 errors=$((errors + 1))
 fi

+if printf 'int main(){return 0;}' | gcc -x c -lz -o /dev/null - > /dev/null 
2>&1; then
+echo "Checking for zlib development files... Yes."
+have_zlib=1
+else
+echo "Checking for zlib development files... No."
+have_zlib=0
+errors=$((errors + 1))
+fi
+
 if pkg-config --modversion valgrind > /dev/null 2>&1; then
 echo "Checking for valgrind development files... Yes."
 have_valgrind=-DHAVE_VALGRIND
@@ -91,13 +100,16 @@ EOF
echo "  The talloc library (including development files such as 
headers)"
echo "  http://talloc.samba.org/;
 fi
+if [ $have_zlib -eq 0 ]; then
+   echo "  The zlib library (including development files such as headers)"
+fi
 cat <

[notmuch] [PATCH 1/3] fix configure script to handle --prefix= and properly create Makefile.config

2009-11-28 Thread Jameson Graef Rollins
This also removes the Makefile.config from the repository, since it
shouldn't be kept in the repository and should be created by the
configure script.
---
 Makefile.config |3 ---
 configure   |   12 +++-
 2 files changed, 11 insertions(+), 4 deletions(-)
 delete mode 100644 Makefile.config

diff --git a/Makefile.config b/Makefile.config
deleted file mode 100644
index ddc7436..000
--- a/Makefile.config
+++ /dev/null
@@ -1,3 +0,0 @@
-prefix = /usr/local
-bash_completion_dir = /etc/bash_completion.d
-CFLAGS += -DHAVE_VALGRIND
diff --git a/configure b/configure
index e55f067..ab28fa3 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,15 @@
 #! /bin/sh

+# defaults
+PREFIX=/usr/local
+
+# option parsing
+for option; do
+if [ "${option%=*}" = '--prefix' ] ; then
+   PREFIX="${option#*=}"
+fi
+done
+
 cat < Makefile.config <

[notmuch] [PATCH] Documentation for notmuch reply --format=(default|headers-only)

2009-11-28 Thread Jed Brown
Signed-off-by: Jed Brown 
---
 notmuch.1 |   22 +++---
 notmuch.c |   16 ++--
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/notmuch.1 b/notmuch.1
index 2be77f9..04bd0cf 100644
--- a/notmuch.1
+++ b/notmuch.1
@@ -211,9 +211,9 @@ section below for details of the supported syntax for 
.
 The
 .B reply
 command is useful for preparing a template for an email reply.
-
-.TP
-.BR reply " ..."
+.RS 4
+.TP 4
+.BR reply " [options...] ..."

 Constructs a reply template for a set of messages.

@@ -236,6 +236,21 @@ each line with '> ' and included in the body.

 The resulting message template is output to stdout.

+Supported options for
+.B reply
+include
+.RS
+.TP 4
+.BR \-\-format= ( default | headers\-only )
+.RS
+.TP 4
+.BR default
+Includes subject and quoted message body.
+.TP
+.BR headers-only
+Only produces In-Reply-To, References, To, Cc, and Bcc headers.
+.RE
+
 See the
 .B "SEARCH SYNTAX"
 section below for details of the supported syntax for .
@@ -248,6 +263,7 @@ once. For example, when a series of patches are sent in a 
single
 thread, replying to the entire thread allows for the reply to comment
 on issue found in multiple patches.
 .RE
+.RE

 The
 .B tag
diff --git a/notmuch.c b/notmuch.c
index 5b0284c..d9846ce 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -204,7 +204,7 @@ command_t commands[] = {
   "\t\tSee \"notmuch help search-terms\" for details of the search\n"
   "\t\tterms syntax." },
 { "reply", notmuch_reply_command,
-  " [...]",
+  "[options...]  [...]",
   "\t\tConstruct a reply template for a set of messages.",
   "\t\tConstructs a new message as a reply to a set of existing\n"
   "\t\tmessages. The Reply-To: header (if any, otherwise From:) is\n"
@@ -213,10 +213,22 @@ command_t commands[] = {
   "\n"
   "\t\tA suitable subject is constructed. The In-Reply-to: and\n"
   "\t\tReferences: headers are set appropriately, and the content\n"
-  "\t\tof the original messages is quoted and included in the body.\n"
+  "\t\tof the original messages is quoted and included in the body\n"
+  "\t\t(unless --format=headers-only is given).\n"
   "\n"
   "\t\tThe resulting message template is output to stdout.\n"
   "\n"
+  "\t\tSupported options for reply include:\n"
+  "\n"
+  "\t\t--format=(default|headers-only)\n"
+  "\n"
+  "\t\t\tdefault:\n"
+  "\t\t\t\tIncludes subject and quoted message body.\n"
+  "\n"
+  "\t\t\theaders-only:\n"
+  "\t\t\t\tOnly produces In-Reply-To, References, To\n"
+  "\t\t\t\tCc, and Bcc headers.\n"
+  "\n"
   "\t\tSee \"notmuch help search-terms\" for details of the search\n"
   "\t\tterms syntax." },
 { "tag", notmuch_tag_command,
-- 
1.6.5.3



[notmuch] Archiving outgoing email in Gnus (was Re: notmuch-new: Eliminate tallocs whilst construct filenames.)

2009-11-28 Thread Adam Sjøgren
On Fri, 27 Nov 2009 05:23:06 -0800, Carl wrote:

>   [*] I tried and tried to figure out how to get gnus to save an Fcc (a
>   file copy of all outgoing messages), and failed to configure the
>   various "fake newsgroup things" that gnus wanted for me to be able
>   to do this.

I use this simple recipe for archiving all my outgoing emails and
news-articles in nnml+archive:{news,mail}-{year} in Gnus:

  ; Define nnml+archive: for archiving emails and news in ~/Mail/archive:
  (setq gnus-message-archive-method '(nnml "archive"
   (nnml-directory "~/Mail/archive")
   (nnml-active-file 
"~/Mail/archive/active")
   (nnml-get-new-mail nil)
   (nnml-inhibit-expiry t)))

  ; Tell Gnus to archive outgoing articles/emails automatically:
  (setq gnus-message-archive-group
'((if (message-news-p)
  (concat "news-" (format-time-string "%Y"))
(concat "mail-" (format-time-string "%Y")

  ; Mark gcc'ed (archive) as read:
  (setq gnus-gcc-mark-as-read t)

>   The other piece I want is for unsent mail drafts to automatically
>   be saved, and for notmuch to prompt me to continue with a draft if
>   I start composing a new message while a draft is
>   around. Currently, I can save a draft while composing in
>   message-mode with "C-x C-s" but the big bug here is that the
>   drafts never get deleted when I send the message, so I can't tell
>   unfinished drafts apart from completed-and-sent messages.

(This works for me in Gnus: automatic saving, deletion when sending.)


  Best regards,

Adam

-- 
 "I'll dye without my hair!"  Adam Sj?gren
 asjo at koldfront.dk



[notmuch] Mailing list Reply-To munging and notmuch reply

2009-11-28 Thread Jed Brown
First, I'm aware that such munging is A Bad Thing

  http://www.unicom.com/pw/reply-to-harmful.html

but a lot of lists do it anyway (mostly to work around widely used
mailers with lame defaults).  After munging, we get headers looking like
this

  From: Some User 
  To: Sample users list 
  Reply-To: Sample users list 

Notmuch reply produces

  To: Sample users list ,
  Sample users list 

Handling this is a bit messy, I think we want the current behavior
unless To matches Reply-To, in which case we use From and Reply-To.  If
this is indeed the least bad behavior, I will make a patch for it.

Jed
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/9a259968/attachment.pgp>


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-28 Thread Adam Sjøgren
On Fri, 27 Nov 2009 23:10:30 +0100, Tassilo wrote:

>> Unable to open server nntp+news, go offline? (y or n) 

> Hm, I can reproduce that with "emacs -Q".  Looks wrong to me, probably a
> bug...  Normally, an unconfigured Gnus should start having one nndoc
> server providing some groups with static Gnus infos (FAQ and stuff).

I don't think that is a bug, Gnus defaults to connecting to a
news-server (more info in "Finding the News" in the manual?.)

I think the minimal way to configure Gnus to start up without contacting
a news-server is:

  (setq gnus-select-method '(nnnil ""))


  Best regards,

Adam


? http://gnus.org/manual/gnus_2.html

-- 
 "I'll dye without my hair!"  Adam Sj?gren
 asjo at koldfront.dk



[notmuch] [PATCH v3] Add the beginnings of a test suite.

2009-11-28 Thread Jeffrey C. Ollie
This is the beginning of a test suite.  It uses the Check[1] unit
testing framework to handle the testing.  There are basic tests of the
SHA1 and tag manipulation routines, obviously many more will need to
be added.

Run "make check" from the toplevel directory to build and run the
checks.

[1] http://check.sourceforge.net/

Signed-off-by: Jeffrey C. Ollie 
---
 .gitignore  |1 +
 Makefile|1 +
 Makefile.local  |3 ++
 checks/Makefile.local   |   14 +++
 checks/notmuch-check-sha1.c |   76 ++
 checks/notmuch-check-tags.c |   84 +++
 checks/notmuch-check.c  |   40 
 checks/notmuch-check.h  |   24 
 configure   |8 
 9 files changed, 251 insertions(+), 0 deletions(-)
 create mode 100644 checks/Makefile.local
 create mode 100644 checks/notmuch-check-sha1.c
 create mode 100644 checks/notmuch-check-tags.c
 create mode 100644 checks/notmuch-check.c
 create mode 100644 checks/notmuch-check.h

diff --git a/.gitignore b/.gitignore
index 8794354..bd542d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ notmuch.1.gz
 *~
 .*.swp
 *.elc
+checks/check
diff --git a/Makefile b/Makefile
index 2cd1b1b..1a4c8db 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@ override LDFLAGS += \
 # Include our local Makefile.local first so that its first target is default
 include Makefile.local
 include lib/Makefile.local
+include checks/Makefile.local

 # And get user settings from the output of configure
 include Makefile.config
diff --git a/Makefile.local b/Makefile.local
index 1744747..f6ffd00 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -47,5 +47,8 @@ install-emacs: install emacs
install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)

+check: checks/check
+   checks/check
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz
diff --git a/checks/Makefile.local b/checks/Makefile.local
new file mode 100644
index 000..57797ea
--- /dev/null
+++ b/checks/Makefile.local
@@ -0,0 +1,14 @@
+dir=checks
+extra_cflags += -I$(dir)
+
+check_c_srcs = \
+   $(dir)/notmuch-check.c  \
+   $(dir)/notmuch-check-sha1.c \
+   $(dir)/notmuch-check-tags.c
+
+check_modules = $(check_c_srcs:.c=.o)
+$(dir)/check: $(check_modules)
+   $(call quiet,CXX) $^ $(LDFLAGS) -o $@ lib/notmuch.a -lcheck
+
+SRCS  := $(SRCS) $(check_c_srcs)
+CLEAN := $(CLEAN) $(check_modules) $(dir)/check
diff --git a/checks/notmuch-check-sha1.c b/checks/notmuch-check-sha1.c
new file mode 100644
index 000..c93fc6f
--- /dev/null
+++ b/checks/notmuch-check-sha1.c
@@ -0,0 +1,76 @@
+/* notmuch - Not much of an email program, (just index and search)
+ *
+ * Copyright ?? 2009 Jeffrey C. Ollie
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ *
+ * Authors: Jeffrey C. Ollie 
+ */
+
+#include 
+#include 
+
+#include "notmuch-private.h"
+#include "notmuch-check.h"
+
+START_TEST (test_sha1_of_string)
+{
+   char *result;
+
+   result = notmuch_sha1_of_string("abcdefghi");
+   fail_if(strcmp("e1435dfb334ec81f2bdd5b0aa45969586e7681c0", result) != 0,
+  "SHA1 results for notmuch_sha1_of_string do not match");
+}
+END_TEST
+
+START_TEST (test_sha1_of_file)
+{
+   char filename[20] = "";
+   char *result;
+   int fd;
+   int i;
+
+   strncpy (filename, "/tmp/notmuch.XX", sizeof (filename));
+   fd = mkstemp (filename);
+
+   fail_if (fd == -1,
+   "Unable to create temporary file for SHA1 test");
+
+   for (i = 0; i < 13993; i++)
+  (void) write(fd, "\0", 1);
+
+   close(fd);
+
+   result = notmuch_sha1_of_file(filename);
+
+   unlink(filename);
+
+   fail_if (strcmp ("db38f0e9aa8eb5bcd0d73f3d1ed84d71712cc0ab", result) != 0,
+   "SHA1 results for notmuch_sha1_of_file do not match");
+}
+END_TEST
+
+Suite *
+notmuch_sha1_suite (void)
+{
+   Suite *s = suite_create ("NotMuch SHA1");
+   
+   /* SHA1 test cases */
+   TCase *tc_sha1 = tcase_create ("SHA1");
+   tcase_add_test (tc_sha1, test_sha1_of_string);
+   tcase_add_test (tc_sha1, test_sha1_of_file);
+   suite_add_tcase (s, tc_sha1);
+
+   return s;
+}
diff --git a/checks/notmuch-check-tags.c 

[notmuch] [PATCH] New function notmuch-show-kill-ring-save-message-id.

2009-11-28 Thread Jed Brown
On Fri, 27 Nov 2009 21:54:11 -0800, Carl Worth  wrote:
> Ah. So we have our first case of emacs-lisp portability issues.

Bummer, my docs say nothing about this changing, let alone in a way
that's going to break anything that used it.

> I'm using "GNU emacs 23.1.1" currently, for what it's worth.

GNU Emacs 23.1.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.16.5) of 
2009-10-08 on home.sergej.pp.ru

I'll fix it up and add the prefix argument.

Jed
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/4f3fbc36/attachment-0001.pgp>


[notmuch] [PATCH 5/9] Forward individual messages using message-forward

2009-11-28 Thread Keith Amidon
{-- Sat, 28 Nov 2009 09:49:58 -0800: Carl  wrote: --}
  Carl> So when there are quick and easy things, (like calling an
  Carl> existing function on an 'f' binding like above), that totally
  Carl> makes sense to do. We can look at things like that as interim
  Carl> solutions until the C program grows up.

  Carl> Long-term, I do expect a lot of features to end up being
  Carl> implemented in the C program.

Thanks for your perspective on the best place for things to be
implemented.  I like the pragmatism of using what's easily available in
emacs now and moving to using functions provided by the C implementation
as they become available in the future.  

Since I have relatively limited time right now, I'll probably be a lot
more productive hacking elisp code.  I won't get too attached to that
code though... :-)

--- Keith





[notmuch] [PATCH] Add the beginnings of a test suite.

2009-11-28 Thread Jeffrey C. Ollie
This is the beginning of a test suite.  It uses the Check[1] unit
testing framework to handle the testing.  There's are basic tests of
the SHA1 routines, obviously many more will need to be added.

Run "make check" from the toplevel directory to build and run the
checks.

[1] http://check.sourceforge.net/

Signed-off-by: Jeffrey C. Ollie 
---
 .gitignore|1 +
 Makefile  |1 +
 Makefile.local|3 ++
 checks/Makefile.local |   12 ++
 checks/check.c|   90 +
 configure |8 
 6 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 checks/Makefile.local
 create mode 100644 checks/check.c

diff --git a/.gitignore b/.gitignore
index 8794354..bd542d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ notmuch.1.gz
 *~
 .*.swp
 *.elc
+checks/check
diff --git a/Makefile b/Makefile
index 2cd1b1b..1a4c8db 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@ override LDFLAGS += \
 # Include our local Makefile.local first so that its first target is default
 include Makefile.local
 include lib/Makefile.local
+include checks/Makefile.local

 # And get user settings from the output of configure
 include Makefile.config
diff --git a/Makefile.local b/Makefile.local
index 1744747..f6ffd00 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -47,5 +47,8 @@ install-emacs: install emacs
install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)

+check: checks/check
+   checks/check
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz
diff --git a/checks/Makefile.local b/checks/Makefile.local
new file mode 100644
index 000..ec34d17
--- /dev/null
+++ b/checks/Makefile.local
@@ -0,0 +1,12 @@
+dir=checks
+extra_cflags += -I../lib
+
+check_c_srcs = \
+   $(dir)/check.c
+
+check_modules = $(check_c_srcs:.c=.o)
+$(dir)/check: $(check_modules)
+   $(call quiet,CXX) $^ $(LDFLAGS) -o $@ lib/notmuch.a -lcheck
+
+SRCS  := $(SRCS) $(check_c_srcs)
+CLEAN := $(CLEAN) $(check_modules) $(dir)/check
diff --git a/checks/check.c b/checks/check.c
new file mode 100644
index 000..1b50de1
--- /dev/null
+++ b/checks/check.c
@@ -0,0 +1,90 @@
+/* notmuch - Not much of an email program, (just index and search)
+ *
+ * Copyright ?? 2009 Jeffrey C. Ollie
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ *
+ * Authors: Jeffrey C. Ollie 
+ */
+
+#include 
+#include 
+#include 
+
+#include "notmuch-private.h"
+
+START_TEST (test_sha1_of_string)
+{
+   char *result;
+
+   result = notmuch_sha1_of_string("abcdefghi");
+   fail_if(strcmp("e1435dfb334ec81f2bdd5b0aa45969586e7681c0", result) != 0,
+  "SHA1 results for notmuch_sha1_of_string do not match");
+}
+END_TEST
+
+START_TEST (test_sha1_of_file)
+{
+   char filename[20] = "";
+   char *result;
+   int fd;
+   int i;
+
+   strncpy (filename, "/tmp/notmuch.XX", sizeof (filename));
+   fd = mkstemp (filename);
+
+   fail_if (fd == -1,
+   "Unable to create temporary file for SHA1 test");
+
+   for (i = 0; i < 13993; i++)
+  (void) write(fd, "\0", 1);
+
+   close(fd);
+
+   result = notmuch_sha1_of_file(filename);
+
+   unlink(filename);
+
+   fail_if (strcmp ("db38f0e9aa8eb5bcd0d73f3d1ed84d71712cc0ab", result) != 0,
+   "SHA1 results for notmuch_sha1_of_file do not match");
+}
+END_TEST
+
+static Suite *
+notmuch_suite (void)
+{
+   Suite *s = suite_create ("NotMuch");
+   
+   /* SHA1 test cases */
+   TCase *tc_sha1 = tcase_create ("SHA1");
+   tcase_add_test (tc_sha1, test_sha1_of_string);
+   tcase_add_test (tc_sha1, test_sha1_of_file);
+   suite_add_tcase (s, tc_sha1);
+   return s;
+}
+
+int
+main (void)
+{
+   int number_failed;
+
+   Suite *s = notmuch_suite ();
+   SRunner *sr = srunner_create (s);
+
+   srunner_run_all (sr, CK_VERBOSE);
+   number_failed = srunner_ntests_failed (sr);
+   srunner_free (sr);
+
+   return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/configure b/configure
index e55f067..9e76f09 100755
--- a/configure
+++ b/configure
@@ -61,6 +61,14 @@ else
 have_valgrind=
 fi

+if pkg-config --exists check > /dev/null 2>&1; then
+echo "Checking for the Check unit test framework... Yes."
+have_check=1
+else
+echo "Checking 

[notmuch] [PATCH] Documentation for notmuch reply --format=(default|headers-only)

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 18:56:15 +0100, Jed Brown  wrote:
> Signed-off-by: Jed Brown 
> ---
>  notmuch.1 |   22 +++---
>  notmuch.c |   16 ++--
>  2 files changed, 33 insertions(+), 5 deletions(-)

Perfect, Jed. Thanks!

This is pushed now.

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/3f20c9e8/attachment.pgp>


[notmuch] Mailing list Reply-To munging and notmuch reply

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 20:26:52 +0100, Jed Brown  wrote:
> I'm not sure I follow (at least not when comparing to the sanitized
> headers shown in the online archives).  Could you send me one of these
> headers?

No problem. See attached.

The mail on cairo-commit has a From: address that is auto-generated by
the username of the committer, (so is likely not even valid for a
reply). The To: address (cairo-commit at cairographics.org) also does not
accept any mail. So a reply to either of those addresses will not be
useful.

Instead, the mail sets a Reply-To: to the general
cairo at cairographics.org list.

So that's not your typical Reply-to munging on a mailing list, (in this
case, there's no incoming mail where the munging could break a user's
manually set Reply-To header).

And it sounds like your idea would not break the replying to this list,
(replies would still be directed to cairo@ which is what I want). If I
understand correctly, it would still also reply to cairo-commit@ which
will end up bouncing, until we add something for "reply to sender only".
And that's the same behavior I've had with any MUA and this list.

> When mailing lists munge, do they ever just add to that field (RFC-2822
> says Reply-To may contain multiple addresses)?

I have no idea about that myself.

-Carl

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/aa5d66a5/attachment.pgp>
-- next part --
An embedded and charset-unspecified text was scrubbed...
Name: cairo-commit-sample.mail
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/aa5d66a5/attachment.asc>


[notmuch] [PATCH] More portable and easier to read regex in notmuch-search-operate-all

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 11:58:27 -0800, Keith Packard  wrote:
> On Sat, 28 Nov 2009 20:51:13 +0100, Jed Brown  wrote:
> > The former one worked in 23.1.50.1 but not in 23.1.1.
> > 
> > Signed-off-by: Jed Brown 
> 
> Tested-by: Keith Packard 

Pushed-by: Carl Worth 

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/625321e4/attachment.pgp>


[notmuch] [PATCH] More portable and easier to read regex in notmuch-search-operate-all

2009-11-28 Thread Keith Packard
On Sat, 28 Nov 2009 20:51:13 +0100, Jed Brown  wrote:
> The former one worked in 23.1.50.1 but not in 23.1.1.
> 
> Signed-off-by: Jed Brown 

Tested-by: Keith Packard 

-- 
keith.packard at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/e5bdc970/attachment.pgp>


[notmuch] [PATCH -v6] notmuch.el: Add face support to search mode

2009-11-28 Thread Aneesh Kumar K.V
This patch use notmuch-tag-face showing tags in the notmuch-search-mode.

We can selectively highlight each tag by setting notmuch-tag-face-alist as below

(defface notmuch-tag-unread-face
 'class color)) (:foreground "goldenrod")))
  "Notmuch search mode face used to highligh tags.")

(defface notmuch-tag-inbox-face
 'class color)) (:foreground "red")))
  "Notmuch search mode face used to highligh tags.")

(setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
   ("inbox" . 'notmuch-tag-inbox-face)))
(require 'notmuch)

Signed-off-by: Aneesh Kumar K.V 
---
 notmuch.el |   30 +-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index e9786c0..5cbfedf 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -846,6 +846,23 @@ thread from that buffer can be show when done with this 
one)."
   (goto-char (point-max))
   (forward-line -1))

+(defface notmuch-tag-face
+  'class color)
+  (background dark))
+ (:foreground "OliveDrab1"))
+(((class color)
+  (background light))
+ (:foreground "navy blue" :bold t))
+(t
+ (:bold t)))
+  "Notmuch search mode face used to highligh tags."
+  :group 'notmuch)
+
+(defvar notmuch-tag-face-alist nil
+  "List containing the tag list that need to be highlighed")
+
+(defvar notmuch-search-font-lock-keywords  nil)
+
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode for searching mail with notmuch.
@@ -876,7 +893,18 @@ global search.
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
mode-name "notmuch-search")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (if (not notmuch-tag-face-alist)
+  (add-to-list 'notmuch-search-font-lock-keywords (list
+   "(\\([^)]*\\))$" '(1  'notmuch-tag-face)))
+(progn
+  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))
+  (loop for notmuch-search-tag  in notmuch-search-tags
+do (add-to-list 'notmuch-search-font-lock-keywords (list
+   (concat "([^)]*\\(" notmuch-search-tag 
"\\)[^)]*)$")
+   `(1  ,(cdr (assoc notmuch-search-tag 
notmuch-tag-face-alist
+  (set (make-local-variable 'font-lock-defaults)
+ '(notmuch-search-font-lock-keywords t)))

 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
-- 
1.6.5.2.74.g610f9



[notmuch] Duplicate In-reply-to line 326 lib/message.cc

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 05:40:13 -0400, David Bremner  
wrote:
> Now it seems that any search that is non-empty (i.e. matches
> something) crashes with a duplicate In-Reply-To ID. This is in git
> revision 92c4dcc (although it was the same yesterday).  The oddest
> thing is that the second message-id is a common English word.
...
> Internal error: Message 877htzhn9e.wl%jemarch at gnu.org has duplicate 
> In-Reply-To IDs: 1e5bcefd0911081424p12eb6fa9te57ff4cfeb83fcdd at 
> mail.gmail.com and data
>  (lib/message.cc:326).

Thanks David,

I replicated this without any difficulty. And the fix was to just
correct a stupid mistake on my part. The only reason I hadn't noticed
this myself earlier is that I've been doing debug builds with:

make CFLAGS="-g -DDEBUG"

instead of:

make CFLAGS="-g -DDEBUG" CXXFLAGS="-g -DDEBUG"

If we can, I'd like to see about making the former work, to avoid hiding
things like this in the future.

> At the moment I don't have any real good ideas for how to debug this
> (or any real familiarity with notmuch internals).  I put a test corpus
> of messages (all from public mailing lists) at

Before I realized how easy the bug was to replicate and fix, I was going
to give a couple of debugging ideas here. I guess I'll briefly mention
things anyway.

The core of what we store in the database for each message is a single
list of "terms", (each a string of text). We use different terms for
different purposes by prefixing some with particular sub-strings. See
the large comment at the top of lib/database.cc for some details on
this.

So if there *were* an actual case of a duplicate In-Reply-To term here,
the first thing to do would be to inspect the actual terms in the
database for the document of the message of interest. Up until now, what
I've been using for this is a little utility I wrote called
xapian-dump. It exists deep in the code history of notmuch. So one could
use git log to find the commit that removed it and then check out the
commit before that to get the utility.

But xapian-dump is pretty dumb and all it does is dump all terms from
all documents in the database, (it also dumps all the data and values


[notmuch] [PATCH] Add the beginnings of a test suite.

2009-11-28 Thread Jeffrey C. Ollie
This is the beginning of a test suite.  It uses the Check[1] unit
testing framework to handle the testing.  There's one basic test of
the SHA1 routines, obviously many more will need to be added.

Run "make check" from the toplevel directory to build and run the
checks.

[1] http://check.sourceforge.net/

Signed-off-by: Jeffrey C. Ollie 
---
 .gitignore|1 +
 Makefile  |1 +
 Makefile.local|3 ++
 checks/Makefile.local |   12 +
 checks/check.c|   61 +
 configure |8 ++
 6 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 checks/Makefile.local
 create mode 100644 checks/check.c

diff --git a/.gitignore b/.gitignore
index 8794354..bd542d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ notmuch.1.gz
 *~
 .*.swp
 *.elc
+checks/check
diff --git a/Makefile b/Makefile
index 2cd1b1b..1a4c8db 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@ override LDFLAGS += \
 # Include our local Makefile.local first so that its first target is default
 include Makefile.local
 include lib/Makefile.local
+include checks/Makefile.local

 # And get user settings from the output of configure
 include Makefile.config
diff --git a/Makefile.local b/Makefile.local
index 1744747..f6ffd00 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -47,5 +47,8 @@ install-emacs: install emacs
install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)

+check: checks/check
+   checks/check
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz
diff --git a/checks/Makefile.local b/checks/Makefile.local
new file mode 100644
index 000..ec34d17
--- /dev/null
+++ b/checks/Makefile.local
@@ -0,0 +1,12 @@
+dir=checks
+extra_cflags += -I../lib
+
+check_c_srcs = \
+   $(dir)/check.c
+
+check_modules = $(check_c_srcs:.c=.o)
+$(dir)/check: $(check_modules)
+   $(call quiet,CXX) $^ $(LDFLAGS) -o $@ lib/notmuch.a -lcheck
+
+SRCS  := $(SRCS) $(check_c_srcs)
+CLEAN := $(CLEAN) $(check_modules) $(dir)/check
diff --git a/checks/check.c b/checks/check.c
new file mode 100644
index 000..8886f1f
--- /dev/null
+++ b/checks/check.c
@@ -0,0 +1,61 @@
+/* notmuch - Not much of an email program, (just index and search)
+ *
+ * Copyright ?? 2009 Jeffrey C. Ollie
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ *
+ * Authors: Jeffrey C. Ollie 
+ */
+
+#include 
+#include 
+
+#include "notmuch-private.h"
+
+START_TEST (test_sha1_simple)
+{
+   char *result;
+
+   result = notmuch_sha1_of_string("abcdefghi");
+   fail_if(strcmp("e1435dfb334ec81f2bdd5b0aa45969586e7681c0", result) != 0,
+  "SHA1 results do not match");
+}
+END_TEST
+
+Suite *
+notmuch_suite (void)
+{
+   Suite *s = suite_create ("NotMuch");
+   
+   /* SHA1 test cases */
+   TCase *tc_sha1 = tcase_create ("SHA1");
+   tcase_add_test (tc_sha1, test_sha1_simple);
+   suite_add_tcase (s, tc_sha1);
+   return s;
+}
+
+int
+main (void)
+{
+   int number_failed;
+
+   Suite *s = notmuch_suite ();
+   SRunner *sr = srunner_create (s);
+
+   srunner_run_all (sr, CK_VERBOSE);
+   number_failed = srunner_ntests_failed (sr);
+   srunner_free (sr);
+
+   return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/configure b/configure
index e55f067..9e76f09 100755
--- a/configure
+++ b/configure
@@ -61,6 +61,14 @@ else
 have_valgrind=
 fi

+if pkg-config --exists check > /dev/null 2>&1; then
+echo "Checking for the Check unit test framework... Yes."
+have_check=1
+else
+echo "Checking for the Check unit test framework... No."
+have_check=
+fi
+
 if [ $errors -gt 0 ]; then
 cat <

[notmuch] semi-usable notmuch-gtk client

2009-11-28 Thread Baruch Even
Bart Trojanowski wrote:
> * Baruch Even  [091127 12:58]:
>> I added a quick hack to show a message thread in notmuch-gtk and this  
>> makes it semi-usable. I don't actually parse the reply of notmuch-show  
>> but it's already passably usable to read mail.
> 
> got screenshots?

I created them now at http://baruch.github.com/notmuch-gtk

They are not pretty and not meant to be, I'm currently just tracing out 
the client to get it somewhat functional as a mail client. The niceties 
will come once I actually get to use it as properly.

Baruch


[notmuch] Mailing list Reply-To munging and notmuch reply

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 17:05:06 +0100, Jed Brown  wrote:
> First, I'm aware that such munging is A Bad Thing
> 
>   http://www.unicom.com/pw/reply-to-harmful.html

Definitely.

>   From: Some User 
>   To: Sample users list 
>   Reply-To: Sample users list 
>   
> Notmuch reply produces
> 
>   To: Sample users list ,
>   Sample users list 
> 
> Handling this is a bit messy, I think we want the current behavior
> unless To matches Reply-To, in which case we use From and Reply-To.  If
> this is indeed the least bad behavior, I will make a patch for it.

Oh, I really like that. The condition there avoids breaking legitimate
uses of Reply-To, (such as the cairo lists I run, where cairo-commit@
has no user-generated From:---just a single automated address, but has
Reply-To: set to the cairo@ list instead so that replies to committed
patches go to the right place).

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/fccc7aa2/attachment.pgp>


[notmuch] [PATCH 5/9] Forward individual messages using message-forward

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 09:32:00 -0800, Keith Amidon  
wrote:
> What are your thoughts generally about integration with things like
> message mode vs. implementing more into the C program?  If you think the
> message-mode enhancements will have a life I'll spend some time on this
> and getting the semi-broken version of the reply functions I posted
> working more correctly as well.

My style has generally been to do whatever I think is easiest. And since
I'm a user of the emacs interface to notmuch, that often means trying to
use some of the very full-featured code within emacs first.

But then again, as you've seen, just trying to figure out to use that
code can be a challenge in and of itself. And meanwhile, the
improvements to the C program will benefit the other backends.

So when there are quick and easy things, (like calling an existing
function on an 'f' binding like above), that totally makes sense to
do. We can look at things like that as interim solutions until the C
program grows up.

Long-term, I do expect a lot of features to end up being implemented in
the C program.

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/e96bf6f2/attachment.pgp>


[notmuch] [PATCH 5/9] Forward individual messages using message-forward

2009-11-28 Thread Keith Amidon
{-- Fri, 27 Nov 2009 21:15:15 -0800: Carl  wrote: --}


  Carl> On Fri, 27 Nov 2009 05:30:11 -0800, camalot at picnicpark.org wrote:
  >> From: Keith Amidon 
  >> Sometimes forwarding a message is preferable to replying and
  >> modifying the set of recipients.  This commit provides that ability
  >> using the message-forward function.

  Carl> This is nice functionality---we were obviously missing a
  Carl> "forward" command before. So I've pushed this.

Thanks.

  Carl> Meanwhile, this does miss one piece of functionality that we
  Carl> have in "notmuch reply" which is to select the From: address
  Carl> based on which configured email address of the user was found in
  Carl> the recipient list of the original message being forwarded.

  Carl> Any suggestion for this functionality? Does message-mode provide
  Carl> something similar? And if so, should notmuch.el simply read the
  Carl> notmuch configuration for the various email addresses and
  Carl> provide them to message-mode? I definitely don't want new users
  Carl> of notmuch to have to configure email addresses both inside of
  Carl> notmuch and also inside of message-mode, for example.

I'm sure message-mode can be tweaked either gracefully or savagely in
order to provide this.  I'd be happy to look into it although I
unfortunately don't have a lot of time to code right now. 

What are your thoughts generally about integration with things like
message mode vs. implementing more into the C program?  If you think the
message-mode enhancements will have a life I'll spend some time on this
and getting the semi-broken version of the reply functions I posted
working more correctly as well.

   --- Keith





[notmuch] [PATCH] Use libgcrypt for hashing.

2009-11-28 Thread Mikhail Gusarov

Twas brillig at 21:28:03 27.11.2009 UTC-06 when jeff at ocjtech.us did gyre and 
gimble:

 JCO> Instead of including a private implementation of the SHA1 hash

xserver went this road, and now it has
--with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto in
configure.

 JCO> This means less code of our own to maintain and

As libsha1 maintainer I'm volunteering to maintain in-tree copy in
notmuch :)

-- 
  http://fossarchy.blogspot.com/
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/4b712566/attachment.pgp>


[notmuch] [PATCH 2/9] Adjust autoload comments

2009-11-28 Thread Keith Amidon
{-- Fri, 27 Nov 2009 21:06:45 -0800: Carl  wrote: --}

  Carl> On Fri, 27 Nov 2009 05:30:08 -0800, camalot at picnicpark.org wrote:
  Carl> I had a patch (on a side branch that I must have never merged)
  Carl> that just removed these autoload comments. Do these even do
  Carl> anything for a file that's not being built along with all the
  Carl> lisp code within emacs?

I was interested in them because the gentoo packaging support for emacs
includes the ability to automatically create autoloads from these
comments for installed add-on packages that then get loaded system-wide
when emacs is started.  

I've my own ebuild using this functionality right now that is just
slightly different from the one that was posted here a little while ago.
I've been meaning to merge my version with that one but haven't gotten
to it yet.

   --- Keith



[notmuch] Using notmuch from Ruby, Python, et al.

2009-11-28 Thread Mikhail Gusarov

Twas brillig at 18:55:28 27.11.2009 UTC-08 when cworth at cworth.org did gyre 
and gimble:

 >> Q: Why are my replies five sentences or less?
 >> A: http://five.sentenc.es/

 CW> There---just five this time. :-)

I imagine hook that counts the number of sentences and inserts proper
signature :)

-- 
  http://fossarchy.blogspot.com/
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/1086afa5/attachment.pgp>


[notmuch] [PATCH] Add some text to configure on how to install dependencies with yum.

2009-11-28 Thread Jeffrey C. Ollie
Add some text on how to install dependencies with yum for Fedora or
other systems that use yum for package management.  Since the named of
the required packages on Fedora are slightly different from Debian
this will help get new users of notmuch that use Fedora going quicker.

Signed-off-by: Jeffrey C. Ollie 
---
 configure |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index e55f067..4377167 100755
--- a/configure
+++ b/configure
@@ -89,6 +89,10 @@ line:

sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev

+Or on Fedora or other RPM-based systems:
+
+   sudo yum install xapian-core-devel gmime-devel libtalloc-devel
+
 On other systems, a similar command can be used, but the details of the 
 package names may be different, (such as "devel" in place of "dev").

@@ -103,6 +107,9 @@ with a command such as:

sudo apt-get install pkg-config

+Or:
+   sudo yum install pkgconfig
+
 But if pkg-config is not available for your system, then you will need
 to manually edit the notmuch Makefile to set NOTMUCH_CFLAGS and
 NOTMUCH_LDFLAGS to the correct values without calling pkg-config.
-- 
1.6.5.2



[notmuch] Duplicate In-reply-to line 326 lib/message.cc

2009-11-28 Thread David Bremner

On the trail of a searching problem, I enabled debugging with 
   make CFLAGS="-g -DDEBUG" CXXFLAGS="-g -DDEBUG"

Now it seems that any search that is non-empty (i.e. matches
something) crashes with a duplicate In-Reply-To ID. This is in git
revision 92c4dcc (although it was the same yesterday).  The oddest
thing is that the second message-id is a common English word.

Here is a trace

dulcinea:~/tmp % ~/projects/notmuch/notmuch search spam
Query string is:
spam
Final query is:
Xapian::Query((Tmail AND Zspam:(pos=1)))
Query string is:
thread:13c033781712e92541a5591320ac0ff4
Query string is:
thread:13c033781712e92541a5591320ac0ff4 AND (spam)
Final query is:
Xapian::Query((Tmail AND 0 * G13c033781712e92541a5591320ac0ff4))
Final query is:
Xapian::Query((Tmail AND 0 * G13c033781712e92541a5591320ac0ff4 AND 
Zspam:(pos=1)))
Internal error: Message 877htzhn9e.wl%jemarch at gnu.org has duplicate 
In-Reply-To IDs: 1e5bcefd0911081424p12eb6fa9te57ff4cfeb83fcdd at mail.gmail.com 
and data
 (lib/message.cc:326).

At the moment I don't have any real good ideas for how to debug this
(or any real familiarity with notmuch internals).  I put a test corpus
of messages (all from public mailing lists) at

   http://pivot.cs.unb.ca/scratch/mailtest.tgz

The current tarball is about 5M.  The machine has plenty of bandwidth
(not meant as a challenge to DDOS hobbyists :) ).

d



[notmuch] [PATCH] Use libgcrypt for hashing.

2009-11-28 Thread Ingmar Vanhassel
Excerpts from Mikhail Gusarov's message of Sat Nov 28 04:31:15 +0100 2009:
> 
> Twas brillig at 21:28:03 27.11.2009 UTC-06 when jeff at ocjtech.us did gyre 
> and
> gimble:
> 
>  JCO> Instead of including a private implementation of the SHA1 hash
> 
> xserver went this road, and now it has
> --with-sha1=libc|libmd|libgcrypt|libcrypto|libsha1|CommonCrypto in
> configure.

>From a distribution & security point of view I'd much rather be able to
choose one hashing library & use that as widely as possible, rather than
having every application ship its own copy.

>  JCO> This means less code of our own to maintain and
> 
> As libsha1 maintainer I'm volunteering to maintain in-tree copy in
> notmuch :)

Right, but on top of that, it would still be preferable to keep the
option for packagers to use a system library instead.
Most distributions have a rather strict policy to use system libraries
over internal copies.

-- 
Exherbo KDE, X.org maintainer


[notmuch] [PATCH] Use libgcrypt for hashing.

2009-11-28 Thread Jeffrey Ollie
On Sat, Nov 28, 2009 at 12:43 AM, Carl Worth  wrote:
>
> Have you actually *looked* at the implementation of libsha1.c that we
> have in notmuch? I can't say with 100% certainty that it's free of any
> buffer overruns, but I can see that it's not doing any memory allocation
> nor network communication. So there are entire classes of security
> problems, (such as have afflicted libraries in your examples), that just
> aren't present here.

I've looked at the code, if only briefly.  But you're wrong that the
code doesn't do any "network communication" - we feed libsha1 hostile
data every time we take the hash of a message.

> And as for security compromises due to a bug in the cryptographic nature
> of this function---well, notmuch isn't even *using* SHA-1 for any secure
> purpose.

>From a distributor's point of view, it doesn't matter what you use the
code for, it only matters that it has the bug and someone has to spend
the time to track down all of the copies of the code and replace the
code with a fixed version.  If the code is confined to one shared
library it's trivial to update the shared library, if the code has
been copied to N packages, it's at least N times the work to verify
that all of those packages get updated.

> The actual functionality that we need here is *so* small that I am
> unwilling to introduce a required dependency on any library as large as
> libcrypt. I mean, look at the actual sizes we're talking about

If libgcrypt were some obscure library that wasn't already packaged up
by your favorite distribution or took up hundreds of megabytes of RAM
and/or disk you might have a point.  But the fact is that it *doesn't
matter* how big libgcrypt is because we essentially get it for free -
I'd bet that libgcrypt is already installed on most people's systems.
As a test I tried to remove libgcrypt from my laptop - if I actually
had gone though with it I would have crippled my system because things
like the X server and the package manager depend (albeit indirectly)
on it.

> Now, if somebody wanted to maintain libsha1 inside a distribution like
> Debian, say, then I'd be happy to link against that version rather than
> a locally compiled version. And like I said earlier, if people would
> rather link against a large cyptographic library for this one tiny
> function, then we could arrange that too, but I don't think that
> justifies dropping this code from notmuch and introducing a hard
> dependency.

Given Debian's reputation for packaging the kitchen sink I'm surprised
that it doesn't already.  Fedora tends not to package libraries unless
there is an application that is going to make use of it...

-- 
Jeff Ollie


[notmuch] Snippet to jump to message in Gnus from notmuch-show buffer

2009-11-28 Thread Kan-Ru Chen
On Fri, 27 Nov 2009 04:54:17 -0800, Carl Worth  wrote:
> Do you happen to know some good documentation for how to get started
> with gnus for reading mail? I'd be happy even with the bare minimum to
> just get gnus to view one single message from out of my mail
> store. (Which is something I tried to figure out from the gnus manual,
> but I neve succeeded.)

The easiest way to view a mbox in gnus is using Foreign Group, IMO.

Start gnus then type C-u Gf, it will ask the file location and file
type. You can also use Gm to add other foreign groups, but they still
need some basic settings.

Cheers,
  Kanru
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/188e726e/attachment.pgp>


[notmuch] Problems importing my mail...

2009-11-28 Thread Jeffrey Ollie
On Sat, Nov 28, 2009 at 12:09 AM, Carl Worth  wrote:
> On Fri, 27 Nov 2009 19:09:56 -0600, Jeffrey Ollie  wrote:
>>
>> $ ./notmuch new
>> Found 328184 total files.
>
> That's certainly not the largest number of messages we've seen indexed
> successfully by notmuch, (I think Keith has near 3 times that
> number). [Maybe notmuch should be reporting the total size of the mail
> store as well...]

Heh, I'm not done downloading them all yet, but I doubt that I'll hit
the 1M mark, maybe 500-600K.

>> Warning: Unexpected extra parts of multipart/signed. Indexing anyway.
>
> Oh, that's a warning I put in place because I wasn't sure if it was
> legitimate for a multipart/signed message to have more than two
> parts. I'd actually be interested to know if the mail is correct, (and I
> should just eliminate the warning), or if the mail is somehow malformed
> and the warning is correct.

No, I think it's legitimate to have multiple parts inside of a
multipart/signed (just very rare).  I've identified the message that
caused the warning.  I'm including it as an attachment, hopefully it
won't get tagged as spam because it's a response to a spam report that
I sent a while back.

>> Note: Ignoring non-mail file:
>> /home/jeff/mail/message/6/5/65c74c15a686187bb6bbf9958f494fc6b80068034a659a9ad44991b08c58f2d2
>> Note: Ignoring non-mail file:
>> /home/jeff/mail/message/7/9/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451
>> Note: Ignoring non-mail file:
>> /home/jeff/mail/message/8/0/802071f7fcd8b0b74a19e1ca64e5468184fee0c9171bacb77ae1fe1669c426ee
>
> Those you should check to see if they actually do look like mail
> messages. Notmuch decides to ignore a file when it can't find any of the
> following headers: Subject:, From:, not To:.

Yes, all of those appear to not be complete mail messages, why they
are in one of my IMAP servers remains to be seen.

>> A Xapian exception occurred creating message: Db block overwritten -
>> are there multiple writers?
>> Error: A Xapian exception occurred. Halting processing.
>
> That's an error I've never seen before. We might want to talk to the
> Xapian folks to see what that could be. There's really no way there can
> be multiple writers here. So I don't know what the actual problem might
> be.
>
>> Internal error: Message with document ID of 175013 has no thread ID.
>> ?(lib/message.cc:353).
>> [jeff at max1 notmuch]$ ./notmuch new
>> Internal error: Message with document ID of 175013 has no thread ID.
>> ?(lib/message.cc:353).
>
> Hmm... we could probably do better here. The fatal error you're getting
> here is for an invariant that notmuch thinks is fairly important, (no
> mail document should exist without a thread ID). Meanwhile, however when
> adding a new message we do actually create a mail document in the
> database, and only later resolve its thread ID and add that to the
> database as well. A better solution would be to resolve the thread ID
> before adding anything to the database so that this invariant would
> never be violated.
>
> Some people have been proposing a "notmuch gc" command or so for
> cleaning up problems like this.
>
> In the meantime, you could explore the current state of your database by
> changing the code that's currently giving you an internal error to
> instead return a fake thread ID. For example:
>
> ? ?if (i == message->doc.termlist_end () || id[0] != *prefix)
> ? ? ? ?message->thread_id = talloc_strdup (message, 
> "");
> ? ?else
> ? ? ? ?message->thread_id = talloc_strdup (message, id.c_str () + 1);

Unfortunately I deleted the database and am in the process of
recreating it with the verbose flag turned on.  So far the problem has
not occurred again.  So if there's a real bug somewhere I'm wondering
if there isn't a timing-related component to it.

-- 
Jeff Ollie
-- next part --
A non-text attachment was scrubbed...
Name: multipart.zip
Type: application/zip
Size: 5446 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20091128/57e7b106/attachment-0001.zip>


[notmuch] [PATCH] Send mail to notmuch list, not Carl

2009-11-28 Thread Alec Berryman
---
 configure |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b4770ec..e55f067 100755
--- a/configure
+++ b/configure
@@ -10,8 +10,8 @@ more efficiently than ever.
 If anything goes wrong in this process, please do as much as you can
 to figure out what could be different on your machine compared to
 those of the notmuch developers. Then, please email those details to
-Carl Worth  so that we can hopefully make future
-versions of notmuch easier for you to use.
+the Notmuch list (notmuch at notmuchmail.org) so that we can hopefully make
+future versions of notmuch easier for you to use.

 We'll now investigate your system to find verify that various software
 components that notmuch relies on are available.
-- 
1.6.5




Re: [notmuch] [PATCH] notmuch-reply: Display reply message part using UTF-8.

2009-11-28 Thread Kan-Ru Chen

Same problem as notmuch-show before. Noticed this when I intend to
reply a Chinese mail...


Cheers,
 Kanru
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] Mailing list Reply-To munging and notmuch reply

2009-11-28 Thread Jed Brown
First, I'm aware that such munging is A Bad Thing

  http://www.unicom.com/pw/reply-to-harmful.html

but a lot of lists do it anyway (mostly to work around widely used
mailers with lame defaults).  After munging, we get headers looking like
this

  From: Some User some.u...@example.com
  To: Sample users list sample-us...@sample.org
  Reply-To: Sample users list sample-us...@sample.org
  
Notmuch reply produces

  To: Sample users list sample-us...@sample.org,
  Sample users list sample-us...@sample.org

Handling this is a bit messy, I think we want the current behavior
unless To matches Reply-To, in which case we use From and Reply-To.  If
this is indeed the least bad behavior, I will make a patch for it.

Jed


pgpa3jjgDMPLC.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH 2/9] Adjust autoload comments

2009-11-28 Thread Keith Amidon
{-- Fri, 27 Nov 2009 21:06:45 -0800: Carl cwo...@cworth.org wrote: --}

  Carl On Fri, 27 Nov 2009 05:30:08 -0800, cama...@picnicpark.org wrote:
  Carl I had a patch (on a side branch that I must have never merged)
  Carl that just removed these autoload comments. Do these even do
  Carl anything for a file that's not being built along with all the
  Carl lisp code within emacs?

I was interested in them because the gentoo packaging support for emacs
includes the ability to automatically create autoloads from these
comments for installed add-on packages that then get loaded system-wide
when emacs is started.  

I've my own ebuild using this functionality right now that is just
slightly different from the one that was posted here a little while ago.
I've been meaning to merge my version with that one but haven't gotten
to it yet.

   --- Keith

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Documentation for notmuch reply --format=(default|headers-only)

2009-11-28 Thread Jed Brown
Signed-off-by: Jed Brown j...@59a2.org
---
 notmuch.1 |   22 +++---
 notmuch.c |   16 ++--
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/notmuch.1 b/notmuch.1
index 2be77f9..04bd0cf 100644
--- a/notmuch.1
+++ b/notmuch.1
@@ -211,9 +211,9 @@ section below for details of the supported syntax for 
search-terms.
 The
 .B reply
 command is useful for preparing a template for an email reply.
-
-.TP
-.BR reply  search-term...
+.RS 4
+.TP 4
+.BR reply  [options...] search-term...
 
 Constructs a reply template for a set of messages.
 
@@ -236,6 +236,21 @@ each line with ' ' and included in the body.
 
 The resulting message template is output to stdout.
 
+Supported options for
+.B reply
+include
+.RS
+.TP 4
+.BR \-\-format= ( default | headers\-only )
+.RS
+.TP 4
+.BR default
+Includes subject and quoted message body.
+.TP
+.BR headers-only
+Only produces In-Reply-To, References, To, Cc, and Bcc headers.
+.RE
+
 See the
 .B SEARCH SYNTAX
 section below for details of the supported syntax for search-terms.
@@ -248,6 +263,7 @@ once. For example, when a series of patches are sent in a 
single
 thread, replying to the entire thread allows for the reply to comment
 on issue found in multiple patches.
 .RE
+.RE
 
 The
 .B tag
diff --git a/notmuch.c b/notmuch.c
index 5b0284c..d9846ce 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -204,7 +204,7 @@ command_t commands[] = {
   \t\tSee \notmuch help search-terms\ for details of the search\n
   \t\tterms syntax. },
 { reply, notmuch_reply_command,
-  search-terms [...],
+  [options...] search-terms [...],
   \t\tConstruct a reply template for a set of messages.,
   \t\tConstructs a new message as a reply to a set of existing\n
   \t\tmessages. The Reply-To: header (if any, otherwise From:) is\n
@@ -213,10 +213,22 @@ command_t commands[] = {
   \n
   \t\tA suitable subject is constructed. The In-Reply-to: and\n
   \t\tReferences: headers are set appropriately, and the content\n
-  \t\tof the original messages is quoted and included in the body.\n
+  \t\tof the original messages is quoted and included in the body\n
+  \t\t(unless --format=headers-only is given).\n
   \n
   \t\tThe resulting message template is output to stdout.\n
   \n
+  \t\tSupported options for reply include:\n
+  \n
+  \t\t--format=(default|headers-only)\n
+  \n
+  \t\t\tdefault:\n
+  \t\t\t\tIncludes subject and quoted message body.\n
+  \n
+  \t\t\theaders-only:\n
+  \t\t\t\tOnly produces In-Reply-To, References, To\n
+  \t\t\t\tCc, and Bcc headers.\n
+  \n
   \t\tSee \notmuch help search-terms\ for details of the search\n
   \t\tterms syntax. },
 { tag, notmuch_tag_command,
-- 
1.6.5.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] Duplicate In-reply-to line 326 lib/message.cc

2009-11-28 Thread Carl Worth
On Sat, 28 Nov 2009 05:40:13 -0400, David Bremner brem...@pivot.cs.unb.ca 
wrote:
 Now it seems that any search that is non-empty (i.e. matches
 something) crashes with a duplicate In-Reply-To ID. This is in git
 revision 92c4dcc (although it was the same yesterday).  The oddest
 thing is that the second message-id is a common English word.
...
 Internal error: Message 877htzhn9e.wl%jema...@gnu.org has duplicate 
 In-Reply-To IDs: 1e5bcefd0911081424p12eb6fa9te57ff4cfeb83f...@mail.gmail.com 
 and data
  (lib/message.cc:326).

Thanks David,

I replicated this without any difficulty. And the fix was to just
correct a stupid mistake on my part. The only reason I hadn't noticed
this myself earlier is that I've been doing debug builds with:

make CFLAGS=-g -DDEBUG

instead of:

make CFLAGS=-g -DDEBUG CXXFLAGS=-g -DDEBUG

If we can, I'd like to see about making the former work, to avoid hiding
things like this in the future.

 At the moment I don't have any real good ideas for how to debug this
 (or any real familiarity with notmuch internals).  I put a test corpus
 of messages (all from public mailing lists) at

Before I realized how easy the bug was to replicate and fix, I was going
to give a couple of debugging ideas here. I guess I'll briefly mention
things anyway.

The core of what we store in the database for each message is a single
list of terms, (each a string of text). We use different terms for
different purposes by prefixing some with particular sub-strings. See
the large comment at the top of lib/database.cc for some details on
this.

So if there *were* an actual case of a duplicate In-Reply-To term here,
the first thing to do would be to inspect the actual terms in the
database for the document of the message of interest. Up until now, what
I've been using for this is a little utility I wrote called
xapian-dump. It exists deep in the code history of notmuch. So one could
use git log to find the commit that removed it and then check out the
commit before that to get the utility.

But xapian-dump is pretty dumb and all it does is dump all terms from
all documents in the database, (it also dumps all the data and values
From those documents, but we're not talking about those parts
here). So that's a *lot* of output. More interesting would be a tool to
dump just the terms from the message you're wanting to debug. So that's
why I want to introduce a new notmuch search --for=terms or so to have
a much more useful debugging tool.

Anyway, I hope that was informative.

Thanks for reporting the bug!

-Carl

commit 64c8d6227a90ea6c37ea112ee20b14f16b9b46e7
Author: Carl Worth cwo...@cworth.org
Date:   Sat Nov 28 10:01:22 2009 -0800

Avoid bogus internal error reporting duplicate In-Reply-To IDs.

This error was tirggered with a debugging build via:

make CXXFLAGS=-DDEBUG

and reported by David Bremner. The actual error is that I'm an
idiot that doesn't know how to use strcmp's return value. Of
course, the strcmp interface scores a negative 7 on Rusty Russell
ranking of bad interfaces:

http://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html

diff --git a/lib/message.cc b/lib/message.cc
index 03b8c81..49519f1 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -318,7 +318,7 @@ _notmuch_message_get_in_reply_to (notmuch_message_t *message
 in_reply_to = *i;
 
 if (i != message-doc.termlist_end () 
-   strncmp ((*i).c_str (), prefix, prefix_len))
+   strncmp ((*i).c_str (), prefix, prefix_len) == 0)
 {
INTERNAL_ERROR (Message %s has duplicate In-Reply-To IDs: %s and %s\n,
notmuch_message_get_message_id (message),


pgpAMGgje8iiU.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] More portable and easier to read regex in notmuch-search-operate-all

2009-11-28 Thread Jed Brown
The former one worked in 23.1.50.1 but not in 23.1.1.

Signed-off-by: Jed Brown j...@59a2.org
---
 notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 96c5d96..65473ba 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1152,7 +1152,7 @@ characters as well as `_.+-'.
 (let ((words action-split))
   (when (null words) (error No operation given))
   (while words
-   (unless (string-match-p ^[\+\-][_\+\-\\w]+$ (car words))
+   (unless (string-match-p ^[-+][-+_.[:word:]]+$ (car words))
  (error Action must be of the form `+thistag -that_tag'))
(setq words (cdr words
 (apply 'notmuch-call-notmuch-process tag
-- 
1.6.5.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] More portable and easier to read regex in notmuch-search-operate-all

2009-11-28 Thread Keith Packard
On Sat, 28 Nov 2009 20:51:13 +0100, Jed Brown j...@59a2.org wrote:
 The former one worked in 23.1.50.1 but not in 23.1.1.
 
 Signed-off-by: Jed Brown j...@59a2.org

Tested-by: Keith Packard kei...@keithp.com

-- 
keith.pack...@intel.com


pgpA5aGfpQ9gu.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH 5/9] Forward individual messages using message-forward

2009-11-28 Thread Keith Amidon
{-- Sat, 28 Nov 2009 09:49:58 -0800: Carl cwo...@cworth.org wrote: --}
  Carl So when there are quick and easy things, (like calling an
  Carl existing function on an 'f' binding like above), that totally
  Carl makes sense to do. We can look at things like that as interim
  Carl solutions until the C program grows up.

  Carl Long-term, I do expect a lot of features to end up being
  Carl implemented in the C program.

Thanks for your perspective on the best place for things to be
implemented.  I like the pragmatism of using what's easily available in
emacs now and moving to using functions provided by the C implementation
as they become available in the future.  

Since I have relatively limited time right now, I'll probably be a lot
more productive hacking elisp code.  I won't get too attached to that
code though... :-)

--- Keith



___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH v3] Add the beginnings of a test suite.

2009-11-28 Thread Jeffrey C. Ollie
This is the beginning of a test suite.  It uses the Check[1] unit
testing framework to handle the testing.  There are basic tests of the
SHA1 and tag manipulation routines, obviously many more will need to
be added.

Run make check from the toplevel directory to build and run the
checks.

[1] http://check.sourceforge.net/

Signed-off-by: Jeffrey C. Ollie j...@ocjtech.us
---
 .gitignore  |1 +
 Makefile|1 +
 Makefile.local  |3 ++
 checks/Makefile.local   |   14 +++
 checks/notmuch-check-sha1.c |   76 ++
 checks/notmuch-check-tags.c |   84 +++
 checks/notmuch-check.c  |   40 
 checks/notmuch-check.h  |   24 
 configure   |8 
 9 files changed, 251 insertions(+), 0 deletions(-)
 create mode 100644 checks/Makefile.local
 create mode 100644 checks/notmuch-check-sha1.c
 create mode 100644 checks/notmuch-check-tags.c
 create mode 100644 checks/notmuch-check.c
 create mode 100644 checks/notmuch-check.h

diff --git a/.gitignore b/.gitignore
index 8794354..bd542d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ notmuch.1.gz
 *~
 .*.swp
 *.elc
+checks/check
diff --git a/Makefile b/Makefile
index 2cd1b1b..1a4c8db 100644
--- a/Makefile
+++ b/Makefile
@@ -33,6 +33,7 @@ override LDFLAGS += \
 # Include our local Makefile.local first so that its first target is default
 include Makefile.local
 include lib/Makefile.local
+include checks/Makefile.local
 
 # And get user settings from the output of configure
 include Makefile.config
diff --git a/Makefile.local b/Makefile.local
index 1744747..f6ffd00 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -47,5 +47,8 @@ install-emacs: install emacs
install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)
 
+check: checks/check
+   checks/check
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz
diff --git a/checks/Makefile.local b/checks/Makefile.local
new file mode 100644
index 000..57797ea
--- /dev/null
+++ b/checks/Makefile.local
@@ -0,0 +1,14 @@
+dir=checks
+extra_cflags += -I$(dir)
+
+check_c_srcs = \
+   $(dir)/notmuch-check.c  \
+   $(dir)/notmuch-check-sha1.c \
+   $(dir)/notmuch-check-tags.c
+
+check_modules = $(check_c_srcs:.c=.o)
+$(dir)/check: $(check_modules)
+   $(call quiet,CXX) $^ $(LDFLAGS) -o $@ lib/notmuch.a -lcheck
+
+SRCS  := $(SRCS) $(check_c_srcs)
+CLEAN := $(CLEAN) $(check_modules) $(dir)/check
diff --git a/checks/notmuch-check-sha1.c b/checks/notmuch-check-sha1.c
new file mode 100644
index 000..c93fc6f
--- /dev/null
+++ b/checks/notmuch-check-sha1.c
@@ -0,0 +1,76 @@
+/* notmuch - Not much of an email program, (just index and search)
+ *
+ * Copyright © 2009 Jeffrey C. Ollie
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ *
+ * Authors: Jeffrey C. Ollie j...@ocjtech.us
+ */
+
+#include check.h
+#include string.h
+
+#include notmuch-private.h
+#include notmuch-check.h
+
+START_TEST (test_sha1_of_string)
+{
+   char *result;
+
+   result = notmuch_sha1_of_string(abcdefghi);
+   fail_if(strcmp(e1435dfb334ec81f2bdd5b0aa45969586e7681c0, result) != 0,
+  SHA1 results for notmuch_sha1_of_string do not match);
+}
+END_TEST
+
+START_TEST (test_sha1_of_file)
+{
+   char filename[20] = ;
+   char *result;
+   int fd;
+   int i;
+
+   strncpy (filename, /tmp/notmuch.XX, sizeof (filename));
+   fd = mkstemp (filename);
+
+   fail_if (fd == -1,
+   Unable to create temporary file for SHA1 test);
+
+   for (i = 0; i  13993; i++)
+  (void) write(fd, \0, 1);
+
+   close(fd);
+
+   result = notmuch_sha1_of_file(filename);
+
+   unlink(filename);
+
+   fail_if (strcmp (db38f0e9aa8eb5bcd0d73f3d1ed84d71712cc0ab, result) != 0,
+   SHA1 results for notmuch_sha1_of_file do not match);
+}
+END_TEST
+
+Suite *
+notmuch_sha1_suite (void)
+{
+   Suite *s = suite_create (NotMuch SHA1);
+   
+   /* SHA1 test cases */
+   TCase *tc_sha1 = tcase_create (SHA1);
+   tcase_add_test (tc_sha1, test_sha1_of_string);
+   tcase_add_test (tc_sha1, test_sha1_of_file);
+   suite_add_tcase (s, tc_sha1);
+
+   return s;
+}
diff --git a/checks/notmuch-check-tags.c