Commit graph

132 commits

Author SHA1 Message Date
Jonas Bernoulli
6fb7d35069 emacs: Remove excess empty lines
Most people who write lots of lisp tend to only sparsely use empty
"separator" lines within forms.  In lisp they feel unnecessary and
since most files stick to this convention we get a bit confused
when there are extra empty lines.  It feels like the s-expressions
are falling into pieces.

All of this is especially true between a function's doc-string and
body because the doc-string is colored differently, which visually
already separates it quite sufficiently from the code that follows.
2020-08-09 20:47:52 -03:00
Jonas Bernoulli
a4617f29ce emacs: Shorten long lines 2020-08-09 19:48:36 -03:00
Tomi Ollila
ed40579ad3 emacs docstrings: consistent indentation, newlines, periods
Fixed emacs docstrings to be consistent. No functional change.

- removed some (accidental) indentation
- removed some trailing newlines
- added trailing periods where missing (some exclusions)
2020-06-06 07:55:58 -03:00
Jonas Bernoulli
11ac932a45 emacs: Use cl-lib' instead of deprecated cl'
Starting with Emacs 27 the old `cl' implementation is finally
considered obsolete.  Previously its use was strongly discouraged
at run-time but one was still allowed to use it at compile-time.

For the most part the transition is very simple and boils down to
adding the "cl-" prefix to some symbols.  A few replacements do not
follow that simple pattern; e.g. `first' is replaced with `car',
even though the alias `cl-first' exists, because the latter is not
idiomatic emacs-lisp.

In a few cases we start using `pcase-let' or `pcase-lambda' instead
of renaming e.g. `first' to `car'.  That way we can remind the reader
of the meaning of the various parts of the data that is being
deconstructed.

An obsolete `lexical-let' and a `lexical-let*' are replaced with their
regular variants `let' and `let*' even though we do not at the same
time enable `lexical-binding' for that file.  That is the right thing
to do because it does not actually make a difference in those cases
whether lexical bindings are used or not, and because this should be
enabled in a separate commit.

We need to explicitly depend on the `cl-lib' package because Emacs
24.1 and 24.2 lack that library.  When using these releases we end
up using the backport from GNU Elpa.

We need to explicitly require the `pcase' library because
`pcase-dolist' was not autoloaded until Emacs 25.1.
2020-04-27 07:36:10 -03:00
Keegan Carruthers-Smith
f28e0a9337 emacs: introduce notmuch-search-by-tag
This is like notmuch-search-filter-by-tag, but creates a new search
rather than filtering the current search. We add this to
notmuch-common-keymap since this can be used by many contexts. We bind
to the key "t", which is the same key used by
notmuch-search-filter-by-tag in notmuch-search-mode-map. This is done
intentionally since the keybinding for notmuch-search-mode-map can be
seen as a specialization of creating a new search.

This change was motivated for use in "notmuch-hello". It is a more
convenient way to search a tag than expanding the list of all tags. I
also noticed many saved searches people use are simply tags.
2020-04-14 12:29:31 -03:00
Mark Walters
63f4ba3057 Introduce unthreaded mode
This commit introduces a new 'unthreaded' search mode where each
matching message is shown on a separate line. It shares almost all of
its code with tree view. Subsequent commits will allow it to diverge
slightly in appearance.
2020-03-19 22:06:49 -03:00
Leo Vivier
46ab6013a2 emacs: make notmuch-search-interactive-region obsolete
`notmuch-search-interactive-region' was moved to notmuch-lib.el in
f3cba19f88 and renamed to
`notmuch-interactive-region' without making the old function
obsolete, thereby breaking user-commands which made use of it.

This commit marks the function as obsolete and makes it an alias for
the new function.
2019-05-23 14:05:05 -03:00
Pierre Neidhardt
f3cba19f88 emacs: Move notmuch-search-interactive-region to notmuch-lib as notmuch-interactive-region 2019-05-07 06:31:19 -03:00
Yang Sheng
0ae8cab4d3 Fix notmuch-describe-key
Fix notmuch-describe-key crashing for the following two cases
1. format-kbd-macro cannot deal with keys like [(32 . 126)], switch to
use key-description instead.
2. if a function in the current keymap is not bounded, it will crash
the whole process. We check if it is bounded and silently skip it to
avoid crashing.
2019-03-31 12:00:50 -03:00
Matt Armstrong
adde6dfaef Emacs: bind "g" to 'notuch-refresh-this-buffer
Using "g" for refresh operations is a pretty common Emacs convention,
codified by `special-mode' in simple.el.
2019-02-21 07:16:53 -04:00
David Edmondson
cfd015bda4 emacs: Kill the stderr buffer when an async process completes
On some platforms (e.g. macOS), it is necessary to add a real sentinel
process for the error buffer used by `notmuch-start-notmuch' rather
than a no-op sentinel.
2018-08-29 06:27:59 -03:00
Daniel Kahn Gillmor
8ea4a99d74 cli/show: make --decrypt take a keyword.
We also expand tab completion for it, update the emacs bindings, and
update T350, T357, and T450 to match.

Make use of the bool-to-keyword backward-compatibility feature.
2017-12-29 16:45:46 -04:00
Vladimir Panteleev
fdf2b3007a emacs: Use make-process when available
make-process is a new function introduced in Emacs 25, which provides
greater control over process creation. Crucially, it allows
separately redirecting stderr directly to a buffer, which allows us to
avoid needing to use the shell to redirect to a temporary file in
order to correctly distinguish stdout and stderr.

* notmuch-lib.el: Use make-process when it is available; fall back to
  the previous method when not.
2017-08-20 08:33:09 -03:00
Vladimir Panteleev
69946c47c9 emacs: Refactor subprocess stderr propagation
Load subprocess error output to a string in the callers, and propagate
the error messages as a string parameter instead of a path to file
names.

Required to be able to avoid using temporary files for subprocess
error output.

* notmuch-lib.el: Update notmuch-check-async-exit-status,
  notmuch-check-exit-status: accept an err parameter instead of
  err-file; shift the responsibility of loading error messages from
  files up the call stack.
2017-08-20 08:32:47 -03:00
Mark Walters
3e21b22c32 emacs: fully add the notmuch-address customize group
We now have several customizable options for address completion. There
is a customize group notmuch-address but it only contains one of these
options. Add all the others, and make it part of the notmuch customize
group.
2017-02-23 08:54:55 -04:00
David Bremner
60ac94fe58 Merge branch 'release'
Updates for 0.23.2
2016-11-17 08:25:08 -04:00
Mark Walters
a3e712fa86 emacs: add compatibility functions for emacs 23
Some of the recent changes to the emacs code have used functions
introduced in emacs 24. The functions used are read-char-choice and
setq-local. This changeset adds a file notmuch-compat.el which
contains compatibility functions so that it should work on emacs
23.

Note, since these functions are taken almost unchanged from the emacs
source they are copyright the Free Software Foundation, and the header
in the file reflects that.
2016-11-16 21:42:34 -04:00
Mark Walters
2f643ac763 emacs: add global keybinding M-= for refresh all buffers
We can't use c-u = as some of the notmuch-show refresh function
already uses that. This is a global keybinding for a relatively
infrequent function but M-= seems unlikely to cause conflicts.
2016-10-17 09:07:54 -03:00
Ioan-Adrian Ratiu
02d3c76102 emacs: notmuch-lib: add refresh all buffers function
notmuch-refresh-all-buffers calls each buffer's major mode specific
refresh function using the generic notmuch-refresh-this-buffer function.

Since the earlier changesets have stopped the refresh functions from
forcing the buffers to be redisplayed this can refresh buffers that
are not currently displayed without disturbing the user.  This is very
useful for silent async background updating the emacs display when new
mail is fetched.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
2016-10-17 09:07:32 -03:00
Mark Walters
5e83fe979d emacs: make the refresh functions more consistent
The different refreshed functions were called differently: some were
called interactively and some were not. Make them all interactive.
2016-10-17 09:01:52 -03:00
Mark Walters
ae06fbfc76 emacs: add a tag jump menu
Add a customisable "jump" style menu for doing tagging operations.
2016-10-04 07:55:16 -03:00
Mark Walters
74b54fb0fa emacs: notmuch-check-exit-status bugfix
This function prints diagnostic information in the event of an
error. However, one of the callers has an optional :stdin-string
keyword argument. This causes the error printing routine to error
itself.

Rather than reach notmuch-check-exit-status about the possible keyword
arguments (currently only one but could be more in the future) this
commit just tells notmuch-check-exit-status how to print non-string arguments.
2016-09-04 08:22:30 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
David Edmondson
fdce7eb545 emacs: Observe the charset of MIME parts when reading them.
`notmuch--get-bodypart-raw' previously assumed that all non-binary MIME
parts could be successfully read by assuming that they were UTF-8
encoded. This was demonstrated to be wrong, specifically when a part was
marked as ISO8859-1 and included accented characters (which were
incorrectly rendered as a result).

Rather than assuming UTF-8, attempt to use the part's declared charset
when reading it, falling back to US-ASCII if the declared charset is
unknown, unsupported or invalid.
2016-05-01 08:04:07 -03:00
Chunyang Xu
0cf457b73b emacs: Fix packaging
Refer to (info "(elisp) Library Headers") for package conventions.
2016-04-16 08:24:42 -03:00
David Edmondson
f0881394bd emacs: Allow part preferences to depend on message content.
Currently the preference for which sub-part of a multipart/alternative
part is shown is global. Allow to the user to override the settings on a
per-message basis by providing the ability to call a function that has
access to the message to return the discouraged type list.

The original approach is retained as the default.
2016-04-09 16:17:20 -03:00
David Edmondson
c41d0db077 emacs: Improve the acquisition of text parts.
`notmuch-get-bodypart-text' assumed that it is always possible to
acquire text/* parts via the sexp output format. This is not true if the
part in question has a content type of application/octet-stream but is
being interpreted as text/* based on the extension of the part filename.

Rework `notmuch-get-bodypart-text' to use the raw output format to
address this and make the implementation common with that of
`notmuch-get-bodypart-binary'.
2016-03-27 17:44:24 -03:00
David Bremner
bceb6516ce Merge branch 'release'
Merge bugfixes applied directly to release
2015-11-23 08:40:40 -04:00
Mark Walters
4c7a592d49 emacs: poll: return useful errors when poll fails.
Previously poll called from emacs would fail silently. This makes it
return a useful error message.

In the non-deprecated case of notmuch new and appropriate hooks, it
uses notmuch-call-notmuch-process which gives an error and
additionally puts the stdout/stderr etc in the *Notmuch errors*
buffer.

In the deprecated case of a custom poll script it only returns an
error message.

Commit based on a bug report, and a potential fix, by Ketil Malde.
2015-11-23 08:37:19 -04:00
Michal Sojka
89f78d38c1 Emacs: Add address completion mechanism implemented in elisp
Currently, notmuch has an address completion mechanism that requires
external command to provide completion candidates. This commit adds a
completion mechanism inspired by https://github.com/tjim/nevermore,
which is implemented in Emacs lisp only.

The preexisting address completion mechanism, activated by pressing
TAB on To/Cc lines, is extended to use the new mechanism when
notmuch-address-command to 'internal, which is the new default.

The core of the new mechanism is the function notmuch-address-harvest,
which collects the completion candidates from the notmuch database and
stores them in notmuch-address-completions variable. The address
harvesting can run either synchronously (same as with the previous
mechanism) or asynchronously. When the user presses TAB for the first
time, synchronous harvesting limited to user entered text is performed.
If the entered text is reasonably long, this operation is relatively
fast. Then, asynchronous harvesting over the full database is triggered.
This operation may take long time (minutes on rotating disk). After it
finishes, no harvesting is normally performed again and subsequent
completion requests use the harvested data cached in memory. Completion
cache is updated after 24 hours.

Note that this commit restores (different) completion functionality for
users when the user used external command named "notmuch-addresses",
i.e. the old default.  The result will be that the user will use
the new mechanism instead of this command. I believe that many users may
not even recognize this because the new mechanism works the same as
http://commonmeasure.org/~jkr/git/notmuch_addresses.git and perhaps also
as other commands suggested at
http://notmuchmail.org/emacstips/#address_completion.

[This feature was significantly improved by David Bremner and Mark Walters]
2015-10-27 08:01:05 -03:00
Tomi Ollila
3c1eea5646 emacs: prefer notmuch-emacs-version in User-Agent: header
Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA
use that as a part of User-Agent: header to provide more accurate
version information when sending emails.

In case some incomplete installation of notmuch emacs MUA is used and
`notmuch-emacs-version' is defined as "unknown" then fall back to ask
version info from cli (as it used to be before this commit).

Requiring notmuch-version[.elc] and if that is missing setting
"fallback" notmuch-emacs-version (to "unknown") was moved from
notmuch.el to notmuch-lib.el as notmuch-mua.el (which provides
User-Agent: information) require's the latter.
2015-08-04 20:56:38 +02:00
Tomi Ollila
0c565fa29f emacs: renamed function notmuch-version to notmuch-cli-version
As it asks `notmuch` binary for its version number.
2015-08-04 20:56:28 +02:00
Austin Clements
3687418526 emacs: Support caching in notmuch-get-bodypart-{binary,text}
(The actual code change here is small, but requires re-indenting
existing code.)
2015-01-25 18:39:13 +01:00
Austin Clements
9d19f325f5 emacs: Return unibyte strings for binary part data
Unibyte strings are meant for representing binary data.  In practice,
using unibyte versus multibyte strings affects *almost* nothing.  It
does happen to matter if we use the binary data in an image descriptor
(which is, helpfully, not documented anywhere and getting it wrong
results in opaque errors like "Not a PNG image: <giant binary spew
that is, in fact, a PNG image>").
2015-01-25 18:39:13 +01:00
Austin Clements
991efcded8 emacs: Remove broken `notmuch-get-bodypart-content' API
`notmuch-get-bodypart-content' could do two very different things,
depending on conditions: for text/* parts other than text/html, it
would return the part content as a multibyte Lisp string *after*
charset conversion, while for other parts (including text/html), it
would return binary part content without charset conversion.

This commit completes the split of `notmuch-get-bodypart-content' into
two different and explicit APIs: `notmuch-get-bodypart-binary' and
`notmuch-get-bodypart-text'.  It updates all callers to use one or the
other depending on what's appropriate.
2015-01-25 18:39:13 +01:00
Austin Clements
021906d6ec emacs: Create an API for fetching parts as undecoded binary
The new function, `notmuch-get-bodypart-binary', replaces
`notmuch-get-bodypart-internal'.  Whereas the old function was really
meant for internal use in `notmuch-get-bodypart-content', it was used
in a few other places.  Since the difference between
`notmuch-get-bodypart-content' and `notmuch-get-bodypart-internal' was
unclear, these other uses were always confusing and potentially
inconsistent.  The new call clearly requests the part as undecoded
binary.

This is step 1 of 2 in separating `notmuch-get-bodypart-content' into
two APIs for retrieving either undecoded binary or decoded text.
2015-01-25 18:39:13 +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
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
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
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
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
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
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
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
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
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
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