Commit graph

67 commits

Author SHA1 Message Date
Austin Clements
c52fee6bcb emacs: Define a common shared keymap for all of notmuch
This defines a single, currently empty keymap that all other notmuch
mode maps inherit from.
2013-09-10 08:07:28 -03:00
Austin Clements
21474f0e09 emacs: Add unified refresh-this-buffer function
This unifies the various refresh and poll-and-refresh functions we
have for different modes.  Now all modes bind "=" and "G" (except
show, which doesn't bind "G" for some reason) to
`notmuch-refresh-this-buffer' and
`notmuch-poll-and-refresh-this-buffer', respectively.
2013-09-10 08:07:06 -03:00
Austin Clements
ebd8a2e344 emacs: Move `notmuch-poll' to notmuch-lib 2013-09-10 08:06:52 -03:00
Tomi Ollila
2bd374c91e emacs: dropped rest of now-unused JSON functionality
Notmuch cli provides all structured data previously provided
in json format now in s-expression format, rendering all current
json functionality obsolete.
2013-07-20 09:13:48 -03:00
Austin Clements
8222af3ecc emacs: Remove `notmuch-call-notmuch-json'
This function is no longer used.
2013-06-24 22:57:28 -07:00
Austin Clements
2626d81573 emacs: Introduce `notmuch-call-notmuch-sexp'
This is just like `notmuch-call-notmuch-json', but parses S-expression
output.  Note that, also like `notmuch-call-notmuch-json', this
doesn't consider trailing data to be an error, which may or may not be
what we want in the long run.
2013-06-24 22:57:02 -07:00
Jani Nikula
c1a42652a1 emacs: update search sort order help to match code 2013-06-24 22:51:37 -07:00
Austin Clements
634914064b emacs: Don't report CLI signals sent by Emacs as errors
Previously, when the user killed the search buffer before the CLI
search process had completed, we would report the signal sent by Emacs
to kill the CLI to the user as an error.  Fix this by only reporting
error exits if the process buffer is still live.  We still report
stderr output regardless in case stderr output was relevant to why the
user killed the search buffer (such as a wrapper script being stuck).
2013-06-12 23:53:15 +09: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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
David Edmondson
6bd3d8af54 emacs: Prefer '[No Subject]' to blank subjects. 2012-02-03 21:20:15 -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
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
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
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
Dmitry Kurochkin
34aa8e8a9c emacs: remove unused `point-invisible-p' function
`point-invisible-p' does not work correctly when `invisible'
property is a list.  There are standard `invisible-p' and related
functions that should be used instead.
2011-11-07 20:38:37 -04:00
Pieter Praet
432e091924 fix sum moar typos [user-visible documentation in code]
Various typo fixes in documentation within the code that can be made
available to the user, (emacs function help strings, "notmuch help"
output, notmuch man page, etc.).

Signed-off-by: Pieter Praet <pieter@praet.org>

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just
documentation and fixed fix of "comman" to "common" rather than
"command".
2011-06-23 15:58:50 -07:00
Jameson Graef Rollins
45fe354745 emacs: Add support for PGP/MIME verification/decryption
A new emacs configuration variable "notmuch-crypto-process-mime"
controls the processing of PGP/MIME signatures and encrypted parts.
When this is set true, notmuch-query will use the notmuch show
--decrypt flag to decrypt encrypted messages and/or calculate the
sigstatus of signed messages.  If sigstatus is available, notmuch-show
will place a specially color-coded header at the begining of the
signed message.

Also included is the ability to switch decryption/verification on/off
on the fly, which is bound to M-RET in notmuch-search-mode.
2011-05-27 16:22:00 -07:00