Function: mh-subject-to-sequence-unthreaded

mh-subject-to-sequence-unthreaded is a byte-compiled function defined in mh-limit.el.gz.

Signature

(mh-subject-to-sequence-unthreaded ALL)

Documentation

Put all following messages with same subject in sequence subject.

This function only works with an unthreaded folder. If arg ALL is t, move to beginning of folder buffer to collect all messages. If arg ALL is nil, collect only messages from current one on forward.

Return number of messages put in the sequence:

 nil -> there was no subject line.
 0 -> there were no later messages with the same
        subject (sequence not made)
 >1 -> the total number of messages including current one.

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-limit.el.gz
(defun mh-subject-to-sequence-unthreaded (all)
  "Put all following messages with same subject in sequence `subject'.

This function only works with an unthreaded folder. If arg ALL is
t, move to beginning of folder buffer to collect all messages. If
arg ALL is nil, collect only messages from current one on
forward.

Return number of messages put in the sequence:

 nil -> there was no subject line.
 0   -> there were no later messages with the same
        subject (sequence not made)
 >1  -> the total number of messages including current one."
  (if (not (eq major-mode 'mh-folder-mode))
      (error "Not in a folder buffer"))
  (save-excursion
    (beginning-of-line)
    (if (or (not (looking-at mh-scan-subject-regexp))
            (not (match-string 3))
            (string-equal "" (match-string 3)))
        (progn (message "No subject line")
               nil)
      (let ((subject (match-string-no-properties 3))
            (list))
        (if (> (length subject) mh-limit-max-subject-size)
            (setq subject (substring subject 0 mh-limit-max-subject-size)))
        (save-excursion
          (if all
              (goto-char (point-min)))
          (while (re-search-forward mh-scan-subject-regexp nil t)
            (let ((this-subject (match-string-no-properties 3)))
              (if (> (length this-subject) mh-limit-max-subject-size)
                  (setq this-subject (substring this-subject
                                                0 mh-limit-max-subject-size)))
              (if (string-equal this-subject subject)
                  (setq list (cons (mh-get-msg-num t) list))))))
        (cond
         (list
          ;; If we created a new sequence, add the initial message to it too.
          (if (not (member (mh-get-msg-num t) list))
              (setq list (cons (mh-get-msg-num t) list)))
          (if (assoc 'subject mh-seq-list) (mh-delete-seq 'subject))
          ;; sort the result into a sequence
          (let ((sorted-list (sort (copy-sequence list) #'mh-lessp)))
            (while sorted-list
              (mh-add-msgs-to-seq (car sorted-list) 'subject nil)
              (setq sorted-list (cdr sorted-list)))
            (safe-length list)))
         (t
          0))))))