aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands/compose/cc-bcc.go7
-rw-r--r--doc/aerc.1.scd2
-rw-r--r--widgets/compose.go17
3 files changed, 21 insertions, 5 deletions
diff --git a/commands/compose/cc-bcc.go b/commands/compose/cc-bcc.go
index 864bb8e..db5f5b6 100644
--- a/commands/compose/cc-bcc.go
+++ b/commands/compose/cc-bcc.go
@@ -1,7 +1,6 @@
package compose
import (
- "fmt"
"strings"
"git.sr.ht/~sircmpwn/aerc/widgets"
@@ -22,10 +21,10 @@ func (_ CC) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (_ CC) Execute(aerc *widgets.Aerc, args []string) error {
- if len(args) < 2 {
- return fmt.Errorf("Usage: %s <addresses>", args[0])
+ var addrs string
+ if len(args) > 1 {
+ addrs = strings.Join(args[1:], " ")
}
- addrs := strings.Join(args[1:], " ")
composer, _ := aerc.SelectedTab().(*widgets.Composer)
switch args[0] {
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 725549e..10e6485 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -216,7 +216,7 @@ message list, the message in the message viewer, etc).
Detaches the file with the given path from the composed email. If no path is
specified, detaches the first attachment instead.
-*cc* <addresses>, *bcc* <addresses>
+*cc* [addresses], *bcc* [addresses]
Sets the Cc or Bcc header to the given addresses. If an editor for the header
is not currently visible in the compose window, a new one will be added.
diff --git a/widgets/compose.go b/widgets/compose.go
index 936da14..c7e38b8 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -509,6 +509,17 @@ func (c *Composer) NextField() {
c.focusable[c.focused].Focus(true)
}
+func (c *Composer) FocusEditor(editor *headerEditor) {
+ c.focusable[c.focused].Focus(false)
+ for i, e := range c.focusable {
+ if e == editor {
+ c.focused = i
+ break
+ }
+ }
+ c.focusable[c.focused].Focus(true)
+}
+
// AddEditor appends a new header editor to the compose window.
func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
if _, ok := c.editors[header]; ok {
@@ -517,6 +528,9 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
value = strings.TrimSpace(header) + ", " + value
}
c.editors[header].input.Set(value)
+ if value == "" {
+ c.FocusEditor(c.editors[header])
+ }
return
}
e := newHeaderEditor(header, value)
@@ -529,6 +543,9 @@ func (c *Composer) AddEditor(header string, value string, appendHeader bool) {
c.focusable[len(c.focusable)-1],
)
c.updateGrid()
+ if value == "" {
+ c.FocusEditor(c.editors[header])
+ }
}
// updateGrid should be called when the underlying header layout is changed.