40 Commits

Author SHA1 Message Date
Robin Jarry
d7cdaf1977 patch: use subcommand descriptions in completion items
go-opt v2.2.0 now supports providing individual descriptions for
completion items by appending a newline character to the completion item
followed by its description.

Do that for patch sub commands. Here's what it looks like:

       apply    (Apply the selected message(s) to the current project.)
       cd       (Change aerc's working directory to the current project.)
       drop     (Drop a patch from the repository.)
       find     (Search for applied patches.)
       init     (Create a new project.)
       list     (List the current project with the tracked patch sets.)
       ls       (List the current project with the tracked patch sets.)
       rebase   (Rebase the patch data.)
       switch   (Switch context to the specified project.)
       term     (Open a shell or run a command in the current project's directory.)
       unlink   (Delete all patch tracking data for the specified project.)
:patch

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Antonin Godard <antonin@godard.cc>
2025-11-17 09:51:00 +01:00
Robin Jarry
713e8a03f2 commands: quote and add space to completions by default
Instead of duplicating commands.QuoteSpace almost everywhere, make it
the default value for the post processing function of FilterList.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Antonin Godard <antonin@godard.cc>
2025-11-17 09:51:00 +01:00
Simon Martin
36ea569b3b commands: use unicode-normalized, case-insensitive fuzzy search
Some of my folders contain accents, e.g. "Télécom". I'm using fuzzy
matching for autocomplete, and this folder is not proposed if I type,
say, ":mv tele", while I expected it would.

We use fuzzy.RankFindFold, and this patch leverages instead the Unicode
normalized fuzzy.RandFindNormalizedFold, making fuzzy search work better
with accents and friends.

Signed-off-by: Simon Martin <simon@nasilyan.com>
Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-10-30 21:12:24 +01:00
Jakub Růžička
1996098b9d ui: list exact matches first when filtering
If the fuzzy-complete option is used, then list strings containing exact
match first followed by the fuzzy matches.

Changelog-changed: Results of filtering when `fuzzy-complete` is
 enabled list exact matches first.
Signed-off-by: Jakub Růžička <jakub.ruzicka@matfyz.cz>
Tested-by: Karel Balej <balejk@matfyz.cz>
Acked-by: Robin Jarry <robin@jarry.cc>
2025-08-04 12:48:51 +02:00
Robin Jarry
3023b3a4e5 pipe: fix deadlock when piping large messages to less
We have the ability to pipe data to a QuickTerm via its stdin argument.
This function creates a virtual terminal and uses its OnStart callback
to read from stdin and write it to the created command pipe.

The OnStart callback is invoked in app.Terminal.Draw but in that case,
it waits until all data has been read and copied before returning which
prevents the main thread from actually rendering less displaying that
data on screen which blocks everything.

Keep the data copying completely async and out of the main thread to
avoid dead locking.

Reported-by: Simon Martin <simon@nasilyan.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Simon Martin <simon@nasilyan.com>
2025-06-03 08:55:43 +02:00
Andrew Jeffery
434ca29c8f completion: complete paths with FilterList
Make the completion filtering for paths use the standard FilterList
function. This leads to fuzzy filtering if configured, as per other
completions.

Changelog-changed: Path completion now uses the normal filtering
 mechanism, respecting case sensitivity and the fuzzy completion option.
Signed-off-by: Andrew Jeffery <dev@jeffas.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-10-27 10:15:08 +01:00
Robin Jarry
3c9ad93801 completion: display descriptions next to choices
Use go-opt v2 new completion API which returns items descriptions along
with their text values.

Display the descriptions after the items separated by two spaces. Wrap
the descriptions in parentheses to better indicate that they are not
part of the completion choices. Limit the description length to 80
characters to avoid display issues.

Add a new style object completion_description in stylesets. By default,
the object will be rendered with a dimmed terminal attribute. Update all
stylesets and documentation accordingly.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Link: https://git.sr.ht/~rjarry/go-opt/commit/ebeb82538395a
Changelog-added: Command completion now displays descriptions next
 to completion items.
Changelog-added: New `completion_description` style object in style
 sets used for rendering completion item descriptions.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00
Robin Jarry
73dc39c6ee treewide: replace uint32 uids with opaque strings
Add a new models.UID type (an alias to string). Replace all occurrences
of uint32 being used as message UID or thread UID with models.UID.

Update all workers to only expose models.UID values and deal with the
conversion internally. Only IMAP needs to convert these to uint32. All
other backends already use plain strings as message identifiers, in
which case no conversion is even needed.

The directory tree implementation needed to be heavily refactored in
order to accommodate thread UID not being usable as a list index.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2024-08-28 12:06:01 +02:00
Johannes Thyssen Tishman
9849601906 pipe: allow closing the terminal automatically
Add a new -s flag to :pipe. When specified, the terminal tab opened by
the :pipe command will be automatically closed after the process is
completed instead of prompting for a key press. While this doesn't
technically silence the command (the output is not suppressed), the
output is not shown to the user.

Changelog-added: Silently close the terminal tab after piping a
 message to a command with `:pipe -s <cmd>`.
Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-04-13 21:47:44 +02:00
Robin Jarry
8edf7b0e4d log: move package to lib
This has nothing to do at the root of the source tree.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
2024-02-14 23:04:38 +01:00
Tim Culverhouse
63b9706441 aerc: change event interfaces to vaxis events
Modify the function signature of Event and MouseEvent interfaces to
accept vaxis events. Note that because a vaxis event is an empty
interface, the implementations are not affected and the events are
delivered as they were before

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-02-12 13:48:42 +01:00
Robin Jarry
3622f7a99e cd: fix completion of folders with a space
Folders that contain spaces are surrounded by quotes. They can never end
with '/'. Hence they are never returned in the completion results.

Update CompletePath with an additional onlyDirs argument to take care of
this before quotes are inserted.

Fixes: abe228b14d ("commands: use completion from go-opt")
Fixes: https://todo.sr.ht/~rjarry/aerc/204
Reported-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2024-01-17 11:52:59 +01:00
Robin Jarry
765761c5bf commands: simplify CompletePath
This function is overly complex, has code duplication and is not
preserving user input (converting all paths to absolute paths).

Simplify it and avoid converting relative paths to absolute ones.

Add unit tests to ensure it works as expected.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2024-01-17 11:52:57 +01:00
Koni Marti
f41a39578f commands: treat folded threads as one entity
Treat folded threads as one entity and apply any operation on its hidden
children as well.

Fixes: https://todo.sr.ht/~rjarry/aerc/206
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
2024-01-07 12:04:54 +01:00
Robin Jarry
2dfeb7130a completion: refactor filter list api
Remove CompletionFromList which is a trivial wrapper around FilterList.

Remove the prefix, suffix and isFuzzy arguments from FilterList.

Replace prefix, suffix by an optional callback to allow post processing
of completion results before presenting them to the user.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>
2023-11-02 11:59:39 +01:00
Robin Jarry
09744e9272 complete: add trailing space after quotes
Currently, completing `:tag +forw` gives: '+forwarded ' instead of
simply +forwarded without quotes with an embedded trailing space.

Add the suffix *after* quoting.

Fixes: abe228b14d ("commands: use completion from go-opt")
Reported-by: Inwit <inwit@sindominio.net>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Inwit <inwit@sindominio.net>
2023-10-30 15:42:56 +01:00
Robin Jarry
abe228b14d commands: use completion from go-opt
Implement command completion with complete struct field tags from the
get-opt library introduced earlier.

Changelog-changed: Improved command completion.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Tested-by: Inwit <inwit@sindominio.net>
2023-10-28 19:25:10 +02:00
Robin Jarry
bc176bd61b app: export global functions
The single Aerc object is passed around in almost all command functions.
This hinders readability.

Store the single Aerc instance as a global variable. Export public
functions from the app package to access methods of that object. Remove
all explicit references to *app.Aerc and replace them with calls to
these functions. For references to private/unexported fields and
functions from within the app package, directly access the global aerc
object.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-10-10 11:38:01 +02:00
Robin Jarry
598e4a5803 widgets: rename package to app
This is the central point of all aerc. Having it named widgets is
confusing. Rename it to app. It will make a cleaner transition when
making the app.Aerc object available globally in the next commit.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2023-10-10 11:37:56 +02:00
Robin Jarry
a5bc7ccf0c xdg: get rid of deprecated dependencies
github.com/mitchellh/go-homedir has not received any update since 2019.
The last release of github.com/kyoh86/xdg was in 2020 and it has been
marked as deprecated by its author.

Replace these with internal functions.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
2023-08-27 18:44:12 +02:00
Robin Jarry
088d63ce93 tabs: make sure to close tab content
Rework how tabs are closed. Change the aerc.RemoveTab and
aerc.ReplaceTab functions to accept a new boolean argument. If true,
make sure to close the tab content.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2023-04-01 01:01:07 +02:00
Moritz Poldrack
466888da47 attach: don't glob hidden files
Most of the time it is not wanted to attach hidden files, but by default
globbing does include hidden files.

Add a small check that removes hidden files from the results if they are
not explicitly globbed for or inside a hidden directory.

Implements: https://todo.sr.ht/~rjarry/aerc/83
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
2022-12-20 10:51:47 +01:00
Robin Jarry
23a05d17ac logging: rename package to log
Use the same name than the builtin "log" package. That way, we do not
risk logging in the wrong place.

Suggested-by: Tim Culverhouse <tim@timculverhouse.com>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2022-12-02 22:10:49 +01:00
Koni Marti
16dbb94221 util: fetch message headers for nil messages
Fix large archive operations that covers messages in the store with
unfetched headers. Commit e5ad877af5 ("msgstore: fetch missing headers
in visual mode") fixed this for the visual selection mode but omitted
the case when 'mark -a' is used to mark all messages.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 09:30:37 +02:00
Moritz Poldrack
ae83373fa6 logging: added a log on panic
Since panics still regularly "destroy" the terminal, it is hard to get a
stack trace for panics you do not anticipate. This commit adds a panic
handler that automatically creates a logfile inside the current working
directory.

It has to be added to every goroutine that is started and will repair
the terminal on a panic.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-23 20:56:09 +01:00
kt programs
cc172970a0 commands: implement fuzzy completion for commands and options
Change the option to enable fuzzy completion to be fuzzy-complete, since
it's no longer only used for folders

Signed-off-by: Kt Programs <ktprograms@gmail.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
2022-03-07 10:18:50 +01:00
Koni Marti
e5ad877af5 msgstore: fetch missing headers in visual mode
fetches missing headers when in visual selection mode. This prevents
large archive operations from panicking due to a nil pointer
dereference.

The archive command will return an error to the ui when a nil message is
encountered to signal that the message store is not ready yet.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
2022-01-22 17:07:50 +01:00
Robin Jarry
0d645bcebd go.mod: change base git url
I'm not sure what are the implications but it seems required.

Link: https://github.com/golang/go/issues/20883
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:21:45 +01:00
Reto Brunner
8ea86cea41 Get rid of the aerc.PushError(" " + $string) idiom
The individual callers should not be responsible for padding
2021-01-30 14:04:23 +01:00
y0ast
03650474e2 update tcell to v2 and enable TrueColor support
Also update to the tcell v2 PaletteColor api, which should keep the chosen
theme of the user intact.

Note, that if $TRUECOLOR is defined and a truecolor given, aerc will now stop
clipping the value to one of the theme colors.
Generally this is desired behaviour though.
2020-12-18 07:23:22 +01:00
Drew DeVault
caad1b2c06 Revert "Add Style configuration"
This reverts commit 0f78f06610.
2020-05-28 10:32:42 -04:00
Drew DeVault
76a91813d8 Revert "Remove duration from the status methods"
This reverts commit f06d683688.
2020-05-28 10:32:32 -04:00
Reto Brunner
f06d683688 Remove duration from the status methods
We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
2020-05-27 08:11:40 +02:00
Reto Brunner
0f78f06610 Add Style configuration
The following functionalities are added to configure aerc ui styles.
- Read stylesets from file with very basic fnmatch wildcard matching
- Add default styleset
- Support different stylesets as part of UiConfig allowing contextual
  styles.
- Move widgets/ui elements to use the stylesets.
- Add configuration manual for the styleset
2020-05-27 07:57:10 +02:00
Martin Michlmayr
a7986f5706 Fix typos 2020-05-21 18:11:47 +02:00
Reto Brunner
ea2646fc03 Change MarkedMessages to return uids
Especially if one tries to interact with all marked messages there could be
the case that not all headers are fetched yet, hence the messageInfo is still nil.

This segfaults a lot of commands which in principle only need the uid to complete.

If we switch to uids, this issue can be alleviated for those commands.
2020-05-11 09:47:34 -04:00
Reto Brunner
881a9081a8 add command helpers 2019-12-21 09:27:50 -05:00
Jeffas
043a02d99d Sort path completions 2019-09-20 15:07:05 -04:00
Galen Abell
c4b57aaad8 Add CompletePath method
CompletePath takes an existing path and returns possible filesystem
completions based on that path.
2019-08-02 09:22:39 -04:00
Galen Abell
28fc9fa53d Add :save and :pipe commands to viewer
* :save takes a path and saves the current message part to that location
* :pipe is the same as pipe on the account page, but uses the current
  message part rather than the whole email (ie :pipe gzip -d)
* Refactored account:pipe and extracted common pipe code to
  commands.util.QuickTerm
* Added helper command aerc.PushError
2019-05-27 09:37:07 -04:00