aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
Commit message (Collapse)AuthorAgeFilesLines
* reply: consider the From address too when checking aliasesKarel Balej2024-10-241-0/+1
| | | | | | | | | | | | | This sets the likely usually desired From address when replying to a previously sent email and does not compose To the alias instead (unless reply-to-self is enabled). Changelog-fixed: Aliases are now taken into account correctly when replying to own messages such as from the Sent folder or via a mailing list. Signed-off-by: Karel Balej <balejk@matfyz.cz> Acked-by: Robin Jarry <robin@jarry.cc>
* completion: add command option descriptionsRobin Jarry2024-10-2316-54/+54
| | | | | | | | | | | | | Add `desc:""` struct field tags in all command arguments where it makes sense. The description values will be returned along with completion choices. Implements: https://todo.sr.ht/~rjarry/aerc/271 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* completion: add commands descriptionsRobin Jarry2024-10-2318-0/+72
| | | | | | | | | | | | | | | Update the Command interface to include a Description() method. Implement the method for all commands using short descriptions inspired from the aerc(1) man page. Return the description values along with command names so that they can be displayed in completion choices. Implements: https://todo.sr.ht/~rjarry/aerc/271 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* viewer: avoid crashes on opening invalid messagesRobin Jarry2024-10-222-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an error occurs during the opening of a message because its contents cannot be parsed, the PartSwitcher object is left to nil and the err field is set to the reported error. This defers the error reporting after the viewer tab is displayed but it is not handled in all sub functions which assume that switcher cannot be nil. Error: runtime error: invalid memory address or nil pointer dereference git.sr.ht/~rjarry/aerc/app.(*PartSwitcher).Show(...) /build/aerc/src/aerc/app/partswitcher.go:77 git.sr.ht/~rjarry/aerc/app.(*MessageViewer).Show(...) /build/aerc/src/aerc/app/msgviewer.go:409 git.sr.ht/~rjarry/aerc/lib/ui.(*Tabs).selectPriv(...) /build/aerc/src/aerc/lib/ui/tab.go:181 git.sr.ht/~rjarry/aerc/lib/ui.(*Tabs).Add(...) /build/aerc/src/aerc/lib/ui/tab.go:75 git.sr.ht/~rjarry/aerc/app.(*Aerc).NewTab(...) /build/aerc/src/aerc/app/aerc.go:511 git.sr.ht/~rjarry/aerc/app.NewTab(...) /build/aerc/src/aerc/app/app.go:61 git.sr.ht/~rjarry/aerc/commands/account.ViewMessage.Execute.func1(...) /build/aerc/src/aerc/commands/account/view.go:71 git.sr.ht/~rjarry/aerc/lib.NewMessageStoreView.func1(...) /build/aerc/src/aerc/lib/messageview.go:80 git.sr.ht/~rjarry/aerc/lib.NewMessageStoreView(...) /build/aerc/src/aerc/lib/messageview.go:124 git.sr.ht/~rjarry/aerc/commands/account.ViewMessage.Execute(...) /build/aerc/src/aerc/commands/account/view.go:52 git.sr.ht/~rjarry/aerc/commands.ExecuteCommand(...) /build/aerc/src/aerc/commands/commands.go:205 main.execCommand(...) Remove that private err field and return an explicit error when the message cannot be opened to enforce handling of the error by the caller. When the msg argument is nil (only used in split viewer), return an empty message viewer object and ensure that all code paths that read the switcher or msg fields perform a nil check before accessing it. Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C12c465e4-b733-4b15-b4b0-62f87429fdf7@gmail.com%3E Link: https://lists.sr.ht/~rjarry/aerc-devel/%3C2C55CF50-A636-46E5-9BA8-FE60A2303ECA@proton.me%3E Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD51PEB6OMNDT.1KVSX0UCNL2MB@posteo.de%3E Reported-by: Benjamin Braun <ben.braun@posteo.de> Reported-by: Filip <filip.sh@proton.me> Reported-by: Sarthak Bhan <sbstratos79@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* invite: honor the -a flag for :sendinwit2024-10-211-1/+9
| | | | | | | | | | | | When sending replies to invitations with :accept, :accept-tentative or :decline, calling `:send -a` in the review screen does not archive the original invitation, as it should. Solve this situation and allow for directly archiving invitations after replying to them. Changelog-fixed: Invitations now honor the -a flag for :send. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: make {{.OriginalText}} available to custom templatesJohannes Thyssen Tishman2024-10-121-8/+6
| | | | | | | | | | | | Currently {{.OriginalText}} is only available to the quote-reply template when using `:reply -q`. Allow templates specified using the `-T` flag to make use of it too. Changelog-changed: Templates passed to the `:reply` command using the `-T` flag can now make use of `{{.OriginalText}}`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* calendar: skip editor when replying to invitationsinwit2024-10-031-2/+7
| | | | | | | | | | | Most of the time, accepting an invitation does not require editing the automatically generated email before sending it. Allow the user to optionally skip the editor entirely and go directly to the review screen when dealing with invitations. References: https://todo.sr.ht/~rjarry/aerc/247 Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* treewide: replace uint32 uids with opaque stringsRobin Jarry2024-08-2812-23/+25
| | | | | | | | | | | | | | | | | Add a new models.UID type (an alias to string). Replace all occurrences of uint32 being used as message UID or thread UID with models.UID. Update all workers to only expose models.UID values and deal with the conversion internally. Only IMAP needs to convert these to uint32. All other backends already use plain strings as message identifiers, in which case no conversion is even needed. The directory tree implementation needed to be heavily refactored in order to accommodate thread UID not being usable as a list index. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* forward: better preserve attached file namesVitaly Ovchinnikov2024-08-241-2/+2
| | | | | | | | | | | Use a dedicated filename function for getting a name of the attached file instad of analyzing its mime type. Some attachments have file name in `Content-Disposition` rather than `Content-Type`, the new method handles both cases. Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru> Acked-by: Robin Jarry <robin@jarry.cc>
* flag: manually toggle the forwarded taginwit2024-08-201-5/+13
| | | | | | | | | | Allow the user to manually set, unset and toggle the forwarded tag. Changelog-added: The :flag command now sets/unsets/toggle the forwarded tag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* forward: allow forwarded flag to be setinwit2024-08-201-1/+10
| | | | | | | | | | | | Usually, a MUA sets a flag for messages that have been forwarded, but this is currently not the case for aerc. Consider the forwarded flag and prepare aerc to set it everytime the :forward command is called and ends successfully. Changelog-added: The :forward command now sets the forwarded flag. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* copy: add -d flag to decrypt before copyingKoni Marti2024-08-201-0/+32
| | | | | | | | | | | Add -d flag to the copy command to decrypt a message before copying it. Implements: https://todo.sr.ht/~rjarry/aerc/238 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jens Grassel <jens@wegtam.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* pipe: add -d flag to decrypt messageKoni Marti2024-08-201-0/+25
| | | | | | | | | | | Add -d flag to the pipe command to decrypt a message before it is piped. Implements: https://todo.sr.ht/~rjarry/aerc/238 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jens Grassel <jens@wegtam.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: allow copying to current folderRobin Jarry2024-08-032-3/+6
| | | | | | | | | Add a new copy-to-replied setting in accounts.conf to copy sent replies to the same folder than their replied message. Requested-by: Tristan Partin <tristan@partin.io> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
* reply: handle the Sender headerBence Ferdinandy2024-08-031-3/+12
| | | | | | | | | | | | | | | | | | | | | | Sometimes emails will have a Sender: header, that is different from the From: header. The only use of this in the wild I have seen to date is when meeting invitation is forwarded by somebody. The From: header will be the person organising the meeting, and the Sender: will be the person forwarding. Naturally, when one replies (e.g. with on accept), it should go to the meeting oragniser, but sometimes one would want to include the Sender in such a reply. When executing :reply determine the To: address in order of Reply-To:, From:, Sender:. When executing :reply -a, include the Sender: in Cc:. Implements: https://todo.sr.ht/~rjarry/aerc/259 Link: https://www.rfc-editor.org/rfc/rfc4021#section-2.1.3 Changelog-added: Replying to all will include the Sender in Cc. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Reviewed-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* cc,bcc,forward: add completion from address bookRobin Jarry2024-06-251-1/+5
| | | | | | | | | | | | Allow using the address book for completion in the :cc, :bcc and :forward commands. Changelog-added: The address book is now used for `:cc`, `:bcc` and `:forward`. Requested-by: Maximilian Bosch <maximilian@mbosch.me> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Maximilian Bosch <maximilian@mbosch.me>
* move: avoid crash when message list is not readyRobin Jarry2024-06-041-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following crash: panic: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: runtime/panic.go:770 +0x132 git.sr.ht/~rjarry/aerc/lib.(*MessageStore).Selected(...) git.sr.ht/~rjarry/aerc/lib/msgstore.go:709 git.sr.ht/~rjarry/aerc/commands/msg.Move.CallBack() git.sr.ht/~rjarry/aerc/commands/msg/move.go:178 +0x78 git.sr.ht/~rjarry/aerc/commands/msg.Move.Execute.func1() git.sr.ht/~rjarry/aerc/commands/msg/move.go:75 +0x90 git.sr.ht/~rjarry/aerc/lib.(*MessageStore).Move.func1() git.sr.ht/~rjarry/aerc/lib/msgstore.go:645 +0x138 When a move operation finishes, the callback is invoked but there is no guarantee that the target account has any message store ready (e.g. IMAP may be disconnected). Only access acct.Store() in the happy code path and even there, only use store if is is not nil. Fixes: 40c25caafd58 ("mv: allow to move messages across accounts") Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD114PEHTFKRE.2R9XF4U2BBDD6@mailbox.org%3E Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD118R1N4XZ1X.1ZFQPGG8DSCDA@schaeffer.tk%3E Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD1B2PVIVGPOZ.1925R9LL60EAZ@disroot.org%3E Reported-by: Alex Freudenberg <alexfxd@mailbox.org> Reported-by: Evin Yulo <yujiri@disroot.org> Reported-by: Maarten Aertsen <sagi+aerc-devel@rtsn.nl> Reported-by: Yuri Schaeffer <yuri@schaeffer.tk> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Tristan Partin <tristan@partin.io>
* pipe: allow closing the terminal automaticallyJohannes Thyssen Tishman2024-04-131-1/+2
| | | | | | | | | | | | | Add a new -s flag to :pipe. When specified, the terminal tab opened by the :pipe command will be automatically closed after the process is completed instead of prompting for a key press. While this doesn't technically silence the command (the output is not suppressed), the output is not shown to the user. Changelog-added: Silently close the terminal tab after piping a message to a command with `:pipe -s <cmd>`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* config: make popover dialogs configurableJohannes Thyssen Tishman2024-04-021-16/+1
| | | | | | | | | | | | Add the [ui].dialog-{position,width,height} options in aerc.conf to set the position, width and height of popover dialogs such as the one from :menu, :envelope or :attach -m relative to the main window. Changelog-added: Add `[ui].dialog-{position,width,height}` to set the position, width and height of popover dialogs. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: add strategies for multi-file messagesJason Cox2024-04-026-21/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A single notmuch message can represent multiple files. As a result, file-based operations like move, copy, and delete can be ambiguous. Add a new account config option, multi-file-strategy, to tell aerc how to handle these ambiguous cases. Also add options to relevant commands to set the multi-file strategy on a per-invocation basis. If no multi-file strategy is set, refuse to take file-based actions on multi-file messages. This default behavior is mostly the same as aerc's previous behavior, but a bit stricter in some cases which previously tried to be smart about multi-file operations (e.g., move and delete). Applying multi-file strategies to cross-account copy and move operations is not implemented. These operations will proceed as they have in the past -- aerc will copy/move a single file. However, for cross-account move operations, aerc will refuse to delete multiple files to prevent data loss as not all of the files are added to the destination account. See the changes to aerc-notmuch(5) for details on the currently supported multi-file strategies. Changelog-added: Tell aerc how to handle file-based operations on multi-file notmuch messages with the account config option `multi-file-strategy` and the `-m` flag to `:archive`, `:copy`, `:delete`, and `:move`. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Tested-by: Maarten Aertsen <maarten@nlnetlabs.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: rename confusing constantsRobin Jarry2024-03-0418-18/+18
| | | | | | | | There is an overlap between ACCOUNT and MESSAGE. Rename ACCOUNT to MESSAGE_LIST and use MESSAGE_LIST|MESSAGE_VIEWER instead of MESSAGE. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* commands: allow to forward from emlKoni Marti2024-02-141-7/+25
| | | | | | | | | | | Forward messages from the message viewer when they are opened with :eml (e.g. rfc822 attachments). Those messages have no associated message store and currently :forward would complain about that. References: https://todo.sr.ht/~rjarry/aerc/227 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: allow to reply to emlKoni Marti2024-02-141-6/+11
| | | | | | | | | | | | | | | | Reply to messages in the message viewer that were opened with :eml (e.g. rfc822 attachments). Those messages have no associated message store and currently :reply would complain about that. However, we can still use the message data to create a reply, but we would have to disable setting the replied flag and/or archiving messages (obviously, these operations don't make sense for such messages in the first place). Implements: https://todo.sr.ht/~rjarry/aerc/227 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* log: move package to libRobin Jarry2024-02-1411-11/+11
| | | | | | | This has nothing to do at the root of the source tree. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* commands: add bounceKarel Balej2024-02-121-0/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a command to allow for reintroduction of messages into the transport system. This means taking a message and forwarding it to new recipients as is including original headers. The fact that the message has been bounced is indicated by the prepend of *Resent-* headers in accordance with RFC 2822. The bounced message is not stored in the sent mailbox. Also add an `-A` switch to allow for bouncing using different account than the one currently selected. Also add default keybind and documentation entry for this command. The mentioned RFC also recognizes *Resent-Cc* and *Resent-Bcc* headers which might be an interesting continuation of this -- currently all recipients are specified in *Resent-To*. Also more control over the *Resent-From* header value could be implemented. This command is strongly inspired by (neo)mutt's `bounce`. Implements: https://todo.sr.ht/~rjarry/aerc/115 Changelog-added: `:bounce` command to reintroduce messages into the transport system. Signed-off-by: Karel Balej <balejk@matfyz.cz> Acked-by: Robin Jarry <robin@jarry.cc>
* mv: fix regression in selection of next messageJohannes Thyssen Tishman2024-01-271-6/+15
| | | | | | | | | | | | | | | Commit 41c25caafd58 ("mv: allow to move messages across accounts") introduced a regression where moving a message causes the last message in the list to be selected instead of the next available one. Record the next message to jump to *before* actually jumping. Fixes: 41c25caafd58 ("mv: allow to move messages across accounts") Fixes: https://todo.sr.ht/~rjarry/aerc/219 Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* flags: add support for draft flagJason Cox2024-01-262-5/+12
| | | | | | | | | | | | | | Support the draft flag wherever flags are used. Automatically set it when postponing a message, and allow recalling a message without the -f flag if it has the draft flag set, regardless of what folder it's in. Notmuch doesn't seem to pick up on the draft flag when indexing even though the flag is set on the maildir file. Explicitly set all tags corresponding to set flags when appending a message in notmuch. Changelog-added: Support the `draft` flag. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* mv: allow to move messages across accountsJohannes Thyssen Tishman2024-01-252-27/+148
| | | | | | | | | | | | Add a new -a flag to :mv. When specified, an account name is required before the folder name. If the destination folder doesn't exist, it will be created whether or not the -p flag is specified. Changelog-added: Move messages across accounts with `:mv -a <account> <folder>`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* cp: allow to copy messages across accountsJohannes Thyssen Tishman2024-01-251-19/+105
| | | | | | | | | | | | Add a new -a flag to :cp. When specified, an account name is required before the folder name. If the destination folder doesn't exist, it will be created whether or not the -p flag is specified. Changelog-added: Copy messages across accounts with `:cp -a <account> <folder>`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* forward: select correct part for signed messagesKoni Marti2024-01-211-2/+20
| | | | | | | | Select the correct body part for signed messages when forwarding. Fixes: https://todo.sr.ht/~rjarry/aerc/214 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: select correct part for signed messagesKoni Marti2024-01-211-29/+18
| | | | | | | | | | Select the correct body part for signed messages when quote-replying. Simplify logic in the reply command for the part selection. Fixes: https://todo.sr.ht/~rjarry/aerc/214 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: refactor registrationRobin Jarry2024-01-2018-31/+95
| | | | | | | | | | | | | | | | | | Register all commands with the same function and store them in the same map. Use bit flags to determine in which contexts each command should be available. Remove duplicate commands now that the same command can be exposed in multiple contexts. Refactor API to allow executing commands from other commands without import cycles. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
* envelope: use message from current tabKoni Marti2024-01-201-2/+7
| | | | | | | | | Use the message from the current tab to populate the :envelope window. Fixes: https://todo.sr.ht/~rjarry/aerc/213 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* reply,forward: use selected message partSebastien Binet2024-01-173-9/+18
| | | | | | | | | | Use the currently selected message part (if any) as the original message for quote-reply and forward. Honor viewer::alternatives if no message part was selected. Signed-off-by: Sebastien Binet <s@sbinet.org> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands/msg: adapt quote-reply to honor viewer::alternativesSebastien Binet2023-12-301-1/+8
| | | | | | | | modify quote-reply to quote the message part corresponding to the first MIME type matching the list in viewer::alternatives. Signed-off-by: Sebastien Binet <s@sbinet.org> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/apply: add apply sub-cmdKoni Marti2023-12-301-0/+16
| | | | | | | | | | Add the :patch apply command to apply a patch set and create a corresponding tag. The tag command argument can be completed based on the subject lines of the selected messages. Add a test for the completion proposal. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* flag,unflag: fix -a option for the answered flagKoni Marti2023-11-241-0/+4
| | | | | | | | Fix the -a option to correctly set or unset the answered flag. Fixes: https://todo.sr.ht/~rjarry/aerc/199 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: allow replying with another accountBence Ferdinandy2023-11-231-3/+18
| | | | | | | | | | | | | When using edit-headers=true using :switch-account alone is not enough to properly switch account since you have to change the From header manually. Add the -A [account] option to reply in order to switch the account before opening the composer, to remove this friction when we already know we want to reply with a different account. Changelog-added: Reply with a different account than the current one with `:reply -A <account>`. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fold: remove aliases from structinwit2023-11-231-1/+1
| | | | | | | | There's no need to specify aliases if an option applies to all the aliases of a command. Remove aliases for :fold's toggle option. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* fold: add an option to fold/unfold all threadsinwit2023-11-231-2/+24
| | | | | | | | | Commands :fold/:unfold act upon a single thread. Add an option to both commands allowing the user to fold/unfold all displayed threads. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* ui: correct some push status messagesinwit2023-11-124-4/+31
| | | | | | | | | | | Upon success, commands :delete, :copy, :archive and :move show "Messages deleted/copied/archived/moved" in the status bar, which is obviously wrong if they are acting upon only one message. Make the success notification for those commands explicitly agree with the actual number of messages. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* completion: refactor filter list apiRobin Jarry2023-11-022-2/+2
| | | | | | | | | | | | Remove CompletionFromList which is a trivial wrapper around FilterList. Remove the prefix, suffix and isFuzzy arguments from FilterList. Replace prefix, suffix by an optional callback to allow post processing of completion results before presenting them to the user. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* hooks: add mail-deleted hookJason Cox2023-11-021-11/+11
| | | | | | | | | | | | The mail-deleted hook runs whenever a message is deleted from a folder. Note that this means moving a message from one folder to another triggers the mail-deleted hook. Changelog-added: `mail-deleted` hook that triggers when a message is removed/moved from a folder. References: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fold: add an option to toggle foldinginwit2023-11-021-4/+6
| | | | | | | | | | Add a toggle option (-t) to :fold/:unfold commands to allow for switching the folding status of a thread. Changelog-Added: Toggle folding with `:fold -t`. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Jason Cox <me@jasoncarloscox.com>
* commands: use completion from go-optRobin Jarry2023-10-2817-65/+28
| | | | | | | | | | | Implement command completion with complete struct field tags from the get-opt library introduced earlier. Changelog-changed: Improved command completion. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* pipe: run commands with sh -cRobin Jarry2023-10-281-11/+14
| | | | | | | | | | | | Change the Cmd argument to a plain string that preserves shell quoting. Use this for sh -c instead of a list of arguments. Changelog-changed: `:pipe` commands are now executed with `sh -c`. Requested-by: Vitaly Ovchinnikov <v@postbox.nz> Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* open: run commands with sh -cRobin Jarry2023-10-281-1/+1
| | | | | | | | | | | Allow running shell commands in openers. Changelog-changed: `:open` commands are now executed with `sh -c`. Requested-by: Vitaly Ovchinnikov <v@postbox.nz> Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* commands: parse arguments with go-optRobin Jarry2023-10-2817-425/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | Use the argument parsing framework introduced earlier to unify the parsing of (almost) all command options. Remove custom parsing code and to avoid extraneous types, add fields with `opt` tags on command structs that have options and arguments. Commands that take no argument do not need anything. Since the command objects now carry data, create a new temporary instance of them before passing them to opt.ArgsToStruct when executing a command. A few of the commands use specific semantics for parsing (:choose), or are delegating argument parsing to another function (:sort, :search, :filter). For these commands, simply add a dummy "-" passthrough argument. Since all commands still have the argument list (after split) nothing needs to be changed in this area. There should be no functional change besides the Usage strings and reported errors which are now generated automatically. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* accounts: allow fnmatch-style wildcards in aliasesJason Cox2023-10-222-38/+35
| | | | | | | | | | | | | | | | | Wildcard aliases make it possible to always reply from the same address to which a message was addressed, which is useful for catch-all email domains. Support fnmatch-style wildcards in only the address portion of an alias. When replying to a message that matches a wildcard alias, substitute the matching email address for the wildcard address, but keep the name specified with the wildcard address. For example, when the alias "Someone Awesome" <*@someone.com> is present, the reply to an email addressed to "Someone" <hi@someone.com> would be from "Someone Awesome" <hi@someone.com>. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* app: export global functionsRobin Jarry2023-10-1018-153/+148
| | | | | | | | | | | | | | | The single Aerc object is passed around in almost all command functions. This hinders readability. Store the single Aerc instance as a global variable. Export public functions from the app package to access methods of that object. Remove all explicit references to *app.Aerc and replace them with calls to these functions. For references to private/unexported fields and functions from within the app package, directly access the global aerc object. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>