Function: gnus-gather-threads-by-references

gnus-gather-threads-by-references is a byte-compiled function defined in gnus-sum.el.gz.

Signature

(gnus-gather-threads-by-references THREADS)

Documentation

Gather threads by looking at References headers.

Probably introduced at or before Emacs version 19.32.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-gather-threads-by-references (threads)
  "Gather threads by looking at References headers."
  (let ((idhashtb (gnus-make-hashtable 1000))
	(thhashtb (gnus-make-hashtable 1000))
	(prev threads)
	(result threads)
	ids references id gthread gid entered ref)
    (while threads
      (when (setq references (mail-header-references (caar threads)))
	(setq id (mail-header-id (caar threads))
	      ids (inline (gnus-split-references references))
	      entered nil)
	(while (setq ref (pop ids))
	  (setq ids (delete ref ids))
	  (if (not (setq gid (gethash ref idhashtb)))
	      (progn
		(puthash ref id idhashtb)
		(puthash id threads thhashtb))
	    (setq gthread (gethash gid thhashtb))
	    (unless entered
	      ;; We enter a dummy root into the thread, if we
	      ;; haven't done that already.
	      (unless (stringp (caar gthread))
		(setcar gthread (list (mail-header-subject (caar gthread))
				      (car gthread))))
	      ;; We add this new gathered thread to this gathered
	      ;; thread.
	      (setcdr (car gthread)
		      (nconc (cdar gthread) (list (car threads)))))
	    ;; Add it into the thread hash table.
	    (puthash id gthread thhashtb)
	    (setq entered t)
	    ;; Remove it from the list of threads.
	    (setcdr prev (cdr threads))
	    (setq threads prev))))
      (setq prev threads)
      (setq threads (cdr threads)))
    result))