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))))))
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)
"Get count of unread messages from ECHO database."
(car (car (emacsql (open-echo-db echo)

View File

@ -271,19 +271,25 @@ 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 ")") )
(switch-to-buffer (concat "*IDEC: INBOX->(" echo ")"))
(let (counter)
(setq counter 0)
(dolist (msg (get-echo-messages echo))
(insert-button (concat (gethash "subj" msg))
'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 "\t" (gethash "time" msg)))
(princ (concat "\t" (gethash "author" msg) "\n")))
(idec-mode))))
(let (longest)
(setq longest (longest-local-echo-subj echo))
(with-output-to-temp-buffer (get-buffer-create (concat "*IDEC: INBOX->(" echo ")") )
(switch-to-buffer (concat "*IDEC: INBOX->(" echo ")"))
(let (counter)
(setq counter 0)
(dolist (msg (get-echo-messages echo))
(insert-button (concat (gethash "subj" msg)
(make-string
(- longest
(length (gethash "subj" msg)))
? ))
'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
@ -319,8 +325,8 @@ optionaly return cursor to CHECKPOINT."
(and (setq current-echo line)
(store-echo-counter line))
(when (and ;; (check-message-in-echo line current-echo)
(> (length line) 1)
(check-message-in-db line current-echo))
(> (length line) 1)
(check-message-in-db line current-echo))
(when (not (string= "" line))
(puthash line current-echo 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)
"Get MSG time."
;; ;; (trim-string
(current-time-string
(car (read-from-string (nth 2 (split-string msg "\n"))))))

View File

@ -53,7 +53,11 @@
(+ (- (get-longest-string (get-local-echoes))
(length echo))
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)
"Mark all messages in ECHO as read;