aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* notmuch: use fswatcher to trigger directory count updateTim Culverhouse2023-03-073-13/+37
| | | | | | | | | | | Use fswatcher to watch the underlying notmuch db to trigger directory updates. Remove unused argument in the handleUpdateDirCounts function. Call this function when listing directories to initialize counts when starting aerc. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch/checkmail: simplify check-mail functionTim Culverhouse2023-03-071-19/+9
| | | | | | | | | Simplify the check-mail function in the notmuch worker. Add account name to the logs. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fswatcher: add a darwin fswatcher implementationTim Culverhouse2023-03-075-0/+97
| | | | | | | | | | Add a darwin implementation of FSWatcher using the fsevents package. The implementation is behind a darwin build flag. Co-authored-by: Ben Cohen <ben@bencohen.net> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
* maildir: use FSWatcher interfaceTim Culverhouse2023-03-072-13/+8
| | | | | | | | Use the FSWatcher interface to create the watcher. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
* worker/lib: implement an fswatcher interfaceTim Culverhouse2023-03-073-0/+113
| | | | | | | | | | | Implement an FSWatcher interface. The interface is used to abstract away file system watchers, which have implementation specific backends. The initial interface has one implementation: inotify for linux. Subsequent commits will add a macOS watcher. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Acked-by: Robin Jarry <robin@jarry.cc>
* change-tab: document "focus previous tab" functionalityinwit2023-03-071-2/+3
| | | | | | | | | | The current :change-tab command allows to be called with a single "-" as a parameter, in which case it changes focus to the previously focused tab. This is useful to switch back and forth between a pair of tabs, and is undocumented. Document this functionality. Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* ipc: stay silent if command succeededMoritz Poldrack2023-03-072-3/+2
| | | | | | | | It would be nicer if aerc behaved the same way most other tools behave in that no news is good news. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* ipc: allow triggering internal commands via IPCMoritz Poldrack2023-03-077-0/+34
| | | | | | | | | | | | | | | | | | | | | In order to make automation easier, it's useful to be able to send commands to aerc via IPC. This can be done by calling the aerc binary followed by a colon and the command to run. For example: aerc :read && aerc :remark && aerc :archive month Security to ensure no malicious commands are run is deferred to the user. By default the socket is only writable by the user. This is considered sufficient as the potential harm an attacker gaining write-access to a user's session can cause is significantly greater than "can delete some emails". To ensure users with an according threat model, it is possible to disable command IPC. mailto-handling is unaffected even though it works over IPC as it is absolutely non-destructive. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* ipc: use an interface instead of a function listMoritz Poldrack2023-03-073-10/+14
| | | | | | | | | Currently, every function has to be mapped to the according handler with our god-object. To make adding new handlers require less changes, change this mapping into an interface that is satisfied by *widgets.Aerc Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* ipc: change protocol to JSONMoritz Poldrack2023-03-074-36/+108
| | | | | | | | | | | | | | | | | | | | | | In overhauling the IPC, it has become necessary to switch to a more extendable message format, to ensure more complex commands can be sent. Messages have the following basic structure and must not contain linebreaks, as these are used to delimit separate messages from one another. {"arguments": ["mailto:moritz@poldrack.dev"]} The responses have the following structure: {"error": "epic fail"} If the IPC request was successful, "error" will be empty. {"error": ""} Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* socket: refactor existing codeMoritz Poldrack2023-03-073-146/+147
| | | | | | | | | | | | | There are several //TODO comments in the socket package, these should be fixed before expanding it. Put send logic into it's own file and rename receiver code. Fix the rather inelegant error handling when shutting down the server. Make sure to close sockets. Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* socket: extract functionality into ipc packageMoritz Poldrack2023-03-072-5/+5
| | | | | | | | | | | | The current model of files dumped into lib does not follow the general advice not to have "util" classes. Naming the package "lib" does not change that it is a random assortments of functions that have some utility. Extracts socket functionality into it's own package. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* mk: speed up notmuch detectionRobin Jarry2023-03-064-31/+28
| | | | | | | | | | | | | | | Use gcc instead of go to build a basic program and determine if notmuch is available. Building a minimal go program takes more than 300ms on a fast machine. A minimal C counterpart takes less than 100ms. To avoid lag when doing bash completion, avoid running any shell commands directly during make evaluation. Rename check-notmuch.sh to goflags.sh and make that script print the goflags directly. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* mk: remove smart rebuild when GOFLAGS have changedRobin Jarry2023-03-063-18/+4
| | | | | | | | | | | This was a nice idea but it is very annoying since the flags change every time the git commit changes even if there are no changes to the source files nor the GOFLAGS... Building with different GOFLAGS now requires cleaning first. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* table: fix center paddingRobin Jarry2023-03-042-14/+29
| | | | | | | | | | | When a column has ALIGN_CENTER and the number of white space character of padding is not a multiple of two, the last cell(character) is not padded and that can cause coloring glitches. Make sure to pad all the way. Fixes: 49de9b09cacc ("ui: parse strings for ansi styles") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* mk: detect if notmuch headers & libs are availableRobin Jarry2023-03-033-3/+39
| | | | | | | | | | Detect if notmuch is available by trying to compile a minimal go program that uses the notmuch.h header and links to libnotmuch.so. If that succeeds, set the default GOFLAGS value to -tags=notmuch. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* config: use reflection to map ini keys to struct fieldsRobin Jarry2023-03-0210-541/+465
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default ini.Section.MapTo() function only handles basic types. Implement a more complete mapping solution that allows: * parsing templates, regexps, email addresses * defining a custom parsing method via the `parse:"MethodName"` tag * defining default values via the `default:"value"` tag * parsing rune values with the `type:"rune"` tag The field name must be specified in the `ini:"field-name"` tag as it was before. It is no longer optional. The `delim:"<separator>"` tag remains but can only be used to parse string arrays. It is now possible to override default values with "zero" values. For example: [ui] dirlist-delay = 0 Will override the default "200ms" value. Also: [statusline] status-columns = Will override the default "left<*,center>=,right>*" value. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: allow inline user stylesTim Culverhouse2023-03-028-0/+66
| | | | | | | | | | | | | | | | | | | | Allow custom user-defined styles in a styleset. The styles can take any name, and must be under the [user] ini section. All attributes apply to user defined styles. Example: [user] red.fg=red red.bold=true Add a .Style function which accepts the name of a user-defined style and applies it to the string. {{.Style "red" "foo"}} Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* colorize: stop parsing theme when other section startsRobin Jarry2023-03-021-1/+6
| | | | | | | | In order to allow multiple sections in a styleset, colorize must stop parsing the theme when it encounters a new section. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* ui: parse strings for ansi stylesTim Culverhouse2023-03-025-33/+714
| | | | | | | | | Parse UI strings for ANSI styles. If there are styles in the string, use those as the display style in tcell. This is in preparation for a template function which can apply arbitrary styles to UI elements. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* doc: add missing entries for :sign and :encryptwitcher2023-03-021-0/+10
| | | | | | | | Update aerc(1) with explanations about key selection priority. Fixes: https://todo.sr.ht/~rjarry/aerc/144 Signed-off-by: witcher <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
* pgp: automatically determine signer from senderwitcher2023-03-021-12/+31
| | | | | | | | | | | | | | | | | | | | This patch automatically determines the signing account from the sender of the email (i.e. the From email header). To reflect this in the compose view after changing the From field, the restriction in updateCrypto() to only run the update if the signing key is empty has been lifted, so the key always gets updated when calling updateCrypt(). Additionally, a Signer() method has been added to the Composer to avoid specifying the same logic twice; once in updateCrypto() and once in WriteMessage(). If the From header is not populated for any reason the Signer() method falls back to the from field specified in accounts.conf. Signed-off-by: witcher <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
* pgp: fix segfault for opportunistic encryptionwitcher2023-03-021-3/+6
| | | | | | | | | | | | | | | | | Commit 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") introduced a bug where if the pgp-opportunistic-encrypt attribute is set to true and a new message is composed, aerc would crash. This is because no recipients have been specified, so checkEncryption() would fail early and *not* call updateCrypto(), which would then cause a segfault in SetEncrypt() later on. To avoid this, when the function would have returned early, it instead does *not* set c.encrypt to true and still calls updateCrypto(). Fixes: 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") Signed-off-by: witcher <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
* check-patches: report all errorsRobin Jarry2023-02-281-14/+18
| | | | | | | Instead of skipping to the next patch after the first error, report all issues. Change the output to make it more user friendly. Signed-off-by: Robin Jarry <robin@jarry.cc>
* Revert "ci: use alpine/latest instead of edge"Robin Jarry2023-02-261-1/+1
| | | | | | | | This reverts commit fff5e2f1bbe4e1d2afecada9b69fca0fc7cec424. Should work now. Signed-off-by: Robin Jarry <robin@jarry.cc>
* mod: remove support for go 1.16Robin Jarry2023-02-265-53/+31
| | | | | | | | | | | | | | | | | | | | | The dependency to x/tools@v0.6.0 drags x/sys@v0.5.0 which is not compatible with go 1.16 # golang.org/x/sys/unix golang.org/x/sys@v0.5.0/unix/syscall.go:83:16: undefined: unsafe.Slice golang.org/x/sys@v0.5.0/unix/syscall_linux.go:2271:9: undefined: unsafe.Slice golang.org/x/sys@v0.5.0/unix/syscall_unix.go:118:7: undefined: unsafe.Slice golang.org/x/sys@v0.5.0/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice note: module requires Go 1.17 Since go 1.16 is now EOL, update the minimal go version to 1.17. Update go.mod and go.sum with the following command: go mod tidy -compat=1.17 Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* lint: always run golangci-lint@latestRobin Jarry2023-02-267-1085/+31
| | | | | | | | | | | | Do not store the dependency in tools.go as there may be conflicts with some indirect dependencies of aerc. Run gofumpt and golangci-lint from their latest tagged release. This should fix issues with go 1.20. Bonus, it drains a bit of fat from go.sum. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* compose: only add delimiter when a signature is definedRobin Jarry2023-02-241-0/+4
| | | | | | | | | | | Inserting a solitary "-- " delimiter without any signature after it makes no sense. Skip the whole delimiter check if the signature is empty. Trim leading and trailing white space along the way. Fixes: a553b33ebcbd ("compose: ensure signature uses standard delimiter") Reported-by: Ben Cohen <ben@bencohen.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ben Cohen <ben@bencohen.net>
* term: update tcell-termTim Culverhouse2023-02-232-11/+11
| | | | | | | | | | | | | Update tcell-term to v0.6.0: - Fixes several leaking goroutines - Adds an EventBell, enabled aerc to know when a terminal has a BEL event - Fixes a panic on \x1b[0G Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: fix conversion of dirlist-formatRobin Jarry2023-02-222-3/+21
| | | | | | | | | | | | | strings.SplitN is not like python str.split() method... It requires an exact number of items including the trailing non split part. Add unit tests to ensure it works. Fixes: 6cfbc87d8ab0 ("dirlist: use templates instead of % mini language") Reported-by: John Mcenroy <handplanet@outlook.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ben Lee-Cohen <ben@lee-cohen.com> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
* mailmap: remove duplicatesRobin Jarry2023-02-201-3/+7
| | | | Signed-off-by: Robin Jarry <robin@jarry.cc>
* config: enable colorize filter for .headersRobin Jarry2023-02-201-1/+1
| | | | | | When running :toggle-headers, pipe the output in colorize by default. Signed-off-by: Robin Jarry <robin@jarry.cc>
* dirlist: use templates instead of % mini languageRobin Jarry2023-02-209-147/+243
| | | | | | | | | | | Replace dirlist-format with two settings: dirlist-left & dirlist-right. These two settings take aerc-templates(7) and may be left empty. Add automatic translation of dirlist-format to these new settings. Display a warning on startup if dirlist-format has been converted. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: add compactDir functionRobin Jarry2023-02-202-0/+14
| | | | | | | This will be used in the dirtree-format replacement by templates. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* statusline: add column based render formatRobin Jarry2023-02-2018-366/+447
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the spirit of commit 535300cfdbfc ("config: add columns based index format"), reuse the column definitions and table widget. Add automatic translation of render-format to column definitions. Allow empty columns to be compatible with the %m (mute) flag. Rename the State object to AccountState to be more precise. Reuse that object in state.TempateData to expose account state info. Move actual status line rendering in StatusLine.Draw(). Add new template fields for status specific data: {{.ConnectionInfo}} Connection state. {{.ContentInfo}} General status information (e.g. filter, search) {{.StatusInfo}} Combination of {{.ConnectionInfo}} and {{.StatusInfo}} {{.TrayInfo}} General on/off information (e.g. passthrough, threading, sorting) {{.PendingKeys}} Currently pressed key sequence that does not match any key binding and/or is incomplete. Display a warning on startup if render-format has been converted to status-columns. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* statusline: move files to lib/stateRobin Jarry2023-02-2011-36/+35
| | | | | | | | These modules will not handle statusline rendering after next commit. Move them in lib/state to make next commit easier to review. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* ui/table: do not require width at constructionRobin Jarry2023-02-202-12/+10
| | | | | | | | | The width is only required when rendering the table in Draw. Remove the redundant width attribute. Fixes: 012be0192c88 ("ui: add reusable table widget") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* ui/table: allow zero width columnsRobin Jarry2023-02-201-4/+7
| | | | | | | | | | | | | When a column uses WIDTH_FIT and its contents are empty, the column is not rendered at all, neither is its separator. This can cause display artifacts (interruption of background color, etc.). Make sure to differentiate between zero-width columns and columns that overflow screen width. Fixes: 012be0192c88 ("ui: add reusable table widget") Acked-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* format: remove unused codeRobin Jarry2023-02-201-319/+0
| | | | | | | Now that this is not used anywhere, remove it. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* triggers: use templates instead of % mini languageRobin Jarry2023-02-209-144/+178
| | | | | | | | | | | | | | | | | | | | | Since previous commit, all commands now support expanding text/template markup. Reuse that for the new-email trigger command. Update commands.ExecuteCommand to take optional *AccountConfig and *MessageInfo arguments. If these are nil, fallback to using the currently selected account and message (if any). Pass the proper *AccountConfig and *MessageInfo objects when firing the trigger command so that these are used instead of the currently selected ones. If new-email contains % placeholders, try to convert them to template markup reusing the same conversion added in commit 535300cfdbfc ("config: add columns based index format"). Warn the user that they need to update their configuration file. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* commands: expand template placeholdersAivars Vaivods2023-02-204-4/+61
| | | | | | | | | Interpret go template constructs in all aerc command arguments based on the currently selected account, folder and message (if any). Signed-off-by: Aivars Vaivods <aivars@vaivods.lv> Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: add now functionRobin Jarry2023-02-202-0/+9
| | | | | | | This allows to get the current local time. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* templates: add firstnames and shortmboxes functionsRobin Jarry2023-02-202-2/+51
| | | | | | | These can be handy for tab-title-composer. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* templates: add message counts for specific foldersRobin Jarry2023-02-204-15/+27
| | | | | | | | | Change the {{.Recent}}, {{.Unread}} and {{.Exists}} template fields to take an arbitrary number of folder names as arguments. If no folder name is specified, these return the counts for all folders. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: fix mboxes functionRobin Jarry2023-02-201-1/+1
| | | | | | | | | | mboxes currently returns the same value that emails. The SplitN API is misleading, to actually split something, the N value must be greater than 1... Fixes: d758441fe0c4 ("templates: add more fields and functions") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* templates: unify data interfaceRobin Jarry2023-02-2010-232/+223
| | | | | | | | | | | | | | | | | | | | | | | Require that all aerc template data objects implement the same TemplateData interface. Implement that interface in two different places: 1) state.TemplateData (renamed/moved from templates.TemplateData). This structure (along with all its methods) needs to be decoupled from the templates package to break the import cycle with the config package. This allows much simpler construction of this object and ensure that values are calculated only when requested. 2) config.dummyData (extracted from templates). This is only used in the config package to validate user templates. Putting it here allows also to break an import cycle. Use state.TemplateData everywhere (including for account tabs title rendering). Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* account: fix segfault when message store is not initializedRobin Jarry2023-02-201-0/+3
| | | | | | | | | | | | | | | | Fix the following error: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x130 pc=0x8769b4] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/lib.(*MessageStore).Uids(0x40ffa5?) git.sr.ht/~rjarry/aerc/lib/msgstore.go:579 +0x14 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).SelectedMessage(0xc0000f41c0) git.sr.ht/~rjarry/aerc/widgets/account.go:198 +0x33 Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* aerc: show effects of mailto: and mbox: immediatelyMoritz Poldrack2023-02-161-0/+6
| | | | | | | | | | | | When handling a mailto-Link or opening an mbox file, another update is required before the composer is shown. This is caused by the view not being invalidated and no redraw being queued. Invalidate the UI and queue a redraw when an IPC command is received. Fixes: 7a489cb0011a ("Add Unix socket for communicating with aerc") Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* log: add debug for send configurationBence Ferdinandy2023-02-121-0/+8
| | | | | | | | Make it easier to debug send configurations. References: https://todo.sr.ht/~rjarry/aerc/127 Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: ensure signature uses standard delimiterMoritz Poldrack2023-02-123-0/+24
| | | | | | | | | | | | Since it has recently been a topic on IRC, and to guide users new to "raw" email, add a note on how signatures are detected and what they should look like. Prepend signature-file and signature-cmd with the standard delimiter if missing. Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>