#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file gnus.el continued
#
CurArch=3
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
sed 's/^X//' << 'SHAR_EOF' >> gnus.el
X  (define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-and-exit)
X  ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-all-and-exit)
X  (define-key gnus-Subject-mode-map "\C-t" 'gnus-Subject-toggle-truncation)
X  (define-key gnus-Subject-mode-map "x" 'gnus-Subject-delete-marked-as-read)
X  (define-key gnus-Subject-mode-map "X" 'gnus-Subject-delete-marked-with)
X  (define-key gnus-Subject-mode-map "\C-c\C-sn" 'gnus-Subject-sort-by-number)
X  (define-key gnus-Subject-mode-map "\C-c\C-sa" 'gnus-Subject-sort-by-author)
X  (define-key gnus-Subject-mode-map "\C-c\C-ss" 'gnus-Subject-sort-by-subject)
X  (define-key gnus-Subject-mode-map "\C-c\C-sd" 'gnus-Subject-sort-by-date)
X  (define-key gnus-Subject-mode-map "\C-c\C-s\C-n" 'gnus-Subject-sort-by-number)
X  (define-key gnus-Subject-mode-map "\C-c\C-s\C-a" 'gnus-Subject-sort-by-author)
X  (define-key gnus-Subject-mode-map "\C-c\C-s\C-s" 'gnus-Subject-sort-by-subject)
X  (define-key gnus-Subject-mode-map "\C-c\C-s\C-d" 'gnus-Subject-sort-by-date)
X  (define-key gnus-Subject-mode-map "=" 'gnus-Subject-expand-window)
X  (define-key gnus-Subject-mode-map "G" 'gnus-Subject-reselect-current-group)
X  (define-key gnus-Subject-mode-map "w" 'gnus-Subject-stop-page-breaking)
X  (define-key gnus-Subject-mode-map "\C-c\C-r" 'gnus-Subject-caesar-message)
X  (define-key gnus-Subject-mode-map "g" 'gnus-Subject-show-article)
X  (define-key gnus-Subject-mode-map "t" 'gnus-Subject-toggle-header)
X  (define-key gnus-Subject-mode-map "v" 'gnus-Subject-show-all-headers)
X  (define-key gnus-Subject-mode-map "\C-d" 'gnus-Subject-rmail-digest)
X  (define-key gnus-Subject-mode-map "a" 'gnus-Subject-post-news)
X  (define-key gnus-Subject-mode-map "f" 'gnus-Subject-post-reply)
X  (define-key gnus-Subject-mode-map "F" 'gnus-Subject-post-reply-with-original)
X  (define-key gnus-Subject-mode-map "C" 'gnus-Subject-cancel-article)
X  (define-key gnus-Subject-mode-map "r" 'gnus-Subject-mail-reply)
X  (define-key gnus-Subject-mode-map "R" 'gnus-Subject-mail-reply-with-original)
X  (define-key gnus-Subject-mode-map "m" 'gnus-Subject-mail-other-window)
X  (define-key gnus-Subject-mode-map "o" 'gnus-Subject-save-article)
X  (define-key gnus-Subject-mode-map "\C-o" 'gnus-Subject-save-in-mail)
X  (define-key gnus-Subject-mode-map "|" 'gnus-Subject-pipe-output)
X  (define-key gnus-Subject-mode-map "\ek" 'gnus-Subject-edit-local-kill)
X  (define-key gnus-Subject-mode-map "\eK" 'gnus-Subject-edit-global-kill)
X  (define-key gnus-Subject-mode-map "V" 'gnus-version)
X  (define-key gnus-Subject-mode-map "q" 'gnus-Subject-exit)
X  (define-key gnus-Subject-mode-map "Q" 'gnus-Subject-quit)
X  (define-key gnus-Subject-mode-map "?" 'gnus-Subject-describe-briefly)
X  (define-key gnus-Subject-mode-map "\C-c\C-i" 'gnus-Info-find-node))
X
X(defun gnus-Subject-mode ()
X  "Major mode for reading articles in this newsgroup.
XAll normal editing commands are turned off.
XInstead, these commands are available:
X
XSPC	Scroll to the next page of the current article.  The next unread
X	article is selected automatically at the end of the message.
XDEL	Scroll to the previous page of the current article.
XRET	Scroll up (or down) one line the current article.
Xn	Move to the next unread article.
Xp	Move to the previous unread article.
XN	Move to the next article.
XP	Move to the previous article.
XESC C-n	Move to the next article which has the same subject as the
X	current article.
XESC C-p	Move to the previous article which has the same subject as the
X	current article.
X\\[gnus-Subject-next-unread-same-subject]
X	Move to the next unread article which has the same subject as the
X	current article.
X\\[gnus-Subject-prev-unread-same-subject]
X	Move to the previous unread article which has the same subject as
X	the current article.
XC-c C-n	Scroll to the next digested message of the current article.
XC-c C-p	Scroll to the previous digested message of the current article.
XC-n	Move to the next subject.
XC-p	Move to the previous subject.
XESC n	Move to the next unread subject.
XESC p	Move to the previous unread subject.
X\\[gnus-Subject-next-group]
X	Exit the current newsgroup and select the next unread newsgroup.
X\\[gnus-Subject-prev-group]
X	Exit the current newsgroup and select the previous unread newsgroup.
X.	Jump to the first unread article in the current newsgroup.
X/	Do an incremental search forward on subjects.
Xs	Do an incremental search forward on the current article.
XESC s	Search for an article containing a regexp forward.
XESC S	Search for an article containing a regexp backward.
X<	Move point to the beginning of the current article.
X>	Move point to the end of the current article.
Xj	Jump to the article specified by the numeric article ID.
XJ	Jump to the article specified by the numeric article ID, then read it.
Xl	Jump to the article you read last.
X^	Refer to parent of the current article.
XESC r	Refer to the article specified by the Message-ID.
Xu	Mark the current article as unread, and go forward.
XU	Mark the current article as unread, and go backward.
Xd	Mark the current article as read, and go forward.
XD	Mark the current article as read, and go backward.
XESC u	Clear the current article's mark, and go forward.
XESC U	Clear the current article's mark, and go backward.
Xk	Mark articles which has the same subject as the current article as
X	read, and then select the next unread article.
XC-k	Mark articles which has the same subject as the current article as
X	read.
XESC k	Edit a local KILL file applied to the current newsgroup.
XESC K	Edit a global KILL file applied to all newsgroups.
XESC C-t	Toggle showing conversation threads.
XESC C-s	Show thread subtrees.
XESC C-h	Hide thread subtrees.
X\\[gnus-Subject-show-all-threads]	Show all thread subtrees.
X\\[gnus-Subject-hide-all-threads]	Hide all thread subtrees.
XESC C-f	Go to the same level next thread.
XESC C-b	Go to the same level previous thread.
XESC C-d	Go downward current thread.
XESC C-u	Go upward current thread.
XESC C-k	Mark articles under current thread as read.
X&	Execute a command for each article conditionally.
X\\[gnus-Subject-catch-up]
X	Mark all articles as read in the current newsgroup, preserving
X	articles marked as unread.
X\\[gnus-Subject-catch-up-all]
X	Mark all articles as read in the current newsgroup.
X\\[gnus-Subject-catch-up-and-exit]
X	Catch up all articles not marked as unread, and then exit the
X	current newsgroup.
X\\[gnus-Subject-catch-up-all-and-exit]
X	Catch up all articles, and then exit the current newsgroup.
XC-t	Toggle truncations of subject lines.
Xx	Delete subject lines marked as read.
XX	Delete subject lines with the specific marks.
XC-c C-s C-n	Sort subjects by article number.
XC-c C-s C-a	Sort subjects by article author.
XC-c C-s C-s	Sort subjects alphabetically.
XC-c C-s C-d	Sort subjects by date.
X=	Expand Subject window to show headers full window.
XG	Reselect the current newsgroup. Prefix argument means to select all.
Xw	Stop page breaking by linefeed.
XC-c C-r	Caesar rotates letters by 13/47 places.
Xg	Force to show the current article.
Xt	Show original article header if pruned header currently shown, or
X	vice versa.
Xv	Show original article header.
XC-d	Run RMAIL on the current digest article.
Xa	Post a new article.
Xf	Post a reply article.
XF	Post a reply article with original article.
XC	Cancel the current article.
Xr	Mail a message to the author.
XR	Mail a message to the author with original author.
Xm	Mail a message in other window.
Xo	Save the current article in your favorite format.
XC-o	Append the current article to a file in Unix mail format.
X|	Pipe the contents of the current article to a subprocess.
Xq	Quit reading news in the current newsgroup.
XQ	Quit reading news without recording unread articles information.
XV	Show the version number of this GNUS.
X?	Describe Subject Mode commands briefly.
XC-h m	Describe Subject Mode.
XC-c C-i	Read Info about Subject Mode.
X
XUser customizable variables:
X gnus-large-newsgroup
X    The number of articles which indicates a large newsgroup. If the
X    number of articles in a newsgroup is greater than the value, the
X    number of articles to be selected is asked for. If the given value
X    N is positive, the last N articles is selected. If N is negative,
X    the first N articles are selected. An empty string means to select
X    all articles.
X
X gnus-use-long-file-name
X    Non-nil means that a newsgroup name is used as a default file name
X    to save articles to. If it's nil, the directory form of a
X    newsgroup is used instead.
X
X gnus-default-article-saver
X    Specifies your favorite article saver which is interactively
X    funcallable. Following functions are available:
X
X	gnus-Subject-save-in-rmail (in Rmail format)
X	gnus-Subject-save-in-mail (in Unix mail format)
X	gnus-Subject-save-in-folder (in MH folder)
X	gnus-Subject-save-in-file (in article format).
X
X gnus-rmail-save-name
X gnus-mail-save-name
X gnus-folder-save-name
X gnus-file-save-name
X    Specifies a function generating a file name to save articles in
X    specified format.  The function is called with NEWSGROUP, HEADERS,
X    and optional LAST-FILE.  Access macros to the headers are defined
X    as nntp-header-FIELD, and functions are defined as
X    gnus-header-FIELD.
X
X gnus-article-save-directory
X    Specifies a directory name to save articles to using the commands
X    gnus-Subject-save-in-rmail, gnus-Subject-save-in-mail and
X    gnus-Subject-save-in-file. The variable is initialized from the
X    SAVEDIR environment variable.
X
X gnus-show-all-headers
X    Non-nil means that all headers of an article are shown.
X
X gnus-save-all-headers
X    Non-nil means that all headers of an article are saved in a file.
X
X gnus-show-threads
X    Non-nil means that conversation threads are shown in tree structure.
X
X gnus-thread-hide-subject
X    Non-nil means that subjects for thread subtrees are hidden.
X
X gnus-thread-hide-subtree
X    Non-nil means that thread subtrees are hidden initially.
X
X gnus-thread-hide-killed
X    Non-nil means that killed thread subtrees are hidden automatically.
X
X gnus-thread-ignore-subject
X    Non-nil means that subject differences are ignored in constructing
X    thread trees.
X
X gnus-thread-indent-level
X    Indentation of thread subtrees.
X
X gnus-optional-headers
X    Specifies a function which generates an optional string displayed
X    in the Subject buffer. The function is called with an article
X    HEADERS.  The result must be a string excluding `[' and `]'.  The
X    default function returns a string like NNN:AUTHOR, where NNN is
X    the number of lines in an article and AUTHOR is the name of the
X    author.
X
X gnus-auto-extend-newsgroup
X    Non-nil means visible articles are extended to forward and
X    backward automatically if possible.
X
X gnus-auto-select-first
X    Non-nil means the first unread article is selected automagically
X    when a newsgroup is selected normally (by gnus-Group-read-group).
X    If you'd like to prevent automatic selection of the first unread
X    article in some newsgroups, set the variable to nil in
X    gnus-Select-group-hook or gnus-Apply-kill-hook.
X
X gnus-auto-select-next
X    Non-nil means the next newsgroup is selected automagically at the
X    end of the newsgroup. If the value is t and the next newsgroup is
X    empty (no unread articles), GNUS will exit Subject mode and go
X    back to Group mode. If the value is neither nil nor t, GNUS won't
X    exit Subject mode but select the following unread newsgroup.
X    Especially, if the value is the symbol `quietly', the next unread
X    newsgroup will be selected without any confirmations.
X
X gnus-auto-select-same
X    Non-nil means an article with the same subject as the current
X    article is selected automagically like `rn -S'.
X
X gnus-auto-center-subject
X    Non-nil means the point of Subject Mode window is always kept
X    centered.
X
X gnus-break-pages
X    Non-nil means an article is broken into pages at page delimiters.
X    This may not work with some versions of GNU Emacs earlier than
X    version 18.50.
X
X gnus-page-delimiter
X    Specifies a regexp describing line-beginnings that separate pages
X    of news article.
X
X [gnus-more-message is obsolete.  overlay-arrow-string interfares
X    with other subsystems, such as dbx mode.]
X
X gnus-digest-show-summary
X    Non-nil means that a summary of digest messages is shown when
X    reading a digest article using `gnus-Subject-rmail-digest'
X    command.
X
X gnus-digest-separator
X    Specifies a regexp separating messages in a digest article.
X
X gnus-mail-reply-method
X gnus-mail-other-window-method
X    Specifies a function to begin composing mail message using
X    commands gnus-Subject-mail-reply and
X    gnus-Subject-mail-other-window.  Functions
X    gnus-mail-reply-using-mail and gnus-mail-reply-using-mhe are
X    available for the value of gnus-mail-reply-method.  And functions
X    gnus-mail-other-window-using-mail and
X    gnus-mail-other-window-using-mhe are available for the value of
X    gnus-mail-other-window-method.
X
XVarious hooks for customization:
X gnus-Subject-mode-hook
X    Entry to this mode calls the value with no arguments, if that
X    value is non-nil.
X
X gnus-Select-group-hook
X    Called with no arguments when newsgroup is selected, if that value
X    is non-nil. It is possible to sort subjects in this hook. See the
X    documentation of this variable for more information.
X
X gnus-Subject-prepare-hook
X    Called with no arguments after a subject list is created in the
X    Subject buffer, if that value is non-nil. If you'd like to modify
X    the buffer, you can use this hook.
X
X gnus-Select-article-hook
X    Called with no arguments when an article is selected, if that
X    value is non-nil. See the documentation of this variable for more
X    information.
X
X gnus-Select-digest-hook
X    Called with no arguments when reading digest messages using Rmail,
X    if that value is non-nil. This hook can be used to modify an
X    article so that Rmail can work with it. See the documentation of
X    the variable for more information.
X
X gnus-Rmail-digest-hook
X    Called with no arguments when reading digest messages using Rmail,
X    if that value is non-nil. This hook is intended to customize Rmail
X    mode.
X
X gnus-Apply-kill-hook
X    Called with no arguments when a newsgroup is selected and the
X    Subject buffer is prepared. This hook is intended to apply a KILL
X    file to the selected newsgroup. The format of KILL file is
X    completely different from that of version 3.8. You have to rewrite
X    them in the new format. See the documentation of Kill file mode
X    for more information.
X
X gnus-Mark-article-hook
X    Called with no arguments when an article is selected at the first
X    time. The hook is intended to mark an article as read (or unread)
X    automatically when it is selected.  See the documentation of the
X    variable for more information.
X
X gnus-Exit-group-hook
X    Called with no arguments when exiting the current newsgroup, if
X    that value is non-nil. If your machine is so slow that exiting
X    from Subject mode takes very long time, inhibit marking articles
X    as read using cross-references by setting the variable
X    gnus-newsgroup-headers to nil in this hook."
X  (interactive)
X  (kill-all-local-variables)
X  ;; Gee.  Why don't you upgrade?
X  (cond ((boundp 'mode-line-modified)
X	 (setq mode-line-modified "--- "))
X	((listp (default-value 'mode-line-format))
X	 (setq mode-line-format
X	       (cons "--- " (cdr (default-value 'mode-line-format))))))
X  (make-local-variable 'global-mode-string)
X  (setq global-mode-string nil)
X  (setq major-mode 'gnus-Subject-mode)
X  (setq mode-name "Subject")
X  ;;(setq mode-line-process '(" " gnus-newsgroup-name))
X  (make-local-variable 'minor-mode-alist)
X  (or (assq 'gnus-show-threads minor-mode-alist)
X      (setq minor-mode-alist
X	    (cons (list 'gnus-show-threads " Thread") minor-mode-alist)))
X  (gnus-Subject-set-mode-line)
X  (use-local-map gnus-Subject-mode-map)
X  (buffer-flush-undo (current-buffer))
X  (setq buffer-read-only t)		;Disable modification
X  (setq truncate-lines t)		;Stop line folding
X  (setq selective-display t)
X  (setq selective-display-ellipses t)	;Display `...'
X  ;;(setq case-fold-search t)
X  (run-hooks 'gnus-Subject-mode-hook))
X
X(defun gnus-Subject-setup-buffer ()
X  "Initialize subject display buffer."
X  (if (get-buffer gnus-Subject-buffer)
X      (set-buffer gnus-Subject-buffer)
X    (set-buffer (get-buffer-create gnus-Subject-buffer))
X    (gnus-Subject-mode)
X    ))
X
X(defun gnus-Subject-read-group (group &optional show-all no-article)
X  "Start reading news in newsgroup GROUP.
XIf optional 1st argument SHOW-ALL is non-nil, already read articles are
Xalso listed.
XIf optional 2nd argument NO-ARTICLE is non-nil, no article is selected
Xinitially."
X  (message "Retrieving newsgroup: %s..." group)
X  (if (gnus-select-newsgroup group show-all)
X      (progn
X	;; Don't switch-to-buffer to prevent displaying old contents
X	;;  of the buffer until new subjects list is created.
X	;; Suggested by Juha Heinanen <jh@tut.fi>
X	(gnus-Subject-setup-buffer)
X	;; You can change the order of subjects in this hook.
X	(run-hooks 'gnus-Select-group-hook)
X	(gnus-Subject-prepare)
X	;; Function `gnus-apply-kill-file' must be called in this hook.
X	(run-hooks 'gnus-Apply-kill-hook)
X	(if (zerop (buffer-size))
X	    ;; This newsgroup is empty.
X	    (progn
X	      (gnus-Subject-catch-up-and-exit nil t) ;Without confirmations.
X	      (message "No unread news"))
X	  ;; Hide conversation thread subtrees.  We cannot do this in
X	  ;; gnus-Subject-prepare-hook since kill processing may not
X	  ;; work with hidden articles.
X	  (and gnus-show-threads
X	       gnus-thread-hide-subtree
X	       (gnus-Subject-hide-all-threads))
X	  ;; Show first unread article if requested.
X	  (goto-char (point-min))
X	  (if (and (not no-article)
X		   gnus-auto-select-first
X		   (gnus-Subject-first-unread-article))
X	      ;; Window is configured automatically.
X	      ;; Current buffer may be changed as a result of hook
X	      ;; evaluation, especially by gnus-Subject-rmail-digest
X	      ;; command, so we should adjust cursor point carefully.
X	      (if (eq (current-buffer) (get-buffer gnus-Subject-buffer))
X		  (progn
X		    ;; Adjust cursor point.
X		    (beginning-of-line)
X		    (search-forward ":" nil t)))
X	    (gnus-configure-windows 'SelectNewsgroup)
X	    (pop-to-buffer gnus-Subject-buffer)
X	    (gnus-Subject-set-mode-line)
X	    ;; I sometime get confused with the old Article buffer.
X	    (if (get-buffer gnus-Article-buffer)
X		(if (get-buffer-window gnus-Article-buffer)
X		    (save-excursion
X		      (set-buffer gnus-Article-buffer)
X		      (let ((buffer-read-only nil))
X			(erase-buffer)))
X		  (kill-buffer gnus-Article-buffer)))
X	    ;; Adjust cursor point.
X	    (beginning-of-line)
X	    (search-forward ":" nil t))
X	  ))
X    ;; Cannot select newsgroup GROUP.
X    (if (gnus-gethash group gnus-active-hashtb)
X	(progn
X	  ;; If NNTP is used, nntp_access file may not be installed
X	  ;; properly.  Otherwise, may be active file problem.
X	  (ding)
X	  (message "Cannot select %s.  May be security or active file problem." group)
X	  (sit-for 0))
X      ;; Check bogus newsgroups.
X      ;; We must be in Group Mode buffer.
X      (gnus-Group-check-bogus-groups))
X    ))
X
X(defun gnus-Subject-prepare ()
X  "Prepare subject list of current newsgroup in Subject mode buffer."
X  (let ((buffer-read-only nil))
X    ;; Note: The next codes are not actually used because the user who
X    ;; want it can define them in gnus-Select-group-hook.
X    ;; Print verbose messages if too many articles are selected.
X    ;;    (and (numberp gnus-large-newsgroup)
X    ;;       (> (length gnus-newsgroup-headers) gnus-large-newsgroup)
X    ;;       (message "Preparing headers..."))
X    (erase-buffer)
X    (gnus-Subject-prepare-threads
X     (if gnus-show-threads
X	 (gnus-make-threads gnus-newsgroup-headers)
X       gnus-newsgroup-headers) 0)
X    ;; Erase header retrieval message.
X    (message "")
X    ;; Call hooks for modifying Subject mode buffer.
X    ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
X    (goto-char (point-min))
X    (run-hooks 'gnus-Subject-prepare-hook)
X    ))
X
X;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>
X
X(defun gnus-Subject-prepare-threads (threads level)
X  "Prepare Subject buffer from THREADS and indentation LEVEL.
XTHREADS is a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...]).'"
X  (let ((thread nil)
X	(header nil)
X	(number nil)
X	;; `M Indent NUM: [OPT] SUBJECT'
X	(cntl (format "%%s %%s%%%dd: [%%s] %%s\n"
X		      (length (prin1-to-string gnus-newsgroup-end)))))
X    (while threads
X      (setq thread (car threads))
X      (setq threads (cdr threads))
X      ;; If thread is a cons, hierarchical threads is given.
X      ;; Otherwise, thread itself is header.
X      (if (consp thread)
X	  (setq header (car thread))
X	(setq header thread))
X      ;; Print valid header only.
X      (if (vectorp header)		;Depends on nntp.el.
X	  (progn
X	    (setq number (nntp-header-number header))
X	    (insert
X	     (format cntl
X		     ;; Read or not.
X		     (cond ((memq number gnus-newsgroup-marked)  "-")
X			   ((memq number gnus-newsgroup-unreads) " ")
X			   (t "D"))
X		     ;; Thread level.
X		     (make-string (* level gnus-thread-indent-level) ? )
X		     ;; Article number.
X		     number
X		     ;; Optional headers.
X		     (or (and gnus-optional-headers
X			      (funcall gnus-optional-headers header)) "")
X		     ;; Its subject string.
X		     (concat (if (or (zerop level)
X				     (not gnus-thread-hide-subject))
X				 nil
X			       (make-string (window-width) ? ))
X			     (nntp-header-subject header))
X		     ))
X	    ))
X      ;; Print subthreads.
X      (and (consp thread)
X	   (cdr thread)
X	   (gnus-Subject-prepare-threads (cdr thread) (1+ level)))
X      )))
X
X(defun gnus-Subject-set-mode-line ()
X  "Set Subject mode line string."
X  ;; The value must be a string to escape %-constructs.
X  (let ((subject
X	 (if gnus-current-headers
X	     (nntp-header-subject gnus-current-headers) gnus-newsgroup-name)))
X    (setq mode-line-buffer-identification
X	  (concat "GNUS: "
X		  subject
X		  ;; Enough spaces to pad subject to 17 positions.
X		  (make-string (max 0 (- 17 (length subject))) ? ))))
X  (set-buffer-modified-p t))
X
X;; GNUS Subject mode command.
X
X(defun gnus-Subject-search-group (&optional backward)
X  "Search for next unread newsgroup.
XIf optional argument BACKWARD is non-nil, search backward instead."
X  (save-excursion
X    (set-buffer gnus-Group-buffer)
X    (save-excursion
X      ;; We don't want to alter current point of Group mode buffer.
X      (if (gnus-Group-search-forward backward nil)
X	  (gnus-Group-group-name))
X      )))
X
X(defun gnus-Subject-search-subject (backward unread subject)
X  "Search for article forward.
XIf 1st argument BACKWARD is non-nil, search backward.
XIf 2nd argument UNREAD is non-nil, only unread article is selected.
XIf 3rd argument SUBJECT is non-nil, the article which has
Xthe same subject will be searched for."
X  (let ((func (if backward 're-search-backward 're-search-forward))
X	(article nil)
X	;; We have to take care of hidden lines.
X	(regexp 
X	 (format "^%s[ \t]+\\([0-9]+\\):.\\[[^]\r\n]*\\][ \t]+%s"
X		 ;;(if unread " " ".")
X		 (cond ((eq unread t) " ") (unread "[ ---]") (t "."))
X		 (if subject
X		     (concat "\\([Rr][Ee]:[ \t]+\\)*"
X			     (regexp-quote (gnus-simplify-subject subject))
X			     ;; Ignore words in parentheses.
X			     "\\([ \t]*([^\r\n]*)\\)*[ \t]*\\(\r\\|$\\)")
X		   "")
X		 )))
X    (if backward
X	(beginning-of-line)
X      (end-of-line))
X    (if (funcall func regexp nil t)
X	(setq article
X	      (string-to-int
X	       (buffer-substring (match-beginning 1) (match-end 1)))))
X    ;; Adjust cursor point.
X    (beginning-of-line)
X    (search-forward ":" nil t)
X    ;; This is the result.
X    article
X    ))
X
X(defun gnus-Subject-search-forward (&optional unread subject)
X  "Search for article forward.
XIf 1st optional argument UNREAD is non-nil, only unread article is selected.
XIf 2nd optional argument SUBJECT is non-nil, the article which has
Xthe same subject will be searched for."
X  (gnus-Subject-search-subject nil unread subject))
X
X(defun gnus-Subject-search-backward (&optional unread subject)
X  "Search for article backward.
XIf 1st optional argument UNREAD is non-nil, only unread article is selected.
XIf 2nd optional argument SUBJECT is non-nil, the article which has
Xthe same subject will be searched for."
X  (gnus-Subject-search-subject t unread subject))
X
X(defun gnus-Subject-article-number ()
X  "Article number around point. If nothing, return current number."
X  (save-excursion
X    (beginning-of-line)
X    (if (looking-at ".[ \t]+\\([0-9]+\\):")
X	(string-to-int
X	 (buffer-substring (match-beginning 1) (match-end 1)))
X      ;; If search fail, return current article number.
X      gnus-current-article
X      )))
X
X(defun gnus-Subject-subject-string ()
X  "Return current subject string or nil if nothing."
X  (save-excursion
X    ;; It is possible to implement this function using
X    ;;  `gnus-Subject-article-number' and `gnus-newsgroup-headers'.
X    (beginning-of-line)
X    ;; We have to take care of hidden lines.
X    (if (looking-at ".[ \t]+[0-9]+:.\\[[^]\r\n]*\\][ \t]+\\([^\r\n]*\\)[\r\n]")
X	(buffer-substring (match-beginning 1) (match-end 1)))
X    ))
X
X(defun gnus-Subject-goto-subject (article)
X  "Move point to ARTICLE's subject."
X  (interactive
X   (list
X    (string-to-int
X     (completing-read "Article number: "
X		      (mapcar
X		       (function
X			(lambda (headers)
X			  (list
X			   (int-to-string (nntp-header-number headers)))))
X		       gnus-newsgroup-headers)
X		      nil 'require-match))))
X  (let ((current (point)))
X    (goto-char (point-min))
X    (or (and article (re-search-forward (format "^.[ \t]+%d:" article) nil t))
X	(progn (goto-char current) nil))
X    ))
X
X(defun gnus-Subject-recenter ()
X  "Center point in Subject mode window."
X  ;; Scroll window so as to cursor comes center of Subject mode window
X  ;;  only when article is displayed.
X  ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
X  ;; Recenter only when requested.
X  ;; Subbested by popovich@park.cs.columbia.edu
X  (and gnus-auto-center-subject
X       (get-buffer-window gnus-Article-buffer)
X       (< (/ (- (window-height) 1) 2)
X	  (count-lines (point) (point-max)))
X       (recenter (/ (- (window-height) 2) 2))))
X
X;; Walking around Group mode buffer.
X
X(defun gnus-Subject-jump-to-group (newsgroup)
X  "Move point to NEWSGROUP in Group mode buffer."
X  ;; Keep update point of Group mode buffer if visible.
X  (if (eq (current-buffer)
X	  (get-buffer gnus-Group-buffer))
X      (save-window-excursion
X	;; Take care of tree window mode.
X	(if (get-buffer-window gnus-Group-buffer)
X	    (pop-to-buffer gnus-Group-buffer))
X	(gnus-Group-jump-to-group newsgroup))
X    (save-excursion
X      ;; Take care of tree window mode.
X      (if (get-buffer-window gnus-Group-buffer)
X	  (pop-to-buffer gnus-Group-buffer)
X	(set-buffer gnus-Group-buffer))
X      (gnus-Group-jump-to-group newsgroup))))
X
X(defun gnus-Subject-next-group (no-article)
X  "Exit current newsgroup and then select next unread newsgroup.
XIf prefix argument NO-ARTICLE is non-nil, no article is selected initially."
X  (interactive "P")
X  ;; Make sure Group mode buffer point is on current newsgroup.
X  (gnus-Subject-jump-to-group gnus-newsgroup-name)
X  (let ((group (gnus-Subject-search-group)))
X    (if (null group)
X	(progn
X	  (message "Exiting %s..." gnus-newsgroup-name)  
X	  (gnus-Subject-exit)
X	  (message ""))
X      (message "Selecting %s..." group)
X      (gnus-Subject-exit t)		;Exit Subject mode temporary.
X      ;; We are now in Group mode buffer.
X      ;; Make sure Group mode buffer point is on GROUP.
X      (gnus-Subject-jump-to-group group)
X      (gnus-Subject-read-group group nil no-article)
X      (or (eq (current-buffer)
X	      (get-buffer gnus-Subject-buffer))
X	  (eq gnus-auto-select-next t)
X	  ;; Expected newsgroup has nothing to read since the articles
X	  ;; are marked as read by cross-referencing. So, try next
X	  ;; newsgroup. (Make sure we are in Group mode buffer now.)
X	  (and (eq (current-buffer)
X		   (get-buffer gnus-Group-buffer))
X	       (gnus-Group-group-name)
X	       (gnus-Subject-read-group
X		(gnus-Group-group-name) nil no-article))
X	  )
X      )))
X
X(defun gnus-Subject-prev-group (no-article)
X  "Exit current newsgroup and then select previous unread newsgroup.
XIf prefix argument NO-ARTICLE is non-nil, no article is selected initially."
X  (interactive "P")
X  ;; Make sure Group mode buffer point is on current newsgroup.
X  (gnus-Subject-jump-to-group gnus-newsgroup-name)
X  (let ((group (gnus-Subject-search-group t)))
X    (if (null group)
X	(progn
X	  (message "Exiting %s..." gnus-newsgroup-name)  
X	  (gnus-Subject-exit)
X	  (message ""))
X      (message "Selecting %s..." group)
X      (gnus-Subject-exit t)		;Exit Subject mode temporary.
X      ;; We are now in Group mode buffer.
X      ;; We have to adjust point of Group mode buffer because current
X      ;; point is moved to next unread newsgroup by exiting.
X      (gnus-Subject-jump-to-group group)
X      (gnus-Subject-read-group group nil no-article)
X      (or (eq (current-buffer)
X	      (get-buffer gnus-Subject-buffer))
X	  (eq gnus-auto-select-next t)
X	  ;; Expected newsgroup has nothing to read since the articles
X	  ;; are marked as read by cross-referencing. So, try next
X	  ;; newsgroup. (Make sure we are in Group mode buffer now.)
X	  (and (eq (current-buffer)
X		   (get-buffer gnus-Group-buffer))
X	       (gnus-Subject-search-group t)
X	       (gnus-Subject-read-group
X		(gnus-Subject-search-group t) nil no-article))
X	  )
X      )))
X
X;; Walking around subject lines.
X
X(defun gnus-Subject-next-subject (n &optional unread)
X  "Go to next N'th subject line.
XIf optional argument UNREAD is non-nil, only unread article is selected."
X  (interactive "p")
X  (while (and (> n 1)
X	      (gnus-Subject-search-forward unread))
X    (setq n (1- n)))
X  (cond ((gnus-Subject-search-forward unread)
X	 (gnus-Subject-recenter))
X	(unread
X	 (message "No more unread articles"))
X	(t
X	 (message "No more articles"))
X	))
X
X(defun gnus-Subject-next-unread-subject (n)
X  "Go to next N'th unread subject line."
X  (interactive "p")
X  (gnus-Subject-next-subject n t))
X
X(defun gnus-Subject-prev-subject (n &optional unread)
X  "Go to previous N'th subject line.
XIf optional argument UNREAD is non-nil, only unread article is selected."
X  (interactive "p")
X  (while (and (> n 1)
X	      (gnus-Subject-search-backward unread))
X    (setq n (1- n)))
X  (cond ((gnus-Subject-search-backward unread)
X	 (gnus-Subject-recenter))
X	(unread
X	 (message "No more unread articles"))
X	(t
X	 (message "No more articles"))
X	))
X
X(defun gnus-Subject-prev-unread-subject (n)
X  "Go to previous N'th unread subject line."
X  (interactive "p")
X  (gnus-Subject-prev-subject n t))
X
X;; Walking around subject lines with displaying articles.
X
X(defun gnus-Subject-expand-window ()
X  "Expand Subject window to show headers full window."
X  (interactive)
X  (gnus-configure-windows 'ExpandSubject)
X  (pop-to-buffer gnus-Subject-buffer))
X
X(defun gnus-Subject-display-article (article &optional all-header)
X  "Display ARTICLE in Article buffer."
X  (if (null article)
X      nil
X    (gnus-configure-windows 'SelectArticle)
X    (pop-to-buffer gnus-Subject-buffer)
X    (gnus-Article-prepare article all-header)
X    (gnus-Subject-recenter)
X    (gnus-Subject-set-mode-line)
X    (run-hooks 'gnus-Select-article-hook)
X    ;; Successfully display article.
X    t
X    ))
X
X(defun gnus-Subject-select-article (&optional all-headers force)
X  "Select the current article.
XOptional argument ALL-HEADERS is non-nil, show all headers."
X  (let ((article (gnus-Subject-article-number)))
X    (if (or (null gnus-current-article)
X	    (/= article gnus-current-article)
X	    (and force (not (eq all-headers gnus-have-all-headers))))
X	;; The selected subject is different from that of the current article.
X	(gnus-Subject-display-article article all-headers)
X      (gnus-configure-windows 'SelectArticle)
X      (pop-to-buffer gnus-Subject-buffer))
X    ))
X
X(defun gnus-Subject-set-current-mark (&optional current-mark)
X  "Put `+' at the current article.
XOptional argument specifies CURRENT-MARK instead of `+'."
X  (save-excursion
X    (set-buffer gnus-Subject-buffer)
X    (let ((buffer-read-only nil))
X      (goto-char (point-min))
X      ;; First of all clear mark at last article.
X      (if (re-search-forward "^.[ \t]+[0-9]+:[^ \t]" nil t)
X	  (progn
X	    (delete-char -1)
X	    (insert " ")
X	    (goto-char (point-min))))
X      (if (re-search-forward (format "^.[ \t]+%d:" gnus-current-article) nil t)
X	  (progn
X	    (delete-char 1)
X	    (insert (or current-mark "+"))))
X      )))
X
X;;(defun gnus-Subject-next-article (unread &optional subject)
X;;  "Select article after current one.
X;;If argument UNREAD is non-nil, only unread article is selected."
X;;  (interactive "P")
X;;  (cond ((gnus-Subject-display-article
X;;	  (gnus-Subject-search-forward unread subject)))
X;;	(unread
X;;	 (message "No more unread articles"))
X;;	(t
X;;	 (message "No more articles"))
X;;	))
X
X(defun gnus-Subject-next-article (unread &optional subject)
X  "Select article after current one.
XIf argument UNREAD is non-nil, only unread article is selected."
X  (interactive "P")
X  (let ((header nil))
X    (cond ((gnus-Subject-display-article
X	    (gnus-Subject-search-forward unread subject)))
X	  ((and subject
X		gnus-auto-select-same
X		(gnus-set-difference gnus-newsgroup-unreads
X				     gnus-newsgroup-marked)
X		(memq this-command
X		      '(gnus-Subject-next-unread-article
X			gnus-Subject-next-page
X			gnus-Subject-kill-same-subject-and-select
X			;;gnus-Subject-next-article
X			;;gnus-Subject-next-same-subject
X			;;gnus-Subject-next-unread-same-subject
X			)))
X	   ;; Wrap article pointer if there are unread articles.
X	   ;; Hook function, such as gnus-Subject-rmail-digest, may
X	   ;; change current buffer, so need check.
X	   (let ((buffer (current-buffer))
X		 (last-point (point)))
X	     ;; No more articles with same subject, so jump to the first
X	     ;; unread article.
X	     (gnus-Subject-first-unread-article)
X	     ;;(and (eq buffer (current-buffer))
X	     ;;	(= (point) last-point)
X	     ;;	;; Ignore given SUBJECT, and try again.
X	     ;;	(gnus-Subject-next-article unread nil))
X	     (and (eq buffer (current-buffer))
X		  (< (point) last-point)
X		  (message "Wrapped"))
X	     ))
X	  ((and (not unread)
X		gnus-auto-extend-newsgroup
X		(setq header (gnus-more-header-forward)))
X	   ;; Extend to next article if possible.
X	   ;; Basic ideas by himacdonald@watdragon.waterloo.edu
X	   (gnus-extend-newsgroup header nil)
X	   ;; Threads feature must be turned off.
X	   (let ((buffer-read-only nil))
X	     (goto-char (point-max))
X	     (gnus-Subject-prepare-threads (list header) 0))
X	   (gnus-Subject-goto-article gnus-newsgroup-end))
X	  (t
X	   ;; Select next newsgroup automatically if requested.
X	   (let ((cmd (string-to-char (this-command-keys)))
X		 (group (gnus-Subject-search-group))
X		 (auto-select
X		  (and gnus-auto-select-next
X		       ;;(null (gnus-set-difference gnus-newsgroup-unreads
X		       ;;				gnus-newsgroup-marked))
X		       (memq this-command
X			     '(gnus-Subject-next-unread-article
X			       gnus-Subject-next-article
X			       gnus-Subject-next-page
X			       gnus-Subject-next-same-subject
X			       gnus-Subject-next-unread-same-subject
X			       gnus-Subject-kill-same-subject
X			       gnus-Subject-kill-same-subject-and-select
X			       ))
X		       ;; Ignore characters typed ahead.
X		       (not (input-pending-p))
X		       )))
X	     (message "No more%s articles%s"
X		      (if unread " unread" "")
X		      (if (and auto-select
X			       (not (eq gnus-auto-select-next 'quietly)))
X			  (if group
X			      (format " (Type %s to %s [%d])"
X				      (key-description (char-to-string cmd))
X				      group
X				      (nth 1 (gnus-gethash group
X							   gnus-unread-hashtb)))
X			    (format " (Type %s to exit %s)"
X				    (key-description (char-to-string cmd))
X				    gnus-newsgroup-name
X				    ))
X			""))
X	     ;; Select next unread newsgroup automagically.
X	     (cond ((and auto-select
X			 (eq gnus-auto-select-next 'quietly))
X		    ;; Select quietly.
X		    (gnus-Subject-next-group nil))
X		   (auto-select
X		    ;; Confirm auto selection.
X		    (let ((char (read-char)))
X		      (if (= char cmd)
X			  (gnus-Subject-next-group nil)
X			(setq unread-command-char char))))
X		   )
X	     ))
X	  )))
X
X(defun gnus-Subject-next-unread-article ()
X  "Select unread article after current one."
X  (interactive)
X  (gnus-Subject-next-article t (and gnus-auto-select-same
X				    (gnus-Subject-subject-string))))
X
X(defun gnus-Subject-prev-article (unread &optional subject)
X  "Select article before current one.
XIf argument UNREAD is non-nil, only unread article is selected."
X  (interactive "P")
X  (let ((header nil))
X    (cond ((gnus-Subject-display-article
X	    (gnus-Subject-search-backward unread subject)))
X	  ((and subject
X		gnus-auto-select-same
X		(gnus-set-difference gnus-newsgroup-unreads
X				     gnus-newsgroup-marked)
X		(memq this-command
X		      '(gnus-Subject-prev-unread-article
X			;;gnus-Subject-prev-page
X			;;gnus-Subject-prev-article
X			;;gnus-Subject-prev-same-subject
X			;;gnus-Subject-prev-unread-same-subject
X			)))
X	   ;; Ignore given SUBJECT, and try again.
X	   (gnus-Subject-prev-article unread nil))
X	  (unread
X	   (message "No more unread articles"))
X	  ((and gnus-auto-extend-newsgroup
X		(setq header (gnus-more-header-backward)))
X	   ;; Extend to previous article if possible.
X	   ;; Basic ideas by himacdonald@watdragon.waterloo.edu
X	   (gnus-extend-newsgroup header t)
X	   (let ((buffer-read-only nil))
X	     (goto-char (point-min))
X	     (gnus-Subject-prepare-threads (list header) 0))
X	   (gnus-Subject-goto-article gnus-newsgroup-begin))
X	  (t
X	   (message "No more articles"))
X	  )))
X
X(defun gnus-Subject-prev-unread-article ()
X  "Select unred article before current one."
X  (interactive)
X  (gnus-Subject-prev-article t (and gnus-auto-select-same
X				    (gnus-Subject-subject-string))))
X
X(defun gnus-Subject-next-page (lines)
X  "Show next page of selected article.
XIf end of artile, select next article.
XArgument LINES specifies lines to be scrolled up."
X  (interactive "P")
X  (let ((article (gnus-Subject-article-number))
X	(endp nil))
X    (if (or (null gnus-current-article)
X	    (/= article gnus-current-article))
X	;; Selected subject is different from current article's.
X	(gnus-Subject-display-article article)
X      (gnus-configure-windows 'SelectArticle)
X      (pop-to-buffer gnus-Subject-buffer)
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	(setq endp (gnus-Article-next-page lines)))
X      (cond ((and endp lines)
X	     (message "End of message"))
X	    ((and endp (null lines))
X	     (gnus-Subject-next-unread-article)))
X      )))
X
X(defun gnus-Subject-prev-page (lines)
X  "Show previous page of selected article.
XArgument LINES specifies lines to be scrolled down."
X  (interactive "P")
X  (let ((article (gnus-Subject-article-number)))
X    (if (or (null gnus-current-article)
X	    (/= article gnus-current-article))
X	;; Selected subject is different from current article's.
X	(gnus-Subject-display-article article)
X      (gnus-configure-windows 'SelectArticle)
X      (pop-to-buffer gnus-Subject-buffer)
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	(gnus-Article-prev-page lines))
X      )))
X
X(defun gnus-Subject-scroll-up (lines)
X  "Scroll up (or down) one line current article.
XArgument LINES specifies lines to be scrolled up (or down if negative)."
X  (interactive "p")
X  (gnus-Subject-select-article)
X  (gnus-eval-in-buffer-window gnus-Article-buffer
X    (cond ((> lines 0)
X	   (if (gnus-Article-next-page lines)
X	       (message "End of message")))
X	  ((< lines 0)
X	   (gnus-Article-prev-page (- 0 lines))))
X    ))
X
X(defun gnus-Subject-next-same-subject ()
X  "Select next article which has the same subject as current one."
X  (interactive)
X  (gnus-Subject-next-article nil (gnus-Subject-subject-string)))
X
X(defun gnus-Subject-prev-same-subject ()
X  "Select previous article which has the same subject as current one."
X  (interactive)
X  (gnus-Subject-prev-article nil (gnus-Subject-subject-string)))
X
X(defun gnus-Subject-next-unread-same-subject ()
X  "Select next unread article which has the same subject as current one."
X  (interactive)
X  (gnus-Subject-next-article t (gnus-Subject-subject-string)))
X
X(defun gnus-Subject-prev-unread-same-subject ()
X  "Select previous unread article which has the same subject as current one."
X  (interactive)
X  (gnus-Subject-prev-article t (gnus-Subject-subject-string)))
X
X(defun gnus-Subject-refer-parent-article (child)
X  "Refer parent article of current article.
XIf a prefix argument CHILD is non-nil, go back to the child article
Xusing internally maintained articles history.
XNOTE: This command may not work with nnspool.el."
X  (interactive "P")
X  (gnus-Subject-select-article t t)	;Request all headers.
X  (let ((referenced-id nil))		;Message-id of parent or child article.
X    (if child
X	;; Go back to child article using history.
X	(gnus-Subject-refer-article nil)
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	;; Look for parent Message-ID.
X	;; We cannot use gnus-current-headers to get references
X	;; because we may be looking at parent or refered article.
X	(let ((references (gnus-fetch-field "References")))
X	  ;; Get the last message-id in the references.
X	  (and references
X	       (string-match "\\(<[^<>]+>\\)[^>]*\\'" references)
X	       (setq referenced-id
X		     (substring references
X				(match-beginning 1) (match-end 1))))
X	  ))
X      (if (stringp referenced-id)
X	  (gnus-Subject-refer-article referenced-id)
X	(error "No more parents"))
X      )))
X
X(defun gnus-Subject-refer-article (message-id)
X  "Refer article specified by MESSAGE-ID.
XIf the MESSAGE-ID is nil or an empty string, Message-ID is poped from
Xinternally maintained articles history.
XNOTE: This command may not work with nnspool.el."
X  (interactive "sMessage-ID: ")
X  ;; Make sure that this command depends on the fact that article
X  ;; related information is not updated when an article is retrieved
X  ;; by Message-ID.
X  (gnus-Subject-select-article t t)	;Request all headers.
X  (if (and (stringp message-id)
X	   (> (length message-id) 0))
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	;; Construct the correct Message-ID if necessary.
X	;; Suggested by tale@pawl.rpi.edu.
X	(or (string-match "^<" message-id)
X	    (setq message-id (concat "<" message-id)))
X	(or (string-match ">$" message-id)
X	    (setq message-id (concat message-id ">")))
X	;; Push current message-id on history.
X	;; We cannot use gnus-current-headers to get current
X	;; message-id because we may be looking at parent or refered
X	;; article.
X	(let ((current (gnus-fetch-field "Message-ID")))
X	  (or (equal current message-id) ;Nothing to do.
X	      (equal current (car gnus-current-history))
X	      (setq gnus-current-history
X		    (cons current gnus-current-history)))
X	  ))
X    ;; Pop message-id from history.
X    (setq message-id (car gnus-current-history))
X    (setq gnus-current-history (cdr gnus-current-history)))
X  (if (stringp message-id)
X      ;; Retrieve article by message-id. This may not work with nnspool.
X      (gnus-Article-prepare message-id t)
X    (error "No such references"))
X  )
X
X(defun gnus-Subject-next-digest (nth)
X  "Move to head of NTH next digested message."
X  (interactive "p")
X  (gnus-Subject-select-article)
X  (gnus-eval-in-buffer-window gnus-Article-buffer
X    (gnus-Article-next-digest (or nth 1))
X    ))
X
X(defun gnus-Subject-prev-digest (nth)
X  "Move to head of NTH previous digested message."
X  (interactive "p")
X  (gnus-Subject-select-article)
X  (gnus-eval-in-buffer-window gnus-Article-buffer
X    (gnus-Article-prev-digest (or nth 1))
X    ))
X
X(defun gnus-Subject-first-unread-article ()
X  "Select first unread article. Return non-nil if successfully selected."
X  (interactive)
X  (let ((begin (point)))
X    (goto-char (point-min))
X    (if (re-search-forward "^ [ \t]+[0-9]+:" nil t)
X	(gnus-Subject-display-article (gnus-Subject-article-number))
X      ;; If there is no unread articles, stay there.
X      (goto-char begin)
X      ;;(gnus-Subject-display-article (gnus-Subject-article-number))
X      (message "No more unread articles")
X      nil
X      )
X    ))
X
X(defun gnus-Subject-isearch-article ()
X  "Do incremental search forward on current article."
X  (interactive)
X  (gnus-Subject-select-article)
X  (gnus-eval-in-buffer-window gnus-Article-buffer
X    (call-interactively 'isearch-forward)
X    ))
X
X(defun gnus-Subject-search-article-forward (regexp)
X  "Search for an article containing REGEXP forward.
Xgnus-Select-article-hook is not called during the search."
X  (interactive
X   (list (read-string
X	  (concat "Search forward (regexp): "
X		  (if gnus-last-search-regexp
X		      (concat "(default " gnus-last-search-regexp ") "))))))
X  (if (string-equal regexp "")
X      (setq regexp (or gnus-last-search-regexp ""))
X    (setq gnus-last-search-regexp regexp))
X  (if (gnus-Subject-search-article regexp nil)
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	(recenter 0)
X	;;(sit-for 1)
X	)
X    (error "Search failed: \"%s\"" regexp)
X    ))
X
X(defun gnus-Subject-search-article-backward (regexp)
X  "Search for an article containing REGEXP backward.
Xgnus-Select-article-hook is not called during the search."
X  (interactive
X   (list (read-string
X	  (concat "Search backward (regexp): "
X		  (if gnus-last-search-regexp
X		      (concat "(default " gnus-last-search-regexp ") "))))))
X  (if (string-equal regexp "")
X      (setq regexp (or gnus-last-search-regexp ""))
X    (setq gnus-last-search-regexp regexp))
X  (if (gnus-Subject-search-article regexp t)
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	(recenter 0)
X	;;(sit-for 1)
X	)
X    (error "Search failed: \"%s\"" regexp)
X    ))
X
X(defun gnus-Subject-search-article (regexp &optional backward)
X  "Search for an article containing REGEXP.
XOptional argument BACKWARD means do search for backward.
Xgnus-Select-article-hook is not called during the search."
X  (let ((gnus-Select-article-hook nil)	;Disable hook.
X	(gnus-Mark-article-hook nil)	;Inhibit marking as read.
X	(re-search
X	 (if backward
X	     (function re-search-backward) (function re-search-forward)))
X	(found nil)
X	(last nil))
X    ;; Hidden thread subtrees must be searched for ,too.
X    (gnus-Subject-show-all-threads)
X    ;; First of all, search current article.
X    ;; We don't want to read article again from NNTP server nor reset
X    ;; current point.
X    (gnus-Subject-select-article)
X    (message "Searching article: %d..." gnus-current-article)
X    (setq last gnus-current-article)
X    (gnus-eval-in-buffer-window gnus-Article-buffer
X      (save-restriction
X	(widen)
X	;; Begin search from current point.
X	(setq found (funcall re-search regexp nil t))))
X    ;; Then search next articles.
X    (while (and (not found)
X		(gnus-Subject-display-article 
X		 (gnus-Subject-search-subject backward nil nil)))
X      (message "Searching article: %d..." gnus-current-article)
X      (gnus-eval-in-buffer-window gnus-Article-buffer
X	(save-restriction
X	  (widen)
X	  (goto-char (if backward (point-max) (point-min)))
X	  (setq found (funcall re-search regexp nil t)))
X	))
X    (message "")
X    ;; Adjust article pointer.
X    (or (eq last gnus-current-article)
X	(setq gnus-last-article last))
X    ;; Return T if found such article.
X    found
X    ))
X
X(defun gnus-Subject-execute-command (field regexp command &optional backward)
X  "If FIELD of article header matches REGEXP, execute COMMAND string.
XIf FIELD is an empty string (or nil), entire article body is searched for.
XIf optional (prefix) argument BACKWARD is non-nil, do backward instead."
X  (interactive
X   (list (let ((completion-ignore-case t))
X	   (completing-read "Field name: "
X			    '(("Number")("Subject")("From")
X			      ("Lines")("Date")("Id")
X			      ("Xref")("References"))
X			    nil 'require-match))
X	 (read-string "Regexp: ")
X	 (read-key-sequence "Command: ")
X	 current-prefix-arg))
SHAR_EOF
echo "End of part 3, continue with part 4"
echo "4" > s2_seq_.tmp
exit 0
--
Masanobu UMEDA
umerin@tc.Nagasaki.GO.JP
