Function: mh-coalesce-msg-list
mh-coalesce-msg-list is an autoloaded and byte-compiled function
defined in mh-utils.el.gz.
Signature
(mh-coalesce-msg-list MESSAGES)
Documentation
Given a list of MESSAGES, return a list of message number ranges.
This is the inverse of mh-read-msg-list, which expands ranges.
Message lists passed to MH programs should be processed by this
function to avoid exceeding system command line argument limits.
Source Code
;; Defined in /usr/src/emacs/lisp/mh-e/mh-utils.el.gz
;;; Message Number Utilities
;;;###mh-autoload
(defun mh-coalesce-msg-list (messages)
"Given a list of MESSAGES, return a list of message number ranges.
This is the inverse of `mh-read-msg-list', which expands ranges.
Message lists passed to MH programs should be processed by this
function to avoid exceeding system command line argument limits."
(let ((msgs (sort (copy-sequence messages) #'mh-greaterp))
(range-high nil)
(prev -1)
(ranges nil))
(while prev
(if range-high
(if (or (not (numberp prev))
(not (equal (car msgs) (1- prev))))
(progn ;non-sequential, flush old range
(if (eq prev range-high)
(setq ranges (cons range-high ranges))
(setq ranges (cons (format "%s-%s" prev range-high) ranges)))
(setq range-high nil))))
(or range-high
(setq range-high (car msgs))) ;start new or first range
(setq prev (car msgs))
(setq msgs (cdr msgs)))
ranges))