]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
Merge branch 'release'
authorDavid Bremner <bremner@debian.org>
Tue, 19 Feb 2013 00:33:48 +0000 (20:33 -0400)
committerDavid Bremner <bremner@debian.org>
Tue, 19 Feb 2013 00:33:48 +0000 (20:33 -0400)
add in NEWS from 0.15.2

Conflicts:
NEWS

38 files changed:
NEWS
bindings/python/notmuch/database.py
bindings/ruby/defs.h
bindings/ruby/init.c
bindings/ruby/thread.c
contrib/notmuch-mutt/notmuch-mutt
contrib/notmuch-mutt/notmuch-mutt.rc
contrib/notmuch-vim/Makefile [moved from vim/Makefile with 100% similarity]
contrib/notmuch-vim/README [moved from vim/README with 100% similarity]
contrib/notmuch-vim/notmuch.yaml [moved from vim/notmuch.yaml with 100% similarity]
contrib/notmuch-vim/plugin/notmuch.vim [moved from vim/plugin/notmuch.vim with 100% similarity]
contrib/notmuch-vim/syntax/notmuch-compose.vim [moved from vim/syntax/notmuch-compose.vim with 100% similarity]
contrib/notmuch-vim/syntax/notmuch-folders.vim [moved from vim/syntax/notmuch-folders.vim with 100% similarity]
contrib/notmuch-vim/syntax/notmuch-git-diff.vim [moved from vim/syntax/notmuch-git-diff.vim with 100% similarity]
contrib/notmuch-vim/syntax/notmuch-search.vim [moved from vim/syntax/notmuch-search.vim with 100% similarity]
contrib/notmuch-vim/syntax/notmuch-show.vim [moved from vim/syntax/notmuch-show.vim with 100% similarity]
debian/NEWS.Debian
debian/control
devel/TODO
devel/nmbug/nmbug [moved from contrib/nmbug/nmbug with 99% similarity]
devel/nmbug/nmbug-status [moved from contrib/nmbug/nmbug-status with 100% similarity]
devel/nmbug/status-config.json [moved from contrib/nmbug/status-config.json with 100% similarity]
devel/release-checks.sh
emacs/notmuch-crypto.el
emacs/notmuch-hello.el
emacs/notmuch-lib.el
emacs/notmuch-show.el
emacs/notmuch-wash.el
lib/message.cc
lib/messages.c
lib/notmuch-private.h
lib/notmuch.h
lib/query.cc
lib/thread.cc
man/man1/notmuch.1
notmuch-tag.c
notmuch.c
test/test-lib.sh

diff --git a/NEWS b/NEWS
index 1cea2ecb60878db63b9f65c4ae2a463bf6c4560c..bd2039b51c5c4508df454caa38e0e9a6d867004e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,20 @@
+Notmuch 0.16 (2013-MM-DD)
+=========================
+
+Command-Line Interface
+----------------------
+
+Deprecated commands "part" and "search-tags" are removed.
+
+Vim Front-End
+-------------
+
+The vim based front end to notmuch is deprecated and moved to contrib.
+We haven't been able to support this as well as we would like, and it
+has accumulated bugs and gaps in functionality.  We recommend that
+people packaging notmuch no longer provide binary packages for
+notmuch-vim, but of course that is their decision.
+
 Notmuch 0.15.2 (2013-02-17)
 ===========================
 
@@ -205,8 +222,8 @@ Internal test framework changes
 
 The emacsclient binary is now user-configurable
 
-  The test framework now accepts TEST_EMACSCLIENT in addition to
-  TEST_EMACS for configuring the emacsclient to use.  This is
+  The test framework now accepts `TEST_EMACSCLIENT` in addition to
+  `TEST_EMACS` for configuring the emacsclient to use.  This is
   necessary to avoid using an old emacsclient with a new emacs, which
   can result in buggy behavior.
 
index fe692eb7ae4e38dceeb9aae24ca9b6cccb595a09..7ddf5cfe7d8d265980963ca09a1388b36717c851 100644 (file)
@@ -188,7 +188,7 @@ class Database(object):
                                        "already has an open one.")
 
         db = NotmuchDatabaseP()
-        status = Database._create(_str(path), Database.MODE.READ_WRITE, byref(db))
+        status = Database._create(_str(path), byref(db))
 
         if status != STATUS.SUCCESS:
             raise NotmuchError(status)
index fe81b3f96de5c86b1f4e28fdab3ed1f47d44236a..5b44585a6ad0cc329d311975a7aa4470a6a890ee 100644 (file)
@@ -261,6 +261,9 @@ notmuch_rb_thread_get_total_messages (VALUE self);
 VALUE
 notmuch_rb_thread_get_toplevel_messages (VALUE self);
 
+VALUE
+notmuch_rb_thread_get_messages (VALUE self);
+
 VALUE
 notmuch_rb_thread_get_matched_messages (VALUE self);
 
index f4931d34a4f39cf321e225e6f21690328654dad9..663271d4e598ed46d60cec5467d4e82f127d8729 100644 (file)
@@ -306,6 +306,7 @@ Init_notmuch (void)
     rb_define_method (notmuch_rb_cThread, "thread_id", notmuch_rb_thread_get_thread_id, 0); /* in thread.c */
     rb_define_method (notmuch_rb_cThread, "total_messages", notmuch_rb_thread_get_total_messages, 0); /* in thread.c */
     rb_define_method (notmuch_rb_cThread, "toplevel_messages", notmuch_rb_thread_get_toplevel_messages, 0); /* in thread.c */
+    rb_define_method (notmuch_rb_cThread, "messages", notmuch_rb_thread_get_messages, 0); /* in thread.c */
     rb_define_method (notmuch_rb_cThread, "matched_messages", notmuch_rb_thread_get_matched_messages, 0); /* in thread.c */
     rb_define_method (notmuch_rb_cThread, "authors", notmuch_rb_thread_get_authors, 0); /* in thread.c */
     rb_define_method (notmuch_rb_cThread, "subject", notmuch_rb_thread_get_subject, 0); /* in thread.c */
index efe5aaf7c56a8946325bd71161d14325e834aaa5..56616d9fcf1446c954cdc6608b6d1d8a9ab2e9a2 100644 (file)
@@ -91,6 +91,26 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self)
     return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
 }
 
+/*
+ * call-seq: THREAD.messages => MESSAGES
+ *
+ * Get a Notmuch::Messages iterator for the all messages in thread.
+ */
+VALUE
+notmuch_rb_thread_get_messages (VALUE self)
+{
+    notmuch_messages_t *messages;
+    notmuch_thread_t *thread;
+
+    Data_Get_Notmuch_Thread (self, thread);
+
+    messages = notmuch_thread_get_messages (thread);
+    if (!messages)
+       rb_raise (notmuch_rb_eMemoryError, "Out of memory");
+
+    return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
+}
+
 /*
  * call-seq: THREAD.matched_messages => fixnum
  *
index d14709df6eb3bccdd054a18f0ffa1cc984167d00..00c5ef82d50d67d0fcac7c43794dcf6958ac3cb1 100755 (executable)
@@ -121,7 +121,8 @@ sub prompt($$) {
 
 sub get_message_id() {
     my $mail = Mail::Internet->new(\*STDIN);
-    $mail->head->get("message-id") =~ /^<(.*)>$/;      # get message-id
+    my $mid = $mail->head->get("message-id") or return undef;
+    $mid =~ /^<(.*)>$/;        # get message-id value
     return $1;
 }
 
@@ -142,6 +143,10 @@ sub thread_action($$@) {
     my ($results_dir, $remove_dups, @params) = @_;
 
     my $mid = get_message_id();
+    if (! defined $mid) {
+       empty_maildir($results_dir);
+       die "notmuch-mutt: cannot find Message-Id, abort.\n";
+    }
     my $search_cmd = 'notmuch search --output=threads ' . shell_quote("id:$mid");
     my $tid = `$search_cmd`;   # get thread id
     chomp($tid);
@@ -151,6 +156,7 @@ sub thread_action($$@) {
 
 sub tag_action(@) {
     my $mid = get_message_id();
+    defined $mid or die "notmuch-mutt: cannot find Message-Id, abort.\n";
 
     system("notmuch tag "
           . shell_quote(join(' ', @_))
@@ -264,13 +270,23 @@ the following in your Mutt configuration (usually one of: F<~/.muttrc>,
 F</etc/Muttrc>, or a configuration snippet under F</etc/Muttrc.d/>):
 
     macro index <F8> \
-          "<enter-command>unset wait_key<enter><shell-escape>notmuch-mutt -r --prompt search<enter><change-folder-readonly>~/.cache/notmuch/mutt/results<enter>" \
+    "<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+    <shell-escape>notmuch-mutt -r --prompt search<enter>\
+    <change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
+    <enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
           "notmuch: search mail"
+
     macro index <F9> \
-          "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt -r thread<enter><change-folder-readonly>~/.cache/notmuch/mutt/results<enter><enter-command>set wait_key<enter>" \
+    "<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+    <pipe-message>notmuch-mutt -r thread<enter>\
+    <change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
+    <enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
           "notmuch: reconstruct thread"
+
     macro index <F6> \
-          "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt tag -- -inbox<enter>" \
+    "<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+    <pipe-message>notmuch-mutt tag -- -inbox<enter>\
+    <enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
           "notmuch: remove message from inbox"
 
 The first macro (activated by <F8>) prompts the user for notmuch search terms
index ddc4b480e23c7804d573d74bc97dd93c0392e339..6b299dc92b0fce1cc9e516f1ebf77b32466c8f9a 100644 (file)
@@ -1,9 +1,19 @@
 macro index <F8> \
-      "<enter-command>unset wait_key<enter><shell-escape>notmuch-mutt -r --prompt search<enter><change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>" \
+"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+<shell-escape>notmuch-mutt -r --prompt search<enter>\
+<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
+<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
       "notmuch: search mail"
+
 macro index <F9> \
-      "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt -r thread<enter><change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter><enter-command>set wait_key<enter>" \
+"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+<pipe-message>notmuch-mutt -r thread<enter>\
+<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
+<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
       "notmuch: reconstruct thread"
+
 macro index <F6> \
-      "<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt tag -- -inbox<enter>" \
+"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+<pipe-message>notmuch-mutt tag -- -inbox<enter>\
+<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
       "notmuch: remove message from inbox"
similarity index 100%
rename from vim/Makefile
rename to contrib/notmuch-vim/Makefile
similarity index 100%
rename from vim/README
rename to contrib/notmuch-vim/README
index 907d790700b17acc172cfd1a517f20e5e24d262c..1dd9e0d047a03c1be26e9d4adef313554b1f9b83 100644 (file)
@@ -1,3 +1,10 @@
+notmuch (0.16-1) unstable; urgency=low
+
+  * The vim interface is no longer provided as a Debian package, due
+    to upstream deprecation.
+
+ -- David Bremner <bremner@debian.org>  Sat, 16 Feb 2013 08:12:02 -0400
+
 notmuch (0.14-1) unstable; urgency=low
 
   There is an incompatible change in option syntax for dump and restore
index 5bb0d051e2f1b44e7ea3b1016e44ac11326ae552..fb99591966319a4c9ba90556835648bbe22df53d 100644 (file)
@@ -106,21 +106,6 @@ Description: thread-based email index, search and tagging (emacs interface)
  This package provides an emacs based mail user agent based on
  notmuch.
 
-Package: notmuch-vim
-Architecture: all
-Section: mail
-Breaks: notmuch (<<0.6~254~)
-Replaces: notmuch (<<0.6~254~)
-Depends: ${misc:Depends}, notmuch, vim-addon-manager
-Description: thread-based email index, search and tagging (vim interface)
- Notmuch is a system for indexing, searching, reading, and tagging
- large collections of email messages in maildir or mh format. It uses
- the Xapian library to provide fast, full-text search with a very
- convenient search syntax.
- .
- This package provides a vim based mail user agent based on
- notmuch.
-
 Package: notmuch-mutt
 Architecture: all
 Depends: notmuch, libmail-box-perl, libmailtools-perl,
index eb757af5da2ab3c75099189dfc6c0de020f107bb..e4f36c2cb8530fc0621b48fe9d05147432aae293 100644 (file)
@@ -57,11 +57,6 @@ Automatically open a message when navigating to it with N or P.
 
 Change 'a' command in thread-view mode to only archive open messages.
 
-Add a binding to open all closed messages.
-
-Change the 'a'rchive command in the thread view to only archive open
-messages.
-
 Completion
 ----------
 Fix bash completion to complete multiple search options (both --first
@@ -75,11 +70,6 @@ listing of duplicate messages, (distinct filenames with the same
 Message-ID). I'm not sure what the option should be named. Perhaps
 --with-duplicates ?
 
-Add a -0 option to "notmuch search" so that one can safely deal with
-any filename with:
-
-       notmuch search --output=files -0 <terms> | xargs -0 <command>
-
 "notmuch setup" should use realpath() before replacing the
 configuration file. The ensures that the final target file of any
 intermediate symbolic links is what is actually replaced, (rather than
@@ -118,13 +108,6 @@ file.
 Allow configuration for filename patterns that should be ignored when
 indexing.
 
-Replace the "notmuch part --part=id" command with "notmuch show
---part=id", (David Edmondson wants to rewrite some of "notmuch show" to
-provide more MIME-structure information in its output first).
-
-Replace the "notmuch search-tags" command with "notmuch search
---output=tags".
-
 Fix to avoid this ugly message:
 
        (process:17197): gmime-CRITICAL **: g_mime_message_get_mime_part: assertion `GMIME_IS_MESSAGE (message)' failed
@@ -163,12 +146,13 @@ vs. tag-when-all-files-flagged (* above)).
 Add an interface to accept a "key" and a byte stream, rather than a
 filename.
 
-Provide a sane syntax for date ranges. First, we don't want to require
-both endpoints to be specified. For example it would be nice to be
-able to say things like "since:2009-01-1" or "until:2009-01-1" and
-have the other endpoint be implicit. Second we'd like to support
-relative specifications of time such as "since:'2 months ago'". To do
-any of this we're probably going to need to break down an write our
+Improve syntax for date ranges queries. date:expr should be
+interpreted as date:expr..expr so that, for example, "date:2013-01-22"
+would cover the whole of the specified day (currently that's not even
+recognized as a date range expression). It might be nice to be able to
+use things like "since:2013-01-22" and "until:2013-01-22" as synonyms
+to "date:2013-01-22.." and "date:..2013-01-22", respectively. To do
+any of this we're probably going to need to break down and write our
 own parser for the query string rather than using Xapian's QueryParser
 class.
 
similarity index 99%
rename from contrib/nmbug/nmbug
rename to devel/nmbug/nmbug
index f003ef9e355fe7446aa49a89f3f7e03e6582c04d..fe103b3b7c5ac2794733e3cff3f2e2ffbb4901f4 100755 (executable)
@@ -331,7 +331,7 @@ sub do_log {
 sub do_push {
   my $remote = shift || 'origin';
 
-  git ('push', $remote);
+  git ('push', $remote, 'master');
 }
 
 
index e1d19f20effa32b08425106fcb81ac1618db773b..4eff1a7fd9a78f6a9a0e29d3e5773d80a8c99f1d 100755 (executable)
@@ -53,12 +53,13 @@ fi < ./version
 
 readonly VERSION
 
+# In the rest of this file, tests collect list of errors to be fixed
+
 verfail ()
 {
        echo No.
-       echo "$@"
-       echo "Please follow the instructions in RELEASING to choose a version"
-       exit 1
+       append_emsg "$@"
+       append_emsg "  Please follow the instructions in RELEASING to choose a version"
 }
 
 echo -n "Checking that '$VERSION' is good with digits and periods... "
@@ -73,8 +74,6 @@ case $VERSION in
 esac
 
 
-# In the rest of this file, tests collect list of errors to be fixed
-
 echo -n "Checking that this is Debian package for notmuch... "
 read deb_notmuch deb_version rest < debian/changelog
 if [ "$deb_notmuch" = 'notmuch' ]
@@ -105,6 +104,20 @@ else
        append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
 fi
 
+echo -n "Checking that NEWS header is tidy... "
+if [ "`exec sed 's/./=/g; 1q' NEWS`" = "`exec sed '1d; 2q' NEWS`" ]
+then
+       echo Yes.
+else
+       echo No.
+       if [ "`exec sed '1d; s/=//g; 2q' NEWS`" != '' ]
+       then
+               append_emsg "Line 2 in NEWS file is not all '=':s"
+       else
+               append_emsg "Line 2 in NEWS file does not have the same length as line 1"
+       fi
+fi
+
 echo -n "Checking that this is Notmuch NEWS... "
 read news_notmuch news_version news_date < NEWS
 if [ "$news_notmuch" = "Notmuch" ]
index 83e5d37aa4a939fbe366076f8d7b16c3b698685a..52338249a82867a4e0fea4fb7788264fc9b15bd4 100644 (file)
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: Jameson Rollins <jrollins@finestructure.net>
 
+(require 'notmuch-lib)
+
 (defcustom notmuch-crypto-process-mime nil
   "Should cryptographic MIME parts be processed?
 
@@ -76,7 +78,8 @@ mode."
 (define-button-type 'notmuch-crypto-status-button-type
   'action (lambda (button) (message (button-get button 'help-echo)))
   'follow-link t
-  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")
+  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."
+  :supertype 'notmuch-button-type)
 
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
index 6db62a01c46b09e7851c9259552c13d7a7574c6b..00b78e1ed265a74d52aaf78d7479934f55a65cfb 100644 (file)
@@ -504,7 +504,7 @@ Complete list of currently available key bindings:
          (notmuch-remove-if-not
           (lambda (tag)
             (not (member tag hide-tags)))
-          (process-lines notmuch-command "search-tags"))))
+          (process-lines notmuch-command "search" "--output=tags" "*"))))
 
 (defun notmuch-hello-insert-header ()
   "Insert the default notmuch-hello header."
index d78bcf8065aae699a162241e9e7e92b114a3267a..270e3dc6b343ec3a5d319b5cf91dd8ecc8603c17 100644 (file)
@@ -97,6 +97,21 @@ For example, if you wanted to remove an \"inbox\" tag and add an
   :group 'notmuch-search
   :group 'notmuch-show)
 
+;; By default clicking on a button does not select the window
+;; containing the button (as opposed to clicking on a widget which
+;; does). This means that the button action is then executed in the
+;; current selected window which can cause problems if the button
+;; changes the buffer (e.g., id: links) or moves point.
+;;
+;; This provides a button type which overrides mouse-action so that
+;; the button's window is selected before the action is run. Other
+;; notmuch buttons can get the same behaviour by inheriting from this
+;; button type.
+(define-button-type 'notmuch-button-type
+  'mouse-action (lambda (button)
+                 (select-window (posn-window (event-start last-input-event)))
+                 (button-activate button)))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
index 1864dd15a05bb8b24c2255806c9e383d9f5f6e31..acaef8ef2afd3871b071e468025fec44ab9f124c 100644 (file)
@@ -469,7 +469,8 @@ message at DEPTH in the current thread."
   'action 'notmuch-show-part-button-default
   'keymap 'notmuch-show-part-button-map
   'follow-link t
-  'face 'message-mml)
+  'face 'message-mml
+  :supertype 'notmuch-button-type)
 
 (defvar notmuch-show-part-button-map
   (let ((map (make-sparse-keymap)))
@@ -1085,6 +1086,7 @@ buttons for a corresponding notmuch search."
        ;; Remove the overlay created by goto-address-mode
        (remove-overlays (first link) (second link) 'goto-address t)
        (make-text-button (first link) (second link)
+                         :type 'notmuch-button-type
                          'action `(lambda (arg)
                                     (notmuch-show ,(third link)))
                          'follow-link t
index d6db4fa290970dd9bf851bd002f08f5e06fdc77d..826b6f43c77ba6853a32f65ad82b67af0a52271c 100644 (file)
@@ -115,7 +115,8 @@ lower).")
 (define-button-type 'notmuch-wash-button-invisibility-toggle-type
   'action 'notmuch-wash-toggle-invisible-action
   'follow-link t
-  'face 'font-lock-comment-face)
+  'face 'font-lock-comment-face
+  :supertype 'notmuch-button-type)
 
 (define-button-type 'notmuch-wash-button-citation-toggle-type
   'help-echo "mouse-1, RET: Show citation"
index 320901f77eb010a1cab4502c79db6faccbc6d49c..8720c1b542d839a24613991b4b425fe03f65e1e3 100644 (file)
@@ -462,9 +462,9 @@ notmuch_message_get_thread_id (notmuch_message_t *message)
 
 void
 _notmuch_message_add_reply (notmuch_message_t *message,
-                           notmuch_message_node_t *reply)
+                           notmuch_message_t *reply)
 {
-    _notmuch_message_list_append (message->replies, reply);
+    _notmuch_message_list_add_message (message->replies, reply);
 }
 
 notmuch_messages_t *
index 11218648f8c15f86f5a5dd6c5c0ece696577e46a..0eee5690d7feae1380aad512ede8110333d8f2b6 100644 (file)
@@ -42,19 +42,7 @@ _notmuch_message_list_create (const void *ctx)
     return list;
 }
 
-/* Append a single 'node' to the end of 'list'.
- */
-void
-_notmuch_message_list_append (notmuch_message_list_t *list,
-                             notmuch_message_node_t *node)
-{
-    *(list->tail) = node;
-    list->tail = &node->next;
-}
-
-/* Allocate a new node for 'message' and append it to the end of
- * 'list'.
- */
+/* Append 'message' to the end of 'list'. */
 void
 _notmuch_message_list_add_message (notmuch_message_list_t *list,
                                   notmuch_message_t *message)
@@ -64,7 +52,8 @@ _notmuch_message_list_add_message (notmuch_message_list_t *list,
     node->message = message;
     node->next = NULL;
 
-    _notmuch_message_list_append (list, node);
+    *(list->tail) = node;
+    list->tail = &node->next;
 }
 
 notmuch_messages_t *
index 7a409f54ca5a08b4de81b39cb652984c330ae758..f38ccb39b1ecfcbc5884341fc4024f50762665e4 100644 (file)
@@ -428,10 +428,6 @@ struct visible _notmuch_messages {
 notmuch_message_list_t *
 _notmuch_message_list_create (const void *ctx);
 
-void
-_notmuch_message_list_append (notmuch_message_list_t *list,
-                             notmuch_message_node_t *node);
-
 void
 _notmuch_message_list_add_message (notmuch_message_list_t *list,
                                   notmuch_message_t *message);
@@ -462,7 +458,7 @@ _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids,
 
 void
 _notmuch_message_add_reply (notmuch_message_t *message,
-                           notmuch_message_node_t *reply);
+                           notmuch_message_t *reply);
 
 /* sha1.c */
 
index 3633bedde20acafc064b62a52f319dcdde153111..373933677772234958a494eea03c8a18e0d4ae3f 100644 (file)
@@ -719,20 +719,21 @@ int
 notmuch_thread_get_total_messages (notmuch_thread_t *thread);
 
 /* Get a notmuch_messages_t iterator for the top-level messages in
- * 'thread'.
+ * 'thread' in oldest-first order.
  *
  * This iterator will not necessarily iterate over all of the messages
  * in the thread. It will only iterate over the messages in the thread
  * which are not replies to other messages in the thread.
- *
- * To iterate over all messages in the thread, the caller will need to
- * iterate over the result of notmuch_message_get_replies for each
- * top-level message (and do that recursively for the resulting
- * messages, etc.).
  */
 notmuch_messages_t *
 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread);
 
+/* Get a notmuch_thread_t iterator for all messages in 'thread' in
+ * oldest-first order.
+ */
+notmuch_messages_t *
+notmuch_thread_get_messages (notmuch_thread_t *thread);
+
 /* Get the number of messages in 'thread' that matched the search.
  *
  * This count includes only the messages in this thread that were
index e9c1a2d158e5d613ab129026ecf98976d1077265..7381a545eda132150461f467d0b6055fb7caa8e8 100644 (file)
@@ -39,12 +39,12 @@ typedef struct _notmuch_mset_messages {
 } notmuch_mset_messages_t;
 
 struct _notmuch_doc_id_set {
-    unsigned int *bitmap;
+    unsigned char *bitmap;
     unsigned int bound;
 };
 
-#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))
-#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))
+#define DOCIDSET_WORD(bit) ((bit) / CHAR_BIT)
+#define DOCIDSET_BIT(bit) ((bit) % CHAR_BIT)
 
 struct visible _notmuch_threads {
     notmuch_query_t *query;
@@ -359,11 +359,11 @@ _notmuch_doc_id_set_init (void *ctx,
                          GArray *arr)
 {
     unsigned int max = 0;
-    unsigned int *bitmap;
+    unsigned char *bitmap;
 
     for (unsigned int i = 0; i < arr->len; i++)
        max = MAX(max, g_array_index (arr, unsigned int, i));
-    bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));
+    bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1);
 
     if (bitmap == NULL)
        return FALSE;
index e976d643db3584f7ce057a7e20dc4adca2bcbdb7..c126aac8cc8b945e9018f7505f7910174c83535e 100644 (file)
@@ -35,7 +35,11 @@ struct visible _notmuch_thread {
     char *authors;
     GHashTable *tags;
 
+    /* All messages, oldest first. */
     notmuch_message_list_t *message_list;
+    /* Top-level messages, oldest first. */
+    notmuch_message_list_t *toplevel_list;
+
     GHashTable *message_hash;
     int total_messages;
     int matched_messages;
@@ -345,29 +349,22 @@ _thread_add_matched_message (notmuch_thread_t *thread,
 }
 
 static void
-_resolve_thread_relationships (unused (notmuch_thread_t *thread))
+_resolve_thread_relationships (notmuch_thread_t *thread)
 {
-    notmuch_message_node_t **prev, *node;
+    notmuch_message_node_t *node;
     notmuch_message_t *message, *parent;
     const char *in_reply_to;
 
-    prev = &thread->message_list->head;
-    while ((node = *prev)) {
+    for (node = thread->message_list->head; node; node = node->next) {
        message = node->message;
        in_reply_to = _notmuch_message_get_in_reply_to (message);
        if (in_reply_to && strlen (in_reply_to) &&
            g_hash_table_lookup_extended (thread->message_hash,
                                          in_reply_to, NULL,
                                          (void **) &parent))
-       {
-           *prev = node->next;
-           if (thread->message_list->tail == &node->next)
-               thread->message_list->tail = prev;
-           node->next = NULL;
-           _notmuch_message_add_reply (parent, node);
-       } else {
-           prev = &((*prev)->next);
-       }
+           _notmuch_message_add_reply (parent, message);
+       else
+           _notmuch_message_list_add_message (thread->toplevel_list, message);
     }
 
     /* XXX: After scanning through the entire list looking for parents
@@ -406,7 +403,8 @@ _notmuch_thread_create (void *ctx,
                        notmuch_string_list_t *exclude_terms,
                        notmuch_sort_t sort)
 {
-    notmuch_thread_t *thread;
+    void *local = talloc_new (ctx);
+    notmuch_thread_t *thread = NULL;
     notmuch_message_t *seed_message;
     const char *thread_id;
     char *thread_id_query_string;
@@ -415,24 +413,23 @@ _notmuch_thread_create (void *ctx,
     notmuch_messages_t *messages;
     notmuch_message_t *message;
 
-    seed_message = _notmuch_message_create (ctx, notmuch, seed_doc_id, NULL);
+    seed_message = _notmuch_message_create (local, notmuch, seed_doc_id, NULL);
     if (! seed_message)
        INTERNAL_ERROR ("Thread seed message %u does not exist", seed_doc_id);
 
     thread_id = notmuch_message_get_thread_id (seed_message);
-    thread_id_query_string = talloc_asprintf (ctx, "thread:%s", thread_id);
+    thread_id_query_string = talloc_asprintf (local, "thread:%s", thread_id);
     if (unlikely (thread_id_query_string == NULL))
-       return NULL;
+       goto DONE;
 
-    thread_id_query = notmuch_query_create (notmuch, thread_id_query_string);
+    thread_id_query = talloc_steal (
+       local, notmuch_query_create (notmuch, thread_id_query_string));
     if (unlikely (thread_id_query == NULL))
-       return NULL;
+       goto DONE;
 
-    talloc_free (thread_id_query_string);
-
-    thread = talloc (ctx, notmuch_thread_t);
+    thread = talloc (local, notmuch_thread_t);
     if (unlikely (thread == NULL))
-       return NULL;
+       goto DONE;
 
     talloc_set_destructor (thread, _notmuch_thread_destructor);
 
@@ -451,8 +448,12 @@ _notmuch_thread_create (void *ctx,
                                          free, NULL);
 
     thread->message_list = _notmuch_message_list_create (thread);
-    if (unlikely (thread->message_list == NULL))
-       return NULL;
+    thread->toplevel_list = _notmuch_message_list_create (thread);
+    if (unlikely (thread->message_list == NULL ||
+                 thread->toplevel_list == NULL)) {
+       thread = NULL;
+       goto DONE;
+    }
 
     thread->message_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                  free, NULL);
@@ -489,17 +490,26 @@ _notmuch_thread_create (void *ctx,
        _notmuch_message_close (message);
     }
 
-    notmuch_query_destroy (thread_id_query);
-
     _resolve_thread_authors_string (thread);
 
     _resolve_thread_relationships (thread);
 
+    /* Commit to returning thread. */
+    talloc_steal (ctx, thread);
+
+  DONE:
+    talloc_free (local);
     return thread;
 }
 
 notmuch_messages_t *
 notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread)
+{
+    return _notmuch_messages_create (thread->toplevel_list);
+}
+
+notmuch_messages_t *
+notmuch_thread_get_messages (notmuch_thread_t *thread)
 {
     return _notmuch_messages_create (thread->message_list);
 }
index a65730841669c5f705af96e947e70ad2b6373463..e645a351fe3c8c35d81a0f4d6e66ab802d0d2d48 100644 (file)
@@ -21,7 +21,7 @@
 notmuch \- thread-based email index, search, and tagging
 .SH SYNOPSIS
 .B notmuch
-.IR command " [" args " ...]"
+.RI "[" option " ...] " command  " [" arg " ...]"
 .SH DESCRIPTION
 Notmuch is a command-line based program for indexing, searching,
 reading, and tagging large collections of email messages.
@@ -50,6 +50,26 @@ interfaces to notmuch. The emacs-based interface to notmuch (available under
 in the Notmuch source distribution) is probably the most widely used at
 this time.
 
+.SH OPTIONS
+
+Supported global options for
+.B notmuch
+include
+
+.RS 4
+.TP 4
+.B \-\-help
+
+Print a synopsis of available commands and exit.
+.RE
+
+.RS 4
+.TP 4
+.B \-\-version
+
+Print the installed version of notmuch, and exit.
+.RE
+
 .SH COMMANDS
 
 
@@ -127,6 +147,14 @@ behavior of notmuch.
 .B NOTMUCH_CONFIG
 Specifies the location of the notmuch configuration file. Notmuch will
 use ${HOME}/.notmuch\-config if this variable is not set.
+
+.TP
+.B NOTMUCH_TALLOC_REPORT
+Location to write a talloc memory usage report. See
+.B talloc_enable_leak_report_full
+in \fBtalloc\fR(3)
+for more information.
+
 .SH SEE ALSO
 
 \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),
index b54c55dd71428ebca229f6135d57a78e109f8e00..d9daf8fbe44a39f50ba2464cb6a057cfe372afc1 100644 (file)
@@ -97,7 +97,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
     notmuch_query_t *query;
     notmuch_messages_t *messages;
     notmuch_message_t *message;
-    int ret = 0;
+    int ret = NOTMUCH_STATUS_SUCCESS;
 
     /* Optimize the query so it excludes messages that already have
      * the specified set of tags. */
index 4fc0973d3715ddd6a967d0c16f8f188b7f951c51..cfb009ba5036eeff5235dc4b792d4bbeb2133f5f 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -31,18 +31,6 @@ typedef struct command {
     const char *summary;
 } command_t;
 
-#define MAX_ALIAS_SUBSTITUTIONS 3
-
-typedef struct alias {
-    const char *name;
-    const char *substitutions[MAX_ALIAS_SUBSTITUTIONS];
-} alias_t;
-
-alias_t aliases[] = {
-    { "part", { "show", "--format=raw"}},
-    { "search-tags", {"search", "--output=tags", "*"}}
-};
-
 static int
 notmuch_help_command (void *ctx, int argc, char *argv[]);
 
@@ -260,9 +248,15 @@ main (int argc, char *argv[])
 {
     void *local;
     command_t *command;
-    alias_t *alias;
-    unsigned int i, j;
-    const char **argv_local;
+    unsigned int i;
+    notmuch_bool_t print_help=FALSE, print_version=FALSE;
+    int opt_index;
+
+    notmuch_opt_desc_t options[] = {
+       { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
+       { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 },
+       { 0, 0, 0, 0, 0 }
+    };
 
     talloc_enable_null_tracking ();
 
@@ -277,60 +271,28 @@ main (int argc, char *argv[])
     if (argc == 1)
        return notmuch (local);
 
-    if (strcmp (argv[1], "--help") == 0)
+    opt_index = parse_arguments (argc, argv, options, 1);
+    if (opt_index < 0) {
+       /* diagnostics already printed */
+       return 1;
+    }
+
+    if (print_help)
        return notmuch_help_command (NULL, argc - 1, &argv[1]);
 
-    if (strcmp (argv[1], "--version") == 0) {
+    if (print_version) {
        printf ("notmuch " STRINGIFY(NOTMUCH_VERSION) "\n");
        return 0;
     }
 
-    for (i = 0; i < ARRAY_SIZE (aliases); i++) {
-       alias = &aliases[i];
-
-       if (strcmp (argv[1], alias->name) == 0)
-       {
-           int substitutions;
-
-           argv_local = talloc_size (local, sizeof (char *) *
-                                     (argc + MAX_ALIAS_SUBSTITUTIONS - 1));
-           if (argv_local == NULL) {
-               fprintf (stderr, "Out of memory.\n");
-               return 1;
-           }
-
-           /* Copy all substution arguments from the alias. */
-           argv_local[0] = argv[0];
-           for (j = 0; j < MAX_ALIAS_SUBSTITUTIONS; j++) {
-               if (alias->substitutions[j] == NULL)
-                   break;
-               argv_local[j+1] = alias->substitutions[j];
-           }
-           substitutions = j;
-
-           /* And copy all original arguments (skipping the argument
-            * that matched the alias of course. */
-           for (j = 2; j < (unsigned) argc; j++) {
-               argv_local[substitutions+j-1] = argv[j];
-           }
-
-           argc += substitutions - 1;
-           argv = (char **) argv_local;
-       }
-    }
-
     for (i = 0; i < ARRAY_SIZE (commands); i++) {
        command = &commands[i];
 
-       if (strcmp (argv[1], command->name) == 0) {
+       if (strcmp (argv[opt_index], command->name) == 0) {
            int ret;
            char *talloc_report;
 
-           ret = (command->function)(local, argc - 1, &argv[1]);
-
-           /* in the future support for this environment variable may
-            * be supplemented or replaced by command line arguments
-            * --leak-report and/or --leak-report-full */
+           ret = (command->function)(local, argc - opt_index, argv + opt_index);
 
            talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");
 
@@ -339,7 +301,13 @@ main (int argc, char *argv[])
 
            if (talloc_report && strcmp (talloc_report, "") != 0) {
                FILE *report = fopen (talloc_report, "w");
-               talloc_report_full (NULL, report);
+               if (report) {
+                   talloc_report_full (NULL, report);
+               } else {
+                   ret = 1;
+                   fprintf (stderr, "ERROR: unable to write talloc log. ");
+                   perror (talloc_report);
+               }
            }
 
            return ret;
index 84db79265418535bdc6a9b4a364a65cd5a710b67..ffab1bb509c400e15948b7fbe5df83d6294187d2 100644 (file)
@@ -194,22 +194,39 @@ test_fixed=0
 test_broken=0
 test_success=0
 
-die () {
+_die_common () {
        code=$?
+       trap - EXIT
+       set +ex
        rm -rf "$TEST_TMPDIR"
+}
+
+die () {
+       _die_common
        if test -n "$GIT_EXIT_OK"
        then
                exit $code
        else
-               echo >&5 "FATAL: Unexpected exit with code $code"
+               exec >&5
+               say_color error '%-6s' FATAL
+               echo " $test_subtest_name"
+               echo
+               echo "Unexpected exit while executing $0. Exit code $code."
                exit 1
        fi
 }
 
+die_signal () {
+       _die_common
+       echo >&5 "FATAL: $0: interrupted by signal" $((code - 128))
+       exit $code
+}
+
 GIT_EXIT_OK=
 # Note: TEST_TMPDIR *NOT* exported!
 TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
 trap 'die' EXIT
+trap 'die_signal' HUP INT TERM
 
 test_decode_color () {
        sed     -e 's/.\[1m/<WHITE>/g' \
@@ -498,12 +515,12 @@ test_expect_equal ()
        if ! test_skip "$test_subtest_name"
        then
                if [ "$output" = "$expected" ]; then
-                       test_ok_ "$test_subtest_name"
+                       test_ok_
                else
                        testname=$this_test.$test_count
                        echo "$expected" > $testname.expected
                        echo "$output" > $testname.output
-                       test_failure_ "$test_subtest_name" "$(diff -u $testname.expected $testname.output)"
+                       test_failure_ "$(diff -u $testname.expected $testname.output)"
                fi
     fi
 }
@@ -524,12 +541,12 @@ test_expect_equal_file ()
        if ! test_skip "$test_subtest_name"
        then
                if diff -q "$file1" "$file2" >/dev/null ; then
-                       test_ok_ "$test_subtest_name"
+                       test_ok_
                else
                        testname=$this_test.$test_count
                        cp "$file1" "$testname.$basename1"
                        cp "$file2" "$testname.$basename2"
-                       test_failure_ "$test_subtest_name" "$(diff -u "$testname.$basename1" "$testname.$basename2")"
+                       test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")"
                fi
     fi
 }
@@ -567,9 +584,9 @@ test_emacs_expect_t () {
                result=$(cat OUTPUT)
                if [ "$result" = t ]
                then
-                       test_ok_ "$test_subtest_name"
+                       test_ok_
                else
-                       test_failure_ "$test_subtest_name" "${result}"
+                       test_failure_ "${result}"
                fi
        else
                # Restore state after the (non) test.
@@ -670,12 +687,12 @@ test_require_external_prereq () {
 
 test_ok_ () {
        if test "$test_subtest_known_broken_" = "t"; then
-               test_known_broken_ok_ "$@"
+               test_known_broken_ok_
                return
        fi
        test_success=$(($test_success + 1))
        say_color pass "%-6s" "PASS"
-       echo " $@"
+       echo " $test_subtest_name"
 }
 
 test_failure_ () {
@@ -684,7 +701,7 @@ test_failure_ () {
                return
        fi
        test_failure=$(($test_failure + 1))
-       test_failure_message_ "FAIL" "$@"
+       test_failure_message_ "FAIL" "$test_subtest_name" "$@"
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
        return 1
 }
@@ -701,13 +718,13 @@ test_known_broken_ok_ () {
        test_reset_state_
        test_fixed=$(($test_fixed+1))
        say_color pass "%-6s" "FIXED"
-       echo " $@"
+       echo " $test_subtest_name"
 }
 
 test_known_broken_failure_ () {
        test_reset_state_
        test_broken=$(($test_broken+1))
-       test_failure_message_ "BROKEN" "$@"
+       test_failure_message_ "BROKEN" "$test_subtest_name" "$@"
        return 1
 }
 
@@ -775,6 +792,7 @@ test_expect_success () {
        test "$#" = 3 && { prereq=$1; shift; } || prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-success"
+       test_subtest_name="$1"
        test_reset_state_
        if ! test_skip "$@"
        then
@@ -784,9 +802,9 @@ test_expect_success () {
                test_check_missing_external_prereqs_ "$@" ||
                if [ "$run_ret" = 0 -a "$eval_ret" = 0 ]
                then
-                       test_ok_ "$1"
+                       test_ok_
                else
-                       test_failure_ "$@"
+                       test_failure_ "$2"
                fi
        fi
 }
@@ -795,6 +813,7 @@ test_expect_code () {
        test "$#" = 4 && { prereq=$1; shift; } || prereq=
        test "$#" = 3 ||
        error "bug in the test script: not 3 or 4 parameters to test-expect-code"
+       test_subtest_name="$2"
        test_reset_state_
        if ! test_skip "$@"
        then
@@ -804,9 +823,9 @@ test_expect_code () {
                test_check_missing_external_prereqs_ "$@" ||
                if [ "$run_ret" = 0 -a "$eval_ret" = "$1" ]
                then
-                       test_ok_ "$2"
+                       test_ok_
                else
-                       test_failure_ "$@"
+                       test_failure_ "exit code $eval_ret, expected $1" "$3"
                fi
        fi
 }
@@ -823,10 +842,10 @@ test_external () {
        test "$#" = 4 && { prereq=$1; shift; } || prereq=
        test "$#" = 3 ||
        error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
-       descr="$1"
+       test_subtest_name="$1"
        shift
        test_reset_state_
-       if ! test_skip "$descr" "$@"
+       if ! test_skip "$test_subtest_name" "$@"
        then
                # Announce the script to reduce confusion about the
                # test output that follows.
@@ -837,9 +856,9 @@ test_external () {
                "$@" 2>&4
                if [ "$?" = 0 ]
                then
-                       test_ok_ "$descr"
+                       test_ok_
                else
-                       test_failure_ "$descr" "$@"
+                       test_failure_ "$@"
                fi
        fi
 }
@@ -853,11 +872,11 @@ test_external_without_stderr () {
        stderr="$tmp/git-external-stderr.$$.tmp"
        test_external "$@" 4> "$stderr"
        [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
-       descr="no stderr: $1"
+       test_subtest_name="no stderr: $1"
        shift
        if [ ! -s "$stderr" ]; then
                rm "$stderr"
-               test_ok_ "$descr"
+               test_ok_
        else
                if [ "$verbose" = t ]; then
                        output=`echo; echo Stderr is:; cat "$stderr"`
@@ -866,7 +885,7 @@ test_external_without_stderr () {
                fi
                # rm first in case test_failure exits.
                rm "$stderr"
-               test_failure_ "$descr" "$@" "$output"
+               test_failure_ "$@" "$output"
        fi
 }