Commit graph

483 commits

Author SHA1 Message Date
Austin Clements
401dbebd48 emacs: Use the minibuffer for CLI error reporting
We recently switched to popping up a buffer to report CLI errors, but
this was too intrusive, especially for transient errors and especially
since we made fewer things ignore errors.  This patch changes this to
display a basic error message in the minibuffer (using Emacs' usual
error handling path) and, if there are additional details, to log
these to a separate error buffer and reference the error buffer from
the minibuffer message.  This is more in line with how Emacs typically
handles errors, but makes the details available to the user without
flooding them with the details.

Given this split, we pare down the basic message and make it more
user-friendly, and also make the verbose message even more detailed
(and more debugging-oriented).
2013-01-06 22:47:35 -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
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
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
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
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
Jani Nikula
11a220a3c1 emacs: add support for stashing the thread id in show view
Add a prefix argument to notmuch-show-stash-message-id to stash thread
id instead of message id.
2012-12-09 19:09:46 -04:00
Mark Walters
776e21d953 emacs: show: refresh buffer did not remove overlays
Previously refreshing the notmuch show buffer did not remove overlays
which meant that if the user refreshed a message with images the
images would remain and then the new text was added after.

One might have guessed that erase-buffer would have removed them but
it seems not.  Thus force the removal of overlays with remove-overlays.
2012-12-06 17:13:23 -04:00
Mark Walters
5382eebcdc emacs: stash bugfix
Currently an attempt to stash a non-existent field (eg cc when not
present) throws an error. Catch this case and give the user a warning
message.
2012-12-06 17:12:47 -04:00
Jani Nikula
fb6edb0800 emacs: drop support for deprecated notmuch-folders
Remove notmuch-folders which has been deprecated since

commit a466921760
Author: Carl Worth <cworth@cworth.org>
Date:   Mon Apr 26 22:42:07 2010 -0700

    emacs: Rip out all of the notmuch-folder code.

This lets us simplify the notmuch-saved-searches code slightly.
2012-12-04 09:08:02 -04:00
Mark Walters
e504b56f24 emacs: Split the function notmuch-show-clean-address
This function is also used by pick so split it out in preperation for
moving to lib. In fact, pick and show want a slightly different
combination of name and email on return so make the separated function
return them as a pair, and let show or pick extract the combination
they want from that.
2012-12-01 08:15:28 -04:00
Tomi Ollila
59c994e770 emacs: less guessing of character set in messages
The macro with-current-notmuch-show-message executes command
`notmuch show --format=raw id:...` which just outputs the contents
of the mail file verbatim (into temporary buffer). In case e.g. utf-8
locale is used the temporary buffer has buffer-file-coding-system as
utf-8. In this case Emacs converts the data to multibyte format, guessing
that input is in utf-8.
However, the "raw" (MIME) message may contain octet data in any other
8bit format, and as no (MIME-)content spesific handling to the message
is done at this point, conversion to other formats may lose information.
By setting coding-system-for-read 'no-conversion drops the conversion part
and makes this handle input as notmuch-get-bodypart-internal() does.
This marks the broken test in previous change fixed.
2012-11-26 22:06:41 -04:00
Tomi Ollila
0a21fb98b2 notmuch-show.el: handle the case where icalendar-import-buffer returns nil
icalendar-import-buffer can fail by an error signal (which have been
witnessed) but according to its docstring it can also return nil
when failing (it returns t when succeeding).

Now that the error is caught by the caller of notmuch-show-inset-part-*
functions in case icalendar-import-buffer returns nil an explicit
error is signaled and unwind-protect takes care of deleting the
temporary file (just in case, it is usually not written to the fs yet).
2012-11-25 11:06:23 -04:00
Tomi Ollila
60b5bff53d notmuch-show.el: import calendar data with public function after CR removal
notmuch-get-bodypart-content provides raw data to its caller so
that it can be stored verbatim whenever needed. icalendar functions
expect Emacs to do EOL conversion for the data given to these. Therefore
it the CRLF -> LF conversion is now done explicitly.

The calls to private functions icalendar--convert-ical-to-diary and
icalendar--read-element are replaced with call to public function
icalendar-import-buffer.
2012-11-25 11:06:12 -04:00
Austin Clements
87a05adba3 emacs: Buttonize mid: links
This adds support for RFC 2392 mid: message ID links.
2012-11-15 18:13:27 -04:00
Austin Clements
580997252f emacs: Improve the regexp used to match id:'s in messages
This regexp agrees with Xapian query syntax much more closely, though
we specifically disallow various cases that would be confusing in the
context of an email body (e.g., punctuation at the end of an id: link
is not considered part of the id: link because it's probably part of
the surrounding text).

In particular, this handles id: links that are not surrounded by
quotes much better, which stash is much more likely to generate now
that we don't quote id's that don't need to be quoted.  It also
handles quoted id: links better.

We update the buttonization test to reflect the new pattern.
2012-11-15 18:11:07 -04:00
Tomi Ollila
7c6ac9fbae emacs/notmuch-show.el: handle bodypart insert error
When inserting of email bodypart failes, insert a failure message
to the buffer (and continue) instead of halting the insertion of
the rest of that email thread in question.
2012-11-07 08:04:12 -04:00
Mark Walters
42391b4056 emacs: Move the incremental JSON parser to notmuch-lib.el
This just moves the newly split out incremental json parser (together
with its state variables) to lib.

There should be no functional change.
2012-10-28 09:42:18 -03:00
Mark Walters
294667871a emacs: Rename incremental JSON internal variables
This patch just renames the internal variables for the JSON parser now
it is no longer specific to search mode. It also fixes up the white
space after the previous patch. There should be no functional changes.
2012-10-28 09:42:09 -03:00
Mark Walters
1dd76ab9b6 emacs: Split out the incremental json parser into its own function
This patch splits out the incremental json parser into its own
function.

It moves the main logic of the parser to happen inside the parse
buffer rather than inside the results buffer, but makes sure all
results and all errors are displayed in the results buffer.

It also changes the local parser variables from being buffer
local to the results buffer to being buffer local to the parse buffer,
and sets them up automatically so the caller does not need to.

Finally to keep the diff small this patch does not fix the whitespace,
nor complete the code movement (these are done in subsequent patches)
but it should contain all the functional changes.
2012-10-28 09:41:54 -03:00
Austin Clements
0a4663ff43 emacs: Escape tag queries suggested by tab completion 2012-10-27 09:34:34 -03:00
Austin Clements
b235850f9b emacs: Escape tag queries performed by hello 2012-10-27 09:34:14 -03:00
Austin Clements
1a4cb8fd29 emacs: Introduce generic boolean term escaping function
Currently, we only properly escape stashed id queries, but there are
other places where the Emacs UI constructs queries for boolean terms.
Since this escaping function is meant to be used in other places, it
avoids escaping strings that don't need escaping.
2012-10-27 09:33:55 -03:00
Pieter Praet
0db6c7b8be emacs: rename notmuch-show-toggle-headers' to notmuch-show-toggle-visibility-headers'
* emacs/notmuch-show.el

  (notmuch-show-toggle-headers):
    Rename to `notmuch-show-toggle-visibility-headers'.

  (notmuch-show-mode-map):
    Update "h" binding wrt renamed `notmuch-show-toggle-headers'.

  (notmuch-message-headers):
    Update docstring wrt renamed `notmuch-show-toggle-headers'.

  (notmuch-message-headers-visible):
    Update docstring wrt renamed `notmuch-show-toggle-headers'.
    Also fixed a small typo.

* test/emacs:

  Update subtest wrt renamed `notmuch-show-toggle-headers':
  - "notmuch-show: hide message headers (w/ notmuch-show-toggle-headers)"
2012-10-20 12:10:41 -03:00
Austin Clements
f227d63b27 emacs: Work around gnus-inhibit-images bug in mm-shr
Emacs 24's mm-shr HTML email renderer fails to load gnus-art before
referencing gnus-inhibit-images, resulting in a void-variable error
when notmuch attempts to render an HTML email with inline images.
This works around this bug by advising mm-shr to load gnus-art.

mm-shr is the only function outside of gnus-art itself that references
gnus-inhibit-images, so this workaround should be correct.  If this
ever changes, hopefully they will have fixed this bug upstream first.

This fixes the "Rendering HTML mail with images" test for Emacs 24.
2012-09-30 11:40:31 -03:00
Jani Nikula
1ecacab28f emacs: simplify point placement in notmuch-hello refresh
notmuch-hello (called also through notmuch-hello-update, bound to '='
by default) tries to find the widget under or following point before
refresh, and put the point back to the widget afterwards. The code has
grown quite complicated, and has at least the following issues:

1) All the individual section functions have to include code to
   support point placement. If there is no such support, point is
   dropped to the search box. Only saved searches and all tags
   sections support point placement.

2) Point placement is based on widget-value. If there are two widgets
   with the same widget-value (for example a saved search with the
   same name as a tag) the point is moved to the earlier one, even if
   point was on the later one.

3) When first entering notmuch-hello notmuch-hello-target is nil, and
   point is dropped to the search box.

Moving the point to the search box is annoying because the user is
required to move the point before being able to enter key bindings.

Simplify the code by removing all point placement based on widgets, as
it does not work properly, and trying to fix that would unnecessarily
complicate the code.

Save current line and column before refresh, and restore them
afterwards. Sometimes, if notmuch-show-empty-saved-searches is nil,
and the refresh adds or removes saved searches from the list, this has
the appearance of moving the point relative to the nearest
widgets. This is a much smaller and less frequent problem than the
ones listed above.
2012-09-30 11:20:08 -03:00
Damien Cassou
f164784d56 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>
2012-09-27 12:48:43 -03:00
Jani Nikula
8a22e28750 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).
2012-09-19 08:06:12 -03:00
Jani Nikula
1548751041 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.
2012-09-19 08:05:59 -03:00
Jani Nikula
d5dcfc714e 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.
2012-09-19 08:04:10 -03:00
Jani Nikula
2590d94bf0 emacs: use new tag change helper to mark messages as replied
Clarify documentation while at it.
2012-09-19 08:03:35 -03:00
Jani Nikula
5a48340bf1 emacs: fix notmuch-message-replied-tags defcustom type 2012-09-19 08:02:48 -03:00
Jani Nikula
1dc7e66ee7 emacs: add helper for tag change list manipulation
Add a helper to create (and optionally reverse) a list of tag changes.
2012-09-19 08:01:59 -03:00
Pieter Praet
c62126238b 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.
2012-09-01 23:08:52 -03:00
Mark Walters
7cd3cd3003 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.
2012-09-01 22:59:54 -03:00
Michal Nazarewicz
1f30f7d290 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).
2012-08-29 19:01:10 -03:00
Austin Clements
c3119c45e1 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.
2012-08-12 21:30:10 +02:00
Mark Walters
5811550cdd 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).
2012-08-12 21:27:45 +02:00
Austin Clements
07b5f97202 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.
2012-08-12 21:05:08 +02:00
Mark Walters
1efb6e7ae1 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.
2012-08-02 21:13:19 -03:00
Mark Walters
3fa00020ea 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.
2012-08-02 21:11:53 -03:00
Austin Clements
5d0883ea1b 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.
2012-07-24 09:23:53 -03:00