Function: mh-parse-flist-output-line

mh-parse-flist-output-line is an autoloaded and byte-compiled function defined in mh-seq.el.gz.

Signature

(mh-parse-flist-output-line LINE &optional CURRENT-FOLDER)

Documentation

Parse LINE to generate folder name, unseen messages and total messages.

If CURRENT-FOLDER is non-nil then it contains the current folder name and it is used to avoid problems in corner cases involving folders whose names end with a + character.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-seq.el.gz
;;;###mh-autoload
(defun mh-parse-flist-output-line (line &optional current-folder)
  "Parse LINE to generate folder name, unseen messages and total messages.
If CURRENT-FOLDER is non-nil then it contains the current folder
name and it is used to avoid problems in corner cases involving
folders whose names end with a `+' character."
  (with-temp-buffer
    (insert line)
    (goto-char (point-max))
    (let (folder unseen total p)
      (when (search-backward " out of " (point-min) t)
        (setq total (string-to-number
                     (buffer-substring-no-properties
                      (match-end 0) (line-end-position))))
        (when (search-backward " in sequence " (point-min) t)
          (setq p (point))
          (when (search-backward " has " (point-min) t)
            (setq unseen (string-to-number (buffer-substring-no-properties
                                            (match-end 0) p)))
            (while (eq (char-after) ? )
              (backward-char))
            (setq folder (buffer-substring-no-properties
                          (point-min) (1+ (point))))
            (when (and (equal (aref folder (1- (length folder))) ?+)
                       (equal current-folder folder))
              (setq folder (substring folder 0 (1- (length folder)))))
            (list (format "+%s" folder) unseen total)))))))