+;; Some summary mode macros.
+
+;; Return a header specified by a NUMBER.
+(defun gnus-get-header-by-number (number)
+ (save-excursion
+ (set-buffer gnus-summary-buffer)
+ (or gnus-newsgroup-headers-hashtb-by-number
+ (gnus-make-headers-hashtable-by-number))
+ (gnus-gethash (int-to-string number)
+ gnus-newsgroup-headers-hashtb-by-number)))
+
+;; Fast version of the function above.
+(defmacro gnus-get-header-by-num (number)
+ (` (gnus-gethash (int-to-string (, number))
+ gnus-newsgroup-headers-hashtb-by-number)))
+
+(defmacro gnus-summary-search-forward (&optional unread subject backward)
+ "Search for article forward.
+If UNREAD is non-nil, only unread articles are selected.
+If SUBJECT is non-nil, the article which has the same subject will be
+searched for.
+If BACKWARD is non-nil, the search will be performed backwards instead."
+ (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
+
+(defmacro gnus-summary-search-backward (&optional unread subject)
+ "Search for article backward.
+If 1st optional argument UNREAD is non-nil, only unread article is selected.
+If 2nd optional argument SUBJECT is non-nil, the article which has
+the same subject will be searched for."
+ (` (gnus-summary-search-forward (, unread) (, subject) t)))
+
+(defmacro gnus-summary-article-number (&optional number-or-nil)
+ "The article number of the article on the current line.
+If there isn's an article number here, then we return the current
+article number."
+ (if number-or-nil
+ '(get-text-property (gnus-point-at-bol) 'gnus-number)
+ '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
+ gnus-current-article)))
+
+(defmacro gnus-summary-thread-level ()
+ "The thread level of the article on the current line."
+ '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
+ 0))
+
+(defmacro gnus-summary-article-mark ()
+ "The mark on the current line."
+ '(get-text-property (gnus-point-at-bol) 'gnus-mark))
+
+(defun gnus-summary-subject-string ()
+ "Return current subject string or nil if nothing."
+ (let ((article (gnus-summary-article-number))
+ header)
+ (and article
+ (setq header (gnus-get-header-by-num article))
+ (vectorp header)
+ (header-subject header))))
+
+