From dabc7bb0487a781dba75fd79f827546043e2de0c Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Sun, 12 Nov 2017 11:15:55 +0300 Subject: [PATCH] Working local echoes --- idec-mode.el | 9 +++++---- idec.el | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/idec-mode.el b/idec-mode.el index 4dd774d..819b69f 100644 --- a/idec-mode.el +++ b/idec-mode.el @@ -227,7 +227,7 @@ optionaly return cursor to CHECKPOINT." ;; Echo name with unread messages ;; ii.test.14 (5)* (insert-button echo - 'action (lambda (x) (browse-local-echo (button-get x 'echo))) + 'action (lambda (x) (idec-browse-local-echo (button-get x 'echo))) 'echo echo '(face nil)) @@ -266,7 +266,7 @@ optionaly return cursor to CHECKPOINT." (goto-char checkpoint)) (idec-mode)) -(defun browse-local-echo (&optional echo) +(defun idec-browse-local-echo (&optional echo) "Get messages from local ECHO." (interactive) (if (not echo) @@ -277,9 +277,10 @@ optionaly return cursor to CHECKPOINT." (setq counter 0) (dolist (msg (get-echo-messages echo)) (insert-button (concat (gethash "subj" msg) "\n") - 'action (lambda (x) (message (button-get x 'subj))) + 'action (lambda (x) (display-message-hash (button-get x 'msg))) 'subj (gethash "subj" msg) - 'help-echo (concat "Read message *" (gethash "subj" msg) "*") ) + 'help-echo (concat "Read message *" (gethash "subj" msg) "*") + 'msg msg) )) (idec-mode))) diff --git a/idec.el b/idec.el index 1d08808..7ef17a9 100644 --- a/idec.el +++ b/idec.el @@ -64,6 +64,40 @@ put cursor to CHECKPOINT." ;; END OF LOCAL MAIL FUNCTIONS ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; +(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"))) + +(defun display-message-hash (msg) + "Disaply message MSG in new buffer." + (mark-message-read (gethash "id" msg) (gethash "echo" msg)) + (with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: " (gethash "subj" msg) "*")) + (switch-to-buffer (concat "*IDEC: " (gethash "subj" msg) "*")) + (princ (make-message-header msg)) + (princ (concat "__________________________________\n\n" + (gethash "body" msg))) + (princ "\n__________________________________\n") + (princ "[") + (let (answer-hash) + (setq answer-hash (make-hash-table :test 'equal)) + (puthash "content" (gethash "msg" msg) answer-hash) + (insert-button "Answer" + 'action (lambda (x) (edit-answer-without-quote (button-get x 'id) (button-get x 'msg-hash))) + 'id (gethash "id" msg) + 'msg-hash answer-hash)) + (princ "]") + (princ "\t [") + (insert-button "Quote answer") + (princ "]") + (add-text-properties (point-min) (point-max) 'read-only)) + (idec-mode)) + (defun display-message (msg) "Display message MSG in new buffer in idec-mode." (mark-message-read (gethash "id" msg) (get-message-field (gethash "msg" msg) "echo"))