+(defun gnus-summary-limit-to-headers (match &optional reverse)
+ "Limit the summary buffer to articles that have headers that match MATCH.
+If REVERSE (the prefix), limit to articles that don't match."
+ (interactive "sMatch headers (regexp): \nP")
+ (gnus-summary-limit-to-bodies match reverse t))
+
+(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
+ "Limit the summary buffer to articles that have bodies that match MATCH.
+If REVERSE (the prefix), limit to articles that don't match."
+ (interactive "sMatch body (regexp): \nP")
+ (let ((articles nil)
+ (gnus-select-article-hook nil) ;Disable hook.
+ (gnus-article-prepare-hook nil)
+ (gnus-use-article-prefetch nil)
+ (gnus-keep-backlog nil)
+ (gnus-break-pages nil)
+ (gnus-summary-display-arrow nil)
+ (gnus-updated-mode-lines nil)
+ (gnus-auto-center-summary nil)
+ (gnus-display-mime-function nil))
+ (dolist (data gnus-newsgroup-data)
+ (let (gnus-mark-article-hook)
+ (gnus-summary-select-article t t nil (gnus-data-number data)))
+ (save-excursion
+ (set-buffer gnus-article-buffer)
+ (article-goto-body)
+ (let* ((case-fold-search t)
+ (found (if headersp
+ (re-search-backward match nil t)
+ (re-search-forward match nil t))))
+ (when (or (and found
+ (not reverse))
+ (and (not found)
+ reverse))
+ (push (gnus-data-number data) articles)))))
+ (if (not articles)
+ (message "No messages matched")
+ (gnus-summary-limit articles)))
+ (gnus-summary-position-point))
+
+(defun gnus-summary-limit-to-singletons (&optional threadsp)
+ "Limit the summary buffer to articles that aren't part on any thread.
+If THREADSP (the prefix), limit to articles that are in threads."
+ (interactive "P")
+ (let ((articles nil)
+ thread-articles
+ threads)
+ (dolist (thread gnus-newsgroup-threads)
+ (if (stringp (car thread))
+ (dolist (thread (cdr thread))
+ (push thread threads))
+ (push thread threads)))
+ (dolist (thread threads)
+ (setq thread-articles (gnus-articles-in-thread thread))
+ (when (or (and threadsp
+ (> (length thread-articles) 1))
+ (and (not threadsp)
+ (= (length thread-articles) 1)))
+ (setq articles (nconc thread-articles articles))))
+ (if (not articles)
+ (message "No messages matched")
+ (gnus-summary-limit articles))
+ (gnus-summary-position-point)))
+