Initial quotes support

This commit is contained in:
Denis Zheleztsov 2018-08-09 22:53:49 +03:00
parent 1ac8f13eec
commit 7344cc325f
2 changed files with 41 additions and 7 deletions

View File

@ -191,7 +191,6 @@
(defun edit-answer-without-quote (id msg-hash)
"Answer to message with ID MSG-HASH."
msg-hash
(let (answer-hash p)
(setq answer-hash (get-answers-hash id msg-hash))
(switch-to-buffer (get-buffer-create (concat "*IDEC: answer to " id "*")))
@ -208,6 +207,33 @@
(goto-char p)
(idec)))
(defun idec-answers-edit-answer-with-quote (id msg-hash)
"Answer to message with quoted body with ID, MSG-HASH and BODY."
(let (answer-hash p)
(setq answer-hash (get-answers-hash id msg-hash))
(switch-to-buffer (get-buffer-create (concat "*IDEC: answer to " id "*")))
(insert (make-answer-header id msg-hash))
(forward-line)
(add-text-properties (point) (point-min) 'read-only)
(setq p (point))
(defun insert-quote (head tail)
"Insert quote with HEAD and TAIL."
(insert "> ") (insert head) (insert "\n")
(when (> (length tail) 0)
(message "%S" tail)
(insert-quote (car tail) (cdr tail))))
(insert-quote (car (get-message-field (gethash "content" msg-hash) "body"))
(cdr (get-message-field (gethash "content" msg-hash) "body")))
(insert "\n")
(insert-text-button "[Send]"
'action (lambda (x) (send-reply-message (button-get x 'msg)))
'msg answer-hash)
(goto-char p))
(idec))
;; END OF ANSWERS
;; NEW MESSAGE

20
idec.el
View File

@ -109,10 +109,15 @@ put cursor to CHECKPOINT."
(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))
'msg-hash answer-hash)
(princ "]")
(princ "\t [")
(insert-button "Quote answer")
(insert-button "Quoted answer"
'action (lambda (x) (idec-answers-edit-answer-with-quote
(button-get x 'id)
(button-get x 'msg-hash)))
'id (gethash "id" msg)
'msg-hash answer-hash))
(princ "]")
(add-text-properties start (point) 'read-only))
(idec))
@ -151,14 +156,17 @@ put cursor to CHECKPOINT."
(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))
'msg-hash answer-hash)
(princ "]")
(princ (concat (make-string 6 ? ) "["))
(insert-button "Quote answer")
(princ (concat (make-string 9 ? ) "["))
(insert-button "Quoted answer"
'action (lambda (x) (idec-answers-edit-answer-with-quote (button-get x 'id) (button-get x 'msg-hash)))
'id (gethash "id" msg)
'msg-hash answer-hash))
(princ "]")
(add-text-properties (point-min) (point-max) 'read-only))
(point-max)
(idec-mode))
(idec))
(defun display-new-messages ()
"Display new fetched messages from `new-messages-list'."