Skip to content

Instantly share code, notes, and snippets.

@rothmichaels
Last active July 8, 2016 16:54
Show Gist options
  • Select an option

  • Save rothmichaels/1d546e61615190d2fea92fd80784b27d to your computer and use it in GitHub Desktop.

Select an option

Save rothmichaels/1d546e61615190d2fea92fd80784b27d to your computer and use it in GitHub Desktop.
(defun gnus-user-format-function-t (dummy)
(case (car gnus-tmp-method)
(nnimap
(let ((count (nnimap-request-message-count gnus-tmp-qualified-group)))
(if count
(format "%d" count)
"?")))
(t
gnus-tmp-number-total)))
(defvar nnimap-message-count-cache-alist nil)
(defun nnimap-message-count-cache-clear nil
(setq nnimap-message-count-cache-alist nil))
(defun nnimap-message-count-cache-get (mbox &optional server)
(when (nnimap-possibly-change-server server)
(cadr (assoc (concat nnimap-current-server ":" mbox)
nnimap-message-count-cache-alist))))
(defun nnimap-message-count-cache-set (mbox count &optional server)
(when (nnimap-possibly-change-server server)
(push (list (concat nnimap-current-server ":" mbox)
count) nnimap-message-count-cache-alist))
count)
(defun nnimap-request-message-count (mbox &optional server)
(let ((count (or (nnimap-message-count-cache-get mbox server)
(and (nnimap-possibly-change-server server)
(progn
(message "Requesting message count for %s..."
mbox)
(prog1
(imap-mailbox-status
mbox 'messages nnimap-server-buffer)
(message "Requesting message count for %s...done"
mbox)))))))
(when count
(nnimap-message-count-cache-set mbox count server))
count))
(add-hook 'gnus-after-getting-new-news-hook 'nnimap-message-count-cache-clear)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment