Function: mh-speed-parse-flists-output

mh-speed-parse-flists-output is a byte-compiled function defined in mh-speed.el.gz.

Signature

(mh-speed-parse-flists-output PROCESS OUTPUT)

Documentation

Parse the incremental results from flists.

PROCESS is the flists process and OUTPUT is the results that must be handled next.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-speed.el.gz
;; Copied from mh-make-folder-list-filter...
;; XXX Refactor to use mh-make-folder-list-filer?
(defun mh-speed-parse-flists-output (_process output)
  "Parse the incremental results from flists.
PROCESS is the flists process and OUTPUT is the results that must
be handled next."
  (let ((prevailing-match-data (match-data))
        (position 0)
        line-end line folder unseen total)
    (unwind-protect
        (while (setq line-end (string-search "\n" output position))
          (setq line (format "%s%s"
                             mh-speed-partial-line
                             (substring output position line-end))
                mh-speed-partial-line "")
          (cl-multiple-value-setq (folder unseen total)
            (cl-values-list
             (mh-parse-flist-output-line line mh-speed-current-folder)))
          (when (and folder unseen total
                     (let ((old-pair (gethash folder mh-speed-flists-cache)))
                       (or (not (equal (car old-pair) unseen))
                           (not (equal (cdr old-pair) total)))))
            (setf (gethash folder mh-speed-flists-cache) (cons unseen total))
            (when (buffer-live-p (get-buffer speedbar-buffer))
              (with-current-buffer speedbar-buffer
                (speedbar-with-writable
                  (when (get-text-property (point-min) 'mh-level)
                    (let ((pos (gethash folder mh-speed-folder-map))
                          face)
                      (when pos
                        (goto-char pos)
                        (goto-char (mh-line-beginning-position))
                        (cond
                         ((null (get-text-property (point) 'mh-count))
                          (goto-char (mh-line-end-position))
                          (setq face (get-text-property (1- (point)) 'face))
                          (insert (format " (%s/%s)" unseen total))
                          (mh-speed-highlight 'unknown face)
                          (goto-char (mh-line-beginning-position))
                          (add-text-properties (point) (1+ (point))
                                               `(mh-count (,unseen . ,total))))
                         ((not (equal (get-text-property (point) 'mh-count)
                                      (cons unseen total)))
                          (goto-char (mh-line-end-position))
                          (setq face (get-text-property (1- (point)) 'face))
                          (re-search-backward " " (mh-line-beginning-position) t)
                          (delete-region (point) (mh-line-end-position))
                          (insert (format " (%s/%s)" unseen total))
                          (mh-speed-highlight 'unknown face)
                          (goto-char (mh-line-beginning-position))
                          (add-text-properties
                           (point) (1+ (point))
                           `(mh-count (,unseen . ,total))))))))))))
          (setq position (1+ line-end)))
      (set-match-data prevailing-match-data))
    (setq mh-speed-partial-line (substring output position))))