Function: gnus-summary-insert-subject

gnus-summary-insert-subject is a byte-compiled function defined in gnus-sum.el.gz.

Signature

(gnus-summary-insert-subject ID &optional OLD-HEADER USE-OLD-HEADER)

Documentation

Find article ID and insert the summary line for that article.

OLD-HEADER can either be a header or a line number to insert the subject line on. If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header, and OLD-HEADER will be used when the summary line is inserted, too, instead of trying to fetch new headers.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-sum.el.gz
(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
  "Find article ID and insert the summary line for that article.
OLD-HEADER can either be a header or a line number to insert
the subject line on.
If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
and OLD-HEADER will be used when the summary line is inserted,
too, instead of trying to fetch new headers."
  (let* ((line (and (numberp old-header) old-header))
	 (old-header (and (mail-header-p old-header) old-header))
	 (header (cond ((and old-header use-old-header)
			old-header)
		       ((and (numberp id)
			     (gnus-number-to-header id))
			(gnus-number-to-header id))
		       (t
			(gnus-read-header id))))
	 (number (and (numberp id) id))
	 d)
    (when header
      ;; Rebuild the thread that this article is part of and go to the
      ;; article we have fetched.
      (when (and (not gnus-show-threads)
		 old-header)
	(when (and number
		   (setq d (gnus-data-find (mail-header-number old-header))))
	  (goto-char (gnus-data-pos d))
	  (gnus-data-remove
	   number
           (- (line-beginning-position)
	      (prog1
                  (1+ (line-end-position))
		(gnus-delete-line))))))
      ;; Remove list identifiers from subject.
      (let ((gnus-newsgroup-headers (list header)))
        (gnus-summary-remove-list-identifiers))
      (when old-header
	(setf (mail-header-number header) (mail-header-number old-header)))
      (setq gnus-newsgroup-sparse
	    (delq (setq number (mail-header-number header))
		  gnus-newsgroup-sparse))
      (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
      (push number gnus-newsgroup-limit)
      (gnus-rebuild-thread (mail-header-id header) line)
      (gnus-summary-goto-subject number nil t))
    (when (and (numberp number)
	       (> number 0))
      ;; We have to update the boundaries even if we can't fetch the
      ;; article if ID is a number -- so that the next `P' or `N'
      ;; command will fetch the previous (or next) article even
      ;; if the one we tried to fetch this time has been canceled.
      (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
	(setq gnus-newsgroup-end number))
      (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
	(setq gnus-newsgroup-begin number))
      (setq gnus-newsgroup-unselected
	    (delq number gnus-newsgroup-unselected)))
    ;; Report back a success?
    (and header (mail-header-number header))))