[PATCH 2/2] emacs: make modifications to message Fcc vars buffer-local

2015-08-04 Thread David Bremner
Previously we globally modified these variables, which tended to cause
problems for people using message-mode, but not notmuch-mua-mail, to
send mail.

User visible changes:

- calling notmuch-fcc-header-setup is no longer optional. OTOH, it
  seems to do the right thing if notmuch-fcc-dirs is set to nil.

- the Fcc header is visible during message composition

- the name in the mode line is changed, and (sadface) no longer
  matches the menu label.

- Previously notmuch-mua-send-and-exit was never called.  Either we
  misunderstood define-mail-user-agent, or it had a bug.  So there was
  no difference if the user called message-send-and-exit directly. Now
  there will be.

- user bindings to C-c C-s and C-c C-s in message-mode-map are
  overridden. The user can override them in notmuch-message-mode-map,
  but then they're on their own for Fcc handling.
---
 emacs/notmuch-maildir-fcc.el | 23 +--
 emacs/notmuch-mua.el | 15 +--
 test/test-lib.sh |  4 ++--
 3 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 07eedba..c2f2f4c 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -59,23 +59,19 @@ yet when sending a mail."
  :require 'notmuch-fcc-initialization
  :group 'notmuch-send)

-(defun notmuch-fcc-initialization ()
-  "If notmuch-fcc-directories is set,
-   hook them into the message-fcc-handler-function"
-;; Set up the message-fcc-handler to move mails to the maildir in Fcc
-;; The parameter is set to mark messages as "seen"
-(setq message-fcc-handler-function
-  (lambda (destdir)
-   (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))
-;; add a hook to actually insert the Fcc header when sending
-(add-hook 'message-header-setup-hook 'notmuch-fcc-header-setup))
+(defun notmuch-fcc-handler (destdir)
+  "Write buffer to `destdir', marking it as sent
+
+Intended to be dynamically bound to `message-fcc-handler-function'"
+(notmuch-maildir-fcc-write-buffer-to-maildir destdir t))

 (defun notmuch-fcc-header-setup ()
   "Add an Fcc header to the current message buffer.

-Can be added to `message-send-hook' and will set the Fcc header
-based on the values of `notmuch-fcc-dirs'. An existing Fcc header
-will NOT be removed or replaced."
+Sets the Fcc header based on the values of `notmuch-fcc-dirs'.
+
+Originally intended to be use a hook function, but now called directly
+by notmuch-mua-mail"

   (let ((subdir
 (cond
@@ -213,6 +209,5 @@ return t if successful, and nil otherwise."
  (delete-file (concat destdir "/tmp/" msg-id
   t)))

-(notmuch-fcc-initialization)
 (provide 'notmuch-maildir-fcc)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 1018321..803459a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -268,9 +268,13 @@ Note that these functions use `mail-citation-hook' if that 
is non-nil."
   (message-goto-body)
   (set-buffer-modified-p nil))

-(define-derived-mode notmuch-message-mode message-mode "Notmuch Message"
+(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"
   "Notmuch message composition mode. Mostly like `message-mode'")

+(define-key notmuch-message-mode-map (kbd "C-c C-c") 
#'notmuch-mua-send-and-exit)
+(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)
+
+
 (defun notmuch-mua-mail ( to subject other-headers  other-args)
   "Invoke the notmuch mail composition window.

@@ -288,6 +292,7 @@ OTHER-ARGS are passed through to `message-mail'."

   (apply #'message-mail to subject other-headers other-args)
   (notmuch-message-mode)
+  (notmuch-fcc-header-setup)
   (message-sort-headers)
   (message-hide-headers)
   (set-buffer-modified-p nil)
@@ -401,7 +406,13 @@ will be addressed to all recipients of the source message."

 (defun notmuch-mua-send-and-exit ( arg)
   (interactive "P")
-  (message-send-and-exit arg))
+  (let ((message-fcc-handler-function #'notmuch-fcc-handler))
+(message-send-and-exit arg)))
+
+(defun notmuch-mua-send ( arg)
+  (interactive "P")
+  (let ((message-fcc-handler-function #'notmuch-fcc-handler))
+(message-send arg)))

 (defun notmuch-mua-kill-buffer ()
   (interactive)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index db3b6aa..eeb5487 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -487,7 +487,7 @@ emacs_deliver_message ()
   (message-goto-body)
   (insert \"${body}\")
   $@
-  (message-send-and-exit))"
+  (notmuch-mua-send-and-exit))"

 # In case message was sent properly, client waits for confirmation
 # before exiting and resuming control here; therefore making sure
@@ -522,7 +522,7 @@ emacs_fcc_message ()
   (message-goto-body)
   (insert \"${body}\")
   $@
-  (message-send-and-exit))" || return 1
+  (notmuch-mua-send-and-exit))" || return 1
 notmuch new 

[PATCH 1/2] emacs: define a notmuch-compose-mode based on message mode.

2015-08-04 Thread David Bremner
This is to provide a clean way of overriding e.g. keybindings when
sending mail from notmuch.
---
 emacs/notmuch-mua.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 3e52d5e..1018321 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -268,6 +268,9 @@ Note that these functions use `mail-citation-hook' if that 
is non-nil."
   (message-goto-body)
   (set-buffer-modified-p nil))

+(define-derived-mode notmuch-message-mode message-mode "Notmuch Message"
+  "Notmuch message composition mode. Mostly like `message-mode'")
+
 (defun notmuch-mua-mail ( to subject other-headers  other-args)
   "Invoke the notmuch mail composition window.

@@ -284,6 +287,7 @@ OTHER-ARGS are passed through to `message-mail'."
   (notmuch-user-name) " <" (notmuch-user-primary-email) 
">")) other-headers))

   (apply #'message-mail to subject other-headers other-args)
+  (notmuch-message-mode)
   (message-sort-headers)
   (message-hide-headers)
   (set-buffer-modified-p nil)
-- 
2.1.4



test suite: add more debugging output for notmuch-new

2015-08-04 Thread David Bremner
Tomi Ollila  writes:

>
> I got the same test results -- and could not figure out the reason through
> a brief look at the notmuch-new.c code.
>
> +1 for the series for now, hopefully we soon find out the resolution to the
> known broken tests.

OK, I pushed it, we'll see what happens. It'd be niced to sort this out
before the next release anyway.

d


[PATCH 2/2] emacs: prefer notmuch-emacs-version in User-Agent: header

2015-08-04 Thread David Bremner
Tomi Ollila  writes:

> Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA
> use that as a part of User-Agent: header to provide more accurate
> version information when sending emails.
>

pushed.

d


[PATCH] test: use the python interpreter in sh.config

2015-08-04 Thread David Bremner
David Bremner  writes:

> The configure script chooses "python" if both python and python{2,3}
> exist exists, so this could change the version of python used to run
> the test suite.
>
> The checking for ${NOTMUCH_PYTHON} in the test suite is arguably
> over-engineering, since the configure step will fail if it can't find
> it.

pushed.

d


[PATCH] devel/release-checks.sh: made python version check work with python 3

2015-08-04 Thread David Bremner
Tomi Ollila  writes:

> This trivial change consists of just putting print() argument in
> parentheses.

Pushed. BTW, would it be a good thing or a bad one to take the python
binary name here from sh.config? Or just not worth the trouble?

d


test suite: add more debugging output for notmuch-new

2015-08-04 Thread Tomi Ollila
On Tue, Aug 04 2015, David Bremner  wrote:

> The first patch in the series is a trivial cleanup.
>
> I _thought_ (and tricked Tomi ;)) that the next one was trivial too,
> but now I'm not so sure.
>
> First, I forgot to update one test, but I mostly understand (or can at
> least rationalize) that output. Then I had the bright idea that I
> should add debugging output to other tests in T050-new. In 5 cases I
> can't really understand the results. It seems like it takes several
> runs of notmuch-new to remove directory entries. Maybe this is
> intended, but I couldn't figure that out in a quick look.

I got the same test results -- and could not figure out the reason through
a brief look at the notmuch-new.c code.

+1 for the series for now, hopefully we soon find out the resolution to the
known broken tests.

Tomi


[PATCH v5 2/3] emacs: add a filter option to show

2015-08-04 Thread David Bremner
Mark Walters  writes:

> Show the current thread with a different filter (i.e., open messages
> in the thread matching the new query).
>
> Bound to 'l' for "limit".
>
> Note that it is not the same as filter in search mode as it replaces
> the existing query rather than ANDing with it (but it does keep the
> thread-id part of the query).

I pushed the first two. I'm not sure there was ever any discussion about
the keybindings change, so I left the third.


update cli/lib to use new notmuch_query_search_* api

2015-08-04 Thread David Bremner
David Bremner  writes:

> I was already to push the first few patches of
>
>   id:1425756182-28468-1-git-send-email-david at tethera.net
>
> When I realized there was probably a reason that no-one had reviewed
> patch 3/5. After breaking up that ball of mud, one thing led to
> another, and deprecating the old API and updating to the new API is up
> to 10 patches.

It's kind of a dirty trick to get feedback on the rest of the series,
but I pushed the part that generates a bunch of compilation warnings ;).

d


[PATCH 1/6] lib: Only sync modified message documents

2015-08-04 Thread David Bremner
David Bremner  writes:

> From: Austin Clements 
>
> Previously, we updated the database copy of a message on every call to
> _notmuch_message_sync, even if nothing had changed.  In particular,
> this always happens on a thaw, so a freeze/thaw pair with no
> modifications between still caused a database update.
>
> We only modify message documents in a handful of places, so keep track
> of whether the document has been modified and only sync it when
> necessary.  This will be particularly important when we add message
> revision tracking.

This patch makes some sense without the rest of lastmod series, so I
merged it early to get some testing.

d


[PATCH 3/3] test: add debugging output to notmuch-new tests, mark 5 as broken

2015-08-04 Thread David Bremner
I marked the tests where I really couldn't understand the output as
broken. It could also be that I don't understand how directory removal
is supposed to work.
---
 test/T050-new.sh | 62 
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index ab15ca1..ff1c354 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -3,25 +3,25 @@ test_description='"notmuch new" in several variations'
 . ./test-lib.sh

 test_begin_subtest "No new messages"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "No new mail."


 test_begin_subtest "Single new message"
 generate_message
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."


 test_begin_subtest "Multiple new messages"
 generate_message
 generate_message
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 2 new messages to the database."


 test_begin_subtest "No new messages (non-empty DB)"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "No new mail."


@@ -31,7 +31,7 @@ mkdir "${MAIL_DIR}"/def
 mkdir "${MAIL_DIR}"/ghi
 generate_message [dir]=def

-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."


@@ -42,7 +42,7 @@ mv "${MAIL_DIR}"/ghi "${MAIL_DIR}"/abc
 rm "${MAIL_DIR}"/def/*
 generate_message [dir]=abc

-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."


@@ -54,7 +54,7 @@ mkdir -p "$(dirname "$tmp_msg_filename")"
 mv "$gen_msg_filename" "$tmp_msg_filename"
 notmuch new > /dev/null
 mv "$tmp_msg_filename" "$gen_msg_filename"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."


@@ -87,34 +87,39 @@ notmuch new > /dev/null

 mv "${MAIL_DIR}"/dir "${MAIL_DIR}"/dir-renamed

-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "No new mail. Detected 3 file renames."
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files_recursive, pass 2: queuing passed 
directory ${MAIL_DIR}/dir for deletion from database
+No new mail. Detected 3 file renames."


 test_begin_subtest "Deleted directory"
-
+test_subtest_known_broken
 rm -rf "${MAIL_DIR}"/dir-renamed

-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "No new mail. Removed 3 messages."
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files_recursive, pass 2: queuing passed 
directory ${MAIL_DIR}/dir-renamed for deletion from database
+No new mail. Removed 3 messages."


 test_begin_subtest "New directory (at end of list)"
+test_subtest_known_broken

 generate_message [dir]=zzz
 generate_message [dir]=zzz
 generate_message [dir]=zzz

-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 3 new messages to the database."


 test_begin_subtest "Deleted directory (end of list)"

+test_subtest_known_broken
 rm -rf "${MAIL_DIR}"/zzz

-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "No new mail. Removed 3 messages."
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files_recursive, pass 3: queuing leftover 
directory ${MAIL_DIR}/zzz for deletion from database
+No new mail. Removed 3 messages."


 test_begin_subtest "New symlink to directory"
@@ -125,7 +130,7 @@ mv "${MAIL_DIR}" "${TMP_DIRECTORY}"/actual_maildir
 mkdir "${MAIL_DIR}"
 ln -s "${TMP_DIRECTORY}"/actual_maildir "${MAIL_DIR}"/symlink

-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."


@@ -135,13 +140,13 @@ 
external_msg_filename="${TMP_DIRECTORY}"/external/"$(basename "$gen_msg_filename
 mkdir -p "$(dirname "$external_msg_filename")"
 mv "$gen_msg_filename" "$external_msg_filename"
 ln -s "$external_msg_filename" "$gen_msg_filename"
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."


 test_begin_subtest "Broken symlink aborts"
 ln -s does-not-exist "${MAIL_DIR}/broken"
-output=$(NOTMUCH_NEW 2>&1)
+output=$(NOTMUCH_NEW --debug 2>&1)
 test_expect_equal "$output" \
 "Error reading file ${MAIL_DIR}/broken: No such file or directory
 Note: A fatal error was encountered: Something went wrong trying to read or 
write a file
@@ -155,7 +160,7 @@ generate_message [dir]=two/levels
 generate_message [dir]=two/levels
 generate_message [dir]=two/levels

-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 3 new messages to the database."


@@ -163,10 +168,12 @@ test_begin_subtest "Deleted two-level directory"

 rm -rf "${MAIL_DIR}"/two

-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "No new mail. Removed 3 messages."
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files_recursive, pass 3: 

[PATCH 2/3] cli/new: add more debugging output

2015-08-04 Thread David Bremner
Try to narrow down what part of the code adds files and directories to
the queue(s) to be deleted.

Update one test. The output is slightly confusing, but I believe it is
correct, resulting from a directory being discovered but containing only 
ignored files.
---
 notmuch-new.c| 14 ++
 test/T050-new.sh |  1 +
 2 files changed, 15 insertions(+)

diff --git a/notmuch-new.c b/notmuch-new.c
index 8ff1ade..ee786a3 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -528,6 +528,10 @@ add_files (notmuch_database_t *notmuch,
  "%s/%s", path,
  notmuch_filenames_get (db_files));

+   if (state->debug)
+   printf ("(D) add_files_recursive, pass 2: queuing passed file 
%s for deletion from database\n",
+   absolute);
+
_filename_list_add (state->removed_files, absolute);

notmuch_filenames_move_to_next (db_files);
@@ -542,6 +546,9 @@ add_files (notmuch_database_t *notmuch,
{
char *absolute = talloc_asprintf (state->removed_directories,
  "%s/%s", path, filename);
+   if (state->debug)
+   printf ("(D) add_files_recursive, pass 2: queuing passed 
directory %s for deletion from database\n",
+   absolute);

_filename_list_add (state->removed_directories, absolute);
}
@@ -610,6 +617,9 @@ add_files (notmuch_database_t *notmuch,
char *absolute = talloc_asprintf (state->removed_files,
  "%s/%s", path,
  notmuch_filenames_get (db_files));
+   if (state->debug)
+   printf ("(D) add_files_recursive, pass 3: queuing leftover file %s 
for deletion from database\n",
+   absolute);

_filename_list_add (state->removed_files, absolute);

@@ -622,6 +632,10 @@ add_files (notmuch_database_t *notmuch,
  "%s/%s", path,
  notmuch_filenames_get (db_subdirs));

+   if (state->debug)
+   printf ("(D) add_files_recursive, pass 3: queuing leftover 
directory %s for deletion from database\n",
+   absolute);
+
_filename_list_add (state->removed_directories, absolute);

notmuch_filenames_move_to_next (db_subdirs);
diff --git a/test/T050-new.sh b/test/T050-new.sh
index 66ea10f..ab15ca1 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -238,6 +238,7 @@ test_expect_equal "$output" \
 (D) add_files_recursive, pass 2: explicitly ignoring 
${MAIL_DIR}/one/two/ignored_file
 (D) add_files_recursive, pass 2: explicitly ignoring 
${MAIL_DIR}/one/two/three/.git
 (D) add_files_recursive, pass 2: explicitly ignoring 
${MAIL_DIR}/one/two/three/ignored_file
+(D) add_files_recursive, pass 3: queuing leftover directory ${MAIL_DIR}/two 
for deletion from database
 No new mail."


-- 
2.1.4



[PATCH 1/3] test: don't claim single message mbox support is going away

2015-08-04 Thread David Bremner
We gave up on this.
---
 test/T050-new.sh | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index e6c3291..66ea10f 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -63,15 +63,18 @@ test_begin_subtest "Renamed message"
 generate_message
 notmuch new > /dev/null
 mv "$gen_msg_filename" "${gen_msg_filename}"-renamed
-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "No new mail. Detected 1 file rename."
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files_recursive, pass 2: queuing passed 
file ${gen_msg_filename} for deletion from database
+No new mail. Detected 1 file rename."


 test_begin_subtest "Deleted message"

 rm "${gen_msg_filename}"-renamed
-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "No new mail. Removed 1 message."
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal "$output" "(D) add_files_recursive, pass 3: queuing leftover 
file ${gen_msg_filename}-renamed for deletion from database
+No new mail. Removed 1 message."
+


 test_begin_subtest "Renamed directory"
@@ -163,7 +166,7 @@ rm -rf "${MAIL_DIR}"/two
 output=$(NOTMUCH_NEW)
 test_expect_equal "$output" "No new mail. Removed 3 messages."

-test_begin_subtest "Support single-message mbox (deprecated)"
+test_begin_subtest "Support single-message mbox"
 cat > "${MAIL_DIR}"/mbox_file1 <
-- 
2.1.4



test suite: add more debugging output for notmuch-new

2015-08-04 Thread David Bremner
The first patch in the series is a trivial cleanup.

I _thought_ (and tricked Tomi ;)) that the next one was trivial too,
but now I'm not so sure.

First, I forgot to update one test, but I mostly understand (or can at
least rationalize) that output. Then I had the bright idea that I
should add debugging output to other tests in T050-new. In 5 cases I
can't really understand the results. It seems like it takes several
runs of notmuch-new to remove directory entries. Maybe this is
intended, but I couldn't figure that out in a quick look.



[PATCH 1/3] test: don't claim single message mbox support is going away

2015-08-04 Thread David Bremner
We gave up on this.
---
 test/T050-new.sh | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index e6c3291..66ea10f 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -63,15 +63,18 @@ test_begin_subtest Renamed message
 generate_message
 notmuch new  /dev/null
 mv $gen_msg_filename ${gen_msg_filename}-renamed
-output=$(NOTMUCH_NEW)
-test_expect_equal $output No new mail. Detected 1 file rename.
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal $output (D) add_files_recursive, pass 2: queuing passed 
file ${gen_msg_filename} for deletion from database
+No new mail. Detected 1 file rename.
 
 
 test_begin_subtest Deleted message
 
 rm ${gen_msg_filename}-renamed
-output=$(NOTMUCH_NEW)
-test_expect_equal $output No new mail. Removed 1 message.
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal $output (D) add_files_recursive, pass 3: queuing leftover 
file ${gen_msg_filename}-renamed for deletion from database
+No new mail. Removed 1 message.
+
 
 
 test_begin_subtest Renamed directory
@@ -163,7 +166,7 @@ rm -rf ${MAIL_DIR}/two
 output=$(NOTMUCH_NEW)
 test_expect_equal $output No new mail. Removed 3 messages.
 
-test_begin_subtest Support single-message mbox (deprecated)
+test_begin_subtest Support single-message mbox
 cat  ${MAIL_DIR}/mbox_file1 EOF
 From test_su...@notmuchmail.org Fri Jan  5 15:43:57 2001
 From: Notmuch Test Suite test_su...@notmuchmail.org
-- 
2.1.4

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


[PATCH 3/3] test: add debugging output to notmuch-new tests, mark 5 as broken

2015-08-04 Thread David Bremner
I marked the tests where I really couldn't understand the output as
broken. It could also be that I don't understand how directory removal
is supposed to work.
---
 test/T050-new.sh | 62 
 1 file changed, 35 insertions(+), 27 deletions(-)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index ab15ca1..ff1c354 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -3,25 +3,25 @@ test_description='notmuch new in several variations'
 . ./test-lib.sh
 
 test_begin_subtest No new messages
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output No new mail.
 
 
 test_begin_subtest Single new message
 generate_message
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 1 new message to the database.
 
 
 test_begin_subtest Multiple new messages
 generate_message
 generate_message
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 2 new messages to the database.
 
 
 test_begin_subtest No new messages (non-empty DB)
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output No new mail.
 
 
@@ -31,7 +31,7 @@ mkdir ${MAIL_DIR}/def
 mkdir ${MAIL_DIR}/ghi
 generate_message [dir]=def
 
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 1 new message to the database.
 
 
@@ -42,7 +42,7 @@ mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
 rm ${MAIL_DIR}/def/*
 generate_message [dir]=abc
 
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 1 new message to the database.
 
 
@@ -54,7 +54,7 @@ mkdir -p $(dirname $tmp_msg_filename)
 mv $gen_msg_filename $tmp_msg_filename
 notmuch new  /dev/null
 mv $tmp_msg_filename $gen_msg_filename
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 1 new message to the database.
 
 
@@ -87,34 +87,39 @@ notmuch new  /dev/null
 
 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
 
-output=$(NOTMUCH_NEW)
-test_expect_equal $output No new mail. Detected 3 file renames.
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal $output (D) add_files_recursive, pass 2: queuing passed 
directory ${MAIL_DIR}/dir for deletion from database
+No new mail. Detected 3 file renames.
 
 
 test_begin_subtest Deleted directory
-
+test_subtest_known_broken
 rm -rf ${MAIL_DIR}/dir-renamed
 
-output=$(NOTMUCH_NEW)
-test_expect_equal $output No new mail. Removed 3 messages.
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal $output (D) add_files_recursive, pass 2: queuing passed 
directory ${MAIL_DIR}/dir-renamed for deletion from database
+No new mail. Removed 3 messages.
 
 
 test_begin_subtest New directory (at end of list)
+test_subtest_known_broken
 
 generate_message [dir]=zzz
 generate_message [dir]=zzz
 generate_message [dir]=zzz
 
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 3 new messages to the database.
 
 
 test_begin_subtest Deleted directory (end of list)
 
+test_subtest_known_broken
 rm -rf ${MAIL_DIR}/zzz
 
-output=$(NOTMUCH_NEW)
-test_expect_equal $output No new mail. Removed 3 messages.
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal $output (D) add_files_recursive, pass 3: queuing leftover 
directory ${MAIL_DIR}/zzz for deletion from database
+No new mail. Removed 3 messages.
 
 
 test_begin_subtest New symlink to directory
@@ -125,7 +130,7 @@ mv ${MAIL_DIR} ${TMP_DIRECTORY}/actual_maildir
 mkdir ${MAIL_DIR}
 ln -s ${TMP_DIRECTORY}/actual_maildir ${MAIL_DIR}/symlink
 
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 1 new message to the database.
 
 
@@ -135,13 +140,13 @@ 
external_msg_filename=${TMP_DIRECTORY}/external/$(basename $gen_msg_filename
 mkdir -p $(dirname $external_msg_filename)
 mv $gen_msg_filename $external_msg_filename
 ln -s $external_msg_filename $gen_msg_filename
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 1 new message to the database.
 
 
 test_begin_subtest Broken symlink aborts
 ln -s does-not-exist ${MAIL_DIR}/broken
-output=$(NOTMUCH_NEW 21)
+output=$(NOTMUCH_NEW --debug 21)
 test_expect_equal $output \
 Error reading file ${MAIL_DIR}/broken: No such file or directory
 Note: A fatal error was encountered: Something went wrong trying to read or 
write a file
@@ -155,7 +160,7 @@ generate_message [dir]=two/levels
 generate_message [dir]=two/levels
 generate_message [dir]=two/levels
 
-output=$(NOTMUCH_NEW)
+output=$(NOTMUCH_NEW --debug)
 test_expect_equal $output Added 3 new messages to the database.
 
 
@@ -163,10 +168,12 @@ test_begin_subtest Deleted two-level directory
 
 rm -rf ${MAIL_DIR}/two
 
-output=$(NOTMUCH_NEW)
-test_expect_equal $output No new mail. Removed 3 messages.
+output=$(NOTMUCH_NEW --debug)
+test_expect_equal $output (D) add_files_recursive, pass 3: queuing leftover 
directory ${MAIL_DIR}/two for deletion from database
+No new mail. Removed 3 messages.
 
 test_begin_subtest 

test suite: add more debugging output for notmuch-new

2015-08-04 Thread David Bremner
The first patch in the series is a trivial cleanup.

I _thought_ (and tricked Tomi ;)) that the next one was trivial too,
but now I'm not so sure.

First, I forgot to update one test, but I mostly understand (or can at
least rationalize) that output. Then I had the bright idea that I
should add debugging output to other tests in T050-new. In 5 cases I
can't really understand the results. It seems like it takes several
runs of notmuch-new to remove directory entries. Maybe this is
intended, but I couldn't figure that out in a quick look.

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


Re: update cli/lib to use new notmuch_query_search_* api

2015-08-04 Thread David Bremner
David Bremner da...@tethera.net writes:

 I was already to push the first few patches of

   id:1425756182-28468-1-git-send-email-da...@tethera.net

 When I realized there was probably a reason that no-one had reviewed
 patch 3/5. After breaking up that ball of mud, one thing led to
 another, and deprecating the old API and updating to the new API is up
 to 10 patches.

It's kind of a dirty trick to get feedback on the rest of the series,
but I pushed the part that generates a bunch of compilation warnings ;).

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


[PATCH 2/3] cli/new: add more debugging output

2015-08-04 Thread David Bremner
Try to narrow down what part of the code adds files and directories to
the queue(s) to be deleted.

Update one test. The output is slightly confusing, but I believe it is
correct, resulting from a directory being discovered but containing only 
ignored files.
---
 notmuch-new.c| 14 ++
 test/T050-new.sh |  1 +
 2 files changed, 15 insertions(+)

diff --git a/notmuch-new.c b/notmuch-new.c
index 8ff1ade..ee786a3 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -528,6 +528,10 @@ add_files (notmuch_database_t *notmuch,
  %s/%s, path,
  notmuch_filenames_get (db_files));
 
+   if (state-debug)
+   printf ((D) add_files_recursive, pass 2: queuing passed file 
%s for deletion from database\n,
+   absolute);
+
_filename_list_add (state-removed_files, absolute);
 
notmuch_filenames_move_to_next (db_files);
@@ -542,6 +546,9 @@ add_files (notmuch_database_t *notmuch,
{
char *absolute = talloc_asprintf (state-removed_directories,
  %s/%s, path, filename);
+   if (state-debug)
+   printf ((D) add_files_recursive, pass 2: queuing passed 
directory %s for deletion from database\n,
+   absolute);
 
_filename_list_add (state-removed_directories, absolute);
}
@@ -610,6 +617,9 @@ add_files (notmuch_database_t *notmuch,
char *absolute = talloc_asprintf (state-removed_files,
  %s/%s, path,
  notmuch_filenames_get (db_files));
+   if (state-debug)
+   printf ((D) add_files_recursive, pass 3: queuing leftover file %s 
for deletion from database\n,
+   absolute);
 
_filename_list_add (state-removed_files, absolute);
 
@@ -622,6 +632,10 @@ add_files (notmuch_database_t *notmuch,
  %s/%s, path,
  notmuch_filenames_get (db_subdirs));
 
+   if (state-debug)
+   printf ((D) add_files_recursive, pass 3: queuing leftover 
directory %s for deletion from database\n,
+   absolute);
+
_filename_list_add (state-removed_directories, absolute);
 
notmuch_filenames_move_to_next (db_subdirs);
diff --git a/test/T050-new.sh b/test/T050-new.sh
index 66ea10f..ab15ca1 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -238,6 +238,7 @@ test_expect_equal $output \
 (D) add_files_recursive, pass 2: explicitly ignoring 
${MAIL_DIR}/one/two/ignored_file
 (D) add_files_recursive, pass 2: explicitly ignoring 
${MAIL_DIR}/one/two/three/.git
 (D) add_files_recursive, pass 2: explicitly ignoring 
${MAIL_DIR}/one/two/three/ignored_file
+(D) add_files_recursive, pass 3: queuing leftover directory ${MAIL_DIR}/two 
for deletion from database
 No new mail.
 
 
-- 
2.1.4

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


Re: [PATCH v5 2/3] emacs: add a filter option to show

2015-08-04 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:

 Show the current thread with a different filter (i.e., open messages
 in the thread matching the new query).

 Bound to 'l' for limit.

 Note that it is not the same as filter in search mode as it replaces
 the existing query rather than ANDing with it (but it does keep the
 thread-id part of the query).

I pushed the first two. I'm not sure there was ever any discussion about
the keybindings change, so I left the third.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/6] lib: Only sync modified message documents

2015-08-04 Thread David Bremner
David Bremner da...@tethera.net writes:

 From: Austin Clements amdra...@mit.edu

 Previously, we updated the database copy of a message on every call to
 _notmuch_message_sync, even if nothing had changed.  In particular,
 this always happens on a thaw, so a freeze/thaw pair with no
 modifications between still caused a database update.

 We only modify message documents in a handful of places, so keep track
 of whether the document has been modified and only sync it when
 necessary.  This will be particularly important when we add message
 revision tracking.

This patch makes some sense without the rest of lastmod series, so I
merged it early to get some testing.

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


Re: [PATCH] devel/release-checks.sh: made python version check work with python 3

2015-08-04 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:

 This trivial change consists of just putting print() argument in
 parentheses.

Pushed. BTW, would it be a good thing or a bad one to take the python
binary name here from sh.config? Or just not worth the trouble?

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


Re: [PATCH] test: use the python interpreter in sh.config

2015-08-04 Thread David Bremner
David Bremner da...@tethera.net writes:

 The configure script chooses python if both python and python{2,3}
 exist exists, so this could change the version of python used to run
 the test suite.

 The checking for ${NOTMUCH_PYTHON} in the test suite is arguably
 over-engineering, since the configure step will fail if it can't find
 it.

pushed.

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


Re: test suite: add more debugging output for notmuch-new

2015-08-04 Thread Tomi Ollila
On Tue, Aug 04 2015, David Bremner da...@tethera.net wrote:

 The first patch in the series is a trivial cleanup.

 I _thought_ (and tricked Tomi ;)) that the next one was trivial too,
 but now I'm not so sure.

 First, I forgot to update one test, but I mostly understand (or can at
 least rationalize) that output. Then I had the bright idea that I
 should add debugging output to other tests in T050-new. In 5 cases I
 can't really understand the results. It seems like it takes several
 runs of notmuch-new to remove directory entries. Maybe this is
 intended, but I couldn't figure that out in a quick look.

I got the same test results -- and could not figure out the reason through
a brief look at the notmuch-new.c code.

+1 for the series for now, hopefully we soon find out the resolution to the
known broken tests.

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


Re: [PATCH] devel/release-checks.sh: made python version check work with python 3

2015-08-04 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:


 I'd say that unless there ever is problem with binary name `python` to make
 those checks to succeed then we could think whether to depend on sh.config
 existing... or do the same way resolving python as configure does.


OK, for now, since there is a very small group of users for
release-checks.sh, let's wait for the hardcoded binary name to cause
problems for someone.

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


Re: [PATCH] devel/release-checks: added checking of copyright year in documentation

2015-08-04 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:

 +copyrightline=`exec python -c __file__ = 'command-line'
 +with open('doc/conf.py') as cf: exec(cf.read()); print(copyright)`

That took me several tries to understand what is going on. Perhaps
that's because patch-review time co-incides with first coffee of the
day, but could you explain it in a comment or something, just in case
it's not only me who finds it confusing.

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


Re: [PATCH] devel/release-checks.sh: made python version check work with python 3

2015-08-04 Thread Tomi Ollila
On Tue, Aug 04 2015, David Bremner da...@tethera.net wrote:

 Tomi Ollila tomi.oll...@iki.fi writes:

 This trivial change consists of just putting print() argument in
 parentheses.

 Pushed.

Thanks.

 BTW, would it be a good thing or a bad one to take the python
 binary name here from sh.config? Or just not worth the trouble?

I'd say that unless there ever is problem with binary name `python` to make
those checks to succeed then we could think whether to depend on sh.config
existing... or do the same way resolving python as configure does.

 d

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


[PATCH 1/2] emacs: define a notmuch-compose-mode based on message mode.

2015-08-04 Thread David Bremner
This is to provide a clean way of overriding e.g. keybindings when
sending mail from notmuch.
---
 emacs/notmuch-mua.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 3e52d5e..1018321 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -268,6 +268,9 @@ Note that these functions use `mail-citation-hook' if that 
is non-nil.
   (message-goto-body)
   (set-buffer-modified-p nil))
 
+(define-derived-mode notmuch-message-mode message-mode Notmuch Message
+  Notmuch message composition mode. Mostly like `message-mode')
+
 (defun notmuch-mua-mail (optional to subject other-headers rest other-args)
   Invoke the notmuch mail composition window.
 
@@ -284,6 +287,7 @@ OTHER-ARGS are passed through to `message-mail'.
   (notmuch-user-name)   (notmuch-user-primary-email) 
)) other-headers))
 
   (apply #'message-mail to subject other-headers other-args)
+  (notmuch-message-mode)
   (message-sort-headers)
   (message-hide-headers)
   (set-buffer-modified-p nil)
-- 
2.1.4

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


Re: [PATCH 2/2] emacs: prefer notmuch-emacs-version in User-Agent: header

2015-08-04 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:

 Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA
 use that as a part of User-Agent: header to provide more accurate
 version information when sending emails.


pushed.

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


Re: test suite: add more debugging output for notmuch-new

2015-08-04 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:


 I got the same test results -- and could not figure out the reason through
 a brief look at the notmuch-new.c code.

 +1 for the series for now, hopefully we soon find out the resolution to the
 known broken tests.

OK, I pushed it, we'll see what happens. It'd be niced to sort this out
before the next release anyway.

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