Commit graph

44 commits

Author SHA1 Message Date
David Bremner
eb226437e1 emacs: wrap make-process
Provide a safe working directory.
2021-09-11 10:27:38 -03:00
David Bremner
04f378e673 emacs: fix typo in variable name
This error crept in during my style rewrite of dkg's proposed change.
2021-07-06 22:25:57 -03:00
Daniel Kahn Gillmor
29d43b7f44 emacs: Prefer email address over User ID when showing valid signature
Most concrete verification steps are likely only taken on the e-mail
address in the first place, and e-mail addresses render more
intelligibly than arbitrary User IDs in the first place.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Amended-by: db, apply dme restructuring suggestions.
2021-06-26 13:34:54 -03:00
Jonas Bernoulli
1bbbde4a0c emacs: notmuch-crypto-status-button-type: fix potential bug
The "help-echo" can potentially contain an unintended %-spec
so we have to make sure it would not be treated as such.
2021-01-13 07:23:11 -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
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
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
Jonas Bernoulli
df3fab18fe emacs: Increase consistency of library headers 2020-08-09 21:14:36 -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
18d289c863 emacs: Only set one variable per setq form
It's a bit weird to avoid having to write the "(setq ... )" more than
once, just because we can.  In a language that uses '=' for the same
purpose we also happily use that once per assignment.

While there are no benefit to using just one 'setq' there are some
drawbacks.  It is not always clear on first what is a key and what a
value and as a result it is easy to make a mistake.  Also it becomes
harder to comment out just one assignment.
2020-08-09 20:50:50 -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
Jonas Bernoulli
b4b558ac38 emacs: Declare function notmuch-show-get-message-id 2020-04-16 07:58:20 -03:00
Daniel Kahn Gillmor
ea16b5ba85 emacs: avoid warning about notmuch-show-get-message-id
Without this change, we see the following warning when compiling the
elisp:

```
EMACS emacs/notmuch-crypto.elc

In end of data:
emacs/notmuch-crypto.el:266:1:Warning: the function
    ‘notmuch-show-get-message-id’ is not known to be defined.
```

Thanks to Örjan Ekeberg and David Edmondson for their followup about
this.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-03-22 22:21:20 -03:00
Steven Allen
92a7f26fac emacs: don't start processes stopped
It causes this function to fail with:

    let: Wrong type argument: null, t

Support for this was removed from Emacs in April
2019 (5c5e309527e6b582e2c04b83e7af45f3144863ac) because it never
worked correctly (apparently).

This also shouldn't be necessary as sentinels will not be called
unless emacs is idle or waiting for input. Therefore, the
`process-put' calls immediately following the `make-process' call
should always complete before the sentinel is first called.
2020-01-08 21:14:47 -04:00
David Edmondson
a7884929d5 emacs: Improve the reporting of key activity
Improve the information provided about key retrieval and key validity.
2019-12-14 07:23:42 -04:00
David Edmondson
d137afface emacs: Add notmuch-crypto-gpg-program and use it
Allow the user to specify the gpg program to use when retrieving keys,
etc., defaulting to the value of `epg-gpg-program'.
2019-12-14 07:23:29 -04:00
David Edmondson
50f0cbcc4d emacs: Minor refactoring of crypto code 2019-12-14 07:23:06 -04:00
David Edmondson
a1d6e406f6 emacs: Asynchronous retrieval of GPG keys
Rather than blocking emacs while gpg does its' thing, by default run
key retrieval asynchronously, possibly updating the display of the
message on successful completion.
2019-12-14 07:22:53 -04:00
Daniel Kahn Gillmor
9300defd64 emacs: Drop content-free "Unknown signature status" button
When we have not been able to evaluate the signature status of a given
MIME part, showing a content-free (and interaction-free) "[ Unknown
signature status ]" button doesn't really help the user at all, and
takes up valuable screen real-estate.

A visual reminder that a given message is *not* signed isn't helpful
unless it is always present, in which case we'd want to see "[ Unknown
signature status ]" buttons on all messages, even ones that don't have
a signing structure, but i don't think we want that.

Amended by db to drop the unused initialization of 'label'
2019-05-25 13:02:02 -03:00
Daniel Kahn Gillmor
3c752b855f emacs: Invoke gpg with --batch and --no-tty
When invoking gpg as a backgrounded tool, it's important to let gpg
know that it is backgrounded, to avoid spurious prompts or other
breakage.

In particular, https://bugs.debian.org/913614 was a regression in
GnuPG which causes problems when importing keys without a terminal,
but gpg expects one.

Ensuring that notmuch-emacs always invokes gpg as a background process
should avoid some of these unnecessary failure.

Thanks to Justus Winter for finding this problem.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-02-10 09:47:12 -04:00
David Bremner
f1bcb6b7c2 emacs: change default for notmuch-crypto-process-mime to t
There are some cases like remote usage where this might cause
problems, but those users can easily customize the variable. The
inconvenience seems to be outweighed by the security benefit for most
users.
2017-07-15 09:11:32 -03:00
John Byrnes
f0d06c8ca3 emacs: use epg-gpg-program
Adjusted notmuch-crypto gpg call-process function to respect
the GPG program set by the EasyPG epg-gpg-program variable.

This is to correct a problem observed on NixOS where only gpg2 is
installed by default. The Notmuch Emacs frontend fails when trying to
access someone's key to verify their signature when it cannot find the
GPG binary.
2017-03-13 21:12:14 -03:00
Matt Armstrong
d62f9dbfc0 emacs: make faces readable on dark backgrounds.
The notmuch-tag-flagged, notmuch-search-flagged-face and
notmuch-crypto-part-header faces defaulted to "blue", which is nearly
unreadable when a dark background is in use.  This is addressed by using
"LightBlue1" for dark backgrounds.

As a side effect, these faces are now no-op definitions for grayscale or
mono displays.
2016-11-02 07:40:20 -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
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
3b63856568 emacs: Improve crypto button labels.
Make the labels for both encryption and signature buttons share a common
format, in which both report the status if it is not one of those known.
2016-03-24 07:58:52 -03:00
Mark Walters
3901bbca2e emacs: show: make buttons select window
Emacs has two button type objects: widgets (as used for saved searches
in notmuch-hello) and buttons as used by parts/citations and id links
in notmuch-show. These two behave subtly differently when clicked with
the mouse: widgets select the window clicked before running the
action, buttons do not.

This patch makes all of these behave the same: clicking always selects
the clicked window. It does this by defining a notmuch-button-type
supertype that the other notmuch buttons can inherit from. This
supertype binds the mouse-action to select the window and then
activate the button.
2013-02-18 20:13:19 -04:00
Tomi Ollila
2c077b1e4a Spelling fix
Retreive is spelled as r e t r i e v e .
2012-03-01 19:04:21 -04:00
Tomi Ollila
1fb5c77818 emacs: retain show buffer state after retrieving gpg key
After retrieving gpg key retain show buffer state like in
all other operations (i.e. no other calls to notmuch-show-refresh-view
provides optional reset-state argument).
Emacs MUA keeps current message under cursor instead of going first
open message(possibly marking it read).
2012-03-01 19:04:02 -04:00
Austin Clements
17a06ab990 emacs: Reverse the meaning of notmuch-show-refresh-view's argument
Consensus seems to be that people prefer that refreshing show buffers
retains state by default, rather than resetting it by default.  This
turns out to be the case in the code, as well.  In fact, there's even
a test for this that's been marked broken for several months, which
this patch finally gets to mark as fixed.
2012-02-25 10:35:22 -04:00
Austin Clements
311e8f6c45 emacs: Fix out-of-date declare-function
The names of the arguments to notmuch-show-refresh-view had gotten out
of sync between the declare-function and the real thing.
2012-02-20 23:05:17 -04:00
David Edmondson
5d021e52e2 emacs: Ensure that gnupg output goes at the end of the buffer.
When showing the user some details of gnupg output, ensure that those
details are shown at the end of the gnupg status buffer
("*notmuch-crypto-gpg-out*"), otherwise it can end up mixed up with
earlier output.
2012-02-12 11:58:20 -05: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
Aaron Ecay
e3260d0253 Don't quote lambda forms
This generates byte-compiler warnings on (at least) current trunk
versions of Emacs.  The quote is not necessary; lambda forms are
self-quoting.
2011-12-21 07:27:38 -04:00
Thomas Jost
430fb27b3e emacs: Add a face for crypto parts headers
Commit cb841878 introduced new parts handlers for crypto parts, but also
hardcoded values for their headers face. This replaces these hardcoded values
with a customizable face.
2011-12-15 22:51:24 -04:00
Jameson Graef Rollins
9207f90f52 emacs: update notmuch-crypto-process-mime config variable documentation.
This mentions the fact that prefix arguments are now used to enable to
crypto switch.
2011-11-12 20:50:22 -04:00
Jameson Graef Rollins
d1519d256a emacs: Add callback functions to crypto sigstatus button.
This adds two callback functions to the sigstatus button.  If the sig
status is "good", then clicking the button displays the output of "gpg
--list-keys" on the key fingerprint.  If the sigstatus is "bad", then
clicking the button will retrieve the key from the keyserver, and
redisplay the current buffer.

Thanks to David Bremner <bremner@unb.ca> for help with this.
2011-10-06 10:30:25 -03:00
Thomas Jost
09793b6132 emacs: Define several faces for the crypto-status button
Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>

jrollins modified this patch to conform to recent changes in the
crypto processing since this patch was originally sent in.
2011-06-01 21:41:24 -07:00
Jameson Graef Rollins
cb8418784c emacs: Give mutlipart/{signed, encrypted} their own part handler.
This is the best way to make the displayed output for
decrypted/verified messages clearer.  The special sigstatus and
encstatus buttons are now displayed under the part header button.  The
part header button is also tweaked to provide information to user
about how to proces crypto.
2011-05-27 16:22:00 -07:00
Jameson Graef Rollins
45fe354745 emacs: Add support for PGP/MIME verification/decryption
A new emacs configuration variable "notmuch-crypto-process-mime"
controls the processing of PGP/MIME signatures and encrypted parts.
When this is set true, notmuch-query will use the notmuch show
--decrypt flag to decrypt encrypted messages and/or calculate the
sigstatus of signed messages.  If sigstatus is available, notmuch-show
will place a specially color-coded header at the begining of the
signed message.

Also included is the ability to switch decryption/verification on/off
on the fly, which is bound to M-RET in notmuch-search-mode.
2011-05-27 16:22:00 -07:00