aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-03-09fswatcher: fix bsd supportfsRobin Jarry
Fix the following error when running maildir on freebsd: could not create file system watcher: Unsupported OS: freebsd Do not register based on os type. Register based on supported API. Rename linux -> inotify and darwin -> fsevents. Only build fsevents on darwin, and inotify on all other platforms. Fixes: a0935a3de0ce ("worker/lib: implement an fswatcher interface") Reported-by: Jens Grassel <jens@wegtam.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-03-09config: report accounts.conf format errorsRobin Jarry
When accounts.conf cannot be parsed, return an error instead of assuming that the file is non existent and wrongfully opening the new account wizard. Use the same ini delimiters for all configuration files. Fixes: https://todo.sr.ht/~rjarry/aerc/151 Reported-by: Jon Fineman <jon@fineman.me> Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-03-09doc: add missing references to other manpagesTom Schwindl
aerc(1) is most likely the entry point for a user who wants to read the docs. Thus, reference all other manpages to improve accessibility. Signed-off-by: Tom Schwindl <schwindl@posteo.de> Acked-by: Robin Jarry <robin@jarry.cc>
2023-03-08templates: add conditional style methodRobin Jarry
Add .StyleSwitch that takes a string and an arbitrary number of cases (regexp, style). Reuse some of the constructs introduced by previous commit. The style of the first regular expression that matches will be applied. If the string does not match any of the expressions, it will be left as-is. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: add switch/case functionsRobin Jarry
This allows much shorter templates. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: add match functionRobin Jarry
Add a match function that returns true if a string matches the provided regular expression. The compiled regular expressions are cached in a sync.Map to avoid repetitive compilations of the same expressions. Caveat: if the user mixes the arguments order, it may cause the cache to consume a lot of memory filled with garbage regular expression objects. Ideally, we would need to limit the size of this cache and/or use a LRU cache implementation. Maybe someday? Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: reverse args order for .StyleRobin Jarry
In preparation for .StyleMatch put the content first, followed by the style name. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: make SubjectBase official apiRobin Jarry
Document .SubjectBase. Fix its value along the way. Do not reuse d.Subject() which may be empty if d.threadSameSubject is true. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: separate thread prefix from subjectRobin Jarry
Extract {{.ThreadPrefix}} from {{.Subject}} so that the prefix can be styled in a different color. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08msglist: fix inconsistent thread subject deduplicationRobin Jarry
When threading is enabled, some messages which have different base subjects are hidden whereas some others which have similar subjects are displayed: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed ├─>[PATCH aerc v3 2/3] mk: only install changed/missing files │ └─>Re: [PATCH aerc v3 2/3] mk: only install changed/missing files │ └─>Re: [PATCH aerc v3 2/3] mk: only install changed/missing files ├─> └─>Re: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed This happens because we are using the "previous" message to get the subject base instead of the current one. Compute the base subject from the current message. Here is the result: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed ├─>[PATCH aerc v3 2/3] mk: only install changed/missing files │ └─> │ └─> ├─>[PATCH aerc v3 3/3] mk: speed up notmuch detection └─>Re: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed Fixes: 535300cfdbfc ("config: add columns based index format") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: avoid error when using .Style with unknown style nameRobin Jarry
When using {{.Style "foo" bar}} and "foo" is not defined in the styleset under the [user] section, there is an obscure error: template: column-right:1:18: executing "column-right" at <.Style>: error calling Style: runtime error: invalid memory address or nil pointer dereference Which is most of the time truncated and can only be read in logs. Referencing an undefined style is not a serious problem. Return the default tcell style in that case and avoid the error. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08templates: allow layered fg & bg color for inline stylesRobin Jarry
If a user style has no fg and/or no bg color defined, use the color from the underlying style. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-03-08contrib: fix sendemail validate scriptRobin Jarry
The current sendemail-validate script cannot be used for patch series. It works on each patch independently from the others and make it impossible to use when there are inter dependencies. I have submitted an alternate validate script that works on whole series which is still waiting for reviews. In the meantime, propose to use my script which can work. To install it in your environment: curl -Lo ~/.local/bin/git-send-email \ https://paste.sr.ht/blob/cedcf24383022949c8dc5bc1300cf5cbc879b36f echo 'export GIT_EXEC_PATH=$PATH:$(git --exec-path)' >> ~/.profile Link: https://lore.kernel.org/git/20230103231133.64050-1-robin@jarry.cc/ Link: https://paste.sr.ht/~rjarry/7e9a98866ba2c6f34e4169debf4f2c14b574613e Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-03-08mk: use fixed versions for gofumpt and golangci-lintRobin Jarry
@latest is flaky and does not resist GOPROXY hiccups. Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-03-07statusline: avoid races when updating status stackTim Culverhouse
The statusline stack is written and read from separate goroutines without a lock. Make the statusline thread-safe by adding locks for access to the stack. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-03-07notmuch: use fswatcher to trigger directory count updateTim Culverhouse
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>
2023-03-07notmuch/checkmail: simplify check-mail functionTim Culverhouse
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>
2023-03-07fswatcher: add a darwin fswatcher implementationTim Culverhouse
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>
2023-03-07maildir: use FSWatcher interfaceTim Culverhouse
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>
2023-03-07worker/lib: implement an fswatcher interfaceTim Culverhouse
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>
2023-03-07change-tab: document "focus previous tab" functionalityinwit
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>
2023-03-07ipc: stay silent if command succeededMoritz Poldrack
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>
2023-03-07ipc: allow triggering internal commands via IPCMoritz Poldrack
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>
2023-03-07ipc: use an interface instead of a function listMoritz Poldrack
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>
2023-03-07ipc: change protocol to JSONMoritz Poldrack
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>
2023-03-07socket: refactor existing codeMoritz Poldrack
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>
2023-03-07socket: extract functionality into ipc packageMoritz Poldrack
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>
2023-03-06mk: speed up notmuch detectionRobin Jarry
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>
2023-03-06mk: remove smart rebuild when GOFLAGS have changedRobin Jarry
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>
2023-03-04table: fix center paddingRobin Jarry
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>
2023-03-03mk: detect if notmuch headers & libs are availableRobin Jarry
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>
2023-03-02config: use reflection to map ini keys to struct fieldsRobin Jarry
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>
2023-03-02templates: allow inline user stylesTim Culverhouse
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>
2023-03-02colorize: stop parsing theme when other section startsRobin Jarry
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>
2023-03-02ui: parse strings for ansi stylesTim Culverhouse
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>
2023-03-02doc: add missing entries for :sign and :encryptwitcher
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>
2023-03-02pgp: automatically determine signer from senderwitcher
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>
2023-03-02pgp: fix segfault for opportunistic encryptionwitcher
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>
2023-02-28check-patches: report all errorsRobin Jarry
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>
2023-02-26Revert "ci: use alpine/latest instead of edge"Robin Jarry
This reverts commit fff5e2f1bbe4e1d2afecada9b69fca0fc7cec424. Should work now. Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-02-26mod: remove support for go 1.16Robin Jarry
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>
2023-02-26lint: always run golangci-lint@latestRobin Jarry
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>
2023-02-24compose: only add delimiter when a signature is definedRobin Jarry
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>
2023-02-23term: update tcell-termTim Culverhouse
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>
2023-02-22dirlist: fix conversion of dirlist-formatRobin Jarry
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>
2023-02-20mailmap: remove duplicatesRobin Jarry
Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-02-20config: enable colorize filter for .headersRobin Jarry
When running :toggle-headers, pipe the output in colorize by default. Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-02-20dirlist: use templates instead of % mini languageRobin Jarry
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>
2023-02-20templates: add compactDir functionRobin Jarry
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>
2023-02-20statusline: add column based render formatRobin Jarry
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>