diff --git a/idec-db.el b/idec-db.el index 8067f47..8bb33c0 100644 --- a/idec-db.el +++ b/idec-db.el @@ -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) diff --git a/idec-mode.el b/idec-mode.el index fed8748..23445bf 100644 --- a/idec-mode.el +++ b/idec-mode.el @@ -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)) diff --git a/idec-parser.el b/idec-parser.el index d4fc133..d4514c2 100644 --- a/idec-parser.el +++ b/idec-parser.el @@ -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")))))) diff --git a/idec.el b/idec.el index 2180706..77d6feb 100644 --- a/idec.el +++ b/idec.el @@ -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;