Commit graph

653 commits

Author SHA1 Message Date
Austin Clements
fd656d7683 emacs: Move ?, q, s, m, =, and G to the common keymap
The only user-visible effect of this should be that "G" now works in
show mode (previously it was unbound for no apparent reason).

This shared keymap gives us one place to put global commands, which
both forces us to think about what commands should be global, and
ensures their bindings can't diverge (like the missing "G" in show).
2013-09-10 08:07:38 -03:00
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
69c52c56f2 emacs: Make notmuch-help work with arbitrary keymaps
This converts notmuch-help to use map-keymap for all keymap traversal.
This generally cleans up and simplifies construction of keymap
documentation, and also makes notmuch-help support anything that can
be in a keymap, including more esoteric stuff like multiple
inheritance.
2013-09-10 08:07:19 -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
Austin Clements
ecdfa9a6b0 emacs: Remove notmuch-search quit continuation
Since notmuch-hello doesn't need this any more, we can remove this
hack.  This also eliminates `notmuch-search-quit', so now all modes
bind "q" to `notmuch-kill-this-buffer'.
2013-09-10 08:06:42 -03:00
Austin Clements
8e10f91798 emacs: Bind "s" to notmuch-search in hello-mode
Since there is now no difference between notmuch-hello-search and
notmuch-search when called interactively, bind "s" to notmuch-search
in notmuch-hello-mode-map.  Now all modes bind "s" this way.
2013-09-10 08:06:24 -03:00
Austin Clements
da88f4b6d5 emacs: Refresh hello whenever the user switches to the buffer
Previously, we refreshed hello when the user quit a search that was
started from hello.  This is fine assuming purely stack-oriented
buffer use, but is quite fragile and requires hacks to search.

This replaces that logic with a new approach that refreshes hello
whenever the user switches to the hello buffer, regardless of how this
happens.
2013-09-10 08:06:08 -03:00
Austin Clements
8a111b58d8 emacs: Consistently use configured sort order
Previously, if `notmuch-search' was called interactively (bound to "s"
in search and show, but not hello), it would always use newest-first.
However, `notmuch-hello-search' (bound to "s" in hello) and
`notmuch-hello-widget-search` would call it with the user-configured
sort order.  This inconsistency seems unintentional, so change
`notmuch-search' to use the user-configured sort order when called
interactively.
2013-09-10 08:05:50 -03:00
Istvan Marko
654260420d emacs: add buttons for all multipart/related parts
When text/html parts include images as multipart/related and the
text/plain alternative is used these images can be completely hidden
with no easy way to access them or even find out that they are there.

Make notmuch-show-insert-part-multipart/related add buttons for all
parts, the first one visible the rest hidden.
2013-09-10 08:05:31 -03:00
Mark Walters
ee8305b519 emacs: show: lazy part handling bugfix
The lazy part handler had a bug that it allowed the button to be
toggled to be specified. During toggling it needs to save and restore
the text-properties for the button but it actually saved the text
properties at point rather than from the button.

In almost all cases this didn't matter as as point had the same text
properties as the button. However, it is a bug and did cause incorrect
behaviour in some cases: see id:87txhz14z6.fsf@qmul.ac.uk for details.
2013-09-10 08:05:05 -03:00
Tomi Ollila
4ceeaf8038 emacs: fix notmuch-mua-reply point placement when signature involved
When composing a reply, notmuch-mua-reply attempts to  cite the
the original message by inserting it before the user signature, if
one is present. The existing method used to search the signature
separator backward from the end of the buffer and then move one
line up. In case of variable `message-signature-insert-empty-line'
being nil this caused point to go to the beginning of
'--text follows this line--'
separator line, and citation was inserted there.
This change checks the value of `message-signature-insert-empty-line'
and doesn't move point if that is nil. Additional narrowing to
the body region ensures that point never goes to the separator line
(or beyond).
`message-signature-setup-hook' or `message-setup-hook' may already have
added some other content to the message body, therefore using simply
(message-goto-body) to move point to the beginning of body might lead
to unexpected results.

Original patch from "Geoffrey H. Ferrari", continued with iterations
from Jani and Mark.
2013-09-08 22:41:19 -03:00
Jani Nikula
5c19eb46a9 emacs: insert quotable parts in reply as they are displayed in show view
In reply, insert quotable parts using notmuch-show-insert-bodypart
instead of calling notmuch-mm-display-part-inline directly to render
the quoted parts as they are rendered in show view.

We use a temp buffer to not leak text properties from the show
renderer into the reply. This way we also don't need to worry about
narrowing or point placement. Credits to Mark Walters
<markwalters1009@gmail.com> and Austin Clements <amdragon@MIT.EDU> for
getting this part straight.

The notable change is that replies to text/calendar parts quote the
pretty printed output of icalendar-import-buffer rather than the ugly
raw vcalendar.
2013-09-05 06:38:24 -03:00
Tomi Ollila
3e60e0b3e9 emacs: removed 3 duplicate functions from notmuch-show.el
notmuch-show.el and notmuch.el had 3 duplicate, identical functions:
notmuch-foreach-mime-part, notmuch-count-attachments and
notmuch-save-attachments. Now these functions in notmuch-show.el
are replaced with declare-functions pointing to "notmuch"(.el).
2013-08-27 07:53:28 -03:00
Mark Walters
15f5fc513d emacs: bugfix attachment content-type as mime-type handling
Notmuch puts attachments in as declared content-type except when the
content-type is application/octet-stream it tries to guess the type
from the filename/extension. This means that viewing a pdf (for
example) which is sent as application/octet-strem invokes the pdf
viewer rather than just offering to save the part.

Recent changes to the attachment handling (commit 1546387d) changed
(broke) this. This patch stores the calculated mime-type with the part
and changes the attachment part handlers can use it instead.
2013-07-31 17:46:09 -03:00
Mark Walters
e395f4507d emacs: hello: make --batch error gracefully
Recently notmuch-hello was converted to use batch count. However, it
seems that several people run different versions of notmuch-emacs and
notmuch-cli so this batch makes emacs fail with an error message if
--batch is not available in the CLI.

Amended by: db
2013-07-27 18:22:37 -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
43251ab653 emacs: Use S-exp format everywhere
This switches `notmuch-mua-reply' and `notmuch-query-get-threads' to
the S-exp format.  These were the last two uses of the JSON format in
the Emacs frontend.
2013-06-24 22:57:13 -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
Austin Clements
eb7d096edc emacs: Remove v command
This removes the v command, since we now have much nicer part commands,
and deprecates the underlying notmuch-show-view-all-mime-parts.  This
also means that people who try using the old unprefixed 'v' command on
a part button will no longer be greeted by ALL of their parts popping
up.
2013-06-24 22:52:10 -07:00
Jani Nikula
c1a42652a1 emacs: update search sort order help to match code 2013-06-24 22:51:37 -07:00
Mark Walters
7bc404f0a4 emacs: show: change emacs interactive pipe message.
Previously the query string for piping a message to a command was
"Pipe message to command: " regardless of whether the function was
called with a prefix argument (which pipes all open messages to the
command). This patch modifies the `interactive' command to reflect
this.
2013-06-24 22:49:33 -07:00
Mark Walters
d0bd88f06d emacs: show: implement lazy hidden part handling
This adds the actual code to do the lazy insertion of hidden parts.

We use a memory inefficient but simple method: when we come to insert
the part if it is hidden we just store all of the arguments to the
part insertion function as a button property. This means when we want
to show the part we can just resume where we left off.

One thing is that we can't tell if a lazy part will produce text until
we try to render it so when unhiding a part we check to see if it
rendered; if not we invoke the default part handler (e.g. an external
viewer).

Also, we would like to insert the lazy part at the start of the line
after the part button. But if this line has some text properties
(e.g. the colours for a following message header) then the lazy part
gets these properties. Thus we start at the end of the part button
line, insert a newline, insert the lazy part, and then delete the
extra newline at the end of the part.
2013-06-13 00:07:19 +09:00
Mark Walters
055f7621d6 emacs: show move addition of :notmuch-part to separate function
This separates out the adding of the :notmuch-part text property to a
separate function to simplify calling from the lazy part insertion
code.
2013-06-13 00:07:07 +09:00
Mark Walters
490b02345e emacs: show: modify the way hidden state is recorded.
Previously, whether a part was hidden or shown was recorded in the
invisibility/visibility of the part overlay. Since we are going to
have lazily rendered parts with no overlay store the hidden/shown
state in the part button itself.

Additionally, in preparation for the invisible part handling move the
actual hiding of the hidden parts to insert-bodypart from
create-part-overlays.

Finally, we will need to know whether a part-insertion has done
anything (it won't if the invisible part cannot be displayed by emacs)
so we slightly rejig the code order in
notmuch-show-toggle-part-invisibility to make it easier for the
function to set an appropriate return value.
2013-06-13 00:06:59 +09:00
Mark Walters
81c199c962 emacs: show: pass button to create-overlays
Now that the bodypart code has the button we can pass that to
create-overlays and simplify that.
2013-06-13 00:06:51 +09:00
Mark Walters
702210b84d emacs: show: move the insertion of the header button to the top level
Previously each of the part insertion handlers inserted the part
button themselves. Move this up into
notmuch-show-insert-bodypart. Since a small number of the handlers
modify the button (the encryption/signature ones) we need to pass the
header button as an argument into the individual part insertion
handlers. However, the declared-type argument was only used for the
text for the part buttons we can now omit it.

The patch is large but mostly simple. The only things of note are that
we let the text/plain handler applies notmuch-wash to the whole part
including the part button. In particular, notmuch-wash removes leading
blank lines from a text/plain part, but since the button is counted as
part of the part this does not happen with text/plain buttons that
have a button. This is probably a bug in notmuch-wash but changing it
does make several tests fail (that rely on this blank line) so, for
the moment, keep the old behaviour.
2013-06-13 00:05:59 +09:00
Mark Walters
27768309ce emacs: show: fake wash parts are handled at insert-bodypart level
Earlier patches have moved the handling of wash fake inline patch
parts to insert-bodypart so we can drop the function
notmuch-show-insert-part-inline-patch-fake-part
2013-06-13 00:05:40 +09:00
Austin Clements
88cce8c6a4 emacs: Fix "no such file or directory" error
Occasionally, when the user killed the search buffer when the CLI
process was still running, Emacs would run the
notmuch-start-notmuch-sentinel sentinel twice.  The first call would
process and delete the error output file and the second would fail
with an "Opening input file: no such file or directory, ..." error
when attempting to access the error file.

Emacs isn't supposed to run the sentinel twice.  The reason it does is
rather subtle (and probably a bug in Emacs):

1) When the user kills the search buffer, Emacs invokes
kill_buffer_processes, which sends a SIGHUP to notmuch, but doesn't do
anything else.  Meanwhile, suppose the notmuch search process has
printed some more output, but Emacs hasn't consumed it yet (this is
critical and is why this error only happens sometimes).

2) Emacs gets a SIGCHLD from the dying notmuch process, which invokes
handle_child_signal, which sets the new process status, but can't do
anything else because it's a signal handler.

3) Emacs returns to its idle loop, which calls status_notify, which
sees that the notmuch process has a new status.  This is where things
get interesting.

3.1) Emacs guarantees that it will run process filters on any
unconsumed output before running the process sentinel, so
status_notify calls read_process_output, which consumes the final
output and calls notmuch-search-process-filter.

3.1.1) notmuch-search-process-filter checks if the search buffer is
still alive and, since it's not, it calls delete-process.

3.1.1.1) delete-process correctly sees that the process is already
dead and doesn't try to send another signal, *but* it still modifies
the status to "killed".  To deal with the new status, it calls
status_notify.  Dun dun dun.  We've seen this function before.

3.1.1.1.1) The *recursive* status_notify invocation sees that the
process has a new status and doesn't have any more output to consume,
so it invokes our sentinel and returns.

3.2) The outer status_notify call (which we're still in) is now done
flushing pending process output, so it *also* invokes our sentinel.

This patch addresses this problem at step 3.1.1, where the filter
calls delete-process, since this is a strange and redundant thing to
do anyway.
2013-06-12 23:53:27 +09: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
Servilio Afre Puentes
10aac89911 emacs: hello: allow deleting individual searches in the history
This commit adds an extra button at the end of the search entries that
allows deleting that individual search from the history. A short
confirmation («y» or «n») is made before taking action.
2013-06-08 20:37:46 -03:00
Servilio Afre Puentes
486340e28e emacs: hello: ask confirmation for clearing recent searches
The button to clear the recent searches in notmuch-hello is easy to
press accidentally while moving around the, clearing potentially
useful searches with no way of recovering them.
2013-06-08 20:37:35 -03:00
Austin Clements
109a0355d6 emacs: Fix applying stickiness to the :notmuch-part property
Previously, we simply called pushnew to add :notmuch-part to the
front-sticky and rear-nonsticky text property lists.  This works if
these are nil or lists, but they can also have the value t, meaning
that all properties are front-sticky/rear-nonsticky.  In this case,
pushnew will signal an error because t is not a list.  We never set
these properties to t ourselves, but since we apply these property
changes over arbitrary renderer output, we have to deal with this
possibility.
2013-06-04 08:39:42 -03:00
David Bremner
b3e8be32e8 emacs: update .gitignore
Start a seperate .gitignore for emacs stuff, move .elc rule there.
2013-06-02 20:44:26 -03:00
David Bremner
915a707ae4 emacs: add `notmuch-archive-tags' cross references in docstrings
Several function docstrings refer to behaviour in docstrings that is
really controlled by notmuch-archive-tags. Add cross references, and
replace hardcoding.
2013-06-02 20:43:14 -03:00
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