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>
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>
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>
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>
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>
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>
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>
Commit 27425c15c4 ("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: 27425c15c4 ("autocompletion: fix slice out of bounds access")
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Fix a regression introduced by commit c2f4404fca ("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: c2f4404fca ("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>
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>
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>
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>
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 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>
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>
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>
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>
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 3ef4a3ca05 ("filters: try and make awk scripts
posix compliant").
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
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>
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>
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>
Calling :prev without this check can cause the index to go below 0 if
the current index is smaller than the value being scrolled / incremented
by. This results in the email selector wrapping around from the top to
the bottom most email in the mailbox folder due to changes in ec150f0
'store: fix Select behaviour'.
Signed-off-by: akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Refactor NextPrev to use already existing selection methods and bounds
checking
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Fix the behavior of the Select(index int) method to select the last
message if an index > len(list) or select from bottom of list for
negative indexes.
Thanks: akspecs <akspecs@gmail.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>