Local echo beautiful view

This commit is contained in:
Denis Zheleztsov 2018-06-27 15:08:32 +03:00
parent d5ee9d046d
commit d41e084ae5
Signed by: Difrex
GPG Key ID: B047A0E62A285621
4 changed files with 36 additions and 17 deletions

View File

@ -178,6 +178,16 @@ unread by default, but you can MARK-READ it."
(setq msgs (append msgs (make-list 1 (make-hash-from-msg-list l)))))) (setq msgs (append msgs (make-list 1 (make-hash-from-msg-list l))))))
msgs)) msgs))
(defun get-echo-subjects (echo)
"Get list of subjects from ECHO."
(let (subjects)
(setq subjects (make-list 0 ""))
(dolist (l (emacsql (open-echo-db echo)
[:select [subj]
:from messages]))
(setq subjects (append subjects (make-list 1 (nth 0 l)))))
subjects))
(defun get-echo-unread-messages (echo) (defun get-echo-unread-messages (echo)
"Get count of unread messages from ECHO database." "Get count of unread messages from ECHO database."
(car (car (emacsql (open-echo-db echo) (car (car (emacsql (open-echo-db echo)

View File

@ -271,19 +271,25 @@ optionaly return cursor to CHECKPOINT."
(interactive) (interactive)
(if (not echo) (if (not echo)
(setq echo (read-string "Enter echo name: "))) (setq echo (read-string "Enter echo name: ")))
(with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: INBOX->(" echo ")") ) (let (longest)
(switch-to-buffer (concat "*IDEC: INBOX->(" echo ")")) (setq longest (longest-local-echo-subj echo))
(let (counter) (with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: INBOX->(" echo ")") )
(setq counter 0) (switch-to-buffer (concat "*IDEC: INBOX->(" echo ")"))
(dolist (msg (get-echo-messages echo)) (let (counter)
(insert-button (concat (gethash "subj" msg)) (setq counter 0)
'action (lambda (x) (display-message-hash (button-get x 'msg-hash))) (dolist (msg (get-echo-messages echo))
'subj (gethash "subj" msg) (insert-button (concat (gethash "subj" msg)
'help-echo (concat "Read message *" (gethash "subj" msg) "*") (make-string
'msg-hash msg) (- longest
(princ (concat "\t" (gethash "time" msg))) (length (gethash "subj" msg)))
(princ (concat "\t" (gethash "author" msg) "\n"))) ? ))
(idec-mode)))) 'action (lambda (x) (display-message-hash (button-get x 'msg-hash)))
'subj (gethash "subj" msg)
'help-echo (concat "Read message *" (gethash "subj" msg) "*")
'msg-hash msg)
(princ (concat " " (gethash "time" msg)))
(princ (concat "\t" (gethash "author" msg) "\n")))
(idec-mode)))))
;; NAVIGATION FUNCTIONS ;; NAVIGATION FUNCTIONS
@ -319,8 +325,8 @@ optionaly return cursor to CHECKPOINT."
(and (setq current-echo line) (and (setq current-echo line)
(store-echo-counter line)) (store-echo-counter line))
(when (and ;; (check-message-in-echo line current-echo) (when (and ;; (check-message-in-echo line current-echo)
(> (length line) 1) (> (length line) 1)
(check-message-in-db line current-echo)) (check-message-in-db line current-echo))
(when (not (string= "" line)) (when (not (string= "" line))
(puthash line current-echo msgid-for-download))))) (puthash line current-echo msgid-for-download)))))
(download-message msgid-for-download)) (download-message msgid-for-download))

View File

@ -44,7 +44,6 @@ White space here is any of: space, tab, Emacs newline (line feed, ASCII 10)."
(defun get-message-time (msg) (defun get-message-time (msg)
"Get MSG time." "Get MSG time."
;; ;; (trim-string
(current-time-string (current-time-string
(car (read-from-string (nth 2 (split-string msg "\n")))))) (car (read-from-string (nth 2 (split-string msg "\n"))))))

View File

@ -53,7 +53,11 @@
(+ (- (get-longest-string (get-local-echoes)) (+ (- (get-longest-string (get-local-echoes))
(length echo)) (length echo))
3) 3)
? )) ? )) ; `? ' - Space character
(defun longest-local-echo-subj (echo)
"Get longest subj from local ECHO."
(get-longest-string (get-echo-subjects echo)))
(defun mark-all-as-read (echo &optional checkpoint) (defun mark-all-as-read (echo &optional checkpoint)
"Mark all messages in ECHO as read; "Mark all messages in ECHO as read;