Commit Graph

191 Commits

Author SHA1 Message Date
Koni Marti e1d8bc4d17 msgviewer: open http links from messages
Parse http links from a message and display them as completions in the
:open-link command.

Add the following binds to the [view] section in your binds.conf:
<C-l> = :open-link <space>

Parsing can be disabled in aerc.conf by setting parse-http-links to
false in the viewer section.

Thanks to Moritz for the help with the regular expression.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Reviewed-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-14 22:12:48 +02:00
Koni Marti 83e0e2638d msgviewer: parse and display authentication results
Parse the Authentication-Results header and display it in the message
viewer (not enabled by default). DKIM, SPF and DMARC authentication
methods are supported. Implement recommendation from RFC 7601 Sec 7.1 to
have an explicit list of trustworthy hostnames before displaying the
authentication results. Be aware that the authentication headers can be
forged.

To display the results for a specific authentication method, add the
corresponding name to the layout of headers in the viewer section of
aerc.conf, e.g. to display all three, use:

header-layout = From|To,Cc|Bcc,Date,Subject,DKIM|SPF|DMARC

More information will be displayed when "+" is appended to the
authentication method name, e.g. DKIM+ or SPF+ or DMARC+.

Also, add the trustworthy hosts per account with the trusted-authres
parameter, e.g.

trusted-authres = *

to trust every host or use regular expressions for a finer control.
Multiple hosts can be entered as a comma-separated list. Authentication
results will only be displayed when the host is listed in the
trusted-authres list.

Link: https://datatracker.ietf.org/doc/html/rfc7601
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-09 09:42:23 +02:00
Tim Culverhouse 2551dd1bfa feat: add background mail polling option for all workers
Check for new mail (recent, unseen, exists counts) with an external
command, or for imap with the STATUS command, at start or on
reconnection and every X time duration

IMAP:
The selected folder is skipped, per specification. Additional config
options are included for including/excluding folders explicitly.

Maildir/Notmuch:
An external command will be run in the background to check for new mail.
An optional timeout can be used with maildir/notmuch. Default is 10s

New account options:
check-mail
check-mail-cmd (maildir/notmuch only)
check-mail-timeout (maildir/notmuch only), default 10s
check-mail-include (IMAP only)
check-mail-exclude (IMAP only)

If unset, or set less than or equal to 0, check-mail will be ignored

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-31 14:32:51 +02:00
Tim Culverhouse bb400c7d88 pgp: add options auto-sign & opportunistic-encrypt
Add account level config options for auto-sign and opportunistic
encryption.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-05-06 11:02:43 +02:00
Tim Culverhouse 57699b1fa6 feat: add gpg integration
This commit adds gpg system integration. This is done through two new
packages: gpgbin, which handles the system calls and parsing; and gpg
which is mostly a copy of emersion/go-pgpmail with modifications to
interface with package gpgbin. gpg includes tests for many cases, and
by it's nature also tests package gpgbin. I separated these in case an
external dependency is ever used for the gpg sys-calls/parsing (IE we
mirror how go-pgpmail+openpgp currently are dependencies)

Two new config options are introduced:
* pgp-provider. If it is not explicitly set to "gpg", aerc will default to
it's internal pgp provider
* pgp-key-id: (Optionally) specify a key by short or long keyId

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-27 09:46:25 +02:00
Tim Culverhouse d09636ee0b refactor: refactor pgp implementation
This commit refactors the internal PGP implementation to make way for
GPG integration.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-27 09:46:11 +02:00
Tim Culverhouse afe35839ed style: add style config options for dirlist_unread and dirlist_recent
Adds two style options: dirlist_unread and dirlist_recent. These options
apply in layers, in the same way as msglist_* styles do.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-27 09:46:06 +02:00
Victor Freire 8db09d2c73 config: add unsafe-accounts-conf option
This adds the option "unsafe-accounts-conf" under the section [general]
of aerc.conf. This allows an user to specify if the accounts.conf file
must be restrict to be read by the file owner (0600).

By default it is set to "false".

Signed-off-by: Victor Freire <victor@freire.dev.br>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-25 12:06:09 +02:00
Ivan Oleynikov f21916ce0a binds: fix incorrect key names for c-] and c-[
The left and right square brackets are inverted. Fix that.

Signed-off-by: Ivan Oleynikov <ivan.oleynikov95@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-25 11:22:12 +02:00
Koni Marti ce18e92881 statusline: refactor to make it more customizable
Refactor statusline by clearly separating the rendering part from the
text display. Use printf-like format string for statusline
customization.

Document printf-like format string to customize the statusline.

Allow to completely mute the statusline (except for push notifications)
with a format specifier.

Provide a display mode with unicode icons for the status elements.

Implements: https://todo.sr.ht/~rjarry/aerc/34
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-25 11:21:07 +02:00
Kenneth Flak eb7e45d43b config: clarify threading-enabled option
This is only supported with notmuch and specific imap servers.

Signed-off-by: Kenneth Flak <kennethflak@protonmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-04-19 09:34:32 +02:00
Koni Marti 029ff63929 binds: allow to bind a command to < and >
Allow to bind to < and > by using \< and \> in binds.conf. Ensure that
the single \ can still be properly used to bind to other commands.

For example, the following binds would work now:
\< = :prev-tab<Enter>
\> = :next-tab<Enter>
\ = :filter<space>

Fixes: https://todo.sr.ht/~rjarry/aerc/37
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Sebastian LaVine <mail@smlavine.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-17 12:16:38 +02:00
kt programs dc271b4da2 binds: add binding for :open by default in viewer
Also move binding for :delete such that the :open, :save, :pipe command
bindings are grouped together.

Signed-off-by: kt programs <ktprograms@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-14 23:48:26 +02:00
Connor Kuehl fb0e9e3e41 config: don't swallow error in checkConfigPerms
os.Stat might return other errors aside from one stating that the file
does not exist. If it does, propagate the error down. As before, if the
file does not exist, just do nothing.

Signed-off-by: Connor Kuehl <cipkuehl@gmail.com>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-04-14 23:48:24 +02:00
Tobias Wölfel e810ae12d7 stylesets: allow specifying color by number
Make it possible to specify the color in the style sets by number in
addition to the color name. This allows using colors defined by the
terminal.

Signed-off-by: Tobias Wölfel <tobias.woelfel@mailbox.org>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-07 12:51:09 +02:00
Moritz Poldrack d39da95f73 go vet: not compatible with reflect.StructTag.Get
This commit fixes all occurrences of the abovementioned lint-error in
the codebase.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-18 13:33:24 +01:00
kt programs 74366d895d viewer: add key passthrough mode
When trying to search in less, keys bound to viewer functions can't be
used as part of the search query, which makes the search useless.

Add a view::passthrough binding mode and a :toggle-key-passthrough
command go toggle in and out of that mode. By default, typing '/' in the
viewer is bound to enabling key passthrough and automatically inserting
'/', to easily enter "less" search mode. When in the passthrough mode,
all bindings are ignored by default. The default binds.conf only defines
a single keybinding in that mode: <Esc> to get back out. $ex is bound to
<C-x> to allow typing colons.

Signed-off-by: Kt Programs <ktprograms@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-14 22:55:19 +01:00
kt programs cc172970a0 commands: implement fuzzy completion for commands and options
Change the option to enable fuzzy completion to be fuzzy-complete, since
it's no longer only used for folders

Signed-off-by: Kt Programs <ktprograms@gmail.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-03-07 10:18:50 +01:00
Daniel Patterson c77a1c5d9d config: expand tilde in search directories
Will expand a user-provided custom sharedir, XDG_CONFIG_HOME and
XDG_DATA_HOME if necessary. Will not alter those strings if they do not
begin with a tilde.

Signed-off-by: Daniel Patterson <me@danielpatterson.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-03 21:31:32 +01:00
Daniel Patterson 0cfffaef54 config: specify sharedir during build
We should use the Makefile value of SHAREDIR when searching for config
files and templates etc.

This is important for systems which do not use the standard file
hierarchy or which do not have a consistent location for installing
program files, for example NixOS, which will have a different install
location with every update.

Signed-off-by: Daniel Patterson <me@danielpatterson.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-03 21:31:32 +01:00
Maxim Karasev 37477794b2 config: fix default PgUp/PgDn bindings
If -s is present, aerc just shows usage info.

Signed-off-by: Maxim Karasev <begs@disroot.org>
Acked-by: Inwit <inwit@sindominio.net>
2022-02-28 00:30:50 +01:00
Koni Marti 7811620eb8 threading: implement on-the-fly message threading
implement message threading on the message store level using the
jwz algorithm. Build threads on-the-fly when new message headers arrive.

Use the references header to create the threads and the in-reply-to
header as a fall-back option in case no references header is present.

Does not run when the worker provides its own threading (e.g. imap
server threads).

Include only those message headers that have been fetched and are
stored in the message store.

References: https://www.jwz.org/doc/threading.html
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Tested-by: akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-02-24 13:00:12 +01:00
Koni Marti 8f9a633523 commands: add expand-folder and collapse-folder
add the expand-folder and collapse-folder commands to navigate the
directory tree view. Provide keybinds for a vi-like folder navigation
experience.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-02-23 21:09:01 +01:00
Koni Marti 454606a9cd dirtree: implement foldable tree for directory list
implement a foldable tree for the directory list. Expand all parent
directories when a hidden directory is selected with the change-folder
command.

folders-sort considers the top-level directories only. The folders and
foldersexclude filters work with the full directory path.

Enable tree view by adding 'dirlist-tree=true' to the config file.

Implements: https://todo.sr.ht/~sircmpwn/aerc2/228
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-02-23 21:09:01 +01:00
Robin Jarry 6c460493ef config: fix default text/plain filter
; is a special character for the INI format. It starts a comment and
apparently cannot be escaped nor quoted. This causes the default
text/plain filter to be truncated and causes this obscure error when
viewing a message:

  sh: 1: Syntax error: Unterminated quoted string

Debugging shows that the filter command is:

  sh -c "sed 's/^>\\+.*/\\x1b[2"

Remove the explicit dim style. It should be the default anyway.

Fixes: 7c3ce816c8 ("config: set a default filter for text/plain")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-19 23:11:03 +01:00
Robin Jarry 7c3ce816c8 config: set a default filter for text/plain
Avoid the following issue when running aerc with the default
configuration:

  No filter configured for this mimetype ('text/plain')

Use a very basic sed command to replace the default plaintext filter.

Fixes: bb0f180140 ("config: do not hardcode sharedir")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-19 22:12:16 +01:00
Robin Jarry bb0f180140 config: do not hardcode sharedir
Instead of using a static SHAREDIR at compile time, use a list of
standard paths to use at runtime for templates, config files and
stylesets.

This implies removing all default filters in the default configuration.
Replace them with basic commands. New users can configure the filters as
they wish.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-19 15:24:55 +01:00
Robin Jarry 77b3a141a4 review: display actual bindings for commands
Parse the actual user bindings to determine what shortcuts are available
in the compose::review stage. Add a predefined list of commands for
which we want to display the keyboard shortcuts.

Fixes: https://todo.sr.ht/~rjarry/aerc/14
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-02 22:12:08 +01:00
Robin Jarry 923e949c05 binds.conf: change default review bindings
Add missing :detach binding.
Ask user for confirmation when pressing 'q'.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-02 22:12:08 +01:00
inwit e0b5f2e08c completions: add folder flexible search as an option
Provide an option to change the completion style when selecting a folder
from completing with folders starting with the input string to
completing with folders in which the input string is a substring present
at any point in the folder name.

References: https://lists.sr.ht/~sircmpwn/aerc/%3C20201129181020.186984-1-inwit%40sindominio.net%3E
References: https://lists.sr.ht/~sircmpwn/aerc/%3C20210223202536.199355-1-clayton%40craftyguy.net%3E
Signed-off-by: inwit <inwit@sindominio.net>
2022-01-31 17:51:57 +01:00
john1doe@ya.ru 27122ef8e8 compose: add option to never include your own address when replying
Introduce an option in aerc.conf to disable the auto-including
of your own address when replying to your own emails (address
replies to the original To: and Cc: instead); default to true
(allow the auto-including)
2022-01-31 16:22:54 +01:00
Robin Jarry a5c046efe3 dirlist: use shorter delay before listing directory contents
1 second is a bit excessive. Use 200ms which should cover most quick
folder changes.

Add an option to make that delay configurable by the users.

References: https://todo.sr.ht/~rjarry/aerc/16
Fixes: cb3090956c ("dirlist: skip unnecessary change-folder action")
Suggested-by: Koni Marti <koni.marti@gmail.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-01-29 22:01:25 +01:00
inwit d922d7325c binds: Warning on unexistent account bindings
After commit 175d0ef ("binds: add account specific bindings"), when
bindings are defined for an account not defined in accounts.conf, aerc
quits with an error. After this commit, a warning is logged and aerc
ignores those bindings.

Signed-off-by: inwit <inwit@sindominio.net>
2022-01-24 11:48:51 +01:00
Robin Jarry b96326517d bindings: fix ctrl-h binding not working
For some unknown reason. tcell does not include the ctrl modifier for
the ctrl-h key event.

Fixes: 7a6c808c04 ("bindings: prepare for more modifers")
Fixes: https://todo.sr.ht/~rjarry/aerc/8
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-01-20 13:23:35 +01:00
Robin Jarry 877a94f5d9 compose: add default template for new messages
Allow defining a default template to use when composing new messages.
Add an example to be used for new users.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-01-19 21:42:41 +01:00
Robin Jarry 92bf89c338 docs: mention missing -T options for compose and forward
A template file may be specified for compose and forward as well.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-01-19 21:29:16 +01:00
Robin Jarry 0ef72dd575 config: fix code formatting
Tabs are required.

Fixes: 175d0efeb2 ("binds: add account specific bindings")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-12-11 23:13:27 +01:00
Jonathan Bartlett 175d0efeb2 binds: add account specific bindings
When using aerc for multiple accounts often bindings might differ
slightly between accounts. For example:

* Account A archives to one directory (:archive)
* Account B archives to monthly directories (:archive month)

Add account specific bindings to allow the user to add a "context" to a
binding group using a context specifier and a regular expression.

Currently the only context specifier is 'account'.

The regular expression is validated against the accounts loaded from
accounts.conf and the configuration fails to load if there are no
matches.

Contextual bindings are merged with global bindings, with contextual
bindings taking precedence, when that context is active.

Bindings are be configured using a generic pattern of
'view:context=regexp'. E.g.:

    # Globally Applicable Archiving
    [messages]
    A = :read<Enter>:archive<Enter>

    # Monthly Archiving for 'Mailbox' Account
    [messages:account=Mailbox$]
    A = :read<Enter>:archive month<Enter>

In the above example all accounts matching the regular expression will
archive in the monthly format - all others will use the global binding.

Signed-off-by: Jonathan Bartlett <jonathan@jonnobrow.co.uk>
2021-12-11 21:45:41 +01:00
Dian M Fay f776fb8246 style: customize vertical and horizontal border characters
New border-char-horizontal and border-char-vertical config settings in
aerc.conf allow users to modify border appearance from the default
1-wide/tall blank space. In stylesets, border.fg now affects the
foreground color when custom characters are defined.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-30 15:05:33 +01:00
Kalyan Sriram 402612fd97 notmuch: allow sort by file order
When using the notmuch backend, it often makes more sense to sort
folders (actual virtual folders, or queries) by the order specified in
the query-map file, rather than alphabetically. This patch introduces a
configuration option (disabled by default) that allows this.

Additionally, due to the notmuch backend previously using maps (which
are order-undefined) to store the list of queries, default query
selection on aerc startup fluctuated. This patch fixes that by using
slices to store query order.
2021-11-13 15:25:04 +01:00
Kalyan Sriram 88d28908d2 binds: add escape to clear search 2021-11-13 15:20:54 +01:00
y0ast dc2a2c2dfd messages: allow displaying email threads
Display threads in the message list. For now, only supported by the
notmuch backend and on IMAP when the server supports the THREAD
extension.

Setting threading-enable=true is global and will cause the message list
to be empty with maildir:// accounts.

Co-authored-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Co-authored-by: Reto Brunner <reto@labrat.space>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-13 15:05:59 +01:00
Robin Jarry fe7ed940d3 config: use dynamic time format for default config
New users may find this nicer than a static format.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-06 17:44:53 +01:00
Robin Jarry 84146e23b3 index: add this-week-time-format
Also allow specific time format for messages received within the last
7 days.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-06 17:34:20 +01:00
Robin Jarry 02e7d8aca8 doc: fix typo today-time-format -> this-day-time-format
Fixes: 42b4302ba3 ("index: allow dynamic formatting of message dates")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-06 17:11:43 +01:00
Robin Jarry 0d645bcebd go.mod: change base git url
I'm not sure what are the implications but it seems required.

Link: https://github.com/golang/go/issues/20883
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:21:45 +01:00
Robin Jarry 42b4302ba3 index: allow dynamic formatting of message dates
When a message has been sent today (or this year) allow formatting the
date differently.

For example, with:

 [ui]
 index-format=%-25.25n   %-25.25D   %s
 timestamp-format=2006 Jan 02, 15:04 GMT-0700
 this-day-time-format=Today at 15:04
 this-year-time-format=Jan 02

The message list would look like this (spaces collapsed):

 Robin Jarry        Today at 16:30             [PATCH 1/2] bindings: prepare for more modifers
 bugzilla@dpdk.org  Oct 26                     [dpdk-dev] [Bug 839] pdump: any subsequent runs of pdump_autotest fail
 Holger Levsen      2020 Mar 15, 13:44 GMT+01  +1 (Re: FTP Team -- call for volunteers)

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:30:59 +02:00
Robin Jarry 1a75906bcb bindings: support more modified keys
Add new supported keys:

  Ctrl+Enter
  Ctrl+Up
  Ctrl+Down
  Ctrl+Left
  Ctrl+Right
  Ctrl+PageUp
  Ctrl+PageDown

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:22:28 +02:00
Robin Jarry 7a6c808c04 bindings: prepare for more modifers
Prepare to support more modifiers in key bindings.

tcell has some premade ctrl-modified keys but not all keys are
supported. Other keys must be explicitly checked with a modifier mask.

Update the KeyStroke type to carry a modifier mask. Update code
accordingly.

No functional change.

Link: https://github.com/gdamore/tcell/blob/master/key.go#L265-L275
Link: https://github.com/gdamore/tcell/blob/master/key.go#L384-L419
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:21:37 +02:00
Reto Brunner 60c5a82a76 load config: do not overwrite the config upon error
It makes absolutely no sense to copy over the default template from aerc.conf
when the syntax is invalid and our ini parser fails.

The only valid case to do that is if the file is actually missing.
2021-04-17 18:57:19 +02:00