[RFC] Add support for the Solaris platform

2010-04-30 Thread Tomas Carnecky
Like on Mac OS X, the linker doesn't automatically resolve dependencies.

Signed-off-by: Tomas Carnecky 
---
 Makefile.local |2 +-
 configure  |   28 ++--
 lib/Makefile.local |2 +-
 notmuch-new.c  |   70 ++--
 4 files changed, 83 insertions(+), 19 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 5bb570b..5bc872b 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -255,7 +255,7 @@ notmuch_client_srcs =   \
 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)

 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
-   $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
+   $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@

 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
$(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) 
$(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
diff --git a/configure b/configure
index c522ad8..91e08dd 100755
--- a/configure
+++ b/configure
@@ -257,15 +257,26 @@ else
 have_emacs=0
 fi

-printf "Checking for Mac OS X (for shared library)... "
+printf "Checking which platform we are on... "
 if [ `uname` = "Darwin" ] ; then
-printf "Yes.\n"
-mac_os_x=1
+printf "Mac OS X.\n"
+platform=MACOSX
 linker_resolves_library_dependencies=0
-else
-printf "No.\n"
-mac_os_x=0
+elif [ `uname` = "SunOS" ] ; then
+printf "Solaris.\n"
+platform=SOLARIS
+linker_resolves_library_dependencies=0
+elif [ `uname` = "Linux" ] ; then
+printf "Linux\n"
+platform=LINUX
 linker_resolves_library_dependencies=1
+else
+printf "Unknown.\n"
+cat d_name);
 }

+/* Helper functions to test if a given dirent is of a certain type
+ */
+static int
+_is_reg(const char *path, struct dirent *entry)
+{
+#ifdef DT_REG
+if (entry->d_type == DT_REG)
+return 1;
+#endif
+
+char buffer[PATH_MAX];
+snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
+
+struct stat sbuf;
+if (!stat(buffer, &sbuf))
+return S_ISREG(sbuf.st_mode);
+
+return 0;
+}
+
+static int
+_is_dir(const char *path, struct dirent *entry)
+{
+#ifdef DT_DIR
+if (entry->d_type == DT_DIR)
+return 1;
+#endif
+
+char buffer[PATH_MAX];
+snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
+
+struct stat sbuf;
+if (!stat(buffer, &sbuf))
+return S_ISDIR(sbuf.st_mode);
+
+return 0;
+}
+
+static int
+_is_lnk(const char *path, struct dirent *entry)
+{
+#ifdef DT_LNK
+if (entry->d_type == DT_LNK)
+return 1;
+#endif
+
+char buffer[PATH_MAX];
+snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
+
+struct stat sbuf;
+if (!stat(buffer, &sbuf))
+return S_ISLNK(sbuf.st_mode);
+
+return 0;
+}
+
 /* Test if the directory looks like a Maildir directory.
  *
  * Search through the array of directory entries to see if we can find all
@@ -143,12 +199,12 @@ dirent_sort_strcmp_name (const struct dirent **a, const 
struct dirent **b)
  * Return 1 if the directory looks like a Maildir and 0 otherwise.
  */
 static int
-_entries_resemble_maildir (struct dirent **entries, int count)
+_entries_resemble_maildir (const char *path, struct dirent **entries, int 
count)
 {
 int i, found = 0;

 for (i = 0; i < count; i++) {
-   if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)
+   if (!_is_dir(path, entries[i]))
continue;

if (strcmp(entries[i]->d_name, "new") == 0 ||
@@ -261,7 +317,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 }

 /* Pass 1: Recurse into all sub-directories. */
-is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
+is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries);

 for (i = 0; i < num_fs_entries; i++) {
if (interrupted)
@@ -276,9 +332,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
-   if (entry->d_type != DT_DIR &&
-   entry->d_type != DT_LNK &&
-   entry->d_type != DT_UNKNOWN)
+   if (!_is_dir(path, entry) && !_is_lnk(path, entry))
{
continue;
}
@@ -356,7 +410,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
-   if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
+   if (_is_lnk(path, entry)) {
int err;

next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
@@ -372,7 +426,7 @@ add_files_recursive (notmuch_database_t *notmuch,

if (! S_ISREG (st.st_mode))
continue;
-   } else if (entry->d_type != DT_REG) {
+   } else if (!_is_reg(path, entry)) {
continue;
}

-- 
1.

[PATCH] Actually respect LDFLAGS as we say in the ./configure help

2010-04-30 Thread Tomas Carnecky

Signed-off-by: Tomas Carnecky 
---
 configure |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 91e08dd..0153655 100755
--- a/configure
+++ b/configure
@@ -400,6 +400,9 @@ CFLAGS = ${CFLAGS}
 # Default FLAGS for C++ compiler (can be overridden by user such as "make 
CXXFLAGS=-g")
 CXXFLAGS = ${CXXFLAGS}

+# Default FLAGS for the linker (can be overridden by user such as "make 
LDFLAGS=-uhm,whatever")
+LDFLAGS = ${LDFLAGS}
+
 # Flags to enable warnings when using the C++ compiler
 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum

-- 
1.7.1



all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary]

2010-04-30 Thread David Edmondson
On Sat, 24 Apr 2010 07:42:48 -0700, Carl Worth  wrote:
> Next, I wonder if we shouldn't do something similar for the search
> view. It might be quite handy if all authors and all unique subjects for
> a thread were made available for i-search in the buffer, but hidden by
> default and expanded as needed like this. What do you think?

All of the authors appear in the output already, but that doesn't seem
to be the case of the subjects. Would you envisage doing something
similar to the changes Dirk made for authors?

dme.
-- 
David Edmondson, http://dme.org
-- 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/20100430/013a119f/attachment-0001.pgp>


[PATCH 2/2] test: Have notmuch-test use the modular test collections

2010-04-30 Thread Jesse Rosenthal
Introduce two new functions (run_collection_setup_and_tests and
run_test_suite) to notmuch-test. The first takes as an argument a subdir
of test/tests and runs all .setup and .test files in there in order of
their numerical prefix. The latter either runs all tests (if given "all"
or no argument) or a given dir (if given it as an argument).

Also introduce the variable TEST_COLLECTIONS. These are all the folders
that "notmuch-test all" should look for. It won't automatically run all
folders, in case there is something that is only relevant in certain
circumstances (such as, perhaps, future tests for remote usage).
---
 test/notmuch-test |  921 +++--
 1 files changed, 47 insertions(+), 874 deletions(-)

diff --git a/test/notmuch-test b/test/notmuch-test
index a861df1..29d5c91 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -7,6 +7,20 @@ set -e
 # without regard to the time zone of where the test suite is run.
 export TZ=UTC+8

+TEST_COLLECTION_DIR="$(dirname $(readlink -f $0))/tests"
+
+TEST_COLLECTIONS="notmuch-new
+notmuch-search
+json
+thread-naming
+notmuch-reply
+uuencoded
+notmuch-dump-restore
+out-of-order-threading
+author-reordering
+from-guessing-multiple
+from-guessing-single"
+
 find_notmuch_binary ()
 {
 dir=$1
@@ -210,13 +224,15 @@ notmuch_show_sanitize ()
 sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
 }

-rm -rf ${TEST_DIR}
-mkdir ${TEST_DIR}
-cd ${TEST_DIR}
+initialize_notmuch_test ()
+{
+rm -rf ${TEST_DIR}
+mkdir ${TEST_DIR}
+cd ${TEST_DIR}

-mkdir ${MAIL_DIR}
+mkdir ${MAIL_DIR}

-cat < ${NOTMUCH_CONFIG}
+cat < ${NOTMUCH_CONFIG}
 [database]
 path=${MAIL_DIR}

@@ -225,878 +241,35 @@ name=Notmuch Test Suite
 primary_email=test_suite at notmuchmail.org
 other_email=test_suite_other at notmuchmail.org;test_suite at otherdomain.org
 EOF
+}

-printf "Testing \"notmuch new\" in several variations:\n"
-printf " No new messages...\t\t\t\t"
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail."
-
-printf " Single new message...\t\t\t\t"
-generate_message
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added 1 new message to the database."
-
-printf " Multiple new messages...\t\t\t"
-generate_message
-generate_message
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added 2 new messages to the database."
-
-printf " No new messages (non-empty DB)...\t\t"
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail."
-
-printf " New directories...\t\t\t\t"
-rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
-mkdir ${MAIL_DIR}/def
-mkdir ${MAIL_DIR}/ghi
-generate_message [dir]=def
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added 1 new message to the database."
-
-printf " Alternate inode order...\t\t\t"
-
-rm -rf ${MAIL_DIR}/.notmuch
-mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
-rm ${MAIL_DIR}/def/*
-generate_message [dir]=abc
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added 1 new message to the database."
-
-printf " Message moved in...\t\t\t\t"
-rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
-generate_message
-tmp_msg_filename=tmp/$gen_msg_filename
-mkdir -p $(dirname $tmp_msg_filename)
-mv $gen_msg_filename $tmp_msg_filename
-increment_mtime ${MAIL_DIR}
-$NOTMUCH new > /dev/null
-mv $tmp_msg_filename $gen_msg_filename
-increment_mtime ${MAIL_DIR}
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added 1 new message to the database."
-
-printf " Renamed message...\t\t\t\t"
-
-generate_message
-$NOTMUCH new > /dev/null
-mv $gen_msg_filename ${gen_msg_filename}-renamed
-increment_mtime ${MAIL_DIR}
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail. Detected 1 file rename."
-
-printf " Deleted message...\t\t\t\t"
-
-rm ${gen_msg_filename}-renamed
-increment_mtime ${MAIL_DIR}
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail. Removed 1 message."
-
-printf " Renamed directory...\t\t\t\t"
-
-generate_message [dir]=dir
-generate_message [dir]=dir
-generate_message [dir]=dir
-
-$NOTMUCH new > /dev/null
-
-mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
-increment_mtime ${MAIL_DIR}
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail. Detected 3 file renames."
-
-printf " Deleted directory...\t\t\t\t"
-
-rm -rf ${MAIL_DIR}/dir-renamed
-increment_mtime ${MAIL_DIR}
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail. Removed 3 messages."
-
-printf " New directory (at end of list)...\t\t"
-
-generate_message [dir]=zzz
-generate_message [dir]=zzz
-generate_message [dir]=zzz
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added 3 new messages to the database."
-
-printf " Deleted directory (end of list)...\t\t"
-
-rm -rf ${MAIL_DIR}/zzz
-increment_mtime ${MAIL_DIR}
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "No new mail. Removed 3 messages."
-
-printf " New symlink to directory...\t\t\t"
-
-rm -rf ${MAIL_DIR}/.notmuch
-mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
-
-mkdir ${MAIL_DIR}
-ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
-
-output=$(NOTMUCH_NEW)
-pass_if_equal "$output" "Added

[PATCH 1/2] test: add modular test collections

2010-04-30 Thread Jesse Rosenthal
For the sake of modularization, add modular test collections. Each
collection is a subdir of test/tests. With each dir is a series of files
with the prefix "*.test" or "*.setup". The command "notmuch-test X" will
run all of the files test and setup files in X, in numerical order (as
determined by their numerical prefix).

*.test files are the actual tests, while *.setup files are used to change
to the state that the tests expect.

1-$(basename $(pwd)).setup and 9-$(basename $(pwd)).setup are
reserved for setting up for the collection and cleaning up after it. In
the original monolithic test suite, certain tests required a certain state
at their startup. By setting up and cleaning up for each test, we can
guarantee that they do not need to be run in a specific order.

The numbering system for all other tests is 00100, 00200, etc. This is
designed to allow for numerous tests to be added, or added between other
tests, while remaining consistent.
---
 .../1-author-reordering.setup  |2 +
 .../author-reordering/00100-adding-parent-msg.test |4 +
 .../00200-adding-initial-child-message.test|4 +
 .../00300-adding-second-child-msg.test |4 +
 .../00400-search-all-msgs-match.test   |3 +
 .../00500-search-two-msgs-match.test   |3 +
 .../00600-search-one-msg-matches.test  |3 +
 .../00700-search-first-msg-matches.test|3 +
 .../9-author-reordering.setup  |4 +
 .../1-from-guessing-multiple.setup |2 +
 .../00100-nothing-to-go-on.test|   17 +++
 .../from-guessing-multiple/00200-envelope-to.test  |   18 +++
 .../00300-x-original-to.test   |   18 +++
 .../from-guessing-multiple/00400-received-for.test |   20 +++
 .../00500-received-doman.test  |   20 +++
 .../9-from-guessing-multiple.setup |4 +
 .../1-from-guessing-single.setup   |4 +
 .../00100-nothing-to-go-on.test|   17 +++
 .../from-guessing-single/00200-envelope-to.test|   18 +++
 .../from-guessing-single/00300-x-original-to.test  |   18 +++
 .../from-guessing-single/00400-received-for.test   |   20 +++
 .../from-guessing-single/00500-received-doman.test |   20 +++
 .../9-from-guessing-single.setup   |   14 ++
 test/tests/json/1-json.setup   |2 +
 test/tests/json/00100-show-message-json.test   |4 +
 test/tests/json/00200-search-message-json.test |   10 ++
 test/tests/json/00300-search-by-subject-utf8.test  |4 +
 test/tests/json/00400-show-message-json-utf8.test  |4 +
 .../tests/json/00500-search-message-json-utf8.test |   10 ++
 test/tests/json/9-json.setup   |4 +
 .../1-notmuch-dump-restore.setup   |2 +
 .../00100-dumping-all-tags.test|3 +
 .../00200-clearing-all-tags.test   |5 +
 .../00300-restoring-original-tags.test |4 +
 .../00400-restore-with-nothing.test|3 +
 .../9-notmuch-dump-restore.setup   |4 +
 test/tests/notmuch-new/1-notmuch-new.setup |2 +
 test/tests/notmuch-new/00100-no-new-mail.test  |3 +
 test/tests/notmuch-new/00200-one-new-message.test  |4 +
 .../notmuch-new/00300-multiple-new-messages.test   |5 +
 test/tests/notmuch-new/00400-non-empty-db.test |3 +
 test/tests/notmuch-new/00500-new-directories.test  |8 +
 .../notmuch-new/00550-alternate-inode-order.test   |9 ++
 test/tests/notmuch-new/00600-message-moved.test|   12 ++
 test/tests/notmuch-new/00700-renamed-message.test  |8 +
 test/tests/notmuch-new/00800-deleted-message.test  |6 +
 .../tests/notmuch-new/00900-renamed-directory.test |   13 ++
 .../tests/notmuch-new/01000-deleted-directory.test |7 +
 .../notmuch-new/01100-new-directory-end-list.test  |8 +
 .../01200-deleted-directory-end-list.test  |7 +
 .../notmuch-new/01300-new-symlink-to-dir.test  |   10 ++
 .../notmuch-new/01400-new-symlink-to-file.test |9 ++
 .../tests/notmuch-new/01500-new-two-level-dir.test |8 +
 .../notmuch-new/01600-deleted-two-level-dir.test   |7 +
 test/tests/notmuch-new/9-notmuch-new.setup |4 +
 test/tests/notmuch-reply/1-notmuch-reply.setup |2 +
 test/tests/notmuch-reply/00100-basic-reply.test|   17 +++
 .../notmuch-reply/00200-multiple-recipients.test   |   17 +++
 test/tests/notmuch-reply/00300-reply-with-cc.test  |   19 +++
 .../00400-reply-from-alternate-address.test|   17 +++
 .../notmuch-reply/00500-support-for-reply-to.test  |   18 +++
 .../notmuch-reply/00600-unmunging-reply-to.test|   18 +++
 test/tests/notmuch-reply/9-notmuch-reply.setup |4 +
 .../notmuch-search/1-notmuch-search.setup  |  152 
 test/tests/notmuch-search/00100-search-body.test   |4 +
 .../t

[PATCH] Modularize test suite

2010-04-30 Thread Jesse Rosenthal
On Fri, 30 Apr 2010 14:36:56 -0400, Jesse Rosenthal  
wrote:
> Sorry the patch is so large: there was a lot of back-and-forth, and it
> was hard to break the patches down into coherent steps. Carl, if you'd
> prefer, I could send you a more granular, but confusing, series of
> patches.

Actually, due the listing of new files in the patch, the patch was so
large that it got bounced pending moderation (13K, with a 12K
limit). It's not actually as complicated as this size would make seem --
mainly just a lot of moving lines to individual files. Since I'm not
sure who the mod is, I'll take this as a sign that I should try to break
it down into smaller patches.

Sorry for the delay.


[PATCHv2] Restructure notmuch-hello-reflect

2010-04-30 Thread Sebastian Spaeth
This function was "not lispy" according to a comment by dme, and it
also relied on a helper function that used 'cl code. Do away with all
that and provide a hopefully lispy solution that relies on elisp only
to "reflect" a (possibly non-square) matrix along it's diagonal.

Remove now unused notmuch-hello-reflect-generate-row function.

Remove unused notmuch-hello-roundup function (which did exactly the
same as (ceiling divident divisor) anyway).

Signed-off-by: Sebastian Spaeth 
---
 Just for the record, this is the final cleaned up version. 
 Still not sure if dme sees it as an improvement though :-)

 emacs/notmuch-hello.el |   37 +++--
 1 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..8dc8ff9 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -113,29 +113,22 @@
maximize (length (car elem)))
   0))

-(defun notmuch-hello-roundup (dividend divisor)
-  "Return the rounded up value of dividing `dividend' by `divisor'."
-  (+ (/ dividend divisor)
- (if (> (% dividend divisor) 0) 1 0)))
-
-(defun notmuch-hello-reflect-generate-row (ncols nrows row list)
-  (let ((len (length list)))
-(loop for col from 0 to (- ncols 1)
- collect (let ((offset (+ (* nrows col) row)))
-   (if (< offset len)
-   (nth offset list)
- ;; Don't forget to insert an empty slot in the
- ;; output matrix if there is no corresponding
- ;; value in the input matrix.
- nil)
-
 (defun notmuch-hello-reflect (list ncols)
-  "Reflect a `ncols' wide matrix represented by `list' along the
-diagonal."
-  ;; Not very lispy...
-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))
-(loop for row from 0 to (- nrows 1)
- append (notmuch-hello-reflect-generate-row ncols nrows row list
+  "Reflect a `ncols' wide matrix `list' along diagonal."
+  (let* ((l (length list))
+ (brows (ceiling l ncols)) ;;#rows of new matrix
+ (bvector (make-vector l nil));;vector to be returned
+ offset)
+(dotimes (pos l)
+  (aset bvector pos
+   (elt list (setq offset 
+(cond ;;return row number if in first colum
+ ((eq 0 (% pos ncols)) 
+  (setq offset (floor pos ncols)))
+ ((>= (% l ncols) (% pos ncols)) 
+  (+ offset brows)) ;;add brows for first 
'long'cols
+ (t (1- (+ offset brows ;;+ brows-1 for 
remainder
+(append bvector nil)));; return bvector as list

 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
-- 
1.7.0.4



[PATCH] Modularize test suite

2010-04-30 Thread Jesse Rosenthal
Responding to this email is a patch to modularize the test suite. It
follows a relatively simple model, but it does seem like it will offer
some degree of flexibility. Plus, no relicensing is necessary.

In short, tests are put in subdirs of test/tests, e.g.:

 test/tests/notmuch-new/
 test/tests/notmuch-search/
 test/tests/json/
 ...

"notmuch-test" (which is the same as "notmuch-test all") should work as
usual. But if you call "notmuch-test json", it will only the json tests.

It will do this by running all of the files in the json subdir that have
an extension "*.test" or "*.setup" (all other files will be ignored). It
runs them in numerical order, which you can set by a numerical
prefix. So, for example, in test/tests/notmuch-reply:

 1-notmuch-reply.setup
 00100-basic-reply.test  
 00200-multiple-recipients.test  
 00300-reply-with-cc.test
 00400-reply-from-alternate-address.test
 00500-support-for-reply-to.test
 00600-unmunging-reply-to.test
 9-notmuch-reply.setup

The basic numbering system is 00100, 00200, etc. to both allow a lot of
space to fit things in between, and to let the collection of tests
grow. 

1-$(basename $(pwd)).setup and 9-$(basename $(pwd)).setup are
reserved for setting up and cleaning up. This allows us to call
individual sets of tests without calling the entire suite in order to
get the environment that the tests expect.

Note that if you add a new subdir collection of tests, you have to add
it to the $TEST_COLLECTIONS variable in notmuch-test. It doesn't run all
subdirs automatically, in case you want to test something out, or have a
subdir that only works in certain cases (imagine future tests of remote
setups).

Sorry the patch is so large: there was a lot of back-and-forth, and it
was hard to break the patches down into coherent steps. Carl, if you'd
prefer, I could send you a more granular, but confusing, series of
patches.

Best,
Jesse






[PATCH] Restructure notmuch-hello-reflect

2010-04-30 Thread Sebastian Spaeth
This function was "not lispy" according to a comment by dme, and it
also relied on a helper function that used 'cl code. Do away with all
that and provide a hopefully lispy solution that relies on elisp only
to "reflect" a (possibly non-square) matrix along it's diagonal.

Remove now unused notmuch-hello-reflect-generate-row function.

Remove unused notmuch-hello-roundup function (which did exactly the
same as (ceiling divident divisor) anyway).

Signed-off-by: Sebastian Spaeth 
---
 emacs/notmuch-hello.el |   36 ++--
 1 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..1999858 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -113,29 +113,21 @@
maximize (length (car elem)))
   0))

-(defun notmuch-hello-roundup (dividend divisor)
-  "Return the rounded up value of dividing `dividend' by `divisor'."
-  (+ (/ dividend divisor)
- (if (> (% dividend divisor) 0) 1 0)))
-
-(defun notmuch-hello-reflect-generate-row (ncols nrows row list)
-  (let ((len (length list)))
-(loop for col from 0 to (- ncols 1)
- collect (let ((offset (+ (* nrows col) row)))
-   (if (< offset len)
-   (nth offset list)
- ;; Don't forget to insert an empty slot in the
- ;; output matrix if there is no corresponding
- ;; value in the input matrix.
- nil)
-
 (defun notmuch-hello-reflect (list ncols)
-  "Reflect a `ncols' wide matrix represented by `list' along the
-diagonal."
-  ;; Not very lispy...
-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))
-(loop for row from 0 to (- nrows 1)
- append (notmuch-hello-reflect-generate-row ncols nrows row list
+  "Transpose a `ncols' wide matrix `list' along diagonal."
+  (let ((brows (ceiling (length list) ncols)) ;;#rows of new matrix
+bvector offset)
+(setq bvector (make-vector (length list) nil));;vector to be returned
+(dotimes (pos (length list))
+  (aset bvector pos
+   (elt list (setq offset 
+(cond ;;return row number if in first colum
+ ((eq 0 (% pos ncols)) 
+  (setq offset (floor pos ncols)))
+ ((>= (% (length list) ncols) (% pos ncols)) 
+  (+ offset brows)) ;;add brows for first 
'long'cols
+ (t (1- (+ offset brows ;;+ brows-1 for 
remainder
+(append bvector nil)));; return bvector as list

 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
-- 
1.7.0.4



[PATCH] emacs: Remove notmuch-hello-roundup function

2010-04-30 Thread Sebastian Spaeth
as it does the same as (ceiling number divisor) which is already provided in 
elisp.
---
dme, am I right that this patch is really correct?

 emacs/notmuch-hello.el |7 +--
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..8fabbf4 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -113,11 +113,6 @@
maximize (length (car elem)))
   0))

-(defun notmuch-hello-roundup (dividend divisor)
-  "Return the rounded up value of dividing `dividend' by `divisor'."
-  (+ (/ dividend divisor)
- (if (> (% dividend divisor) 0) 1 0)))
-
 (defun notmuch-hello-reflect-generate-row (ncols nrows row list)
   (let ((len (length list)))
 (loop for col from 0 to (- ncols 1)
@@ -133,7 +128,7 @@
   "Reflect a `ncols' wide matrix represented by `list' along the
 diagonal."
   ;; Not very lispy...
-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))
+  (let ((nrows (ceiling (length list) ncols)))
 (loop for row from 0 to (- nrows 1)
  append (notmuch-hello-reflect-generate-row ncols nrows row list

-- 
1.7.0.4



[RFC] Add support for the Solaris platform

2010-04-30 Thread Tomas Carnecky
Like on Mac OS X, the linker doesn't automatically resolve dependencies.

Signed-off-by: Tomas Carnecky 
---
 Makefile.local |2 +-
 configure  |   28 ++--
 lib/Makefile.local |2 +-
 notmuch-new.c  |   70 ++--
 4 files changed, 83 insertions(+), 19 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 5bb570b..5bc872b 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -255,7 +255,7 @@ notmuch_client_srcs =   \
 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
 
 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
-   $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
+   $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@
 
 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
$(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) 
$(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
diff --git a/configure b/configure
index c522ad8..91e08dd 100755
--- a/configure
+++ b/configure
@@ -257,15 +257,26 @@ else
 have_emacs=0
 fi
 
-printf "Checking for Mac OS X (for shared library)... "
+printf "Checking which platform we are on... "
 if [ `uname` = "Darwin" ] ; then
-printf "Yes.\n"
-mac_os_x=1
+printf "Mac OS X.\n"
+platform=MACOSX
 linker_resolves_library_dependencies=0
-else
-printf "No.\n"
-mac_os_x=0
+elif [ `uname` = "SunOS" ] ; then
+printf "Solaris.\n"
+platform=SOLARIS
+linker_resolves_library_dependencies=0
+elif [ `uname` = "Linux" ] ; then
+printf "Linux\n"
+platform=LINUX
 linker_resolves_library_dependencies=1
+else
+printf "Unknown.\n"
+cat d_name);
 }
 
+/* Helper functions to test if a given dirent is of a certain type
+ */
+static int
+_is_reg(const char *path, struct dirent *entry)
+{
+#ifdef DT_REG
+if (entry->d_type == DT_REG)
+return 1;
+#endif
+
+char buffer[PATH_MAX];
+snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
+
+struct stat sbuf;
+if (!stat(buffer, &sbuf))
+return S_ISREG(sbuf.st_mode);
+
+return 0;
+}
+
+static int
+_is_dir(const char *path, struct dirent *entry)
+{
+#ifdef DT_DIR
+if (entry->d_type == DT_DIR)
+return 1;
+#endif
+
+char buffer[PATH_MAX];
+snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
+
+struct stat sbuf;
+if (!stat(buffer, &sbuf))
+return S_ISDIR(sbuf.st_mode);
+
+return 0;
+}
+
+static int
+_is_lnk(const char *path, struct dirent *entry)
+{
+#ifdef DT_LNK
+if (entry->d_type == DT_LNK)
+return 1;
+#endif
+
+char buffer[PATH_MAX];
+snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
+
+struct stat sbuf;
+if (!stat(buffer, &sbuf))
+return S_ISLNK(sbuf.st_mode);
+
+return 0;
+}
+
 /* Test if the directory looks like a Maildir directory.
  *
  * Search through the array of directory entries to see if we can find all
@@ -143,12 +199,12 @@ dirent_sort_strcmp_name (const struct dirent **a, const 
struct dirent **b)
  * Return 1 if the directory looks like a Maildir and 0 otherwise.
  */
 static int
-_entries_resemble_maildir (struct dirent **entries, int count)
+_entries_resemble_maildir (const char *path, struct dirent **entries, int 
count)
 {
 int i, found = 0;
 
 for (i = 0; i < count; i++) {
-   if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)
+   if (!_is_dir(path, entries[i]))
continue;
 
if (strcmp(entries[i]->d_name, "new") == 0 ||
@@ -261,7 +317,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 }
 
 /* Pass 1: Recurse into all sub-directories. */
-is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
+is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries);
 
 for (i = 0; i < num_fs_entries; i++) {
if (interrupted)
@@ -276,9 +332,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
-   if (entry->d_type != DT_DIR &&
-   entry->d_type != DT_LNK &&
-   entry->d_type != DT_UNKNOWN)
+   if (!_is_dir(path, entry) && !_is_lnk(path, entry))
{
continue;
}
@@ -356,7 +410,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
-   if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
+   if (_is_lnk(path, entry)) {
int err;
 
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
@@ -372,7 +426,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 
if (! S_ISREG (st.st_mode))
continue;
-   } else if (entry->d_type != DT_REG) {
+   } else if (!_is_reg(path, entry)) {
continue;
   

[PATCH] Actually respect LDFLAGS as we say in the ./configure help

2010-04-30 Thread Tomas Carnecky

Signed-off-by: Tomas Carnecky 
---
 configure |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 91e08dd..0153655 100755
--- a/configure
+++ b/configure
@@ -400,6 +400,9 @@ CFLAGS = ${CFLAGS}
 # Default FLAGS for C++ compiler (can be overridden by user such as "make 
CXXFLAGS=-g")
 CXXFLAGS = ${CXXFLAGS}
 
+# Default FLAGS for the linker (can be overridden by user such as "make 
LDFLAGS=-uhm,whatever")
+LDFLAGS = ${LDFLAGS}
+
 # Flags to enable warnings when using the C++ compiler
 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
 
-- 
1.7.1

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


Re: [PATCH] Modularize test suite

2010-04-30 Thread Jesse Rosenthal
On Fri, 30 Apr 2010 14:36:56 -0400, Jesse Rosenthal  wrote:
> Sorry the patch is so large: there was a lot of back-and-forth, and it
> was hard to break the patches down into coherent steps. Carl, if you'd
> prefer, I could send you a more granular, but confusing, series of
> patches.

Actually, due the listing of new files in the patch, the patch was so
large that it got bounced pending moderation (13K, with a 12K
limit). It's not actually as complicated as this size would make seem --
mainly just a lot of moving lines to individual files. Since I'm not
sure who the mod is, I'll take this as a sign that I should try to break
it down into smaller patches.

Sorry for the delay.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Remove notmuch-hello-roundup function

2010-04-30 Thread David Edmondson
On Fri, 30 Apr 2010 12:33:57 +0200, Sebastian Spaeth  
wrote:
> as it does the same as (ceiling number divisor) which is already provided in 
> elisp.
> ---
> dme, am I right that this patch is really correct?

Yes. I have the same patch in a tree somewhere here...

dme.
-- 
David Edmondson, http://dme.org
-- 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/20100430/9bedaf05/attachment.pgp>


[PATCH] Modularize test suite

2010-04-30 Thread Jesse Rosenthal
Responding to this email is a patch to modularize the test suite. It
follows a relatively simple model, but it does seem like it will offer
some degree of flexibility. Plus, no relicensing is necessary.

In short, tests are put in subdirs of test/tests, e.g.:

 test/tests/notmuch-new/
 test/tests/notmuch-search/
 test/tests/json/
 ...

"notmuch-test" (which is the same as "notmuch-test all") should work as
usual. But if you call "notmuch-test json", it will only the json tests.

It will do this by running all of the files in the json subdir that have
an extension "*.test" or "*.setup" (all other files will be ignored). It
runs them in numerical order, which you can set by a numerical
prefix. So, for example, in test/tests/notmuch-reply:

 1-notmuch-reply.setup
 00100-basic-reply.test  
 00200-multiple-recipients.test  
 00300-reply-with-cc.test
 00400-reply-from-alternate-address.test
 00500-support-for-reply-to.test
 00600-unmunging-reply-to.test
 9-notmuch-reply.setup

The basic numbering system is 00100, 00200, etc. to both allow a lot of
space to fit things in between, and to let the collection of tests
grow. 

1-$(basename $(pwd)).setup and 9-$(basename $(pwd)).setup are
reserved for setting up and cleaning up. This allows us to call
individual sets of tests without calling the entire suite in order to
get the environment that the tests expect.

Note that if you add a new subdir collection of tests, you have to add
it to the $TEST_COLLECTIONS variable in notmuch-test. It doesn't run all
subdirs automatically, in case you want to test something out, or have a
subdir that only works in certain cases (imagine future tests of remote
setups).

Sorry the patch is so large: there was a lot of back-and-forth, and it
was hard to break the patches down into coherent steps. Carl, if you'd
prefer, I could send you a more granular, but confusing, series of
patches.

Best,
Jesse




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


Re: all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary]

2010-04-30 Thread David Edmondson
On Sat, 24 Apr 2010 07:42:48 -0700, Carl Worth  wrote:
> Next, I wonder if we shouldn't do something similar for the search
> view. It might be quite handy if all authors and all unique subjects for
> a thread were made available for i-search in the buffer, but hidden by
> default and expanded as needed like this. What do you think?

All of the authors appear in the output already, but that doesn't seem
to be the case of the subjects. Would you envisage doing something
similar to the changes Dirk made for authors?

dme.
-- 
David Edmondson, http://dme.org


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


[PATCHv2] Restructure notmuch-hello-reflect

2010-04-30 Thread Sebastian Spaeth
This function was "not lispy" according to a comment by dme, and it
also relied on a helper function that used 'cl code. Do away with all
that and provide a hopefully lispy solution that relies on elisp only
to "reflect" a (possibly non-square) matrix along it's diagonal.

Remove now unused notmuch-hello-reflect-generate-row function.

Remove unused notmuch-hello-roundup function (which did exactly the
same as (ceiling divident divisor) anyway).

Signed-off-by: Sebastian Spaeth 
---
 Just for the record, this is the final cleaned up version. 
 Still not sure if dme sees it as an improvement though :-)

 emacs/notmuch-hello.el |   37 +++--
 1 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..8dc8ff9 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -113,29 +113,22 @@
maximize (length (car elem)))
   0))
 
-(defun notmuch-hello-roundup (dividend divisor)
-  "Return the rounded up value of dividing `dividend' by `divisor'."
-  (+ (/ dividend divisor)
- (if (> (% dividend divisor) 0) 1 0)))
-
-(defun notmuch-hello-reflect-generate-row (ncols nrows row list)
-  (let ((len (length list)))
-(loop for col from 0 to (- ncols 1)
- collect (let ((offset (+ (* nrows col) row)))
-   (if (< offset len)
-   (nth offset list)
- ;; Don't forget to insert an empty slot in the
- ;; output matrix if there is no corresponding
- ;; value in the input matrix.
- nil)
-
 (defun notmuch-hello-reflect (list ncols)
-  "Reflect a `ncols' wide matrix represented by `list' along the
-diagonal."
-  ;; Not very lispy...
-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))
-(loop for row from 0 to (- nrows 1)
- append (notmuch-hello-reflect-generate-row ncols nrows row list
+  "Reflect a `ncols' wide matrix `list' along diagonal."
+  (let* ((l (length list))
+ (brows (ceiling l ncols)) ;;#rows of new matrix
+ (bvector (make-vector l nil));;vector to be returned
+ offset)
+(dotimes (pos l)
+  (aset bvector pos
+   (elt list (setq offset 
+(cond ;;return row number if in first colum
+ ((eq 0 (% pos ncols)) 
+  (setq offset (floor pos ncols)))
+ ((>= (% l ncols) (% pos ncols)) 
+  (+ offset brows)) ;;add brows for first 
'long'cols
+ (t (1- (+ offset brows ;;+ brows-1 for 
remainder
+(append bvector nil)));; return bvector as list
 
 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
-- 
1.7.0.4

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


[PATCH] Restructure notmuch-hello-reflect

2010-04-30 Thread Sebastian Spaeth
This function was "not lispy" according to a comment by dme, and it
also relied on a helper function that used 'cl code. Do away with all
that and provide a hopefully lispy solution that relies on elisp only
to "reflect" a (possibly non-square) matrix along it's diagonal.

Remove now unused notmuch-hello-reflect-generate-row function.

Remove unused notmuch-hello-roundup function (which did exactly the
same as (ceiling divident divisor) anyway).

Signed-off-by: Sebastian Spaeth 
---
 emacs/notmuch-hello.el |   36 ++--
 1 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..1999858 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -113,29 +113,21 @@
maximize (length (car elem)))
   0))
 
-(defun notmuch-hello-roundup (dividend divisor)
-  "Return the rounded up value of dividing `dividend' by `divisor'."
-  (+ (/ dividend divisor)
- (if (> (% dividend divisor) 0) 1 0)))
-
-(defun notmuch-hello-reflect-generate-row (ncols nrows row list)
-  (let ((len (length list)))
-(loop for col from 0 to (- ncols 1)
- collect (let ((offset (+ (* nrows col) row)))
-   (if (< offset len)
-   (nth offset list)
- ;; Don't forget to insert an empty slot in the
- ;; output matrix if there is no corresponding
- ;; value in the input matrix.
- nil)
-
 (defun notmuch-hello-reflect (list ncols)
-  "Reflect a `ncols' wide matrix represented by `list' along the
-diagonal."
-  ;; Not very lispy...
-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))
-(loop for row from 0 to (- nrows 1)
- append (notmuch-hello-reflect-generate-row ncols nrows row list
+  "Transpose a `ncols' wide matrix `list' along diagonal."
+  (let ((brows (ceiling (length list) ncols)) ;;#rows of new matrix
+bvector offset)
+(setq bvector (make-vector (length list) nil));;vector to be returned
+(dotimes (pos (length list))
+  (aset bvector pos
+   (elt list (setq offset 
+(cond ;;return row number if in first colum
+ ((eq 0 (% pos ncols)) 
+  (setq offset (floor pos ncols)))
+ ((>= (% (length list) ncols) (% pos ncols)) 
+  (+ offset brows)) ;;add brows for first 
'long'cols
+ (t (1- (+ offset brows ;;+ brows-1 for 
remainder
+(append bvector nil)));; return bvector as list
 
 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
-- 
1.7.0.4

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


Re: [PATCH] emacs: Remove notmuch-hello-roundup function

2010-04-30 Thread David Edmondson
On Fri, 30 Apr 2010 12:33:57 +0200, Sebastian Spaeth  
wrote:
> as it does the same as (ceiling number divisor) which is already provided in 
> elisp.
> ---
> dme, am I right that this patch is really correct?

Yes. I have the same patch in a tree somewhere here...

dme.
-- 
David Edmondson, http://dme.org


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


[PATCH] emacs: Remove notmuch-hello-roundup function

2010-04-30 Thread Sebastian Spaeth
as it does the same as (ceiling number divisor) which is already provided in 
elisp.
---
dme, am I right that this patch is really correct?

 emacs/notmuch-hello.el |7 +--
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..8fabbf4 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -113,11 +113,6 @@
maximize (length (car elem)))
   0))
 
-(defun notmuch-hello-roundup (dividend divisor)
-  "Return the rounded up value of dividing `dividend' by `divisor'."
-  (+ (/ dividend divisor)
- (if (> (% dividend divisor) 0) 1 0)))
-
 (defun notmuch-hello-reflect-generate-row (ncols nrows row list)
   (let ((len (length list)))
 (loop for col from 0 to (- ncols 1)
@@ -133,7 +128,7 @@
   "Reflect a `ncols' wide matrix represented by `list' along the
 diagonal."
   ;; Not very lispy...
-  (let ((nrows (notmuch-hello-roundup (length list) ncols)))
+  (let ((nrows (ceiling (length list) ncols)))
 (loop for row from 0 to (- nrows 1)
  append (notmuch-hello-reflect-generate-row ncols nrows row list
 
-- 
1.7.0.4

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


Failing test cases

2010-04-30 Thread Olly Betts
On 2010-04-28, Jason White wrote:
> It seems to be repeatable here, even after running git clean -d -f -x,
> followed by make && make test
>
> Is anyone else seeing this?

Yes, I got the same failure trying to rebuild the notmuch 0.3.1 Debian package
with Xapian 1.2.0 (building in a clean Debian sid chroot on x86-64).

I'm hoping to get 1.2.x in for Debian's next stable release, so it would be
good to work out what's going on.

Cheers,
Olly