Commit graph

130 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Jameson Graef Rollins
cbba1d1ba9 emacs: do not modify subject in search or show
A previous patch [0] replaced blank subject lines with '[No Subject]'
in search and show mode.  Apparently this was needed to circumvent
some bug in the printing code, but there was no need for it search or
show, and it is definitely not desirable, so we undo it here (a revert
is no longer feasible).  We should not be modifying strings in the
original message without good reason, or without a clear indication
that we are doing so, neither of which apply in this case.  For
further discussion see [0].

[0] id:"1327918561-16245-3-git-send-email-dme@dme.org"
2012-04-28 23:30:59 -03:00
Jameson Graef Rollins
5073de34b4 emacs: modify help message for notmuch-search-line-faces to reflect preferred "deleted" tag name.
No functional change here.  The help message previously referred to
the "delete" tag, but "deleted" is now preferred, so hopefully this
will reduce any potential confusion.
2012-04-24 23:25:51 -03:00
Jameson Graef Rollins
6c84116091 emacs: have tag-completion return all tags for nil input
Previously the function would fail if the initial input was nil.  Now
it will return a list of all tags, which obviously makes much more
sense.
2012-04-12 15:34:49 -03:00
Jameson Graef Rollins
8225ff21ec emacs: include tags from excluded messages in tag tab completion
The new message exclude functionality will hide tags that only exist
on excluded messages.  However, one might very well want to manually
modify excluded tags.  This makes sure tags from excluded messages are
always available in tab completion.
2012-04-12 08:43:22 -03:00
Jameson Graef Rollins
1d4758e21f emacs: update call in tag-completion function
"search-tags" is deprecated, so use the more modern and supported
"search --output=tags".
2012-04-12 08:42:55 -03:00
Austin Clements
0eaf4a21dd emacs: Fix search tab completion in terminals
In X, Emacs distinguishes the tab key, which produces a 'tab event;
from C-i, which produces a ?\t event.  However, in a terminal, these
are indistinguishable and only produce a ?\t event.  In order to
simplify things, Emacs automatically translates from 'tab to ?\t (see
"Function key translations" in M-x describe-bindings), so functions
only need to be bound to ?\t to work in all situations.

Previously, the search tab completion code usedq (kbd "<tab>"), which
produced the event sequence [tab], which only matched the 'tab event
and hence only worked in X.  This patch changes it to (kbd "TAB"),
which matches the general ?\t event and works in all situations.
2012-03-18 09:14:23 -03:00
Mark Walters
1aa4abe7a1 emacs: notmuch.el ignore excluded matches
This is a small change to make notmuch.el ignore excluded matches.  In
the future it could do something better like add a button for
rerunning the search with the excludes (particularly if nothing
matches with the excludes) or having them invisible and allowing the
visibility to be toggled.
2012-03-02 08:38:27 -04:00
Michal Sojka
e4ceb19cc7 emacs: Fix display of highlighted line in notmuch-search
When notmuch-search-line-faces is used to set background color in search
results, the highlight of the current line is not always displayed
correctly. This patch fixes that by increasing the priority property of
the highlight overlay.
2012-02-17 08:03:26 -04:00
David Edmondson
19ec74c50e emacs: Rework crypto switch toggle.
Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
2012-02-12 11:58:21 -05:00
Jani Nikula
e06943f85e emacs: add default value to notmuch-search-line-faces
Add default value to notmuch-search-line-faces to show "unread"
messages in bold, and "flagged" messages in blue, to have some visual
indication of important messages in search results. This should be
helpful for new users.

"unread" tag is quite obvious, and handled specially both in the lib
and emacs ui. "flagged" is synced to maildir F flag in the lib. If one
syncs the maildir to IMAP, this also translates to corresponding IMAP
flag. (This is "starred" in GMail and Android.)

Signed-off-by: Jani Nikula <jani@nikula.org>
2012-02-12 11:58:20 -05:00
Dmitry Kurochkin
6e59a5630f emacs: s/tags/tag-changes/ for arguments of tagging functions
This makes the argument names more consistent and clear.  The
following functions changed: `notmuch-tag',
`notmuch-search-tag-thread', `notmuch-search-tag-region' and
`notmuch-search-tag-all'.
2012-02-08 11:22:44 -04:00
Dmitry Kurochkin
9d8fa2acac emacs: accept empty tag list in `notmuch-tag'
Since `notmuch-tag' is a non-interactive function and hence is meant
to be invoked programmatically, it should accept zero tags.  Also, the
tagging operations (bound to "*", "+", "-") would accept empty input
without an error.
2012-02-08 11:21:52 -04:00
Dmitry Kurochkin
26fce4ae60 emacs: relax tag syntax check in `notmuch-tag' function
The tag syntax check in `notmuch-tag' function was too strict and did
not allow nmbug tags with "::".  Since the check is done for all
tagging operations in Emacs UI, this basically means that no nmbug
tags can be changed.  The patch relaxes the tag syntax check to allow
any tag names that do not include whitespace characters.
2012-02-08 11:19:23 -04:00
Dmitry Kurochkin
904eafaefc emacs: separate history for operations which accept single and multiple tags
Some tag-related operations accept a single tag without prefix
(`notmuch-select-tag-with-completion'), others accept multiple tags
prefixed with '+' or '-' (`notmuch-read-tag-changes').  Before the
change, both functions used a single default minibuffer history.  This
is inconvenient because you have to skip options with incompatible
format when going through the history.  The patch adds separate
history lists for the two functions.  Note that functions that accept
the same input format (e.g. "+", "-", "*") share the history list as
before.
2012-02-08 11:18:37 -04:00
Dmitry Kurochkin
f643f1bac0 emacs: rename notmuch-search-operate-all' to notmuch-search-tag-all'
`Notmuch-search-tag-all' is more clear and consistent with other
tagging function names.
2012-02-08 11:16:04 -04:00
Dmitry Kurochkin
2beaefa2ec emacs: make "+" and "-" tagging operations in notmuch-search more flexible
Before the change, "+" and "-" tagging operations in notmuch-search
view accepted only a single tag.  The patch makes them use the
recently added `notmuch-read-tag-changes' function (renamed
`notmuch-select-tags-with-completion'), which allows to enter multiple
tags with "+" and "-" prefixes.  So after the change, "+" and "-"
bindings in notmuch-search view allow to both add and remove multiple
tags.  The only difference between "+" and "-" is the minibuffer
initial input ("+" and "-" respectively).
2012-02-08 11:08:43 -04:00
Dmitry Kurochkin
b3eafaf725 emacs: remove text properties from `notmuch-search-get-tags' result 2012-02-08 11:08:22 -04:00
Dmitry Kurochkin
0adf05f578 emacs: move tag format validation to `notmuch-tag' function
Before the change, tag format validation was done in
`notmuch-search-operate-all' function only.  The patch moves it down
to `notmuch-tag', so that all users of that function get input
validation.
2012-02-08 11:08:09 -04:00
David Edmondson
6bd3d8af54 emacs: Prefer '[No Subject]' to blank subjects. 2012-02-03 21:20:15 -04:00
David Edmondson
e516a712bb emacs: Stop the `truncate-string-to-width' madness.
There's no need to call `truncate-string-to-width' twice in this code
path.
2012-02-03 21:19:00 -04:00
Pieter Praet
2dcd1e7234 emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."
Less code, same results, without sacrificing readability.
2012-02-01 21:29:17 -04:00
Dmitry Kurochkin
58d714e5ce emacs: `notmuch-search-operate-all' code cleanup, no functional changes 2012-01-27 07:46:05 -04:00
Dmitry Kurochkin
f764bbd544 emacs: add completion to "tag all" operation ("*" binding)
The patch adds <tab> completion to "tag all" operation bound to "*"
(`notmuch-search-operate-all' function).
2012-01-27 07:45:40 -04:00
Dmitry Kurochkin
bc267b70b0 emacs: use a single history for all searches
There are two ways to do search in Emacs UI: search widget in
notmuch-hello buffer and `notmuch-search' function bound to "s".
Before the change, these search mechanisms used different history
lists.  The patch makes notmuch-hello search use the same history list
as `notmuch-search' function.
2012-01-25 08:33:39 -04:00
Jameson Graef Rollins
4ba787bca2 emacs: have notmuch-search-archive-thread use -next-thread function
Use this standard function, to keep thread navigation in one place.
2012-01-25 07:17:12 -04:00
Tomi Ollila
37dec7d7b3 emacs/*.el: changed one-char comment prefix ';' to two; ';;'
In order for emacs (indent-region) to (re)indent emacs lisp
properly there needs to be at least 2 comment characters (;;).
2012-01-21 14:06:17 -04:00
Pieter Praet
046f5dded2 emacs: globally replace non-branching "(if (not ..." with "(unless ..."
Less code, same results, without sacrificing readability.
2012-01-21 08:17:56 -04:00
Pieter Praet
643ce61c1b emacs: logically group def{custom,face}s
To allow for expansion whilst keeping everything tidy and organized,
move all defcustom/defface variables to the following subgroups,
defined in notmuch-lib.el:

- Hello
- Search
- Show
- Send
- Crypto
- Hooks
- External Commands
- Appearance

As an added benefit, defcustom keyword args are now consistently
ordered as they appear @ defcustom's docstring (OCD much?).

Proper defgroup docstrings and various other improvements
by courtesy of Austin Clements.
2012-01-19 09:27:02 -04:00
David Edmondson
ef5c1d73f8 emacs: Cycle through notmuch buffers rather than jumping to the last.
As suggested by j4ni in #notmuch, rename
`notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
have it behave accordingly.

Consider `message-mode' buffers to be of interest.
2012-01-15 22:32:14 -04:00