Select echo messages fucntion
This commit is contained in:
parent
a208a5192a
commit
fc60b7d2f3
@ -198,7 +198,7 @@
|
||||
'action (lambda (x) (send-reply-message (button-get x 'msg)))
|
||||
'msg answer-hash)
|
||||
(goto-char p)
|
||||
(idec-mode)))
|
||||
(org-idec)))
|
||||
|
||||
;; END OF ANSWERS
|
||||
|
||||
@ -225,7 +225,7 @@
|
||||
'action (lambda (x) (send-new-message (button-get x 'msg-echo)))
|
||||
'msg-echo echo)
|
||||
(goto-char p))
|
||||
(idec-mode))
|
||||
(org-idec))
|
||||
|
||||
(provide 'idec-answers)
|
||||
|
||||
|
32
idec-db.el
32
idec-db.el
@ -142,6 +142,38 @@ unread by default, but you can MARK-READ it."
|
||||
[:select [id]
|
||||
:from messages])))
|
||||
|
||||
(defun make-hash-from-msg-list (msg-list)
|
||||
"Return hash table maded from MSG-LIST."
|
||||
(let (msg-hash)
|
||||
(if (and
|
||||
(listp msg-list)
|
||||
(> (length msg-list) 0))
|
||||
(let ()
|
||||
(setq msg-hash (make-hash-table :test 'equal))
|
||||
(puthash "id" (nth 0 l) msg-hash)
|
||||
(puthash "tags" (nth 1 l) msg-hash)
|
||||
(puthash "author" (nth 2 l) msg-hash)
|
||||
(puthash "recipient" (nth 3 l) msg-hash)
|
||||
(puthash "repto" (nth 4 l) msg-hash)
|
||||
(puthash "echo" (nth 5 l) msg-hash)
|
||||
(puthash "subj" (nth 6 l) msg-hash)
|
||||
(puthash "body" (nth 7 l) msg-hash)
|
||||
(puthash "time" (nth 8 l) msg-hash)
|
||||
(puthash "unread" (nth 9 l) msg-hash)))
|
||||
msg-hash))
|
||||
|
||||
(defun get-echo-messages (echo)
|
||||
"Get ECHO messages ordered by time."
|
||||
(let (msgs)
|
||||
(setq msgs (make-list 0 (make-hash-table :test 'equal)))
|
||||
(dolist (l (emacsql (open-echo-db echo)
|
||||
[:select [id tags author recipient repto echo subj body time unread]
|
||||
:from messages
|
||||
:order-by time]))
|
||||
(if (> (length l) 0)
|
||||
(setq msgs (append msgs (make-list 1 (make-hash-from-msg-list l))))))
|
||||
msgs))
|
||||
|
||||
(defun get-echo-unread-messages (echo)
|
||||
"Get count of unread messages from ECHO database."
|
||||
(car (car (emacsql (open-echo-db echo)
|
||||
|
45
idec-mode.el
45
idec-mode.el
@ -61,16 +61,25 @@
|
||||
'("\\<\\(>>?.*\\)\s\\>" . font-lock-comment-face)))
|
||||
"Quotes highligting for IDEC mode.")
|
||||
|
||||
(defvar idec-font-lock-keywords
|
||||
'(("function \\(\\sw+\\)" (1 font-lock-function-name-face)))
|
||||
(defvar idec-font-lock-keywords idec-font-lock-keywords-1
|
||||
;; '(("ID" (1 font-lock-function-name-face)))
|
||||
"Default highlighting expressions for IDEC mode.")
|
||||
|
||||
;; Mode function
|
||||
(define-derived-mode idec-mode org-mode "IDEC"
|
||||
(define-generic-mode
|
||||
'idec
|
||||
'("//" ">" "ЗЫ" "# ")
|
||||
'("ii://" "ID" "$subj" "сабж" "субж"
|
||||
"Subject" "From" "To" "Echo" "At")
|
||||
'(("=" . 'font-lock-operator)
|
||||
(";" . 'font-lock-builtin))
|
||||
'("\\.idec$")
|
||||
nil)
|
||||
|
||||
(define-derived-mode org-idec text-mode "IDEC"
|
||||
"Major mode for view and editing IDEC messages."
|
||||
:syntax-table idec-mode-syntax-table
|
||||
(setq-local comment-start "// ")
|
||||
(setq-local comment-start-skip "//+\\s-*")
|
||||
(setq-local comment-start "/{2} ")
|
||||
(setq-local font-lock-defaults
|
||||
'(idec-font-lock-keywords))
|
||||
(use-local-map idec-mode-map)
|
||||
@ -79,19 +88,19 @@
|
||||
(setq mode-name "[IDEC]")
|
||||
(run-hooks 'idec-mode-hook))
|
||||
|
||||
;; (defun idec-mode ()
|
||||
;; "Major mode for view and editing IDEC messages."
|
||||
;; (interactive)
|
||||
;; (kill-all-local-variables)
|
||||
;; ;; Mode definition
|
||||
;; (set-syntax-table idec-mode-syntax-table)
|
||||
;; (use-local-map idec-mode-map)
|
||||
;; ;; (font-lock-add-keywords 'idec-mode '(idec-font-lock-keywords))
|
||||
;; ;; (set (make-local-variable 'font-lock-defaults) '(idec-font-lock-keywords))
|
||||
;; (setq major-mode 'idec-mode)
|
||||
;; (setq mode-name "[IDEC]")
|
||||
;; (setq imenu-generic-expression "*IDEC")
|
||||
;; (run-hooks 'idec-mode-hook))
|
||||
(defun idec-mode ()
|
||||
"Major mode for view and editing IDEC messages."
|
||||
(interactive)
|
||||
(kill-all-local-variables)
|
||||
;; Mode definition
|
||||
(set-syntax-table idec-mode-syntax-table)
|
||||
(use-local-map idec-mode-map)
|
||||
;; (font-lock-add-keywords 'idec-mode '(idec-font-lock-keywords))
|
||||
;; (set (make-local-variable 'font-lock-defaults) '(idec-font-lock-keywords))
|
||||
(setq major-mode 'idec-mode)
|
||||
(setq mode-name "[IDEC]")
|
||||
(setq imenu-generic-expression "*IDEC")
|
||||
(run-hooks 'idec-mode-hook))
|
||||
|
||||
(provide 'idec-mode)
|
||||
|
||||
|
@ -52,7 +52,9 @@
|
||||
(princ (concat "To: " (get-message-field (gethash "content" msg-hash) "recipient") "\n"))
|
||||
(princ (concat "Echo: " (get-message-field (gethash "content" msg-hash) "echo") "\n"))
|
||||
(princ (concat "At: " (get-message-field (gethash "content" msg-hash) "time") "\n"))
|
||||
(princ (concat "Subject: " (get-message-field (gethash "content" msg-hash) "subj") "\n"))
|
||||
(let (subj)
|
||||
(setq subj (concat "Subject: " (get-message-field (gethash "content" msg-hash) "subj")))
|
||||
(princ (concat subj "\n")))
|
||||
(princ (concat "__________________________________\n\n"
|
||||
(s-join "\n" (get-message-field (gethash "content" msg-hash) "body"))))
|
||||
(princ "\n__________________________________\n")
|
||||
@ -64,11 +66,11 @@
|
||||
(princ "]")
|
||||
(princ "\t [")
|
||||
(insert-button "Answer with quote")
|
||||
(princ "]\n\n"))
|
||||
(add-text-properties (point-min) (point) 'read-only))
|
||||
(princ "]\n\n")))
|
||||
;; Plain messages hash proccesing
|
||||
(get-messages-content echo-msg-hash))
|
||||
(idec-mode))))
|
||||
;; (idec-mode)
|
||||
(idec))))
|
||||
|
||||
|
||||
(defun load-echo-messages (echo &optional online)
|
||||
@ -89,20 +91,38 @@
|
||||
"Parse RAW-LIST from HTTP response."
|
||||
(with-output-to-temp-buffer (get-buffer-create "*IDEC: list.txt*")
|
||||
(switch-to-buffer "*IDEC: list.txt*")
|
||||
(dolist (line (split-string (decode-coding-string raw-list 'utf-8) "\n"))
|
||||
(when (not (equal line ""))
|
||||
;; Defind echo
|
||||
(defvar current-echo nil)
|
||||
(setq current-echo (nth 0 (split-string line ":")))
|
||||
;; Create clickable button
|
||||
(insert-text-button current-echo
|
||||
'action (lambda (x) (load-echo-messages (button-get x 'echo) t))
|
||||
'help-echo (concat "Go to echo " current-echo)
|
||||
'echo current-echo)
|
||||
(princ (format "\t\t||%s\t\t%s\n"
|
||||
(nth 2 (split-string line ":"))
|
||||
(nth 1 (split-string line ":")))))
|
||||
))
|
||||
(let (len lst)
|
||||
;; Calculate echo name
|
||||
(setq lst (list))
|
||||
(dolist (l (split-string (decode-coding-string raw-list 'utf-8) "\n"))
|
||||
(add-to-list 'lst (nth 0 (split-string l ":")) t))
|
||||
(setq len (get-longest-string lst))
|
||||
(message (concat "Longest echo " (number-to-string len)))
|
||||
(dolist (line (split-string (decode-coding-string raw-list 'utf-8) "\n"))
|
||||
(when (not (equal line ""))
|
||||
;; Define echo
|
||||
(defvar current-echo nil)
|
||||
(setq current-echo (nth 0 (split-string line ":")))
|
||||
;; Create clickable button
|
||||
(insert-text-button current-echo
|
||||
'action (lambda (x) (load-echo-messages (button-get x 'echo) t))
|
||||
'help-echo (concat "Go to echo " current-echo)
|
||||
'echo current-echo)
|
||||
(save-excursion
|
||||
(let (s e)
|
||||
(setq e (point))
|
||||
(beginning-of-line)
|
||||
(setq s (point))
|
||||
(add-text-properties s e '(comment t face '(:foreground "light green")))))
|
||||
(princ (make-string (+ 3 (- len (length current-echo))) ? ))
|
||||
(princ (format "%s\n"
|
||||
(nth 2 (split-string line ":"))))
|
||||
(save-excursion
|
||||
(let (s e)
|
||||
(setq e (point))
|
||||
(re-search-backward " ")
|
||||
(setq s (point))
|
||||
(add-text-properties s e '(comment t face '(:foreground "light blue")))))))))
|
||||
(idec-mode))
|
||||
|
||||
(defun idec-fetch-echo-list (nodeurl)
|
||||
|
9
idec.el
9
idec.el
@ -212,7 +212,7 @@ optionaly return cursor to CHECKPOINT."
|
||||
(setq start (point))
|
||||
(end-of-line)
|
||||
(setq end (point))
|
||||
(add-text-properties start end '(comment t face '(:foreground "green")))
|
||||
(add-text-properties start end '(comment t face '(:foreground "light green")))
|
||||
|
||||
(princ (concat (dots echo)
|
||||
"("
|
||||
@ -248,7 +248,9 @@ optionaly return cursor to CHECKPOINT."
|
||||
(interactive)
|
||||
(if (not echo)
|
||||
(setq echo (read-string "Enter echo name: ")))
|
||||
(with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: INBOX->(" echo ")") )))
|
||||
(with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: INBOX->(" echo ")") )
|
||||
(princ (number-to-string (length (get-echo-messages echo))))
|
||||
(idec-mode)))
|
||||
|
||||
;; END OF LOCAL MAIL FUNCTIONS
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -313,8 +315,7 @@ optionaly return cursor to CHECKPOINT."
|
||||
(princ "]")
|
||||
(add-text-properties (point-min) (point-max) 'read-only))
|
||||
(point-max)
|
||||
(idec-mode)
|
||||
(visual-line-mode))
|
||||
(idec-mode))
|
||||
|
||||
(defun display-new-messages ()
|
||||
"Display new fetched messages from `new-messages-list'."
|
||||
|
Loading…
Reference in New Issue
Block a user