aboutsummaryrefslogtreecommitdiffstats
path: root/app/account.go
Commit message (Collapse)AuthorAgeFilesLines
* viewer: avoid crashes on opening invalid messagesRobin Jarry3 days1-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* patch: add auto-switch optionKoni Marti2024-08-241-1/+23
| | | | | | | | | | | | | | | | | | | Add an auto-switch option that changes the project of the patch manager based on the subject line of a message if it contains a '[PATCH <project>]' segment. A subject line with '[PATCH aerc v2]' would switch to the 'aerc' project if that project is available in the patch manager. The auto switching can be activated per account by adding 'pama-auto-switch = true' to your account config. Implements: https://todo.sr.ht/~rjarry/aerc/226 Changelog-added: Auto-switch projects based on the message subject for the :patch command. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: add reloadKoni Marti2024-08-201-0/+7
| | | | | | | | | | | | | | Add the reload command that performs a reload of config files. The reload command supports reloading the binds.conf and aerc.conf config files. Reloading will reload account views (including the directory list), message viewers, and composers. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* store: extract configure logicKoni Marti2024-08-201-12/+8
| | | | | | | | | | Extract a function to configure the message store from its constructor to reconfigure the store when the data changes. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: update split viewsKoni Marti2024-08-201-2/+23
| | | | | | | | | | | Update split views on reload. Use the safe acct.SelectedMessage() instead of acct.msglist.Selected() which can panic if msglist.store is nil. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: extract configure logicKoni Marti2024-08-201-17/+22
| | | | | | | | | | Extract a function to configure the account view from the constructor; rebuild the grid whenever the config data changed on a hot-reload. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: remove ui config struct fieldKoni Marti2024-08-201-17/+14
| | | | | | | | | | Remove the UI config field in the AccountView struct to ensure we use the most current UI config. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* reply: allow copying to current folderRobin Jarry2024-08-031-1/+1
| | | | | | | | | 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>
* acct: indicate connection state in tab titleKoni Marti2024-08-031-0/+1
| | | | | | | | | | | | | | | | Indicate the connection state in the tab title. Example [ui].tab-title-account option in aerc.conf: tab-title-account= {{if .Connected}}{{.Account}}✓{{else}}{{.Account}}✗{{end}} Suggested-by: inwit <inwit@sindominio.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Gregory Anders <greg@gpanders.com> Tested-by: Inwit <inwit@sindominio.net> Reviewed-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>
* threadbuilder: allow threading by subjectRobin Jarry2024-06-251-0/+1
| | | | | | | | | | | | If no match were found in the References and In-Reply-To headers, allow threading by looking at subjects. This behaviour is disabled by default. Add a setting to enable it. Changelog-added: Allow fallback to threading by subject with `[ui].threading-by-subject`. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Matěj Cepl <mcepl@cepl.eu>
* hooks: add AERC_ACCOUNT_BACKEND to hooks with AERC_ACCOUNTBence Ferdinandy2024-06-051-0/+6
| | | | | | | | | | It can be good to know the backend used for an account in a hook. Add this information to all hooks that already pass the account name along. Changelog-added: Added `AERC_ACCOUNT_BACKEND` to hooks with `AERC_ACCOUNT`. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* hooks: add AERC_FOLDER_ROLE to hooks with AERC_FOLDERBence Ferdinandy2024-06-051-0/+9
| | | | | | | | | | It's logical to pass this information as well, when we pass a folder name. Changelog-added: Added `AERC_FOLDER_ROLE` to hooks that have `AERC_FOLDER`. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: add select-last-message optionKoni Marti2024-05-281-0/+1
| | | | | | | | | | | | | | Add a [ui].select-last-message option to position the cursor at the bottom of the message list view. Fixes: https://todo.sr.ht/~rjarry/aerc/254 Changelog-added: Add `[ui].select-last-message` option to position cursor at the bottom of the view. Suggested-by: Bence Ferdinandy <bence@ferdinandy.com> Requested-by: Tomasz Kramkowski <tomasz@kramkow.ski> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tomasz Kramkowski <tomasz@kramkow.ski> Acked-by: Robin Jarry <robin@jarry.cc>
* hooks: add flag-changedBence Ferdinandy2024-04-141-0/+10
| | | | | | | | | Add the flag-changed hook. References: https://todo.sr.ht/~rjarry/aerc/136 Changelog-added: New `flag-changed` hook. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* hooks: add tag-modifiedBence Ferdinandy2024-04-141-0/+10
| | | | | | | | | Add the tag-modified hook for notmuch and JMAP accounts. References: https://todo.sr.ht/~rjarry/aerc/136 Changelog-added: New `tag-modified` hook for notmuch and JMAP accounts. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msglist: allow configuring default splitRobin Jarry2024-02-221-15/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new setting to configure the default split layout for message list tabs. The syntax is a bit different from the :split and :vsplit commands since it needs to convey the direction in the value as well. I didn't reuse split/vsplit since they are a bit confusing when used in a configuration file. The syntax is as follows: message-list-split = [<direction>] <size> The direction is optional and defaults to horizontal. The size is the number of terminal cells that will be used to display the message list. All these examples are equivalent: message-list-split = horiz 12 message-list-split = h 12 message-list-split = 12 Same idea for vertical splits: message-list-split = vertical 120 message-list-split = vert 120 message-list-split = v 120 Both :split and :vsplit commands remain usable as before. The configuration options only affect the initial layout at startup. Add config.SPLIT_* constants and sanitize AccountView.{Split,Vsplit} methods. Changelog-added: Configure default message list `:split` or `:vsplit` on startup with `message-list-split` in `aerc.conf`. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* log: move package to libRobin Jarry2024-02-141-1/+1
| | | | | | | 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>
* aerc: change event interfaces to vaxis eventsTim Culverhouse2024-02-121-3/+2
| | | | | | | | | | Modify the function signature of Event and MouseEvent interfaces to accept vaxis events. Note that because a vaxis event is an empty interface, the implementations are not affected and the events are delivered as they were before Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* cf: allow changing folder of another accountRobin Jarry2023-12-051-0/+8
| | | | | | | | | | | | | | Add a new -a flag to :cf. When specified, an account name is required before the folder name and the focus will be changed to the corresponding account tab before changing folders. If the target folder does not exist, an explicit error will be reported. Changelog-added: Change to a folder of another account with `:cf -a <account> <folder>`. Signed-off-by: Robin Jarry <robin@jarry.cc> Co-authored-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
* hooks: add mail-added hookJason Cox2023-11-021-0/+9
| | | | | | | | | | | | | | The mail-added hook runs whenever a message is added to a folder. Note that the hook does not run when a new message is received (the mail-received hook already covers that) but instead runs whenever aerc itself adds a message to a folder, e.g. when moving or copying a message. Changelog-added: `mail-added` hook that triggers when a message is added to 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>
* hooks: add mail-deleted hookJason Cox2023-11-021-0/+9
| | | | | | | | | | | | 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>
* terminal: add `:send-keys` commandVitaly Ovchinnikov2023-10-221-0/+8
| | | | | | | | | | | | Add a new command for sending keystrokes to the active terminal, if there is one visible. Covers split preview, message viewer, composer and the terminal mode. This can be used to navigate the embedded applications to scroll or safely quit them when needed. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* split: add an alias for horizontal splitinwit2023-10-131-1/+1
| | | | | | | | | | To date, there are two orthogonal commands named :vsplit and :split, which create a vertical and a horizontal split, respectively. Add a :hsplit alias for the latter. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* app: fix nil pointer dereference on startupRobin Jarry2023-10-111-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following crash on startup: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x9e2314] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/log.PanicHandler() git.sr.ht/~rjarry/aerc/log/panic-logger.go:51 +0x70f panic({0xae95a0, 0x119f9b0}) runtime/panic.go:890 +0x263 git.sr.ht/~rjarry/aerc/app.(*Aerc).SelectedAccount(0x8503cdd28?) git.sr.ht/~rjarry/aerc/app/aerc.go:384 +0x14 git.sr.ht/~rjarry/aerc/app.SelectedAccount(...) git.sr.ht/~rjarry/aerc/app/app.go:44 git.sr.ht/~rjarry/aerc/app.(*AccountView).isSelected(...) git.sr.ht/~rjarry/aerc/app/account.go:225 git.sr.ht/~rjarry/aerc/app.(*AccountView).UpdateStatus(0x850364380) git.sr.ht/~rjarry/aerc/app/account.go:127 +0x28 git.sr.ht/~rjarry/aerc/app.(*AccountView).SetStatus(0x850364380, {0x850243a50, 0x1, 0x0?}) git.sr.ht/~rjarry/aerc/app/account.go:123 +0x94 git.sr.ht/~rjarry/aerc/app.NewAccountView(0x8503d38c0, 0x85041bf80) git.sr.ht/~rjarry/aerc/app/account.go:111 +0x573 git.sr.ht/~rjarry/aerc/app.NewAerc({0xcab0c0?, 0x11fa3c8}, 0x850433860, 0xbf3040, {0xca75e8?, 0x11ca800}, 0x0?) git.sr.ht/~rjarry/aerc/app/aerc.go:91 +0x6ce git.sr.ht/~rjarry/aerc/app.Init(...) git.sr.ht/~rjarry/aerc/app/app.go:24 main.main() git.sr.ht/~rjarry/aerc/main.go:242 +0x52e There was two things very wrong: - Access of the global aerc pointer before it was initialized. - The host field of AccountView was left there and still accessed but never initialized. Replace the global aerc pointer with a real struct value. Update code accordingly. Remove the AccountView.host field which is now useless. Reported-by: Jens Grassel <jens@wegtam.com> Reported-by: Matěj Cepl <mcepl@cepl.eu> Fixes: bc176bd61ba7 ("app: export global functions") Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
* app: export global functionsRobin Jarry2023-10-101-14/+10
| | | | | | | | | | | | | | | 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-0/+649
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>