Commit graph

3515 commits

Author SHA1 Message Date
David Bremner
0919ea4c55 notmuch-restore: allocate a temporary talloc context for each line parsed.
This lets the high level code in notmuch restore be ignorant about
what the lower level code is doing as far as allocating memory.
2012-12-22 23:19:43 -04:00
David Bremner
ba4e856529 tag-utils: use the tag_opt_list_t as talloc context, if possible.
The memory usage discipline of tag_op_list_t is never to free the
internal array of tag operations before freeing the whole list, so it
makes sense to take advantage of hierarchical de-allocation by talloc.

By not relying on the context passed into tag_parse_line, we can allow
tag_op_list_t structures to live longer than that context.
2012-12-22 23:13:15 -04:00
David Bremner
77b4ec70ec notmuch-restore: fix return value propagation
Previously notmuch_restore_command returned 0 if tag_message returned
a non-zero (failure) value. This is wrong, since non-zero status
indicates something mysterious went wrong with retrieving the message,
or applying it.

There was also a failure to check or propagate the return value from
tag_op_list_apply in tag_message.
2012-12-22 23:11:47 -04:00
Mark Walters
4af1ac604e emacs: show: set default show-all-multipart/alternatives to nil
Now that the invisibility display of parts is present we no longer
need to force the display of all multipart/alternatives: users can
toggle them for themselves when needed.
2012-12-21 10:03:06 -04:00
Mark Walters
a5b5404976 emacs: show: add invisibility button action
This adds a button action to show hidden parts. In this version "RET"
toggles the visibility of any part which puts content in the buffer
(as opposed to attachments such as application/pdf).

The button is used to hide parts when appropriate (eg text/html in
multipart/alternative).
2012-12-21 10:02:57 -04:00
Mark Walters
0c3a63f1af emacs: show: add overlays for each part
This makes notmuch-show-insert-bodypart add an overlay for any
non-trivial part with a button header (currently the first text/plain
part does not have a button). At this point the overlay is available
to the button but there is no action using it yet.

In addition the argument HIDE is passed down to
notmuch-show-insert-part-overlays to request that the part be hidden
by default but this is not acted on yet.
2012-12-21 09:59:00 -04:00
Mark Walters
fff2ea2ba9 emacs: show: modify insert-part-header to save the button text
This just make notmuch-show-insert-part-header save the basic button
text for parts as an attribute. This makes it simpler for the button
action (added in a later patch) to reword the label as appropriate (eg
append "(not shown)" or not as appropriate).
2012-12-21 09:54:30 -04:00
Austin Clements
8ba6016889 emacs: Eliminate buffer invisibility specs from show and wash
Previously, all visibility in show buffers for headers, message
bodies, and washed text was specified by generating one or more
symbols for each region and creating overlays with their 'invisible
property set to carefully crafted combinations of these symbols.
Visibility was controlled not by modifying the overlays directly, but
by adding and removing the generated symbols from a gigantic buffer
invisibilty spec.

This has myriad negative consequences.  It's slow because Emacs'
display engine has to traverse the buffer invisibility list for every
overlay and, since every overlay has its own symbol, this makes
rendering O(N^2) in the number of overlays.  It composes poorly
because symbol-type 'invisible properties are taken from the highest
priority overlay over a given character (which is often ambiguous!),
rather than being gathered from all overlays over a character.  As a
result, we have to include symbols related to message hiding in the
wash code lest the wash overlays un-hide parts of hidden messages.  It
also requires various workarounds for isearch to properly open
overlays, to set up buffer-invisibility-spec for
remove-from-invisibility-spec to work right, and to explicitly refresh
the display after updating the buffer invisibility spec.

None of this is necessary.

This patch converts show and wash to use simple boolean 'invisible
properties and to not use the buffer invisibility spec.  Rather than
adding and removing generated symbols from the invisibility spec, the
code now directly toggles the 'invisible property of the appropriate
overlay.  This speeds up rendering because the display engine only has
to check the boolean values of the overlays over a character.  It
composes nicely because text will be invisible if *any* overlay over
it has 'invisible t, which means we can overlap invisibility overlays
with abandon.  We no longer need any of the workarounds mentioned
above.  And it fixes a minor bug for free: now, when isearch opens a
washed region, the button text will update to say "Click/Enter to
hide" rather than remaining unchanged.
2012-12-21 09:43:45 -04:00
Austin Clements
92d7ae3876 news: Promote some things to a general section
Date range search may be implemented as a library change, but it's an
important user-facing change that affects all notmuch usage.  Tag name
restrictions aren't as important, but they affect both the CLI
interface and the Emacs interface.
2012-12-21 09:41:39 -04:00
Austin Clements
60fc5a43c0 News for changes from Austin Clements
I fear I've fallen behind on my NEWS duties.
2012-12-21 09:41:39 -04:00
Justus Winter
db64b67bf8 python: remove now unused import of module sys
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-12-21 14:23:54 +01:00
Justus Winter
0687e2ae23 python: remove functions that have been marked as deprecated in 0.14
Removes Message.{format,print}_messages.

This code adds functionality at the python level that is unlikely to
be useful for anyone. Furthermore the python bindings strive to be a
thin wrapper around libnotmuch. The code has been marked as deprecated
in 0.14 and is now removed.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-12-21 10:56:06 +01:00
Justus Winter
8728340644 python: remove Database.db_p
The function has been marked as deprecated in 0.14 and is now removed.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-12-21 10:56:06 +01:00
Jani Nikula
22ebd9aa24 man: document notmuch search --format=text0 2012-12-18 17:04:29 -04:00
Jani Nikula
b98e890456 test: notmuch search --format=text0 2012-12-18 17:04:17 -04:00
Jani Nikula
69408c35ff cli: add --format=text0 to notmuch search
Add new format text0, which is otherwise the same as text, but use the
null character as separator instead of the newline character. This is
similar to find(1) -print0 option, and works together with the
xargs(1) -0 option.
2012-12-18 17:04:06 -04:00
Jani Nikula
64122c31fa sprinter: add text0 formatter for null character separated text
Same as the text formatter, but with each field separated by a null
character rather than a newline character.
2012-12-18 17:03:34 -04:00
Jani Nikula
1358f93a9f sprinter: clarify separator documentation
For text printers, the separator is a syntactic element.
2012-12-18 17:03:24 -04:00
Mark Walters
480f44fbe4 contrib: pick: Do not indent messages in the message pane
Currently pick just uses notmuch-show to display messages in the
message pane: this means that they get indented just as show
would. However, since pick is only displaying one message at a time
there is no need to indent so override the indentation.
2012-12-18 17:03:00 -04:00
Peter Wang
732f50a20a test: conform to content length, encoding fields
Update tests to expect content-length and content-transfer-encoding
fields in show --format=json output, for leaf parts with omitted body
content.
2012-12-17 09:11:57 -04:00
Peter Wang
b96ba6326a show: indicate length, encoding of omitted body content
If a leaf part's body content is omitted, return the encoded length and
transfer encoding in --format=json output.  This information may be used
by the consumer, e.g. to decide whether to download a large attachment
over a slow link.

Returning the _encoded_ content length is more efficient than returning
the _decoded_ content length.  Returning the transfer encoding allows
the consumer to estimate the decoded content length.
2012-12-17 09:10:35 -04:00
Peter Wang
35860e00d1 show: indicate charset for all omitted parts
Write a "charset" field for all omitted parts for which it is applicable,
not only text/html parts. Factor out the code to a separate function.
It will be extended with more fields next.
2012-12-17 09:10:00 -04:00
Peter Wang
ee425ae2ad test: normalize only message filenames in show json
notmuch_json_show_sanitize replaced "filename" field values even in part
structures, where the value is predictable.  Make it only normalize the
filename value if it is an absolute path (begins with slash), which is
true of the Maildir filenames that were intended to be normalized away.
2012-12-17 09:08:04 -04:00
Austin Clements
2cdb3f54f7 emacs: Use --format-version for search, show, and reply 2012-12-16 17:22:26 -04:00
Austin Clements
0df6dcfe76 emacs: Special handling for version mismatch errors
Since Emacs has more semantic information, we suppress the generic
format version error from the CLI and give a more informative error.
2012-12-16 17:22:14 -04:00
Austin Clements
e723e21f75 test: Sanity tests for the --format-version argument 2012-12-16 17:21:49 -04:00
Austin Clements
f6adf6615c reply: Support --format-version 2012-12-16 17:21:32 -04:00
Austin Clements
aecff2c9fd show: Support --format-version 2012-12-16 17:21:00 -04:00
Austin Clements
3152cf4b12 search: Support --format-version 2012-12-16 17:20:43 -04:00
Austin Clements
1c6195b9e3 cli: Framework for structured output versioning
Currently there is a period of pain whenever we make
backward-incompatible changes to the structured output format, which
discourages not only backward-incompatible improvements to the format,
but also backwards-compatible additions that may not be "perfect".  In
the end, these problems limit experimentation and innovation.

This series of patches introduces a way for CLI callers to request a
specific format version on the command line and to determine if the
CLI does not supported the requested version (and perhaps present a
useful diagnostic to the user).  Since the caller requests a format
version, it's also possible for the CLI to support multiple
incompatible versions simultaneously, unlike the alternate approach of
including version information in the output.

This patch lays the groundwork by introducing a versioning convention,
standard exit codes, and a utility function to check the requested
version and produce standardized diagnostic messages and exit
statuses.
2012-12-16 17:20:33 -04:00
Austin Clements
1e12b91b3c test: Test search's handling of subprocess errors 2012-12-16 17:17:58 -04:00
Austin Clements
19e5b2d912 emacs: Use unified error handling in search
This slightly changes the output of an existing test since we now
report non-zero exits with a pop-up buffer instead of at the end of
the search results.
2012-12-16 17:17:41 -04:00
Austin Clements
b3dc31f78d test: Test show's handling of subprocess errors 2012-12-16 17:04:24 -04:00
Austin Clements
e1d5e88156 emacs: Improve error handling for notmuch-call-notmuch-json
This checks for non-zero exit status from JSON CLI calls and pops up
an error buffer with stderr and stdout.  A consequence of this is that
show and reply now handle errors, rather than ignoring them.
2012-12-16 17:04:08 -04:00
Austin Clements
66c935cff3 emacs: Factor out synchronous notmuch JSON invocations
Previously this code was duplicated between show and reply.  This
factors out synchronously invoking notmuch and parsing the output as
JSON.
2012-12-16 17:00:22 -04:00
Austin Clements
0844af35eb emacs: Use unified error handling in notmuch-call-notmuch-process
This makes notmuch-call-notmuch-process use the unified CLI error
handling, which basically refines the error handling this function
already did.
2012-12-16 17:00:00 -04:00
Austin Clements
693cf03cee emacs: Centralize notmuch command error handling
This provides library functions for unified handling of errors from
the notmuch CLI.  Follow-up patches will convert some scattered error
handling to use this and add error handling where we currently ignore
errors.
2012-12-16 16:58:14 -04:00
Mark Walters
780a98d14e contrib: pick: archive message updated
Update pick's archive message to respect notmuch-archive-tags. Also
split archive message into an archiving part and a separate
"then-next" part, to move more inline with show. Update the keybinding
so default behaviour is unchanged.
2012-12-15 13:48:02 -04:00
Austin Clements
d0ebd6cb53 emacs: Fix bug in resynchronizing after a JSON parse error
Previously, if the input stream consisted only of an error message,
notmuch-json-begin-compound would signal a (wrong-type-argument
number-or-marker-p nil) error when reaching the end of the error
message.  This happened because notmuch-json-scan-to-value would think
that it reached a value and put the parser into the 'value state.
Even after notmuch-json-begin-compound signaled the syntax error, the
parser would remain in this state and when the resynchronization logic
reached the end of the buffer, the parser would fail because the
'value state indicates that characters are available.

This fixes this problem by restoring the parser's previous state if it
encounters a syntax error.
2012-12-15 13:47:49 -04:00
David Bremner
327f30a8f3 perf-test: use nmbug tags in dump-restore tests
This makes the tag set a bit less trivial.

Note that if you use the small corpus, this is not so interesting (and
is also a bit noisy) since the messages will not be found. In the
future this could be checked for.

Conflicts:
	performance-test/01-dump-restore
2012-12-15 08:30:13 -04:00
David Bremner
51b0f8ff33 perf-test: split basic into 00-new, 01-dump-restore, and 02-tag
We use the new "time_start" function to restore the database from cache
if possible.
2012-12-15 08:29:08 -04:00
David Bremner
5c35791d7c perf-test: unpack tags.
There is only one set of tags, independant of the size of message
corpus chosen.
2012-12-15 08:17:58 -04:00
David Bremner
5f8e376912 perf-test: bump corpus version to 0.3
The new version ships with some tags, and an updated archive of the
notmuch mailing list.
2012-12-15 08:17:58 -04:00
David Bremner
d7ba84dfad perf-test: update README
Describe new argument parsing and mention cache handling routines.
2012-12-15 08:17:58 -04:00
David Bremner
ceaf5ca6c0 perf-test: add caching of xapian database
The caching and uncaching seem to be necessarily manual, as timing the
initial notmuch new is one of our goals with this suite.
2012-12-15 08:17:58 -04:00
David Bremner
74a883562b perf-test: cache unpacked corpus
Unpacking is not really the expensive step (compared to the initial
notmuch new), but this is a pre-requisite to caching the database.
2012-12-15 08:17:57 -04:00
David Bremner
925ebd1fde perf-test: optionally print description for each group of tests
Output from tests is indented slightly in the same style as the
correctness tests.
2012-12-15 08:17:57 -04:00
David Bremner
a3137c61e1 perf-test: add corpus size to output, compact I/O stats
Austin suggested a while ago that the corpus size be printed in the
header. In the end it seems the corpus will be fixed per test script,
so this suggestion indeed makes sense.

The tabbing was wrapping on my usual 80 column terminal, so I joined
the input and output columns together.
2012-12-14 22:23:55 -04:00
David Bremner
e7c661d31a perf-test: add argument parsing for performance tests
This patch just sets (non-exported) variables. The variable $debug is
already used, and $corpus_size will be used in following commits.
2012-12-14 22:23:55 -04:00
David Bremner
e52597016f perf-test: propagate non-zero returns from /usr/bin/time
Unlike in the correctness tests, the most common cause of non-zero
return seems to be the user interrupting, so killing the run seems
like the friendly thing to do.
2012-12-14 22:23:54 -04:00