Commit Graph

145 Commits

Author SHA1 Message Date
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
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 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 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
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 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 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
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
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
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 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 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
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
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 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
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 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
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 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 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 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 7b12f2d1ea reply: add References header 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
Reto Brunner 8bf100f7b4 reply: don't override the answered flag if we didn't send
Aerc just sent the true / false update regardless, meaning if someone already
replied to a mail, then drafted yet another mail to the same parent the flag
would vanish. This commit fixes this behaviour.
2020-09-21 20:43:22 +02:00
Reto Brunner 720733bc6e reply: use set instead of linear search 2020-08-27 08:38:41 +02:00
Reto Brunner 186d61f21c msg/reply: don't cc the sending address on reply all 2020-08-20 21:54:33 +02:00
y0ast 6a1c0f60af Add account alias configuration and correctly set From field
We infer the correct From using the To: and Cc: field of the email that
we reply to.
2020-08-20 21:54:31 +02:00