diff options
author | Moritz Poldrack <git@moritz.sh> | 2023-05-26 10:22:47 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-06-01 22:19:19 +0200 |
commit | 5f5514d8742c803e5c0b701e3d6c053624687f70 (patch) | |
tree | 06ae86f50cb4f571c964de1b7b2695ca7192a97e | |
parent | 11ccc471bb91e19334fa266f9837f9bb09a1e34d (diff) | |
download | aerc-5f5514d8742c803e5c0b701e3d6c053624687f70.tar.gz |
compose: quit composing when editor returns error
When the editor crashes, or the user forces it to exit with an error
code, it is safe to assume that they can't (if the command failed) or
don't want to (if :cq'd) continue composing a meaningful message.
Suggested-by: tristan957
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | doc/aerc.1.scd | 3 | ||||
-rw-r--r-- | widgets/compose.go | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eed2aef..c321b001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `:archive` now works on servers using a different delimiter +### Changed + +- Composing an email is now aborted if the text editor exits with an error + (e.g. with `vim`, abort an email with `:cq`). + ## [0.15.2](https://git.sr.ht/~rjarry/aerc/refs/0.15.2) - 2023-05-11 ### Fixed diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd index cf6f7caa..0c89460b 100644 --- a/doc/aerc.1.scd +++ b/doc/aerc.1.scd @@ -522,6 +522,9 @@ message list, the message in the message viewer, etc). *:abort* Close the composer without sending, discarding the message in progress. + If the text editor exits with an error (e.g. *:cq* in *vim*(1)), the + message is immediately discarded. + *:attach* _<path>_++ *:attach* *-m* [_<arg>_] Attaches the file at the given path to the email. The path can contain diff --git a/widgets/compose.go b/widgets/compose.go index ea6a50a4..43657a29 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -1022,6 +1022,12 @@ func (c *Composer) termClosed(err error) { if c.editor == nil { return } + if c.editor.cmd.ProcessState.ExitCode() > 0 { + c.Close() + c.aerc.RemoveTab(c, true) + c.aerc.PushError("Editor exited with error. Compose aborted!") + return + } c.grid.RemoveChild(c.editor) c.review = newReviewMessage(c, err) c.grid.AddChild(c.review).At(3, 0) |