aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* lint: homogenize operations and minor fixes (gocritic)Moritz Poldrack2022-08-0452-256/+231
| | | | | | | | | | | | | | | | | | Apply GoDoc comment policy (comments for humans should have a space after the //; machine-readable comments shouldn't) Use strings.ReplaceAll instead of strings.Replace when appropriate Remove if/else chains by replacing them with switches Use short assignment/increment notation Replace single case switches with if statements Combine else and if when appropriate Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: removed unused code (deadcode, structcheck, unused)Moritz Poldrack2022-08-048-33/+5
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: ensure errors are at least logged (errcheck)Moritz Poldrack2022-08-0433-103/+301
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: merge declaration and assignment (S1021)Moritz Poldrack2022-08-041-2/+1
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: simplify code (gosimple)Moritz Poldrack2022-08-046-39/+28
| | | | | | | | | | | | | | Replaces infinite for loops containing a select on a channel with a single case with a range over the channel. Removes redundant assignments to blank identifiers. Remove unnecessary guard clause around delete(). Remove `if condition { return true } return false` with return condition Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: remove ineffectual assignments (ineffassign)Moritz Poldrack2022-08-044-8/+4
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: remove unused structs and functions (unused)Moritz Poldrack2022-08-043-25/+1
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: remove redundant returns (S1023)Moritz Poldrack2022-08-044-5/+0
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: fix function parameters being overwritten before they are used (SA4009)Moritz Poldrack2022-08-041-2/+2
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: fix ineffective assignments (SA4005)Moritz Poldrack2022-08-041-1/+0
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: remove conditions that are always true (SA4003)Moritz Poldrack2022-08-041-1/+1
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: remove empty branches (SA9003)Moritz Poldrack2022-08-041-4/+4
| | | | | | | | Empty branches are effectively dead code and should therefore be removed. Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: formatted codeMoritz Poldrack2022-08-041-1/+3
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* seqmap: refactor seqmap to use slice instead of mapTim Culverhouse2022-08-035-48/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The imap worker's seqmap is represented as a map of sequence number to UID. This presents a problem when expunging group of messages from the mailbox: each individual expunge decrements the sequence numbers by 1 (for every sequence number greater than the expunged). This requires a looping around the map to update the keys. The use of a map also requires that both the sequence number and the UID of a message be known in order to insert it into the map. This is only discovered by fetching individual message body parts (flags, headers, etc), leaving the seqmap to be empty until we have fetched information about each message. In certain instances (if a mailbox has recently been loaded), all information is loaded in memory and no new information is fetched - leaving the seqmap empty and the UI out of sync with the worker. Refactor the seqmap as a slice, so that any expunge automatically decrements the rest of the sequences. Use the results of FetchDirectoryContents or FetchDirectoryThreaded to initialize the seqmap with all discovered UIDs. Sort the UIDs in ascending order: IMAP specification requires that sequence numbers start at 1 increase in order of ascending UID. Add individual messages to the map if they come via a MessageUpdate and have a sequence number larger than our slice. Update seqmap tests with new logic. Reference: https://datatracker.ietf.org/doc/html/rfc3501#section-2.3.1.2 Fixes: https://todo.sr.ht/~rjarry/aerc/69 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* seqmap: compare ints instead of uintsTim Culverhouse2022-08-031-2/+2
| | | | | | | | | When a test fails with a uint comparison, assert displays the hex code instead of an int, making it harder to debug. Use ints in sequmap test asserts instead of uints for better readability when tests fail Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* seqmap: re-order test assertsTim Culverhouse2022-08-031-15/+15
| | | | | | | | Reorder seqmap asserts to properly show display expected and actual when performing go test -v ./... Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* filters: make it explicit that encoding is UTF-8q3cpma2022-08-034-0/+6
| | | | | | | | | | Document filter input charset Add w3m filter example to default config Adapt html and html-unsafe filters Fixes: https://todo.sr.ht/~rjarry/aerc/65 Signed-off-by: q3cpma <q3cpma@posteo.net> Acked-by: Robin Jarry <robin@jarry.cc>
* mailto: add account query parameterKoni Marti2022-08-012-5/+16
| | | | | | | | | | | | | Specify an account parameter in the mailto argument. If not specified, the selected account is used as default. Example: $ aerc 'mailto:user@host?account=Fastmail' Suggested-by: staceee Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: apply new formatting rulesMoritz Poldrack2022-08-0178-285/+288
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: use gofumpt instead of gofmtMoritz Poldrack2022-08-013-10/+30
| | | | | | Link: https://github.com/mvdan/gofumpt Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* autocompletion: fix regressionKoni Marti2022-08-011-2/+2
| | | | | | | | | | | | | | | | | | | | | Commit 27425c15c4b9 ("autocompletion: fix slice out of bounds access") introduced a regression in the autocompletion that messes up the order of last entered chars when autocompletion runs. The ranges for a slice a[low:high] are 0 <= low <= high <= len(a) [0] To reproduce with the ":cf" command: 1) enter ":c" 2) wait for autocompleteion 3) enter "f" 4) the prompt will now be ":fc" [0]: https://go.dev/ref/spec#Slice_expressions Fixes: 27425c15c4b9 ("autocompletion: fix slice out of bounds access") Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* store: fix nexprev when filteringKoni Marti2022-08-011-0/+1
| | | | | | | | | | | | | | | Select the first message with NextPrev when the cursor disappears after applying a filter where the selected message is not part of. Currently, the NextPrev would select the last message in the mailbox (like a G jump). To reproduce: 1) select a message 2) apply a filter where the selected message is not selected 3) move the cursor and it will jump to the last message Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msglist: remove invalidate from commands which remove messagesTim Culverhouse2022-08-013-7/+0
| | | | | | | | | | Archive, delete, and move all remove messages from the message store. The commands themselves invalidated the message list. The message list was also invalidated for every MessagesDeleted message received. Remove the call in the command logic to reduce redraws of the message list Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* archive,move: fix reselect next messageTim Culverhouse2022-08-012-2/+6
| | | | | | | | | | Move and Archive used store.Next to select the next message. When moving or archiving multiple messages with an upward movement, this would result in a to-be-removed message being selected. Use findNextNonDeleted function to select the correct next message for these commands. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: leave visual-mark mode after certain commandsTim Culverhouse2022-08-013-0/+7
| | | | | | | | | | | | | | | | Commit "4753cfd visual-mode: deselect messages after performing command" introduced the behavior of leaving visual mark mode after performing certain commands. Add this behavior to additional commands: - Delete - Archive - Move Remark the selected mail files if an error occurred during the operation. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: add check-mail commandTim Culverhouse2022-08-014-2/+56
| | | | | | | | | Add :check-mail command for ad-hoc checking of mail. Reset timer for automatic checking if it is enabled. Suggested-by: staceee Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* checkmail: error if check-mail-cmd is not setTim Culverhouse2022-08-012-0/+8
| | | | | | | Send error message to UI if check-mail-cmd is required but not set. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* pipe: fix ordering by message id for long patch seriesRobin Jarry2022-08-011-9/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Git send-email Message-Id headers have the following format: DATETIME.PID-NUM-COMMITTER Unfortunately, when there are more than 9 patches, the patch number (NUM) is not zero-padded which makes ascii sorting invalid, e.g.: 1 10 11 12 2 3 4 5 6 7 8 9 Instead of: 1 2 3 4 5 6 7 8 9 10 11 12 We need the patches to be ordered correctly to pipe them to git am. Make sure to pad the patch number with zero characters to allow series of up to 999 patches. Only re-order messages before piping them if all the Message-Id headers look like git-send-email headers. Link: https://github.com/git/git/blob/v2.36.0/git-send-email.perl#L1197 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* changelog: add missing entriesRobin Jarry2022-07-311-0/+2
| | | | Signed-off-by: Robin Jarry <robin@jarry.cc>
* notmuch: fix cursor movement in threaded viewKoni Marti2022-07-312-1/+7
| | | | | | | | | | | | | | | | Set the SkipSort flag when sending directory infos for counting purposes. Without this, the directory infos would trigger a directory fetch which could bring the notmuch threads out of sync with the message list. The notmuch backend sends these directory infos automatically every minute. To reproduce the weird cursor movement in notmuch's threaded view: 1. enter threaded view in notmuch 2. wait 1 min (until the auto directory infos are sent out) 3. move cursor around and notice how it jumps over threads Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* autocompletion: fix slice out of bounds accessMoritz Poldrack2022-07-311-0/+3
| | | | | Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* outgoing-cred-cmd: delay execution until an email needs to be sentStas Rudakou2022-07-313-45/+60
| | | | | | | | | | | | | | | | | | This can be useful in cases when: 1. outgoing-cred-cmd requires a user action or confirmation (e.g. when using pass with a Yubikey or similar smart card that requires a user to enter a pin or touch the device when decrypting the password) 2. A user starts aerc frequently, but not all the sessions end up with sending emails 3. So the user only wants to execute outgoing-cred-cmd when the password is really used, so the user doesn't have to enter pin or touch their Yubikey each time aerc starts Signed-off-by: Stas Rudakou <stas@garage22.net> Acked-by: Robin Jarry <robin@jarry.cc>
* doc: fix blink config exampleJoel Pickett2022-07-301-1/+1
| | | | | Signed-off-by: Joel Pickett <mail@vyryls.com> Acked-by: Robin Jarry <robin@jarry.cc>
* index: workaround for wide character printingPinghao Wu2022-07-301-0/+17
| | | | | | | | | | | | | | This is a workaround for https://todo.sr.ht/~rjarry/aerc/22, by injecting zero-width spaces in front of wide characters to make up width calculation in fmt.Sprintf. With this applied, columns will still be misaligned a little only if they are left with trailing zero-width spaces when cut. It is better than a large offset caused by each wide characters in the column. References: https://todo.sr.ht/~rjarry/aerc/22 Signed-off-by: Pinghao Wu <xdavidwuph@gmail.com> Acked-by: Koni Marti <koni.marti@gmail.com>
* changelog: fix typosRobin Jarry2022-07-261-8/+8
| | | | Signed-off-by: Robin Jarry <robin@jarry.cc>
* Add changelogRobin Jarry2022-07-263-5/+243
| | | | | | | | | | | | Git history is not for everyone. Let's introduce a user-oriented change log. Ideally, this file should be updated incrementally when adding a new feature. I have added contributors guidelines in README.md. Update release.sh to automatically generate the release tag message with the unreleased changes from the changelog. Link: https://keepachangelog.com/en/1.0.0/ Signed-off-by: Robin Jarry <robin@jarry.cc>
* imap: remove unused expunge codeTim Culverhouse2022-07-261-21/+1
| | | | | | | | | | Remove unused code in the handleDeleteMessages routine. During debugging, it was found that the channel for expunge updates was not working and that all expunge details were coming through as ExpungeUpdates. The reporting channel is unneeded. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* sort: clear sort criteria when called without argumentsTim Culverhouse2022-07-262-6/+6
| | | | | | | | | | | | Fix a regression introduced by commit c2f4404fca15 ("threading: enable filtering of server-side threads"). Prior to this commit, a :sort command (no args) would clear out the current sort criteria (or rather, apply the value from the config). Restore this functionality. Fixes: c2f4404fca15 ("threading: enable filtering of server-side threads") Reported-by: akspecs <akspecs@gmail.com> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* sort: show warning when sort is not supportedKoni Marti2022-07-263-0/+13
| | | | | | | | | | Use the capabilities returned by the backend to check whether sort is implemented when the user tries to use the sort command. Print a warning to the log when a sort request is silently dropped by the backend. Suggested-by: |cos| Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threads: match regular view scrolling behaviorKoni Marti2022-07-261-0/+24
| | | | | | | | | | | | Try to keep the position in the message list when scrolling through threaded messages to match the scrolling behavior of the regular view. This only needs to be implemented for the client-side threading since we have to rebuild the threads when new messages arrive. Reported-by: akspecs <akspecs@gmail.com> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Akspecs <akspecs@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threads: fix race warnings for client-side debouncingKoni Marti2022-07-262-5/+19
| | | | | | | | | Client-side thread debouncing happens in a different goroutine. Any function or variable that is called or accessed by this goroutine should be protected from a concurrent access. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threads: debounce client-side thread buildingKoni Marti2022-07-266-8/+36
| | | | | | | | | | | | | | | | Debounce client-side thread building in the message store. Debouncing is useful when multiple messages are loaded, i.e. when scrolling with PgUp/PgDown. Without the debouncing, all client-side threads will be built everytime the message store is updated which creates a noticable lag in the message list ui when client-side threading is activated. The default debouncing delay can be changed by changing 'client-threads-delay' in the UI config section. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* check-mail: fix startup when default folder is emptyTim Culverhouse2022-07-261-3/+15
| | | | | | | | | | | | | check-mail was triggered to run at startup after a Done:FetchHeaders message. This message would only occur if there were messages in the default folder. In the case where there are no messages, check-mail would not run at startup as intended. Run check-mail even if there are no messages found in the default folder at startup. Fixes: https://todo.sr.ht/~rjarry/aerc/60 Reported-by: ~foutrelis Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* delete: improve find next functionKoni Marti2022-07-261-8/+16
| | | | | | | | | | Improve the function to find the next valid message after the delete operation. This ensures that messages at the end or when marked in the visual mode are properly dealt with. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: implement a uid-based architectureKoni Marti2022-07-265-86/+73
| | | | | | | | | | | Change the message store architecture from an index-based to a uid-based one. Key advantage of this design approach is that no reselect mechanism is required anymore since it comes with the design for free. Fixes: https://todo.sr.ht/~rjarry/aerc/43 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fix: crash when copying/moving all messagesEnsar Sarajčić2022-07-241-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This prevents dereferencing nil when updating RUE counts. This seems to happen for messages that were not yet loaded, but were selected for copy operation. This can happen when using `mark -a` command and then initiating copy operation. When such message is encountered during RUE counting, it is stopped and full recount is triggered. **Original backtrace:** Error: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: runtime/debug.Stack() runtime/debug/stack.go:24 +0x65 git.sr.ht/~rjarry/aerc/logging.PanicHandler() git.sr.ht/~rjarry/aerc/logging/panic-logger.go:45 +0x64b panic({0x9e5f80, 0xecc360}) runtime/panic.go:844 +0x258 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).onMessage(0xc0001be870, {0xb7f860?, 0xc00073b4c0?}) git.sr.ht/~rjarry/aerc/widgets/account.go:353 +0xecc git.sr.ht/~rjarry/aerc/widgets.(*AccountView).Tick(0xc0001be870) git.sr.ht/~rjarry/aerc/widgets/account.go:116 +0x6c git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Tick(0xc0003ba000) git.sr.ht/~rjarry/aerc/widgets/aerc.go:144 +0x7a main.main() git.sr.ht/~rjarry/aerc/aerc.go:225 +0xbb8 Signed-off-by: Ensar Sarajčić <dev@ensarsarajcic.com> Acked-by: Robin Jarry <robin@jarry.cc>
* filters: posix compliant rewrite of calendar filterKoni Marti2022-07-241-178/+109
| | | | | | | | | | | | Rewrite of the awk calendar filter to make it posix compliant. Tested with awk --posix (awk -V = GNU Awk 5.1.1). Also added some improvements to readability and formatting. This complements commit 3ef4a3ca051a ("filters: try and make awk scripts posix compliant"). Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* seqmap: sync seqNum to uid after expungeTim Culverhouse2022-07-242-5/+20
| | | | | | | | | | | | | | This patch updates the seqNums after an Expunge operation. When an expunge operation occurs, the seqNum of the deleted message is reported. The Imap spec [0] states that an immediate decrement of all seqnums greater than the deleted occurs, even before the next reporting of an expunge update. [0]: https://datatracker.ietf.org/doc/html/rfc3501#section-7.4.1 Fixes: https://todo.sr.ht/~rjarry/aerc/61 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* delete: select new last message if last message was deletedTim Culverhouse2022-07-241-0/+7
| | | | | | | | | | If the last message is deleted, the new selection should be the last message instead of the first message. Fixes: https://todo.sr.ht/~rjarry/aerc/59 Reported-by: Sebastien Binet <s@sbinet.org> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* delete: move tab replace logic into Done callbackTim Culverhouse2022-07-241-27/+25
| | | | | | | | | | | | Move tab replacement logic for next-message-on-delete into the callback. This also moves the Invalidate() call into the callback, and should make imap deletion UI work more reliably - there is a race condition between the worker and the UI in displaying deleted messages. This should resolve the race condition, and also only remove the MsgView tab if the message is actually deleted. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>