Commit graph

639 commits

Author SHA1 Message Date
David Bremner
94064a6ba2 Merge branch 'release'
A point release is slowly being built on branch release. Merge those
changes into master.
2014-05-28 09:50:32 -03:00
Mark Walters
83f531ad7e emacs: make sure tagging on an empty query is harmless
Currently notmuch-tag throws a "wrong-type-argument stringp nil" if
passed a nil query-string. Catch this and provide a more useful error
message. This fixes a case in notmuch-tree (if you try to tag when at
the end of the buffer).

Secondly, as pointed out by David (dme)
`notmuch-search-find-stable-query-region' can return the query string
() if there are no messages in the region. This gets passed to notmuch
tag, and due to interactions in the optimize_query code in
notmuch-tag.c becomes, in the case tag-change is -inbox, "( () ) and
(tag:inbox)". This query matches some strange collection of messages
which then get archived. This should probably be fixed, but in any
case make `notmuch-search-find-stable-query-region' return a nil
query-string in this case.

This avoids data-loss (random tag removal) in this case.
2014-05-27 20:40:04 -03:00
David Edmondson
ec02089433 emacs: Correct the documentation for `notmuch-search-line-faces'.
The implementation and documentation for `notmuch-search-line-faces'
disagreed in how elements in the list were merged. Correct the
documentation to match the implementation (that is, the earlier
elements in the list have precedence over later elements).
2014-05-18 06:42:23 +09:00
Jani Nikula
ecef282a16 emacs: allow functions in notmuch-show-stash-mlarchive-link-alist
Some archives may use a more complicated scheme for referring to
messages than just concatenated url and message-id. In particular,
patchwork requires a query to translate message-id to a patchwork
patch id. Allow functions in notmuch-show-stash-mlarchive-link-alist
to facilitate this.

For example, one could use something like this for patchwork.

(lambda (message-id)
  (concat
   "http://patchwork.example.com/patch/"
   (nth 0
	(split-string
	 (car (last (process-lines "pwclient" "search" "-n" "1"
				   "-m" (concat "<" message-id ">"))))))))
2014-05-04 14:16:24 +09:00
Mark Walters
ae2888015e emacs: hello: bugfix for saved searches defcustom
The recent changes for saved searches introduced a bug when notmuch
was loaded after the saved search was defined. This was caused by a
utility function not being defined when the defcustom was loaded.

Fix this by moving some code around: the defcustom is moved into
notmuch-hello (which is a more natural place anyway), and the utility
functions are moved before the defcustom in notmuch-hello. We are
rather constrained as the defcustom for saved searches is the first
variable in the notmuch-hello customize window; to avoid moving this
customize the defcustom needs to be the first defcustom in
notmuch-hello, and the utility functions come before that.

This patch also renames one of the utility functions from
notmuch--saved-searches-to-plist to
notmuch-hello--saved-searches-to-plist (as it is purely local to
notmuch-hello) and corrects a couple of typo/spelling mistakes pointed
out by Tomi.
2014-04-21 21:48:41 +09:00
Austin Clements
1ada97e05b emacs: Honor debug-on-error for part renderers
Previously, even if debug-on-error was non-nil, the debugger would not
trap on part renderer errors.  This made debugging part renderer bugs
frustrating, so let the debugger trap these errors.
2014-04-19 13:08:30 +09:00
Mark Walters
2fc72a1854 emacs: hello: bugfix: make alphabetically sorted saved searches work
My recent changes to the saved search format broke the alphabetically
sorted saved sort option. This makes it work again.

Also update docs for saved-search sort defcustom to match the new
format.

Finally, since the saved-search list is no longer an alist change the
names in the sort function to avoid confusion.
2014-04-14 23:17:20 -03:00
Jameson Graef Rollins
16a3103023 emacs: remove auto-signing of replies to signed messages
It was decided that auto-signing is potentially too troublesome for the
apparently common case of users who enable crypto processing for the
purpose of checking signature validity but who are not in a position to
sign out-going messages.  Users can still manually invoke signing as needed.

Encrypting replies to encrypted messages is more of a security issue
so we leave it in place.
2014-04-14 23:16:40 -03:00
Tomi Ollila
c2048addd4 emacs: add $(srcdir) to notmuch-version.el.tmpl dependency
This fixes out-of-tree build when generating emacs/notmuch-version.el.
2014-04-13 08:42:51 -03:00
Jani Nikula
30a0ed197e emacs: sign/encrypt replies to signed/encrypted messages
This is a simple approach to improving security when replying to
signed or encrypted messages. If the message being replied to was
signed, add mml tag to sign the reply. If the message being replied to
was encrypted, add mml tag to sign and encrypt the reply.

This may need configuration; I for one might want to encrypt replies
to encrypted messages, but not always sign replies to signed messages.

This still includes a slight bug: if any mml tags are added, they are
included in the region containing the quoted parts. Killing the region
will kill the mml tags too.
2014-04-12 22:37:03 -03:00
Mark Walters
f225ee59eb emacs: Add a sort-order option to saved-searches
This adds a sort-order option to saved-searches, stores it in the
saved-search buttons (widgets), and uses the stored value when the
button is pressed.

Storing the sort-order in the widget was suggested by Jani in
id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org.
2014-04-11 10:27:26 -03:00
Mark Walters
355d24fb94 emacs: hello: switch notmuch-hello-insert-buttons to plists
Switching notmuch-hello-insert-buttons to plists means we can easily
pass extra options through to the buttons.
2014-04-11 10:26:51 -03:00
Mark Walters
79c262be66 emacs: hello: add a customize for saved-searches
Make the defcustom for notmuch-saved-searches use the new plist
format. It should still work with oldstyle saved-searches but will
write the newstyle form.
2014-04-11 10:26:41 -03:00
Mark Walters
5e26d14536 emacs: hello: use the saved-search helper functions
This uses the helper functions: the saved searches format has not
changed yet but backwards compatibility means everything still works.
2014-04-11 10:26:30 -03:00
Mark Walters
4767e89bc7 emacs: hello: add helper functions for saved-searches
Add helper functions to for saved searches to ease the transition to
the new plist form while maintaining backwards compatibility. They
will be used in the next patch.
2014-04-11 10:26:19 -03:00
Tomi Ollila
8977b1a259 emacs: defun notmuch-hello-versions and bind 'v' in hello mode to it
If notmuch cli & notmuch emacs MUA versions differ, print also the
emacs MUA version string (along with the cli version) to the
minibuffer.
2014-04-10 23:28:06 -03:00
Tomi Ollila
cab1415a94 emacs: add notmuch-version.el.tmpl and create notmuch-version.el from it
The notmuch cli program and emacs lisp versions may differ (especially
in remote usage). It helps to resolve problems if we can determine
the versions of notmuch cli and notmuch emacs mua separately.

The build process now creates notmuch-version.el from template file
by filling the version info to notmuch-emacs-version variable.
2014-04-10 23:25:36 -03:00
Jani Nikula
d0c4cd7e58 emacs: push mark before signature on reply
We push mark on reply so user can cut the quote. Push the mark before
signature, if any, instead of end of buffer so the signature is
preserved.

This is consistent with message-kill-to-signature.
2014-03-30 19:22:05 -03:00
Tomi Ollila
31fc76b782 emacs: add defcustom notmuch-init-file and load it if exists
So that users can easily organize their notmuch-specific configurations
to separate file and they don't have to have notmuch configurations in
*every* emacs installation they launch, especially if those need to
'(require notmuch) to make the configurations possible.
2014-03-30 11:02:28 -03:00
Tomi Ollila
7341b78aba emacs: instruct user to autoload notmuch instead of require'ing it
When (require 'notmuch) is added to ~/.emacs notmuch is loaded to every
instance of emacs although it may not be used in majority of
those instances.

When (autoload 'notmuch "notmuch" ...) is added to ~/.emacs notmuch
is loaded (only) when user invokes the notmuch function.

User may want to add other entrypoints to notmuch by adding more
autoloads -- the autoload instruction given should offer them clue how
to do so.
2014-03-30 11:02:08 -03:00
Austin Clements
92c3fd938e emacs: Use whitelist instead of blacklist for term escaping
Previously, the term escaper used a blacklist of characters that
needed escaping.  This blacklist turned out to be somewhat incomplete;
for example, it did not contain non-whitespace ASCII control
characters or Unicode "fancy quotes", both of which do require the
term to be escaped.

Switch to a whitelist of characters that are definitely safe to leave
unquoted.  This fixes the broken test introduced by the previous
patch.
2014-03-25 19:57:06 -03:00
Mark Walters
274355776b emacs: tree: use orig-tags in search
This uses the recent functionality to show the tag changes in the tree
buffer. Currently this is only used to show changes the tree buffer
makes itself: i.e., it does not make display any changes reflecting
tagging done by other notmuch-buffers.
2014-03-24 19:48:55 -03:00
Mark Walters
af8c8c2b46 emacs: search: use orig-tags in search
This uses the recent functionality to show the tag changes in the
search buffer. Currently this is only used to show changes the search
buffer makes itself: i.e., it does not make display any changes
reflecting tagging done by other notmuch-buffers.
2014-03-24 19:48:40 -03:00
Mark Walters
a673d618d1 emacs: show: use orig-tags for tag display
This uses the previous patch to show the tag changes that have occured
in the show buffer since it was last loaded/refreshed.
2014-03-24 19:48:22 -03:00
Mark Walters
941e172724 emacs: show: mark tags changed since buffer loaded
This allows (and requires) the original-tags to be passed along with
the current-tags to be passed to notmuch-tag-format-tags. This allows
the tag formatting to show added and deleted tags.By default a removed
tag is displayed with strike-through in red (if strike-through is not
available, eg on a terminal, inverse video is used instead) and an
added tag is displayed underlined in green.

If the caller does not wish to use the new feature it can pass
current-tags for both arguments and, at this point, we do exactly that
in the three callers of this function.

Note, we cannot tidily allow original-tags to be optional because we would
need to distinguish nil meaning "we are not specifying original-tags"
from nil meaning there were no original-tags (an empty list).

We use this in subsequent patches to make it clear when a message was
unread when you first loaded a show buffer (previously the unread tag
could be removed before a user realised that it had been unread).

The code adds into the existing tag formatting code. The user can
specify exactly how a tag should be displayed normally, when deleted,
or when added.

Since the formatting code matches regexps a user can match all deleted
tags with a ".*" in notmuch-tag-deleted-formats.  For example setting
notmuch-tag-deleted-formats to '((".*" nil)) tells notmuch not to show
deleted tags at all.

All the variables are customizable; however, more complicated cases
like changing the face depending on the type of display will require
custom lisp.

Currently this overrides notmuch-tag-deleted-formats for the tests
setting it to '((".*" nil)) so that they get removed from the display
and, thus, all tests still pass.
2014-03-24 19:48:04 -03:00
Mark Walters
d5acfdda5f emacs: tag: add customize for deleted/added tag formats
Add customize options for deleted/added tag formats.  These are not
used yet but will be later in the series.

We switch to using `notmuch-apply-face' rather than `propertize' in
the defcustom for faces so that the faces for deleted/added tags add
to the default face attributes for the tag.

We special case deleting the unread tag as that tag is a strong visual
cue and we don't need that cue when we are just saying it used to be
unread. Thus, we revert to the normal tag face with strikethough for
deleted unread tags.
2014-03-24 19:47:49 -03:00
Mark Walters
b9a777e0a3 emacs: tag split customise option for format-tags into a widget
We will re-use the customize option for format-tags for formattting
deleted tags to added tags in the next patch so split it into a
widget. There should be no functional change.
2014-03-24 19:47:35 -03:00
Austin Clements
7023466ece Make keys of notmuch-tag-formats regexps and use caching
This modifies `notmuch-tag-format-tag' to treat the keys of
`notmuch-tag-formats' as (anchored) regexps, rather than literal
strings.  This is clearly more flexible, as it allows for prefix
matching, defining a fallback format, etc.  This may cause compatibility
problems if people have customized `notmuch-tag-formats' to match tags
that contain regexp specials, but this seems unlikely.

Regular expression matching has quite a performance hit over string
lookup, so this also introduces a simple cache from exact tags to
formatted strings.  The number of unique tags is likely to be quite
small, so this cache should have a high hit rate.  In addition to
eliminating the regexp lookup in the common case, this cache stores
fully formatted tags, eliminating the repeated evaluation of potentially
expensive, user-specified formatting code.  This makes regexp lookup at
least as fast as assoc for unformatted tags (e.g., inbox) and *faster*
than the current code for formatted tags (e.g., unread):

                    inbox (usec)   unread (usec)
    assoc:              0.4            2.8
    regexp:             3.2            7.2
    regexp+caching:     0.4            0.4

(Though even at 7.2 usec, tag formatting is not our top bottleneck.)

This cache must be explicitly cleared to keep it coherent, so this adds
the appropriate clearing calls.
2014-03-24 19:43:00 -03:00
Austin Clements
dfab8e5e49 emacs: Combine notmuch-combine-face-text-property{, -string}
This combines our two face combining functions into one, easy to use
function with a much shorter name: `notmuch-apply-face'.  This
function takes the full set of arguments that
`notmuch-combine-face-text-property' took, but takes them in a more
convenient order and provides smarter defaults that make the function
easy to use on both strings and buffers.
2014-03-24 19:42:33 -03:00
Jani Nikula
14d3251b9c emacs: add path: prefix to query completion
Complete to the new path: prefix.
2014-03-23 07:49:50 -03:00
Jani Nikula
ec13bd12e3 emacs: use the originating buffer's working directory for pipe
Currently notmuch-show-pipe-message runs the command in the working
directory of the *notmuch-pipe* buffer if it exists, and the current
buffer's working directory (which is inherited to the new
*notmuch-pipe* buffer) otherwise. This is all very surprising to the
user, and it's difficult to know or change where the command will be
run.

Always use the current show buffer's working directory for piping. The
user can check that with M-x pwd and change it with M-x cd. This is
consistent with notmuch-show-pipe-part.
2014-03-04 20:00:50 -04:00
Austin Clements
ed720f4e6d emacs: Simplify and fix `notmuch-mua-prompt-for-sender'
`notmuch-mua-prompt-for-sender' is over-engineered and often wrong.
It attempts to detect when all identities have the same name and
specialize the prompt to just the email address part.  However, to do
this it uses `mail-extract-address-components', which is meant for
displaying email addresses, not general-purpose parsing, and hence
performs many canonicalizations that can interfere with this use.  For
example, configuring notmuch-identities to ("Austin
<austin@example.com>"), will cause `notmuch-mua-prompt-for-sender' to
lose the name part entirely and return " <austin@example.com>".

This patch rewrites `notmuch-mua-prompt-for-sender' to simply prompt
for a full identity when notmuch-identities is configured, or to
prompt for a sender address when it isn't.

The original code also did several strange things, like using `eval'
and specifying that this function was interactive.  As a side-effect,
this patch fixes these problems.  And it adds a docstring.
2014-03-04 19:59:35 -04:00
David Bremner
75d84dfd84 emacs: remove newlines from input to notmuch count --batch
Since a newline starts a new query in batch mode, this causes
mysterious crashes in the emacs interface if saved searches contain
newlines.  See the discussion at

      id:87wqhcxb5j.fsf@maritornes.cs.unb.ca

In general newlines seem to be just whitespace to the xapian query
parser, so this should be mainly harmless.
2014-02-25 20:53:19 -04:00
Austin Clements
4b2ec627eb emacs: Fix `notmuch-user-other-email' when no other emails are configured
Thanks to the previous patch, this no longer crashes in this
situation, but now would return ("").  Fix it to return () when no
emails are configured.
2014-02-22 19:51:13 -04:00
Austin Clements
4b734374fb emacs: Fix exception when fetching empty or unconfigured settings
When "notmuch config" is called with the name of an empty or
unconfigured setting, it prints nothing (not even a new line).
Previously, `notmuch-config-get' assumed it would always print a
newline.  As a result, when `notmuch-config-get' was called with the
name of an empty of unconfigured setting, it would attempt to
(substring "" 0 -1) to strip the newline, which would fail with a
(args-out-of-range "" 0 -1) exception.

Fix this by only stripping the newline if there actually is one.
2014-02-22 19:51:03 -04:00
Austin Clements
1326ec09ee emacs: Build forwarded message buffer more directly
Previously, we used `message-forward' to build forwarded messages, but
this function is simply too high-level to be a good fit for some of
what we do.

First, since `message-forward' builds a full forward message buffer
given the message to forward, we have to duplicate much of the logic
in `notmuch-mua-mail' to patch the notmuch-y things into the built
buffer.

Second, `message-forward' constructs the From header from
user-full-name and user-mail-address.  As a result, if we prompt the
user for an identity, we have to parse it into name and address
components, just to have it put back together by `message-forward'.
This process is not entirely loss-less because
`mail-extract-address-components' does a lot of canonicalization
(since it's intended for displaying addresses, not for parsing them).

To fix these problems, don't use `message-forward' at all.
`message-forward' itself is basically just a call to `message-mail'
and `message-forward-make-body'.  Do this ourselves, but call
`notmuch-mua-mail' instead of `message-mail' so we can directly build
a notmuch-y message and control the From header.

This also fixes a bug that was a direct consequence of our use of
`mail-extract-address-components': if the user chose an identity that
had no name part (or the name part matched the mailbox), we would bind
user-full-name to nil, which would cause an exception in the bowels of
message-mode because user-full-name is expected to always be a string
(even if it's just "").
2014-02-22 19:50:55 -04:00
Austin Clements
7c0a1b4d60 emacs: Avoid rebuilding .eldeps even when there's nothing to do
Previously, we updated .eldeps only if the file contents actually
needed to change.  This was done to avoid unnecessary make restarts
(if the .eldeps rule changes the mtime of .eldeps, make has to restart
to collect the new dependencies).  However, this meant that, after a
modification to any .el file that did not change dependencies, .eldeps
would always be out of date, so every make invocation would run the
.eldeps rule, which is both expensive because it starts up Emacs and
noisy.  This was true even when there was nothing to do.  E.g.,

$ make clean && make
...
$ touch emacs/notmuch-lib.el && make
...
$ make
Use "make V=1" to see the verbose compile lines.
EMACS emacs/.eldeps
make: Nothing to be done for `all'.
$ make
Use "make V=1" to see the verbose compile lines.
EMACS emacs/.eldeps
make: Nothing to be done for `all'.

Fix this by replacing .eldeps with two files with identical content.
One tracks the mtime of the dependency information and triggers the
Emacs call to rebuild dependencies only when it may be necessary.  The
other tracks the content only; this rule over-triggers in the same way
the old rule did, but this rule is cheap and quiet.
2014-02-21 21:07:23 -04:00
Jed Brown
718d58ade0 emacs: update alist for mail-archive.com API change
Searching by Message-Id no longer works via the old mail-archive.com
API, though I have contacted them in hopes that they restore it to
prevent dead links.  Anyway, the new API is cleaner.

Acked-by: Austin Clements <amdragon@MIT.EDU>
2014-02-16 18:55:24 -04:00
Tomi Ollila
9c1bc977d7 emacs: initialize ido(-completing-read) in emacs 23.[123]
Otherwise `ido-completing-read' will freeze after PROMPT is displayed.
2014-02-03 16:20:39 -04:00
Tomi Ollila
9ac863c549 emacs: ad-activate 'mm-shr after ad-disable-advice 'mm-shr
Imitated from "Enabling advice" in Emacs lisp manual...

ad-disable-advice by itself only changes the enable flag for a
piece of advice. To make the change take effect in the
advised definition, the advice needs to be activated again.
2014-01-30 12:21:25 -04:00
David Bremner
1c2f2c960c emacs: add notmuch-assert-cli-sane to notmuch-hello
This is meant to be the friendly entrypoint, so let's do something
better than the mangled output described in

       id:5228989D.8030607@fifthhorseman.net
2014-01-26 15:10:30 -04:00
David Bremner
71d809ac9a emacs: add function notmuch-assert-cli-sane
If the CLI seems borked, signal an error, and log a suggestion for the
user about how to recover.
2014-01-26 15:10:30 -04:00
David Bremner
71d6a40581 emacs: add a function to heuristically test if the CLI is configured OK.
We cache the result so that we can call the function many places
without worrying about the cost.
2014-01-26 15:10:29 -04:00
Mark Walters
17e44cd584 emacs: tree: use tag-format-tags
Previously tree did not use tag-format-tags: since tree wants to
distinguish matching messages from non-matching messages it is not a
perfect fit.

However, in preparation for allowing tag-changes to be shown (i.e.,
added or deleted tags to be indicated) it is convenient to make all
places displaying tags call the same routines.

We modify notmuch-tag-format-tags slightly so that it can take and
argument for the default characteristics of the face before the
special tag features are applied.

This also means that things like the star symbol for flagged messages
all work in tree.
2014-01-18 14:41:50 -04:00
Mark Walters
3c231e7e49 emacs: tree: default face for matching/non-matching messages
This adds default faces for matching and non-matching messages. This
makes it easier for a user to do broad customization without having to
customize every field. It also fits more neatly with the next patch
which switches to using notmuch-tag-format-tags for tag formatting.

We set the field specific face customization to nil for all the fields
which use the message default face to make it clear to a user which
fields customizations are being used.
2014-01-18 14:41:19 -04:00
Mark Walters
719391f09a emacs: tree remove comma separator tags
Previously the tags on each line in tree view were separarted by ", "
not just " ". This is different from show and search views.

This patch removes this comma. This is a large patch as essentially
every line of each of the expected outputs in the tree tests needs
updating.

Apart from aesthetic reasons this simplifies the switch to
notmuch-tag-format-tags in the next patch.
2014-01-13 14:12:29 -04:00
Tomi Ollila
f2a3d9799d emacs: Makefile.local: HAVE_EMACS usage fixes
If we don't have emacs, disable targets that used EMACS while doing
the recipes of that target.

If we do have emacs, make install-emacs depend on *.elc files,
as making the target will attempt to install those.
2014-01-13 14:12:05 -04:00
Mark Walters
e36284d72d emacs: tree: bare-id in tree
Previously notmuch-tree-get-message-id always returned the id
including the prefix "id:". Modify the function to take an optional
`bare' argument saying to return the raw string.

This will be useful later and brings the function in line with
notmuch-show-get-message-id.
2014-01-03 07:12:28 -04:00
Mark Walters
6d6006bea9 emacs: add '?' to some prefix keymaps to describe its bindings
Added function notmuch-subkeymap-help to describe keybindings of a
subkeymap (eg after . or c in notmuch-search and notmuch-show).
2013-12-10 03:52:54 +08:00
Mark Walters
9c25d4bbf0 emacs: show: stop stderr appearing in buffer
In emacs 24.3+ the stdout/stderr from externally displaying an
attachment gets inserted into the show buffer. This is caused by
changes in mm-display-external in mm-decode.el.

Ideally, we would put this output in the notmuch errors buffer but the
handler is called asynchronously so we don't know when the output will
appear. Thus if we put it straight into the errors buffer it could get
interleaved with other errors. Also we can't easily tell when we
have got all the error output so can't wait until the process is complete.

One solution would be to create a new buffer for the stderr of each
attachment viewed. Again, since we can't tell when the process has
finished, we can't close these buffers automatically so this will
leave lots of buffers around.

Thus we add a debug variable notmuch-show-attachment-debug: it this is
non-nil we create a new buffer for each viewer; if this variable is
nil we just use a temp buffer which means all error output is
discarded (this is the same behaviour as with emacs pre 24.3).
2013-11-20 18:14:35 -04:00