[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_te

[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 ch

[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] [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] [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 b

[notmuch] [PATCH] Use libgcrypt for hashing.

2009-11-27 Thread Jeffrey C. Ollie
Instead of including a private implementation of the SHA1 hash, use
libgcrypt.  This means less code of our own to maintain and it will be
easier to switch to a different hash function like SHA256.

libgcrypt was chosen because it has a fairly simple API, it's well
tested (it's used in gnutls and gnupg2), and it's licensed under the
LGPL.

Signed-off-by: Jeffrey C. Ollie 
---
 Makefile   |6 +-
 configure  |   15 +++-
 lib/Makefile.local |1 -
 lib/libsha1.c  |  242 
 lib/libsha1.h  |   67 --
 lib/sha1.c |   44 +-
 6 files changed, 42 insertions(+), 333 deletions(-)
 delete mode 100644 lib/libsha1.c
 delete mode 100644 lib/libsha1.h

diff --git a/Makefile b/Makefile
index 2cd1b1b..a5ff3e7 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,8 @@ gzip = gzip

 # Additional flags that we will append to whatever the user set.
 # These aren't intended for the user to manipulate.
-extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
+extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc) \
+   $(shell libgcrypt-config --cflags)
 extra_cxxflags := $(shell xapian-config --cxxflags)

 emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
@@ -28,7 +29,8 @@ override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) 
$(extra_cxxflags)

 override LDFLAGS += \
$(shell pkg-config --libs glib-2.0 gmime-2.4 talloc) \
-   $(shell xapian-config --libs)
+   $(shell xapian-config --libs) \
+   $(shell libgcrypt-config --libs)

 # Include our local Makefile.local first so that its first target is default
 include Makefile.local
diff --git a/configure b/configure
index b4770ec..22f8066 100755
--- a/configure
+++ b/configure
@@ -61,6 +61,15 @@ else
 have_valgrind=
 fi

+if libgcrypt-config --version > /dev/null 2>&1; then
+echo "Checking for libgcrypt development files... Yes."
+have_libgcrypt=1
+else
+echo "Checking for libgcrypt development files... No."
+have_libgcrypt=0
+errors=$((errors + 1))
+fi
+
 if [ $errors -gt 0 ]; then
 cat <http://talloc.samba.org/;
 fi
+if [ $have_libgcrypt -eq 0 ]; then
+   echo "  The libgcrypt library (including development files such as 
headers)"
+   echo "  http://directory.fsf.org/project/libgcrypt/;
+fi
 cat < /* for memcpy() etc.*/
-
-#include "libsha1.h"
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
-
-#define SHA1_BLOCK_SIZE  64
-
-#define rotl32(x,n)   (((x) << n) | ((x) >> (32 - n)))
-#define rotr32(x,n)   (((x) >> n) | ((x) << (32 - n)))
-
-#define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 
0xff00ff00))
-
-#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
-#define bsw_32(p,n) \
-{ int _i = (n); while(_i--) ((uint32_t*)p)[_i] = 
bswap_32(((uint32_t*)p)[_i]); }
-#else
-#define bsw_32(p,n)
-#endif
-
-#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
-
-#if 0
-
-#define ch(x,y,z)   (((x) & (y)) ^ (~(x) & (z)))
-#define parity(x,y,z)   ((x) ^ (y) ^ (z))
-#define maj(x,y,z)  (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
-
-#else   /* Discovered by Rich Schroeppel and Colin Plumb   */
-
-#define ch(x,y,z)   ((z) ^ ((x) & ((y) ^ (z
-#define parity(x,y,z)   ((x) ^ (y) ^ (z))
-#define maj(x,y,z)  (((x) & (y)) | ((z) & ((x) ^ (y
-
-#endif
-
-/* Compile 64 bytes of hash data into SHA1 context. Note*/
-/* that this routine assumes that the byte order in the */
-/* ctx->wbuf[] at this point is in such an order that low   */
-/* address bytes in the ORIGINAL byte stream will go in */
-/* this buffer to the high end of 32-bit words on BOTH big  */
-/* and little endian systems*/
-
-#ifdef ARRAY
-#define q(v,n)  v[n]
-#else
-#define q(v,n)  v##n
-#endif
-
-#define one_cycle(v,a,b,c,d,e,f,k,h)\
-q(v,e) += rotr32(q(v,a),27) +   \
-  f(q(v,b),q(v,c),q(v,d)) + k + h;  \
-q(v,b)  = rotr32(q(v,b), 2)
-
-#define five_cycle(v,f,k,i) \
-one_cycle(v, 0,1,2,3,4, f,k,hf(i  ));   \
-one_cycle(v, 4,0,1,2,3, f,k,hf(i+1));   \
-one_cycle(v, 3,4,0,1,2, f,k,hf(i+2));   \
-one_cycle(v, 2,3,4,0,1, f,k,hf(i+3));   \
-one_cycle(v, 1,2,3,4,0, f,k,hf(i+4))
-
-static void sha1_compile(sha1_ctx ctx[1])
-{   uint32_t*w = ctx->wbuf;
-
-#ifdef ARRAY
-uint32_tv[5];
-memcpy(v, ctx->hash, 5 * sizeof(uint32_t));
-#else
-uint32_tv0, v1, v2, v3, v4;
-v0 = ctx->hash[0]; v1 = ctx->hash[1];
-v2 = ctx->hash[2]; v3 = ctx->hash[3];
-v4 = ctx->hash[4];
-#endif
-
-#define hf(i)   w[i]
-
-five_cycle(v, ch, 0x5a827999,  0);
-five_cycle(v, ch, 0x5a827999,  5);
-five_cycle(v, ch, 0x5a827999, 10);
-one_cycle(v,0,1,2,3,4, ch, 0x5a827999, hf(15))

[notmuch] [PATCH] Silence compiler warning by initializing a variable.

2009-11-25 Thread Jeffrey C. Ollie
If Xapian threw an exception on notmuch_query_count_messages the count
variable could be used uninitialized.  Initialize count to solve the
problem.

Signed-off-by: Jeffrey C. Ollie 
---
 lib/query.cc |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/query.cc b/lib/query.cc
index a571a61..9106b92 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -315,7 +315,7 @@ notmuch_query_count_messages (notmuch_query_t *query)
 {
 notmuch_database_t *notmuch = query->notmuch;
 const char *query_string = query->query_string;
-Xapian::doccount count;
+Xapian::doccount count = 0;

 try {
Xapian::Enquire enquire (*notmuch->xapian_db);
-- 
1.6.5.2



[notmuch] [PATCH] Add tests to configure script to detect strndup and getline

2009-11-23 Thread Jeffrey C. Ollie
Add some simple tests to the configure script to detect strndup and
getline.  It's not important that the tests run, just that they
compile and link without any errors.

Signed-off-by: Jeffrey C. Ollie 
---
 configure |   20 +++-
 getlinetest.c |   13 +
 strnduptest.c |   10 ++
 3 files changed, 42 insertions(+), 1 deletions(-)
 create mode 100644 getlinetest.c
 create mode 100644 strnduptest.c

diff --git a/configure b/configure
index b4770ec..44c1700 100755
--- a/configure
+++ b/configure
@@ -118,6 +118,24 @@ EOF
 exit 1
 fi

+if ! gcc -o strnduptest strnduptest.c > /dev/null 2>&1
+then
+echo "Checking for strndup... No."
+strndup=-Dstrndup=_notmuch_strndup
+else
+echo "Checking for strndup... Yes."
+fi
+rm -f strnduptest
+
+if ! gcc -o getlinetest getlinetest.c > /dev/null 2>&1
+then
+echo "Checking for getline... No."
+getline=-Dgetline=_notmuch_getline
+else
+echo "Checking for getline... Yes."
+fi
+rm -f getlinetest
+
 cat < Makefile.config <
+#include 
+
+int main()
+{
+  ssize_t count = 0;
+  size_t n = 0;
+  char **lineptr = NULL;
+  FILE *stream = NULL;
+
+  count = getline(lineptr, , stream);
+}
diff --git a/strnduptest.c b/strnduptest.c
new file mode 100644
index 000..97c7c80
--- /dev/null
+++ b/strnduptest.c
@@ -0,0 +1,10 @@
+#include 
+
+int main()
+{
+  char *d;
+  const char *s = "";
+  size_t n = 0;
+
+  d = strndup(s, n);
+}
-- 
1.6.5.2



[notmuch] [PATCH] Add private implementations of strndup and getline.

2009-11-23 Thread Jeffrey C. Ollie
Add private implementations of strndup and getline for those platforms
that don't have them (notably Mac OS X) no matter what preprocessor
symbols you define.

Signed-off-by: Jeffrey C. Ollie 
---
 lib/xutil.c |   99 +++
 lib/xutil.h |6 +++
 2 files changed, 105 insertions(+), 0 deletions(-)

diff --git a/lib/xutil.c b/lib/xutil.c
index 6fa5eb0..61467f1 100644
--- a/lib/xutil.c
+++ b/lib/xutil.c
@@ -79,6 +79,105 @@ xstrdup (const char *s)
 return ret;
 }

+/* Mac OS X don't have strndup even if _GNU_SOURCE is defined */
+char *
+_notmuch_strndup (const char *s, size_t n)
+{
+size_t len = strlen (s);
+char *ret;
+
+if (len <= n)
+   return strdup (s);
+
+ret = malloc(n + 1);
+strncpy(ret, s, n);
+ret[n] = '\0';
+return ret;
+}
+
+/* getline implementation is copied from glibc. */
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
+#endif
+
+ssize_t
+_notmuch_getline (char **lineptr, size_t *n, FILE *fp)
+{
+ssize_t result;
+size_t cur_len = 0;
+
+if (lineptr == NULL || n == NULL || fp == NULL)
+{
+   errno = EINVAL;
+   return -1;
+}
+
+if (*lineptr == NULL || *n == 0)
+{
+   *n = 120;
+   *lineptr = (char *) malloc (*n);
+   if (*lineptr == NULL)
+   {
+   result = -1;
+   goto end;
+   }
+}
+
+for (;;)
+{
+   int i;
+
+   i = getc (fp);
+   if (i == EOF)
+   {
+   result = -1;
+   break;
+   }
+
+   /* Make enough space for len+1 (for final NUL) bytes.  */
+   if (cur_len + 1 >= *n)
+   {
+   size_t needed_max =
+   SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
+   size_t needed = 2 * *n + 1;   /* Be generous. */
+   char *new_lineptr;
+
+   if (needed_max < needed)
+   needed = needed_max;
+   if (cur_len + 1 >= needed)
+   {
+   result = -1;
+   goto end;
+   }
+
+   new_lineptr = (char *) realloc (*lineptr, needed);
+   if (new_lineptr == NULL)
+   {
+   result = -1;
+   goto end;
+   }
+
+   *lineptr = new_lineptr;
+   *n = needed;
+   }
+
+   (*lineptr)[cur_len] = i;
+   cur_len++;
+
+   if (i == '\n')
+   break;
+}
+(*lineptr)[cur_len] = '\0';
+result = cur_len ? (ssize_t) cur_len : result;
+
+end:
+return result;
+}
+
 char *
 xstrndup (const char *s, size_t n)
 {
diff --git a/lib/xutil.h b/lib/xutil.h
index b973f7d..d13259a 100644
--- a/lib/xutil.h
+++ b/lib/xutil.h
@@ -39,6 +39,12 @@ char *
 xstrdup (const char *s);

 char *
+_notmuch_strndup (const char *s, size_t n);
+
+ssize_t
+_notmuch_getline (char **lineptr, size_t *n, FILE *stream);
+
+char *
 xstrndup (const char *s, size_t n);

 void
-- 
1.6.5.2



[notmuch] [PATCH] Mac OS X compatibility fixes

2009-11-23 Thread Jeffrey C. Ollie
Here's a patch that adds private implementations of strndup and
getline.  They are unconditionally compiled so that compiler errors in
these functions can be detected on any platform, even those that
provide strndup and getline in the standard library.  I'll have a
patch that handles the strndup/getline detection later today (I've
already done it in SCons, just need to figure out how I want to do it
in plain shell for the current configure script).



[notmuch] [PATCH] Add install target for desktop files.

2009-11-22 Thread Jeffrey C. Ollie
Add an install target that uses desktop-file-install to install the
desktop file in the appropriate location.  The location of the install
can be modified by changing the desktop_dir variable.

Signed-off-by: Jeffrey C. Ollie 
---
 Makefile.local |4 
 configure  |1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index c87e0c4..2e7c3cd 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -45,5 +45,9 @@ install-emacs: install emacs
install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)

+install-desktop:
+   install -d $(DESTDIR)$(desktop_dir)
+   desktop-file-install --mode 0644 --dir $(DESTDIR)$(desktop_dir) 
notmuch.desktop
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz
diff --git a/configure b/configure
index b4770ec..1198ba7 100755
--- a/configure
+++ b/configure
@@ -132,5 +132,6 @@ EOF
 cat > Makefile.config <

[notmuch] [PATCH] Add SCons build files.

2009-11-22 Thread Jeffrey C. Ollie
The SCons build files included here *should* do everything that the
current Makefiles do, plus a little bit of configuration checking.  To
build/install:

scons all emacs
sudo scons install
sudo scons install-emacs
sudo scons install-desktop

Various installation directories can be customized:

sudo scons install DESTDIR=/tmp/buildroot prefix=/opt/notmuch

See the output of 'scons -h' for a complete list of the variables that
can be modified.

Signed-off-by: Jeffrey C. Ollie 
---
 .gitignore |3 +
 SConstruct |  226 
 lib/SConscript |   19 +
 3 files changed, 248 insertions(+), 0 deletions(-)
 create mode 100644 SConstruct
 create mode 100644 lib/SConscript

diff --git a/.gitignore b/.gitignore
index 8794354..6661b3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,6 @@ notmuch.1.gz
 *~
 .*.swp
 *.elc
+.sconsign.dblite
+.sconf_temp
+config.log
diff --git a/SConstruct b/SConstruct
new file mode 100644
index 000..8d6960d
--- /dev/null
+++ b/SConstruct
@@ -0,0 +1,226 @@
+# -*- mode: python; coding: utf-8 -*-
+
+import os
+
+variables = Variables('custom.py')
+
+variables.Add('DESTDIR',
+  'Destination directory',
+  '')
+
+variables.Add('prefix',
+  'Installation prefix',
+  '/usr/local')
+
+variables.Add('bindir',
+  'Directory that user binaries go into',
+  '${prefix}/bin')
+
+variables.Add('datadir',
+  'Directory that static data files go into',
+  '${prefix}/share')
+
+variables.Add('mandir',
+  'Directory that manual pages go into',
+  '${datadir}/man')
+
+variables.Add('emacs_lispdir',
+  'Directory that Emacs LISP files go into',
+  '${default_emacs_lispdir}')
+
+variables.Add('sysconfdir',
+  'Directory that system configuration files go into',
+  '/etc')
+
+variables.Add('bash_completion_dir',
+  'Directory that Bash completion files go into',
+  '${sysconfdir}/bash_completion.d')
+
+variables.Add('desktop_dir',
+  'Directory that desktop files go into',
+  '${datadir}/applications')
+
+variables.Add('gzip',
+  'Gzip executable',
+  'gzip')
+
+variables.Add('emacs',
+  'Emacs executable',
+  'emacs')
+
+def InstallPerm(env, dest, files, perm):
+obj = env.Install(dest, files)
+for i in obj:
+env.AddPostAction(i, Chmod(str(i), perm))
+return dest
+
+def InstallAsPerm(env, dest, files, perm):
+obj = env.InstallAs(dest, files)
+for i in obj:
+env.AddPostAction(i, Chmod(str(i), perm))
+return dest
+
+topenv = Environment(variables = variables,
+ BUILDERS = {'InstallPerm': InstallPerm,
+ 'InstallAsPerm': InstallAsPerm})
+
+topenv.Append(CPPPATH=['#/lib'])
+
+cflags = None
+if os.environ.has_key('CFLAGS'):
+cflags = topenv.ParseFlags(os.environ['CFLAGS'])
+topenv.MergeFlags(cflags)
+
+if os.environ.has_key('CXXFLAGS'):
+cxxflags = topenv.ParseFlags(os.environ['CXXFLAGS'])
+topenv.MergeFlags(cxxflags)
+
+if cflags is None or cxxflags is None:
+optflags = topenv.ParseFlags('-O2')
+topenv.MergeFlags(optflags)
+
+warnflags = topenv.ParseFlags('-Wall -Wextra -Wmissing-declarations 
-Wwrite-strings -Wswitch-enum')
+topenv.MergeFlags(warnflags)
+
+def CheckPkgConfig(context, version):
+context.Message('Checking for pkg-config... ')
+result = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % 
version)[0]
+context.Result(result)
+return result
+ 
+def CheckPkg(context, name):
+context.Message('Checking for %s... ' % name)
+result = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
+context.Result(result)
+return result
+
+def CheckXapian(context):
+context.Message('Checking for xapian-core... ')
+for xapian_config in ['xapian-config-1.1', 'xapian-config']:
+result, output = context.TryAction('%s --version > $TARGET' % 
xapian_config)
+if result:
+xapian_version = output.strip().split()[-1]
+context.env['xapian_config'] = xapian_config
+context.env['xapian_version'] = xapian_version
+context.Result(xapian_version)
+return result
+context.Result(False)
+return False
+
+def CheckEmacs(context):
+context.Message('Checking for emacs... ')
+context.env['default_emacs_lispdir'] = '${prefix}/share/emacs/site-lisp'
+result = context.TryAction('pkg-config --exists emacs')
+if result:
+result, output = context.TryAction('pkg-config emacs --variable 
sitepkglispdir > $TARGET')
+if result:
+context.env['default_emacs_lispdir'] = output.strip()
+context.Result(True)
+return True
+context.Result(False)
+return False
+
+def CheckDesktopFileInstall(c

[notmuch] [PATCH 2/2] Add a .desktop file entry.

2009-11-19 Thread Jeffrey C. Ollie
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 
---
 notmuch.desktop |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)
 create mode 100644 notmuch.desktop

diff --git a/notmuch.desktop b/notmuch.desktop
new file mode 100644
index 000..d29dff6
--- /dev/null
+++ b/notmuch.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=Not Much Mail
+Exec=emacs -f notmuch
+Icon=emblem-mail
+Terminal=false
+Type=Application
+Categories=Network;Email
-- 
1.6.5.2



[notmuch] [PATCH 1/2] Improve installation of emacs mode.

2009-11-19 Thread Jeffrey C. Ollie
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 
---
 .gitignore |2 +-
 Makefile   |6 ++
 Makefile.local |   15 ---
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8417d60..7d3c543 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,4 @@ notmuch.1.gz
 *.[ao]
 *~
 .*.swp
-
+*.elc
diff --git a/Makefile b/Makefile
index 023b2ec..17fa4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ CFLAGS=-O2
 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
 extra_cxxflags := $(shell xapian-config --cxxflags)

+emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
+emacs_startdir := $(shell pkg-config emacs --variable sitestartdir)
+
 # Now smash together user's values with our extra values
 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
@@ -28,6 +31,9 @@ include Makefile.config
 %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

+%.elc: %.el
+   emacs -batch -f batch-byte-compile $<
+
 .deps/%.d: %.c
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.; \
diff --git a/Makefile.local b/Makefile.local
index c44d160..ecd4ceb 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,5 +1,7 @@
 all: notmuch notmuch.1.gz

+emacs: notmuch.elc
+
 notmuch_client_srcs =  \
notmuch.c   \
notmuch-config.c\
@@ -25,15 +27,22 @@ notmuch.1.gz: notmuch.1

 install: all notmuch.1.gz
for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \
-   $(DESTDIR)/$(prefix)/share/emacs/site-lisp/ 
$(DESTDIR)/etc/bash_completion.d/ ; \
+   $(DESTDIR)/etc/bash_completion.d/ ; \
do \
install -d $$d ; \
done ;
install notmuch $(DESTDIR)$(prefix)/bin/
install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
-   install -m0644 notmuch.el $(DESTDIR)$(prefix)/share/emacs/site-lisp/
install notmuch-completion.bash \
$(DESTDIR)/etc/bash_completion.d/notmuch

+install-emacs: install emacs
+   for d in $(DESTDIR)/$(emacs_lispdir) ; \
+   do \
+   install -d $$d ; \
+   done ;
+   install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
+   install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
-CLEAN := $(CLEAN) notmuch $(notmuch_client_modules)
+CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc
-- 
1.6.5.2



[notmuch] [PATCH] notmuch: improve installation of emacs mode

2009-11-19 Thread Jeffrey C. Ollie
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-start directory so that it
   gets loaded automatically.

5) Ignore byte-compiled emacs files.

Signed-off-by: Jeffrey C. Ollie 
---
 .gitignore |2 +-
 Makefile   |6 ++
 Makefile.local |   15 ---
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8417d60..7d3c543 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,4 @@ notmuch.1.gz
 *.[ao]
 *~
 .*.swp
-
+*.elc
diff --git a/Makefile b/Makefile
index 023b2ec..17fa4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ CFLAGS=-O2
 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
 extra_cxxflags := $(shell xapian-config --cxxflags)

+emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
+emacs_startdir := $(shell pkg-config emacs --variable sitestartdir)
+
 # Now smash together user's values with our extra values
 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
@@ -28,6 +31,9 @@ include Makefile.config
 %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

+%.elc: %.el
+   emacs -batch -f batch-byte-compile $<
+
 .deps/%.d: %.c
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.; \
diff --git a/Makefile.local b/Makefile.local
index 6bc01a5..2bb4521 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,5 +1,7 @@
 all: notmuch notmuch.1.gz

+emacs: notmuch.elc
+
 notmuch_client_srcs =  \
notmuch.c   \
notmuch-config.c\
@@ -25,15 +27,22 @@ notmuch.1.gz: notmuch.1

 install: all notmuch.1.gz
for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \
-   $(DESTDIR)/$(prefix)/share/emacs/site-lisp/ 
$(DESTDIR)/etc/bash_completion.d/ ; \
+   $(DESTDIR)/etc/bash_completion.d/ ; \
do \
install -d $$d ; \
done ;
install notmuch $(DESTDIR)$(prefix)/bin/
install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
-   install -m0644 notmuch.el $(DESTDIR)$(prefix)/share/emacs/site-lisp/
install notmuch-completion.bash \
$(DESTDIR)/etc/bash_completion.d/notmuch

+install-emacs: install emacs
+   for d in $(DESTDIR)/$(emacs_startdir) ; \
+   do \
+   install -d $$d ; \
+   done ;
+   install -m0644 notmuch.el $(DESTDIR)$(emacs_startdir)
+   install -m0644 notmuch.elc $(DESTDIR)$(emacs_startdir)
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
-CLEAN := $(CLEAN) notmuch $(notmuch_client_modules)
+CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc
-- 
1.6.5.2



[notmuch] [PATCH] notmuch: improve installation of emacs mode

2009-11-19 Thread Jeffrey C. Ollie
1) Add a separate install target to 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-start directory so that it
   gets loaded automatically.

Signed-off-by: Jeffrey C. Ollie 
---
 Makefile   |6 ++
 Makefile.local |   13 ++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 023b2ec..17fa4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ CFLAGS=-O2
 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
 extra_cxxflags := $(shell xapian-config --cxxflags)

+emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
+emacs_startdir := $(shell pkg-config emacs --variable sitestartdir)
+
 # Now smash together user's values with our extra values
 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
@@ -28,6 +31,9 @@ include Makefile.config
 %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

+%.elc: %.el
+   emacs -batch -f batch-byte-compile $<
+
 .deps/%.d: %.c
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.; \
diff --git a/Makefile.local b/Makefile.local
index 6bc01a5..e4a27e5 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,4 @@
-all: notmuch notmuch.1.gz
+all: notmuch notmuch.1.gz notmuch.elc

 notmuch_client_srcs =  \
notmuch.c   \
@@ -25,15 +25,22 @@ notmuch.1.gz: notmuch.1

 install: all notmuch.1.gz
for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \
-   $(DESTDIR)/$(prefix)/share/emacs/site-lisp/ 
$(DESTDIR)/etc/bash_completion.d/ ; \
+   $(DESTDIR)/etc/bash_completion.d/ ; \
do \
install -d $$d ; \
done ;
install notmuch $(DESTDIR)$(prefix)/bin/
install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
-   install -m0644 notmuch.el $(DESTDIR)$(prefix)/share/emacs/site-lisp/
install notmuch-completion.bash \
$(DESTDIR)/etc/bash_completion.d/notmuch

+install-emacs: install notmuch.elc
+   for d in $(DESTDIR)/$(emacs_startdir) ; \
+   do \
+   install -d $$d ; \
+   done ;
+   install -m0644 notmuch.el $(DESTDIR)$(emacs_startdir)
+   install -m0644 notmuch.elc $(DESTDIR)$(emacs_startdir)
+
 SRCS  := $(SRCS) $(notmuch_client_srcs)
 CLEAN := $(CLEAN) notmuch $(notmuch_client_modules)
-- 
1.6.5.2



[notmuch] [PATCH] notmuch: improve installation of emacs mode

2009-11-19 Thread Jeffrey C. Ollie
1) Don't hardcode the installation directory, instead use emacs'
   pkg-config module.

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

3) Install the emacs mode in emacs' site-start directory so that it
   gets loaded automatically.
---
 Makefile   |6 ++
 Makefile.local |9 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 023b2ec..17fa4a2 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,9 @@ CFLAGS=-O2
 extra_cflags := $(shell pkg-config --cflags glib-2.0 gmime-2.4 talloc)
 extra_cxxflags := $(shell xapian-config --cxxflags)

+emacs_lispdir := $(shell pkg-config emacs --variable sitepkglispdir)
+emacs_startdir := $(shell pkg-config emacs --variable sitestartdir)
+
 # Now smash together user's values with our extra values
 override CFLAGS += $(WARN_FLAGS) $(extra_cflags)
 override CXXFLAGS += $(WARN_FLAGS) $(extra_cflags) $(extra_cxxflags)
@@ -28,6 +31,9 @@ include Makefile.config
 %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

+%.elc: %.el
+   emacs -batch -f batch-byte-compile $<
+
 .deps/%.d: %.c
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@.; \
diff --git a/Makefile.local b/Makefile.local
index 27e42ba..8aac201 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,4 @@
-all: notmuch notmuch.1.gz
+all: notmuch notmuch.1.gz notmuch.elc

 notmuch_client_srcs =  \
notmuch.c   \
@@ -23,15 +23,16 @@ notmuch: $(notmuch_client_modules) lib/notmuch.a
 notmuch.1.gz: notmuch.1
gzip --stdout notmuch.1 > notmuch.1.gz

-install: all notmuch.1.gz
+install: all notmuch.1.gz notmuch.elc
for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 \
-   $(DESTDIR)/etc/bash_completion.d/ ; \
+   $(DESTDIR)/etc/bash_completion.d/ $(DESTDIR)$(emacs_startdir) ; 
\
do \
install -d $$d ; \
done ;
install notmuch $(DESTDIR)$(prefix)/bin/
install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
-   install -m0644 notmuch.el $(DESTDIR)$(prefix)/share/emacs/site-lisp/
+   install -m0644 notmuch.el $(DESTDIR)$(emacs_startdir)
+   install -m0644 notmuch.elc $(DESTDIR)$(emacs_startdir)
install notmuch-completion.bash \
$(DESTDIR)/etc/bash_completion.d/notmuch

-- 
1.6.5.2



[notmuch] [PATCH] notmuch build: add a RPM spec file

2009-11-18 Thread Jeffrey C. Ollie
Add a spec file for building RPM packages.

Signed-off-by: Jeffrey C. Ollie 
---
 notmuch.spec |  110 ++
 1 files changed, 110 insertions(+), 0 deletions(-)
 create mode 100644 notmuch.spec

diff --git a/notmuch.spec b/notmuch.spec
new file mode 100644
index 000..cca3a1b
--- /dev/null
+++ b/notmuch.spec
@@ -0,0 +1,110 @@
+%global git 306635c2
+
+%if %($(pkg-config emacs) ; echo $?)
+%global emacs_version 23.1
+%global emacs_lispdir %{_datadir}/emacs/site-lisp
+%global emacs_startdir %{_datadir}/emacs/site-lisp/site-start.d
+%else
+%global emacs_version %(pkg-config emacs --modversion)
+%global emacs_lispdir %(pkg-config emacs --variable sitepkglispdir)
+%global emacs_startdir %(pkg-config emacs --variable sitestartdir)
+%endif
+
+Name:   notmuch
+Version:0.0
+Release:0.3.%{git}%{?dist}
+Summary:Not much of an email program
+
+Group:  Applications/Internet
+License:GPLv3+
+URL:http://notmuchmail.org/
+
+#
+# To create a tarball:
+#
+# git clone git://notmuchmail.org/git/notmuch
+# cd notmuch
+# git archive --format=tar --prefix=notmuch/ HEAD | bzip2 > notmuch-`git 
show-ref --hash=8 HEAD`.tar.bz2
+#
+Source0:notmuch-%{git}.tar.bz2
+BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires:  xapian-core-devel
+BuildRequires:  gmime-devel
+BuildRequires:  libtalloc-devel
+BuildRequires:  zlib-devel
+BuildRequires:  emacs-el
+BuildRequires:  emacs-nox
+
+Requires:   emacs(bin) >= %{emacs_version}
+
+%description
+* "Not much mail" is what Notmuch thinks about your email
+  collection. Even if you receive 12000 messages per month or have on
+  the order of millions of messages that you've been saving for
+  decades. Regardless, Notmuch will be able to quickly search all of
+  it. It's just plain not much mail.
+
+* "Not much mail" is also what you should have in your inbox at any
+  time. Notmuch gives you what you need, (tags and fast search), so
+  that you can keep your inbox tamed and focus on what really matters
+  in your life, (which is surely not email).
+
+* Notmuch is an answer to Sup. Sup is a very good email program
+  written by William Morgan (and others) and is the direct inspiration
+  for Notmuch. Notmuch began as an effort to rewrite
+  performance-critical pieces of Sup in C rather than ruby. From
+  there, it grew into a separate project. One significant contribution
+  Notmuch makes compared to Sup is the separation of the
+  indexer/searcher from the user interface. (Notmuch provides a
+  library interface so that its indexing/searching/tagging features
+  can be integrated into any email program.)
+
+* Notmuch is not much of an email program. It doesn't receive messages
+  (no POP or IMAP suport). It doesn't send messages (no mail composer,
+  no network code at all). And for what it does do (email search) that
+  work is provided by an external library, Xapian. So if Notmuch
+  provides no user interface and Xapian does all the heavy lifting,
+  then what's left here? Not much.
+
+Notmuch is still in the early stages of development, but it does
+include one user interface, (implemented within emacs), which has at
+least two users using it for reading all of their incoming mail. If
+you've been looking for a fast, global-search and tag-based email
+reader to use within emacs, then Notmuch may be exactly what you've
+been looking for.
+
+Otherwise, if you're a developer of an existing email program and
+would love a good library interface for fast, global search with
+support for arbitrary tags, then Notmuch also may be exactly what
+you've been looking for.
+
+%prep
+%setup -q -n notmuch
+
+%build
+make %{?_smp_mflags} CFLAGS="%{optflags}"
+emacs -batch -f batch-byte-compile notmuch.el
+
+%install
+rm -rf %{buildroot}
+make install DESTDIR=%{buildroot} prefix=%{_prefix}
+mkdir -p %{buildroot}%{emacs_startdir}
+install -m0644 -p notmuch.el* %{buildroot}%{emacs_startdir}
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%doc AUTHORS COPYING COPYING-GPL-3 INSTALL README TODO
+
+%{_sysconfdir}/bash_completion.d/notmuch
+%{_bindir}/notmuch
+%{_mandir}/man1/notmuch.1*
+%{emacs_startdir}/notmuch.el*
+
+%changelog
+* Wed Nov 18 2009 Jeffrey C. Ollie  - 0.0-0.3.306635c2
+- First version
+
-- 
1.6.5.2



[notmuch] RPM spec file

2009-11-18 Thread Jeffrey C. Ollie
I prefere managing all of the software on my system with RPM, so I
came up with a quick spec file for building RPMS.  Once notmuch
settles down and I continue using it I may submit notmuch to Fedora as
an official package.  If you'd like your own RPMS build your own, I
don't plan on offering a repository of binary packages.