Commit graph

660 commits

Author SHA1 Message Date
David Edmondson
7585e8c906 emacs: with-current-notmuch-show-message' should not leak coding-system-for-read'
`with-current-notmuch-show-message' applies a `no-conversion' coding
system when reading a raw message from notmuch. That coding system
should _not_ be applied when the body of the macro is evaluated, as it
can cause file operations used during that evaluation to incorrectly
apply the `no-conversion' coding system.

This was discovered when a user's .signature file contained non-ASCII
characters. When a message is forwarded, the `no-conversion' coding
system was applied to the reading of the .signature file, resulting in
raw rather than UTF-8 interpretation of the data.
2014-11-26 18:26:07 +01:00
Mark Walters
78a1575aa4 emacs: show: document the mark unread defcustom function 2014-11-09 16:08:58 +01:00
David Edmondson
30f1c43efe emacs: Improve the behaviour of the 'q' binding.
When a user hits 'q' in a notmuch buffer, kill the buffer only if
there are no other windows currently showing it.
2014-10-31 17:54:21 +01:00
David Edmondson
961937988e emacs: notmuch-jump.el should provide.
To ease loading, notmuch-jump.el should provide 'notmuch-jump.
2014-10-25 19:55:16 +02:00
Mark Walters
b2caa125ee emacs: jump: fix compile warning on emacs 23
notmuch-jump uses window-body-width which is not defined in emacs
23. To get around this it does

(unless (fboundp 'window-body-width)
  ;; Compatibility for Emacs pre-24
  (defalias 'window-body-width 'window-width))

This makes sure window-body-width is defined and all should be
well. But it seems that the byte compiler does not realise that this
guarantees that window-body-width will be defined and so, when
compiling with emacs 23, it gives an error

In end of data:
notmuch-jump.el:172:1:Warning: the function `window-body-width' is not known to be defined.

Domo and I came to following on irc: wrap the (unless (fboundp ...))
inside eval-and-compile which ensures that both the test and the
defalias (if needed) happen at both compile and load time.  This fixes
the warning.
2014-09-24 19:55:36 +02:00
Austin Clements
5673fdbdfa emacs: Fix coding system in `notmuch-show-view-raw-message'
This fixes the known-broken test of viewing 8bit messages added by the
previous commit.
2014-09-21 21:23:45 +02:00
Austin Clements
0b94dd7fd3 emacs: Remove redundant NTH argument from `notmuch-get-bodypart-content'.
This can be derived from the PART argument (which is arguably
canonical), so there's no sense in giving the caller an extra foot
gun.
2014-09-21 21:23:45 +02:00
Mark Walters
5c4f6ed99b emacs: jump: sort-order bugfix
default-value needs its argument to be quoted.

Slightly strangely default-value of 't or nil is 't or nil
respectively so the code

(default-value notmuch-search-oldest-first)

just gives the current value of notmuch-search-oldest-first rather
than intended default-value of this variable.

The symptom is that if you are in a search buffer and use notmuch jump
to run a saved search which does not have an explicitly set sort order
then the sort order of the saved-search is inherited from the current
search buffer rather than being the default search order.

Thanks to Jani for finding the bug.
2014-09-07 20:02:16 +02:00
Austin Clements
c1845bf0a4 emacs: Improved compatibility for window-body-width in Emacs < 24
Fix byte compiler warning "Warning: the function `window-body-width'
is not known to be defined." by moving our compatibility wrapper
before its use and simplify the definition to a defalias for the old
name of the function.
2014-08-16 17:44:47 -07:00
Austin Clements
e501a16e71 emacs: Expand default saved searches and add shortcut keys
This should help new users off to a better start with the addition of
more sensible saved searches and default shortcut keys.  Most existing
users have probably customized this variable and won't be affected.
2014-08-05 08:07:52 -03:00
Austin Clements
3c1ad5bfa0 emacs: Introduce notmuch-jump: shortcut keys to saved searches
This introduces notmuch-jump, which is like a user-friendly,
user-configurable global prefix map for saved searches.  This provides
a non-modal and much faster way to access saved searches than
notmuch-hello.

A user configures shortcut keys in notmuch-saved-searches, which are
immediately accessible from anywhere in Notmuch under the "j" key (for
"jump").  When the user hits "j", the minibuffer immediately shows a
helpful table of bindings reminiscent of a completions buffer.

This code is a combination of work from myself (originally,
"notmuch-go"), David Edmondson, and modifications from Mark Walters.
2014-08-05 08:07:27 -03:00
Austin Clements
8251d639b2 emacs: Clarify that notmuch-poll-script is deprecated
notmuch-poll-script has long since been deprecated in favor of
post-new hooks, but this wasn't obvious from the documentation.
Update the documentation to make this clear.  Since
notmuch-poll-script could, to some extend, be used to control the path
of the notmuch binary and that use is now clearly discouraged, promote
notmuch-command to a real defcustom instead of just a variable.
2014-07-31 07:10:47 -03:00
Mark Walters
d25c729825 emacs: show: make return value of notmuch-show-get-prop explicit
This makes the fact the notmuch-show-get-prop returns nil if the major
mode is neither show not tree explicit.
2014-07-30 18:25:58 -03:00
Mark Walters
ebb58751dc emacs: tree/show remove duplicate function
tree overrides notmuch-show-get-prop so that it can use many of the
utility function directly. Now that tree is in mainline the version
from tree can be moved to show and the original overridden show
version dropped.
2014-07-16 06:33:17 -03:00
Mark Walters
f47eeac0b0 emacs: set default in notmuch-read-query
This adds the current query as a "default value" to
notmuch-read-qeury. The default value is available via a down-arrow as
opposed to history which is available from the up arrow.

Note if a user presses return in the minibuffer this value is not
returned.

The implementation is simple but notmuch-read-query could be called
via notmuch-search/notmuch-tree etc from any buffer so it makes sense
to put the decision of how to extract the current query in
notmuch-read-query rather than in each of the callers.
2014-07-15 20:32:49 -03:00
Mark Walters
ef819eb689 emacs: search archive tweak
notmuch-search-archive-thread moves to the next line after tagging. In
the normal case this makes sense, but if the region is active, it tags
the whole region and then it doesn't really. Thus only move to the
next line if region is not active.
2014-07-15 20:06:41 -03:00
Mark Walters
2e1eee3a77 emacs: show: add an update seen function to post-command-hook
Add a function for updating seen messages to the
post-command-hook. This function calls a customizable (by eg
defcustom) function with parameters the start and end of the current
window and that function can decide what to mark read based on that
and the current point.

Since this is in the post-command-hook it should get called after most
user actions (exceptions include user resizing the window) so it
should be possible to make sure the seen status gets updated whether
the user uses notmuch commands like next-message or normal emacs
commands like scroll-up.

It removes all of the old mark read/seen points but introduces a
simple example function that just marks the current message read if it
is open. This function has one small subtlety: it makes sure it
doesn't mark the same message read twice (in the same instance of the
same buffer); otherwise the post-command-hook makes it impossible for
a user to manually mark a message unread.

This fixes the current bugs (imo) that closed messages can be marked
read, and that opening a closed message does not mark it read.

Another advantage of using the post-command-hook any programmatic use
with point passing through a message will not mark it read.
2014-07-13 12:34:02 -03:00
David Edmondson
bc180bd388 emacs: Fix indentation.
Fix the indentation of `notmuch-show-mode-map'.
2014-07-13 12:32:06 -03:00
David Edmondson
b732a58a00 emacs: Forwarded messages should not have modified buffers
When the user begins forwarding a message, the resulting composition
buffer should not be marked as modified, in order that it can
immediately be killed without prompting.
2014-06-22 07:41:49 -03:00
David Bremner
9e7bc02530 Merge branch 'release'
still painfully slowly assembling 0.18.1
2014-06-15 15:52:18 -03:00
Tomi Ollila
f0ad36cb7f emacs install: make sure all components to be installed are there
`make install-emacs` will copy $(emacs_sources), $(emacs_images) and
$(emacs_bytecode) to their target directories. $(emacs_bytecode) was
already a prerequisite of make install-emacs as these obviously needed
to be build. Until a while ago all of $(emacs_sources) was available
in the repository, but now it includes `notmuch-version.el` which
is generated. In the future we may have generated emacs images too.
2014-06-15 15:40:51 -03:00
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