Working quoting
This commit is contained in:
parent
004b3396ca
commit
c8c7a9a78b
|
@ -106,7 +106,7 @@
|
||||||
(puthash "body"
|
(puthash "body"
|
||||||
(encode-coding-string (s-join "\n" (-drop-last 1 (-drop 4 (split-string (buffer-string) "\n"))))
|
(encode-coding-string (s-join "\n" (-drop-last 1 (-drop 4 (split-string (buffer-string) "\n"))))
|
||||||
'utf-8)
|
'utf-8)
|
||||||
msg)
|
|
||||||
(puthash "subj"
|
(puthash "subj"
|
||||||
(encode-coding-string (nth 1 (split-string (nth 2 (split-string (buffer-string) "\n")) "bj: "))
|
(encode-coding-string (nth 1 (split-string (nth 2 (split-string (buffer-string) "\n")) "bj: "))
|
||||||
'utf-8)
|
'utf-8)
|
||||||
|
@ -207,28 +207,50 @@
|
||||||
(goto-char p)
|
(goto-char p)
|
||||||
(idec)))
|
(idec)))
|
||||||
|
|
||||||
|
(defun idec-answers-get-author-for-quote (author)
|
||||||
|
"Get AUTHOR."
|
||||||
|
;; Parse author
|
||||||
|
(if (string-match ".* .*" author)
|
||||||
|
(concat
|
||||||
|
(nth 1 (s-split "" (nth 0 (s-split " " author))))
|
||||||
|
(nth 1 (s-split "" (nth 1 (s-split " " author)))))
|
||||||
|
author))
|
||||||
|
|
||||||
|
(defun idec-answers-insert-quote (head tail author)
|
||||||
|
"Recursive function for inserting quoted body text;
|
||||||
|
receive string HEAD, list TAIL and original message AUTHOR."
|
||||||
|
(message "Quote insert %S" author)
|
||||||
|
(when (not (string-match "^$" head))
|
||||||
|
(insert author)
|
||||||
|
(insert "> "))
|
||||||
|
(insert (replace-in-string "\r" "" head)) (insert "\n")
|
||||||
|
(when (> (length tail) 0)
|
||||||
|
(idec-answers-insert-quote (car tail) (cdr tail) author)))
|
||||||
|
|
||||||
(defun idec-answers-edit-answer-with-quote (id msg-hash)
|
(defun idec-answers-edit-answer-with-quote (id msg-hash)
|
||||||
"Answer to message with quoted body with ID, MSG-HASH and BODY."
|
"Answer to message with quoted body with ID, MSG-HASH and BODY."
|
||||||
(let (answer-hash p)
|
(let (answer-hash p author)
|
||||||
(setq answer-hash (get-answers-hash id msg-hash))
|
(setq answer-hash (get-answers-hash id msg-hash))
|
||||||
(switch-to-buffer (get-buffer-create (concat "*IDEC: answer to " id "*")))
|
(switch-to-buffer (get-buffer-create (concat "*IDEC: answer to " id "*")))
|
||||||
|
|
||||||
|
;; Answer message header
|
||||||
(insert (make-answer-header id msg-hash))
|
(insert (make-answer-header id msg-hash))
|
||||||
(forward-line)
|
(forward-line)
|
||||||
(add-text-properties (point) (point-min) 'read-only)
|
(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"))
|
;; Quote
|
||||||
(cdr (get-message-field (gethash "content" msg-hash) "body")))
|
(idec-answers-insert-quote
|
||||||
|
(car (get-message-field (gethash "content" msg-hash) "body"))
|
||||||
|
(cdr (get-message-field (gethash "content" msg-hash) "body"))
|
||||||
|
(idec-answers-get-author-for-quote (get-message-field (gethash "content" msg-hash) "author")))
|
||||||
(insert "\n")
|
(insert "\n")
|
||||||
(insert-text-button "[Send]"
|
|
||||||
|
(setq p (- (point) 1))
|
||||||
|
|
||||||
|
;; [Send] button
|
||||||
|
(setq start (point))
|
||||||
|
(insert-button "[Send]"
|
||||||
'action (lambda (x) (send-reply-message (button-get x 'msg)))
|
'action (lambda (x) (send-reply-message (button-get x 'msg)))
|
||||||
'msg answer-hash)
|
'msg answer-hash)
|
||||||
(goto-char p))
|
(goto-char p))
|
||||||
|
@ -243,8 +265,7 @@
|
||||||
(concat "New message to echo " echo "\n")
|
(concat "New message to echo " echo "\n")
|
||||||
"\n"
|
"\n"
|
||||||
"Subj: \n"
|
"Subj: \n"
|
||||||
"------- YOU MESSAGE BELLOW -------\n")
|
"------- YOU MESSAGE BELLOW -------\n"))
|
||||||
)
|
|
||||||
|
|
||||||
(defun edit-new-message (echo)
|
(defun edit-new-message (echo)
|
||||||
"Edit new message to ECHO."
|
"Edit new message to ECHO."
|
||||||
|
|
|
@ -268,7 +268,7 @@ optionaly return cursor to CHECKPOINT."
|
||||||
(princ "]\n"))
|
(princ "]\n"))
|
||||||
(message (concat "IDEC: FUUUUUU <" echo ">")))
|
(message (concat "IDEC: FUUUUUU <" echo ">")))
|
||||||
))
|
))
|
||||||
(add-text-properties (beginning-of-buffer) (end-of-buffer) 'read-only))
|
(put-text-property (beginning-of-buffer) (end-of-buffer) 'read-only nil))
|
||||||
(if checkpoint
|
(if checkpoint
|
||||||
(goto-char checkpoint))
|
(goto-char checkpoint))
|
||||||
(idec))
|
(idec))
|
||||||
|
|
2
idec.el
2
idec.el
|
@ -111,7 +111,7 @@ put cursor to CHECKPOINT."
|
||||||
'id (gethash "id" msg)
|
'id (gethash "id" msg)
|
||||||
'msg-hash answer-hash)
|
'msg-hash answer-hash)
|
||||||
(princ "]")
|
(princ "]")
|
||||||
(princ "\t [")
|
(princ (concat (make-string 11 ? ) "["))
|
||||||
(insert-button "Quoted answer"
|
(insert-button "Quoted answer"
|
||||||
'action (lambda (x) (idec-answers-edit-answer-with-quote
|
'action (lambda (x) (idec-answers-edit-answer-with-quote
|
||||||
(button-get x 'id)
|
(button-get x 'id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user