summary refs log tree commit diff stats
path: root/widgets/compose.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-05-14 15:25:30 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-14 15:25:30 -0400
commit065da5e37230976d85d163a6f682eddb9345aede (patch)
tree12bbbbdc95ad03d4e1a57b50350d372022a8b50d /widgets/compose.go
parent9b2612eaf2fbe60a47ef9ca187a9fddb33705e92 (diff)
downloadaerc-065da5e37230976d85d163a6f682eddb9345aede.tar.gz
Add $EDITOR, internal config for compose
Diffstat (limited to 'widgets/compose.go')
-rw-r--r--widgets/compose.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 2daa29c..9460397 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -36,7 +36,8 @@ type Composer struct {
 }
 
 // TODO: Let caller configure headers, initial body (for replies), etc
-func NewComposer(conf *config.AccountConfig) *Composer {
+func NewComposer(conf *config.AercConfig,
+	acct *config.AccountConfig) *Composer {
 	grid := ui.NewGrid().Rows([]ui.GridSpec{
 		{ui.SIZE_EXACT, 3},
 		{ui.SIZE_WEIGHT, 1},
@@ -55,7 +56,7 @@ func NewComposer(conf *config.AccountConfig) *Composer {
 	})
 
 	to := newHeaderEditor("To", "")
-	from := newHeaderEditor("From", conf.From)
+	from := newHeaderEditor("From", acct.From)
 	subject := newHeaderEditor("Subject", "")
 	headers.AddChild(to).At(0, 0)
 	headers.AddChild(from).At(0, 1)
@@ -68,15 +69,21 @@ func NewComposer(conf *config.AccountConfig) *Composer {
 		return nil
 	}
 
-	// TODO: built-in config option, $EDITOR, then vi, in that order
-	editor := exec.Command("vim", email.Name())
+	editorName := conf.Compose.Editor
+	if editorName == "" {
+		editorName = os.Getenv("EDITOR")
+	}
+	if editorName == "" {
+		editorName = "vi"
+	}
+	editor := exec.Command(editorName, email.Name())
 	term, _ := NewTerminal(editor)
 
 	grid.AddChild(headers).At(0, 0)
 	grid.AddChild(term).At(1, 0)
 
 	c := &Composer{
-		config: conf,
+		config: acct,
 		editor: term,
 		email:  email,
 		grid:   grid,
14b4ef558ccec2f77a42a192b74b0eba0cf541a'>e14b4ef5 ^
e14b4ef5 ^
52f6ad6f ^


52f6ad6f ^



9b41c4ee ^
8adca66f ^
ae4c2781 ^
3b2446c4 ^
f6da9444 ^


de06c40d ^
de06c40d ^
c20e38a4 ^


76e7a834 ^


ba66d6b7 ^

f47bd58a ^




7a63cf2e ^



6d6bc67d ^
122fe09c ^

122fe09c ^
f6da9444 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56