Commit graph

717 commits

Author SHA1 Message Date
David Bremner
487359e9cc emacs: remove hardcoded defaults values from docstrings
These functions refer to default values of variables, but it seems
less confusing and less likely to get out of date to just allow the
user to follow the help cross-reference links.
2013-06-02 20:43:02 -03:00
David Bremner
63782f4023 emacs: replace setq + let with let*
I found several places where a setq is immediately followed by a let
or a let*. This seems to be the pessimal combination, with the
implicit scope of the setq combined with the extra indentation of the let.
I combined these cases into a single let* which I think is easier to read.
2013-06-02 20:38:17 -03:00
David Bremner
9de0639126 emacs: replace (funcall 'foo ...) with (foo ...)
I can't see any benefit to the funcall, and it looks like the result
of cut-and-paste from some code that actually used a variable for the
function to call.
2013-06-02 11:37:22 -03:00
Austin Clements
89efd5717a emacs: Use streaming S-expr parser for search
In addition to being the Right Thing to do, this noticeably improves
the time taken to display the first page of search results, since it's
roughly an order of magnitude faster than the JSON parser.
Interestingly, it does *not* significantly improve the time to
completely fill a large search buffer because for large search
buffers, the cost of creating author invisibility overlays and
inserting text (which slows down with more overlays) dominates.
However, the time required to display the first page of results is
generally more important to the user experience.
2013-06-01 09:00:40 -03:00
Austin Clements
b89ffba301 emacs: Streaming S-expression parser
This provides the same interface as the streaming JSON parser, but
reads S-expressions incrementally.  The only difference is that the
`notmuch-sexp-parse-partial-list' helper does not handle interleaved
error messages (since we now have the ability to separate these out at
the invocation level), so it no longer takes an error function and
does not need to do the horrible resynchronization that the JSON
parser had to.

Some implementation improvements have been made over the JSON parser.
This uses a vector instead of a list for the parser data structure,
since this allows faster access to elements (and modern versions of
Emacs handle storage of small vectors efficiently).  Private functions
follow the "prefix--name" convention.  And the implementation is much
simpler overall because S-expressions are much easier to parse.
2013-06-01 08:56:25 -03:00
Austin Clements
08fde50bf3 emacs: Use async process helper for search
Previously, search started the async notmuch process directly.  Now,
it uses `notmuch-start-notmuch'.  This simplifies the process sentinel
a bit and means that we no longer have to worry about errors
interleaved with the JSON output.

We also update the tests of Emacs error handling, since the error
output is now separated from the search results buffer.
2013-06-01 08:56:16 -03:00
Austin Clements
a13b388243 emacs: Utilities to manage asynchronous notmuch processes
This provides a new notmuch-lib utility to start an asynchronous
notmuch process that handles redirecting of stderr and checking of the
exit status.  This is similar to `notmuch-call-notmuch-json', but for
asynchronous processes (and it leaves output processing to the
caller).
2013-06-01 08:53:36 -03:00
Austin Clements
edc740857f emacs: Bind MIME part commands to "." submap
Since the part commands are no longer tied to a button, but can be
applied with point anywhere within a part, bind the part commands
keymap to "." everywhere in the show buffer.  This lets you save or
view parts without having to navigate to the part button, and is
particularly useful for parts that have no button.

This removes the un-prefixed MIME part commands from the part button
keymap, but that's okay because those clashed in annoying ways with
show buffer bindings like "s" for search.  RET on part buttons is
unaffected, which is the most important part button binding.
2013-05-31 22:01:12 -03:00
Austin Clements
1546387d72 emacs: Simplify MIME part command implementation
This unifies the part button actions and the underlying part action
functions into single interactive command that simply applies to the
part containing point using the just-added part p-list text property
instead of button properties.  Since all part actions can be performed
by applying the appropriate mm function to an mm-handle, this patch
abstracts out the creation of mm handles, making the implementations
of the part commands trivial.  This also eliminates our special
handling for part save in favor of using the appropriate mm function.

This necessarily modifies the way we handle the default part button
action, but in a way that does not change the meaning of the
notmuch-show-part-button-default-action defcustom.

Since these commands are no longer specific to buttons, this patch
eliminates the extra metadata stored with each button.  This also
eliminates one rather special-purpose macro for a collection of
general purpose part handling utilities.
2013-05-31 22:01:02 -03:00
Austin Clements
04725cfbe5 emacs: Record part p-list in a text property
This is similar to what we already do with the message p-list, though
we apply the part's text property to the whole part's text, in
contrast with the message p-list, which is (rather obscurely) only
applied to the first character.
2013-05-31 22:00:52 -03:00
Austin Clements
6bbb91f8b6 emacs: Retain text properties when toggling buttons
Previously, we lost any text properties applied to part buttons or
wash buttons when they were toggled because `insert' directly copies
the text properties of the string being inserted.  Fix this by
capturing the properties applied to the button beforehand and
re-applying them after inserting the new text.
2013-05-31 22:00:44 -03:00
Austin Clements
e7ade21d56 emacs: Fix trimming regexp in notmuch-check-exit-status
For such a simple regexp, this was broken in a very complicated way.

The intent was to strip the newline (and potentially other whitespace)
off the end of the error string so there wasn't an extra newline in
the error signal.  However, the regexp was deeply dependent on the
active syntax table and the subtleties of $.  We didn't notice this
because all notmuch major modes put ?\n in the whitespace class, which
makes this behaved as intended: the "\\s " matches all newlines, but
by matching the newline character, causes the $ *not* to match
*except* where it matched the empty string at the very end of the
string, which was not followed by a newline.

However, if the syntax table declares ?\n to be non-whitespace
(lisp-mode declares it as endcomment, and is likely to be the mode
you're in when testing functions), then this regexp behaves completely
differently, matching trailing spaces at the end of every line within
the string.

The solution is to say what we mean for whitespace *and* to switch
from $ to \', which matches only the end of the string, rather than
the end of each line.  Both are necessary or this will strip away
interior newlines, which is not what we want.
2013-05-27 18:19:03 -03:00
Jani Nikula
8a164516ee emacs: add show view bindings to move to previous/next thread
We have most of the plumbing in place, add the bindings M-n and M-p.
2013-05-26 18:48:31 -03:00
Austin Clements
d4940d4716 emacs: Don't override mm-show-part in notmuch-show-view-part
Previously, notmuch-show-view-part overrode the function binding of
mm-show-part to redirect it to notmuch-show-save-part to get notmuch's
default file name handling in case mm-display-part decided to fall
back to saving the part.  In addition to being messy, this depended on
the now-deprecated dynamic binding behavior of flet.

This patch removes the mm-show-part override in favor of passing the
file name in to mm-show-part the way it expects, so we get its default
file name handling.  It's not clear why we didn't do this before;
mm-show-part has supported default file names since at least Emacs
23.1.
2013-05-26 18:45:10 -03:00
Austin Clements
68720286eb emacs: Compute build dependencies to fix byte compile issues
Previously, we simply byte compiled each Elisp source file
independently.  This is actually the wrong thing to do and can lead to
issues with macros and performance issues with substitutions because
1) when the byte compiler encounters a (require 'x) form, it will load
x.elc in preference to x.el, even if x.el is newer, and as a result
may load old macro and substitution definitions and 2) if we update a
macro or substitution definition in one file, we currently won't
re-compile other files that depend on the file containing the
definition.

This patch addresses these problems by computing make dependency rules
from the (require 'x) forms in the Elisp source files, which we inject
into make's dependency database.
2013-05-23 08:06:12 -03:00
Mark Walters
c8589e4eb8 emacs: show: handle inline patch fake parts at top level
The inline patch fake part handler also modifies the content-type so
handle this in notmuch-show-insert-bodypart too.
2013-05-20 15:01:59 -03:00
Mark Walters
b681aa8235 emacs:show: separate out handling of application/octet-stream
Currently mime parts are basically handled based on their mime-type
with the exception of application/octet-stream parts. Deal with these
parts at the top level (notmuch-show-insert-bodypart).

This is needed later in the series as we need to put in a part button
for each part (which means knowing its mime type) while deferring the
actual insertion of the part.
2013-05-20 15:01:48 -03:00
Austin Clements
e63aa66de8 emacs: Proper error string handling in search sentinel
Apparently Emacs provides a function to stringify errors properly.
Use this in the search sentinel where we have to do our own error
messaging, rather than assuming the first error argument will be the
descriptive string.
2013-05-18 07:50:11 -03:00
Mark Walters
14aef58b61 emacs: tag: fix compile warning
When compiling notmuch-tag.el there is a compile warning:
notmuch-tag.el:27:1:Warning: cl package required at runtime

Since we have decided to allow runtime use of cl we suppress this
warning by adding a tail comment to the file.
2013-05-15 22:23:58 -03:00
Tomi Ollila
ab30a846a4 emacs: removed code attempting to support emaces prior to version 23
The support for emacs version 22 has not worked at least since
September 2011 when I attempted to use it. I expanded the support in
id:yf6ippgtbn0.fsf@taco2.nixu.fi but that was not enough and then I
found it easier to switch to emacs 23.
In case one wants to resurrect emacs 22 (or earlier!) support, pick
the changes from the patch email referenced above.
2013-05-13 21:08:10 -03:00
Tomi Ollila
72dcfede51 emacs/notmuch-address.el: add notmuch-address-selection-function
Added a customizable variable notmuch-address-selection-function
and the function with the same name to provide a way for user to
change the function called to do address selection.

By default the functionality is exactly the same as it has been so
far; completing-read is called with the same parameters as before.

Setting equivalent lambda expression in place of using
notmuch-address-selection-function function is done as follows:

(setq notmuch-address-selection-function
   (lambda (prompt collection initial-input)
     (completing-read prompt collection nil nil initial-input)))

For example drop-in replacement with ido-completing-read can be done
easily as an one alternative to the default.
2013-05-13 21:05:29 -03:00
Jani Nikula
c75dff3c1a emacs: add kernel.org mail archive redirector
See http://lkml.kernel.org/
2013-05-05 13:56:52 -03:00
Tomi Ollila
8bee3c417c emacs: fixed (declare-function ...) definitions
Some (declare-function ...) definitions were drifted away from the
actual (defun ...)'s. To find the drifts and to verify changes
the following command line was used:

$ emacs --batch -L emacs --eval '(check-declare-directory "emacs")'
2013-04-30 06:13:18 -03:00
David Bremner
661dcf87ae Revert "emacs: functions to import sender or recipient into BBDB"
This reverts commit 238bf4cb09.

This commit was causing a build failure.

Bad me for not checking before pushing.
2013-04-06 16:11:02 -03:00
Daniel Bergey
238bf4cb09 emacs: functions to import sender or recipient into BBDB
From a show buffer, notmuch-bbdb/snarf-from imports the sender into
bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported
contacts are reported in the minibuffer / Messages buffer.

Both functions use the BBDB parser to recognize email address formats.
2013-04-06 08:36:54 -03:00
Mark Walters
c933e54227 emacs: hello: use batch count
This modifies notmuch hello to use the new count --batch
functionality. It should give exactly the same results as before but
under many conditions it should be much faster. In particular it is
much faster for remote use.

The code is a little ugly as it has to do some working out of the
query when asking the query and some when dealing with the result.
However, the code path is exactly the same in both local and remote
use.
2013-04-01 12:22:30 -04:00
David Bremner
abd4d6b92e emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string
This has two benefits: unified error handling, and avoiding tramp's
hooking into shell-command-string.

This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de
2013-04-01 07:58:20 -04:00
Damien Cassou
b714a808a6 emacs: possibility to customize the rendering of tags
This patch extracts the rendering of tags in notmuch-show to
the notmuch-tag file.

This file introduces a `notmuch-tag-formats' variable that associates
each tag to a particular format. This variable can be customized
thanks to the work of Austin Clements. For example,

  '(("unread" (propertize tag 'face '(:foreground "red")))
    ("flagged" (notmuch-tag-format-image tag "star.svg")))

associates a red foreground to the "unread" tag and a star picture to
the "flagged" tag.

Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
2013-03-25 11:38:49 -04:00
Damien Cassou
4ea80dd2a1 emacs: Add notmuch-combine-face-text-property-string
Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
2013-03-25 11:38:29 -04:00
Austin Clements
9cf89a3c04 emacs: Combine string faces and combine under existing faces
This improves notmuch-combine-face-text-property to support both
applying faces to strings and to support combining the given face
under existing faces, rather than over.
2013-03-25 11:36:47 -04:00
Austin Clements
3ddb4dc806 emacs: Handle all face forms when combining faces
Previously, notmuch-combine-face-text-property assumed that any
existing face properties of the modified text were already in face
list form.  This was true as long as it was the only function
manipulating faces (since it always produced a list form face), but if
anything else has manipulated the face, it was more likely to be
either a face name or a face plist.  It also didn't correctly handle
face lists as arguments, even though the doc string claimed it did.

This patch fixes notmuch-combine-face-text-property to handle all face
forms correctly by canonicalizing both the argument face and the
existing faces into list form.  This also means we can set the face to
a simpler non-list form if there's no existing face.
2013-03-25 11:35:22 -04:00
Mark Walters
3901bbca2e emacs: show: make buttons select window
Emacs has two button type objects: widgets (as used for saved searches
in notmuch-hello) and buttons as used by parts/citations and id links
in notmuch-show. These two behave subtly differently when clicked with
the mouse: widgets select the window clicked before running the
action, buttons do not.

This patch makes all of these behave the same: clicking always selects
the clicked window. It does this by defining a notmuch-button-type
supertype that the other notmuch buttons can inherit from. This
supertype binds the mouse-action to select the window and then
activate the button.
2013-02-18 20:13:19 -04:00
David Bremner
bdf7955cd5 emacs: don't use deprecated "notmuch search-tags" command
A followup patch will finally remove this command, so we need to stop
using it.
2013-01-22 21:18:56 -04:00
Mark Walters
f1a355febf emacs: show: w3m/invisibility workaround
There is a bug in the current notmuch code with w3m and invisible
parts. w3m sets a keymap, and if we have a hidden [text/html] point
at the start of the following line still gets this w3m keymap which
causes some strange effects. For example, RET gives an error "No URL
at Point" rather than hiding the message, <down> goes to the next link
rather than just down a line.

These keybinding are also inconvenient when the text/html part is
displayed so we ask w3m not to install a keymap.

This is only likely to be a problem for emacs 23 as shr is preferred
as html renderer on emacs 24 (although the user can set the renderer
to w3m even on emacs 24).

This solution was suggested by Tomi Ollila <tomi.ollila@iki.fi>
2013-01-14 19:46:13 -04:00
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
Austin Clements
90e741ef81 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.)
2012-07-24 09:23:13 -03:00
Austin Clements
e94b45112e 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.
2012-07-24 09:21:48 -03:00
Austin Clements
7ba5c86399 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.
2012-07-24 09:21:38 -03:00
Austin Clements
2a91f636d8 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.
2012-07-24 09:04:50 -03:00
Austin Clements
60ebc84945 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.
2012-07-24 09:04:38 -03:00
Austin Clements
ae30f33093 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.
2012-07-24 09:04:27 -03:00
Ingo Lohmar
bcdfff4f3a 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.
2012-07-24 09:01:26 -03:00
Austin Clements
9c5ea07cc6 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"
2012-07-12 17:39:36 -06:00
Austin Clements
889dda3731 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.
2012-07-12 17:39:28 -06:00
Austin Clements
1a5bcdf6c1 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.
2012-07-12 17:39:12 -06:00
Austin Clements
17525340a2 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.
2012-07-12 17:39:04 -06:00
Austin Clements
9b4361d0fe 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.
2012-07-12 17:38:54 -06:00
Austin Clements
e4818cc9c5 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.
2012-07-12 17:38:43 -06:00
Austin Clements
bbc74d98f5 emacs: Clean up notmuch-search-show-result
This simplifies the code and makes it no longer cubic in the number of
result fields.
2012-07-12 17:38:34 -06:00
Daniel Schoepe
88b922afdc emacs: Add configurable wrapping width for notmuch-wash-wrap-long-lines
This introduces a variable to control after how many characters a line
is wrapped by notmuch-wash-wrap-long-lines (still wrapping at the
window width if it is lower).
2012-06-29 22:38:52 -03:00
Mark Walters
e12645c869 emacs: make elide messages use notmuch-show for omitting messages.
Previously the elide messages code got the entire-thread from
notmuch-show.c and then threw away all non-matching messages. This
version calls notmuch-show.c without the --entire-thread flag so
it never receives the non-matching messages in the first place.

This makes it substantially faster.
2012-06-29 22:33:31 -03:00
Mark Walters
ae1940cedc emacs: add pipe attachment command
Allow the user to pipe the attachment somewhere. Bound to '|' on the
attachment button.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
2012-06-22 07:40:49 -03:00
Jesse Rosenthal
d094153a26 emacs: derive correct timestamp in FCC unique name
Previously, the timestamp at the beginning of the FCC unique maildir
name was derived incorrectly, thanks to an integer overflow. This
changes the derivation of timestamp to use a float, and so will get
the number correct at least until 2038. (It is still formatted with
"%d" so it will show up as an integer.) Should we need to change it in
the next 26 years to take the unix millenium into account, it will be
invisible to users.

This change is mostly a question of consistency, since the unique name
is arbitrary anyway. But since most people use timestamps, and that was
the original intention here as well, we might as well.

Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>
2012-06-22 07:39:21 -03:00
Jani Nikula
0ff57e75cf emacs: only strip "re:" in the beginning of subject
Fix notmuch-show-strip-re by matching "re:" only in the beginning of
the input string.
2012-06-07 23:28:17 -03:00
Austin Clements
44224b6259 emacs: Suppress warnings about using cl at runtime
It was decided in the thread starting at [0] that it is okay for
notmuch to use 'cl runtime functions.  However, by default, these
produce byte compiler warnings.  This suppresses those using
file-local variables.

[0] id:"m262g864dz.fsf@wal122.wireless-pennnet.upenn.edu"
2012-06-03 13:27:07 -03:00
Tomi Ollila
70ca3444c7 emacs: use 'gnus-decoded in notmuch-mm-display-part-inline ()
When mail message is read from emacs, the message structure
obtained may contain parts which have content included
(`text/plain` for example) and other parts where content is not
included (`text/html` for example).

In case content is included, the string is already available in
emacs' internal format and therefore mm-... functions should not
attempt to do further decoding for the data in temp buffer
provided for it.

Currently when reply buffer is created,
notmuch-mm-display-part-inline () is used to provided quoted reply
content. This change makes the mm-... functions called by it use
'gnus-decoded as charset whenever the content is already available.

File .../emacs-23.3/lisp/gnus/mm-uu.el mentions:
"`gnus-decoded' is a fake charset, which means no further decoding."
2012-05-23 22:29:32 -03:00
Dmitry Kurochkin
4997ec9571 emacs: fix custom queries section customization widget in notmuch-hello
The customization widget referred to a non-existing function
`notmuch-hello-insert-query-list'.  The patch changes it to the
correct one - `notmuch-hello-insert-searches'.  The relevant test is
fixed now.
2012-05-06 19:44:55 -03:00
Michal Sojka
e02c179c8f emacs: Do not pass stderr of notmuch reply to JSON parser
Sometimes, notmuch reply outputs something to stderr, for example:
"Failed to verify signed part: Cannot verify multipart/signed part:
unsupported signature protocol". When this happens, replying in emacs
fails, because emacs cannot parse the error message as JSON.

This patch causes emacs to ignore stderr when reading reply from
notmuch.
2012-05-06 08:49:38 -03:00
Thomas Jost
832fd1a7a6 emacs: Let the user choose where to compose new mails
Introduce a new defcustom notmuch-mua-compose-in that allows users to
specify where new mails are composed, either in the current window or
in a new window or frame.

Signed-off-by: Jameson Rollins <jrollins@finestructure.net>
2012-05-06 08:49:05 -03:00
Adam Wolfe Gordon
f6c170fabc emacs: Correctly quote non-text/plain parts in reply
Quote non-text parts nicely by displaying them with mm-display-part
before calling message-cite-original to quote them. HTML-only emails
can now be quoted correctly. We re-use some code from notmuch-show
(notmuch-show-mm-display-part-inline), which has been moved to
notmuch-lib.el.

Mark the test for this feature as not broken.
2012-05-06 08:48:11 -03:00
Jameson Graef Rollins
904a807088 emacs: eliminate search-tag-thread in favor of just search-tag
notmuch-search-tag-thread is now completely redundant with
notmuch-search-tag so we eliminate it to simplify the interface.
2012-04-29 17:43:03 -03:00
Jameson Graef Rollins
c1bcf5f8c0 emacs: modify show tag functions to use new notmuch-tag interface
The main change here is to modify argument parsing so as to not force
tag-changes to be a list, and to let notmuch-tag handle prompting the
user when required.  doc strings are also updated and cleaned up.
2012-04-29 17:42:43 -03:00
Jameson Graef Rollins
dba0e53ea8 emacs: modify search tag functions to use new notmuch-tag interface
The main change here is to modify argument parsing so as to not force
tag-changes to be a list, and to let notmuch-tag handle prompting the
user when required.  doc strings are also updated and cleaned up.
2012-04-29 17:41:57 -03:00
Jameson Graef Rollins
97aa3c0659 emacs: allow notmuch-tag to accept string inputs and prompt for tags
notmuch-tag is extended to accept various formats of the tag changes.
In particular, user prompting for tag changes is now incorporated
here, so it is common for modes.

The tag binary and the notmuch-{before,after}-tag-hooks are only
called if tag changes is non-nil.

In all cases tag-changes is returned as a list.
2012-04-29 17:41:35 -03:00
Jameson Graef Rollins
eb8feb1666 emacs: create notmuch-tag.el, and move appropriate functions from notmuch.el
Tagging functions are used in notmuch.el, notmuch-show.el, and
notmuch-message.el.  There are enough common functions for tagging
that it makes sense to put them all in their own library.

No code is modified, just moved around.
2012-04-29 17:39:37 -03:00
Jameson Graef Rollins
f5102f71ea emacs: fix archive thread/message function documentation.
This removes an inaccuracy in the thread archiving function, and adds
a clarification to the message archiving function.
2012-04-29 15:54:13 -03:00
David Edmondson
af59d61a4c emacs: Don't move to the next thread unless the cursor is at the end of the buffer.
When using the spacebar to scroll through a thread, hitting 'space'
when the bottom of the last message is visible should take the cursor
to the end of the buffer rather than immediately archiving the thread
and moving to the next thread.
2012-04-29 15:54:13 -03:00
Mark Walters
94250ac2c5 emacs-show: open excluded matches if no other matches
Currently emacs show does not open matching but excluded
messages. This is normally the desired behaviour but is probably not
ideal if only excluded messages match. This patch opens all the
matching (necessarily excluded) messages in this case and goes to the
first one.
2012-04-29 15:54:13 -03:00
Jameson Graef Rollins
cbba1d1ba9 emacs: do not modify subject in search or show
A previous patch [0] replaced blank subject lines with '[No Subject]'
in search and show mode.  Apparently this was needed to circumvent
some bug in the printing code, but there was no need for it search or
show, and it is definitely not desirable, so we undo it here (a revert
is no longer feasible).  We should not be modifying strings in the
original message without good reason, or without a clear indication
that we are doing so, neither of which apply in this case.  For
further discussion see [0].

[0] id:"1327918561-16245-3-git-send-email-dme@dme.org"
2012-04-28 23:30:59 -03:00
Austin Clements
9429141bb1 emacs: Put notmuch-hello-sections in custom group notmuch-hello 2012-04-24 23:39:19 -03:00
Austin Clements
ff53fb468e emacs: Put notmuch-print-mechanism in custom group notmuch-show 2012-04-24 23:25:51 -03:00
Jameson Graef Rollins
5073de34b4 emacs: modify help message for notmuch-search-line-faces to reflect preferred "deleted" tag name.
No functional change here.  The help message previously referred to
the "delete" tag, but "deleted" is now preferred, so hopefully this
will reduce any potential confusion.
2012-04-24 23:25:51 -03:00
Jameson Graef Rollins
6c84116091 emacs: have tag-completion return all tags for nil input
Previously the function would fail if the initial input was nil.  Now
it will return a list of all tags, which obviously makes much more
sense.
2012-04-12 15:34:49 -03:00
Jameson Graef Rollins
8225ff21ec emacs: include tags from excluded messages in tag tab completion
The new message exclude functionality will hide tags that only exist
on excluded messages.  However, one might very well want to manually
modify excluded tags.  This makes sure tags from excluded messages are
always available in tab completion.
2012-04-12 08:43:22 -03:00
Jameson Graef Rollins
1d4758e21f emacs: update call in tag-completion function
"search-tags" is deprecated, so use the more modern and supported
"search --output=tags".
2012-04-12 08:42:55 -03:00
Dmitry Kurochkin
6409a27b2c emacs: get rid of trailing spaces in notmuch-hello view
This patch removes trailing spaces in notmuch-hello view.

A side effect of this change is that tag/query buttons no longer
include a space at the end.  This means that pressing RET when the
point is at the first character after the tag/query button no longer
works (note that this is the standard behavior for buttons).  We may
change this behavior in the future (without adding trailing spaces
back) if people would find this change inconvenient.
2012-04-12 08:40:33 -03:00
Mark Walters
075d7df01e emacs: make show set --exclude=false
Show has to set --exclude=false to deal with cases where it is asked
to show a single excluded message. It uses JSON so it can easily pass
the exclude information to the user.
2012-04-07 23:06:31 -03:00
Jani Nikula
052000f85a emacs: do not modify the alist passed to notmuch-sort-saved-searches
Sort modifies its input as a side effect. Pass it a copy in
notmuch-sort-saved-searches to not modify the notmuch-saved-searches
alist.
2012-04-06 12:34:16 -03:00
Dmitry Kurochkin
1361dd37bc emacs: fix off-by-one error in notmuch-hello column alignment
Expected results for few tests are fixed, the relevant test is
unmarked broken.
2012-04-05 07:40:12 -03:00
Adam Wolfe Gordon
e4844fafec emacs: Fix the References header in reply
In the new reply code, the References header gets inserted by
message.el using a function called message-shorten-references. Unlike
all the other header-inserting functions, it doesn't put a newline
after the header, causing the next header to end up on the same
line. In our case, this header happened to be User-Agent, so it's hard
to notice. This is probably a bug in message.el, but we need to work
around it.

This fixes the problem by wrapping message-shorten-references in a
function that inserts a newline after if necessary. This should
protect against the message.el bug being fixed in the future.
2012-04-02 17:47:04 -03:00
Adam Wolfe Gordon
3737ca6e26 emacs: Fix two bugs in reply
Bug 1: Replying from alternate addresses
----------------------------------------

The reply code was inconsistent in its use of symbols and strings for
header names being passed to message.el functions. This caused the
From header to be lookup up incorrectly, causing an additional From
header to be added with the user's primary address instead of the
correct alternate address.

This is fixed by using symbols everywhere, i.e. never using strings
for header names when interacting with message.el.

This change also removes our use of `mail-header`, since we don't use
it anywhere else, and using assq makes it clear how the header lists
are expected to work.

Bug 2: Duplicate headers in emacs 23.2
--------------------------------------

The message.el code in emacs 23.2 assumes that header names will
always be passed as symbols, so our use of strings caused
problems. The symptom was that on 23.2 (and presumably on earlier
versions) the reply message would end up with two of some headers.

Converting everything to symbols also fixes this issue.
2012-04-02 17:45:27 -03:00
Austin Clements
839a80513a emacs: Fix mis-named argument to notmuch-get-bodypart-internal
Previously, this function took an argument called "message-id", even
though it was a general query, rather than a message ID.  This changes
it to "query".
2012-03-31 08:27:15 -03:00
Austin Clements
ee1180018e emacs: Escape all message ID queries
This adds a lib function to turn a message ID into a properly escaped
message ID query and uses this function wherever we previously
hand-constructed ID queries.  Wherever this new function is used,
documentation has been clarified to refer to "id: queries" instead of
"message IDs".

This fixes the broken test introduced by the previous patch.
2012-03-30 21:27:03 -03:00
Mark Walters
f57ef64302 emacs: content-type comparison should be case insensitive.
The function notmuch-match-content-type was comparing content types
case sensitively. Fix it so it tests case insensitively.

This fixes a bug where emacs would not include any body when replying
to a message with content-type TEXT/PLAIN.
2012-03-30 21:19:50 -03:00
Adam Wolfe Gordon
650123510c emacs: Use the new JSON reply format and message-cite-original
Use the new JSON reply format to create replies in emacs. Quote HTML
parts nicely by using mm-display-part to turn them into displayable
text, then quoting them with message-cite-original. This is very
useful for users who regularly receive HTML-only email.

Use message-mode's message-cite-original function to create the
quoted body for reply messages. In order to make this act like the
existing notmuch defaults, you will need to set the following in
your emacs configuration:

message-citation-line-format "On %a, %d %b %Y, %f wrote:"
message-citation-line-function 'message-insert-formatted-citation-line

The tests have been updated to reflect the (ugly) emacs default.
2012-03-19 22:03:23 -03:00
Adam Wolfe Gordon
950789f3c3 emacs: Factor out useful functions into notmuch-lib
Move a few functions related to handling multipart/alternative parts
into notmuch-lib.el, so they can be used by future reply code.
2012-03-19 21:59:24 -03:00
Austin Clements
0eaf4a21dd emacs: Fix search tab completion in terminals
In X, Emacs distinguishes the tab key, which produces a 'tab event;
from C-i, which produces a ?\t event.  However, in a terminal, these
are indistinguishable and only produce a ?\t event.  In order to
simplify things, Emacs automatically translates from 'tab to ?\t (see
"Function key translations" in M-x describe-bindings), so functions
only need to be bound to ?\t to work in all situations.

Previously, the search tab completion code usedq (kbd "<tab>"), which
produced the event sequence [tab], which only matched the 'tab event
and hence only worked in X.  This patch changes it to (kbd "TAB"),
which matches the general ?\t event and works in all situations.
2012-03-18 09:14:23 -03:00
David Bremner
c46764030d Merge branch 'release' 2012-03-10 21:46:26 -04:00
Jani Nikula
90f310b4fb emacs: fix MML quoting in replies
The reply MML quoting added in commit ae438cc unintentionally MML
quotes also the signature/encryption MML tags added via
message-setup-hook, causing the reply not to be signed/encrypted.

MML quote just the original message in the temp buffer before
inserting it to the message buffer, to not interfere with message mode
hooks or message construction in general.

See [1] and [2] for bug reports.

Thanks to Tim Bielawa <tbielawa@redhat.com> for testing.

[1] id:"87hay78x6l.fsf@wyzanski.jamesvasile.com"
[2] id:"1330812262-28272-1-git-send-email-tbielawa@redhat.com".

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-03-10 21:24:14 -04:00
Michal Sojka
4a0740920d emacs-hello: Do not calculate the count of the messages in hidden sections
The result is that hello screen shows much faster when some sections are
hidden.
2012-03-10 10:10:27 -04:00
David Bremner
ad6a6edb38 Merge branch 'release' 2012-03-03 11:56:36 -04:00
Mark Walters
1aa4abe7a1 emacs: notmuch.el ignore excluded matches
This is a small change to make notmuch.el ignore excluded matches.  In
the future it could do something better like add a button for
rerunning the search with the excludes (particularly if nothing
matches with the excludes) or having them invisible and allowing the
visibility to be toggled.
2012-03-02 08:38:27 -04:00
Mark Walters
119a42571e emacs: show: recognize the exclude flag.
Show mode will recognize the exclude flag by not opening excluding
messages by default, and will start at the first matching non-excluded
message. If there are no matching non-excluded messages it will go to
the first matching (necessarily excluded) message.
2012-03-02 08:37:50 -04:00
Tomi Ollila
2c077b1e4a Spelling fix
Retreive is spelled as r e t r i e v e .
2012-03-01 19:04:21 -04:00
Tomi Ollila
1fb5c77818 emacs: retain show buffer state after retrieving gpg key
After retrieving gpg key retain show buffer state like in
all other operations (i.e. no other calls to notmuch-show-refresh-view
provides optional reset-state argument).
Emacs MUA keeps current message under cursor instead of going first
open message(possibly marking it read).
2012-03-01 19:04:02 -04:00
Daniel Schoepe
3557acab64 emacs: User-defined sections in notmuch-hello
This patch makes the notmuch-hello screen fully customizable
by allowing the user to add and remove arbitrary sections. It
also provides some convenience functions for constructing sections,
e.g. showing the unread message count for each tag.

This is done by specifying a list of functions that will be run
when notmuch-hello is invoked.
2012-03-01 08:16:29 -04:00
Michal Sojka
8c095acb6c emacs: Clarify description of thread manipulating functions
It is not clear whether the term "thread" refers to the thread in the
database or to the thread currently shown in a buffer. Those two
meanings may refer to different sets of messages, e.g. when a new email
is added to the database while the buffer shows the state before the new
email arrived.

This patch replaces the term thread with the term current buffer, which
is hopefully less ambiguous.
2012-02-29 22:47:57 -04:00
Austin Clements
f89f3709d6 emacs: Fix out of date comment
The behavior of the header line in show-mode changed from showing the
subject of the first open message to showing the subject of the first
message in 4d77f18b.  Update a comment to reflect this.
2012-02-27 22:36:34 -04:00
Austin Clements
17a06ab990 emacs: Reverse the meaning of notmuch-show-refresh-view's argument
Consensus seems to be that people prefer that refreshing show buffers
retains state by default, rather than resetting it by default.  This
turns out to be the case in the code, as well.  In fact, there's even
a test for this that's been marked broken for several months, which
this patch finally gets to mark as fixed.
2012-02-25 10:35:22 -04:00
Austin Clements
4d77f18b1d emacs: When refreshing a show buffer, only mark read when resetting state
If we retain state while refreshing a show buffer, it should not mark
any messages read since it's not a navigation operation (it especially
shouldn't mark the first message matching the query read, which is
what it did previously).  If the user or caller requests that refresh
reset the state of the buffer, then we consider that a navigation
operation, so we do mark the message under point after the refresh
read.

This is implemented by moving responsibility for initial positioning
and read-marking out of notmuch-show-worker and into its caller.
Since notmuch-show-worker is now exclusively about building the show
buffer, we rename it to notmuch-show-build-buffer.
2012-02-25 10:35:08 -04:00
Pieter Praet
2f86290aaf emacs: add `notmuch-show-stash-mlarchive-link{, -and-go}'
* emacs/notmuch-show.el

  (notmuch-show-stash-mlarchive-link-alist):
    New defcustom of type `alist' (key = name, value = URI),
    containing Mailing List Archive URI's for searching by Message-Id.

  (notmuch-show-stash-mlarchive-link-default):
    New defcustom, default MLA to use when `notmuch-show-stash-mlarchive-link'
    received no user input whatsoever.  Available choices are generated using
    the contents of `notmuch-show-stash-mlarchive-link-alist'.

  (notmuch-show-stash-map):
    Added keybinds "l" and "L" for `notmuch-show-stash-mlarchive-link'
    respectively `notmuch-show-stash-mlarchive-link-and-go'.

  (notmuch-show-stash-mlarchive-link):
    New function, stashes a URI pointing to the current message at one
    of the MLAs configured in `notmuch-show-stash-mlarchive-link-alist'.
    Prompts user with `completing-read' if not provided with an MLA key.

  (notmuch-show-stash-mlarchive-link-and-go):
    New function, uses `notmuch-show-stash-mlarchive-link' to
    stash a URI, and then visits it using the browser configured
    in `browse-url-browser-function'.

Based on original work [1] by David Edmondson <dme@dme.org>.

[1] id:"1327397873-20596-1-git-send-email-dme@dme.org"
2012-02-25 10:34:27 -04:00
Pieter Praet
16ba777fd2 emacs: `notmuch-show-get-message-id': optionally return Message-Id sans prefix
* emacs/notmuch-show.el

  (notmuch-show-get-message-id):
    Add optional arg BARE.  When non-nil, return a Message-Id without
    quotes and prefix, thus obviating the need to strip them off again
    in various places.

  (notmuch-show-stash-message-id-stripped):
    Update wrt changes in `notmuch-show-get-message-id'.
2012-02-25 10:33:18 -04:00
Jani Nikula
cfdc9a472d emacs: support text/calendar mime type
Replace text/x-vcalendar with text/calendar, while maintaining support
and backwards compatibility for text/x-vcalendar.

Code by David Edmondson <dme@dme.org>
2012-02-25 08:55:47 -04:00
Austin Clements
311e8f6c45 emacs: Fix out-of-date declare-function
The names of the arguments to notmuch-show-refresh-view had gotten out
of sync between the declare-function and the real thing.
2012-02-20 23:05:17 -04:00
Michal Sojka
e4ceb19cc7 emacs: Fix display of highlighted line in notmuch-search
When notmuch-search-line-faces is used to set background color in search
results, the highlight of the current line is not always displayed
correctly. This patch fixes that by increasing the priority property of
the highlight overlay.
2012-02-17 08:03:26 -04:00
Dmitry Kurochkin
d8bff4b3af emacs: allow to set RETAIN-STATE for `notmuch-show-refresh-view' interactively
The notmuch-show view refresh function (`notmuch-show-refresh-view',
bound to "=") accepts an optional RETAIN-STATE argument.  The patch
allows to set this argument interactively by using "C-u =".
2012-02-14 23:42:28 -04:00
Dmitry Kurochkin
a5674c2158 emacs: cleanup and simplify `notmuch-show-archive-thread' and related functions
Recent changes in notmuch-show tagging introduced some code
duplication.  The patch cleanups and simplifies
`notmuch-show-archive-thread' function by using
`notmuch-show-tag-all', no longer used function are removed.  After
the change, `notmuch-show-archive-thread' function becomes symmetric
with `notmuch-show-archive-message'.

A side effect of these changes is that `notmuch-show-archive-thread'
no longer calls "notmuch tag" for each message in the thread.
2012-02-12 14:01:28 -04:00
David Edmondson
668b66ec85 emacs: A prefix argument to `notmuch-show' should invert the matching message behaviour.
Allow the user to open a thread with inverted
`notmuch-show-only-matching-messages' behaviour using a prefix
argument.
2012-02-12 11:58:21 -05:00
David Edmondson
866ce8b132 emacs: Add `notmuch-show-only-matching-messages'.
Allow the user to choose that only matching messages are shown by
default.
2012-02-12 11:58:21 -05:00
David Edmondson
d268422884 emacs: Check that the parent buffer is alive before using it. 2012-02-12 11:58:21 -05:00
David Edmondson
48766fca71 emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view'.
With an argument, record and reply the state of the buffer during
`notmuch-show-refresh-view'.

In this context, "state" is defined as:
 - the open/closed state of each message,
 - the current message.

Traditional use of refresh with the = key does not retain the
state. The recently introduced toggle commands ($, !, < and >) do
retain the state.
2012-02-12 11:58:21 -05:00
David Edmondson
7bcab5d645 emacs: Add a binding (t) to toggle the truncation of long lines. 2012-02-12 11:58:21 -05:00
David Edmondson
c205e8ffae emacs: Allow the indentation of content to be toggled.
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with '<'.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
2012-02-12 11:58:21 -05:00
David Edmondson
44a544ede0 emacs: Allow `notmuch-show-mode' to display only matching messages.
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
2012-02-12 11:58:21 -05:00
David Edmondson
19ec74c50e emacs: Rework crypto switch toggle.
Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
2012-02-12 11:58:21 -05:00
David Edmondson
5d021e52e2 emacs: Ensure that gnupg output goes at the end of the buffer.
When showing the user some details of gnupg output, ensure that those
details are shown at the end of the gnupg status buffer
("*notmuch-crypto-gpg-out*"), otherwise it can end up mixed up with
earlier output.
2012-02-12 11:58:20 -05:00
Jani Nikula
e06943f85e emacs: add default value to notmuch-search-line-faces
Add default value to notmuch-search-line-faces to show "unread"
messages in bold, and "flagged" messages in blue, to have some visual
indication of important messages in search results. This should be
helpful for new users.

"unread" tag is quite obvious, and handled specially both in the lib
and emacs ui. "flagged" is synced to maildir F flag in the lib. If one
syncs the maildir to IMAP, this also translates to corresponding IMAP
flag. (This is "starred" in GMail and Android.)

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-02-12 11:58:20 -05:00
Jani Nikula
d2ef4edc54 emacs: make show view a/A/x/X key bindings more consistent
Modify the show view key bindings as follows to make them more
consistent:

'a' = Archive current message, then move to next message, or show next
thread from search if at the last message in thread.

'A' = Archive each message in thread, then show next thread from
search.

'x' = Archive current message, then move to next message, or exit back
to search results if at the last message in thread.

'X' = Archive each message in thread, then exit back to search
results.

The changes make the key bindings more consistent in two ways:
1) 'a'/'A' both advance to the next thread like 'a' used to.
2) 'x' operates on messages and 'X' on threads like 'a'/'A'.
2012-02-08 13:22:00 -04:00
Dmitry Kurochkin
6e59a5630f emacs: s/tags/tag-changes/ for arguments of tagging functions
This makes the argument names more consistent and clear.  The
following functions changed: `notmuch-tag',
`notmuch-search-tag-thread', `notmuch-search-tag-region' and
`notmuch-search-tag-all'.
2012-02-08 11:22:44 -04:00
Dmitry Kurochkin
9d8fa2acac emacs: accept empty tag list in `notmuch-tag'
Since `notmuch-tag' is a non-interactive function and hence is meant
to be invoked programmatically, it should accept zero tags.  Also, the
tagging operations (bound to "*", "+", "-") would accept empty input
without an error.
2012-02-08 11:21:52 -04:00
Dmitry Kurochkin
26fce4ae60 emacs: relax tag syntax check in `notmuch-tag' function
The tag syntax check in `notmuch-tag' function was too strict and did
not allow nmbug tags with "::".  Since the check is done for all
tagging operations in Emacs UI, this basically means that no nmbug
tags can be changed.  The patch relaxes the tag syntax check to allow
any tag names that do not include whitespace characters.
2012-02-08 11:19:23 -04:00
Dmitry Kurochkin
904eafaefc emacs: separate history for operations which accept single and multiple tags
Some tag-related operations accept a single tag without prefix
(`notmuch-select-tag-with-completion'), others accept multiple tags
prefixed with '+' or '-' (`notmuch-read-tag-changes').  Before the
change, both functions used a single default minibuffer history.  This
is inconvenient because you have to skip options with incompatible
format when going through the history.  The patch adds separate
history lists for the two functions.  Note that functions that accept
the same input format (e.g. "+", "-", "*") share the history list as
before.
2012-02-08 11:18:37 -04:00
Dmitry Kurochkin
26d5b0efe4 emacs: add "*" binding for notmuch-show view
The patch adds `notmuch-show-tag-all' function bound to "*" in
notmuch-show view.  The function is similar to the
`notmuch-search-tag-all' function for the notmuch-search view: it
changes tags for all messages in the current thread.
2012-02-08 11:17:45 -04:00
Dmitry Kurochkin
f643f1bac0 emacs: rename notmuch-search-operate-all' to notmuch-search-tag-all'
`Notmuch-search-tag-all' is more clear and consistent with other
tagging function names.
2012-02-08 11:16:04 -04:00
Dmitry Kurochkin
389ddf0f12 emacs: make "+" and "-" tagging operations in notmuch-show more flexible
Before the change, "+" and "-" tagging operations in notmuch-show view
accepted only a single tag.  The patch makes them use the recently
added `notmuch-read-tag-changes' function, which allows to enter
multiple tags with "+" and "-" prefixes.  So after the change, "+" and
"-" bindings in notmuch-show view allow to both add and remove
multiple tags.  The only difference between "+" and "-" is the
minibuffer initial input ("+" and "-" respectively).
2012-02-08 11:13:53 -04:00
Dmitry Kurochkin
2beaefa2ec emacs: make "+" and "-" tagging operations in notmuch-search more flexible
Before the change, "+" and "-" tagging operations in notmuch-search
view accepted only a single tag.  The patch makes them use the
recently added `notmuch-read-tag-changes' function (renamed
`notmuch-select-tags-with-completion'), which allows to enter multiple
tags with "+" and "-" prefixes.  So after the change, "+" and "-"
bindings in notmuch-search view allow to both add and remove multiple
tags.  The only difference between "+" and "-" is the minibuffer
initial input ("+" and "-" respectively).
2012-02-08 11:08:43 -04:00
Dmitry Kurochkin
b3eafaf725 emacs: remove text properties from `notmuch-search-get-tags' result 2012-02-08 11:08:22 -04:00
Dmitry Kurochkin
0adf05f578 emacs: move tag format validation to `notmuch-tag' function
Before the change, tag format validation was done in
`notmuch-search-operate-all' function only.  The patch moves it down
to `notmuch-tag', so that all users of that function get input
validation.
2012-02-08 11:08:09 -04:00
David Bremner
2c6710e3ba emacs: use mark instead of point-max in MML quoting.
As Aaron explains in id:"m2vco72tf3.fsf@wal122.wireless-pennnet.upenn.edu"

  Using point-max would include the signature in the quoting as well.
  It would probably be fairly odd to want to put an MML tag in one’s
  signature, but that doesn’t mean that we should break that usage.

We had to use point-max in the 0.11.1 bug-fix release, because the
mark functionality was added post 0.11.
2012-02-04 13:40:24 -05:00
David Bremner
d43f6c00b3 Merge commit '0.11.1'
Conflicts:
	NEWS
	bindings/python/notmuch/database.py
	bindings/python/notmuch/message.py
	notmuch.1

NEWS merged by hand, others taken from master.
2012-02-04 12:01:46 -05:00
Dmitry Kurochkin
8281430558 emacs: fix `notmuch-wash-region-to-button' to work at beginning of buffer
`Notmuch-wash-region-to-button' is the function that creates hidden
regions with buttons for signatures, citations and original messages.
Before the change, it did not work correctly if the to-be-hidden
region started at the beginning of a message: the visibility toggle
button was hidden as well.  The patch fixes this.  There are two parts
in the fix:

* Use `insert-before-markers' instead of `insert' for creating the
  button, so that it does not get added to the hidden overlay.

* Stop using PREFIX argument for adding a newline before the button.
  The newline should not be added before a button at the beginning of
  buffer.

The corresponding test is fixed now.
2012-02-04 07:33:18 -05:00
David Edmondson
d8d7387881 emacs: Move the blank line from the bottom of the headers to the top of the body.
The blank line doesn't really change position, but is now considered
to be part of the body rather than part of the headers. This means
that it is visible when the body is visible rather than when the
headers are visible.
2012-02-03 21:28:45 -04:00
David Edmondson
32d7b3aabd emacs: More address cleaning.
Remove outer single-quotes from the mailbox part. Allow for multiple
sets of nested single and double quotes.

Add more tests.
2012-02-03 21:24:48 -04:00
David Edmondson
6bd3d8af54 emacs: Prefer '[No Subject]' to blank subjects. 2012-02-03 21:20:15 -04:00
David Edmondson
e516a712bb emacs: Stop the `truncate-string-to-width' madness.
There's no need to call `truncate-string-to-width' twice in this code
path.
2012-02-03 21:19:00 -04:00
Aaron Ecay
ae438ccd8c emacs: quote MML tags in replies
Emacs message-mode uses certain text strings to indicate how to attach
files to outgoing mail.  If these are present in the text of an email,
and a user is tricked into replying to the message, the user’s files
could be exposed.

Edited-by: Pieter Praet <pieter@praet.org>:  Rebased to release branch.
2012-02-03 08:26:41 -04:00
Pieter Praet
2dcd1e7234 emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."
Less code, same results, without sacrificing readability.
2012-02-01 21:29:17 -04:00
Jameson Graef Rollins
7cd907b69c emacs: fix show-previous-message doc string 2012-01-30 23:25:01 -04:00
Jameson Graef Rollins
4a5281b888 emacs: modify the default show-mode key bindings for archiving
This changes the default key bindings for the 'a' key in notmuch-show
mode.  Instead of archiving the entire thread, it now just archives
the current message, and then advance to the next open message
(archive-message-then-next).  'A' is now bound to the previous
archive-thread-then-next function.
2012-01-30 23:24:36 -04:00
Jameson Graef Rollins
0417c22d11 emacs: use pop-at-end functionality in show-archive-message-then-next function
This provides a smoother message processing flow by reducing the
number of key presses needed for these common operations.
2012-01-30 23:24:02 -04:00
Jameson Graef Rollins
cdb51decdd emacs: add option to show-next-{, open-}message functions to pop out to parent buffer if at end
This will allow for keybindings that achieve a smoother message
processing flow by reducing the number of key presses needed for most
common operations.
2012-01-30 23:23:49 -04:00
Jameson Graef Rollins
436c98a973 emacs: add message archiving functions
This adds two new message archiving functions that parallel the thread
archiving functions: notmuch-show-archive-message{,-then-next}.  The
former also takes a prefix argument to unarchive the message (ie. put
back in inbox).
2012-01-30 23:21:16 -04:00
Jameson Graef Rollins
be05158b69 emacs: break out thread navigation from notmuch-show-archive-thread
This function is now just for archiving the current thread.  A new
function is created to archive-then-next.  The 'a' key binding is
updated accordingly.

This will allow people to bind to the simple thread archiving function
without the extra navigation.  The archive-thread function now also
takes a prefix to unarchive the current thread (ie. put the whole
thread back in the inbox).
2012-01-30 23:21:01 -04:00
Jameson Graef Rollins
047792102c emacs: break up notmuch-show-archive-thread-internal into two more generally useful functions
Break up notmuch-show-archive-thread-internal into two new functions:

notmuch-show-tag-thread-internal: applies a tag to all messages in
thread.  If option remove flag is t, tags will be removed instead of
added.

notmuch-show-next-thread: moves to the next thread in the search
result.  If given a prefix, will show the next result, otherwise will
just move to it in the search view.

Two new interactive functions, notmuch-show-{add,remove}-tag-thread,
are also added.  Together, these provide a better suit of thread
tagging and navigation tools.

The higher level thread archiving functions are modified to use these
new function.
2012-01-30 23:19:10 -04:00
Jameson Graef Rollins
9b7e0dcb9a emacs: use search-next-thread to move to next thread in show mode
We should always use the dedicated search mode navigation functions,
in case navigation mechanics change down the line.
2012-01-30 23:18:22 -04:00
David Edmondson
6f388fa711 emacs: Don't mark messages as "unsaved" when printing.
`ps-print-buffer' notes that a buffer is unsaved unless
`buffer-modified-p' returns `nil', so ensure that it does.
2012-01-27 08:01:59 -04:00
David Edmondson
cd03f21447 emacs: Another special case for `notmuch-show-clean-address'.
Remove backslashes.
2012-01-27 07:59:40 -04:00
David Edmondson
cbc4876a33 emacs: Avoid mail-header-parse-address' in notmuch-show-clean-address'.
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.

Mark the corresponding test as no longer broken.

Minor whitespace cleanup.
2012-01-27 07:58:58 -04:00
David Edmondson
3f003a3ae0 emacs: Re-enable line wrapping in `notmuch-show-mode'.
Turn on `visual-line-mode' via a hook, so that those who so choose can
avoid it.
2012-01-27 07:48:06 -04:00
Dmitry Kurochkin
58d714e5ce emacs: `notmuch-search-operate-all' code cleanup, no functional changes 2012-01-27 07:46:05 -04:00
Dmitry Kurochkin
f764bbd544 emacs: add completion to "tag all" operation ("*" binding)
The patch adds <tab> completion to "tag all" operation bound to "*"
(`notmuch-search-operate-all' function).
2012-01-27 07:45:40 -04:00
Dmitry Kurochkin
d0a048f856 emacs: polish notmuch-hello help text
Make `=' binding description consistent with others.
2012-01-26 08:20:40 -04:00
David Edmondson
76f5da775e emacs: Fix a notmuch-print.el compiler warning.
`notmuch-show-get-prop' should be declared.
2012-01-26 08:13:05 -04:00
David Edmondson
63342a3c06 emacs: Make the part content available to `mm-inlinable-p'.
The `mm-inlinable-p' function works better if it has access to the
data of the relevant part, so load that content before calling it.

Don't load the content for parts that the user has indicated no desire
to inline.

This fixes the display of attached image/jpeg parts, for example.
2012-01-26 08:10:55 -04:00
Dmitry Kurochkin
e6e10b82c9 emacs: bind "s" to `notmuch-hello-search' in notmuch-hello buffer
`notmuch-hello-search' uses `notmuch-search' function but refreshes
notmuch-hello buffer when the search buffer is closed.
2012-01-25 08:33:48 -04:00
Dmitry Kurochkin
bc267b70b0 emacs: use a single history for all searches
There are two ways to do search in Emacs UI: search widget in
notmuch-hello buffer and `notmuch-search' function bound to "s".
Before the change, these search mechanisms used different history
lists.  The patch makes notmuch-hello search use the same history list
as `notmuch-search' function.
2012-01-25 08:33:39 -04:00
Dmitry Kurochkin
02d8815922 emacs: bind "s" to `notmuch-search' in notmuch-hello buffer
Before the change, "s" in notmuch-hello buffer would jump to the
search box.  The patch changes the binding to `notmuch-search' which
is consistent with all other notmuch buffers.
2012-01-25 08:33:27 -04:00
Jameson Graef Rollins
4ba787bca2 emacs: have notmuch-search-archive-thread use -next-thread function
Use this standard function, to keep thread navigation in one place.
2012-01-25 07:17:12 -04:00
Tomi Ollila
37dec7d7b3 emacs/*.el: changed one-char comment prefix ';' to two; ';;'
In order for emacs (indent-region) to (re)indent emacs lisp
properly there needs to be at least 2 comment characters (;;).
2012-01-21 14:06:17 -04:00
Mark Walters
85665a2955 Make buttons for attachments allow viewing as well as saving
Define a keymap for attachment buttons to allow multiple actions.
Define 3 possible actions:
    save attachment: exactly as currently,
    view attachment: uses mailcap entry,
    view attachment with user chosen program

Keymap on a button is: s for save, v for view and o for view with
other program. Default (i.e. enter or mouse button) is save but this
is configurable in notmuch customize.

One implementation detail: the view attachment function forces all
attachments to be "displayed" using mailcap even if emacs could
display them itself. Thus, for example, text/html appears in a browser
and text/plain asks whether to save (on a standard debian setup)
2012-01-21 08:55:48 -04:00
Dmitry Kurochkin
d3aa6848da emacs: add invisible dot instead of space at the end of notmuch-hello search box
This makes `show-trailing-whitespace' happy, i.e. it does not mark the
whole search box line as trailing spaces.

Since the dot is invisible, this change makes no visible difference
for `notmuch-hello'.

Edited-by: Pieter Praet <pieter@praet.org> to fix the tests.
2012-01-21 08:50:48 -04:00
Pieter Praet
3a602dc27a emacs: invert relation between 'notmuch-send and 'message customization groups
'message contains options relevant to 'notmuch-send, not the other way around.

Thanks to Austin for suggesting `custom-add-to-group'.
  id:"20120118184408.GD16740@mit.edu"
2012-01-21 08:43:47 -04:00
David Edmondson
05f4904616 emacs: Improved printing support.
Add various functions to print notmuch messages and tie them together
with a simple frontend.

Add a binding ('#') in `notmuch-show-mode' to print the current
message.

one trailing space removed by db.
2012-01-21 08:38:38 -04:00
David Edmondson
d2a1140c44 emacs: Truncate lines and do not enable visual-line-mode in notmuch-show buffers.
Enable the truncation of lines in `notmuch-show-mode' to avoid visual
noise caused by the wrapping of the header lines.

Don't enable `visual-line-mode' because it disables line truncation.

The benefits of `visual-line-mode' were that it wrapped long lines
in received messages. With `notmuch-wash-wrap-long-lines' now default
behaviour, this is no longer required.
2012-01-21 08:22:27 -04:00
Pieter Praet
046f5dded2 emacs: globally replace non-branching "(if (not ..." with "(unless ..."
Less code, same results, without sacrificing readability.
2012-01-21 08:17:56 -04:00
Pieter Praet
643ce61c1b emacs: logically group def{custom,face}s
To allow for expansion whilst keeping everything tidy and organized,
move all defcustom/defface variables to the following subgroups,
defined in notmuch-lib.el:

- Hello
- Search
- Show
- Send
- Crypto
- Hooks
- External Commands
- Appearance

As an added benefit, defcustom keyword args are now consistently
ordered as they appear @ defcustom's docstring (OCD much?).

Proper defgroup docstrings and various other improvements
by courtesy of Austin Clements.
2012-01-19 09:27:02 -04:00
David Bremner
efa5d6cb32 Revert "emacs: Don't attempt to colour tags in `notmuch-show-mode'."
This reverts commit 4b256ff557.

According to id:"87aa5nlwwg.fsf@praet.org" and followup messages, the
assumptions of the patch seem not to hold in emacs 23.
2012-01-17 08:01:48 -04:00
David Edmondson
ef5c1d73f8 emacs: Cycle through notmuch buffers rather than jumping to the last.
As suggested by j4ni in #notmuch, rename
`notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
have it behave accordingly.

Consider `message-mode' buffers to be of interest.
2012-01-15 22:32:14 -04:00
David Edmondson
4b256ff557 emacs: Don't attempt to colour tags in `notmuch-show-mode'.
The tags were coloured using text properties. Unfortunately that text
(the header line) also has an overlay, which overrides the text
properties. There's not point in applying text properties that will
never be seen.
2012-01-15 22:31:00 -04:00
Jani Nikula
f02b475fa7 emacs: bind 'r' to reply-to-sender and 'R' to reply-to-all
Change the default reply key bindings, making 'r' reply-to-sender and 'R'
reply-to-all.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-14 11:11:06 -04:00
Jani Nikula
dc0919c912 emacs: add support for replying just to the sender
Provide reply to sender counterparts to the search and show reply
functions. Add key binding 'R' to reply to sender, while keeping 'r' as
reply to all, both in search and show views.

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-01-14 11:10:41 -04:00
David Edmondson
647c250989 notmuch/emacs: Observe the charset of text/html parts, where known.
Add the charset of text/html parts to the JSON output of 'notmuch
-show' when it is known. Observe the encoding when rendering such
parts in emacs.
2012-01-13 21:45:21 -04:00
David Bremner
0bbfc5ce8b Merge branch 'release'
Conflicts:
	notmuch-reply.c
	notmuch.1
2012-01-13 20:52:01 -04:00
David Edmondson
38546e4acb emacs: Improve `notmuch-hello' display on ttys.
Inserting spaces to pad out columns is good, except when the padding
makes the line wider than the window. This looks particularly bad on a
tty where there is no fringe.

Hence, avoid padding the last column on each row.
2012-01-12 22:33:29 -04:00
David Edmondson
03146f2013 emacs: Mark the quoted region during reply.
Mark the quoted region of text during a reply, making it easy for the
user to delete it quickly.
2012-01-10 06:31:02 -04:00
David Edmondson
a74ec0edd6 emacs: Better handling of inherited keymaps for `nomuch-help'.
`notmuch-hello-mode' inherits the keymap for widgets, which confused
`notmuch-substitute-command-keys'. Fix the confusion.

Simplify `notmuch-substitute-command-keys' a little to make it easier
to read.
2012-01-09 22:33:19 -04:00
David Edmondson
dd41a07bbd emacs: Don't signal an error when reaching the end of the search results.
With the default configuration ('space' moves through the messages
matching the search and back to the results index at the end) it's
unnecessary to signal an error when the last message has been read, as
this is the common case.

Moreover, it's very annoying when `debug-on-error' is t.
2012-01-09 06:40:24 -04:00
Jameson Graef Rollins
74bced62b4 emacs: fix notmuch-show-indent-messages-width customization variable name
The name was originally notmuch-indent-messages-width, which is
inconsistent with our variable naming convention.
2012-01-05 17:48:46 -04:00
David Edmondson
641399fa2c emacs: Enable more text/plain hook functions by default.
Users are missing out on various functions which usefully improve the
display of text/plain message parts because they are not enabled by
default. Enable a useful set.

`notmuch-wash-convert-inline-patch-to-part' is _not_ enabled by
default as it is based on a heuristic.
2011-12-28 13:28:54 -04:00
Jani Nikula
f893d31762 emacs: create patch filename from subject for inline patch fake parts
Use the mail subject line for creating a descriptive filename for the wash
generated inline patch fake parts. The names are similar to the ones
created by 'git format-patch'.

If the user has notmuch-wash-convert-inline-patch-to-part hook enabled in
notmuch-show-insert-text/plain-hook, this will change the old default
filename of "inline patch" in fake parts:

[ inline patch: inline patch (as text/x-diff) ]

into, for example:

[ 0002-emacs-create-patch-filename-from-subject-for-inline.patch: inline patch (as text/x-diff) ]

which is typically the same filename the sender had if he was using 'git
format-patch' and 'git send-email'.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-28 08:18:27 -04:00
Jani Nikula
d5d39a92f1 emacs: add inline patch fake parts through a special handler
Add wash generated inline patch fake parts through a special
"inline-patch-fake-part" handler to distinguish them from real MIME
parts. The fake parts are described as "inline patch (as text/x-diff)".

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-28 08:18:13 -04:00
Dmitry Kurochkin
c44a0edadc emacs: fix docstring for `notmuch-search-line-faces'.
Examples in documentation for `notmuch-search-line-faces' had an extra
quote, e.g.:

  '(\"unread\" . '(:foreground \"green\"))

Which resulted in values like:

  (\"unread\" quote (:foreground \"green\"))

And tons of "Invalid face reference: quote" errors in the messages
buffer.
2011-12-24 15:34:07 -04:00
Jameson Graef Rollins
c0d694035d emacs: call notmuch-show instead of notmuch-search in buttonised id: links
Since message-ids necessarily match just a single message, there's no
reason to do a search for the id before viewing the actual message;
the search just becomes an extra screen to click through.  Clicking on
an id: links now just jumps straight to the message itself.
2011-12-24 15:32:01 -04:00
Aaron Ecay
8392a7cc54 emacs: fix off-by-one bug in notmuch-show-archive
Text properties change between characters; prev-s-c-property-change
returns the position after the change.  Thus, it is still inside the
invisible region.
2011-12-23 08:29:04 -04:00
Dmitry Kurochkin
49af79cd2a emacs: put the last search on top of recent searches in notmuch-hello
Notmuch-hello stores a list of recent searches.  Before the change, if
a search from this list is repeated, the recent search list is not
changed.  The patch makes repeated recent searches move to the head of
the list.  I.e. the last search is always on top of the recent search
list, which is what one would expect from a history list.
2011-12-22 07:41:02 -04:00
Thomas Jost
7edf9e2765 emacs: Change the default thousands separator to a space
This had been discussed and decided on IRC.

Rationale:
  Therefore the space is recommended in the SI/ISO 31-0 standard, and the
  International Bureau of Weights and Measures states that "for numbers with
  many digits the digits may be divided into groups of three by a thin space, in
  order to facilitate reading. Neither dots nor commas are inserted in the
  spaces between groups of three".

(http://en.wikipedia.org/wiki/Decimal_separator#Digit_grouping)
2011-12-22 06:56:41 -04:00
Thomas Jost
6dd482a16d emacs: rename notmuch-decimal-separator to notmuch-hello-thousands-separator
In 123,456.78, "." is the decimal separator, but "," is the thousands separator.
2011-12-22 06:56:26 -04:00
David Edmondson
0fc424a1f0 emacs: Don't prompt the user to choose from zero matching addresses.
If the address matching function generates no matches, don't prompt
the user to choose between them (!). Instead, generate a message to
report that there were no matches.
2011-12-22 06:54:56 -04:00
Jani Nikula
d4c598dc9e emacs: Fix notmuch-mua-user-agent defcustom
The :options keyword is not meaningful for function type. Also, it was not
possible to enter nil value, contrary to the notmuch-mua-user-agent
defcustom documentation. Specify the alternatives using choice type, taking
nil into account.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-22 06:54:29 -04:00
Jani Nikula
2f7f259d62 emacs: Fix notmuch-hello-tag-list-make-query defcustom
It was not possible to define custom filters or filter functions because
the types were const. Remove const to allow editing.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-22 06:54:10 -04:00
Thomas Jost
4e2fe89520 emacs: add notmuch-hello-refresh-hook
This hook is called every time a notmuch-hello buffer is updated.
2011-12-21 07:52:10 -04:00
Aaron Ecay
e3260d0253 Don't quote lambda forms
This generates byte-compiler warnings on (at least) current trunk
versions of Emacs.  The quote is not necessary; lambda forms are
self-quoting.
2011-12-21 07:27:38 -04:00
David Edmondson
4a2a271878 emacs: Add `notmuch-jump-to-recent-buffer'.
From a Carl Worth idea: add a function which will select the most
recently used notmuch buffer (search, show or hello). If no recent
buffer is found, run `notmuch'.

It is expected that the user will global bind this command to a key
sequence.
2011-12-20 08:10:36 -04:00
Dmitry Kurochkin
59adb2da19 emacs: do not call `notmuch-hello-mode' on update
`notmuch-hello' should call `notmuch-hello-mode' function only when
run for the first time.  But before the change, `notmuch-hello' used
`kill-all-local-variables' to remove editable widgets fields.  This
caused the major mode to be reset, and `notmuch-hello-mode' to be
called every time.

The patch manually deletes all editable widget fields and removes
`kill-all-local-variables' call.
2011-12-20 07:42:31 -04:00
Aaron Ecay
a2d0215a58 Add an argument to notmuch-mua-mail
From the emacs changelog:

  ** `compose-mail' now accepts an optional 8th arg, RETURN-ACTION, and
  passes it to the mail user agent function.  This argument specifies an
  action for returning to the caller after finishing with the mail.
  This is currently used by Rmail to delete a mail window.

Under Emacs 24, notmuch breaks when this argument is passed to it by a
function in another part of Emacs.  One example of a functon that does
this is report-emacs-bug -- so notmuch users cannot file emacs bug
reports!

This patch also adds a &rest argument to the arg-list of this function,
to future-proof against such changes.  This is adapted from the approach
taken by message-mail, a similar function built into emacs.

This patch was originally submitted by richardmurri@gmail.com on Aug. 1:
id:"877h6x6oor.fsf@veracitynetworks.com"
2011-12-18 08:18:06 -04:00
Ivy Foster
db352df09e emacs: Add notmuch-hello-mode-hook
Functions called after entering `notmuch-hello-mode'
2011-12-16 17:17:30 -04:00
Daniel Schoepe
3f02ba3406 emacs: Document notmuch-show-get-message-properties 2011-12-16 08:34:26 -04:00
Thomas Jost
430fb27b3e emacs: Add a face for crypto parts headers
Commit cb841878 introduced new parts handlers for crypto parts, but also
hardcoded values for their headers face. This replaces these hardcoded values
with a customizable face.
2011-12-15 22:51:24 -04:00
Jani Nikula
ed56fee6e5 emacs: support "notmuch new" as a notmuch-poll-script
Support nil value for notmuch-poll-script to run "notmuch new" instead of
an external script, and make this the new default. "notmuch new" is run
using the configured notmuch-command.

This allows taking better advantage of the "notmuch new" hooks from emacs
without intermediate scripts.

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-15 00:20:11 -04:00
Dmitry Kurochkin
a647f43643 emacs: do not call notmuch show for non-inlinable parts
Before the change, there was a workaround to avoid notmuch show calls
for parts with application/* Content-Type.  But non-inlinable parts
are not limited to this Content-Type (e.g. mp3 files have audio/mpeg
Content-Type and are not inlinable).  For such parts
`notmuch-show-insert-part-*/*' handler is called which unconditionally
fetches contents for all parts.

The patch moves content fetching from `notmuch-show-insert-part-*/*'
to `notmuch-show-mm-display-part-inline' function after MIME inlinable
checks are done to avoid useless notmuch show calls.  The
application/* hack is no longer needed and removed.
2011-12-07 20:05:25 -04:00
Dmitry Kurochkin
2a349d739b emacs: remove unused variable in `notmuch-show-insert-part-message/rfc822'
An obvious cleanup.  I wonder why there was no warning about this
during compilation.
2011-12-07 20:00:24 -04:00