Commit Graph

408 Commits

Author SHA1 Message Date
Koni Marti beae17a6da imap: auto-reconnects on connection error
if the worker emits a connection error, the ui will automatically send back a
reconnect command. The worker then establishes a new connection. Auto-reconnect
is disabled when the user sends the disconnect command.

Fixes: https://todo.sr.ht/~rjarry/aerc/1
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-19 17:40:52 +01:00
Koni Marti 1ace50a6b9 imap: emits connection error on logout
implements a new connection error message. This allows the worker to emit a
connection-related error message to the ui when the imap client closes the
loggedOut channel.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-19 17:34:42 +01:00
Koni Marti 4782473064 fix segfault when copy-pasting into compose editor
fixes the segmentation fault when copy-pasting a large text into the
composer editor. The problem is a concurrent read of the vterm field in the
Terminal widget in its flushTerminal() method which can be avoided with a mutex.

Fixes: https://todo.sr.ht/~rjarry/aerc/12
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-14 20:35:07 +01:00
Parasrah 71eda7d37c completions: add support for completing multiple addresses
as per the discussion https://lists.sr.ht/~sircmpwn/aerc/patches/15367
this handles completions in `completer/completer.go` by enabling the
completer to return a `prefix` that will be prepended to the selected
completion candidate.
2022-01-07 13:54:10 +01:00
Koni Marti b19b844a63 pgp: PGP/MIME encryption for outgoing emails
implements PGP/MIME encryption with go-pgpmail. The Encrypt() function of
go-pgpmail requires a list of public keys which are taken from the
keystore. The keystore is searched for the email addresses of all
recipients (to, cc, and bcc).
If you want to be able to read the encrypted email afterwards, add
yourself as a recipient in either to, cc, or bcc as well.

Public keys can be exported from gpg into aerc as follows:
$ gpg --export  >> ~/.local/share/aerc/keyring.asc

When composing a message, the encryption is enabled with the
":encrypt" command. This sets a bool flag in the Composer struct.
A reapted application of this command will toggle the flag.
The encrypted message can also be signed by using the ":sign"
command before or after ":encrypt".

References: https://todo.sr.ht/~rjarry/aerc/6
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-07 13:45:34 +01:00
Koni Marti 69d4e3895f pgp: PGP/MIME signing for outgoing emails
implements PGP/MIME signing with go-pgpmail. The Sign() function of
go-pgpmail requires a private (signing) key. The signing key which matches
the senders email address (from field in email header) is looked up
in aerc's copy of the keyring.

Private keys can be exported from gpg into aerc as follows:
$ gpg --export-secret-keys  >> ~/.local/share/aerc/keyring.asc

A message is signed with the ":sign" command. The sign command sets
a bool flag in the Composer struct. Using the command repeatedly will
toggle the flag.

References: https://todo.sr.ht/~rjarry/aerc/6
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-07 13:45:34 +01:00
Koni Marti 8813fadfe9 pgp: update openpgp packages (go-crypto and go-pgpmail)
Replaces golang.org/x/crypto with github.com/ProtonMail/go-crypto
consistently and updates go-pgpmail to v0.2.0

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-07 13:45:34 +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
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 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 e41ed82cf3 imap: add manual {dis,}connect support
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:45:31 +01:00
Robin Jarry 20752df89c viewer: add colon after header names
Display them as standard RFC 822 headers.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:45:31 +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 fc84b19bba view,compose: use border color to separate headers from body
When composing a message, there is an empty fill line between the
headers and the text editor. The line is printed with the default style
which may cause users to assume it is part of the editor.

Display the fill lines with the border color to avoid confusion.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:38:23 +02: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 fea57839fb filters: allow matching any email header
In addition of the common headers (subject, to, from, cc), allow
matching arbitrary email headers in filters. E.g.:

  x-bugzilla-severity,critical=tput setaf 1; cat;tput sgr0

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:22:33 +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
Clayton Craft 98d778eeae widgets/terminal: Only call vterm.ScreenCell.Attrs once in styleFromCell
This fixes a substantial performance issue when scrolling emails with
long/complicated contents, where scrolling down a single line can take
something like hundreds of ms before the screen is updated to reflect
the scroll. It's really bad if the email has lots of columns, e.g. like
if it's an html email that was passed through a filter (w3m, etc) to
render it.

Using pprof, I found that the multiple calls to vterm.ScreenCell.Attrs()
in styleFromCell were really really expensive. This patch replaces them
with a single call.

Here's a before and after with a simple, but very manual test of opening
a large email with contents that went through a w3m filter and
continuously scrolling up and down over and over for ~30 seconds:

*** Before:

----------------------------------------------------------+-------------
      flat  flat%   sum%        cum   cum%   calls calls% + context
----------------------------------------------------------+-------------
                                            28.25s   100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.PartSwitcher.Draw
         0     0% 99.94%     28.25s 82.31%                | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.PartViewer.Draw
                                            28.25s   100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.Draw
----------------------------------------------------------+-------------
                                            28.25s   100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.PartViewer.Draw
         0     0% 99.94%     28.25s 82.31%                | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.Draw
                                            19.23s 68.07% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.styleFromCell
                                             6.04s 21.38% | github.x2ecom..z2fddevault..z2fgo..z2dlibvterm.Screen.GetCellAt
                                             1.38s  4.88% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2flib..z2fui.Context.Printf
                                             0.62s  2.19% | runtime.mapassign
                                             0.43s  1.52% | runtime.mapaccess2
                                             0.20s  0.71% | runtime.newobject
                                             0.19s  0.67% | runtime.callers (inline)
                                             0.07s  0.25% | runtime.makeslice
                                             0.07s  0.25% | runtime.mallocgc
----------------------------------------------------------+-------------
                                            19.23s   100% | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.Draw
         0     0% 99.94%     19.23s 56.03%                | git.x2esr.x2eht..z2f..z7esircmpwn..z2faerc..z2fwidgets.Terminal.styleFromCell
                                            19.21s 99.90% | github.x2ecom..z2fddevault..z2fgo..z2dlibvterm.ScreenCell.Attrs

*** After:

----------------------------------------------------------+-------------
      flat  flat%   sum%        cum   cum%   calls calls% + context
----------------------------------------------------------+-------------
                                             0.31s   100% | git.x2esr.x2eht/~sircmpwn/aerc/widgets.Terminal.Draw
         0     0% 99.87%      0.31s  1.33%                | github.x2ecom/ddevault/go-libvterm.NewPos
                                             0.25s 80.65% | runtime.callers (inline)
                                             0.04s 12.90% | runtime.gomcache (inline)
----------------------------------------------------------+-------------
                                             8.40s   100% | github.x2ecom/ddevault/go-libvterm.Screen.GetCellAt
         0     0% 99.87%      8.40s 36.11%                | github.x2ecom/ddevault/go-libvterm.Screen.GetCell
                                             7.14s 85.00% | github.x2ecom/ddevault/go-libvterm._cgoCheckPointer
                                             0.54s  6.43% | runtime.callers (inline)
                                             0.35s  4.17% | runtime.exitsyscall
                                             0.11s  1.31% | runtime.deferprocStack
                                             0.07s  0.83% | doentersyscall
                                             0.07s  0.83% | runtime.getg
                                             0.05s   0.6% | runtime.casgstatus
                                             0.03s  0.36% |   _init
                                             0.03s  0.36% | runtime.gomcache (inline)
----------------------------------------------------------+-------------
                                             8.46s   100% | git.x2esr.x2eht/~sircmpwn/aerc/widgets.Terminal.Draw
         0     0% 99.87%      8.46s 36.37%                | github.x2ecom/ddevault/go-libvterm.Screen.GetCellAt
                                             8.40s 99.29% | github.x2ecom/ddevault/go-libvterm.Screen.GetCell
                                             0.06s  0.71% | runtime.callers (inline)
----------------------------------------------------------+-------------
                                             0.31s   100% | git.x2esr.x2eht/~sircmpwn/aerc/widgets.Terminal.styleFromCell
         0     0% 99.87%      0.31s  1.33%                | github.x2ecom/ddevault/go-libvterm.ScreenCell.Attrs
)
2021-04-13 01:32:45 +02:00
Alexey Yerin 804329970b terminal: Add support for Shift+Tab 2021-02-07 10:11:31 +01:00
Reto Brunner 8ea86cea41 Get rid of the aerc.PushError(" " + $string) idiom
The individual callers should not be responsible for padding
2021-01-30 14:04:23 +01:00
Eyal Sawady d344ceecfe compose: apply default style to header separator 2021-01-14 06:36:09 +01:00
Reto Brunner 0e554a879d trim <> from messageIDs when handling mailto links
Co-authored-by: James Walmsley <james@fullfat-fs.co.uk>
2021-01-12 20:22:34 +01:00
Eyal Sawady 7371d91b3c Apply dirlist style to unselected directories 2021-01-12 20:07:36 +01:00
Shaw Vrana 3c14c2cb34 Reapply 'Fix nil pointer deref on Envelope'
The commit bf16ccde48 appears to have been
unintentionally dropped by commit 905cb9dfd3
(Implement style configuration).
2021-01-03 09:08:27 +01:00
y0ast 3edbe0c67c add italics support
Fixes: https://todo.sr.ht/~sircmpwn/aerc2/416

Co-authored-by: JD <john1doe@ya.ru>
2020-12-24 10:26:18 +01:00
y0ast 03650474e2 update tcell to v2 and enable TrueColor support
Also update to the tcell v2 PaletteColor api, which should keep the chosen
theme of the user intact.

Note, that if $TRUECOLOR is defined and a truecolor given, aerc will now stop
clipping the value to one of the theme colors.
Generally this is desired behaviour though.
2020-12-18 07:23:22 +01:00
Reto Brunner af0a2b9a46 Use extensions for querying the mime type of attachments
This gets rid of the issue that lots of things are detected as zip files, even
though they are a more specialized format (say office files)
2020-12-15 21:48:25 +01:00
Reto Brunner 7bc556740a fix mailto parsing 2020-11-28 15:45:46 +01:00
Reto Brunner 20ec2c8eeb compose: use a proper header instead of a string map
Prior to this commit, the composer was based on a map[string]string.
While this approach was very versatile, it lead to a constant encoding / decoding
of addresses and other headers.

This commit switches to a different model, where the composer is based on a header.
Commands which want to interact with it can simply set some defaults they would
like to have. Users can overwrite them however they like.

In order to get access to the functions generating / getting the msgid go-message
was upgraded.
2020-11-14 15:40:13 +01:00
Reto Brunner e7d450c61d rename header to heditors 2020-11-14 15:40:13 +01:00
Chris Vittal f9bba3d17d Apply relevant msglist styles in order
Allow styles to be layered over a base style. The list of styles to
apply is layered over the base style in order, such that if the layer
does not differ from the base it is not used. The order that these
styles are applied in is, from first to last:

msglist_default
msglist_unread
msglist_read    (exclusive with unread, so technically the same level)
msglist_flagged
msglist_deleted
msglist_marked

So, msglist_marked style dominates.

This fixes an issue where the msglist_deleted style was not being applied.
2020-11-01 09:50:58 +01:00
Reto Brunner 75cbf76732 refactor ParseMessageFormat to use a ctx object 2020-10-14 08:42:26 +02:00
Reto Brunner fe42beb3e4 dirlist: fix empty row if dir is added
There is a window where a new dir entry isn't yet in the dirlist.dir.
dirlist.ensureScroll however expected to always find a valid index.
Add a check so that we don't try to scroll to a -1 index.
2020-09-08 07:48:55 +02:00
y0ast 6ddd347b06 Make mimetype check consistent across cases 2020-09-07 07:27:15 +02:00
y0ast f09e3966a7 correctly apply msglist_read color 2020-09-01 19:09:27 +02:00
Reto Brunner c846307144 base models.Address on the mail.Address type
This allows us to hook into the std libs implementation of parsing related stuff.
For this, we need to get rid of the distinction between a mailbox and a host
to just a single "address" field.

However this is already the common case. All but one users immediately
concatenated the mbox/domain to a single address.

So this in effects makes it simpler for most cases and we simply do the
transformation in the special case.
2020-08-20 19:18:57 +02:00
ARaspiK fe1cabb077 Add support for :rmdir
The `:rmdir` command removes the current directory (`-f` is required if
the directory is not empty).

This is not supported on the notmuch backend.

An issue with the maildir backend is that some sync programs (e.g.
offlineimap) may recover the directory after it is deleted.  They need
to specifically be configured to accept deletions, or special commands
need to be executed (e.g. `offlineimap --delete-folder`) to properly
delete folders.

A danger of using this on the IMAP backend is that it is possible for a
new message to be added to the directory and for aerc to not show it
immediately (due to a slow connection) - using `:rmdir` at this moment
(with `-f` if the directory already contains messages) would delete the
directory and the new message that just arrived (and all other
contents).  This is documented in aerc(1) so that users are aware of
possible risks.
2020-08-19 11:38:57 +02:00
Reto Brunner 2d7a870725 show error if account view creation fails
This can happen for example if aerc is compiled without notmuch support but the
notmuch worker is requested.
Pushing a status message isn't good enough, as this gets overridden pretty
quickly if one has multiple accounts configured.
So we show a fullscreen error instead.
2020-08-10 08:00:34 +02:00
Kalyan Sriram 1023dd9588 Rename selecter to selector 2020-08-06 21:42:06 +02:00
Kalyan Sriram 905cb9dfd3 Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of
aerc's look (color scheme, font weight, etc). Default styleset is
installed to /path/to/aerc/stylesets/default.
2020-08-06 21:42:06 +02:00
Reto Brunner 3d784c5d8c Revert "Implement style configuration."
This reverts commit 1ff687ca2b.
2020-07-30 23:22:32 +02:00
Reto Brunner 6ee7b1c3fd Revert "Rename selecter to selector"
This reverts commit 2c244222d5.
2020-07-30 23:22:16 +02:00
Kalyan Sriram 2c244222d5 Rename selecter to selector 2020-07-30 19:35:59 +02:00
Kalyan Sriram 1ff687ca2b Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of
aerc's look (color scheme, font weight, etc). Default styleset is
installed to /path/to/aerc/stylesets/default.
2020-07-30 19:35:59 +02:00
Reto Brunner 1bab1754f0 msgviewer: set max line length to 1 GB
some people send around huge html without any newline in between.
This did overflow the default 64KB buffer of bufio.Scanner.
If something can't fit in a GB there's no hope left

Also, ignoring errors is bad mkey
2020-07-30 19:35:59 +02:00
Reto Brunner 01885e2448 msgviewer: simplify attemptCopy
No functional changes, simply extract more complex stuff into
sub functions to help readability.
2020-07-30 19:35:59 +02:00
Reto Brunner c574a838fa Remove hard coded bodystruct path everywhere
Aerc usually used the path []int{1} if it didn't know what the proper path is.
However this only works for multipart messages and breaks if it isn't one.

This patch removes all the hard coding and extracts the necessary helpers to lib.
2020-07-27 09:19:27 +02:00
Heiko Carrasco 749dbb93a4 Use PushStatus instead of SetStatus where it makes sense 2020-07-09 08:37:01 +02:00