aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--NEWS21
-rw-r--r--bindings/python/notmuch/database.py2
-rw-r--r--bindings/ruby/defs.h3
-rw-r--r--bindings/ruby/init.c1
-rw-r--r--bindings/ruby/thread.c20
-rwxr-xr-xcontrib/notmuch-mutt/notmuch-mutt24
-rw-r--r--contrib/notmuch-mutt/notmuch-mutt.rc16
-rw-r--r--contrib/notmuch-vim/Makefile (renamed from vim/Makefile)0
-rw-r--r--contrib/notmuch-vim/README (renamed from vim/README)0
-rw-r--r--contrib/notmuch-vim/notmuch.yaml (renamed from vim/notmuch.yaml)0
-rw-r--r--contrib/notmuch-vim/plugin/notmuch.vim (renamed from vim/plugin/notmuch.vim)0
-rw-r--r--contrib/notmuch-vim/syntax/notmuch-compose.vim (renamed from vim/syntax/notmuch-compose.vim)0
-rw-r--r--contrib/notmuch-vim/syntax/notmuch-folders.vim (renamed from vim/syntax/notmuch-folders.vim)0
-rw-r--r--contrib/notmuch-vim/syntax/notmuch-git-diff.vim (renamed from vim/syntax/notmuch-git-diff.vim)0
-rw-r--r--contrib/notmuch-vim/syntax/notmuch-search.vim (renamed from vim/syntax/notmuch-search.vim)0
-rw-r--r--contrib/notmuch-vim/syntax/notmuch-show.vim (renamed from vim/syntax/notmuch-show.vim)0
-rw-r--r--debian/NEWS.Debian7
-rw-r--r--debian/control15
-rw-r--r--devel/TODO30
-rwxr-xr-xdevel/nmbug/nmbug (renamed from contrib/nmbug/nmbug)2
-rwxr-xr-xdevel/nmbug/nmbug-status (renamed from contrib/nmbug/nmbug-status)0
-rw-r--r--devel/nmbug/status-config.json (renamed from contrib/nmbug/status-config.json)0
-rwxr-xr-xdevel/release-checks.sh23
-rw-r--r--emacs/notmuch-crypto.el5
-rw-r--r--emacs/notmuch-hello.el2
-rw-r--r--emacs/notmuch-lib.el15
-rw-r--r--emacs/notmuch-show.el4
-rw-r--r--emacs/notmuch-wash.el3
-rw-r--r--lib/message.cc4
-rw-r--r--lib/messages.c17
-rw-r--r--lib/notmuch-private.h6
-rw-r--r--lib/notmuch.h13
-rw-r--r--lib/query.cc10
-rw-r--r--lib/thread.cc64
-rw-r--r--man/man1/notmuch.130
-rw-r--r--notmuch-tag.c2
-rw-r--r--notmuch.c84
-rw-r--r--test/test-lib.sh67
38 files changed, 289 insertions, 201 deletions
diff --git a/NEWS b/NEWS
index 1cea2ecb..bd2039b5 100644
--- 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.
diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index fe692eb7..7ddf5cfe 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -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)
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index fe81b3f9..5b44585a 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -262,6 +262,9 @@ 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);
VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index f4931d34..663271d4 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -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 */
diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c
index efe5aaf7..56616d9f 100644
--- a/bindings/ruby/thread.c
+++ b/bindings/ruby/thread.c
@@ -92,6 +92,26 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self)
}
/*
+ * 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
*
* Get the number of messages in thread that matched the search
diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt
index d14709df..00c5ef82 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -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
diff --git a/contrib/notmuch-mutt/notmuch-mutt.rc b/contrib/notmuch-mutt/notmuch-mutt.rc
index ddc4b480..6b299dc9 100644
--- a/contrib/notmuch-mutt/notmuch-mutt.rc
+++ b/contrib/notmuch-mutt/notmuch-mutt.rc
@@ -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"
diff --git a/vim/Makefile b/contrib/notmuch-vim/Makefile
index f17bebfe..f17bebfe 100644
--- a/vim/Makefile
+++ b/contrib/notmuch-vim/Makefile
diff --git a/vim/README b/contrib/notmuch-vim/README
index 53f1c4e1..53f1c4e1 100644
--- a/vim/README
+++ b/contrib/notmuch-vim/README
diff --git a/vim/notmuch.yaml b/contrib/notmuch-vim/notmuch.yaml
index 3d8422c8..3d8422c8 100644
--- a/vim/notmuch.yaml
+++ b/contrib/notmuch-vim/notmuch.yaml
diff --git a/vim/plugin/notmuch.vim b/contrib/notmuch-vim/plugin/notmuch.vim
index 8f27fb92..8f27fb92 100644
--- a/vim/plugin/notmuch.vim
+++ b/contrib/notmuch-vim/plugin/notmuch.vim
diff --git a/vim/syntax/notmuch-compose.vim b/contrib/notmuch-vim/syntax/notmuch-compose.vim
index 19adb756..19adb756 100644
--- a/vim/syntax/notmuch-compose.vim
+++ b/contrib/notmuch-vim/syntax/notmuch-compose.vim
diff --git a/vim/syntax/notmuch-folders.vim b/contrib/notmuch-vim/syntax/notmuch-folders.vim
index 9477f86f..9477f86f 100644
--- a/vim/syntax/notmuch-folders.vim
+++ b/contrib/notmuch-vim/syntax/notmuch-folders.vim
diff --git a/vim/syntax/notmuch-git-diff.vim b/contrib/notmuch-vim/syntax/notmuch-git-diff.vim
index 6f15fdc7..6f15fdc7 100644
--- a/vim/syntax/notmuch-git-diff.vim
+++ b/contrib/notmuch-vim/syntax/notmuch-git-diff.vim
diff --git a/vim/syntax/notmuch-search.vim b/contrib/notmuch-vim/syntax/notmuch-search.vim
index f458d778..f458d778 100644
--- a/vim/syntax/notmuch-search.vim
+++ b/contrib/notmuch-vim/syntax/notmuch-search.vim
diff --git a/vim/syntax/notmuch-show.vim b/contrib/notmuch-vim/syntax/notmuch-show.vim
index c3a98b77..c3a98b77 100644
--- a/vim/syntax/notmuch-show.vim
+++ b/contrib/notmuch-vim/syntax/notmuch-show.vim
diff --git a/debian/NEWS.Debian b/debian/NEWS.Debian
index 907d7907..1dd9e0d0 100644
--- a/debian/NEWS.Debian
+++ b/debian/NEWS.Debian
@@ -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
diff --git a/debian/control b/debian/control
index 5bb0d051..fb995919 100644
--- a/debian/control
+++ b/debian/control
@@ -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,
diff --git a/devel/TODO b/devel/TODO
index eb757af5..e4f36c2c 100644
--- a/devel/TODO
+++ b/devel/TODO
@@ -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.
diff --git a/contrib/nmbug/nmbug b/devel/nmbug/nmbug
index f003ef9e..fe103b3b 100755
--- a/contrib/nmbug/nmbug
+++ b/devel/nmbug/nmbug
@@ -331,7 +331,7 @@ sub do_log {
sub do_push {
my $remote = shift || 'origin';
- git ('push', $remote);
+ git ('push', $remote, 'master');
}
diff --git a/contrib/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index d08ca08d..d08ca08d 100755
--- a/contrib/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
diff --git a/contrib/nmbug/status-config.json b/devel/nmbug/status-config.json
index 6b4934fa..6b4934fa 100644
--- a/contrib/nmbug/status-config.json
+++ b/devel/nmbug/status-config.json
diff --git a/devel/release-checks.sh b/devel/release-checks.sh
index e1d19f20..4eff1a7f 100755
--- a/devel/release-checks.sh
+++ b/devel/release-checks.sh
@@ -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" ]
diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 83e5d37a..52338249 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -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))
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6db62a01..00b78e1e 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -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."
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index d78bcf80..270e3dc6 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -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
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1864dd15..acaef8ef 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -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
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d6db4fa2..826b6f43 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -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"
diff --git a/lib/message.cc b/lib/message.cc
index 320901f7..8720c1b5 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -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 *
diff --git a/lib/messages.c b/lib/messages.c
index 11218648..0eee5690 100644
--- a/lib/messages.c
+++ b/lib/messages.c
@@ -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 *
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 7a409f54..f38ccb39 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -429,10 +429,6 @@ 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 */
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 3633bedd..37393367 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -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
diff --git a/lib/query.cc b/lib/query.cc
index e9c1a2d1..7381a545 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -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;
diff --git a/lib/thread.cc b/lib/thread.cc
index e976d643..c126aac8 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -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,18 +490,27 @@ _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);
}
diff --git a/man/man1/notmuch.1 b/man/man1/notmuch.1
index a6573084..e645a351 100644
--- a/man/man1/notmuch.1
+++ b/man/man1/notmuch.1
@@ -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),
diff --git a/notmuch-tag.c b/notmuch-tag.c
index b54c55dd..d9daf8fb 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -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. */
diff --git a/notmuch.c b/notmuch.c
index 4fc0973d..cfb009ba 100644
--- 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;
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 84db7926..ffab1bb5 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -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
}