aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/compose.go54
-rw-r--r--config/binds.conf17
2 files changed, 44 insertions, 27 deletions
diff --git a/app/compose.go b/app/compose.go
index 754dc590..d7a0b1c8 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -1615,7 +1615,14 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
)
bindings = bindings.ForFolder(composer.SelectedDirectory())
- reviewCommands := [][]string{
+ const maxInputWidth = 6
+ type reviewCmd struct {
+ output string
+ annotation string
+ input string
+ }
+
+ reviewCmds := []reviewCmd{
{":send<enter>", "Send", ""},
{":edit<enter>", "Edit", ""},
{":attach<space>", "Add attachment", ""},
@@ -1625,50 +1632,59 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
{":abort<enter>", "Abort (discard message, no confirmation)", ""},
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""},
}
- knownCommands := len(reviewCommands)
+ knownCommands := len(reviewCmds)
var actions []string
for _, binding := range bindings.Bindings {
inputs := config.FormatKeyStrokes(binding.Input)
outputs := config.FormatKeyStrokes(binding.Output)
found := false
- for i, rcmd := range reviewCommands {
- if outputs == rcmd[0] {
+ for i, rcmd := range reviewCmds {
+ if outputs == rcmd.output {
found = true
- if reviewCommands[i][2] == "" {
- reviewCommands[i][2] = inputs
+ if reviewCmds[i].input == "" {
+ reviewCmds[i].input = inputs
} else {
- reviewCommands[i][2] += ", " + inputs
+ reviewCmds[i].input += ", " + inputs
+ }
+ if binding.Annotation != "" {
+ // overwrite default description with
+ // user annotations if present
+ reviewCmds[i].annotation = binding.Annotation
}
break
}
}
if !found {
- rcmd := []string{outputs, "", inputs}
- reviewCommands = append(reviewCommands, rcmd)
+ rcmd := reviewCmd{
+ output: outputs,
+ annotation: binding.Annotation,
+ input: inputs,
+ }
+ reviewCmds = append(reviewCmds, rcmd)
}
}
- unknownCommands := reviewCommands[knownCommands:]
+ unknownCommands := reviewCmds[knownCommands:]
sort.Slice(unknownCommands, func(i, j int) bool {
- return unknownCommands[i][2] < unknownCommands[j][2]
+ return unknownCommands[i].input < unknownCommands[j].input
})
longest := 0
- for _, rcmd := range reviewCommands {
- if len(rcmd[2]) > longest {
- longest = len(rcmd[2])
+ for _, rcmd := range reviewCmds {
+ if len(rcmd.input) > longest {
+ longest = len(rcmd.input)
}
}
width := longest
- if longest < 6 {
- width = 6
+ if longest < maxInputWidth {
+ width = maxInputWidth
}
widthstr := strconv.Itoa(width)
- for _, rcmd := range reviewCommands {
- if rcmd[2] != "" {
+ for _, rcmd := range reviewCmds {
+ if rcmd.input != "" {
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
- rcmd[2], rcmd[1], rcmd[0]))
+ rcmd.input, rcmd.annotation, rcmd.output))
}
}
diff --git a/config/binds.conf b/config/binds.conf
index 4c2efa47..011d86ee 100644
--- a/config/binds.conf
+++ b/config/binds.conf
@@ -158,14 +158,15 @@ $ex = <C-x>
[compose::review]
# Keybindings used when reviewing a message to be sent
-y = :send<Enter>
-n = :abort<Enter>
-v = :preview<Enter>
-p = :postpone<Enter>
-q = :choose -o d discard abort -o p postpone postpone<Enter>
-e = :edit<Enter>
-a = :attach<space>
-d = :detach<space>
+# Inline comments are used as descriptions on the review screen
+y = :send<Enter> # Send
+n = :abort<Enter> # Abort (discard message, no confirmation)
+v = :preview<Enter> # Preview message
+p = :postpone<Enter> # Postpone
+q = :choose -o d discard abort -o p postpone postpone<Enter> # Abort or postpone
+e = :edit<Enter> # Edit
+a = :attach<space> # Add attachment
+d = :detach<space> # Remove attachment
[terminal]
$noinherit = true