From 748a56633674db33cac782a42a00fd92c3e4dc10 Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Sat, 11 Aug 2018 15:08:05 +0300 Subject: [PATCH] Repto support in local mail. Closes #5 --- idec-db.el | 8 ++++++-- idec.el | 25 ++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/idec-db.el b/idec-db.el index 6186818..f9f2f08 100644 --- a/idec-db.el +++ b/idec-db.el @@ -217,9 +217,13 @@ unread by default, but you can MARK-READ it." [:select (funcall count id) :from messages])))) -(defun get-message-from-db (msgid echo) +(defun idec-db-get-message-by-id (msgid &optional echo) "Retrieve message by MSGID from ECHO database." - ) + (make-hash-from-msg-list (car (emacsql (open-echo-db echo) + [:select [id, tags, author, address, recipient, repto, echo, subj, body, time, unread] + :from messages + :where (= id $s1)] + msgid)))) (defun delete-message-from-db (msgid echo) "Delete message by MSGID from ECHO database." diff --git a/idec.el b/idec.el index 9ae7ccb..37c9e4e 100644 --- a/idec.el +++ b/idec.el @@ -81,16 +81,23 @@ put cursor to CHECKPOINT." "\n" (gethash "body" msg) "\n")) - (defun make-message-header (msg) "Make message header from MSG hash." - (concat - (concat "ID: " (gethash "id" msg) "\n") - (concat "From: " (gethash "author" msg) "[" (gethash "address" msg) "]" "\n") - (concat "To: " (gethash "recipient" msg) "\n") - (concat "Echo: " (gethash "echo" msg) "\n") - (concat "At: " (gethash "time" msg) "\n") - (concat "Subject: " (gethash "subj" msg) "\n"))) + (insert (concat "ID: " (gethash "id" msg) "\n")) + (insert "From: " ) + (if (not (string-equal (gethash "repto" msg) "")) + (insert-button (concat (gethash "author" msg) "[" (gethash "address" msg) "]") + 'action (lambda (x) (display-message-hash + (idec-db-get-message-by-id + (gethash "repto" (button-get x 'msg)) + (gethash "echo" (button-get x 'msg))))) + 'msg msg) + (insert (concat (gethash "author" msg) "[" (gethash "address" msg) "]"))) + (insert "\n") + (insert (concat "To: " (gethash "recipient" msg) "\n")) + (insert (concat "Echo: " (gethash "echo" msg) "\n")) + (insert (concat "At: " (gethash "time" msg) "\n")) + (insert (concat "Subject: " (gethash "subj" msg) "\n"))) (defun display-message-hash (msg) "Disaply message MSG in new buffer." @@ -98,7 +105,7 @@ put cursor to CHECKPOINT." (with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: " (gethash "subj" msg) "*")) (switch-to-buffer (concat "*IDEC: " (gethash "subj" msg) "*")) (setq start (point)) - (princ (make-message-header msg)) + (make-message-header msg) (princ (concat "__________________________________\n\n" (replace-in-string "\r" "" (gethash "body" msg)))) (princ "\n__________________________________\n")