Commit graph

585 commits

Author SHA1 Message Date
Mark Walters
141f3813d8 emacs: help: split out notmuch-describe-key as a function
The actual documentation function notmuch-describe-keymap was getting
rather complicated so split out the code for a single key into its own
function notmuch-describe-key.
2013-11-13 21:46:32 -04:00
Mark Walters
9d0174b11c emacs: help: remove duplicate bindings
If the user (or a mode) overrides a keybinding from the common keymap
in one of the modes then both help lines appear in the help screen
even though only one of them is applicable.

Fix this by checking if we already have that key binding. We do this
by constructing an list of (key . docstring) pairs so it is easy to
check if we have already had that binding. Then the actual print help
routine changes these pairs into strings "key \t docstring"
2013-11-13 21:33:28 -04:00
Mark Walters
6f616bd733 emacs: help: save-match-data
The routines that construct the help page in notmuch-lib rely on
match-data being preserved across some fairly complicated code. This
is currently valid but will not be when this series is finished. Thus
place everything between the string-match and replace-match inside a
save-match-data.
2013-11-13 21:33:14 -04:00
Mark Walters
a5ecdf390e emacs: help: check for nil key binding
A standard way to unset a key binding is local-unset-key which is equivalent to
  (define-key (current-local-map) key nil)

Currently notmuch-help gives an error and fails if a user has done this.

To fix this we only add a help line if the binding is non-nil.
2013-11-13 21:33:05 -04:00
Austin Clements
9ecfc1c426 emacs: Correct documentation of `notmuch-poll-script'
The functions referred to in the documentation for this variable were
replaced by the unified `notmuch-poll-and-refresh-this-buffer' in
21474f0e.  Update the documentation to reflect the new function.
2013-11-13 21:27:51 -04:00
Austin Clements
96c0ce28f8 emacs: Fix search tagging races
This fixes races in thread-local and global tagging in notmuch-search
(e.g., "+", "-", "a", "*", etc.).  Previously, these would modify tags
of new messages that arrived after the search.  Now they only operate
on the messages that were in the threads when the search was
performed.  This prevents surprises like archiving messages that
arrived in a thread after the search results were shown.

This eliminates `notmuch-search-find-thread-id-region(-search)'
because these functions strongly encouraged racy usage.

This fixes the two broken tests added by the previous patch.
2013-11-08 20:52:00 -04:00
Austin Clements
730b8f61e0 emacs: Use notmuch tag --batch for large tag queries
(Unfortunately, it's difficult to first demonstrate this problem with
a known-broken test because modern Linux kernels have argument length
limits in the megabytes, which makes Emacs really slow!)
2013-11-08 20:35:13 -04:00
Austin Clements
662e097984 emacs: Support passing input via `notmuch-call-notmuch-*'
This adds support for passing a string to write to notmuch's stdin to
`notmuch-call-notmuch-process' and `notmuch-call-notmuch-sexp'.  Since
this makes both interfaces a little more complicated, it also unifies
their documentation better.
2013-11-08 20:28:44 -04:00
Austin Clements
ddc44ae0d0 emacs: Move `notmuch-call-notmuch-process' to notmuch-lib
Previously, this was in notmuch.el, but all of the other notmuch call
wrappers were in notmuch-lib.el.  Move `notmuch-call-notmuch-process'
to live with its friends.  This happens to fix a missing dependency
from notmuch-tag.el, which required notmuch-lib, but not notmuch.
2013-11-08 20:23:03 -04:00
Mark Walters
3cf926463e emacs: move the show entry to tree into show.el
Move the keybinding and show specific helper from tree.el to show.el
2013-11-07 08:01:22 -04:00
Mark Walters
31d81f7fdd emacs: add z to common keymap
Add the main entry "z" to notmuch-tree to the common keymap.
2013-11-07 08:01:07 -04:00
Mark Walters
00b3ee4f82 emacs: move search based tree functions to notmuch.el
Move a couple of the search mode specifc caller helpers for tree from
tree into notmuch.el.
2013-11-07 07:52:43 -04:00
Mark Walters
6661206381 emacs: minimal change to load notmuch-tree by default
We want to load notmuch-tree when notmuch is loaded, so include it as
a require in notmuch.el. To avoid circular dependency we need to move
one keybinding from notmuch-tree.el to notmuch.el: it makes sense for
it to be defined there anyway.

Since tree is now loaded by default there is no need to print a
message when it is loaded.
2013-11-07 07:47:25 -04:00
Mark Walters
6e56912d13 emacs: add tree to the makefile 2013-11-07 07:39:52 -04:00
Mark Walters
bb5fb8ea25 emacs: move notmuch-tree from contrib to mainline 2013-11-07 07:31:55 -04:00
Mark Walters
52faf1f993 emacs: move notmuch-help to lib
notmuch-help is in notmuch.el not notmuch-lib.el and this is
incovenient for the way pick/tree uses it. I think lib makes more
sense anyway so move it there.
2013-11-07 07:16:47 -04:00
Austin Clements
9f9a63c863 emacs: Add a space after completed tag operations
Previously, when a user fully completed a tag operation, they had to
press space to begin entering another tag operation.  This is
different from, say, shell file name completion, which typically
inserts a space after an unambiguous completion under the assumption
that the user will want to enter more input.

This patch tweaks `notmuch-read-tag-changes' to act more like shell
file name completion: after an unambiguous tag completion, it now
inserts a space, ready and waiting for another tagging operation from
the user.  This is backwards-compatible with old habits, since there's
no harm in putting an extra space.
2013-10-27 17:35:58 -03:00
Austin Clements
a7964c86d1 emacs: Sanitize authors and subjects in search and show
Authors and subjects can contain embedded, encoded control characters
like "\n" and "\t" that mess up display.  Transform control characters
into spaces everywhere we display them in search and show.
2013-10-27 09:31:29 -03:00
Austin Clements
45444eebe5 emacs: Remove interactive behavior of `notmuch-tag'
We no longer use this, since we've lifted all interactive behavior to
the appropriate interactive entry points.  Because of this,
`notmuch-tag' also no longer needs to return the tag changes list,
since the caller always passes it in.
2013-10-25 21:31:20 -03:00
Austin Clements
22172daa17 emacs: Use interactive specifications for tag changes in search
This is similar to the previous commit, but applies to search.

Search is somewhat more complicated because its tagging operations can
also apply to a region.  Hence, this lifts interactive prompting into
a helper function.  This also takes advantage of the new ability to
provide a prompt to distinguish tagging a single thread from tagging a
region of threads.
2013-10-25 21:26:30 -03:00
Austin Clements
47792533b3 emacs: Use interactive specifications for tag changes in show
This modifies all tagging operations in show to call
`notmuch-read-tag-changes' in their interactive specification to input
tag changes, rather than depending on lower-level functions to prompt
for tag changes regardless of their calling context.

Besides being more Elispy and providing a more consistent programmatic
API, this enables callers to provide two call site-specific pieces of
information: an appropriate prompt, and the set of visible tags.  The
prompt lets us differentiate * from +/-.  Providing visible tags
enables a more consistent user experience than retrieving the
(potentially different) tags from the database, and avoids a
round-trip to the CLI and database.
2013-10-25 21:26:13 -03:00
Austin Clements
0f8d5b6b0e emacs: Take prompt and current tags in `notmuch-read-tag-changes'
This modifies the interface of `notmuch-read-tag-changes' to take an
optional prompt string as well as a list of existing tags instead of a
query.  This list of tags is used to populate the tag removal
completions and lets the caller compute these in a more
efficient/consistent manner than performing a potentially large or
complex query.  This patch also updates the sole current caller of
`notmuch-read-tag-changes'.
2013-10-25 21:25:52 -03:00
Austin Clements
440b8065c9 emacs: Fix misuse of `notmuch-tag'
The calling convention for `notmuch-tag' changed in commit 97aa3c06 to
take a list of tag changes instead of a &rest argument, but the call
from `notmuch-search-tag-all' still passed a &rest argument.  This
happened to work for interactive calls because tag-changes would be
nil, so the `apply' call would pass only the query string to
`notmuch-tag' and simply omit the &optional tag-changes argument.
2013-10-25 21:25:37 -03:00
Mark Walters
99d474c484 emacs: show: use interactive instead of current-prefix-arg
Currently notmuch-show looks at the prefix-arg directly via
current-prefix-arg. This changes it to use the interactive
specification.

One test (for elide-toggle functionality) set the prefix arg
directly. Update this test to set the new argument directly.
2013-10-19 22:42:49 -03:00
Gregor Zattler
6878b0b2aa emacs: distinguish tag `flagged' on terminal
Change foreground color to `blue' like lines representing threads
with flagged messages in notmuch-search.  Before tag `flagged' was
shown in notmuch-show buffers as image star on graphical frames while
there was no visible distinction to other flags on terminal frames.
2013-10-12 08:40:39 -03:00
Austin Clements
459c586967 emacs: Improved `notmuch-describe-keymap' documentation 2013-10-10 07:42:54 -03:00
Austin Clements
c1221dd65a emacs: Improve interactive use documentation
This improves the function documentation for many interactive
commands, either by improving their documentation string where the
improvement also makes sense for programmatic use or by adding a
'notmuch-doc property where it doesn't.

For nearly all commands that support a prefix argument, this adds a
'notmuch-prefix-doc property to document their prefixed behavior This
omits prefix documentation for a few commands where I thought the
prefixed behavior was too obscure (or too complex to fit in one line).
2013-10-07 20:32:08 -03:00
Austin Clements
fad4f21cb7 emacs: Support overriding help and describing prefix action
Traditionally, function documentation strings are intended primarily
for programmers, rather than users.  They're written from the
perspective of calling the function, not interactively invoking it.
They're only ever displayed along with the function prototype (and
often refer to argument names).  And built-in help commands like
`describe-bindings' show the name of the command, not its
documentation.

The notmuch help system is like `describe-bindings', but tries to be
more user-friendly by displaying documentation strings, rather than
Elisp command names.  For most commands, this is fine, but for some
the "programmer description" is inappropriate for interactive use.
This is particularly noticeable for commands that take an optional
prefix argument.

This patch adds support for two symbol properties: notmuch-doc and
notmuch-prefix-doc, which let a command override its interactive
documentation and provide separate documentation for its prefixed
invocation.  If notmuch-prefix-doc is present, we add an extra line to
the help giving the prefixed key sequence along with the documentation
for the prefixed command.
2013-10-07 20:31:53 -03:00
Austin Clements
adfff87a71 emacs: Clean up a few documentation strings
Correct some grammatical errors, fix some violations of standard
documentation string formatting conventions, and be more precise.
2013-10-07 20:31:40 -03:00
Austin Clements
e1fba87327 emacs: `notmuch-mua-new-reply' is also not interactive
Like `notmuch-mua-new-forward-message', this is meant to be invoked
programmatically by something that can provide a reasonable query
string.

In fact, `notmuch-mua-new-reply's interactive specification didn't
match its arguments, so it wouldn't have worked interactively.
2013-10-07 20:31:28 -03:00
Austin Clements
0a84aaec6f emacs: `notmuch-mua-new-forward-message' is not interactive
`notmuch-mua-new-forward-message' must be called from a buffer
containing a raw RFC2822-formatted message to forward.  Hence, it's
intended to be invoked programmatically through something else that
sets up this buffer (like `notmuch-show-forward-message'), not
interactively.

Remove its interactive specification and update the documentation
string to mention the requirements on the current buffer.
2013-10-07 20:31:16 -03:00
Mark Walters
302120362e emacs: bugfix unquoted symbol
In the recent changes for search order handling the default-value of
notmuch-search-oldest-first was used. However, default-value needs a
symbol so the symbol-name needs to be quoted.

This missing quote was causing strange sort-orders in some cases.
2013-09-15 08:55:14 -03:00
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