Commit Graph

399 Commits

Author SHA1 Message Date
Tim Culverhouse 56dabb5c9c msgstore: leave visual-mark mode after certain commands
Commit "4753cfd visual-mode: deselect messages after performing command"
introduced the behavior of leaving visual mark mode after performing
certain commands. Add this behavior to additional commands:

- Delete
- Archive
- Move

Remark the selected mail files if an error occurred during the
operation.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:37:35 +02:00
Tim Culverhouse db195bebf0 commands: add check-mail command
Add :check-mail command for ad-hoc checking of mail. Reset timer for
automatic checking if it is enabled.

Suggested-by: staceee
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:37:28 +02:00
Robin Jarry c816103a24 pipe: fix ordering by message id for long patch series
Git send-email Message-Id headers have the following format:

   DATETIME.PID-NUM-COMMITTER

Unfortunately, when there are more than 9 patches, the patch number
(NUM) is not zero-padded which makes ascii sorting invalid, e.g.:

   1 10 11 12 2 3 4 5 6 7 8 9

Instead of:

   1 2 3 4 5 6 7 8 9 10 11 12

We need the patches to be ordered correctly to pipe them to git am.

Make sure to pad the patch number with zero characters to allow series
of up to 999 patches.

Only re-order messages before piping them if all the Message-Id headers
look like git-send-email headers.

Link: https://github.com/git/git/blob/v2.36.0/git-send-email.perl#L1197
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-08-01 09:38:15 +02:00
Stas Rudakou ca90343850 outgoing-cred-cmd: delay execution until an email needs to be sent
This can be useful in cases when:

1. outgoing-cred-cmd requires a user action or confirmation (e.g. when
   using pass with a Yubikey or similar smart card that requires a user
   to enter a pin or touch the device when decrypting the password)

2. A user starts aerc frequently, but not all the sessions end up with
   sending emails

3. So the user only wants to execute outgoing-cred-cmd when the password
   is really used, so the user doesn't have to enter pin or touch their
   Yubikey each time aerc starts

Signed-off-by: Stas Rudakou <stas@garage22.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-31 19:53:13 +02:00
Tim Culverhouse 6db766260b sort: clear sort criteria when called without arguments
Fix a regression introduced by commit c2f4404fca ("threading: enable
filtering of server-side threads"). Prior to this commit, a :sort
command (no args) would clear out the current sort criteria (or rather,
apply the value from the config). Restore this functionality.

Fixes: c2f4404fca ("threading: enable filtering of server-side threads")
Reported-by: akspecs <akspecs@gmail.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:24:01 +02:00
Koni Marti 26b9c3d966 sort: show warning when sort is not supported
Use the capabilities returned by the backend to check whether sort is
implemented when the user tries to use the sort command. Print a warning
to the log when a sort request is silently dropped by the backend.

Suggested-by: |cos|
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:22:58 +02:00
Koni Marti d941960fe1 delete: improve find next function
Improve the function to find the next valid message after the delete
operation. This ensures that messages at the end or when marked in the
visual mode are properly dealt with.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 11:34:31 +02:00
Koni Marti 8f7695fde5 msgstore: implement a uid-based architecture
Change the message store architecture from an index-based to a uid-based
one. Key advantage of this design approach is that no reselect mechanism
is required anymore since it comes with the design for free.

Fixes: https://todo.sr.ht/~rjarry/aerc/43
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 11:34:19 +02:00
Tim Culverhouse 9bfcec5660 delete: select new last message if last message was deleted
If the last message is deleted, the new selection should be the last
message instead of the first message.

Fixes: https://todo.sr.ht/~rjarry/aerc/59
Reported-by: Sebastien Binet <s@sbinet.org>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-24 23:05:53 +02:00
Tim Culverhouse 80f8bab6cf delete: move tab replace logic into Done callback
Move tab replacement logic for next-message-on-delete into the
callback. This also moves the Invalidate() call into the callback, and
should make imap deletion UI work more reliably - there is a race
condition between the worker and the UI in displaying deleted messages.
This should resolve the race condition, and also only remove the MsgView
tab if the message is actually deleted.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-24 23:05:11 +02:00
Robin Jarry cd19995557 logging: use level-based logger functions
Do not pass logger objects around anymore. Shuffle some messages to make
them consistent with the new logging API. Avoid using %v when a more
specific verb exists for the argument types.

The loggers are completely disabled (i.e. Sprintf is not even called)
by default. They are only enabled when redirecting stdout to a file.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-23 22:52:15 +02:00
Robin Jarry 171fefd209 tabs: make fields private
The Tabs object exposes an array of Tab objects and the current selected
index in that array. The these two fields are sometimes modified in
goroutines, which can lead to data races causing fatal out of bounds
accesses on the tab array.

Hide these fields as private API. Expose only what needs to be seen from
the outside. This will prepare for protecting concurrent access with
a lock in the next commit.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-07-23 22:00:25 +02:00
Robin Jarry c841f36513 tabs: rename SelectedTab to SelectedTabContent
This function returns an ui.Drawable. Use a more explicit name. This
prepares for adding a new SelectedTab function which will return
an ui.Tab.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-07-23 22:00:21 +02:00
Koni Marti 76b39311dc send: enter no-quit mode until message is sent
Protect the sending of a message by entering the no-quit mode. This
prevents aerc from exiting with the :quit command until the operation is
done or the exit is forced.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:15:13 +02:00
Koni Marti e200cd56bf commands: implement a no-quit mode
Add a mode that prevents aerc from quitting normally when an important
task is performed, i.e. when sending a message. The no-quit mode will be
ignored when quit is used with the -f option to force an exit.

Suggested-by: ph14nix[m]
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:15:02 +02:00
Koni Marti 5102d32cea pipe: use go-mbox for writing multiple messages
Use go-mbox for piping out multiple messages in the mbox format.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:14:59 +02:00
Koni Marti e572087e58 account: import mbox file to a folder
Append all messages from an mbox file to the selected folder with the
import-mbox command.

User confirmation is required when the folder already contains messages.

A failed append will be retried a few times. If a backend timeout
occurs, the entire import is stopped to prevent a hang.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:14:56 +02:00
Koni Marti 845763cb1f account: export folder to mbox file
Export all message in the current folder to an mbox file. If an error
occurs during the export, aerc retries a few times before giving up to
prevent a hang.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-14 23:14:54 +02:00
Tim Culverhouse a953e4dbe9 threading: refactor reselect logic
This patch refactors reselection of a message during certain operations
(searching, filtering, clearing, deleting, moving, new message arrival).
The addition of server-side filtering for threaded views broke the
existing reselection logic.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse c2f4404fca threading: enable filtering of server-side threads
This patch enables the filtering of a threaded view which uses
server-built threads. Filtering is done server-side, in order to
preserve the use of server-built threads.

In adding this feature, the filtering of notmuch folders was brought up
to feature parity with the other workers. The filters function the same
(ie: they can be stacked). The notmuch filters, however, still use
notmuch syntax for the filtering.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse 3a614e45fc threading: enable toggle-threads for server-side threads
Enable the :toggle-threads command to work for workers which have Thread
capability. The implementation of that feature has the side effect that
the threading-enabled config option now sets the default view (threaded
or not threaded) for any worker, not just IMAP or notmuch.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Koni Marti e19b411e52 recall: support pgp/mime messages
PGP/MIME messages are stored encrypted and/or signed in the draft folder
for security reasons. Recall will open them through the lib.MessageView
interface in order to display the message content properly in the
composer tab. If the stored message was encrypted or signed, the
recalled message in the composer will also be encrypted or signed.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:39:53 +02:00
Koni Marti a293a39454 recall: append attachments
Append attachments to the composer when a message with attachments is
recalled. Before the attachement refactoring in the composer, the
recalled attachments were ignored.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:39:46 +02:00
Koni Marti 4335eeceb3 recall: confirm deleting message when not sent
Ask for user confirmation when a recalled message is deleted after the
composer is closed but the message has not been sent yet. The message
will only be deleted automatically when the message is sent. This might
prevent data loss since the recalled message is currently deleted either
way.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:39:42 +02:00
Koni Marti 99b74dbcc9 postpone: avoid calling WriteMessage twice
Postpone will currently call composer.WriteMessage twice: once for
counting the bytes and another time for appending the message.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:36:24 +02:00
Sergey Smirnykh 12e8217d1f commands: implement prompt completion
This patch implements :prompt completion.
The completion mechanism only provides completions when there is at least
one argument specified (prompt text).
The mechanism is based on other commands' completions and works as follows:

   1. Attempts to look up a command by the name specified in args[1].

   2.a On success it uses command.Complete.

   2.b Otherwise, if total arguments count is lesser or equals than 2
       (i.e. no command arguments specified), it attempts to complete
       the command's name.

Additional effort is made to preserve prompt text, which often contains
spaces and formatting.

Signed-off-by: Sergey Smirnykh <sergey.smirnykh@siborgium.xyz>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-02 18:36:40 +02:00
Koni Marti c04446327e forward: remove crlf in text body
Remove crlf from the text body when forwarding a message.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-07-02 17:53:11 +02:00
Koni Marti 60052c6070 forward: provide option to append all attachments
Append all non-multipart attachments with the -A flag. Rename the flag
for forwarding a full message as an RFC2822 attachments to -F.

Suggested-by: psykose
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-07-02 17:53:06 +02:00
Koni Marti 9d90b70b4e compose: refactor attachment handling
Refactor the attachment handling process in the composer. The composer
can currently only handle attachments that are stored as files (or pgp
keys). This patch removes this limitation so that any message part can
be handled as an attachment. With this we can treat files, pgp keys and
message parts on an equal footing and it will enable us also to easily
forward attachments.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-07-02 17:52:49 +02:00
Tim Culverhouse 96db50c4f0 open: fix mimetype discovery for encrypted or signed messages
Mimetype discovery for the :open command is based on the BodyStructure
of the message. This patch fixes the method which got the BodyStructure
of the message to a more generalized one, which is set post-encryption
and post-validation. This allows encrypted or signed message parts to
have their proper mimetype discovered.

Fixes: https://todo.sr.ht/~rjarry/aerc/50
Reported-by: ~ph14nix
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-06-26 12:07:44 +02:00
Tim Culverhouse 8f9bb2b289 pgp: fix pipe|open|save command behavior
Signed and/or encrypted PGP messages did not behave properly for pipe,
open, and save commands. Specifically, the proper Message Part would not
be passed to the command in the MessageViewer. This is due to the
encapsulation of the body structure. This patch fixes the behavior for
piping|opening|saving of message parts.

Fixes: https://todo.sr.ht/~rjarry/aerc/47
Reported-by: ~ph14nix
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-24 21:08:21 +02:00
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
Tim Culverhouse 4753cfd3e3 visual-mode: deselect messages after performing command
In order to better align to vim functionality: deselect visual mode
selections after performing a command on the selection. This patch also
introduces a new command to allow for re-selecting (remarking) the
previous selection set so that commands can be chained together. The
deselection only applies to msg commands that *do not* move the message
from the store (those types of commands already deselect):
- read/unread
- flag/unflag
- modify-labels
- copy
- pipe

Previous usage to mark several messages as read and deselect all:
Vjjj:read<Enter>:unmark -a<Enter>

New usage, similar to vim:
Vjjj:read<Enter>

To chain a command together:
Vjjj:read<Enter>:remark<Enter>{next command}<Enter>

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-14 22:12:42 +02:00
Koni Marti 461726802e unsubscribe: select method with the selector dialog
Provide a choice to the user with the selector dialog to select the
desired unsubscribe method. Before, the first method that appeared in
the list-unsubscribe header was used.

For the http method, the user can now also confirm whether he wants to
open the provided link in the browser or not.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-31 14:32:33 +02:00
Koni Marti 62982a9a67 invites: reply with accept, accept-tentative or decline
Reply to iCalendar invitations with three commands: :accept,
:accept-tentative or :decline. Parse a text/calendar request, create a
reply and append it to the composer.

Suggested-by: Ondřej Synáček <ondrej@synacek.org>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-31 14:32:24 +02:00
Tim Culverhouse f4d4e2b4e1 help: add completions
Add :help completion arguments (config, imap, etc). The option "aerc"
brings up the general manpage

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-05-23 20:59:10 +02:00
Tim Culverhouse b57fceaad4 pgp: add attach key command
Add compose command ("attach-key") to attach the public key associated
with the sending account. Public key is attached in ascii armor format,
with the mimetype set according to RFC 3156 ("application/pgp-keys").

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-05-06 11:02:55 +02:00
Tim Culverhouse 32a16dcd8d pgp: check encryption keys before sending message
Add check for public keys of all message recipients (to, cc, and bcc)
before sending the message. Adds an OnFocusLost callback to header
editors to facilitate a callback for checking keys whenever a new
recipient is added (OnChange results in too many keyring checks).

Once encryption is initially set, the callbacks are registered. If a
public key is not available for any recipient, encryption is turned off.
However, notably, the callbacks are still registered meaning as s soon
as the user removes the recipients with missing keys, encryption is
turned back on.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-05-06 11:02:50 +02:00
Tim Culverhouse dbf52bb4b4 pgp: check for signing key before signing time
Check that the signing key exists when the user issues the :sign
command. The signing key ID will be displayed in the security status
also, allowing the user to see what key will be used to sign the
message.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Jens Grassel <jens@wegtam.com>
2022-05-04 14:07:15 +02:00
inwit a1b75a99bd recall: mention the -f option in the error message
Commit bc593ac7cd ("recall: allow recalling messages from any folder")
added the possibility to recall any message by providing the -f flag.
Mention the flag in the error message.

Signed-off-by: inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-29 15:02:28 +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
Koni Marti 25a8a00c55 filter: clear filter when called with no args
Clear filter when called with no arguments.

Fixes: https://todo.sr.ht/~rjarry/aerc/35
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-25 11:22:04 +02:00
Koni Marti cb887a2d9d store: keep current message selected
Keep current message selected when clearing or changing filters and when
toggling threads.

Add -s flag to the clear command to also clear the selected message and
set cursor to the top of the message list.

Implements: https://todo.sr.ht/~rjarry/aerc/36
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-17 12:18:33 +02:00
Tim Culverhouse 6a87d8be72 forward: allow ':forward -A' with no address
Allow using the command ':forward -A' without specifying an email
address inline.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-14 23:48:25 +02:00
Moritz Poldrack 4dbdf58688 fix: out-of-bounds error in command header
This commit fixes an out-of-bound error that happened while parsing
commands.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-06 15:37:13 +02:00
Moritz Poldrack 3c08b8e6a9 header: remove trailing colon in header field
With this commit trailing colons in the :header command's field are
removed to prevent double-colon-headers from being sent.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-06 15:37:13 +02:00
Evan Gates 1aa32bf377 compose: parse headers correctly from -H
By using :compose -H <header> a user should be able to add
arbitrary headers to an email.  The existing implementation from
5b523880b4 added the headers as lines
to the beginning of the body.  These lines were not interpreted as
headers anywhere and ended up as plain text in the body of the email.
Fix the code to parse and add the headers correctly.

Signed-off-by: Evan Gates <evan.gates@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-04-06 15:37:13 +02:00
Robin Jarry 2fd9cef568 save: fix path completion
Ignore option flags and prepend default-save-path if the current path is
not absolute.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
2022-03-31 12:55:07 +02:00
Koni Marti fc604b6679 statusline: indicate when sorting is in progress
Indicate when sorting is in progress in the statusline.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-25 13:07:25 +01:00
Koni Marti e50ab59284 sort: keep sort criteria applied to folder
Keep the sort criteria applied to the selected folder until the default
sort order should be restored. Call the sort command without arguments
to restore the default sort order.

The current behavior is that the default sort order is restored as soon
as the folder reloads. This happens often and then the results of the
sort command are lost. This makes the sort command not very
user-friendly. Instead, we should keep the sort criteria applied until
the user explicitly wants to restore the default sort order again.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-25 13:07:20 +01:00
Robin Jarry d64ceba2cc save: add -a option to save all attachments
Allow saving all message parts that have the content disposition
"attachment" header to a folder.

Suggested-by: Ondřej Synáček <ondrej@synacek.org>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-03-24 15:30:10 +01:00
Moritz Poldrack ae83373fa6 logging: added a log on panic
Since panics still regularly "destroy" the terminal, it is hard to get a
stack trace for panics you do not anticipate. This commit adds a panic
handler that automatically creates a logfile inside the current working
directory.

It has to be added to every goroutine that is started and will repair
the terminal on a panic.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-23 20:56:09 +01:00
Koni Marti feecc09b73 statusline: make statusline folder-specific
Make statusline folder-specific. Update filter, search and threading
status when changing folders.

Commit 2512c04 ("statusline: implement per-account status") introduced
an account-specific statusline. This makes it account- and
folder-specific.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2022-03-23 20:55:30 +01:00
Tim Culverhouse e56648029f compose: make headerEditor focusing more reliable
Focusing header editors was hardcoded as integers which only worked with
the default ui. If a user changed the UI to, for example, put CC as a
field below "to", FocusSubject would focus the CC field instead of the
subject. This commit reuses and modifies the function FocusEditor to
generalize the focusing of header editors - which can now be called by
name via FocusEditor(name string)

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-22 09:50:32 +01:00
Koni Marti 2512c0403f statusline: implement per-account status
Implement a statusline state for each account. Keep the ex line and the
push notifications global. Add account name prefix to push
notifications. Prefix status line with account name when multiple
accounts are available.

Use account-specific status line for each tab where an account is
defined.

Handle threading, filter/search, viewer passthrough and connection
status.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-18 23:42:07 +01:00
kt programs a0fceb80b3 commands: use SelectedAccountUiConfig instead of explicit nil check
Remove code duplication and provide completion even when acct is nil

Signed-off-by: kt programs <ktprograms@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-16 17:02:36 +01:00
kt programs a16bd05321 commands: fix possible panic in CompletionFromList
Panic might occur if aerc.SelectedAccount() is nil

Signed-off-by: kt programs <ktprograms@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-16 17:02:29 +01:00
Koni Marti 7d9ae36977 bindings: fix panic for terminal keybind
Fix panic in the GetCompletions function when using the keybind for the
terminal command.

Fixes: https://todo.sr.ht/~rjarry/aerc/29
Reported-by: inwit <inwit@sindominio.net>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-14 22:57:18 +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
Moritz Poldrack 4bc43d2741 all: fix minor issues found by staticcheck
Signed-off-by: Moritz Poldrack <git@moritz.sh>
2022-03-12 21:00:23 +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
Moritz Poldrack 2f575c00ec reply: add automatic replacement of localized Re:
Some MUAs (namely Outlook) use localized prefixes for replied-to and
forwarded mail. With this patch aerc replaces known localized prefixes
and repetitions with the common Re: prefix.

Link: https://office-watch.com/2014/outlook-reply-forward-prefixes/
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-03 21:31:26 +01:00
Robin Jarry 115dabb634 pipe: allow piping multiple marked messages
When messages are marked, pipe their contents into the specified
command. The messages are ordered according to their respective
Message-Id headers. This allows applying complete patch series with
a single command.

When piping more than one message, make sure to write them in the mbox
format as git am expects them to be.

Link: https://en.wikipedia.org/wiki/Mbox
Link: https://github.com/git/git/blob/v2.35.1/builtin/mailsplit.c#L15-L44
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: akspecs <akspecs@gmail.com>
2022-02-25 13:56:53 +01:00
Robin Jarry c26d08103b aerc: always check SelectedAccount return value
aerc.SelectedAccount() is used in lots of places. Most of them without
checking the return value.

In some cases, the currently selected tab is not related to any account
(widget.Terminal for example). This can lead to unexpected crashes when
accessing account specific configuration.

When possible, return an error when no account is currently selected.
If no error can be returned, fallback to non-account specific
configuration.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
2022-02-25 13:56:53 +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
Robin Jarry 8935c45293 search/filter: display in extra status
Add an extra attribute to the status line. When non-empty, display it
after the current status.

Set that extra status after a successful :search or :filter. Remove it
after :clear.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-23 11:27:19 +01:00
Robin Jarry e384203390 search/filter: remove from status bar after 20 seconds
The status is not cleared. It is annoying.

Fixes: c37f1eaaea ("filter/search: display current search/filter arguments")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-19 22:29:40 +01:00
inwit c37f1eaaea filter/search: display current search/filter arguments
Make the statusbar message after search and filter completion more
informative by showing the full call that was used.

Signed-off-by: inwit <inwit@sindominio.net>
2022-02-19 18:07:33 +01:00
Koni Marti 287df9defb unsubscribe: parse internationalized headers
Fix the parsing of internationalized headers (RFC 6532). Enable
unsubscribe to work with regular and encoded headers.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-02-19 15:46:23 +01:00
Koni Marti 4bd4f4664a postpone: re-open review mode on error
re-opens the review UI when the postpone operation fails. Before, the
composer would close, even on error, and we would lose the email draft.
Now, the user can decide on how to proceed when postponing fails.

References: https://lists.sr.ht/~rjarry/aerc-devel/patches/28824
Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-02-06 17:06:20 +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
Koni Marti cdec23323c recover: recover emails from tempdir after a crash
implements a recover command that searches the local temp dir for aerc
emails. If a file is found and selected, a new composer tab will open
with the file contents as the message body. No header data is stored in
the temp file and thus this information cannot be recovered.

Recover will not remove the temporary file unless the force flag (-f) is
explicitly used.

This recovery method only works when the editor buffer is saved to
disk and the Close() function of the composer has not been called yet.

Sending, postponing or quitting will call the Close() function which
removes the temporary file completely. After Close() is called, no
recovery is possible anymore.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-29 22:01:25 +01:00
Robin Jarry 7edcc9f794 reply: use new-message template for non-quoted replies
Unless a template is specified with reply -T, use the new-message
template for non-quoted replies.

Fixes: 877a94f5d9 ("compose: add default template for new messages")
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-01-27 09:16:54 +01:00
Koni Marti e5ad877af5 msgstore: fetch missing headers in visual mode
fetches missing headers when in visual selection mode. This prevents
large archive operations from panicking due to a nil pointer
dereference.

The archive command will return an error to the ui when a nil message is
encountered to signal that the message store is not ready yet.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-22 17:07:50 +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
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
inwit bc593ac7cd recall: allow recalling messages from any folder
Recall fails when called outside of the "postpone" folder (usually
"Drafts"). This makes sense for postponed messages. However, sometimes
the user would like to re-edit and re-send an old, possibly sent,
message, which would serve as a basis for the new one.

This patch allows recall to work outside the postpone folder, thus
allowing for re-edition of any message.

In the original recall function, if the recalled message is found in the
"postpone" folder, once the message has been recalled, re-edited and
sent, the original draft is deleted. With this patch, when the message
is not in the "postpone" folder, the original message is not deleted.

Signed-off-by: inwit <inwit@sindominio.net>
2021-12-13 14:56:39 +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 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
Reto Brunner 413fc431f7 add mimeType to OriginalMail struct for both forward and reply 2021-03-07 14:52:42 +01:00
Reto Brunner 8cd2485170 send: fix missing error return 2021-02-28 02:05:12 +01:00
Reto Brunner 8b4f2d148c Fix linter warnings
* Remove redundant return (code was never reached)
* Remove redundant type information
* Rename unused function parameters to "_"
2021-02-26 22:14:58 +01:00
Reto Brunner 2d2010fd42 send: fix crash if invalid password is given 2021-02-05 21:20:17 +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
Reto Brunner 949781fa0a Refactor lib/open to accept user provided arguments
* Get rid of open_darwin
	It just lead to code duplication for a simple one string change.
	Instead we query it during initialization
* Accept user provided arguments
	"open" on MacOS accepts things like -A to use a specific application
	Pass trough arguments the user provided in order to facilitate this
* Refactor the function to a struct
	This makes it more convenient for the caller and avoids signatures like
	lib.OpenFile(nil, u.String(), nil) which are fairly unreadable
2021-01-30 14:04:23 +01:00
Reto Brunner 9385827cae send: don't block the UI thread during the sending 2021-01-24 18:00:23 +01:00
Robin Opletal 3720c86236 save: if part name is a path, only use the filename 2021-01-14 07:17:23 +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 67923707ff Refactor send command 2020-11-21 15:40:50 +01:00
Reto Brunner 7b12f2d1ea reply: add References header 2020-11-14 15:40:13 +01:00
Reto Brunner 256af6322b allow the loading of existing headers 2020-11-14 15:40:13 +01:00
Reto Brunner 24f1c575ae format: remove parse methods, use the one from go-message 2020-11-14 15:40:13 +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 3ad3a5ede0 models: add RFC822 headers to OriginalMail 2020-11-14 15:40:13 +01:00
Reto Brunner fc9ccc3000 remove models.Address in favor of go-message Address
We made a new type out of go-message/mail.Address without any real reason.
This suddenly made it necessary to convert from one to the other without actually
having any benefit whatsoever.
This commit gets rid of the additional type
2020-11-14 15:40:13 +01:00
y0ast 42ce6b41ff propagate error from sendmail 2020-09-22 08:12:38 +02:00