Commit graph

142 commits

Author SHA1 Message Date
Pengji Zhang
2355ff274d emacs/mua: Correct autoload cookies
This is a follow-up to [1: 8d06dfce]. Per Info node '(elisp)Autoload',
autoload cookies should start with ';;;###'.

1: 2024-04-04 8d06dfce17
   emacs: Autoload notmuch-user-agent related functions
2024-08-16 17:39:20 -03:00
Tony Zorman
fefc7a9474 emacs/mua: optionally check for erroneous subjects
This works much like notmuch-mua-attachment-regexp, but for the
subject instead. By default, check for empty subjects, as that seems a
reasonable thing to safeguard against.
2024-07-25 19:37:08 +09:00
Jelle Licht
8d06dfce17 emacs: Autoload notmuch-user-agent related functions
With this change, users with mail-user-agent set to
'notmuch-user-agent can start composing emails without having to
require 'notmuch-mua first.
2024-04-04 08:20:51 -03:00
David Bremner
e4ead7656c emacs/mua: change name of ignored parameter
Suppress compiler warning.
2023-10-06 20:37:16 -03:00
Russell Sim
82aa1acc0c emacs: move From header addition to after header intern
OTHER-HEADERS are expected to be passed as strings, to match the
implementation of `compose-mail'.  But the "From" header is currently
expected to be passed as a symbol.  Instead the "From" header can be
safely added after converting all the headers to symbols.
2022-11-05 13:30:50 -04:00
David Bremner
1ef7c75111 emacs/reply: reply to correct duplicate
Essentially we just need to arrange to pass the right --duplicate
argument to notmuch reply.

As a side-effect, correct the previously unused value of EXPECTED in
T453-emacs-reply.sh.
2022-07-30 08:46:22 -03:00
jao
9695e4c38d emacs: use message-dont-reply-to-names when composing replies
notmuch-mua functions for replies now use the built-in customizable
variable message-dont-reply-to-names with the same semantics as
message-mode.
2022-06-16 08:51:19 -03:00
Damien Cassou
3a6b479a73 emacs: change where notmuch-mua-mail moves point
Move point to the position that makes the most sense instead of always
moving point to the TO.  This is useful when TO/SUBJECT are passed as
argument.

Amended by db: move news item to UNRELEASED.
2022-06-02 08:21:56 -03:00
David Bremner
90a7c1af36 emacs/reply: restrict what mime types are inlined by default
Apply the previously factored-out function used by notmuch-show.
2022-05-16 07:12:47 -03:00
David Bremner
e722b4f48c emacs: wrap call-process
Provide safe working directory
2021-09-11 11:11:29 -03:00
David Bremner
731697d671 CLI: define and use format version 5
This is a bit of a cheat, since the format does not actually
change. On the other hand it is fairly common to do something like
this to shared libary SONAMEs when the ABI changes in some subtle way.
It does rely on the format-version argument being early enough on the
command line to generate a sensible error message.
2021-08-22 07:05:13 -07:00
edef
fb4b45062f emacs: remap send-message and send-message-and-exit
All three of C-c C-c, <menu-bar> <Message> <Send Message>,
and <tool-bar> <Send Message> are bound to message-send-and-exit by
message.el, but notmuch-mua.el only had an explicit override for the
keyboard binding. This mostly manifests as confusing Fcc behaviour for
GUI users.

Patching the bindings for specific keys is rather brittle, since it has
to be aware of every relevant binding. This change switches to instead
using a remap binding, which turns any binding for message-send or
message-send-and-exit into a binding for the corresponding notmuch-mua
command.
2021-06-27 14:22:35 -03:00
Jonas Bernoulli
6cae6f32b1 emacs: notmuch-mua-add-more-hidden-headers: use local binding 2021-01-15 07:29:09 -04:00
Jonas Bernoulli
371f481d93 emacs: use string-empty-p 2021-01-15 06:47:28 -04:00
Jonas Bernoulli
9ca1f945d9 emacs: improve how cl-lib and pcase are required
We need to load `cl-lib' at run-time because we use more from it than
just macros.  Never-the-less many, but not all libraries required it
only at compile-time, which we got away with because at least some
libraries already required it at run-time as well.

We use `cl-lib' and (currently to a lesser extend) `pcase' throughout
the code-base, which means that we should require these features in
most libraries.

In the past we tried to only require these features in just the
libraries that actually need them, without fully succeeding.  We did
not succeed in doing so because that means we would have to check
every time that we use a function from these features whether they
are already being required in the current library.

An alternative would be to add the `require' forms at the top of every
library but that is a bit annoying too.

In order to make sure that these features are loaded when needed but
also to keep the noise down we only require them in "notmuch-lib.el",
which most other libraries require, and in most of the few libraries
that do not do so, namely "notmuch-draft.el", "notmuch-message.el" and
"notmuch-parser.el".  ("coolj.el", "make-deps.el", various generated
libraries, and "notmuch-compat.el" are left touched.)
2021-01-15 06:46:38 -04:00
Jonas Bernoulli
692acdf9da emacs: various doc-string improvements 2021-01-15 06:40:58 -04:00
Jonas Bernoulli
16b2db0986 emacs: various cosmetic improvements 2021-01-15 06:38:00 -04:00
Jonas Bernoulli
7db6ed2dd4 emacs: notmuch-mua.el: move all options into "Options" section
This is how we do it in other libraries.
2021-01-13 07:23:11 -04:00
Jonas Bernoulli
37bb41a792 emacs: notmuch-mua-prompt-for-sender: don't force Ido on users
We shouldn't force `ido-completion-read' on users who do not otherwise
use Ido.  Unfortunately simply turning on `ido-mode' does not change
every `completing-read' into a `ido-completing-read', instead it only
changes file and buffer completion.

I do realize that existing Ido users will initially dislike this
change, but I would like to encourage them to see this as an
opportunity to learn about Fido.

Unlike `ido-mode', build-in `fido-mode' confirms to the standard
completion API, so turning it on causes every `completing-read' to
use the Fido completion mechanism and which is similar to the Ido
mechanism:

> An enhanced `icomplete-mode' that emulates `ido-mode'.  This global
> minor mode makes minibuffer completion behave more like `ido-mode'
> than regular `icomplete-mode'."
2021-01-13 07:23:11 -04:00
Jonas Bernoulli
117501d5ce emacs: define notmuch-message-queued-tag-changes as buffer-local
Also improve the doc-string.
2021-01-13 07:21:32 -04:00
Jonas Bernoulli
0067a43ea2 emacs: deal with unused lexical arguments and variables
The previous commit switched to lexical-binding but without dealing
with the new warnings about unused lexical arguments and variables.

This commit deals with most of them, in most cases by either removing
leftover bindings that are actually unnecessary, or by marking certain
arguments as "known to be unused" by prefixing their names with "_".

In the case of the functions named `notmuch-show-insert-...' the
amount of silencing that is required is a bit extreme and we might
want to investigate if there is a better way.

In the case of `notmuch-mua-mail', ignoring CONTINUE means that we do
not fully follow the intended behavior described in `compose-mail's
doc-string.
2021-01-13 07:16:23 -04:00
Jonas Bernoulli
fc4cda07a9 emacs: use lexical-bindings in all libraries
Doing so causes many new compile warnings.  Some of these warnings
concern genuine changes in behavior that have to be addressed right
away.

Many other warnings are due to unused variables.  Nothing has changed
here, except that the byte-compiler can now detect these pre-existing
and harmless issues.  We delay addressing these issues so that we can
focus on the important ones here.

A third group of warnings concern arguments that are not actually used
inside the function but which cannot be removed because the functions
signature is dictated by some outside convention.  Silencing these
warning is also delayed until subsequent commits.
2021-01-13 07:16:04 -04:00
Jonas Bernoulli
2ca941163d emacs: make headings outline-minor-mode compatible
`outline-minor-mode' treats comments that begin with three or more
semicolons as headings.  That makes it very convenient to navigate
code and to show/hide parts of a file.

Elips libraries typically have four top-level sections, e.g.:

;;; notmuch.el --- run notmuch within emacs...
;;; Commentary:...
;;; Code:...
;;; notmuch.el ends here

In this package many libraries lack a "Commentary:" section, which is
not optimal but okay for most libraries, except major entry points.

Depending on how one chooses to look at it, the "... ends here" line
is not really a heading that begins a section, because it should never
have a "section" body (after all it marks eof).

If the file is rather short, then I left "Code:" as the only section
that contains code.  Otherwise I split the file into multiple sibling
sections.  The "Code:" section continues to contain `require' and
`declare-function' forms and other such "front matter".

If and only if I have split the code into multiple sections anyway,
then I also added an additional section named just "_" before the
`provide' form and shortly before the "...end here" line.  This
section could also be called "Back matter", but I feel it would be
distracting to be that explicit about it.  (The IMO unnecessary but
unfortunately still obligatory "... ends here" line is already
distracting enough as far as I am concerned.)

Before this commit some libraries already uses section headings, some
of them consistently.  When a library already had some headings, then
this commit often sticks to that style, even at the cost inconsistent
styling across all libraries.

A very limited number of variable and function definitions have to be
moved around because they would otherwise end up in sections they do
not belong into.

Sections, including but not limited to their heading, can and should
be further improved in the future.
2021-01-13 07:10:27 -04:00
Jonas Bernoulli
54492ddf23 emacs: do not quote self-quoting t 2020-12-06 16:23:11 -04:00
Jonas Bernoulli
53a4eb4780 emacs: misc doc-string improvements 2020-12-06 16:20:28 -04:00
Jonas Bernoulli
3cdf105e0f emacs: place complete first sentence on first doc-string line 2020-12-06 16:20:02 -04:00
Jonas Bernoulli
a7ba52eb94 emacs: place only first sentence on first doc-string line 2020-12-06 16:19:36 -04:00
Jonas Bernoulli
ff80122972 emacs: more cleanup since dropping support for Emacs 24
Notmuch requires at least version 25 of Emacs now.

Adjust comments that previously referenced version 24 specifically,
even though they also apply to later releases. Remove documentation
and code that no longer applies.

- `mm-shr' no longer references `gnus-inhibit-images'.
2020-12-06 16:18:20 -04:00
Jonas Bernoulli
1acaaa093c emacs: remove kludge for Emacs 23 from notmuch-mua-mail
Notmuch requires at least Emacs version 25.

The `return-action' argument was added prior to Emacs 24.1
in 25ca2e61403f97b5a023164f2924d5f8aca2492a.
2020-12-06 16:17:52 -04:00
Jonas Bernoulli
f061ae5b42 emacs: fix old bug in notmuch-mua-mail
This fixes a regression introduced in [1: 7e20d264].  If the argument
RETURN-ACTION was non-nil then we should pass along the value of that
argument.  Instead we passed along the constant symbol `return-action'.

1: 7e20d26480
   emacs: Fix mail composition under Emacs 23
2020-12-06 16:17:36 -04:00
Jonas Bernoulli
0496668ad5 emacs: define notmuch-message-mode-map explicitly
Key bindings should not be defined at the top-level but inside
a `defvar' form.  Doing it at the top-level makes it harder to
reliably customize key bindings.
2020-11-11 20:13:00 -04:00
Tim Quelch
45193bab16 emacs: Remove notmuch-mua-message-send-hook
Currently `message-send-hook` functions are being called twice: In
notmuch send common when `notmuch-mua-send-hook` functions are
run (which by default includes `notmuch-mua-message-send-hook`) and in
`message-send` itself.

Because `message-send-hook` functions are run in `message-send` itself,
we don't need also need to run them before we delegate to `message-send`

Calling `notmuch-mua-message-send-hook` resulted in functions in
`message-send-hook` to be called twice. This causes bugs in
non-idempotent hook functions.
2020-09-19 06:49:17 -03:00
Jonas Bernoulli
96baa22318 emacs: Drop old advices that were only need for Emacs 23 2020-08-09 21:16:12 -03:00
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
Jonas Bernoulli
e1a700067a emacs: Use 'when' instead of 'if' when there is no ELSE part 2020-08-09 20:52:34 -03:00
Jonas Bernoulli
09f6533c37 emacs: Use 'unless' instead of 'when' and 'not'
Also use 'unless' in a few cases where previously 'if' was used with
'not' but without an ELSE part.
2020-08-09 20:51:26 -03:00
Jonas Bernoulli
dfb1b8eb89 emacs: Use 'and' instead of 'when' when the return value matters
Also do so for some 'if' forms that lack an ELSE part.
Even go as far as using 'and' and 'not' instead of 'unless'.
2020-08-09 20:51:16 -03:00
Jonas Bernoulli
caaa108760 emacs: Fix indentation 2020-08-09 20:48:09 -03:00
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
Örjan Ekeberg
1d9ec88d87 emacs: limit search for attachment to stop at first mime-part
This commit changes the behaviour of notmuch-mua-attachment-check
so that it stops searching for notmuch-mua-attachment-regexp when a
new mime-part is reached.  This avoids false warnings when matching
words occur inside forwarded messages.
2019-12-14 07:28:42 -04:00
Örjan Ekeberg
f599ea7877 emacs: Add missing type and group to defcustom variable
Added the type 'regexp and group 'notmuch-send as properties to the
customizable variable notmuch-mua-attachment-regexp.
2019-04-24 07:06:55 -03:00
Örjan Ekeberg
606f2a6615 emacs: Tag forwarded messages with +forwarded (customizable)
Use the buffer-local variable notmuch-message-queued-tag-changes
to change tags when the forwarding message is sent.
2019-04-14 08:00:44 -03:00
Örjan Ekeberg
d9800c8932 emacs: Use a buffer-local variable to update tags when sending replies
Instead of relying on the "In-Reply-To" header, use a buffer-local variable,
notmuch-message-queued-tag-changes, to add and remove tags to affected
messages when the message-send-hook is triggered.
2019-04-14 07:58:06 -03:00
Örjan Ekeberg
3b807db52b emacs: Add References header to forwarded messages
Include the message-id of forwarded messages in the new message.
This ensures that the new (forwarding) message is linked to the
same thread as the message being forwarded.
2019-04-14 07:57:32 -03:00
David Edmondson
1aae6daef7 emacs: Optionally check for missing attachments in outgoing messages
Query the user if the message text indicates that an attachment is
expected but no MML referencing an attachment is found.

This is not enabled by default - see the documentation for
`notmuch-mua-attachment-check'.
2019-03-28 14:37:07 -03:00
David Edmondson
329a8c7fce emacs: Update integration with third party packages.
`mm-inline-text-html-with-images' was removed from mm-decode.el in
2016 and replaced with `mm-html-inhibit-images'.

`gnus-select-frame-set-input-focus' was removed from gnus-util.el in
2016 and existed only for XEmacs compatibility.
2018-10-08 12:50:34 -03:00
David Edmondson
e8cb6b2cd6 emacs: Call `notmuch-mua-send-hook' hooks when sending a message
Previously any hook functions attached to `notmuch-mua-send-hook' were
ignored.
2018-09-28 20:22:42 -03:00