about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--commands/account/compose.go4
-rw-r--r--config/accounts.conf2
-rw-r--r--config/config.go3
-rw-r--r--widgets/account.go4
-rw-r--r--widgets/compose.go32
5 files changed, 31 insertions, 14 deletions
diff --git a/commands/account/compose.go b/commands/account/compose.go
index 15fc354..c9be17a 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -17,8 +17,8 @@ func Compose(aerc *widgets.Aerc, args []string) error {
 	if len(args) != 1 {
 		return errors.New("Usage: compose")
 	}
-	// TODO: Pass along the sender info
-	composer := widgets.NewComposer()
+	acct := aerc.SelectedAccount()
+	composer := widgets.NewComposer(acct.AccountConfig())
 	// TODO: Change tab name when message subject changes
 	aerc.NewTab(composer, runewidth.Truncate(
 		"New email", 32, "…"))
diff --git a/config/accounts.conf b/config/accounts.conf
index 03846db..96c5e2b 100644
--- a/config/accounts.conf
+++ b/config/accounts.conf
@@ -8,10 +8,12 @@
 # [Personal]
 # source=imaps://username[:password]@hostname[:port]
 # outgoing=smtps+plain://username[:password]@hostname[:port]
+# from=Joe Bloe <joe@example.org>
 #
 # [Work]
 # source=imaps://username[:password]@hostname[:port]
 # outgoing=/usr/bin/sendmail
+# from=Jane Plain <jane@example.org>
 # folders=INBOX,Sent,Archives
 # default=Archives
 #
diff --git a/config/config.go b/config/config.go
index 88986e3..79d1810 100644
--- a/config/config.go
+++ b/config/config.go
@@ -30,6 +30,7 @@ const (
 
 type AccountConfig struct {
 	Default  string
+	From     string
 	Name     string
 	Source   string
 	Folders  []string
@@ -108,6 +109,8 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
 				account.Folders = strings.Split(val, ",")
 			} else if key == "outgoing" {
 				account.Outgoing = val
+			} else if key == "from" {
+				account.From = val
 			} else if key != "name" {
 				account.Params[key] = val
 			}
diff --git a/widgets/account.go b/widgets/account.go
index a8cd9ad..c01b15f 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -80,6 +80,10 @@ func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
 	return view
 }
 
+func (acct *AccountView) AccountConfig() *config.AccountConfig {
+	return acct.acct
+}
+
 func (acct *AccountView) Name() string {
 	return acct.acct.Name
 }
diff --git a/widgets/compose.go b/widgets/compose.go
index f07e3ee..3d74301 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -1,11 +1,14 @@
 package widgets
 
 import (
+	"io/ioutil"
+	"os"
 	"os/exec"
 
 	"github.com/gdamore/tcell"
 	"github.com/mattn/go-runewidth"
 
+	"git.sr.ht/~sircmpwn/aerc2/config"
 	"git.sr.ht/~sircmpwn/aerc2/lib/ui"
 )
 
@@ -21,7 +24,10 @@ type Composer struct {
 		to      *headerEditor
 	}
 
+	config *config.AccountConfig
+
 	editor *Terminal
+	email  *os.File
 	grid   *ui.Grid
 
 	focusable []ui.DrawableInteractive
@@ -29,7 +35,7 @@ type Composer struct {
 }
 
 // TODO: Let caller configure headers, initial body (for replies), etc
-func NewComposer() *Composer {
+func NewComposer(conf *config.AccountConfig) *Composer {
 	grid := ui.NewGrid().Rows([]ui.GridSpec{
 		{ui.SIZE_EXACT, 3},
 		{ui.SIZE_WEIGHT, 1},
@@ -48,32 +54,34 @@ func NewComposer() *Composer {
 	})
 
 	to := newHeaderEditor("To", "")
-	from := newHeaderEditor("From", "")
+	from := newHeaderEditor("From", conf.From)
 	subject := newHeaderEditor("Subject", "")
 	headers.AddChild(to).At(0, 0)
 	headers.AddChild(from).At(0, 1)
 	headers.AddChild(subject).At(1, 0).Span(1, 2)
 	headers.AddChild(ui.NewFill(' ')).At(2, 0).Span(1, 2)
 
+	email, err := ioutil.TempFile("", "aerc-compose-*.eml")
+	if err != nil {
+		// TODO: handle this better
+		return nil
+	}
+
 	// TODO: built-in config option, $EDITOR, then vi, in that order
-	// TODO: temp file
-	editor := exec.Command("vim")
+	editor := exec.Command("vim", email.Name())
 	term, _ := NewTerminal(editor)
 
 	grid.AddChild(headers).At(0, 0)
 	grid.AddChild(term).At(1, 0)
 
 	return &Composer{
-		grid:   grid,
+		config: conf,
 		editor: term,
+		email:  email,
+		grid:   grid,
 		// You have to backtab to get to "From", since you usually don't edit it
-		focused: 1,
-		focusable: []ui.DrawableInteractive{
-			from,
-			to,
-			subject,
-			term,
-		},
+		focused:   1,
+		focusable: []ui.DrawableInteractive{from, to, subject, term},
 	}
 }
 
it/ranger/ext/rifle.py?id=5ca9ab8ca0bdc772124b445341f17c6ca2066a8f'>5ca9ab8c ^
6f8ca83b ^



45dd1a43 ^
6f8ca83b ^



33562459 ^





33562459 ^




45dd1a43 ^
5ca9ab8c ^





4ead0882 ^

5ca9ab8c ^







6f8ca83b ^
45dd1a43 ^

6f8ca83b ^
8e63339d ^


6f8ca83b ^

90b176ed ^
8e63339d ^
6f8ca83b ^
8e63339d ^
6f8ca83b ^
8e63339d ^
6f8ca83b ^
8e63339d ^
6f8ca83b ^
8e63339d ^
6f8ca83b ^
8e63339d ^
456bddd6 ^


8e63339d ^
5ca9ab8c ^
6f8ca83b ^
5ca9ab8c ^

8e63339d ^
6f8ca83b ^

8e63339d ^
6f8ca83b ^
8e63339d ^
6f8ca83b ^


5ca9ab8c ^
6f8ca83b ^

56549de7 ^




6f8ca83b ^
4ead0882 ^




6f8ca83b ^
4ead0882 ^
79c760d7 ^

6f8ca83b ^
4ead0882 ^


6f8ca83b ^

4ead0882 ^














ea8c70ca ^
53f8129c ^
ea8c70ca ^
49e5aa69 ^
4ead0882 ^

6f8ca83b ^
5ca9ab8c ^






6f8ca83b ^
34c0d954 ^
6f8ca83b ^
456bddd6 ^
4ead0882 ^

6f8ca83b ^
5ca9ab8c ^
6f8ca83b ^

456bddd6 ^



06a00bd0 ^
6f8ca83b ^
26e2fcc7 ^
5ca9ab8c ^


26e2fcc7 ^

5ca9ab8c ^

26e2fcc7 ^

5ca9ab8c ^





6f8ca83b ^
8f343062 ^
34c0d954 ^
5ca9ab8c ^
654a81ca ^
26e2fcc7 ^
34c0d954 ^
654a81ca ^
34c0d954 ^
8f343062 ^

c908fd3d ^

1e2d7ced ^
c908fd3d ^
34c0d954 ^
5ca9ab8c ^

8f343062 ^
ddefc642 ^



8f343062 ^

5ca9ab8c ^
4ead0882 ^
032bd50b ^


45dd1a43 ^


bc649759 ^
45dd1a43 ^



4ead0882 ^
33562459 ^
4ead0882 ^
33562459 ^












4ead0882 ^



33562459 ^
4ead0882 ^




33562459 ^


4ead0882 ^


33562459 ^

26e2fcc7 ^
33562459 ^

26e2fcc7 ^
33562459 ^










4ead0882 ^

33562459 ^
26e2fcc7 ^
33562459 ^
6f8ca83b ^

9cf43c17 ^




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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345