Working local echoes

This commit is contained in:
Denis Zheleztsov 2017-11-12 11:15:55 +03:00
parent 94ad808dcb
commit dabc7bb048
2 changed files with 39 additions and 4 deletions

View File

@ -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)))

34
idec.el
View File

@ -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"))