diff options
author | jao <jao@gnu.org> | 2021-01-02 01:43:12 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2021-01-02 01:45:50 +0000 |
commit | 4cba361c3a7d51038002300117392ccf5af71814 (patch) | |
tree | adb3d6f40647c862f3ec2b2bdab42381fc77444e | |
parent | 02a28ae4aa5b5d77e7d2ff4fdf6766ee566e773d (diff) | |
download | elibs-4cba361c3a7d51038002300117392ccf5af71814.tar.gz elibs-4cba361c3a7d51038002300117392ccf5af71814.tar.bz2 |
jao-maildir: ordering
-rw-r--r-- | net/jao-maildir.el | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/net/jao-maildir.el b/net/jao-maildir.el index ec6ac28..2177009 100644 --- a/net/jao-maildir.el +++ b/net/jao-maildir.el @@ -65,17 +65,19 @@ (defun jao-maildir--set-trackers (maildirs tracked-maildirs) (jao-maildir--init-counts maildirs) (let* ((label-mboxes (make-hash-table :test 'equal)) - (trackers (mapcar (lambda (track) - (puthash (car track) () label-mboxes) - (let ((tr (seq-take track 2)) - (l (elt track 2))) - (append tr - (cond ((eq l t) '(jao-maildir-emph)) - ((null l) '(default)) - (t (list l)))))) + (trackers (seq-map-indexed + (lambda (track idx) + (puthash (car track) () label-mboxes) + (let ((tr (seq-take track 2)) + (l (elt track 2))) + (append tr + (cond ((eq l t) '(jao-maildir-emph)) + ((null l) '(default)) + (t (list l))) + (list (or (elt track 3) idx))))) tracked-maildirs))) (dolist (mbox maildirs) - (let ((lb (seq-find (lambda (lb) (string-match-p lb mbox)) + (let ((lb (seq-find (lambda (lb) (when lb (string-match-p lb mbox))) (hash-table-keys label-mboxes)))) (puthash lb (cons mbox (gethash lb label-mboxes)) label-mboxes))) (setq jao-maildir--label-mboxes label-mboxes) @@ -93,13 +95,11 @@ (other (assoc-delete-all label jao-maildir--track-strings)) (cnt (jao-maildir--tracked-count track))) (if (> cnt 0) - (let* ((face (last track)) - (str (cons label - (propertize (format "%s%s" label cnt) 'face face)))) - (setq jao-maildir--track-strings - (if (eq face 'default) - (append other (list str)) - (cons str other)))) + (let* ((face (car (last (butlast track)))) + (order (car (last track))) + (str (propertize (format "%s%s" label cnt) 'face face)) + (str (cons label (cons order str)))) + (setq jao-maildir--track-strings (cons str other))) (setq jao-maildir--track-strings other))))) ;;;###autoload @@ -109,7 +109,8 @@ ((stringp mbox) (puthash mbox (jao-maildir--maildir-new-count mbox) jao-maildir--counts) (jao-maildir--update-track-string mbox))) - (let ((s (mapconcat 'identity (mapcar 'cdr jao-maildir--track-strings) " "))) + (let* ((s (seq-sort-by #'cadr #'< jao-maildir--track-strings)) + (s (mapconcat 'identity (mapcar 'cddr s) " "))) (setq jao-maildir-info-string (if (string-blank-p s) "" (concat s " ")))) (when jao-maildir-echo-p (jao-minibuffer-refresh))) |