aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-02-20statusline: move files to lib/stateRobin Jarry
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>
2023-02-20ui/table: do not require width at constructionRobin Jarry
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>
2023-02-20ui/table: allow zero width columnsRobin Jarry
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>
2023-02-20format: remove unused codeRobin Jarry
Now that this is not used anywhere, remove it. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2023-02-20triggers: use templates instead of % mini languageRobin Jarry
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>
2023-02-20commands: expand template placeholdersAivars Vaivods
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>
2023-02-20templates: add now functionRobin Jarry
This allows to get the current local time. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-02-20templates: add firstnames and shortmboxes functionsRobin Jarry
These can be handy for tab-title-composer. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
2023-02-20templates: add message counts for specific foldersRobin Jarry
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>
2023-02-20templates: fix mboxes functionRobin Jarry
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>
2023-02-20templates: unify data interfaceRobin Jarry
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>
2023-02-20account: fix segfault when message store is not initializedRobin Jarry
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>
2023-02-16aerc: show effects of mailto: and mbox: immediatelyMoritz Poldrack
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>
2023-02-12log: add debug for send configurationBence Ferdinandy
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>
2023-02-12compose: ensure signature uses standard delimiterMoritz Poldrack
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>
2023-02-12tabs: use template for compose tabsTim Culverhouse
Use a template for compose tabs. Other available values: Account string Subject string To []*mail.Address From []*mail.Address Cc []*mail.Address Bcc []*mail.Address OriginalFrom []*mail.Address When you use To, From, CC, BCC, or OriginalFrom the title will only be updated when an editing field has lost focus. This is so we don't end up calling "PrepareHeader" on every keystroke, which will likely error out anyways since it will be an invalid header. Subject still updates every keystroke. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-02-12templates: add initials functionBence Ferdinandy
When listing all addresses with names, in for example the To field, one might end up with a very long string. Add the initials function, which extracts the names from addresses and then shortens each of them to the initials of the name. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-02-11ci: use alpine/latest instead of edgeRobin Jarry
The edge branch sometimes has pre-release go versions which do not play well with some of our dependencies. Make sure to stay on the latest stable version. Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-02-02config: warn for all deprecated settingsRobin Jarry
index-format may be used in contextual [ui] sections. Display a warning for every converted section so that users don't miss any. Fixes: 535300cfdbfc ("config: add columns based index format") Reported-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2023-02-02config: add option for SMTP HELO/EHLO local domainKarel D. Kopecký
Expose go-smtp functionality for setting the domain name as a config option. This allows aerc to communicate with SMTP servers with strict antispam measures without relying on sendmail. In theory, this should be set to a fully qualified domain name, but some servers simply forbid the use of "localhost", so it is reasonable to let the user set whatever value works for them. For comparison, this is equivalent to the functionality of the "domain" option of msmtp. Signed-off-by: Karel D. Kopecký <kdk@freeshell.de> Acked-by: Robin Jarry <robin@jarry.cc>
2023-02-02colorize: restore previous default themeRobin Jarry
Restore the default theme from the previous colorize awk script. It is more colorful and may be more appealing to new users out of the box. Since colorize is now configurable via stylesets, power users can do whatever they like. Requested-by: Andrea Pappacoda <andrea@pappacoda.it> Signed-off-by: Robin Jarry <robin@jarry.cc> Agreed-by: Bence Ferdinandy <bence@ferdinandy.com>
2023-02-02viewer: use textproto.WriteHeaderRobin Jarry
When [ui].show-headers is true, use textproto.WriteHeader instead of manually writing the header values. This allows displaying the original header buffer with on-the-wire format (and with lines wrapped). Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2023-01-29templates: add trimSignature functionMoritz Poldrack
Some contacts, especially corporate, include a wall of text in their signatures. To not clutter the reply chain, this commit introduces a new function to the templating engine that removes the signature from a message. Link: https://learn.microsoft.com/en-us/microsoft-365/admin/setup/create-signatures-and-disclaimers Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-29config: remove unused field "RenderAccountTabs"Tim Culverhouse
Remove unused "RenderAccountTabs" field from config. This field is not used anywhere in the codebase and does not appear anywhere in the docs nor default configs. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-29dirlist: simplify getRUEString logicTim Culverhouse
Reuse the newly-added GetRUECount method to simplify getRUEString Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-29tabs: use template for account tab nameTim Culverhouse
Use a go template to render the account tab display. Add config option for setting a specific template for the account. Add a method on Tab to allow setting a title, which may be different than the tab Name. The default template is {{.Account}}. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-29log: log account name in worker message logsTim Culverhouse
Add account name to log of all Post/Process Message/Action logs. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-28wrap: be more robust with localeRobin Jarry
On (some?) MacOS systems there is no C.UTF-8 locale available. Instead there is a non-standard "UTF-8" (encoding only) replacement. Running wrap on MacOS results in an error: error: failed to set locale: Bad file descriptor Instead of expecting that C.UTF-8 will always be available, try to use the user set locale (either from the $LC_ALL or $LANG environment variables). If these variables are unset or if they are set to an invalid/non-existent locale, fallback on C.UTF-8. If C.UTF-8 is not available, make one last desperate attempt for this UTF-8 non-standard locale (MacOS only). aerc will always send UTF-8 encoded text to the filter commands, If the locale that we managed to load does not use the UTF-8 character encoding, exit with an explicit error instead of risking undefined behaviour. Reported-by: Ben Cohen <ben@bencohen.net> Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-01-28filters: make colorize URL regex more strictAndrea Pappacoda
The previous URL regex was too lax, allowing all "[:graph:]" characters after the protocol:// part. This caused the script to mark as part of an URL also things like ">", which is commonly used as a URL delimiter in plain text and Markdown; the url() function tried to account for this with some heuristic to remove trailing characters, but it didn't always work (see the screenshots below). As RFC 3986 specifies the list of allowed characters in URLs, we can simply make our regex stricter and only mark characters as part of an URL if they match the allowed set. As the number of allowed characters has been reduced, the aforementioned heuristic has been slightly simplified. I've also removed the backslash escapes from the bracket expressions, as POSIX regular expressions do not require them; the only characters that need special handling are ']' and '-', which need to be placed at the start and at the end of the expression, respectively. Signed-off-by: Andrea Pappacoda <andrea@pappacoda.it> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-28stylesets: add solarized themeJens Grassel
This adds a styleset using the solarized theme to aerc which affects the tui and the colorize wrapper. Link: https://ethanschoonover.com/solarized/ Signed-off-by: Jens Grassel <jens@wegtam.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-26ci: fix obscure build errorRobin Jarry
Fix the following obscure build error: gcc -O2 -g -Wall -Wextra -Werror -Wformat-security -Wstack-protector -fstack-protector-strong -fanalyzer gcc: fatal error: no input files The issue is that CFLAGS contains newline characters '\n' because of the yaml > continuation. I had misinterpreted the spec hoping that the final newline will also be stripped which is not. Put all CFLAGS on a single line. Link: https://yaml.org/spec/1.0/#id2567537 Fixes: 3191ee171c43 ("filters: rewrite wrap in c") Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-01-26compose: allow sending format=flowed messagesRobin Jarry
Allow composing and sending messages with: Content-Type: text/plain; Format=Flowed This requires additional configuration in the text editor to actually produce the required trailing spaces at the end of lines that are part of the same paragraph. For example, with vim: "~/.vim/ftplugin/mail.vim setlocal textwidth=72 setlocal formatoptions=1jnwtcql setlocal comments+=nb:> Link: https://www.rfc-editor.org/rfc/rfc3676.html Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
2023-01-26viewer: allow piping full headers in a filterRobin Jarry
Allow defining a .headers special filter command that will be used only to process email headers (when [viewer].show-headers=true). Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Kt Programs <ktprograms@gmail.com>
2023-01-26viewer: remove local redundant showHeaders variablesRobin Jarry
The config objects are now globally available. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Kt Programs <ktprograms@gmail.com>
2023-01-26config: remove unused ui.show-header settingRobin Jarry
This has setting never been used. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Kt Programs <ktprograms@gmail.com>
2023-01-26filters: rewrite colorize in cRobin Jarry
Since its introduction, we had multiple issues with the colorize awk script with regard to non-GNU awk compatibility. Also, this script is standalone and the color theme must be hard coded into it. Reading from an external configuration file (aerc's styleset) from a non-GNU awk is close to impossible (and even far from trivial with GNU awk). Rewrite the builtin colorize filter in C to allow getting the color theme from aerc's active styleset. The theme is configured using the existing styleset syntax and attributes under a separate [viewer] section (see examples and man page). Export the active styleset file path to AERC_STYLESET env var when invoking the filter command so that colorize can access it and use it. I have tested compilation (with clang-analyzer and gcc -fanalyzer) and basic operation on FreeBSD, Fedora (glibc) and Alpine (muslibc). More tests would probably be required on MacOSX and older Linux distros. I also added test vectors to give some confidence that this works as expected. The execution with these vectors passed valgrind --leak-check=full without errors. NB: the default theme has changed to be more minimal. Sample stylesets have more colorful examples. The awk -v theme=xxx option is no longer supported. usage: colorize [-h] [-s FILE] [-f FILE] options: -h show this help message -s FILE use styleset file (default $AERC_STYLESET) -f FILE read from filename (default stdin) Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-01-26filters: rewrite wrap in cRobin Jarry
This utility introduced in commit c9524d265793 ("filters: add wrap utility written in go") allows to reflow text to view emails that have very long lines without breaking quotes, lists and indentation. For such a simple task, go produces a binary that is 2.0M bytes on disk. After stripping debugging symbols, it can be reduced to 1.2M bytes. All of this for 267 lines of source code. This is a bit ridiculous, provided people may load this binary into memory multiple times per minute. This tool is a small side-project that seems not suitable for golang. Rewrite it in C. It now only depends on a POSIX libc to run. It is safe to assume that there is one available on all *NIX systems in the world of 2023. The resulting binary is now 27K bytes (15K after stripping). To build it, a C compiler and libc headers are required. These should most likely be available since they are dependencies of the go compiler toolchain. I have tested compilation (with clang-analyzer and gcc -fanalyzer) and basic operation on FreeBSD, Fedora (glibc) and Alpine (musl libc). More tests would probably be required on MacOSX and older Linux distros. I also added test vectors to give some confidence that this works as expected. Update CI with aggressive gcc hardening flags and to run these tests with valgrind --leak-check=full. Command line options are unchanged: usage: wrap [-h] [-w INT] [-r] [-l INT] [-f FILE] Wrap text without messing up email quotes. options: -h show this help message -w INT preferred wrap margin (default 80) -r reflow all paragraphs even if no trailing space -l INT minimum percentage of letters in a line to be considered a paragaph -f FILE read from filename (default stdin) Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Maxwell G <gotmax@e.email>
2023-01-26stylesets: add support for dim textRobin Jarry
Allow defining <obj>.dim=true to turn on half-bright text. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-01-26switch-account: also switch account configurationBence Ferdinandy
When switching accounts, headers were updated, but not the account configurations in the composer. Switch the account config also and add a debug log to send with the uri being used. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-26imap,smtp: cache and cycle XOAUTH2 refresh tokenDean
Normally for emails with xoauth2, the help page says to pass the refresh token as the password. When the refresh token expires, aerc can't fetch the access token, and you must get a new refresh token from the external script. This patch implements a cycle of refresh tokens so you only need to use an external script to fetch the refresh token once. Once you have fetched the initial refresh token (with an external script like mutt_xoauth2.py or https://github.com/gaoDean/oauthRefreshToken), that refresh token is inputted as the password to aerc (as normal) to fetch the access token. Before this patch aerc used to only fetch the access token, but now it fetches that and a new refresh token, which it caches in $XDG_CONFIG_HOME/aerc/<account>-xoauth2.token. In the next opening of aerc, aerc will pull the refresh token from the cache, and use it instead of the inputted refresh token from the password. If it is not present in the cache, the refresh token is taken from the password as usual. Signed-off-by: Dean <gao.dean@hotmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-26logging: add trace to every command callBence Ferdinandy
A previous commit introduced a trace loglevel, but aerc doesn't make much use of it. Logging is not very informative either. Add a log.Tracef to every command and log the provided arguments as well. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-26status: print appropriate log message on pushBence Ferdinandy
Increase logging usability, by logging all messages pushed to status at an appropriate loglevel. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
2023-01-24msgstore: fix new-email trigger firing for all unread messagesRobin Jarry
Unfortunate typo. Fixes: 5677f93ff8e0 ("model: change flags array to bitmask") Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ben Cohen <ben@bencohen.net>
2023-01-11templates: correctly return week format when necessaryNojus Gudinavičius
This fixes a bug when thisDayTimeFmt was returned for both this day and this week. Fixes: d758441fe0c4 ("templates: add more fields and functions") Signed-off-by: Nojus Gudinavičius <nojus.gudinavicius@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2023-01-11spinner: add spinner-interval config optionDean
The default 200ms between each spinner frame can be unsuitable for spinners with many frames, so this adds a spinner-interval config option with type `time.Duration` to specify the interval between frames. The default is still the usual 200ms. Signed-off-by: Dean <gao.dean@hotmail.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-01-11config: disable ini reflection for pgp-error-levelRobin Jarry
This field must be converted from a string value to an integer manually. The conversion cannot be automated via go ini reflection mechanism. Fixes: 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Jose Lombera <jose@lombera.dev>
2023-01-11config: fix accounts backend specific parameters detectionRobin Jarry
Since commit c56027b2e69e ("config: cleanup accounts.conf section parsing"), no backend-specific settings are parsed and stored into account.Params. The logic is completely broken. Any key is specific unless one field of the AccountConfig struct has a matching ini:"key" tag. The fields that are tagged ini:"-" are already handled in the parent switch block. Reported-by: Jose Lombera <jose@lombera.dev> Reported-by: Ben Cohen <ben@bencohen.net> Fixes: c56027b2e69e ("config: cleanup accounts.conf section parsing") Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Jose Lombera <jose@lombera.dev>
2023-01-11msglist: log template errorsRobin Jarry
The template exec errors can be rather verbose and may be truncated when the table is rendered. Log them as errors so that they can be inspected by users. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
2023-01-10filters: install them in $PREFIX/libexec/aerc/filtersRobin Jarry
The filesystem hierarchy standard describes /usr/share as "Architecture-independent data". This folder is not intended for executable scripts and especially not for arch specific binary files (such as the wrap filter). Lintian reports an error with aerc 0.14.0: arch-dependent-file-in-usr-share [usr/share/aerc/filters/wrap] Which I had to fix by moving the filter into /usr/libexec. Install all filters into $PREFIX/libexec/aerc/filters and update the default SearchDirs to look them up in here as well. Link: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s11.html Link: https://salsa.debian.org/go-team/packages/aerc/-/commit/a0ca00260ffd Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-01-10config: make styleset error message clearerBence Ferdinandy
When aerc fails to load a styleset it reports being unable to load the default styleset. Change error message to print the name of the styleset instead of default. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>