aboutsummaryrefslogtreecommitdiffstats
path: root/app/aerc.go
diff options
context:
space:
mode:
authorJason Cox <me@jasoncarloscox.com>2024-02-22 20:25:16 -0500
committerRobin Jarry <robin@jarry.cc>2024-04-13 21:46:35 +0200
commit4a0bb5d1840f282989bb6b4e3ec16d3da4d5c7f7 (patch)
tree4440ae9566d38fb52ce0f12ac3fccbcf9bd10f32 /app/aerc.go
parent8312b46f144cc1bcf5b6838854df2a9b167c1c3a (diff)
downloadaerc-4a0bb5d1840f282989bb6b4e3ec16d3da4d5c7f7.tar.gz
ipc: retry failed command directly, not over IPC
If IPC fails the first time we try it, we know that no other aerc instance is running. When we retry, run the command directly instead of going through the current instance's own IPC server. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app/aerc.go')
-rw-r--r--app/aerc.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/app/aerc.go b/app/aerc.go
index 7418e979..667696f7 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -698,7 +698,31 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) {
aerc.prompts.Push(p)
}
-func (aerc *Aerc) Mailto(addr *url.URL) error {
+func (aerc *Aerc) Command(args []string) error {
+ switch {
+ case len(args) == 0:
+ return nil // noop success, i.e. ping
+ case strings.HasPrefix(args[0], "mailto:"):
+ mailto, err := url.Parse(args[0])
+ if err != nil {
+ return err
+ }
+ return aerc.mailto(mailto)
+ case strings.HasPrefix(args[0], "mbox:"):
+ return aerc.mbox(args[0])
+ case strings.HasPrefix(args[0], ":"):
+ cmdline := args[0]
+ if len(args) > 1 {
+ cmdline = opt.QuoteArgs(args...).String()
+ }
+ defer ui.Invalidate()
+ return aerc.cmd(cmdline, nil, nil)
+ default:
+ return errors.New("command not understood")
+ }
+}
+
+func (aerc *Aerc) mailto(addr *url.URL) error {
var subject string
var body string
var acctName string
@@ -790,7 +814,7 @@ func (aerc *Aerc) Mailto(addr *url.URL) error {
return nil
}
-func (aerc *Aerc) Mbox(source string) error {
+func (aerc *Aerc) mbox(source string) error {
acctConf := config.AccountConfig{}
if selectedAcct := aerc.SelectedAccount(); selectedAcct != nil {
acctConf = *selectedAcct.acct
@@ -819,11 +843,6 @@ func (aerc *Aerc) Mbox(source string) error {
return nil
}
-func (aerc *Aerc) Command(cmd string) error {
- defer ui.Invalidate()
- return aerc.cmd(cmd, nil, nil)
-}
-
func (aerc *Aerc) CloseBackends() error {
var returnErr error
for _, acct := range aerc.accounts {