aboutsummaryrefslogtreecommitdiffstats
path: root/commands
Commit message (Collapse)AuthorAgeFilesLines
...
* commands: treat folded threads as one entityKoni Marti2024-01-071-1/+30
| | | | | | | | | | 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>
* commands/msg: adapt quote-reply to honor viewer::alternativesSebastien Binet2023-12-301-1/+8
| | | | | | | | modify quote-reply to quote the message part corresponding to the first MIME type matching the list in viewer::alternatives. Signed-off-by: Sebastien Binet <s@sbinet.org> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/find: add find sub-cmdKoni Marti2023-12-301-0/+132
| | | | | | | | Implement the :patch find command. Search and filter for a given commit by subject line in the current accout and current folder. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch: implement worktree supportKoni Marti2023-12-301-11/+23
| | | | | | | | | | | | | | | | | | | | | | Implement worktree support for the patch management. Use ":patch apply -w <commit-ish> <tag>" to create a new worktree and apply the selected messages to it. The worktree is linked to repo in the current project. Internally, the worktree is stored as a new project. When this project is deleted with ":patch delete", the underlying linked worktree is removed as well. ":patch list" shows when a project is a worktree and to what project it is linked to. Worktrees enable the users to create a new copy of the repo at a given commit and apply patches without interrupting the current work in the base repo. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/switch: add switch sub-cmdKoni Marti2023-12-301-0/+54
| | | | | | | | Implement the :project switch command. Switch between different projects. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/delete: add delete sub-cmdKoni Marti2023-12-301-0/+54
| | | | | | | | | Implement the :patch delete command. Remove the project data from the permanent store. If no argument is provided, the current project will be deleted. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/term: add term sub-cmdKoni Marti2023-12-302-5/+50
| | | | | | | | | Implement the :patch term command. This will open a shell in the project's root directory that was defined during the :project init setup. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/rebase: add rebase sub-cmdKoni Marti2023-12-302-0/+363
| | | | | | | | | | | | | | | | | Implement the :patch rebase command. Rebase the internal patch data in case the repository was rebased too. The :patch rebase command accepts a optional argument which is used as the reference commit from which the rebasing will occur. Open an editor with the commits that are found on top of the rebase reference. Any untracked commit will have the tag 'untracked'. If a line is removed or the 'untracked' tag remains, it will be dropped from the internal data. To group commits into a patch set, assign the same tag names. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/cd: add cd sub-cmdKoni Marti2023-12-301-0/+42
| | | | | | | | Implement the :patch cd command. Change the directory to the project's root directory that was determined during the :patch init setup process. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/remove: add remove sub-cmdKoni Marti2023-12-301-0/+43
| | | | | | | | | | | Implement the :patch remove command. Remove a patch set from the respository and from the internal storage. Note that in git, this will change all commit hashes that appear after the removed one since the commit hash depends on its parents. Adjust the code to handle such cases and add tests for this. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/list: add list sub-cmdKoni Marti2023-12-301-0/+113
| | | | | | | | | Implement the :patch list command. List the the current project and add a flag to list all saved projects. Use the pager to display the data and extract the pager commands and move them into the config package. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/apply: add apply sub-cmdKoni Marti2023-12-303-0/+317
| | | | | | | | | | Add the :patch apply command to apply a patch set and create a corresponding tag. The tag command argument can be completed based on the subject lines of the selected messages. Add a test for the completion proposal. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch/init: add init sub-cmdKoni Marti2023-12-301-0/+36
| | | | | | | Implement the :patch init command to initialize a new project. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* patch: create sub-command structureKoni Marti2023-12-302-1/+77
| | | | | | | | Create the sub-command structure for the :patch command. Make the :patch command accessible from any context. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* doc: add aerc-patchKoni Marti2023-12-301-0/+1
| | | | | | | | | Document the local patch management. Adjust the help command. Add default key binds. Changelog-added: Patch management with `:patch`. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* cf: allow changing folder of another accountRobin Jarry2023-12-051-23/+66
| | | | | | | | | | | | | | Add a new -a flag to :cf. When specified, an account name is required before the folder name and the focus will be changed to the corresponding account tab before changing folders. If the target folder does not exist, an explicit error will be reported. Changelog-added: Change to a folder of another account with `:cf -a <account> <folder>`. Signed-off-by: Robin Jarry <robin@jarry.cc> Co-authored-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
* eml: expand tilde to home dirRobin Jarry2023-12-041-1/+2
| | | | | | | Allow running :eml ~/foo/baz.eml. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* flag,unflag: fix -a option for the answered flagKoni Marti2023-11-241-0/+4
| | | | | | | | Fix the -a option to correctly set or unset the answered flag. Fixes: https://todo.sr.ht/~rjarry/aerc/199 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: make viewer tab title configurable via templatesBence Ferdinandy2023-11-231-1/+16
| | | | | | | | | | | | | We had account and composer tab title configuration fields already, but not for viewer. Add tab-title-viewer configuration, which defaults to Subject if it is not empty and to "(no subject)" when it is empty. Changelog-added: New `[ui].tab-title-viewer` setting to configure the message viewer tab title. Changelog-changed: Message viewer tab titles will now show `(no subject)` if there is no subject in the viewed email. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* rmdir: back to current folder upon errorKoni Marti2023-11-231-1/+5
| | | | | | | | | | | | | Jump back to the current folder consistently when encountering an error. This has only been partly implemented. For example, when you try to remove a notmuch folder, the remove operation will fail because it is unsupported. However, you would end up in a different directory because a directoy change is done before trying to remove the current folder. If this happens make sure you end up in the current directory again. Fixes: a35d9bab4664 ("rmdir: ensure proper sequence of operations") Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirtree: add custom virtual directory roleKoni Marti2023-11-231-0/+7
| | | | | | | | | Add a new directory role to indicate virtual nodes in the directory tree. This allows to style the virtual nodes differently and apply different behaviors in some commands (i.e. rmdir). Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: copy to composing account's sent folderJason Cox2023-11-231-3/+4
| | | | | | | | | | | | The composing account may be different than the currently selected account if the user has moved between different tabs since beginning the message. Fixes: faa879f9a84d ("hooks: add mail-added hook") Reported-by: Vitaly Ovchinnikov <v@ovch.ru> Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Vitaly Ovchinnikov <v@ovch.ru>
* reply: allow replying with another accountBence Ferdinandy2023-11-231-3/+18
| | | | | | | | | | | | | When using edit-headers=true using :switch-account alone is not enough to properly switch account since you have to change the From header manually. Add the -A [account] option to reply in order to switch the account before opening the composer, to remove this friction when we already know we want to reply with a different account. Changelog-added: Reply with a different account than the current one with `:reply -A <account>`. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fold: remove aliases from structinwit2023-11-231-1/+1
| | | | | | | | There's no need to specify aliases if an option applies to all the aliases of a command. Remove aliases for :fold's toggle option. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* fold: add an option to fold/unfold all threadsinwit2023-11-231-2/+24
| | | | | | | | | Commands :fold/:unfold act upon a single thread. Add an option to both commands allowing the user to fold/unfold all displayed threads. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* cf: fix over quoting of notmuch queriesRobin Jarry2023-11-121-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | Currently, :cf thread:\{id:{{.MessageId}}\} is broken because it is quoted before being interpreted by notmuch. The dynamic folder is created with this "query" (including the quotes): 'thread:{id:23627381....}' Notmuch queries use the xapian syntax and do not follow basic shell quotes interpretation. Change :cf only argument to preserve the command line as entered by the user without any interpretation. When the backend is notmuch, forward that as the dynamic folder name. For other backends, interpret shell quoting on the user entry and fail if it produces more than one argument. Link: https://xapian.org/docs/queryparser.html Fixes: 6613d9b555be ("cf: fix unexpected argument on notmuch") Reported-by: Inwit <inwit@sindominio.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* rmdir: ensure proper sequence of operationsKoni Marti2023-11-122-13/+43
| | | | | | | | | | | | | | | | | | | | Ensure the proper sequence of opening and removing a directory. Fix a potential race between the OpenDirectory (issued by dirlist.Select()) and the RemoveDirectory messages when removing a directory. Due to the delay in the current dirlist.Select() function, the RemoveDirectory message can arrive at the backend before the directory was changed to a different one. This can cause an error on some imap servers and problems with the watcher on the maildir backends. Introduce dirlist.Open() that accepts a callback function so that the operations can be performed in proper sequence. Dirlist.Select() is now a wrapper call to dirlist.Open(). Reported-by: inwit <inwit@sindominio.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* {im,ex}port-mbox: allow using ~ in pathVitaly Ovchinnikov2023-11-122-0/+6
| | | | | | | | Add ~ support to :export-mbox and :import-box the same way as it is done in :save. Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: correct some push status messagesinwit2023-11-124-4/+31
| | | | | | | | | | | Upon success, commands :delete, :copy, :archive and :move show "Messages deleted/copied/archived/moved" in the status bar, which is obviously wrong if they are acting upon only one message. Make the success notification for those commands explicitly agree with the actual number of messages. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* cf: do not quote notmuch queries in completion resultsRobin Jarry2023-11-021-1/+15
| | | | | | | | | | Notmuch queries should not be quoted, they will be interpreted by the notmuch library. Make sure not to return quoted results for directories which have the role == "query". Reported-by: Inwit <inwit@sindominio.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* completion: refactor filter list apiRobin Jarry2023-11-0217-36/+45
| | | | | | | | | | | | 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>
* hooks: add mail-added hookJason Cox2023-11-023-58/+71
| | | | | | | | | | | | | | The mail-added hook runs whenever a message is added to a folder. Note that the hook does not run when a new message is received (the mail-received hook already covers that) but instead runs whenever aerc itself adds a message to a folder, e.g. when moving or copying a message. Changelog-added: `mail-added` hook that triggers when a message is added to a folder. References: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* hooks: add mail-deleted hookJason Cox2023-11-021-11/+11
| | | | | | | | | | | | The mail-deleted hook runs whenever a message is deleted from a folder. Note that this means moving a message from one folder to another triggers the mail-deleted hook. Changelog-added: `mail-deleted` hook that triggers when a message is removed/moved from a folder. References: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fold: add an option to toggle foldinginwit2023-11-021-4/+6
| | | | | | | | | | Add a toggle option (-t) to :fold/:unfold commands to allow for switching the folding status of a thread. Changelog-Added: Toggle folding with `:fold -t`. Signed-Off-By: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Jason Cox <me@jasoncarloscox.com>
* cf: fix unexpected argument on notmuchRobin Jarry2023-10-301-3/+21
| | | | | | | | | | | | | | Notmuch supports creating "dynamic" folders with the :cf command. When the backend is notmuch, :cf must accept multiple arguments since it can be a free-form notmuch query. Detect if the backend is notmuch and build a quoted query based on the provided arguments. Otherwise require a single argument. Fixes: e54486ee40c9 ("commands: parse arguments with go-opt") Reported-by: Inwit <inwit@sindominio.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* complete: add trailing space after quotesRobin Jarry2023-10-301-2/+2
| | | | | | | | | | | | Currently, completing `:tag +forw` gives: '+forwarded ' instead of simply +forwarded without quotes with an embedded trailing space. Add the suffix *after* quoting. Fixes: abe228b14d97 ("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>
* treewide: replace shlex.Split with opt.SplitArgsRobin Jarry2023-10-281-5/+3
| | | | | | | | | | Replace the remaining shlex.Split calls with opt.SplitArgs. Remove dependency to shlex. 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>
* commands: use completion from go-optRobin Jarry2023-10-2880-967/+196
| | | | | | | | | | | 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>
* commands: remove command set completion apiRobin Jarry2023-10-282-50/+14
| | | | | | | | | | | Do not expose the completion of a command via its command set. Instead, require a single command object to be resolved in order to execute it. Extract the command names and the template terms completions in main.go. 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>
* pipe: run commands with sh -cRobin Jarry2023-10-281-11/+14
| | | | | | | | | | | | Change the Cmd argument to a plain string that preserves shell quoting. Use this for sh -c instead of a list of arguments. Changelog-changed: `:pipe` commands are now executed with `sh -c`. Requested-by: Vitaly Ovchinnikov <v@postbox.nz> 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>
* open: run commands with sh -cRobin Jarry2023-10-283-4/+4
| | | | | | | | | | | Allow running shell commands in openers. Changelog-changed: `:open` commands are now executed with `sh -c`. Requested-by: Vitaly Ovchinnikov <v@postbox.nz> 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>
* search: use a common api for all workersRobin Jarry2023-10-281-4/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | Define a SearchCriteria structure. Update the FetchDirectoryContents, FetchDirectoryThreaded and SearchDirectory worker messages to include this SearchCriteria structure instead of a []string slice. Parse the search arguments in a single place into a SearchCriteria structure and use it to search/filter via the message store. Update all workers to use that new API. Clarify the man page indicating that notmuch supports searching with aerc's syntax and also with notmuch specific syntax. getopt is no longer needed, remove it from go.mod. NB: to support more complex search filters in JMAP, we need to use an email.Filter interface. Since GOB does not support encoding/decoding interfaces, store the raw SearchCriteria and []SortCriterion values in the cached FolderContents. Translate them to JMAP API objects when sending an email.Query request to the server. 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>
* commands: parse arguments with go-optRobin Jarry2023-10-2875-1346/+673
| | | | | | | | | | | | | | | | | | | | | | | | | | Use the argument parsing framework introduced earlier to unify the parsing of (almost) all command options. Remove custom parsing code and to avoid extraneous types, add fields with `opt` tags on command structs that have options and arguments. Commands that take no argument do not need anything. Since the command objects now carry data, create a new temporary instance of them before passing them to opt.ArgsToStruct when executing a command. A few of the commands use specific semantics for parsing (:choose), or are delegating argument parsing to another function (:sort, :search, :filter). For these commands, simply add a dummy "-" passthrough argument. Since all commands still have the argument list (after split) nothing needs to be changed in this area. There should be no functional change besides the Usage strings and reported errors which are now generated automatically. 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>
* commands: remove command set execute apiRobin Jarry2023-10-281-9/+5
| | | | | | | | | | Do not expose the execution of a command via its command set. Instead, require a single command object to be resolved in order to execute it. 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>
* commands: expand templates before command resolutionRobin Jarry2023-10-281-20/+9
| | | | | | | | Move the template expansion before the command name is looked up. It saves a few void renderings and will be required for the next commits. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* commands: pass raw command line down to template evaluationRobin Jarry2023-10-284-158/+23
| | | | | | | | | | | | | | | | | | | | | | | | Some commands need to invoke others and/or run shell commands. For this, we need the raw command line as entered by the user. Pass it down the call chain just before it is split to invoke the command Execute method. Remove unit tests for the template expand() test which does have any added value now that it is performed on a single string without any quote juggling. Update all code to handle a single string instead of a list of arguments. Introduce a new dependency on git.sr.ht/~rjarry/go-opt to deal with shell splitting. This is in preparation for using opt.ArgsToStruct to parse arguments for all aerc commands. There should be no functional change after this patch. 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>
* commands: add :suspendNojus Gudinavičius2023-10-241-0/+22
| | | | | | | | | Add :suspend to suspend the aerc process, returning to shell. Include documentation and default Ctrl-z keybinding for it. Changelog-added: New `:suspend` command bound to `<C-z>` by default. Signed-off-by: Nojus Gudinavičius <nojus.gudinavicius@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* export-mbox: preserve the user-visible sorting order when exportingVitaly Ovchinnikov2023-10-221-6/+47
| | | | | | | | Export messages to mbox format in the same order as they are displayed to the user. Both marked-only and "full" export modes are supported. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* accounts: allow fnmatch-style wildcards in aliasesJason Cox2023-10-222-38/+35
| | | | | | | | | | | | | | | | | Wildcard aliases make it possible to always reply from the same address to which a message was addressed, which is useful for catch-all email domains. Support fnmatch-style wildcards in only the address portion of an alias. When replying to a message that matches a wildcard alias, substitute the matching email address for the wildcard address, but keep the name specified with the wildcard address. For example, when the alias "Someone Awesome" <*@someone.com> is present, the reply to an email addressed to "Someone" <hi@someone.com> would be from "Someone Awesome" <hi@someone.com>. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* terminal: add `:send-keys` commandVitaly Ovchinnikov2023-10-221-0/+51
| | | | | | | | | | | | Add a new command for sending keystrokes to the active terminal, if there is one visible. Covers split preview, message viewer, composer and the terminal mode. This can be used to navigate the embedded applications to scroll or safely quit them when needed. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>