aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: add MessageId to aerc-templates.7Tim Culverhouse2023-08-241-0/+6
| | | | | | | | | | {{.MessageId}} is available within templates but undocumented. Previously, users could have surmised a way to get the message ID using {{.Header "message-id"}}, but since this is built into the struct already, document it for ease of use. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* jmap: cache session as jsonTim Culverhouse2023-08-242-5/+5
| | | | | | | | | | | | | | | The gob encoder requires registration of types used during encoding. There are several types defined in the Session object that don't directly or indirectly get registered with gob. As a result, the session object never actually gets cached, requiring an authentication step which is often unnecessary. Use json encoding for this object to provide a simpler serialization path. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* doc: add <esc> to aerc-binds.5Keenan Gugeler2023-08-241-0/+2
| | | | | | | We always accepted this binding, but it was never documented. Signed-off-by: Keenan Gugeler <me@kgugeler.ca> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* contributing: add guidelines for including changelogsRobin Jarry2023-08-242-0/+24
| | | | | | | | | | Recently there were several contributors that included their changelog in the commit message and/or didn't include a changelog at all. Add comprehensive guidelines to help people figuring the email-based review workflow. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* colorize: only emit osc8 if [general].enable-osc8=trueRobin Jarry2023-08-243-5/+21
| | | | | | | | | | | | | | | | Some old versions of less do not handle OSC 8 escape sequences. Even if aerc's embedded terminal is configured to handle them, less corrupts them making the output unreadable. 8;id=colorize-1;https://foobar.com/stuff/https://foobar.com/stuff/ When [general].enable-osc8 is set to false (its default value) do not attempt to generate OSC 8 sequences with the built-in colorize filter. These sequences would be stripped out anyway. Reported-by: Omar Polo <op@omarpolo.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Kirill Chibisov <contact@kchibisov.com>
* terminal: avoid races between close and drawRobin Jarry2023-08-111-27/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix races where a goroutine calls Terminal.Draw and another one calls Terminal.Close or Terminal.Destroy. The closing thread will eventually set term.vterm to nil just before the drawing thread calls term.vterm.Draw(), causing this crash: Error: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: panic({0xb09140, 0x10b5860}) runtime/panic.go:890 +0x263 git.sr.ht/~rockorager/tcell-term.(*VT).Draw(0x0) git.sr.ht/~rockorager/tcell-term@v0.8.0/vt.go:424 +0x50 git.sr.ht/~rjarry/aerc/widgets.(*Terminal).draw(0xc001c658b0) git.sr.ht/~rjarry/aerc/widgets/terminal.go:116 +0x29 git.sr.ht/~rjarry/aerc/widgets.(*Terminal).Draw(0xc001c658b0, 0xc002b08150) git.sr.ht/~rjarry/aerc/widgets/terminal.go:108 +0x1b4 git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc001d0c360, 0xc0008ddb30) git.sr.ht/~rjarry/aerc/lib/ui/grid.go:126 +0x225 git.sr.ht/~rjarry/aerc/widgets.(*Composer).Draw(0xc001c13180, 0xc0008ddb30) git.sr.ht/~rjarry/aerc/widgets/compose.go:747 +0x8f git.sr.ht/~rjarry/aerc/lib/ui.(*TabContent).Draw(0xc0003cc5b0, 0xc0008ddb30) git.sr.ht/~rjarry/aerc/lib/ui/tab.go:468 +0x1f4 git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc0001b2900, 0xc000037050) git.sr.ht/~rjarry/aerc/lib/ui/grid.go:126 +0x225 git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Draw(0xc000000180, 0xc000037050) git.sr.ht/~rjarry/aerc/widgets/aerc.go:193 +0x209 git.sr.ht/~rjarry/aerc/lib/ui.(*UI).Render(0xc000414040) git.sr.ht/~rjarry/aerc/lib/ui/ui.go:105 +0x62 main.main() git.sr.ht/~rjarry/aerc/main.go:279 +0xbac Use an atomic to determine if the terminal is closed or not. Never set vterm to nil (it is not necessary). Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* style: add msglist_gutter and msglist_pill to configKonstantin Shelekhin2023-08-1110-2/+19
| | | | | | | | | | Allow a user to change the default style of the message list scrollbar. There is no easy way to set the default style for an object directly in code, so I've updated every built-in theme to preserve the existing style. Signed-off-by: Konstantin Shelekhin <k.shelekhin@ftml.net> Acked-by: Robin Jarry <robin@jarry.cc>
* doc: strip email addresses in authors sectionRobin Jarry2023-08-1115-45/+45
| | | | | | | | Let's not encourage users to send us personal emails. The referenced URL https://sr.ht/~rjarry/aerc/ should have all necessary information. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* mk: deprecate BSD make in favor of GNU makeRobin Jarry2023-08-115-224/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | Being portable between BSD and GNU make is a nightmare. It restricts features to a very minimal surface and in turn requires a lot of code duplication and manual updating of file lists. Worse, aerc's makefile relies on the shell assignment operator (!=) which has been supported by BSD make 2.2 since 1997 but GNU make 4.0 since 2013. Unfortunately, MacOS runs GNU make 3.8 which does not have that feature. Reducing the feature set even more. Stop that nonsense and remove BSD make compatibility. The majority of aerc's users either run a GNU Linux distribution or MacOS. For those who run any *BSD variant, it is easy for them to install GNU make (gmake) if they don't have it installed already. Use GNU make constructs to generate build and install rules dynamically based on source files discovery. GNU make will use "GNUmakefile" in priority over "Makefile" if possible. Leverage this to display an explicit message when other flavours of make are used. Leave a "Makefile" with a .DEFAULT: target and rename the actual file to "GNUmakefile". Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* notmuch: add option to provide path for accountKirill Chibisov2023-08-053-2/+16
| | | | | | | | | | Add the "maildir-account-path" account configuration option to select the account relative to the "maildir-store" to have traditional maildir one tab per account behavior with notmuch. Signed-off-by: Kirill Chibisov <contact@kchibisov.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* export-mbox: only export marked messages, if anyVitaly Ovchinnikov2023-08-053-4/+28
| | | | | | | | | | Change the `:export-mbox` behavior, so if some messages are marked with `:mark` - only those messages are exported. If nothing is marked - the whole folder is exported, as usual. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* attach: add an option to pipe the attachments inVitaly Ovchinnikov2023-08-054-24/+100
| | | | | | | | | | | | | | | Add the -r option to :attach so that the attachments can be piped in from a command. Example: :attach -r image.jpg read-jpeg-from-clipboard.sh It takes two parameters: the attachment name (to be used in the email and to get the MIME type from) and the command to execute and read the output. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com>
* go.mod: drop mergo packageKoni Marti2023-08-042-3/+0
| | | | | | | | | Drop the mergo package since it is no longer needed to merge the UI configs. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* config: fix contextual ui configKoni Marti2023-08-041-4/+5
| | | | | | | | | | | Re-parse the contextual UI config over the existing UI config in order to avoid the zero-value overwrite issue. This fixes the usage of bool config variables in the contextual sections (such as threading-enabled). Fixes: https://todo.sr.ht/~rjarry/aerc/121 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* account: fix contextual sortKoni Marti2023-08-041-4/+11
| | | | | | | | | | | | Fix contextual sort. Pass a folder-specific sort criteria to the message store when it is created. Before, the message store would receive the sort criteria from the UI config of the currently selected directory (if any was selected at all). Fixes: https://todo.sr.ht/~rjarry/aerc/121 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* contrib: update sendemail-validate hookRobin Jarry2023-08-044-36/+64
| | | | | | | | | With git 2.41, git send-email exports a patch counter to the validate hook. Copy the example hook from git and adapt it for aerc. Link: https://github.com/git/git/commit/3c8d3adeae83 Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* filters: put libexec/filters dirs before default PATHRobin Jarry2023-08-044-3/+16
| | | | | | | | | | | | | | | | | | Some distro packages install binaries in /usr/bin that clash with some of aerc's builtin filters (for example, colorize and wrap). The issue is that aerc filters dir (usually /usr/libexec/aerc/filters) is *after* /usr/bin, making the builtin filters not accessible when these distro packages are installed. Since this mostly concerns colorize and wrap, move $LIBEXEC/aerc/filters at the beginning of the exec PATH when running filter commands. If the intent is **really** to execute /usr/bin/colorize or /usr/bin/html, then their absolute paths should be used. Link: https://archlinux.org/packages/extra/x86_64/talkfilters/ Link: https://tracker.debian.org/pkg/colorize Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
* hooks: add account and folder to mail-received envRobin Jarry2023-08-044-2/+10
| | | | | | | | Add AERC_ACCOUNT and AERC_FOLDER to the environment of the mail-received hook command. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
* msglist: fetch headers even when not focusedRobin Jarry2023-08-042-7/+30
| | | | | | | | | | | | | | Do not rely on MessageList.Draw only to fetch missing headers. In Draw, report the current scroll offset and length to the message store and use them to determine if a new message UID should be candidate for fetching headers. This allows the mail-received hook to work even when the message list is not focused. Fixes: https://todo.sr.ht/~rjarry/aerc/147 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
* wizard: allow ? in passwordsRobin Jarry2023-08-041-0/+1
| | | | | | | | | | | | There is a default ? bind in the global context to show the current key bindings. It is completely useless in the wizard context and prevents users from typing ? if this character is in their password. Disable globals in the wizard bindings (equivalent of $noinherit=true). Reported-by: Brad <super1337@posteo.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* watchers: move filesystem monitoring stuff in libRobin Jarry2023-08-047-49/+50
| | | | | | | No functional change. This will allow reuse in other parts of aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* templates: attach directly from templatesKoni Marti2023-08-037-1/+46
| | | | | | | | | | | | | | | | | | Attach a file from templates. Add a split template function. {{- .Attach "LICENSE" -}} or {{range (exec "find ./doc -type f -name *.scd" "" | split "\n") -}} {{with . }} {{- $.Attach . -}} {{- end}} {{- end}} Fixes: https://todo.sr.ht/~rjarry/aerc/109 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: support the Gmail extension (X-GM-EXT-1)Koni Marti2023-08-039-0/+280
| | | | | | | | | | | | | Support the IMAP Gmail extension (X-GM-EXT-1) to fetch all messages for a given thread. This allows client-side threading to display a full message thread. Obviously, it requires a Gmail account to work. The extension is only used when requested in accounts.conf with: "use-gmail-ext = true" (default: false) Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
* mouse: fix offset in tab title clickable areaBence Ferdinandy2023-08-031-10/+18
| | | | | | | | | | | | | | | | Since templates have been introduced into the tab titles the clickable area has been offset from the actual title. This is because the clickable areas are calculated based on the tab names, which can now be different from the acually shown titles. Extract the logic of getting the display name of a tab from TabStrip and add as method of Tab. Also extract the magic constant 32. Use the method and const in both clicked and Draw. Switch from using len() to runewidth, when calculating the length of the display name. Fixes: https://todo.sr.ht/~rjarry/aerc/162 Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com>
* wizard: display warning when focus is lostKoni Marti2023-08-033-16/+20
| | | | | | | | | | | | | | | Display the warning that the password is stored in plaintext after the focus of the password input field is lost. The current behavior of showing the warning after the first character is entered is ackward and confusing. It also eliminates the need to debounce the warning when a password is pasted. Reported-by: Brad <super1337@posteo.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* composer: reopen the email file when editor is closedRobin Jarry2023-08-021-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some text editors save changes in a temp file before moving it over to the destination instead of rewriting the original file in place. This protects against all sorts of corruption, like writing partial files in disk-full scenarios for example. When this is the case, aerc's open file descriptor points to a different file, one that was never written to by the editor. For text editors that *do* overwrite the file (i.e. the same filesystem inode id), depending on timing, kernel version, operating system, filesystem options, caching, etc. Reading from aerc's file descriptor after the text editor has modified the same file on disk may not return the updated data. This behaviour can be easily observed with the following C program: #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { int fd; ssize_t n; char buf[BUFSIZ]; unlink("test.txt"); fd = open("test.txt", O_CREAT|O_RDWR, 0644); write(fd, "Bonjour\n", strlen("Bonjour\n")); fsync(fd); lseek(fd, 0, SEEK_SET); n = read(fd, buf, sizeof(buf)); buf[n] = '\0'; printf("before: %s\n", buf); system("vim test.txt"); lseek(fd, 0, SEEK_SET); n = read(fd, buf, sizeof(buf)); buf[n] = '\0'; printf("after: %s\n", buf); return 0; } Most of the time, before and after texts will be identical even if you modified the test.txt file contents in the editor. The only reliable way to ensure to read the latest contents from the disk is to close and reopen the file after the text editor has exited. Do exactly that in termClosed before anything else. Fixes: 801caf812377 ("compose: factorize body read in a method") Fixes: https://todo.sr.ht/~rjarry/aerc/184 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ronald Evers <ronald@ch10.nl>
* compose: fix panic when adding empty header with uppercase lettersRobin Jarry2023-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running `:header Hello` causes a panic: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa09328] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/widgets.(*Composer).AddEditor git.sr.ht/~rjarry/aerc/widgets/compose.go:1302 git.sr.ht/~rjarry/aerc/commands/compose.Header.Execute git.sr.ht/~rjarry/aerc/commands/compose/header.go:83 git.sr.ht/~rjarry/aerc/commands.(*Commands).ExecuteCommand git.sr.ht/~rjarry/aerc/commands/commands.go:133 main.execCommand git.sr.ht/~rjarry/aerc/main.go:71 This is because addEditor() converts the header name to lowercase before updating the c.editors map. After this, c.editors[header] (with `header` containing uppercase letters) returns nil causes a nil pointer access. This is a side effect of splitting AddEditor into public and private functions. focusEditor also converts the argument to lowercase. Fix and simplify this. Only call focusEditor with whatever the user provided. Fixes: 11e5390fa0ac ("compose: implement embedded headers in editor") Reported-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* compose: allow removing headersRobin Jarry2023-07-314-20/+47
| | | | | | | | Allow removing headers from the compose window when edit-headers=false (the default) with :header -d <name>. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* split: ensure messagestore is availableMoritz Poldrack2023-07-281-0/+4
| | | | | | | | | | Checking that a messagestore is connected, prevents crashes when aerc has disconnected or :v?split is called without delay inside the aerc-startup hook. Reported-by: Ryan Roden-Corrent <ryan@rcorre.net> Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: replace redundant default bindAnton Mosich2023-07-281-1/+1
| | | | | | | | <C-PgDn> was defined twice in the [compose::editor] context. I changed one of the definitions to a proper <C-PgUp> one. Signed-off-by: Anton Mosich <anton@mosich.at> Acked-by: Robin Jarry <robin@jarry.cc>
* textinput: fix deleteWord with an only whitespaceOskar Sharipov2023-07-282-1/+73
| | | | | | | | | | | Fix a panic in the textinput.deleteWord when text is a whitespace symbol. Add tests for textinput. Fixes: https://todo.sr.ht/~rjarry/aerc/183 Signed-off-by: Oskar Sharipov <oskargit@riseup.net> Acked-by: Robin Jarry <robin@jarry.cc>
* contrib: actually fix irc patchset hook when author is not registeredRobin Jarry2023-07-282-4/+6
| | | | | | | | When the author is not registered in sr.ht, the schema object is different. Fixes: 3a73ffb40ed1 ("contrib: fix irc patchset hook when author is not registered") Signed-off-by: Robin Jarry <robin@jarry.cc>
* compose: only add signature if missingRobin Jarry2023-07-171-1/+21
| | | | | | | | | Allow putting signatures in the templates. Do not add a duplicate signature during :recall and :recover. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: allow changing edit-headers on the flyRobin Jarry2023-07-1712-54/+180
| | | | | | | | | Add -e|-E flags to all compose commands to allow switching between edit-headers = true/false without restarting aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: implement embedded headers in editorKoni Marti2023-07-177-56/+262
| | | | | | | | | Implement embedded header mode in the composer widget. To activate it, use set [compose].edit-headers=true in aerc.conf. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* compose: always use cr-lf line endingsRobin Jarry2023-07-171-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | .eml files are universally formatted with DOS line-endings, per RFC5322. Make sure to replace line endings with CRLF before sending the message. Always present CRLF files to the text editor. If the editor forces LF line endings, convert them back to CRLF. Text editors (vim and nvim at least) detect the .eml extension and force dos line endings. Emacs seems not to care and will use whatever line endings are present in the file. Kakoune seems to force unix line endings and does not care about the contents of the file. Notes: * add explicit calls to Truncate() to ensure any trailing content is stripped from the file when overwriting with shorter content. * NewCRLFReader cannot be reused since we need buffered and unbuffered versions of it (for GetBody and {Set,append}Contents, respectively). Link: https://datatracker.ietf.org/doc/html/rfc5322 Link: https://github.com/vim/vim/blob/v8.2.3583/runtime/ftplugin/mail.vim#L29-L35 Link: https://github.com/neovim/neovim/blob/v0.6.0/runtime/ftplugin/mail.vim#L29-L35 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: improve error handlingRobin Jarry2023-07-172-25/+35
| | | | | | | | | On error, return to the caller instead of logging a warning and trying to continue. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: factorize body read in a methodRobin Jarry2023-07-171-33/+25
| | | | | | | | | | | | | | In preparation for allowing headers in the text editor, put code related to reading the email body in a method and use it where needed. Never close the email temp file, always keep it opened in read-write mode. This will be also required to update embedded header values when running :edit after modifying email headers from the compose::review screen. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: only allow setting content at creationRobin Jarry2023-07-179-74/+45
| | | | | | | | | | | | | Add a parameter for the initial value of the body to be inserted *before* the signature when composing a message. Make AppendContents and SetContents private methods to ensure there is no other way to change the composer contents from the outside after creation. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* send: return error when recipients list is emptyRobin Jarry2023-07-171-0/+3
| | | | | | | | Avoid sending messages with no recipients. Fixes: https://todo.sr.ht/~rjarry/aerc/182 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* imap: fix header cache key collisionsRobin Jarry2023-07-161-13/+17
| | | | | | | | | | | | | | | | | | | | | | Sometimes, aerc lists completely random messages when opening a mailbox. It only happens when cache-headers=true. According to RFC 3501: > The combination of mailbox name, UIDVALIDITY, and UID must refer to > a single immutable message on that server forever. It turns out that several mailboxes may have the same UIDVALIDITY value and may contain messages that have the same UID. When that happens, aerc assumes that the headers for these messages are already cached and returns them whereas they are for messages from another mailbox. Add the mailbox name into the header cache key to avoid these confusing collisions. Fixes: 7aa71d334b27 ("imap: add option to cache headers") Link: https://datatracker.ietf.org/doc/html/rfc3501#section-2.3.1.1 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* styles: add style for folded threadsKoni Marti2023-07-162-0/+8
| | | | | | | | | Add a style for folded threads. Use msglist_thread_folded in the stylesheet like "msglist_thread_folded.dim = true" Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* templates: add ThreadCount and ThreadFoldedKoni Marti2023-07-169-14/+67
| | | | | | | | | | | | | | Add the number of threads and a flag to indicated folded threads to the template data. Use {{.ThreadCount}} and {{.ThreadFolded}} in template expression for the message list. column-subject = {{.ThreadPrefix}}{{if .ThreadFolded}}[{{.ThreadCount}}] {{end}}{{.Subject}} Update default configuration accordingly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* commands: add :fold and :unfold for thread foldingKoni Marti2023-07-162-0/+51
| | | | | | | | | | Add the :fold and :unfold commands to perform thread folding. They only work on the selected message. Add vim-like bindings. Fixes: https://todo.sr.ht/~rjarry/aerc/148 Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* store: implement thread foldingKoni Marti2023-07-162-1/+39
| | | | | | | | Implement thread folding on the message store level. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* msglist: simplified threads renderingKoni Marti2023-07-161-55/+39
| | | | | | | | | | | Simplifies the rendering of threads by removing a thread specific loop and just add the relevent threading information. Since the uids are ordered based on the thread structure already by the threadbuilder, it is not necessary to loop over the threads slice. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* threadbuilder: store uid/thread associationKoni Marti2023-07-163-41/+49
| | | | | | | | | | | | | | Store the association between uids and threads in a map instead of just having the threads in a slice. This simplifies the lookup of a thread when we have an uid and we can avoid computationally expensive tree walks. The threadbuilder will rebuild the uids from the given thread structure. Hence there is no need now to keep a threads slice around. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* commands: fix panic in helper structKoni Marti2023-07-151-1/+5
| | | | | | | | | | | | Fix a panic in the helper struct than can occur when a delayed archiving operation (from :send -a) occurs and the user is already in a different window that does not implement the ProvideMessages interface. Use the *AccountView as a fallback when the type cast fails. Fixes: https://todo.sr.ht/~rjarry/aerc/181 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* wizard: properly initialize configurationRobin Jarry2023-07-154-59/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wizard constructs an AccountConfig object by hand without initializing default values. This causes a crash when replying to an email (rr) just after completing the account creation: ~/.config/aerc/aerc.conf not found, installing the system default~/.config/aerc/binds.conf not found, installing the system defaultpanic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x5d1550] ... regexp.(*Regexp).doExecute(0x7fc1089aa108?, {0x0?, 0x0?}, {0x0?, 0x0?, 0xc000fe5408?}, {0xc000698120?, 0x10?}, 0xad3a40?, 0x2, ...) regexp/exec.go:527 +0x90 regexp.(*Regexp).FindString(0x44e372?, {0xc000698120, 0x27}) regexp/regexp.go:852 +0x6c git.sr.ht/~rjarry/aerc/commands/msg.trimLocalizedRe({0xc000698120, 0x27}, 0xc00003e420?) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:332 +0x36 git.sr.ht/~rjarry/aerc/commands/msg.reply.Execute({}, 0xc0002ba180, {0xc0002f8800?, 0x2, 0x2}) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:157 +0x765 ... Extract the account parsing and initialization into a function. Reuse that function in both accounts.conf parsing and the wizard. Fixes: 40cc540357d9 ("reply: allow to override localized Re regexp in configuration") Reported-by: Mechiel Lukkien <mechiel@ueber.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Andrew Yu <andrew@andrewyu.org>
* jmap: fix crash when opening multiple instancesRobin Jarry2023-07-152-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following error when opening another aerc instance with the same jmap account: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x9a1ffd] git.sr.ht/~rjarry/aerc/worker/jmap/cache.(*JMAPCache).get(0x99d08e?, {0xbc3c1a?, 0xc00003a160?}) git.sr.ht/~rjarry/aerc/worker/jmap/cache/cache.go:47 +0x1d git.sr.ht/~rjarry/aerc/worker/jmap/cache.(*JMAPCache).GetSession(0xc00052a030?) git.sr.ht/~rjarry/aerc/worker/jmap/cache/session.go:8 +0x29 git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).handleConnect(0xc00055e180, 0x0?) git.sr.ht/~rjarry/aerc/worker/jmap/connect.go:29 +0xd3 git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).handleMessage(0xc000311500?, {0xcc8b00?, 0xc0001fcff0?}) git.sr.ht/~rjarry/aerc/worker/jmap/worker.go:114 +0x9f git.sr.ht/~rjarry/aerc/worker/jmap.(*JMAPWorker).Run(0xc00055e180) git.sr.ht/~rjarry/aerc/worker/jmap/worker.go:177 +0x10c git.sr.ht/~rjarry/aerc/widgets.NewAccountView.func3() git.sr.ht/~rjarry/aerc/widgets/account.go:110 +0x65 created by git.sr.ht/~rjarry/aerc/widgets.NewAccountView git.sr.ht/~rjarry/aerc/widgets/account.go:103 +0x518 Do not return an error if the leveldb cannot be opened, log a message and fallback on the in-memory cache. Fixes: be0bfc1ae28b ("worker: add jmap support") Reported-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>