-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathakmuch-reply.el
93 lines (90 loc) · 3.02 KB
/
akmuch-reply.el
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
(defun akmuch-reply-sender ()
(interactive)
(akmuch-reply t))
(defun akmuch-reply (&optional senderonly)
(interactive)
(let (file m-strt m-end)
(setq
file
(if (buffer-live-p (get-buffer akmuch-message-buffer))
(with-current-buffer akmuch-message-buffer
akmuch-message-filename)
(akmuch-message-latest (akmuch-get-thread-id))))
(when file
(switch-to-buffer-other-frame (generate-new-buffer "*unsent mail*"))
(if senderonly
(call-process akmuch-notmuch-helper nil (current-buffer) nil
"reply-sender" file)
(call-process akmuch-notmuch-helper nil (current-buffer) nil
"reply" file))
(goto-char (point-min))
(search-forward-regexp "\n\n")
(forward-line -1)
(when (not (search-backward-regexp "^From: " nil t))
(goto-char (point-at-bol))
(insert (format "From: %s\n" user-mail-address)))
(insert "--text follows this line--\n\n")
(goto-char (point-min))
;; hide the in-reply-to and references fields
(save-excursion
(search-forward-regexp "^In-Reply-To:")
(setq m-strt (point-at-bol))
(search-forward-regexp "^[^ \t]")
(add-text-properties m-strt (- (point) 1) '(invisible t read-only t)))
(save-excursion
(search-forward-regexp "^References:")
(setq m-strt (point-at-bol))
(search-forward-regexp "^[^ \t]")
(add-text-properties m-strt (- (point) 1) '(invisible t read-only t)))
(search-forward "--text follows this line--")
(forward-line)
(message-mode)
(run-hooks 'message-setup-hook)
(set-buffer-modified-p nil))))
(defun akmuch-forward ()
(interactive)
(let (file)
(setq
file
(if (buffer-live-p (get-buffer akmuch-message-buffer))
(with-current-buffer akmuch-message-buffer
akmuch-message-filename)
(akmuch-message-latest (akmuch-get-thread-id))))
(with-temp-buffer
(let ((coding-system-for-read 'no-conversion)
(coding-system-for-write 'no-conversion)
buff subject start (done nil)
)
(insert-file-contents file)
(goto-char (point-min))
(while (not done)
(if (or (looking-at (concat "^\\(From\\|To\\|Date\\|Subject\\|"
"Content-Transfer-Encoding\\|"
"Cc\\|Content-Type\\|MIME-Version\\): "))
(looking-at "^[ \t]"))
(forward-line 1)
(delete-region
(point)
(save-excursion
(forward-char 1)
(search-forward-regexp "^[^ \t]")
(forward-char -1)
(point))))
(when (looking-at "^$")
(setq done t)))
(setq buff (current-buffer))
(message-mail-other-frame)
(message-forward-make-body buff nil)
(search-forward-regexp "^<#mml")
(when
(search-forward-regexp
"^Subject: "
(save-excursion (search-forward-regexp "^$") (point)) t)
(setq subject (buffer-substring (point) (point-at-eol))))
(goto-char (point-min))
(search-forward-regexp "^Subject: ")
(insert (concat "Fwd: " subject))
(goto-char (point-min))
(search-forward-regexp "^To: ")
(set-buffer-modified-p nil)))))
(provide 'akmuch-reply)