Skip to content

Commit 748a566

Browse files
committed
Repto support in local mail. Closes #5
1 parent 853ec76 commit 748a566

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

idec-db.el

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,13 @@ unread by default, but you can MARK-READ it."
217217
[:select (funcall count id)
218218
:from messages]))))
219219

220-
(defun get-message-from-db (msgid echo)
220+
(defun idec-db-get-message-by-id (msgid &optional echo)
221221
"Retrieve message by MSGID from ECHO database."
222-
)
222+
(make-hash-from-msg-list (car (emacsql (open-echo-db echo)
223+
[:select [id, tags, author, address, recipient, repto, echo, subj, body, time, unread]
224+
:from messages
225+
:where (= id $s1)]
226+
msgid))))
223227

224228
(defun delete-message-from-db (msgid echo)
225229
"Delete message by MSGID from ECHO database."

idec.el

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,31 @@ put cursor to CHECKPOINT."
8181
"\n"
8282
(gethash "body" msg) "\n"))
8383

84-
8584
(defun make-message-header (msg)
8685
"Make message header from MSG hash."
87-
(concat
88-
(concat "ID: " (gethash "id" msg) "\n")
89-
(concat "From: " (gethash "author" msg) "[" (gethash "address" msg) "]" "\n")
90-
(concat "To: " (gethash "recipient" msg) "\n")
91-
(concat "Echo: " (gethash "echo" msg) "\n")
92-
(concat "At: " (gethash "time" msg) "\n")
93-
(concat "Subject: " (gethash "subj" msg) "\n")))
86+
(insert (concat "ID: " (gethash "id" msg) "\n"))
87+
(insert "From: " )
88+
(if (not (string-equal (gethash "repto" msg) ""))
89+
(insert-button (concat (gethash "author" msg) "[" (gethash "address" msg) "]")
90+
'action (lambda (x) (display-message-hash
91+
(idec-db-get-message-by-id
92+
(gethash "repto" (button-get x 'msg))
93+
(gethash "echo" (button-get x 'msg)))))
94+
'msg msg)
95+
(insert (concat (gethash "author" msg) "[" (gethash "address" msg) "]")))
96+
(insert "\n")
97+
(insert (concat "To: " (gethash "recipient" msg) "\n"))
98+
(insert (concat "Echo: " (gethash "echo" msg) "\n"))
99+
(insert (concat "At: " (gethash "time" msg) "\n"))
100+
(insert (concat "Subject: " (gethash "subj" msg) "\n")))
94101

95102
(defun display-message-hash (msg)
96103
"Disaply message MSG in new buffer."
97104
(mark-message-read (gethash "id" msg) (gethash "echo" msg))
98105
(with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: " (gethash "subj" msg) "*"))
99106
(switch-to-buffer (concat "*IDEC: " (gethash "subj" msg) "*"))
100107
(setq start (point))
101-
(princ (make-message-header msg))
108+
(make-message-header msg)
102109
(princ (concat "__________________________________\n\n"
103110
(replace-in-string "\r" "" (gethash "body" msg))))
104111
(princ "\n__________________________________\n")

0 commit comments

Comments
 (0)