Justus Winter [Mon, 24 Sep 2012 15:21:20 +0000 (17:21 +0200)]
Avoid potentially dereferencing a NULL pointer
GMIME_IS_MULTIPART and GMIME_IS_MESSAGE both handle NULL pointers
gracefully, but the G_OBJECT_TYPE used in the error handling block
dereferences it without checking it first.
Fix this by checking whether parent->part is valid.
Found using the clang static analyzer.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Justus Winter [Mon, 24 Sep 2012 15:21:19 +0000 (17:21 +0200)]
Annotate internal_error with the attribute noreturn
Annotating functions that do not return with the noreturn attribute
(which is understood by both gcc and clang) prevents static analyzers
from generating false positives (internal_error is used to terminate
the process and is used extensively in error handling code paths).
Remove the return statement that was placed there to appease the
compiler. Functions annotated with noreturn are not supposed to return
any values.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Justus Winter [Mon, 24 Sep 2012 15:21:18 +0000 (17:21 +0200)]
Fix the COERCE_STATUS macro
Fix the COERCE_STATUS macro to handle _internal_error being declared
as void function.
Note that the function _internal_error does not return. Evaluating to
NOTMUCH_STATUS_SUCCESS is done purely to appease the compiler.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Justus Winter [Mon, 24 Sep 2012 15:21:17 +0000 (17:21 +0200)]
Extend compat/README
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Justus Winter [Mon, 24 Sep 2012 15:21:16 +0000 (17:21 +0200)]
Provide a NORETURN_ATTRIBUTE macro similar to PRINTF_ATTRIBUTE
This attribute is understood by gcc since version 2.5. clang provides
support for testing for function attributes using __has_attribute. For
other compilers this macro evaluates to the empty string.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Justus Winter [Mon, 24 Sep 2012 15:21:15 +0000 (17:21 +0200)]
Provide a __has_attribute compatibility macro
__has_attribute is defined by clang and tests whether a given function
attribute is supported by clang.
Add a compatibility macro for other compilers.
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
Damien Cassou [Mon, 17 Sep 2012 16:43:28 +0000 (18:43 +0200)]
Run `notmuch-show-hook' after setting `header-line-format'
This patch makes it possible for notmuch-show hooks to change the
header line.
Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
Jani Nikula [Thu, 6 Sep 2012 15:32:42 +0000 (18:32 +0300)]
emacs: add support for reversing notmuch-show-mark-read tag changes
Since marking a message as read can now be a user customized set of
tag changes, make reversing this easier. Allow a prefix argument to
notmuch-show-mark-read to reverse the marking as read, similar to the
unarchiving in notmuch-show-archive-message.
While at it, update the relevant documentation to match that of other
automatic tagging (i.e. archive and reply).
Jani Nikula [Thu, 6 Sep 2012 15:32:41 +0000 (18:32 +0300)]
emacs: add support for reversing notmuch-search-archive-thread tag changes
Since archiving a thread can now be a user customized set of tag
changes, make reversing this easier. Allow a prefix argument to
notmuch-search-archive-thread to reverse the archiving, similar to the
unarchiving in notmuch-show-archive-message.
Jani Nikula [Thu, 6 Sep 2012 15:32:40 +0000 (18:32 +0300)]
emacs: add support for custom tag changes on message/thread archive
Add support for customization of the tag changes that are applied when
a message or a thread is archived. Instead of hard-coded removal of
the "inbox" tag, the user can now specify a list of tag changes to
perform.
Jani Nikula [Thu, 6 Sep 2012 15:32:39 +0000 (18:32 +0300)]
emacs: use new tag change helper to mark messages as replied
Clarify documentation while at it.
Jani Nikula [Thu, 6 Sep 2012 15:32:38 +0000 (18:32 +0300)]
emacs: fix notmuch-message-replied-tags defcustom type
Jani Nikula [Thu, 6 Sep 2012 15:32:37 +0000 (18:32 +0300)]
emacs: add helper for tag change list manipulation
Add a helper to create (and optionally reverse) a list of tag changes.
Tomi Ollila [Tue, 4 Sep 2012 14:49:13 +0000 (17:49 +0300)]
{., man}/Makefile.local: edit/remove release-checks.sh related targets
Use new target release-checks in place of verify-version-debian,
verify-version-python verify-version-manpage. This target executes
devel/release-checks.sh which does all the verifications the three
dropped targets did, and some more.
Tomi Ollila [Tue, 4 Sep 2012 14:49:12 +0000 (17:49 +0300)]
devel: add release-checks.sh
Currently Makefile.local contains some machine executable release
checking functionality. This is unnecessarily complex way to do it:
Multiline script functionality is hard to embed -- from Makefile point
of view there is just one line split using backslashes and every line
ends with ';'. It is hard to maintain such "script" when it gets longer.
The embedded script does not fail as robust as separate script; set -eu
could be added to get same level of robustness -- but the provided
Bourne Again Shell (bash) script exceeds this with 'set -o pipefail',
making the script to fail when any of the commands in pipeline fails
(and not just the last one).
Checking for release is done very seldom compared to all other use;
The whole Makefile.local gets simpler and easier to grasp when most
release checking targets are removed.
When release checking is done, the steps are executed sequentially;
nothing is allowed to be skipped due to some satisfied dependency.
Mike Kelly [Wed, 30 May 2012 07:02:03 +0000 (03:02 -0400)]
test/atomicity: use a more portable 'cp' form
-a already implies -r/-R, so no need for both.
FreeBSD's cp complains:
cp: the -R and -r options may not be specified together
Mike Kelly [Wed, 30 May 2012 07:02:01 +0000 (03:02 -0400)]
test/basic: use portable args for find
`-executable` isn't available in FreeBSD's version of find, so use a
more portable version, `-perm +111`.
Mike Kelly [Wed, 30 May 2012 07:02:00 +0000 (03:02 -0400)]
tests: Test against source man pages.
Without this, help-test tests against the installed man pages, rather
than the default ones.
Mike Kelly [Wed, 30 May 2012 07:01:59 +0000 (03:01 -0400)]
test/smtp-dummy.c: fix compilation on FreeBSD
Use the more portable netint/in.h, instead of netint/ip.h, to include
htons(3), etc.
Mike Kelly [Wed, 30 May 2012 07:01:57 +0000 (03:01 -0400)]
test/Makefile.local: Use $(XAPIAN_LDFLAGS) for symbol-test
On FreeBSD, and probably anywhere else someone installed xapian to
some other prefix, we need to use XAPIAN_LDFLAGS to make the linker can
actually find libxapian.
Mike Kelly [Wed, 30 May 2012 07:01:56 +0000 (03:01 -0400)]
configure: Add support for FreeBSD.
This makes FreeBSD a recognized platform. Follow up patches make it
work properly.
Dmitry Kurochkin [Wed, 1 Feb 2012 07:19:54 +0000 (11:19 +0400)]
test: make test_expect_equal_file() arguments flexible
Before the change, test_expect_equal_file() function treated the first
argument as "actual output file" and the second argument as "expected
output file". When the test fails, the files are copied for later
inspection. The first files was copied to "$testname.output" and the
second file to "$testname.expected". The argument order for
test_expect_equal_file() is often wrong which results in confusing
diff output and incorrectly named files.
The patch solves the issue by changing test_expect_equal_file() to
treat arguments just as two files, without any special properties
(like "actual" and "expected"). The file names for copying is now
based on the given file name: "$testname.$file1" and
"$testname.$file2". E.g. if test_expect_equal_file() is called with
"OUTPUT" and "EXPECTED", the copied files can be named
"emacs.1.OUTPUT" and "emacs.1.EXPECTED".
The down side of this approach is that diff argument order depends on
test_expect_equal_file() argument order. So sometimes we get diff
from expected to actual results, and sometimes the other way around.
But the files are always named correctly.
Pieter Praet [Wed, 22 Feb 2012 20:09:14 +0000 (21:09 +0100)]
emacs: correct `notmuch-search-mode's docstring wrt `notmuch-search-tag-all'
* emacs/notmuch.el (notmuch-search-mode):
`notmuch-search-tag-all' currently uses the current query string
instead of `notmuch-search-find-thread-id-region-search', which
might cause a race condition.
Mark Walters [Tue, 5 Jun 2012 14:36:36 +0000 (15:36 +0100)]
cli: make the command line parser's errors more informative.
Previously, the cli parser was a little erratic in what errors it
reported and would fail silently in many cases (for example, when no
argument was passed to an integer option). This was particularly
annoying as the user could not (easily) tell whether the command
failed or just there were no search results.
This patch tries to make the handling consistent and return a helpful
error message in all cases.
Sascha Silbe [Sun, 24 Jun 2012 16:29:24 +0000 (18:29 +0200)]
lib: fix NULL checks for filenames iterators
The API documentation (notmuch.h) states that the parameter may be NULL,
but the implementation only checked the current element, potentially
dereferencing a NULL pointer in the process.
Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org>
Mark Walters [Tue, 24 Jul 2012 21:21:48 +0000 (22:21 +0100)]
emacs: make notmuch-show return its buffer
notmuch-pick uses the returned buffer to try and make sure it does not
close the wrong buffer.
Tomi Ollila [Fri, 24 Aug 2012 17:29:21 +0000 (20:29 +0300)]
contrib/nmbug/nmbug-status: if realname empty, use part of mailaddr
When the From: field in patch email does not contain 'realname'
field, the patch listing does not show anything as patch sender.
In this case use the part before '@' in mail address as the sender
identification in patch listing.
David Bremner [Fri, 31 Aug 2012 01:05:51 +0000 (22:05 -0300)]
test: use (format "%S") to print nil in emacs test.
The behaviour of "emacsclient --eval nil" changed from emacs23 to
emacs24, and in emacs24 it prints 'nil' rather than an empty string.
(format "%S" foo) produces a sexpr form of foo, and is consistent
between the two versions.
David Bremner [Thu, 30 Aug 2012 01:09:54 +0000 (22:09 -0300)]
test: canonicalize content-type in "Sending a message via (fake) SMTP"
The version of message.el in emacs24 omits the charset=us-ascii,
causing the current version of this test to fail. With this patch, we
accept either option. According to RFC 2046, they are semantically
equivalent.
Tomi Ollila [Sun, 5 Aug 2012 11:13:02 +0000 (14:13 +0300)]
test: emacs: run list-processes after accept-process-output in emacs 23.1
When running emacs tests using emacs 23.1.1 the tests block (until timeout)
when emacs function (notmuch-test-wait) is called.
There is an emacs bug #2930 titled:
23.0.92; `accept-process-output' and `sleep-for' do not run sentinel
It seems this is present in emacs 23.1.
Calling list-processes after accept-process-output seems work around
this problem; in case Emacs version is 23.1 a defadvice is activated
to do just that.
Tomi Ollila [Sun, 5 Aug 2012 11:13:01 +0000 (14:13 +0300)]
test: emacs: call accept-process-output in notmuch-test-wait
notmuch-test-wait called sleep-for in a loop to wait unconditionally 0.1
seconds while waiting for process to exit.
accept-process-output returns as soon as there is any data available
from process, so using it avoids unnecessary fixed delays.
Both of these functions run process sentinels.
Michal Nazarewicz [Tue, 21 Aug 2012 13:13:36 +0000 (15:13 +0200)]
notmuch-show: add notmuch-show-mark-read-tags option
The `notmuch-show-mark-read-tags' lists tags that are to be applied when
message is read. By default, the only value is "-unread" which will remove
the unread tag. Among other uses, this variable can be used to stop
notmuch-show from modifying tags when message is shown (by setting the
variable to an empty list).
Tomi Ollila [Fri, 24 Aug 2012 08:19:41 +0000 (11:19 +0300)]
NEWS: 2 minor consistency changes in sections 0.13.1 and 0.13.2
0.13.2: `contrib/notmuch-deliver` is in backticks elsewhere in
NEWS file. Commands are generally written in backticks in latest
NEWS entries.
0.13.1: Dropped period at the end of Title
'Fix compilation of ruby bindings',
as all other titles do not end with a period.
David Bremner [Tue, 21 Aug 2012 08:41:39 +0000 (10:41 +0200)]
debian: mention some upstream news in changelog
David Bremner [Tue, 21 Aug 2012 08:39:58 +0000 (10:39 +0200)]
debian: set distribution to experimental
This is to simplify potential bugfix uploads during Debian freeze.
David Bremner [Mon, 20 Aug 2012 12:48:00 +0000 (14:48 +0200)]
version: propagate version changes
These are the result of running "make update-versions"
David Bremner [Mon, 20 Aug 2012 12:46:31 +0000 (14:46 +0200)]
debian: set date for changelog.
Make d/changelog match NEWS
David Bremner [Mon, 20 Aug 2012 12:46:15 +0000 (14:46 +0200)]
NEWS: set date for release.
David Bremner [Mon, 20 Aug 2012 11:53:50 +0000 (13:53 +0200)]
version: bump primary version
The date for man pages is taken from the last commit, so in this case
it makes sense to do this in two commits.
Austin Clements [Mon, 13 Aug 2012 15:27:19 +0000 (11:27 -0400)]
News for new 'previous' behavior
Austin Clements [Sat, 14 Jul 2012 03:47:48 +0000 (23:47 -0400)]
emacs: Make moving to the previous message move to the previous boundary
Previously, notmuch-show-previous-message would move to the beginning
of the message before the message containing point. This patch makes
it instead move to the previous message *boundary*. That is, if point
isn't already at the beginning of the message, it moves to the
beginning of the current message. This is consistent with
notmuch-show-next-message, which can be thought of as moving to the
next message boundary. Several people have expressed a preference for
this.
Austin Clements [Tue, 7 Aug 2012 12:57:10 +0000 (08:57 -0400)]
reply: Convert JSON format to use sprinter
Almost all of reply was already being formatted using the sprinter.
This patch converts the top-level dictionary to use the sprinter
interface.
Austin Clements [Tue, 7 Aug 2012 13:04:27 +0000 (09:04 -0400)]
cli: Remove now-unused json.c
The string buffer quoting functions in json.c have been superseded by
the new sprinter interface and are no longer used. Remove them.
Mark Walters [Tue, 7 Aug 2012 16:32:18 +0000 (17:32 +0100)]
emacs: notmuch search bugfix
The recent change to use json for notmuch-search.el introduced a bug
in the code for keeping position on refresh. The problem is a
comparison between (plist-get result :thread) and a thread-id returned
by notmuch-search-find-thread-id: the latter is prefixed with
"thread:"
We fix this by adding an option to notmuch-search-find-thread-id to
return the bare thread-id. It appears that notmuch-search-refresh-view
is the only caller of notmuch-search that supplies a thread-id so this
change should be safe (but could theoretically break users .emacs
functions).
Mark Walters [Wed, 8 Aug 2012 21:23:33 +0000 (22:23 +0100)]
sprinters: bugfix when NULL passed for a string.
The string function in a sprinter may be called with a NULL string
pointer (eg if a header is absent). This causes a segfault. We fix
this by checking for a null pointer in the string functions and update
the sprinter documentation.
At the moment some output when format=text is done directly rather than
via an sprinter: in that case a null pointer is passed to printf or
similar and a "(null)" appears in the output. That behaviour is not
changed in this patch.
Austin Clements [Wed, 8 Aug 2012 01:28:33 +0000 (21:28 -0400)]
test: Add test for messages with missing headers
Currently the JSON tests for search and show are broken because
notmuch attempts to dereference a NULL pointer.
Austin Clements [Wed, 8 Aug 2012 21:40:10 +0000 (17:40 -0400)]
emacs: Fix "not defined at runtime" warning
Previously, the Emacs byte compiler produced the warning
the function `remove-if-not' might not be defined at runtime.
because we only required cl at compile-time (not runtime). This fixes
this warning by requiring cl at runtime, ensuring that the definition
of remove-if-not is available.
David Bremner [Sun, 5 Aug 2012 15:05:10 +0000 (12:05 -0300)]
NEWS: discuss changes for dump and restore syntax.
The duplication in NEWS.Debian is so that Debian users will be warned
during upgrade.
David Bremner [Sat, 4 Aug 2012 12:55:45 +0000 (09:55 -0300)]
notmuch-restore: replace positional argument for input with option
Since notmuch dump doesn't use positional arguments anymore, it seems
better to be consistent.
David Bremner [Sat, 4 Aug 2012 02:23:11 +0000 (23:23 -0300)]
notmuch-dump: remove deprecated positional argument for output file
The syntax --output=filename is a smaller change than deleting the
output argument completely, and conceivably useful e.g. when running
notmuch under a debugger.
David Bremner [Fri, 3 Aug 2012 00:56:26 +0000 (21:56 -0300)]
debian: alternately depend on emacs24 for notmuch-emacs, build
This should allow users to install notmuch-emacs with only emacs24
installed on their system. For good measure, allow building with
emacs24 as a 4th choice.
Austin Clements [Fri, 3 Aug 2012 01:14:59 +0000 (21:14 -0400)]
show: Remove now unused fields from notmuch_show_format
The message_set_{begin,sep,end} and null_message fields are no longer
used because we now use the structure printer provided by the format.
Austin Clements [Fri, 3 Aug 2012 01:14:58 +0000 (21:14 -0400)]
show: Convert do_show to use sprinter
Austin Clements [Fri, 3 Aug 2012 01:14:57 +0000 (21:14 -0400)]
show: Convert show_message to use sprinter
Unlike the previous patches, this function is used for all formats.
However, for formats other than the JSON format, the sprinter methods
used by show_message are all no-ops, so this code continues to
function correctly for all of the formats.
Converting show_message eliminates show_null_message in the process,
since this maps directly to an sprinter method.
Austin Clements [Fri, 3 Aug 2012 01:14:56 +0000 (21:14 -0400)]
show: Convert envelope format_part_json to use sprinter
Austin Clements [Fri, 3 Aug 2012 01:14:55 +0000 (21:14 -0400)]
show: Convert non-envelope format_part_json to use sprinter
Austin Clements [Fri, 3 Aug 2012 01:14:54 +0000 (21:14 -0400)]
show: Convert format_part_sigstatus_json to use sprinter
Austin Clements [Fri, 3 Aug 2012 01:14:53 +0000 (21:14 -0400)]
show: Convert format_headers_json to use sprinter
This no longer requires a talloc context (not that it really did
before since it didn't return anything), so we remove its context
argument.
Austin Clements [Fri, 3 Aug 2012 01:14:52 +0000 (21:14 -0400)]
show: Feed the sprinter down to part formatters
There are several levels of function calls between where we create the
sprinter and the call to the part formatter in show_message. This
feeds the sprinter through all of them and into the part formatters.
Austin Clements [Fri, 3 Aug 2012 01:14:51 +0000 (21:14 -0400)]
reply: Create a JSON sprinter
Austin Clements [Fri, 3 Aug 2012 01:14:50 +0000 (21:14 -0400)]
show: Associate an sprinter with each format
This associates an sprinter constructor with each show format and uses
this to construct the appropriate sprinter. Currently nothing is done
with this sprinter, but the following patches will weave it through
the layers of notmuch show.
Austin Clements [Fri, 3 Aug 2012 01:14:49 +0000 (21:14 -0400)]
sprinter: Add a string_len method
This method allows callers to output strings with specific lengths.
It's useful both for strings with embedded NULs (which JSON can
represent, though parser support is apparently spotty), and
non-terminated strings.
Austin Clements [Fri, 3 Aug 2012 01:14:48 +0000 (21:14 -0400)]
test: Remove unnecessary JSON canonicalization
Format canonicalization of JSON output is no longer necessary, so
remove it. Value canonicalization (e.g., normalizing thread IDs) is
still necessary, so all of the sanitization functions remain.
Austin Clements [Fri, 3 Aug 2012 01:14:47 +0000 (21:14 -0400)]
test: Uniformly canonicalize actual and expected JSON
Previously, we used a variety of ad-hoc canonicalizations for JSON
output in the test suite, but were ultimately very sensitive to JSON
irrelevancies such as whitespace. This introduces a new test
comparison function, test_expect_equal_json, that first pretty-prints
*both* the actual and expected JSON and the compares the result.
The current implementation of this simply uses Python's json.tool to
perform pretty-printing (with a fallback to the identity function if
parsing fails). However, since the interface it introduces is
semantically high-level, we could swap in other mechanisms in the
future, such as another pretty-printer or something that does not
re-order object keys (if we decide that we care about that).
In general, this patch does not remove the existing ad-hoc
canonicalization because it does no harm. We do have to remove the
newline-after-comma rule from notmuch_json_show_sanitize and
filter_show_json because it results in invalid JSON that cannot be
pretty-printed.
Most of this patch simply replaces test_expect_equal and
test_expect_equal_file with test_expect_equal_json. It changes the
expected JSON in a few places where sanitizers had placed newlines
after commas inside strings.
David Bremner [Fri, 3 Aug 2012 00:37:18 +0000 (21:37 -0300)]
debian: close notmuch-mutt bug in changelog
Apparently Stefano and I forgot to finish that discussion about how to
patch the changelog.
Mark Walters [Sat, 28 Jul 2012 11:56:34 +0000 (12:56 +0100)]
emacs: show: exclude bug fix
The pipe message function (when used with a prefix) uses a search of
the form "id:<id1> or id:<id2>" etc. Since the user says precisely
which messages are wanted by opening them it should not use excludes.
Stefano Zacchiroli [Wed, 1 Aug 2012 08:09:42 +0000 (10:09 +0200)]
debian packaging: new depends for duplicate removals in mutt contrib
both new hard dependency for File::Which and soft dependency on fdupes
Kevin McCarthy [Wed, 1 Aug 2012 08:09:41 +0000 (10:09 +0200)]
Add duplicate message removal for notmuch-mutt.
Add a --remove-dups flag which removes duplicate files from search and
thread results. Uses fdupes if installed. Otherwise it runs a size and
Digest::SHA scan on each file to detect duplicates.
Signed-off-by: Stefano Zacchiroli <zack@upsilon.cc>
Mark Walters [Thu, 2 Aug 2012 07:19:37 +0000 (08:19 +0100)]
emacs: fix a bug introduced by the recent search cleanups.
In commit
5d0883e the function notmuch-search-next-thread was changed.
In particular it only goes to the next message if there is a next
message. This breaks notmuch-show-archive-thread-then-next. Fix this
by going to the "next" message whenever we are on a current message.
David Bremner [Thu, 2 Aug 2012 12:36:24 +0000 (09:36 -0300)]
debian: update changelog for cleaning changes
David Bremner [Thu, 2 Aug 2012 12:30:31 +0000 (09:30 -0300)]
build system: remove configure output in Make distclean.
Create a variable DISTCLEAN which contains a list of things to
clean in the distclean target (in addition to running the clean
target).
The deleted comment seems to be false these days, since we do
create files during configuration.
Use "rm -rf" here as well in case we want to add directories to
DISTCLEAN.
David Bremner [Thu, 2 Aug 2012 12:27:26 +0000 (09:27 -0300)]
build system: remove directories created by tests in "make clean"
These extra directories cause problems for building on Debian
twice in a row.
In order to remove directories, we need to us "rm -rf" instead of
"rm -f". So now we should be extra careful what we add to the
variable CLEAN.
Tomi Ollila [Thu, 3 May 2012 18:59:58 +0000 (21:59 +0300)]
configure: check whether shell is capable of parameter substring processing
'configure' script uses parameter substring extensively. It is Posix shell
feature. Original Bourne shell does not have such features. Some systems
still ships such shells as /bin/sh (for compatibility reasons -- shell
scripts written on those platforms are expected to work on 1990's systems).
Just testing whether parameter substring processing works will make the
shell exit due to syntax error if it is not compatible. Therefore the test
is executed in a subshell -- subshell exits with nonzero value when the
operation in question fails.
As 'if ! ...' does not work in Bourne shell, Short-circuiting construct
'||' is used to print information message and exit when expected.
Mark Walters [Tue, 24 Jul 2012 18:57:57 +0000 (19:57 +0100)]
man: show: update man page for entire-thread and json.
Previously in notmuch show --format=json implied --entire-thread. This
is still the default but it is now possible to disable this. Update
the manpage to reflect this.
Mark Walters [Tue, 24 Jul 2012 18:23:30 +0000 (19:23 +0100)]
schemata: update for --body=true|false option
Previously body: was a compulsory field in a message. The new
--body=false option causes notmuch show to omit this field so update
schemata to reflect this.
Mark Walters [Tue, 24 Jul 2012 18:23:29 +0000 (19:23 +0100)]
man: update man page for the new --body=true|false option
Mark Walters [Tue, 24 Jul 2012 18:23:28 +0000 (19:23 +0100)]
test: add tests for the new --body=true|false option
Mark Walters [Tue, 24 Jul 2012 18:23:27 +0000 (19:23 +0100)]
cli: add --body=true|false option to notmuch-show.c
This option allows the caller to suppress the output of the bodies of
the messages. Currently this is only implemented for format=json.
This is used by notmuch-pick.el (although not needed) because it gives
a speed-up of at least a factor of a two (and in some cases a speed up
of more than a factor of 8); moreover it reduces the memory usage in
emacs hugely.
craven@gmx.net [Mon, 23 Jul 2012 10:39:46 +0000 (12:39 +0200)]
Use the structured formatters in notmuch-search.c.
This patch switches from the current ad-hoc printer to the structured
formatters in sprinter.h, sprinter-text.c and sprinter-json.c.
The JSON tests are changed slightly in order to make them PASS for the
new structured output formatter.
The text tests pass without adaptation.
craven@gmx.net [Mon, 23 Jul 2012 10:39:45 +0000 (12:39 +0200)]
Add structured output formatter for JSON and plain text (but don't use them yet).
Using the new structured printer support in sprinter.h, implement
sprinter_json_create, which returns a new JSON structured output
formatter. The formatter prints output similar to the existing JSON, but
with differences in whitespace (mostly newlines, --output=summary prints
the entire message summary on one line, not split across multiple lines).
Also implement a "structured" formatter for plain text that prints
prefixed strings, to be used with notmuch-search.c plain text output.
craven@gmx.net [Mon, 23 Jul 2012 10:39:44 +0000 (12:39 +0200)]
Add support for structured output formatters.
This patch adds a new struct type sprinter_t, which is used for
structured formatting, e.g. JSON or S-Expressions. The structure printer
is heavily based on code from Austin Clements
(id:87d34hsdx8.fsf@awakening.csail.mit.edu).
It includes the following functions:
/* Start a new map/dictionary structure. This should be followed by
* a sequence of alternating calls to map_key and one of the
* value-printing functions until the map is ended by end.
*/
void (*begin_map) (struct sprinter *);
/* Start a new list/array structure.
*/
void (*begin_list) (struct sprinter *);
/* End the last opened list or map structure.
*/
void (*end) (struct sprinter *);
/* Print one string/integer/boolean/null element (possibly inside a
* list or map, followed or preceded by separators).
* For string, the char * must be UTF-8 encoded.
*/
void (*string) (struct sprinter *, const char *);
void (*integer) (struct sprinter *, int);
void (*boolean) (struct sprinter *, notmuch_bool_t);
void (*null) (struct sprinter *);
/* Print the key of a map's key/value pair. The char * must be UTF-8
* encoded.
*/
void (*map_key) (struct sprinter *, const char *);
/* Insert a separator (usually extra whitespace) for improved
* readability without affecting the abstract syntax of the
* structure being printed.
* For JSON, this could simply be a line break.
*/
void (*separator) (struct sprinter *);
/* Set the current string prefix. This only affects the text
* printer, which will print this string, followed by a colon,
* before any string. For other printers, this does nothing.
*/
void (*set_prefix) (struct sprinter *, const char *);
To support the plain text format properly, the following additional
function must also be implemented:
/* Set the current string prefix. This only affects the text
* printer, which will print this string, followed by a colon,
* before any string. For other printers, this does nothing.
*/
void (*set_prefix) (struct sprinter *, const char *);
The structure also contains a flag that should be set to FALSE in all
custom printers and to TRUE in the plain text formatter.
/* True if this is the special-cased plain text printer.
*/
notmuch_bool_t is_text_printer;
The printer can (and should) use internal state to insert delimiters
and syntax at the correct places.
Example:
format->begin_map(format);
format->map_key(format, "foo");
format->begin_list(format);
format->integer(format, 1);
format->integer(format, 2);
format->integer(format, 3);
format->end(format);
format->map_key(format, "bar");
format->begin_map(format);
format->map_key(format, "baaz");
format->string(format, "hello world");
format->end(format);
format->end(format);
would output JSON as follows:
{"foo": [1, 2, 3], "bar": { "baaz": "hello world"}}
Austin Clements [Sat, 21 Jul 2012 17:37:12 +0000 (13:37 -0400)]
News for search cleanups
Austin Clements [Sat, 21 Jul 2012 17:37:11 +0000 (13:37 -0400)]
emacs: Fix navigation of multi-line search result formats
At this point, the only remaining functions that don't support
multi-line search result formats are the thread navigation functions.
This patch fixes that by rewriting them in terms of
notmuch-search-result-{beginning,end}.
This changes the behavior of notmuch-search-previous-thread slightly
so that if point isn't at the beginning of a result, it first moves
point to the beginning of the result.
Austin Clements [Sat, 21 Jul 2012 17:37:10 +0000 (13:37 -0400)]
emacs: Allow custom tags formatting
Previously we ignored any notmuch-search-result-format customizations
for tag formatting because we needed to be able to parse back in the
result line and update the tags in place. We no longer do either of
these things, so we can allow customization of this format.
(Coincidentally, previously we still allowed too much customization of
the tags format, since moving it earlier on the line or removing it
from the line would interfere with the tagging mechanism. There is
now no problem with doing such things.)
Austin Clements [Sat, 21 Jul 2012 17:37:09 +0000 (13:37 -0400)]
emacs: Replace other search text properties with result property
Since the result object contains everything that the other text
properties recorded, we can remove the other text properties and
simply look in the plist of the appropriate result object.
Austin Clements [Sat, 21 Jul 2012 17:37:08 +0000 (13:37 -0400)]
emacs: Use result text properties for search result iteration
This simplifies the traversal of regions of results and eliminates the
need for save-excursions (which tend to get in the way of maintaining
point when we make changes to the buffer). It also fixes some strange
corner cases in the old line-based code where results that bordered
the region but were not included in it could be affected by region
commands. Coincidentally, this also essentially enables multi-line
search result formats; the only remaining non-multi-line-capable
functions are notmuch-search-{next,previous}-thread, which are only
used for interactive navigation.
Austin Clements [Sat, 21 Jul 2012 17:37:07 +0000 (13:37 -0400)]
emacs: Update tags by rewriting the search result line in place
Now that we keep the full thread result object, we can refresh a
result after any changes by simply deleting and reconstructing the
result line from scratch.
A convenient side-effect of this wholesale replacement is that search
now re-applies notmuch-search-line-faces when tags change.
Austin Clements [Sat, 21 Jul 2012 17:37:06 +0000 (13:37 -0400)]
emacs: Use text properties instead of overlays for tag coloring
Previously, tag-based search result highlighting was done by creating
an overlay over each search result. However, overlays have annoying
front- and rear-advancement semantics that make it difficult to
manipulate text at their boundaries, which the next patch will do.
They also have performance problems (creating an overlay is linear in
the number of overlays between point and the new overlay, making
highlighting a search buffer quadratic in the number of results).
Text properties have neither problem. However, text properties make
it more difficult to apply multiple faces since, unlike with overlays,
a given character can only have a single 'face text property. Hence,
we introduce a utility function that combines faces into any existing
'face text properties.
Using this utility function, it's straightforward to apply all of the
appropriate tag faces in notmuch-search-color-line.
Austin Clements [Sat, 21 Jul 2012 17:37:05 +0000 (13:37 -0400)]
emacs: Record thread search result object in a text property
This also provides utility functions for working with this text
property that get its value, find its start, and find its end.
Ingo Lohmar [Sun, 3 Jun 2012 18:23:57 +0000 (21:23 +0300)]
emacs: Fix notmuch-message-mark-replied.
notmuch-message-mark-replied used "apply" to change message tags
according to notmuch-message-replied-tags after sending a reply. This
works if the latter is a single-element list. But with the recently
changed format of tag changes, it breaks for multiple-element lists.
Use "funcall" to properly pass the list of tag changes as a single
argument.
David Bremner [Thu, 12 Jul 2012 23:49:09 +0000 (17:49 -0600)]
debian: finalize changelog
It turns out the "debian-snapshot" target needs a valid changelog.
Austin Clements [Mon, 9 Jul 2012 21:42:42 +0000 (17:42 -0400)]
News for JSON-based search
Austin Clements [Mon, 9 Jul 2012 21:42:41 +0000 (17:42 -0400)]
emacs: Switch from text to JSON format for search results
The JSON format eliminates the complex escaping issues that have
plagued the text search format. This uses the incremental JSON parser
so that, like the text parser, it can output search results
incrementally.
This slows down the parser by about ~4X, but puts us in a good
position to optimize either by improving the JSON parser (evidence
suggests this can reduce the overhead to ~40% over the text format) or
by switching to S-expressions (evidence suggests this will more than
double performance over the text parser). [1]
This also fixes the incremental search parsing test.
This has one minor side-effect on search result formatting.
Previously, the date field was always padded to a fixed width of 12
characters because of how the text parser's regexp was written. The
JSON format doesn't do this. We could pad it out in Emacs before
formatting it, but, since all of the other fields are variable width,
we instead fix notmuch-search-result-format to take the variable-width
field and pad it out. For users who have customized this variable,
we'll mention in the NEWS how to fix this slight format change.
[1] id:"
20110720205007.GB21316@mit.edu"
Austin Clements [Mon, 9 Jul 2012 21:42:40 +0000 (17:42 -0400)]
emacs: Implement an incremental JSON parser
This parser is designed to read streaming JSON whose structure is
known to the caller. Like a typical JSON parsing interface, it
provides a function to read a complete JSON value from the input.
However, it extends this with an additional function that
requires the next value in the input to be a compound value and
descends into it, allowing its elements to be read one at a time
or further descended into. Both functions can return 'retry to
indicate that not enough input is available.
The parser supports efficient partial parsing, so there's no need to
frame the input for correctness or performance.
The bulk of the parsing is still done by Emacs' json.el, so any
improvements or optimizations to that will benefit the incremental
parser as well.
Currently only descending into JSON lists is supported because that's
all we need, but support for descending into JSON objects can be added
in the future.
Austin Clements [Mon, 9 Jul 2012 21:42:39 +0000 (17:42 -0400)]
test: New test for incremental search output parsing
This advises the search process filter to make it process one
character at a time in order to test the pessimal case for incremental
search output parsing.
The text parser fails this test because it gets tricked into thinking
a parenthetical remark in a subject is the tag list.
Austin Clements [Mon, 9 Jul 2012 21:42:38 +0000 (17:42 -0400)]
emacs: Pass plist to `notmuch-search-show-result'
Rather than passing lots of arguments and then further passing those
to `notmuch-search-insert-field', pass a plist containing all of the
search result information. This plist is compatible with the JSON
format search results.
Austin Clements [Mon, 9 Jul 2012 21:42:37 +0000 (17:42 -0400)]
emacs: Move search-target logic to `notmuch-search-show-result'
This is a simpler place to do this, since we can avoid any point
motion and hence any save-excursions in
`notmuch-search-process-filter', which in turn lets us put all of the
search-target logic outside of any save-excursions.
`notmuch-search-show-{result,error}' are now responsible for their own
point motion.
`notmuch-search-process-filter' could use some reindentation after
this, but we're about to rewrite it entirely, so we won't bother.
Austin Clements [Mon, 9 Jul 2012 21:42:36 +0000 (17:42 -0400)]
emacs: Helper for reporting search parsing errors
This removes the last bit of direct output from the parsing function.
With the parser now responsible solely for parsing, we can swap it out
for another parser.
Austin Clements [Mon, 9 Jul 2012 21:42:35 +0000 (17:42 -0400)]
emacs: Separate search line parsing and display
Previously, much of the display of search lines was done in the same
function that parsed the CLI's output. Now the parsing function only
parses, and notmuch-search-show-result fully inserts the search result
in the search buffer.
Austin Clements [Mon, 9 Jul 2012 21:42:34 +0000 (17:42 -0400)]
emacs: Clean up notmuch-search-show-result
This simplifies the code and makes it no longer cubic in the number of
result fields.