aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/delete.go
Commit message (Collapse)AuthorAgeFilesLines
* viewer: avoid crashes on opening invalid messagesRobin Jarry3 days1-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* treewide: replace uint32 uids with opaque stringsRobin Jarry2024-08-281-2/+2
| | | | | | | | | | | | | | | | | 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>
* notmuch: add strategies for multi-file messagesJason Cox2024-04-021-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-041-1/+1
| | | | | | | | 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: refactor registrationRobin Jarry2024-01-201-1/+6
| | | | | | | | | | | | | | | | | | 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>
* ui: correct some push status messagesinwit2023-11-121-1/+8
| | | | | | | | | | | 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>
* commands: use completion from go-optRobin Jarry2023-10-281-4/+0
| | | | | | | | | | | 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>
* commands: parse arguments with go-optRobin Jarry2023-10-281-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* app: export global functionsRobin Jarry2023-10-101-11/+11
| | | | | | | | | | | | | | | 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>
* widgets: rename package to appRobin Jarry2023-10-101-5/+5
| | | | | | | | | This is the central point of all aerc. Having it named widgets is confusing. Rename it to app. It will make a cleaner transition when making the app.Aerc object available globally in the next commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* tabs: make sure to close tab contentRobin Jarry2023-04-011-3/+3
| | | | | | | | Rework how tabs are closed. Change the aerc.RemoveTab and aerc.ReplaceTab functions to accept a new boolean argument. If true, make sure to close the tab content. Signed-off-by: Robin Jarry <robin@jarry.cc>
* findNextNonDeleted: set next to nil if last messageTim Culverhouse2022-12-141-0/+3
| | | | | | | | | | | The introduction of the iterator means the "next" non-deleted message is never nil, it will always be equal to the previous message (meaning there is only one message left and it is the one we are deleting). In this case, deliberately set next to nil so that the remove tab on delete logic works properly. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* config: make various sections accessible via global varsRobin Jarry2022-12-141-2/+3
| | | | | | | | | | | | | | | | | | | | There is only one instance of AercConfig which is associated to the Aerc widget. Everywhere we need to access configuration options, we need somehow to get a reference either to the Aerc widget or to a pointer to the AercConfig instance. This makes the code cluttered. Remove the AercConfig structure and every place where it is referenced. Instead, declare global variables for every configuration section and access them directly from the `config` module. Since bindings and ui sections can be "contextual" (i.e. per account, per folder or per subject), leave most local references intact. Replacing them with config.{Ui,Binds}.For{Account,Folder,Subject} would make this patch even more unreadable. This is something that may be addressed in the future. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* invalidatable: cleanup dead codeTim Culverhouse2022-10-121-1/+2
| | | | | | | | Remove invalidatable type and all associated calls. All items can directly invalidate the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* view: add peek flag and propagateKoni Marti2022-10-041-1/+1
| | | | | | | | | | | | Add a peek flag -p to the view commands to open the message viewer without setting the "seen" flag. If the flag is set, it would ignore the "auto-mark-read" config. The SetSeen flag will be propagated in case the message viewer moves on to other messages, i.e. with the delete or archive commands. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* viewer: option to not mark message as seenKoni Marti2022-10-041-1/+2
| | | | | | | | | | | | | | | | | Add option to open a message in the message viewer without setting the seen flag. Enables the message viewer to be used as a preview pane without changing the message flags unintentionally. Before, the message viewer would set the seen flag by default. The IMAP backend will now always fetch the message body with the peek option enabled (same as we fetch the headers). An "auto-mark-read" option is added to the ui config which is set to true by default. If set the false, the seen flag is not set by the message viewer. Co-authored-by: "James Cook" <falsifian@falsifian.org> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* delete: fix find-next functionKoni Marti2022-08-221-3/+6
| | | | | | | | | | | Fixes the find-next-loop when deleting the last message. The reverse loop with store.Prev() will break too early because the value of 'previous' was not reset correctly. Fixes: d941960f "delete: improve find next function" References: https://todo.sr.ht/~rjarry/aerc/59 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* store: extract marking behavior and add testsKoni Marti2022-08-221-3/+4
| | | | | | | | Separate the marking functions from the message store and extract the marking behavior into its own class with tests. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* delete: revert deleted messages if Delete is unsupportedTim Culverhouse2022-08-051-0/+3
| | | | | | | | | | Delete operations are not supported by the notmuch backend. Revert deleted messages when the operation is not supported, and reselect the original selection. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: apply new formatting rulesMoritz Poldrack2022-08-011-1/+1
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* msglist: remove invalidate from commands which remove messagesTim Culverhouse2022-08-011-1/+0
| | | | | | | | | | Archive, delete, and move all remove messages from the message store. The commands themselves invalidated the message list. The message list was also invalidated for every MessagesDeleted message received. Remove the call in the command logic to reduce redraws of the message list Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: leave visual-mark mode after certain commandsTim Culverhouse2022-08-011-0/+3
| | | | | | | | | | | | | | | | 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>
* delete: improve find next functionKoni Marti2022-07-261-8/+16
| | | | | | | | | | 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>
* msgstore: implement a uid-based architectureKoni Marti2022-07-261-2/+2
| | | | | | | | | | | 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>
* delete: select new last message if last message was deletedTim Culverhouse2022-07-241-0/+7
| | | | | | | | | | 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>
* delete: move tab replace logic into Done callbackTim Culverhouse2022-07-241-27/+25
| | | | | | | | | | | | 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>
* refactor: refactor pgp implementationTim Culverhouse2022-04-271-1/+1
| | | | | | | | | 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>
* all: fix minor issues found by staticcheckMoritz Poldrack2022-03-121-8/+7
| | | | Signed-off-by: Moritz Poldrack <git@moritz.sh>
* go.mod: change base git urlRobin Jarry2021-11-051-4/+4
| | | | | | | 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>
* Fix linter warningsReto Brunner2021-02-261-1/+0
| | | | | | * Remove redundant return (code was never reached) * Remove redundant type information * Rename unused function parameters to "_"
* Get rid of the aerc.PushError(" " + $string) idiomReto Brunner2021-01-301-1/+1
| | | | The individual callers should not be responsible for padding
* delete: push unsupported error up to the userReto Brunner2020-07-051-0/+3
|
* Rework msglist scrollingJeffas2020-06-091-2/+2
| | | | | | | | | | | | This changes the scrolling to be done on the draw, when the height is updated, ensuring that the selected item is kept on screen during resizing. Also, this ensures that messages will fill the screen when resizing the window, for instance, shrinking and then growing drags down more messages if possible. This is a transplant of the dirlist scrolling logic.
* Revert "Add Style configuration"Drew DeVault2020-05-281-2/+2
| | | | This reverts commit 0f78f06610c0e8887aba2ae50e99b86477a384b3.
* Revert "Remove duration from the status methods"Drew DeVault2020-05-281-3/+4
| | | | This reverts commit f06d683688e3d2139b14f67b7e349089e7200bf4.
* Remove duration from the status methodsReto Brunner2020-05-271-4/+3
| | | | We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
* Add Style configurationReto Brunner2020-05-271-2/+2
| | | | | | | | | | The following functionalities are added to configure aerc ui styles. - Read stylesets from file with very basic fnmatch wildcard matching - Add default styleset - Support different stylesets as part of UiConfig allowing contextual styles. - Move widgets/ui elements to use the stylesets. - Add configuration manual for the styleset
* pgp: fail gracefully from email decryptionRay Ganardi2020-05-251-1/+5
| | | | | Aerc panics when there's an error on email decryption. Instead, an error message should be shown.
* commands/helper: remove duplicated methodReto Brunner2020-05-111-1/+1
|
* gofmt fixesDrew DeVault2020-04-241-1/+1
|
* Use aerc.PushError where appropriateBen Fiedler2020-04-231-4/+1
| | | | Forgot an unused import, to save you the hassle here is v2.
* Initial support for PGP decryption & signaturesDrew DeVault2020-03-031-2/+5
|
* msg/delete: remove redundant err checkReto Brunner2020-02-291-3/+0
|
* delete: adapt to ProvidesMessagesReto Brunner2019-12-211-21/+59
|
* Config for deleting message from message viewerSrivathsan Murali2019-09-201-1/+1
| | | | | As suggested in #268, this adds a behaviour setting for deleting message from message viewer.
* all: purge redundant underscoresWagner Riffel2019-09-041-3/+3
| | | | Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
* select next message when deleting from message viewerAditya Srivastava2019-08-021-3/+10
|
* commands: Don't crash when store is nilKevin Kuehler2019-07-151-0/+3
| | | | | | | On a slow network connection, running these commands without this guard will cause aerc to panic. Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
* Fix crashes when operating on empty folder (#216)Daniel Bridges2019-07-101-3/+3
|
* Crash on delete in empty folder (#213)Zach Sisco2019-07-041-0/+3
|