Commit graph

73 commits

Author SHA1 Message Date
Jani Nikula
ed56fee6e5 emacs: support "notmuch new" as a notmuch-poll-script
Support nil value for notmuch-poll-script to run "notmuch new" instead of
an external script, and make this the new default. "notmuch new" is run
using the configured notmuch-command.

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

Signed-off-by: Jani Nikula <jani@nikula.org>
2011-12-15 00:20:11 -04:00
Chris Gray
9e805b6a58 emacs: Use notmuch-command variable in process-lines.
The process-lines function calls the notmuch binary.  The location of
the binary may have been customized by the user, so it is better to
use the customized location rather than allowing the process-lines
function to search the user's PATH for the binary.
2011-11-30 17:19:44 -08:00
Austin Clements
9cfafc070a emacs: Avoid unnecessary markers.
This is just cleanup.  These markers are all immediately resolved to
points by Emacs, so using markers here is just unncessary overhead.
2011-11-24 08:33:12 -04:00
Austin Clements
3a3f6f0ab5 emacs: Don't record undo information for search or show buffers.
There's no reason to record undo information for read-only,
programmatically-constructed buffers.  The undo list just chews up
memory keeping track of our calls to insert.
2011-11-24 08:31:44 -04:00
Jameson Graef Rollins
07022714eb emacs: Unbind M-RET as display of thread with crypto switch.
Use prefix argument instead to set switch.
2011-11-12 20:42:25 -04:00
Austin Clements
a2d78fba20 emacs: Use a single buffer invisibility spec to fix quadratic search cost.
Buffer redisplay requires traversing the buffer's invisibility spec
for every part of the display that has an 'invisible text or overlay
property.  Previously, the search buffer's invisibility spec list
contained roughly one entry for each search result.  As a result,
redisplay took O(NM) time where N is the number of visible lines and M
is the total number of results.  On a slow computer, this is enough to
make even buffer motion noticeably slow.  Worse, during a search
operation, redisplay is triggered for each search result (even if
there are no visible buffer changes), so search was quadratic
(O(NM^2)) in the number of search results.

This change switches to using a single element buffer invisibility
spec.  To un-hide authors, instead of removing an entry from the
invisibility spec, it simply removes the invisibility overlay from
those authors.

I tested using a query with 6633 results on a 9 year old machine.
Before this patch, Emacs took 70 seconds to fill the search buffer;
toward the end of the search, Emacs consumed 10-20x as much CPU as
notmuch; and moving point in the buffer took about a second.  With
this patch, the same query takes 40 seconds, Emacs consumes ~3x the
CPU of notmuch by the end, and there's no noticeable lag to moving
point.  (There's still some source of non-linearity, because Emacs and
notmuch consume roughly the same amount of CPU early in the search.)
2011-11-12 09:21:03 -05:00
Michal Sojka
0234a16b56 Do not query on notmuch-search exit
Emacs 23.2 queries by default about killing existing processes. This
is annoying when one wants to interrupt long search with 'q' key.
Disable this behavior for notmuch.
2011-11-08 14:25:07 -04:00
Daniel Schoepe
6a280088e6 emacs: Tab completion for notmuch-search and notmuch-search-filter
This patch adds completion with <tab> in the minibuffer for
notmuch-search and notmuch-search-filter.
2011-11-02 22:06:44 -03: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
Thomas Jost
f7cc259c10 emacs: Allow the user to choose the "From" address when replying to a message
When pressing C-u r, the user will be prompted for the identity to use.
2011-05-26 10:38:16 -07:00
Thomas Jost
784649561a emacs: Allow the user to choose the "From" address when composing a new message
When pressing C-u m, the user will be prompted for the identity to use.
2011-05-26 10:34:37 -07:00
Daniel Schoepe
d84e927091 emacs: add notmuch-before- and notmuch-after-tag-hook
This patch adds hooks that are run before/after messages are tagged
From the emacs interface.  In order to implement this and to avoid
having hooks parse all the arguments to the notmuch binary again, I
created a `notmuch-tag' function that other modules should use instead
of running (notmuch-call-notmuch-process "tag" ...) directly.
2011-05-24 13:28:41 -07:00
Jameson Graef Rollins
907cac7035 use custom-face-edit value-type in notmuch-search-line-faces
This enables the proper face customization UI for
notmuch-search-line-faces.
2011-04-25 14:26:20 -07:00
Carl Worth
eead238277 emacs: Define notmuch-search-process-filter-data before first use.
To avoid a wraning about a reference to a free variable when compiling.
2011-03-10 17:59:53 -08:00
Carl Worth
708c4f46ca emacs: Don't drop error messages from "notmuch search"
With the previous commit, unexpected output before or between search results
would be displayed. However, trailing junk from the "notmuch search" output
would still be silently swallowed.

The most common case for an error message from "notmuch search" would be
an invalid command-line, and in that case, there would be no search results
and the trailing error message would get swallowed.

We fix the process sentinel to check for leftover data and add it to the
final buffer. We also add a test case to ensure this works.
2011-03-10 16:53:46 -08:00
Carl Worth
8a534dc60d emacs: Fix notmuch-search-process-filter to handle incomplete lines
This fixes the recently-added emacs-large-search-buffer test. This is
as simple as saving any trailing input and then pre-prepending it on
the next call.

MAny thanks to Thomas Schwinge <thomas@schwinge.name> for tracking
down this problem and contributing a preliminary version of this fix.
2011-03-10 16:25:37 -08:00
Carl Worth
44d3c57e2a emacs: Display any unexpected output from notmuch search
Rather than silently swallowing unexpected output, the emacs interface will now
display it. This will allow error messages to actually arrive at the emacs
interface (though not in an especially pretty way). This also allows for easier
investigation of the inadvertent swallowing of search results that span page
boundaries (as demonstrated by the recent added emacs-large-search-buffer test).

The page-boundary bug has been present since a commit from 2009-11-24:
93af7b5745

Many thanks to Thomas Schwinge for tracking that bug down and
contributing the test for it.
2011-03-10 15:18:40 -08:00
David Edmondson
5d05d5434d emacs: Improve the display of truncated authors.
Incremental search does not match strings that span a
visible/invisible boundary. This results in failure to correctly
isearch for authors in `notmuch-search' mode if the name of the author
is split between the visible and invisible components of the authors
string. To avoid this, attempt to truncate the visible component of
the authors string on a boundary between authors, such that the
entirety of an author's name is either visible or invisible.
2010-12-07 13:57:05 -08:00
Jameson Rollins
2b433736a5 emacs: add stash thread-id function to notmuch-search mode
This add a "stash-map" for search-mode, just like in show-mode, and
adds one function, bound to "i" to stash the thread-id of the current
selected thread.

Couldn't think of the correct way to stash other thread info, so I
didn't add any other stash functions for now.
2010-11-11 17:28:48 -08:00
Jameson Rollins
7171e77d4d Don't use kill-this-buffer to kill notmuch emacs buffers
kill-this-buffer appears to be a function intended specifically for
use in the menu bar, and causes problem killing notmuch buffers when
multiple frames have been used.  This patch replaces kill-this-buffer
with notmuch-kill-this-buffer, which in turn just simply calls
(kill-buffer (current-buffer)).
2010-11-08 09:02:54 -08:00
David Edmondson
f99ad42da0 emacs: Re-work the implementation of highlighting in notmuch-search-mode.
Re-write `notmuch-search-color-line', with the following improvements:
 - create overlays only if they will be needed,
 - merge the properties specified for a tag on top of any matching a
   previous tag.
2010-10-29 15:30:43 -07:00
Carl Worth
b11ecf613a emacs: Fix the autoload comments
Remove them from non-top-level entry points, (such as the functions to
set notmuch modes and the deprecated notmuch-folder function). And add
one to the notmuch-hello function. Also, add missing documentation
string to notmuch-hello.
2010-10-29 15:27:01 -07:00
David Benjamin
adbfff40ca Don't involve the shell in notmuch searches
The shell isn't needed to interpret any of the arguments, so don't
bother using it at all.

Signed-off-by: David Benjamin <davidben@mit.edu>
2010-10-29 14:13:51 -07:00
Carl Worth
c9e0da3a1a emacs: Eliminate warning of calling function with excess arguments.
Yet another case of "how could this have possibly worked before?!".

I guess we were just getting very lucky with the emacs lisp calling
conventions and what happens with extra arguments, but, ick! Much
better now.
2010-10-27 18:04:38 -07:00
Carl Worth
75f703e7c2 emacs: Remove non-interactive call of goto-line
As the emacs compiler warns, the goto-line function is only intended for
interactive use. Instead use the approach recommended in the goto-line
documentation to avoid this.
2010-10-27 17:58:19 -07:00
David Edmondson
c506e1034b emacs: Avoid runtime use of `cl'.
The GNU Emacs Lisp Reference Manual section D.1 says:

> *  Please don't require the cl package of Common Lisp extensions at
>    run time. Use of this package is optional, and it is not part of
>    the standard Emacs namespace. If your package loads cl at run time,
>    that could cause name clashes for users who don't use that package.
>
>    However, there is no problem with using the cl package at compile
>    time, with (eval-when-compile (require 'cl)). That's sufficient for
>    using the macros in the cl package, because the compiler expands
>    them before generating the byte-code.

Follow this advice, requiring the following changes where `cl' was
used at runtime:

- replace `rassoc-if' in `notmuch-search-buffer-title' with the `loop'
  macro and inline code. At the same time find the longest prefix
  which matches the query rather than simply the last,
- replace `union', `intersection' and `set-difference' in
  `notmuch-show-add-tag' and `notmuch-show-remove-tag' with local code
  to calculate the result of adding and removing a list of tags from
  another list of tags.
2010-10-27 17:41:50 -07:00
Carl Worth
31a5e5a125 emacs: Fix bug when parsing a subject cotaining: \[[0-9/]\]
That is, a subject with a bracketed set of digits (and optionally a
slash), for example "[2010]" would cause the emacs code to misparse
the search results. Fix this by tweaking the regular expression.
2010-09-23 13:21:03 -07:00
David Edmondson
17b09af228 emacs: In search mode, truncate authors using invisible text.
Rather than discarding authors when truncated to fit the defined
column width, mark the text beyond the end of the column as invisible
and allow `isearch' to be used over the text so hidden.

This allows us to retain the compact display whilst enabling a user to
find the elided text.
2010-06-03 19:12:23 -07:00
David Edmondson
f2525ed18f emacs: Adjust comment to avoid confusing font-lock.
Comments with an open bracket in the first column confuse `font-lock'
mode, so avoid them.
2010-06-03 19:11:15 -07:00
David Edmondson
55cef18f95 emacs: Allow control over faces for search mode columns.
Add face declarations for the date, count, matching author and subject
columns in search mode and apply those faces when building the search
mode display.

Approved-by: Jameson Rollins <jrollins@finestructure.net>
2010-06-03 16:55:27 -07:00
David Edmondson
965b3e6a8b emacs: Set the face' property rather than font-lock-face'.
Avoid using face properties reserved for the font-lock package.
2010-06-03 16:53:36 -07:00
David Edmondson
106f9862d1 emacs: Display non-matching authors with a different face.
In search mode some messages don't match the search criteria. Show
their authors names with a different face - generally darker than
those that do match.
2010-06-03 16:53:32 -07:00
Jesse Rosenthal
a43ceef205 emacs: require notmuch-message.el from notmuch.el
Add a (require 'notmuch-message) to notmuch.el. This is for functions that
specifically target message mode (and, in the future, notmuch-message
mode).
2010-04-27 09:16:44 -07:00
Carl Worth
0d8e26d0e3 emacs: Tweak search-buffer naming to search list in reverse order
The complete-string matching of commit
f2ebe3ac44
defeats the substitution of partial search
strings when the user manually types a
long search string that just happens to
partially match a saved search.

For example, typing "tag:inbox and not tag:foo"
should result in "[inbox] and not tag:foo" but
this has been broken since that commit.

As a compromise between this feature and what the
commit was trying to achieve, we now reverse the
saved-searches list before looking for a match.
This happens to work for me, but won't necessarily
work in general.

What we really want is the longest match, but rassoc-if
just gives us the first match. All of this is just about
creating slightly nice search-buffer names. So if anyone
really cares about making the names *even* nicer, then
they could improve this further.
2010-04-26 23:00:20 -07:00
Carl Worth
6731ab1037 emacs: Rename search buffers with "saved-search" not "folder"
Since we recently renamed everything from notmuch-folders to
notmuch-saved-searches, fix up the generated names in the search
buffers to match.
2010-04-26 22:58:46 -07:00
Carl Worth
f2ebe3ac44 emacs: Match entire saved-search when computing search-view buffer name
I happen to have a lot of saved searches that are variants of the
tag:inbox search, (such as "tag:inbox and tag:notmuch"). The logic for
these was always matching inbox first, resulting in "[ inbox ] and
tag:notmuch" rather than "notmuch" as desired.

Anchor the regular expression on both ends to make it look harder for
the better match.
2010-04-26 22:49:45 -07:00
Carl Worth
a466921760 emacs: Rip out all of the notmuch-folder code.
We are asserting that the new notmuch-hello implementation, (available
by just calling `notmuch') is just as easy to use as the old
notmuch-folder. So let's remove what's now a largely redundant
implementation.

To make this transition easier, we are still supporting the
notmuch-folders variable name, and we still provide `notmuch-folder'
as an alias which can be invoked to get the new notmuch-hello
functionality.
2010-04-26 22:42:07 -07:00
Carl Worth
f1f7e71e03 emacs: Add a notmuch-saved-searches function.
We use this function to abstract away the common 3-step process for
looking for a value for the saved-searches variable:

	1. Look at the notmuch-saved-searches variable itself
	2. Look at the notmuch-folders vaiable
	3. Use a default value

We were already using this logic (open-coded) in notmuch-hello, but
notmuch.el was accessing notmuch-folders directly for the clever name
selection of search buffers.
2010-04-26 22:37:11 -07:00
Sebastian Spaeth
36245db69d Integrate notmuch-maildir-fcc into notmuch
Require notmuch-maildir-fcc and also install it.
Rename all jkr/* functions to notmuch-maildir-fcc-*

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2010-04-26 11:58:34 -07:00
David Edmondson
975307c945 emacs: Remove duplicate declaration of `notmuch-folders'
Reviewed-by: Carl Worth <cworth@cworth.org>

This variable was moved from notmuch.el to notmuch-lib.el some time
ago, but the declaration in notmuch.el was left around. Clean that up.
2010-04-26 10:45:05 -07:00
David Edmondson
98cf886120 emacs: notmuch' should display the notmuch-hello' interface
Reviewed-by: Carl Worth <cworth@cworth.org>

The notmuch-hello functionality is now sufficiently useful that we
want to make it the default view of notmuch for new users. This also
effectively hides the "hello" name from the user, so we'll be free to
change that in the implementation if necessary.

This change also shuffles the requires between notmuch.el and
notmuch-hello.el. This fixes things so that our documented (require
'notmuch) is sufficient for getting the notmuch-hello functionality.

Finally, the shuffling caused the notmuch-search-oldest-first variable
from one file to the other. While doing that, give this variable the
defcustom treatment for easier customization.
2010-04-26 10:37:35 -07:00
David Edmondson
6afa0b16a3 emacs: Fix `notmuch-search-insert-field'
Compare the formatted version of the authors with the formatted sample
string rather than the un-formatted authors with the formatted sample
string.
2010-04-26 08:23:48 -07:00
David Edmondson
45ad21fba1 emacs: Re-arrange message sending code
Define a new `mail-user-agent' (`notmuch-user-agent') and use it by
default. Re-arrange various routines that send mail to use this
(compose, reply, forward). Insert a `User-Agent:' header by default.

This is the real commit for this functionality this time. The
previous attempt to merge this code:

	commit 57926bc7b0

was botched (by Carl Worth, not David) to include only the Makefile
change. So the build was broken until this commit that actually adds
the new file.
2010-04-23 15:41:33 -07:00
Carl Worth
4b0994dd25 emacs: Fix some compilation warnings.
Fix missing argumen in declaration of notmuch-search function and add
a definition of notmuch-search-continuation to avoid warning about
assignment to a free variable.
2010-04-23 12:57:22 -07:00
David Edmondson
e9394932f7 emacs: Add notmuch-hello.el, a friendly frontend to notmuch
This is based on the prototype that Carl Worth described in the TODO
file. It provides a search bar as well as support for recent searches,
saved searches, and a list of all tags in the database (as well as the
number of messages with each tag).
2010-04-23 12:50:18 -07:00
David Edmondson
b65bcb5f8f emacs: Remove notmuch-search-authors-width' and fix the use of notmuch-search-result-format' accordingly
The width of the authors field in search output was previously
specified in two places:
 - `notmuch-search-authors-width': the limit beyond which the authors
   names are truncated,
 - `notmuch-search-result-format': the layout of the search results.

Changing the configuration of one of these may have required the user
to know about and adapt the other accordingly. This led to confusion.

Instead, remove `notmuch-search-authors-width' and perform truncation
based on the relevant field in `notmuch-search-result-format'.

Approved-By: Jameson Rollins <jrollins@finestructure.net>
2010-04-23 12:14:17 -07:00
Carl Worth
0b2cf3527e emacs: Add customize treatment and rename refresh-script to notmuch-poll-script
With defcustom the user can easily find this variable (and its
documentation) within "M-x customize-group" "notmuch" (though finding
*that* is still tricky).

The new name of notmuch-poll-script is also easier to remember, (for
me at least).
2010-04-22 14:46:15 -07:00
Carl Worth
577a6906ce emacs: Use consistent naming for the two new poll functions.
Emacs scoping rules strongly encourage us to have fully-namespaced
function names. A prefix like "notmuch-search" is a pretty ugly
namespace name, but it's what we have for now.
2010-04-22 14:24:37 -07:00
Dirk Hohndel
f373ed0792 Add 'G' keybinding to folder and search view that triggers external poll
The new functions first check if an external poll script has been defined in
the variable 'notmuch-external-refresh-script and if yes, runs that script
before executing the existing refresh function (which is bound to '=')

This can be used to have 'G' mimic the mutt behavior of polling an external
mail server - or if the mail polling is already automatic, it can trigger
the call to notmuch new and any necessary automatic tagging of new email.

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
2010-04-22 14:22:09 -07:00