When receiving the SIGHUP signal, reload all configuration.
Changelog-added: `:reload` is now invoked when `SIGHUP` is received
by the `aerc` process.
Suggested-by: Anachron <gith@cron.world>
Signed-off-by: Robin Jarry <robin@jarry.cc>
When reloading the configuration with :reload, global variables in the
config package are reset to their startup values and then, the config is
parsed from disk. While the parsing is done, these variables are
temporarily in an inconsistent and possibly invalid state.
When commands are executed interactively from aerc, they are handled by
the main goroutine which also deals with UI rendering. No UI render will
be done while :reload is in progress.
However, the IPC socket handler runs in an independent goroutine. This
has the unfortunate side effect to let the UI goroutine to run while
config parsing is in progress and causes crashes:
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6bb142]
goroutine 1 [running]:
git.sr.ht/~rjarry/aerc/lib/log.PanicHandler()
lib/log/panic-logger.go:51 +0x6cf
panic({0xc1d960?, 0x134a6e0?})
/usr/lib/go/src/runtime/panic.go:783 +0x132
git.sr.ht/~rjarry/aerc/config.(*StyleConf).getStyle(0xc00038b908?, 0x4206b7?)
config/style.go:386 +0x42
git.sr.ht/~rjarry/aerc/config.StyleSet.Get({0x0, 0x0, 0x0, {0x0, 0x0, 0x0}}, 0x421a65?, 0x0)
config/style.go:408 +0x8b
git.sr.ht/~rjarry/aerc/config.(*UIConfig).GetStyle(...)
config/ui.go:379
git.sr.ht/~rjarry/aerc/lib/ui.(*TabStrip).Draw(0xc000314700, 0xc000192230)
lib/ui/tab.go:378 +0x15b
git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc000186fc0, 0xc0002c25f0)
lib/ui/grid.go:126 +0x28e
git.sr.ht/~rjarry/aerc/app.(*Aerc).Draw(0x14b9f00, 0xc0002c25f0)
app/aerc.go:192 +0x1fe
git.sr.ht/~rjarry/aerc/lib/ui.Render()
lib/ui/ui.go:155 +0x16b
main.main()
main.go:310 +0x997
Make the reload operation safe by changing how config objects are
exposed and updated. Change all objects to be atomic pointers. Expose
public functions to access their value atomically. Only update their
value after a complete and successful config parse. This way the UI
thread will always have access to a valid configuration.
NB: The account configuration is not included in this change since it
cannot be reloaded.
Fixes: https://todo.sr.ht/~rjarry/aerc/319
Reported-by: Anachron <gith@cron.world>
Signed-off-by: Robin Jarry <robin@jarry.cc>
We rely on IMAP's \Recent flag to trigger the new email hook, making it
unreliable since not all providers support that flag (it's been
deprecated in RFC 9051).
This patch implements the following heuristic to force the \Recent flag
on messages, regardless of what the server says, and "fixes" this
inconsistency across providers: a message is always considered having
the \Recent flag if:
- The IMAP header cache is enabled, and
- The message is not in the header cache, and
- It's not marked as read, and
- It's been received less than `check-mail` in the past
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Some applications may request being notified of changes to the color
scheme of their host terminal so that they could redraw themselves
appropriately. Pass such notifications provided by Vaxis to virtual
terminal widgets that may be open inside aerc to facilitate these
notifications for the applications running in them.
Cc: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
Add a solarized-dark styleset which is based on the solarized
styleset. It is supposed to better suit terminal emulators which are
configured to use the dark solarized palette.
Signed-off-by: Martin Dosch <martin@mdosch.de>
Acked-by: Robin Jarry <robin@jarry.cc>
The account-wizard only shows the default path for the configuration and
does not account for a modified XDG_CONFIG_HOME. Dynamically generate
the message to embed the correct path.
Changelog-fixed: The account wizard now always shows the correct path
for the account configuration.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
Since pill is ambiguous and an uncommon name for it, mention that the
pill is what is commonly referred to as a scrollbar in the
documentation.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
During Review of another patch, this jumped at me and just looked wrong.
Change it to show three dots.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Reviewed-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
The maintainer of this library has gone AWOL. We are depending on
a patch that has never been merged. Let's vendor the library to avoid
future issues.
This patch has been made with the following steps:
git clone https://github.com/konimarti/jwz lib/jwz
git -C lib/jwz checkout fix-missing-messages
mv lib/jwz/test/testdata/ham lib/jwz/testdata
sed -i 's#test/testdata#testdata#' lib/jwz/jwz_test.go
rm -rf lib/jwz/.* lib/jwz/docs lib/jwz/examples lib/jwz/test
sed -i 's#github.com/gatherstars-com/jwz#git.sr.ht/~rjarry/aerc/lib/jwz#' \
lib/threadbuilder.go
go mod tidy
git add --intent-to-add lib/jwz
make fmt
Along with some manual adjustments to fix the linter warnings. Also, to
make the patch smaller, I only kept 93 test emails from the test data
fixture.
Changelog-changed: The JWZ library used for threading is now vendored.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
If the fuzzy-complete option is used, then list strings containing exact
match first followed by the fuzzy matches.
Changelog-changed: Results of filtering when `fuzzy-complete` is
enabled list exact matches first.
Signed-off-by: Jakub Růžička <jakub.ruzicka@matfyz.cz>
Tested-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
According to RFC 8058, a List-Unsubscribe header must have a valid DKIM
signature. This is currently not checked for.
Implement a DKIM check before acting upon a subscribe link.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
If there is only one option to unsubscribe, select that method
automatically.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
According to RFC 8058, links in the List-Unsubscribe headers should have
a POST request sent to them. This is not possible in the current setup,
as links are only opened in a browser.
Change the default behaviour to match the RFC and keep an "Open in
Browser" option for non-compliant senders.
Link: https://datatracker.ietf.org/doc/html/rfc8058
Changelog-fixed: `:unsubscribe` now follows RFC 8058.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
Throw an error when a binding with an unknown modifier key is defined.
Previously, when a binding was defined using an unknown modifier (for
example <M-s>) aerc would return no errors and function as if that
binding was defined without the unknown modifier (`<M-s>` would act like
`s`)
Signed-off-by: chupson <chupson@chupson.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
Historically UNIX programs read VISUAL before EDITOR. The former
is to be set to a screen editor like 'vi' and the latter to a line
editor like 'ed'.
Aerc should correctly read VISUAL first if both are defined.
Signed-off-by: Erin John <unrealapex@disroot.org>
Acked-by: Robin Jarry <robin@jarry.cc>
Go has evolved significantly over the years and has introduced some
handy helper functions that make the code easier to read.
Use helper functions like slices.Contains, map.Copy, and
strings.CutPrefix, when appropriate.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
The various handleFetchXYZ functions do not consistently request
X-GM-LABELS when interacting with GMail, and the in-memory "label state"
can easily get out-of-sync with the server.
This patch fixes this, and also ensures that we only log that we're
attaching a label to a message when we actually do (and if so, puts the
account name in the log line).
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
As part of my effort to properly support labels in IMAP for providers
that have this notion, this patch takes care of the case of GMail and
Proton, and gracefully errors for all others.
To do so, it detects the actual provider we're connected to by analyzing
the target URL, and implements label addition / removal (toggling is not
supported right now [1]) according to the documentation:
- For GMail, it leverages the IMAP STORE command.
- For Proton, it leverages moving the message across (virtual) folders.
[1] There's nothing fundamental preventing supporting toggling, but
getting the current "label state" from there in the code is not trivial.
It could be done in a second step if there's demand).
Changelog-added: Support :modify-labels command for GMail and Proton.
Signed-off-by: Simon Martin <simon@nasilyan.com>
Tested-by: Jan Černohorský <jan@grsc.cz>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
Pass the focus changes to the content of the currently active tab if it
wants to be notified of them.
Signed-off-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
Update to latest Vaxis tag, which includes support for focus events in
the terminal widget.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
When typing inside textinput, Ctrl+Left places the cursor at the start
of the current word, and Ctrl+Right goes to the start of the next one.
Ctrl+Left uses the same code `deleteWord()` function used (which is now
split into a separate function), and Ctrl+Right uses similar lookup in
the other direction.
Implements: https://todo.sr.ht/~rjarry/aerc/231
Signed-off-by: GregTheMadMonk <yagreg7@gmail.com>
Tested-by: skejg <grolleman@zoho.com>
Acked-by: Robin Jarry <robin@jarry.cc>
During development, generating coredumps can be very helpful when
debugging crashes. Add runtime environment variable to dev target to
dump core by default on dev builds.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
While it negotiates the X-GM-EXT-1 capability with GMail, aerc defaults
to not using it because the use-gmail-ext configuration knob defaults to
false.
This patch simply dismantles that knob, so that GMail users always
benefit from all its capabilities.
Changelog-added: Always use `X-GM-EXT-1` extension if negotiated
with GMail.
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Contrary to popular belief, not all recipients of a mail are listed in
it's To: header. They may also be included in the Cc: or Bcc: headers.
Include them in the list when filtering.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
Use the GMail IMAP extension to fetch labels for messages when
use-gmail-ext is enabled. Labels are automatically fetched when fetching
headers for a message and when fetching flags for a message. They should
be correctly cached.
Link: https://developers.google.com/workspace/gmail/imap/imap-extensions
Changelog-added: Readonly support for GMail labels.
Signed-off-by: Jan Černohorský <jan@grsc.cz>
Tested-by: Vojtěch Káně <vojta001@vkane.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
Allow piping composed messages that are about to be sent in the compose
review mode. This enables users to process or inspect messages before
sending them.
Update documentation to reflect this new capability.
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Acked-by: Robin Jarry <robin@jarry.cc>
Move doExec and doTerm functions to package level. Both functions now
accept parameters for command, reader, name, and callback. doTerm
additionally accepts a silent flag.
This refactoring is a preparation to add COMPOSE_REVIEW to the supported
contexts.
Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
Acked-by: Robin Jarry <robin@jarry.cc>
When forwarding an email using edit-headers=true, using :switch-account
alone is not enough to properly switch the account since you have to
change the From header manually. Add the -x [account] option to :forward
in order to switch the account before opening the composer, to remove
this friction when we already know we want to forward with a different
account.
Changelog-added: Forward with a different account than the current
one with `:forward -x <account>`.
Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
inwit reported on IRC that when receiving a new email (on his O365
account) in the currently selected folder, the unread counter is updated
as it should, but that the message list won't show the new mail until
navigating out of then back into the directory.
Traces that we captured together [1] show that O365 notifies aerc of the
update with a MailboxUpdate message, but does NOT report a different
UIDNEXT (I believe it's a bug; other providers do). It does however
report that the folder has more messages, and we can use this to force a
refetch (we'd have done so if they'd reported a different UIDNEXT).
[1] Lines 9-10 from https://paste.sr.ht/~inwit/8b7696456de831adc8e169e7f34b9f08c0a8971b
Reported-by: inwit <inwit@sindominio.net>
Signed-off-by: Simon Martin <simon@nasilyan.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
I've been working with skejg on a regression from 0.20 that he's seeing
with his Zoho account: when receiving a new email, the unread counter is
incremented but the message list is not updated.
The change in scope is 96603ea04e, that uses the directory name
instead of "" when LIST STATUS'ing a single directory, which improves
overall performance, especially for accounts with many folders.
The problem is that Zoho does not give an error in such a case, but also
does not return *any* status, making the CheckMail command virtually a
no-op.
This patch works this around (while not removing the performance benefit
to "normal providers") by always restricting the LIST STATUS' ref if a
single directory is required, and in case it returns neither a status
nor an error, do another LIST STATUS with "" as ref.
Fixes: 96603ea04e ("imap: only restrict list-status to a single directory when we can")
Reported-by: skejg <grolleman@zoho.com>
Signed-off-by: Simon Martin <simon@nasilyan.com>
Tested-by: skejg <grolleman@zoho.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This adds support for the :toggle-headers command from the message list,
which will flip the config value and refresh the split if open.
Signed-off-by: Terrance <git@terrance.allofti.me>
Acked-by: Robin Jarry <robin@jarry.cc>
The only think worse than no documentation is incorrect documentation...
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
It's currently possible to delete mails (*not* move to Trash) from any
folder. What a delete action does depends on the mail client, and it is
often synonymous to "Move to trash", and aerc's behaviour can surprise
users (who will find out too late, when their mail is gone forever...).
This patch adds a configuration setting to control whether deletes are
allowed from any folder, or are restricted to the Trash and Junk
folders.
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Users can specify that messages should be marked as read when they're
viewed, but not when they're previewed in a message list split.
This patch makes it possible via two configuration knobs: one stating
whether the split message viewer should mark messages as read (off by
default), and one specifying the delay after which to do it.
Fixes: https://todo.sr.ht/~rjarry/aerc/126
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
As part of my analysis about read/unread, I noticed a bug in 8fc6ddd2:
the worker bit wrongly assumes that we can only have an ExpungeHandler
for deletes, and that MessageUpdates for messages in the ExpungeHandler
should therefore be ignored (because another one will arrive later).
This assumption is however wrong, and we should NOT ignore those updates
if the ExpungeHandler was built for a move action.
Fixes: 8fc6ddd292 ("imap: support various provider policies for expunge calls")
Signed-off-by: Simon Martin <simon@nasilyan.com>
Tested-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
As part of my analysis about read/unread, I noticed another bug in
8fc6ddd2: if we're notified of a deletion that we are unable to resolve
in the ExpungeHandler, we should revert to using the sequence instead of
erroring out.
Fixes: 8fc6ddd292 ("imap: support various provider policies for expunge calls")
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
While investigating a reported slowness when marking messages (un)read,
I noticed an issue with commit 7cb8e0e7ce: it systematically updates
the Seen count using the unsolicited message's status. This is wrong
because we might receive that message long after we updated things on
our end, or at the next action on the message (e.g. opening it).
We need to compare the status reported by the server with ours, and only
if they differ update the counter with what the server states.
Doing so also allows to fix the reported slowdown by reflecting Seen
flag updates right after an explicit :[un]read command, instead of
deferring to the confirmation by the IMAP server, and paying the
(unnecessary) latency of a round-trip. It is safe because we will only
do it after a successful UidStore call, hence confirmation from the IMAP
server of the flag change.
Fixes: 7cb8e0e7ce ("imap: properly handle out-of-band Unseen flag updates")
Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CDACPBQ04UHUF.30CJJ4QKJDYLY@zoho.com%3E
Reported-by: skejg <grolleman@zoho.com>
Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Robin Jarry <robin@jarry.cc>
We have the ability to pipe data to a QuickTerm via its stdin argument.
This function creates a virtual terminal and uses its OnStart callback
to read from stdin and write it to the created command pipe.
The OnStart callback is invoked in app.Terminal.Draw but in that case,
it waits until all data has been read and copied before returning which
prevents the main thread from actually rendering less displaying that
data on screen which blocks everything.
Keep the data copying completely async and out of the main thread to
avoid dead locking.
Reported-by: Simon Martin <simon@nasilyan.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Simon Martin <simon@nasilyan.com>