#!/bin/sh
# this is part 6 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file gnus.el continued
#
CurArch=6
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	       (not (string-match gnus-newsrc-options-n-no group))
X	       (and gnus-newsrc-options-n-yes
X		    (string-match gnus-newsrc-options-n-yes group)))
X	   (null (assoc group gnus-newsrc-assoc)) ;No duplication.
X	   ;; Subscribed in options line and not in gnus-newsrc-assoc.
X	   (setq new-killed
X		 (cons (car old-killed) new-killed)))
X      (setq old-killed (cdr old-killed))
X      )
X    (setq gnus-killed-assoc (nreverse new-killed))
X    ))
X
X(defun gnus-check-bogus-newsgroups (&optional confirm)
X  "Delete bogus newsgroups.
XIf optional argument CONFIRM is non-nil, confirm deletion of newsgroups."
X  (let ((group nil)			;Newsgroup name temporary used.
X	(old-newsrc gnus-newsrc-assoc)
X	(new-newsrc nil)
X	(bogus nil)			;List of bogus newsgroups.
X	(old-killed gnus-killed-assoc)
X	(new-killed nil)
X	(old-marked gnus-marked-assoc)
X	(new-marked nil))
X    (message "Checking bogus newsgroups...")
X    ;; Update gnus-newsrc-assoc.
X    (while old-newsrc
X      (setq group (car (car old-newsrc)))
X      (if (or (gnus-gethash group gnus-active-hashtb)
X	      (and confirm
X		   (not (y-or-n-p
X			 (format "Delete bogus newsgroup: %s " group)))))
X	  ;; Active newsgroup.
X	  (setq new-newsrc (cons (car old-newsrc) new-newsrc))
X	;; Found a bogus newsgroup.
X	(setq bogus (cons group bogus)))
X      (setq old-newsrc (cdr old-newsrc))
X      )
X    (setq gnus-newsrc-assoc (nreverse new-newsrc))
X    ;; Update gnus-killed-assoc.
X    ;; The killed newsgroups are deleted without any confirmations.
X    (while old-killed
X      (setq group (car (car old-killed)))
X      (and (gnus-gethash group gnus-active-hashtb)
X	   (null (assoc group gnus-newsrc-assoc))
X	   ;; Active and really killed newsgroup.
X	   (setq new-killed (cons (car old-killed) new-killed)))
X      (setq old-killed (cdr old-killed))
X      )
X    (setq gnus-killed-assoc (nreverse new-killed))
X    ;; Remove BOGUS from .newsrc file.
X    (while bogus
X      (gnus-update-newsrc-buffer (car bogus) 'delete)
X      (setq bogus (cdr bogus)))
X    ;; Update gnus-marked-assoc.
X    (while old-marked
X      (setq group (car (car old-marked)))
X      (if (and (cdr (car old-marked))	;Non-empty?
X	       (assoc group gnus-newsrc-assoc))	;Not bogus?
X	  (setq new-marked (cons (car old-marked) new-marked)))
X      (setq old-marked (cdr old-marked)))
X    (setq gnus-marked-assoc new-marked)
X    (message "Checking bogus newsgroups... done")
X    ))
X
X(defun gnus-get-unread-articles ()
X  "Compute diffs between active and read articles."
X  (let ((read gnus-newsrc-assoc)
X	(group-info nil)
X	(group-name nil)
X	(active nil)
X	(range nil))
X    (message "Checking new news...")
X    (or gnus-unread-hashtb
X	(setq gnus-unread-hashtb (gnus-make-hashtable)))
X    (while read
X      (setq group-info (car read))	;About one newsgroup
X      (setq group-name (car group-info))
X      (setq active (nth 2 (gnus-gethash group-name gnus-active-hashtb)))
X      (if (and gnus-octive-hashtb
X	       ;; Is nothing changed?
X	       (equal active
X		      (nth 2 (gnus-gethash group-name gnus-octive-hashtb)))
X	       ;; Is this newsgroup in the unread hash table?
X	       (gnus-gethash group-name gnus-unread-hashtb)
X	       )
X	  nil				;Nothing to do.
X	(setq range (gnus-difference-of-range active (nthcdr 2 group-info)))
X	(gnus-sethash group-name
X		      (cons group-name	;Group name
X			    (cons (gnus-number-of-articles range)
X				  range)) ;Range of unread articles
X		      gnus-unread-hashtb)
X	)
X      (setq read (cdr read))
X      )
X    (message "Checking new news... done")
X    ))
X
X(defun gnus-expire-marked-articles ()
X  "Check expired article which is marked as unread."
X  (let ((marked-assoc gnus-marked-assoc)
X	(updated-assoc nil)
X	(marked nil)			;Current marked info.
X	(articles nil)			;List of marked articles.
X	(updated nil)			;List of real marked.
X	(begin nil))
X    (while marked-assoc
X      (setq marked (car marked-assoc))
X      (setq articles (cdr marked))
X      (setq updated nil)
X      (setq begin
X	    (car (nth 2 (gnus-gethash (car marked) gnus-active-hashtb))))
X      (while (and begin articles)
X	(if (>= (car articles) begin)
X	    ;; This article is still active.
X	    (setq updated (cons (car articles) updated)))
X	(setq articles (cdr articles)))
X      (if updated
X	  (setq updated-assoc
X		(cons (cons (car marked) updated) updated-assoc)))
X      (setq marked-assoc (cdr marked-assoc)))
X    (setq gnus-marked-assoc updated-assoc)
X    ))
X
X(defun gnus-mark-as-read-by-xref
X  (group headers unreads &optional subscribed-only)
X  "Mark articles as read using cross references and return updated newsgroups.
XArguments are GROUP, HEADERS, UNREADS, and optional SUBSCRIBED-ONLY."
X  (let ((xref-list nil)
X	(header nil)
X	(xrefs nil)			;One Xref: field info.
X	(xref nil)			;(NEWSGROUP . ARTICLE)
X	(gname nil)			;Newsgroup name
X	(article nil))			;Article number
X    (while headers
X      (setq header (car headers))
X      (if (memq (nntp-header-number header) unreads)
X	  ;; This article is not yet marked as read.
X	  nil
X	(setq xrefs (gnus-parse-xref-field (nntp-header-xref header)))
X	;; For each cross reference info. in one Xref: field.
X	(while xrefs
X	  (setq xref (car xrefs))
X	  (setq gname (car xref))	;Newsgroup name
X	  (setq article (cdr xref))	;Article number
X	  (or (string-equal group gname) ;Ignore current newsgroup.
X	      ;; Ignore unsubscribed newsgroup if requested.
X	      (and subscribed-only
X		   (not (nth 1 (assoc gname gnus-newsrc-assoc))))
X	      ;; Ignore article marked as unread.
X	      (memq article (cdr (assoc gname gnus-marked-assoc)))
X	      (let ((group-xref (assoc gname xref-list)))
X		(if group-xref
X		    (if (memq article (cdr group-xref))
X			nil		;Alread marked.
X		      (setcdr group-xref (cons article (cdr group-xref))))
X		  ;; Create new assoc entry for GROUP.
X		  (setq xref-list (cons (list gname article) xref-list)))
X		))
X	  (setq xrefs (cdr xrefs))
X	  ))
X      (setq headers (cdr headers)))
X    ;; Mark cross referenced articles as read.
X    (gnus-mark-xrefed-as-read xref-list)
X    ;;(message "%s %s" (prin1-to-string unreads) (prin1-to-string xref-list))
X    ;; Return list of updated group name.
X    (mapcar (function car) xref-list)
X    ))
X
X(defun gnus-parse-xref-field (xref-value)
X  "Parse Xref: field value, and return list of `(group . article-id)'."
X  (let ((xref-list nil)
X	(xref-value (or xref-value "")))
X    ;; Remove server host name.
X    (if (string-match "^[ \t]*[^ \t,]+[ \t,]+\\(.*\\)$" xref-value)
X	(setq xref-value (substring xref-value (match-beginning 1)))
X      (setq xref-value nil))
X    ;; Process each xref info.
X    (while xref-value
X      (if (string-match
X	   "^[ \t,]*\\([^ \t,]+\\):\\([0-9]+\\)[^0-9]*" xref-value)
X	  (progn
X	    (setq xref-list
X		  (cons
X		   (cons
X		    ;; Group name
X		    (substring xref-value (match-beginning 1) (match-end 1))
X		    ;; Article-ID
X		    (string-to-int
X		     (substring xref-value (match-beginning 2) (match-end 2))))
X		   xref-list))
X	    (setq xref-value (substring xref-value (match-end 2))))
X	(setq xref-value nil)))
X    ;; Return alist.
X    xref-list
X    ))
X
X(defun gnus-mark-xrefed-as-read (xrefs)
X  "Update unread article information using XREFS alist."
X  (let ((group nil)
X	(idlist nil)
X	(unread nil))
X    (while xrefs
X      (setq group (car (car xrefs)))
X      (setq idlist (cdr (car xrefs)))
X      (setq unread (gnus-uncompress-sequence
X		    (nthcdr 2 (gnus-gethash group gnus-unread-hashtb))))
X      (while idlist
X	(setq unread (delq (car idlist) unread))
X	(setq idlist (cdr idlist)))
X      (gnus-update-unread-articles group unread 'ignore)
X      (setq xrefs (cdr xrefs))
X      )))
X
X(defun gnus-update-unread-articles (group unread-list marked-list)
X  "Update unread articles of GROUP using UNREAD-LIST and MARKED-LIST."
X  (let ((active (nth 2 (gnus-gethash group gnus-active-hashtb)))
X	(unread (gnus-gethash group gnus-unread-hashtb)))
X    (if (or (null active) (null unread))
X	;; Ignore unknown newsgroup.
X	nil
X      ;; Update gnus-unread-hashtb.
X      (if unread-list
X	  (setcdr (cdr unread)
X		  (gnus-compress-sequence unread-list))
X	;; All of the articles are read.
X	(setcdr (cdr unread) '((0 . 0))))
X      ;; Number of unread articles.
X      (setcar (cdr unread)
X	      (gnus-number-of-articles (nthcdr 2 unread)))
X      ;; Update gnus-newsrc-assoc.
X      (if (> (car active) 0)
X	  ;; Articles from 1 to N are not active.
X	  (setq active (cons 1 (cdr active))))
X      (setcdr (cdr (assoc group gnus-newsrc-assoc))
X	      (gnus-difference-of-range active (nthcdr 2 unread)))
X      ;; Update .newsrc buffer.
X      (gnus-update-newsrc-buffer group)
X      ;; Update gnus-marked-assoc.
X      (if (listp marked-list)		;Includes NIL.
X	  (let ((marked (assoc group gnus-marked-assoc)))
X	    (cond (marked
X		   (setcdr marked marked-list))
X		  (marked-list		;Non-NIL.
X		   (setq gnus-marked-assoc
X			 (cons (cons group marked-list)
X			       gnus-marked-assoc)))
X		  )))
X      )))
X
X(defun gnus-read-active-file ()
X  "Get active file from NNTP server."
X  (message "Reading active file...")
X  (if (gnus-request-list)		;Get active file from server
X      (save-excursion
X	(set-buffer nntp-server-buffer)
X	;; Save OLD active info.
X	(setq gnus-octive-hashtb gnus-active-hashtb)
X	(setq gnus-active-hashtb (gnus-make-hashtable))
X	(gnus-active-to-gnus-format)
X	(message "Reading active file... done"))
X    (error "Cannot read active file from NNTP server.")))
X
X(defun gnus-active-to-gnus-format ()
X  "Convert active file format to internal format."
X  ;; Delete unnecessary lines.
X  (goto-char (point-min))
X  (delete-matching-lines "^to\\..*$")
X  ;; Store active file in hashtable.
X  (goto-char (point-min))
X  (while
X      (re-search-forward
X       "^\\([^ \t]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([ymn]\\).*$"
X       nil t)
X    (gnus-sethash
X     (buffer-substring (match-beginning 1) (match-end 1))
X     (list (buffer-substring (match-beginning 1) (match-end 1))
X	   (string-equal
X	    "y" (buffer-substring (match-beginning 4) (match-end 4)))
X	   (cons (string-to-int
X		  (buffer-substring (match-beginning 3) (match-end 3)))
X		 (string-to-int
X		  (buffer-substring (match-beginning 2) (match-end 2)))))
X     gnus-active-hashtb)
X    ))
X
X(defun gnus-read-newsrc-file (&optional rawfile)
X  "Read startup FILE.
XIf optional argument RAWFILE is non-nil, the raw startup file is read."
X  (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
X  ;; Reset variables which may be included in the quick startup file.
X  (let ((variables gnus-variable-list))
X    (while variables
X      (set (car variables) nil)
X      (setq variables (cdr variables))))
X  (let* ((newsrc-file gnus-current-startup-file)
X	 (quick-file (concat newsrc-file ".el"))
X	 (quick-loaded nil)
X	 (newsrc-mod (nth 5 (file-attributes newsrc-file)))
X	 (quick-mod (nth 5 (file-attributes quick-file))))
X    (save-excursion
X      ;; Prepare .newsrc buffer.
X      (set-buffer (find-file-noselect newsrc-file))
X      ;; It is not so good idea turning off undo.
X      ;;(buffer-flush-undo (current-buffer))
X      ;; Load quick .newsrc to restore gnus-marked-assoc and
X      ;; gnus-killed-assoc even if gnus-newsrc-assoc is out of date.
X      (condition-case nil
X	  (setq quick-loaded (load quick-file t t t))
X	(error nil))
X      (cond ((and (not rawfile)		;Not forced to read the raw file.
X		  (or (and (fboundp 'file-newer-than-file-p)
X			   (file-newer-than-file-p quick-file newsrc-file))
X		      (and newsrc-mod quick-mod
X			   ;; .newsrc.el is newer than .newsrc.
X			   ;; Some older version does not support function
X			   ;; `file-newer-than-file-p'.
X			   (or (< (car newsrc-mod) (car quick-mod))
X			       (and (= (car newsrc-mod) (car quick-mod))
X				    (<= (nth 1 newsrc-mod) (nth 1 quick-mod))))
X			   ))
X		  quick-loaded
X		  gnus-newsrc-assoc	;Really loaded?
X		  )
X	     ;; We don't have to read the raw startup file.
X	     )
X	    (t
X	     ;; Since .newsrc file is newer than quick file, read it.
X	     (message "Reading %s..." newsrc-file)
X	     (gnus-newsrc-to-gnus-format)
X	     (gnus-check-killed-newsgroups)
X	     (message "Reading %s... Done" newsrc-file)))
X      )))
X
X(defun gnus-make-newsrc-file (file)
X  "Make server dependent file name by catenating FILE and server host name."
X  (let* ((file (expand-file-name file nil))
X	 (real-file (concat file "-" gnus-nntp-server)))
X    (if (file-exists-p real-file)
X	real-file file)
X    ))
X
X(defun gnus-newsrc-to-gnus-format ()
X  "Parse current buffer as .newsrc file."
X  (let ((newsgroup nil)
X	(subscribe nil)
X	(ranges nil)
X	(subrange nil)
X	(read-list nil))
X    ;; We have to re-initialize these variable (except for
X    ;; gnus-marked-assoc and gnus-killed-assoc) because quick startup
X    ;; file may contain bogus values.
X    (setq gnus-newsrc-options nil)
X    (setq gnus-newsrc-options-n-yes nil)
X    (setq gnus-newsrc-options-n-no nil)
X    (setq gnus-newsrc-assoc nil)
X    ;; Save options line to variable.
X    ;; Lines beginning with white spaces are treated as continuation
X    ;; line.  Refer man page of newsrc(5).
X    (goto-char (point-min))
X    (if (re-search-forward
X	 "^[ \t]*options[ \t]*\\(.*\\(\n[ \t]+.*\\)*\\)[ \t]*$" nil t)
X	(progn
X	  ;; Save entire options line.
X	  (setq gnus-newsrc-options
X		(buffer-substring (match-beginning 1) (match-end 1)))
X	  ;; Compile "-n" option.
X	  (if (string-match "\\(^\\|[ \t\n]\\)-n" gnus-newsrc-options)
X	      (let ((yes-and-no
X		     (gnus-parse-n-options
X		      (substring gnus-newsrc-options (match-end 0)))))
X		(setq gnus-newsrc-options-n-yes (car yes-and-no))
X		(setq gnus-newsrc-options-n-no  (cdr yes-and-no))
X		))
X	  ))
X    ;; Parse body of .newsrc file
X    ;; Options line continuation lines must be also considered here.
X    ;; Before supporting continuation lines, " newsgroup ! 1-5" was
X    ;; okay, but now it is invalid.  It should be "newsgroup! 1-5".
X    (goto-char (point-min))
X    ;; Due to overflows in regex.c, change the following regexp:
X    ;; "^\\([^:! \t\n]+\\)\\([:!]\\)[ \t]*\\(.*\\)$"
X    ;; Suggested by composer@bucsf.bu.edu (Jeff Kellem).
X    (while (re-search-forward
X	    "^\\([^:! \t\n]+\\)\\([:!]\\)[ \t]*\\(\\(...\\)*.*\\)$" nil t)
X      (setq newsgroup (buffer-substring (match-beginning 1) (match-end 1)))
X      ;; Check duplications of newsgroups.
X      ;; Note: Checking the duplications takes very long time.
X      (if (assoc newsgroup gnus-newsrc-assoc)
X	  (message "Ignore duplicated newsgroup: %s" newsgroup)
X	(setq subscribe
X	      (string-equal
X	       ":" (buffer-substring (match-beginning 2) (match-end 2))))
X	(setq ranges (buffer-substring (match-beginning 3) (match-end 3)))
X	(setq read-list nil)
X	(while (string-match "^[, \t]*\\([0-9-]+\\)" ranges)
X	  (setq subrange (substring ranges (match-beginning 1) (match-end 1)))
X	  (setq ranges (substring ranges (match-end 1)))
X	  (cond ((string-match "^\\([0-9]+\\)-\\([0-9]+\\)$" subrange)
X		 (setq read-list
X		       (cons
X			(cons (string-to-int
X			       (substring subrange
X					  (match-beginning 1) (match-end 1)))
X			      (string-to-int
X			       (substring subrange
X					  (match-beginning 2) (match-end 2))))
X			read-list)))
X		((string-match "^[0-9]+$" subrange)
X		 (setq read-list
X		       (cons (cons (string-to-int subrange)
X				   (string-to-int subrange))
X			     read-list)))
X		(t
X		 (ding) (message "Ignoring bogus lines of %s" newsgroup)
X		 (sit-for 0))
X		))
X	(setq gnus-newsrc-assoc
X	      (cons (cons newsgroup (cons subscribe (nreverse read-list)))
X		    gnus-newsrc-assoc))
X	))
X    (setq gnus-newsrc-assoc
X	  (nreverse gnus-newsrc-assoc))
X    ))
X
X(defun gnus-parse-n-options (options)
X  "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
X  (let ((yes nil)
X	(no nil)
X	(yes-or-no nil)			;`!' or not.
X	(newsgroup nil))
X    ;; Parse each newsgroup description such as "comp.all".  Commas
X    ;; and white spaces can be a newsgroup separator.
X    (while
X	(string-match "^[ \t\n,]*\\(!?\\)\\([^--- \t\n,][^ \t\n,]*\\)" options)
X      (setq yes-or-no
X	    (substring options (match-beginning 1) (match-end 1)))
X      (setq newsgroup
X	    (regexp-quote
X	     (substring options
X			(match-beginning 2) (match-end 2))))
X      (setq options (substring options (match-end 2)))
X      ;; Rewrite "all" to ".+" not ".*".  ".+" requires at least one
X      ;; character.
X      (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
X	(setq newsgroup
X	      (concat (substring newsgroup 0 (match-end 1))
X		      ".+"
X		      (substring newsgroup (match-beginning 2)))))
X      (cond ((string-equal yes-or-no "!")
X	     (setq no (cons newsgroup no)))
X	    ((string-equal newsgroup ".+")) ;Ignore `all'.
X	    (t
X	     (setq yes (cons newsgroup yes)))
X	    ))
X    ;; Make a cons of regexps from parsing result.
X    (cons (if yes
X	      (concat "^\\("
X		      (apply (function concat)
X			     (mapcar
X			      (function
X			       (lambda (newsgroup)
X				 (concat newsgroup "\\|")))
X			      (cdr yes)))
X		      (car yes) "\\)"))
X	  (if no
X	      (concat "^\\("
X		      (apply (function concat)
X			     (mapcar
X			      (function
X			       (lambda (newsgroup)
X				 (concat newsgroup "\\|")))
X			      (cdr no)))
X		      (car no) "\\)")))
X    ))
X
X(defun gnus-save-newsrc-file ()
X  "Save to .newsrc FILE."
X  ;; Note: We cannot save .newsrc file if all newsgroups are removed
X  ;; from the variable gnus-newsrc-assoc.
X  (and (or gnus-newsrc-assoc gnus-killed-assoc)
X       gnus-current-startup-file
X       (save-excursion
X	 ;; A buffer containing .newsrc file may be deleted.
X	 (set-buffer (find-file-noselect gnus-current-startup-file))
X	 (if (not (buffer-modified-p))
X	     (message "(No changes need to be saved)")
X	   (message "Saving %s..." gnus-current-startup-file)
X	   (let ((make-backup-files t)
X		 (version-control nil)
X		 (require-final-newline t)) ;Don't ask even if requested.
X	     ;; Make backup file of master newsrc.
X	     ;; You can stop or change version control of backup file.
X	     ;; Suggested by jason@violet.berkeley.edu.
X	     (run-hooks 'gnus-Save-newsrc-hook)
X	     (save-buffer))
X	   ;; Quickly loadable .newsrc.
X	   (set-buffer (get-buffer-create " *GNUS-newsrc*"))
X	   (buffer-flush-undo (current-buffer))
X	   (erase-buffer)
X	   (gnus-gnus-to-quick-newsrc-format)
X	   (let ((make-backup-files nil)
X		 (version-control nil)
X		 (require-final-newline t)) ;Don't ask even if requested.
X	     (write-file (concat gnus-current-startup-file ".el")))
X	   (kill-buffer (current-buffer))
X	   (message "Saving %s... Done" gnus-current-startup-file)
X	   ))
X    ))
X
X(defun gnus-update-newsrc-buffer (group &optional delete next)
X  "Incrementally update .newsrc buffer about GROUP.
XIf optional 1st argument DELETE is non-nil, delete the group.
XIf optional 2nd argument NEXT is non-nil, inserted before it."
X  (save-excursion
X    ;; Taking account of the killed startup file.
X    ;; Suggested by tale@pawl.rpi.edu.
X    (set-buffer (or (get-file-buffer gnus-current-startup-file)
X		    (find-file-noselect gnus-current-startup-file)))
X    ;; Options line continuation lines must be also considered here.
X    ;; Before supporting continuation lines, " newsgroup ! 1-5" was
X    ;; okay, but now it is invalid.  It should be "newsgroup! 1-5".
X    (let ((deleted nil)
X	  (buffer-read-only nil))	;May be not modifiable.
X      ;; Delete ALL entries which match for GROUP.
X      (goto-char (point-min))
X      (while (re-search-forward
X	      (concat "^" (regexp-quote group) "[:!]") nil t)
X	(beginning-of-line)
X	(delete-region (point) (progn (forward-line 1) (point)))
X	(setq deleted t)		;Old entry is deleted.
X	)
X      (if delete
X	  nil
X	;; Insert group entry.
X	(let ((newsrc (assoc group gnus-newsrc-assoc)))
X	  (if (null newsrc)
X	      nil
X	    ;; Find insertion point.
X	    (cond (deleted nil)		;Insert here.
X		  ((and (stringp next)
X			(progn
X			  (goto-char (point-min))
X			  (re-search-forward
X			   (concat "^" (regexp-quote next) "[:!]") nil t)))
X		   (beginning-of-line))
X		  (t
X		   (goto-char (point-max))
X		   (or (bolp)
X		       (insert "\n"))))
X	    ;; Insert after options line.
X	    (if (looking-at "^[ \t]*options\\([ \t]\\|$\\)")
X		(progn
X		  (forward-line 1)
X		  ;; Skip continuation lines.
X		  (while (and (not (eobp))
X			      (looking-at "^[ \t]+"))
X		    (forward-line 1))))
X	    (insert group		;Group name
X		    (if (nth 1 newsrc) ": " "! ")) ;Subscribed?
X	    (gnus-ranges-to-newsrc-format (nthcdr 2 newsrc)) ;Read articles
X	    (insert "\n")
X	    )))
X      )))
X
X(defun gnus-gnus-to-quick-newsrc-format ()
X  "Insert GNUS variables such as gnus-newsrc-assoc in lisp format."
X  (insert ";; GNUS internal format of .newsrc.\n")
X  (insert ";; Touch .newsrc instead if you think to remove this file.\n")
X  (let ((variable nil)
X	(variables gnus-variable-list)
X	;; Temporary rebind to make changes invisible.
X	(gnus-killed-assoc gnus-killed-assoc))
X    ;; Remove duplicated or unsubscribed newsgroups in gnus-killed-assoc.
X    (gnus-check-killed-newsgroups)
X    ;; Then, insert lisp expressions.
X    (while variables
X      (setq variable (car variables))
X      (and (boundp variable)
X	   (symbol-value variable)
X	   (insert "(setq " (symbol-name variable) " '"
X		   (prin1-to-string (symbol-value variable))
X		   ")\n"))
X      (setq variables (cdr variables)))
X    ))
X
X(defun gnus-ranges-to-newsrc-format (ranges)
X  "Insert ranges of read articles."
X  (let ((range nil))			;Range is a pair of BEGIN and END.
X    (while ranges
X      (setq range (car ranges))
X      (setq ranges (cdr ranges))
X      (cond ((= (car range) (cdr range))
X	     (if (= (car range) 0)
X		 (setq ranges nil)	;No unread articles.
X	       (insert (int-to-string (car range)))
X	       (if ranges (insert ","))
X	       ))
X	    (t
X	     (insert (int-to-string (car range))
X		     "-"
X		     (int-to-string (cdr range)))
X	     (if ranges (insert ","))
X	     ))
X      )))
X
X(defun gnus-compress-sequence (numbers)
X  "Convert list of sorted numbers to ranges."
X  (let* ((numbers (sort (copy-sequence numbers) (function <)))
X	 (first (car numbers))
X	 (last (car numbers))
X	 (result nil))
X    (while numbers
X      (cond ((= last (car numbers)) nil) ;Omit duplicated number
X	    ((= (1+ last) (car numbers)) ;Still in sequence
X	     (setq last (car numbers)))
X	    (t				;End of one sequence
X	     (setq result (cons (cons first last) result))
X	     (setq first (car numbers))
X	     (setq last  (car numbers)))
X	    )
X      (setq numbers (cdr numbers))
X      )
X    (nreverse (cons (cons first last) result))
X    ))
X
X(defun gnus-uncompress-sequence (ranges)
X  "Expand compressed format of sequence."
X  (let ((first nil)
X	(last  nil)
X	(result nil))
X    (while ranges
X      (setq first (car (car ranges)))
X      (setq last  (cdr (car ranges)))
X      (while (< first last)
X	(setq result (cons first result))
X	(setq first (1+ first)))
X      (setq result (cons first result))
X      (setq ranges (cdr ranges))
X      )
X    (nreverse result)
X    ))
X
X(defun gnus-number-of-articles (range)
X  "Compute number of articles from RANGE `((beg1 . end1) (beg2 . end2) ...)'."
X  (let ((count 0))
X    (while range
X      (if (/= (cdr (car range)) 0)
X	  ;; If end1 is 0, it must be skipped. Usually no articles in
X	  ;;  this group.
X	  (setq count (+ count 1 (- (cdr (car range)) (car (car range))))))
X      (setq range (cdr range))
X      )
X    count				;Result
X    ))
X
X(defun gnus-difference-of-range (src obj)
X  "Compute (SRC - OBJ) on range.
XRange of SRC is expressed as `(beg . end)'.
XRange of OBJ is expressed as `((beg1 . end1) (beg2 . end2) ...)."
X  (let ((beg (car src))
X	(end (cdr src))
X	(range nil))			;This is result.
X    ;; Src may be nil.
X    (while (and src obj)
X      (let ((beg1 (car (car obj)))
X	    (end1 (cdr (car obj))))
X	(cond ((> beg end)
X	       (setq obj nil))		;Terminate loop
X	      ((< beg beg1)
X	       (setq range (cons (cons beg (min (1- beg1) end)) range))
X	       (setq beg (1+ end1)))
X	      ((>= beg beg1)
X	       (setq beg (max beg (1+ end1))))
X	      )
X	(setq obj (cdr obj))		;Next OBJ
X	))
X    ;; Src may be nil.
X    (if (and src (<= beg end))
X	(setq range (cons (cons beg end) range)))
X    ;; Result
X    (if range
X	(nreverse range)
X      (list (cons 0 0)))
X    ))
X
X
X;;Local variables:
X;;eval: (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
X;;end:
SHAR_EOF
chmod 0644 gnus.el || echo "restore of gnus.el fails"
set `wc -c gnus.el`;Sum=$1
if test "$Sum" != "225947"
then echo original size 225947, current size $Sum;fi
sed 's/^X//' << 'SHAR_EOF' > gnusmail.el &&
X;;; Mail reply commands for GNUS newsreader
X;; Copyright (C) 1990 Masanobu UMEDA
X;; $Header: gnusmail.el,v 1.1 90/03/23 13:24:39 umerin Locked $
X
X;; This file is part of GNU Emacs.
X
X;; GNU Emacs is distributed in the hope that it will be useful,
X;; but WITHOUT ANY WARRANTY.  No author or distributor
X;; accepts responsibility to anyone for the consequences of using it
X;; or for whether it serves any particular purpose or works at all,
X;; unless he says so in writing.  Refer to the GNU Emacs General Public
X;; License for full details.
X
X;; Everyone is granted permission to copy, modify and redistribute
X;; GNU Emacs, but only under the conditions described in the
X;; GNU Emacs General Public License.   A copy of this license is
X;; supposed to have been given to you along with GNU Emacs so you
X;; can know your rights and responsibilities.  It should be in a
X;; file named COPYING.  Among other things, the copyright notice
X;; and this notice must be preserved on all copies.
X
X(provide 'gnusmail)
X(require 'gnus)
X
X;; Provides mail reply and mail other window command using usual mail
X;; interface and mh-e interface.
X;; 
X;; To use MAIL: set the variables gnus-mail-reply-method and
X;; gnus-mail-other-window-method to gnus-mail-reply-using-mail and
X;; gnus-mail-other-window-using-mail, respectively.
X;;
X;; To use MH-E: set the variables gnus-mail-reply-method and
X;; gnus-mail-other-window-method to gnus-mail-reply-using-mhe and
X;; gnus-mail-other-window-using-mhe, respectively.
X
X(autoload 'news-mail-reply "rnewspost")
X(autoload 'news-mail-other-window "rnewspost")
X
X(autoload 'mh-send "mh-e")
X(autoload 'mh-send-other-window "mh-e")
X(autoload 'mh-find-path "mh-e")
X(autoload 'mh-yank-cur-msg "mh-e")
X
X;;; Mail reply commands of GNUS Subject Mode
X
X(defun gnus-Subject-mail-reply (yank)
X  "Reply mail to news author.
XIf prefix argument YANK is non-nil, original article is yanked automatically.
XCustomize the variable gnus-mail-reply-method to use another mailer."
X  (interactive "P")
X  (gnus-Subject-select-article)
X  (switch-to-buffer gnus-Article-buffer)
X  (widen)
X  (delete-other-windows)
X  (bury-buffer gnus-Article-buffer)
X  (funcall gnus-mail-reply-method yank))
X
X(defun gnus-Subject-mail-reply-with-original ()
X  "Reply mail to news author with original article."
X  (interactive)
X  (gnus-Subject-mail-reply t))
X
X(defun gnus-Subject-mail-other-window ()
X  "Compose mail in other window.
XCustomize the variable gnus-mail-other-window-method to use another mailer."
X  (interactive)
X  (gnus-Subject-select-article)
X  (switch-to-buffer gnus-Article-buffer)
X  (widen)
X  (delete-other-windows)
X  (bury-buffer gnus-Article-buffer)
X  (funcall gnus-mail-other-window-method))
X
X
X;;; Send mail using sendmail mail mode.
X
X(defun gnus-mail-reply-using-mail (&optional yank)
X  "Compose reply mail using mail.
XOptional argument YANK means yank original article."
X  (news-mail-reply)
X  (gnus-overload-functions)
X  (if yank
X      (let ((last (point)))
X	(goto-char (point-max))
X	(mail-yank-original nil)
X	(goto-char last)
X	)))
X
X(defun gnus-mail-other-window-using-mail ()
X  "Compose mail other window using mail."
X  (news-mail-other-window)
X  (gnus-overload-functions))
X
X
X;;; Send mail using mh-e.
X
X;; The following mh-e interface is all cooperative works of
X;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
X;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
X;; SHINGU).
X
X(defun gnus-mail-reply-using-mhe (&optional yank)
X  "Compose reply mail using mh-e.
XOptional argument YANK means yank original article.
XThe command \\[mh-yank-cur-msg] yank the original message into current buffer."
X  ;; First of all, prepare mhe mail buffer.
X  (let (from cc subject date to reply-to (buffer (current-buffer)))
X    (save-restriction
X      (gnus-Article-show-all-headers)	;I don't think this is really needed.
X      (setq from (gnus-fetch-field "from")
X	    subject (let ((subject (gnus-fetch-field "subject")))
X		      (if (and subject
X			       (not (string-match "^[Rr][Ee]:.+$" subject)))
X			  (concat "Re: " subject) subject))
X	    reply-to (gnus-fetch-field "reply-to")
X	    cc (gnus-fetch-field "cc")
X	    date (gnus-fetch-field "date"))
X      (setq mh-show-buffer buffer)
X      (setq to (or reply-to from))
X      (mh-find-path)
X      (mh-send to (or cc "") subject)
X      (save-excursion
X	(mh-insert-fields
X	 "In-reply-to:"
X	 (concat
X	  (substring from 0 (string-match "  *at \\|  *@ \\| *(\\| *<" from))
X	  "'s message of " date)))
X      (setq mh-sent-from-folder buffer)
X      (setq mh-sent-from-msg 1)
X      ))
X  ;; Then, yank original article if requested.
X  (if yank
X      (let ((last (point)))
X	(mh-yank-cur-msg)
X	(goto-char last)
X	)))
X
X(defun gnus-mail-other-window-using-mhe ()
X  "Compose mail other window using mh-e."
X  (let ((to (read-string "To: "))
X	(cc (read-string "Cc: "))
X	(subject (read-string "Subject: " (gnus-fetch-field "subject"))))
X    (gnus-Article-show-all-headers)	;I don't think this is really needed.
X    (setq mh-show-buffer (current-buffer))
X    (mh-find-path)
X    (mh-send-other-window to cc subject)
X    (setq mh-sent-from-folder (current-buffer))
X    (setq mh-sent-from-msg 1)))
SHAR_EOF
chmod 0644 gnusmail.el || echo "restore of gnusmail.el fails"
set `wc -c gnusmail.el`;Sum=$1
if test "$Sum" != "5140"
then echo original size 5140, current size $Sum;fi
sed 's/^X//' << 'SHAR_EOF' > gnusmisc.el &&
X;;; Miscellaneous commands for GNUS newsreader
X;; Copyright (C) 1989 Fujitsu Laboratories LTD.
X;; Copyright (C) 1989, 1990 Masanobu UMEDA
X;; $Header: gnusmisc.el,v 1.2 90/03/23 13:25:04 umerin Locked $
X
X;; This file is part of GNU Emacs.
X
X;; GNU Emacs is distributed in the hope that it will be useful,
X;; but WITHOUT ANY WARRANTY.  No author or distributor
X;; accepts responsibility to anyone for the consequences of using it
X;; or for whether it serves any particular purpose or works at all,
X;; unless he says so in writing.  Refer to the GNU Emacs General Public
X;; License for full details.
X
X;; Everyone is granted permission to copy, modify and redistribute
X;; GNU Emacs, but only under the conditions described in the
X;; GNU Emacs General Public License.   A copy of this license is
X;; supposed to have been given to you along with GNU Emacs so you
X;; can know your rights and responsibilities.  It should be in a
X;; file named COPYING.  Among other things, the copyright notice
X;; and this notice must be preserved on all copies.
X
X(provide 'gnusmisc)
X(require 'gnus)
X
X;;;
X;;; GNUS Browse-Killed Mode
X;;;
X
X;; Some ideas are due to roland@wheaties.ai.mit.edu (Roland McGrath).
X;; I'd like to thank him very much.
X
X(defvar gnus-Browse-killed-mode-hook nil
X  "*A hook for GNUS Browse-Killed Mode.")
X
X(defvar gnus-Browse-killed-buffer "*Killed Newsgroup*")
X(defvar gnus-Browse-killed-mode-map nil)
X(defvar gnus-winconf-browse-killed nil)
X
X(put 'gnus-Browse-killed-mode 'mode-class 'special)
X
X;; Make the buffer to be managed by GNUS.
X
X(or (memq gnus-Browse-killed-buffer gnus-buffer-list)
X    (setq gnus-buffer-list
X	  (cons gnus-Browse-killed-buffer gnus-buffer-list)))
X
X(if gnus-Browse-killed-mode-map
X    nil
X  (setq gnus-Browse-killed-mode-map (make-keymap))
X  (suppress-keymap gnus-Browse-killed-mode-map t)
X  (define-key gnus-Browse-killed-mode-map " " 'gnus-Group-next-group)
X  (define-key gnus-Browse-killed-mode-map "\177" 'gnus-Group-prev-group)
X  (define-key gnus-Browse-killed-mode-map "\C-n" 'gnus-Group-next-group)
X  (define-key gnus-Browse-killed-mode-map "\C-p" 'gnus-Group-prev-group)
X  (define-key gnus-Browse-killed-mode-map "n" 'gnus-Group-next-group)
X  (define-key gnus-Browse-killed-mode-map "p" 'gnus-Group-prev-group)
X  (define-key gnus-Browse-killed-mode-map "y" 'gnus-Browse-killed-yank)
X  (define-key gnus-Browse-killed-mode-map "\C-y" 'gnus-Browse-killed-yank)
X  (define-key gnus-Browse-killed-mode-map "l" 'gnus-Browse-killed-groups)
X  (define-key gnus-Browse-killed-mode-map "q" 'gnus-Browse-killed-exit)
X  (define-key gnus-Browse-killed-mode-map "\C-c\C-c" 'gnus-Browse-killed-exit)
X  (define-key gnus-Browse-killed-mode-map "\C-c\C-i" 'gnus-Info-find-node))
X
X(defun gnus-Browse-killed-mode ()
X  "Major mode for browsing the killed newsgroups.
XAll normal editing commands are turned off.
XInstead, these commands are available:
X\\{gnus-Browse-killed-mode-map}
X
XThe killed newsgroups are saved in the quick startup file (.newsrc.el)
Xunless it against the options line in the startup file (.newsrc).
X
XEntry to this mode calls gnus-Browse-killed-mode-hook with no arguments,
Xif that value is non-nil."
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	(t
X	 (setq mode-line-format
X	       "--- GNUS: Killed Newsgroups  %[(%m)%]----%3p-%-")))
X  (setq major-mode 'gnus-Browse-killed-mode)
X  (setq mode-name "Browse-Killed")
X  (setq mode-line-buffer-identification	"GNUS: Killed Newsgroups")
X  (use-local-map gnus-Browse-killed-mode-map)
X  (buffer-flush-undo (current-buffer))
X  (setq buffer-read-only t)		;Disable modification
X  (run-hooks 'gnus-Browse-killed-mode-hook))
X
X(defun gnus-Browse-killed-groups ()
X  "Browse the killed newsgroups.
XThe keys y and C-y yank the newsgroup on the current line into the
XNewsgroups buffer."
X  (interactive)
X  (or gnus-killed-assoc
X      (error "No killed newsgroups"))
X  ;; Save current window configuration if this is first invocation..
X  (or (get-buffer-window gnus-Browse-killed-buffer)
X      (setq gnus-winconf-browse-killed
X	    (current-window-configuration)))
X  ;; Prepare browsing buffer.
X  (pop-to-buffer (get-buffer-create gnus-Browse-killed-buffer))
X  (gnus-Browse-killed-mode)
X  (let ((buffer-read-only nil)
X	(killed-assoc gnus-killed-assoc))
X    (erase-buffer)
X    (while killed-assoc
X      (insert (gnus-Group-prepare-line (car killed-assoc)))
X      (setq killed-assoc (cdr killed-assoc)))
X    (goto-char (point-min))
X    ))
X
X(defun gnus-Browse-killed-yank ()
X  "Yank current newsgroup to Newsgroup buffer."
X  (interactive)
X  (let ((group (gnus-Group-group-name)))
X    (if group
X	(let* ((buffer-read-only nil)
X	       (killed (assoc group gnus-killed-assoc)))
X	  (pop-to-buffer gnus-Group-buffer) ;Needed to adjust point.
X	  (if killed
X	      (gnus-Group-insert-group killed))
X	  (pop-to-buffer gnus-Browse-killed-buffer)
X	  (beginning-of-line)
X	  (delete-region (point)
X			 (progn (forward-line 1) (point)))
X	  )))
X  (gnus-Browse-killed-check-buffer))
X
X(defun gnus-Browse-killed-check-buffer ()
X  "Exit if the buffer is empty by deleting the window and killing the buffer."
X  (and (null gnus-killed-assoc)
X       (get-buffer gnus-Browse-killed-buffer)
X       (gnus-Browse-killed-exit)))
X
X(defun gnus-Browse-killed-exit ()
X  "Exit this mode by deleting the window and killing the buffer."
X  (interactive)
X  (and (get-buffer-window gnus-Browse-killed-buffer)
X       (delete-window (get-buffer-window gnus-Browse-killed-buffer)))
X  (kill-buffer gnus-Browse-killed-buffer)
X  ;; Restore previous window configuration if available.
X  (and gnus-winconf-browse-killed
X       (set-window-configuration gnus-winconf-browse-killed))
X  (setq gnus-winconf-browse-killed nil))
X
X
X;;;
X;;; kill/yank newsgroup commands of GNUS Group Mode
X;;;
X
X(defun gnus-Group-kill-group (n)
X  "Kill newsgroup on current line, repeated prefix argument N times.
XThe killed newsgroups can be yanked by using \\[gnus-Group-yank-group]."
X  (interactive "p")
X  (let ((buffer-read-only nil)
X	(group nil))
X    (while (> n 0)
X      (setq group (gnus-Group-group-name))
X      (or group
X	  (signal 'end-of-buffer nil))
X      (beginning-of-line)
X      (delete-region (point)
X		     (progn (forward-line 1) (point)))
X      (gnus-kill-newsgroup group)
X      (setq n (1- n))
X      ;; Add to killed newsgroups in the buffer if exists.
X      (if (get-buffer gnus-Browse-killed-buffer)
X	  (save-excursion
X	    (set-buffer gnus-Browse-killed-buffer)
X	    (let ((buffer-read-only nil))
X	      (goto-char (point-min))
X	      (insert (gnus-Group-prepare-line (car gnus-killed-assoc)))
X	      )))
X      )
X    (search-forward ":" nil t)
X    ))
X
X(defun gnus-Group-yank-group ()
X  "Yank the last newsgroup killed with \\[gnus-Group-kill-group],
Xinserting it before the newsgroup on the line containging point."
X  (interactive)
X  (gnus-Group-insert-group (car gnus-killed-assoc))
X  ;; Remove killed newsgroups from the buffer if exists.
X  (if (get-buffer gnus-Browse-killed-buffer)
X      (save-excursion
X	(set-buffer gnus-Browse-killed-buffer)
X	(let ((buffer-read-only nil))
X	  (goto-char (point-min))
X	  (delete-region (point-min)
X			 (progn (forward-line 1) (point)))
X	  )))
X  (gnus-Browse-killed-check-buffer))
X
X(defun gnus-Group-insert-group (info)
X  "Insert newsgroup at current line using gnus-newsrc-assoc INFO."
X  (if (null gnus-killed-assoc)
X      (error "No killed newsgroups"))
X  (if (not gnus-have-all-newsgroups)
X      (error
X       (substitute-command-keys
X	"Not all newsgroups are displayed.  Type \\[gnus-Group-list-all-groups] to display all newsgroups.")))
X  (let ((buffer-read-only nil)
X	(group (gnus-Group-group-name)))
X    (gnus-insert-newsgroup info group)
X    (beginning-of-line)
X    (insert (gnus-Group-prepare-line info))
X    (forward-line -1)
X    (search-forward ":" nil t)
X    ))
SHAR_EOF
chmod 0644 gnusmisc.el || echo "restore of gnusmisc.el fails"
set `wc -c gnusmisc.el`;Sum=$1
if test "$Sum" != "7966"
then echo original size 7966, current size $Sum;fi
sed 's/^X//' << 'SHAR_EOF' > gnuspost.el &&
X;;; Post news commands for GNUS newsreader
X;; Copyright (C) 1989 Fujitsu Laboratories LTD.
X;; Copyright (C) 1989, 1990 Masanobu UMEDA
X;; $Header: gnuspost.el,v 1.2 90/03/23 13:25:16 umerin Locked $
X
X;; This file is part of GNU Emacs.
X
X;; GNU Emacs is distributed in the hope that it will be useful,
X;; but WITHOUT ANY WARRANTY.  No author or distributor
X;; accepts responsibility to anyone for the consequences of using it
X;; or for whether it serves any particular purpose or works at all,
X;; unless he says so in writing.  Refer to the GNU Emacs General Public
X;; License for full details.
X
X;; Everyone is granted permission to copy, modify and redistribute
X;; GNU Emacs, but only under the conditions described in the
X;; GNU Emacs General Public License.   A copy of this license is
X;; supposed to have been given to you along with GNU Emacs so you
X;; can know your rights and responsibilities.  It should be in a
X;; file named COPYING.  Among other things, the copyright notice
X;; and this notice must be preserved on all copies.
X
X(provide 'gnuspost)
X(require 'gnus)
X
X(defvar gnus-organization-file "/usr/lib/news/organization"
X  "*Local news organization file.")
X
X(defvar gnus-post-news-buffer "*post-news*")
X(defvar gnus-winconf-post-news nil)
X
X(autoload 'news-reply-mode "rnewspost")
X
X;;; Post news commands of GNUS Group Mode and Subject Mode
X
X(defun gnus-Group-post-news ()
X  "Post an article."
X  (interactive)
X  ;; Save window configuration.
X  (setq gnus-winconf-post-news (current-window-configuration))
X  (unwind-protect
X      (gnus-post-news)
X    (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
X	     (not (zerop (buffer-size))))
X	;; Restore last window configuration.
X	(set-window-configuration gnus-winconf-post-news)))
X  ;; We don't want to return to Subject buffer nor Article buffer later.
X  (if (get-buffer gnus-Subject-buffer)
X      (bury-buffer gnus-Subject-buffer))
X  (if (get-buffer gnus-Article-buffer)
X      (bury-buffer gnus-Article-buffer)))
X
X(defun gnus-Subject-post-news ()
X  "Post an article."
X  (interactive)
X  (gnus-Subject-select-article t nil)
X  ;; Save window configuration.
X  (setq gnus-winconf-post-news (current-window-configuration))
X  (unwind-protect
X      (progn
X	(switch-to-buffer gnus-Article-buffer)
X	(widen)
X	(delete-other-windows)
X	(gnus-post-news))
X    (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
X	     (not (zerop (buffer-size))))
X	;; Restore last window configuration.
X	(set-window-configuration gnus-winconf-post-news)))
X  ;; We don't want to return to Article buffer later.
X  (bury-buffer gnus-Article-buffer))
X
X(defun gnus-Subject-post-reply (yank)
X  "Post a reply article.
XIf prefix argument YANK is non-nil, original article is yanked automatically."
X  (interactive "P")
X  (gnus-Subject-select-article t nil)
X  ;; Check Followup-To: poster.
X  (set-buffer gnus-Article-buffer)
X  (if (and gnus-use-followup-to
X	   (string-equal "poster" (gnus-fetch-field "followup-to"))
X	   (or (not (eq gnus-use-followup-to t))
X	       (not (y-or-n-p "Do you want to ignore `Followup-To: poster'? "))))
X      ;; Mail to the poster.  GNUS is now RFC1036 compliant.
X      (gnus-Subject-mail-reply yank)
X    ;; Save window configuration.
X    (setq gnus-winconf-post-news (current-window-configuration))
X    (unwind-protect
X	(progn
X	  (switch-to-buffer gnus-Article-buffer)
X	  (widen)
X	  (delete-other-windows)
X	  (gnus-news-reply yank))
X      (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
X	       (not (zerop (buffer-size))))
X	  ;; Restore last window configuration.
X	  (set-window-configuration gnus-winconf-post-news)))
X    ;; We don't want to return to Article buffer later.
X    (bury-buffer gnus-Article-buffer)))
X
X(defun gnus-Subject-post-reply-with-original ()
X  "Post a reply article with original article."
X  (interactive)
X  (gnus-Subject-post-reply t))
X
X(defun gnus-Subject-cancel-article ()
X  "Cancel an article you posted."
X  (interactive)
X  (gnus-Subject-select-article t nil)
X  (gnus-eval-in-buffer-window gnus-Article-buffer
X    (gnus-cancel-news)))
X
X
X;;; Post a News using NNTP
X
X(defun gnus-post-news ()
X  "Begin editing a new USENET news article to be posted.
XType \\[describe-mode] once editing the article to get a list of commands."
X  (interactive)
X  (if (or (not gnus-novice-user)
X	  (y-or-n-p "Are you sure you want to post to all of USENET? "))
X      (let ((artbuf (current-buffer))
X	    (newsgroups			;Default newsgroup.
X	     (if (eq major-mode 'gnus-Article-mode) gnus-newsgroup-name))
X	    (subject nil)
X	    (distribution nil))
X	(save-restriction
X	  (and (not (zerop (buffer-size)))
X	       ;;(equal major-mode 'news-mode)
X	       (equal major-mode 'gnus-Article-mode)
X	       (progn
X		 ;;(news-show-all-headers)
X		 (gnus-Article-show-all-headers)
X		 (narrow-to-region (point-min)
X				   (progn (goto-char (point-min))
X					  (search-forward "\n\n")
X					  (point)))))
X	  (setq news-reply-yank-from (mail-fetch-field "from"))
X	  (setq news-reply-yank-message-id (mail-fetch-field "message-id")))
X	(pop-to-buffer gnus-post-news-buffer)
X	(news-reply-mode)
X	(gnus-overload-functions)
X	(if (and (buffer-modified-p)
X		 (> (buffer-size) 0)
X		 (not (y-or-n-p "Unsent article being composed; erase it? ")))
X	    ;; Continue composition.
X	    ;; Make news-reply-yank-original work on the current article.
X	    (setq mail-reply-buffer artbuf)
X	  (erase-buffer)
X	  (if gnus-interactive-post
X	      ;; Newsgroups, subject and distribution are asked for.
X	      ;; Suggested by yuki@flab.fujitsu.junet.
X	      (progn
X		;; Subscribed newsgroup names are required for
X		;; completing read of newsgroup.
X		(or gnus-newsrc-assoc
X		    (gnus-read-newsrc-file))
X		;; Which do you like? (UMERIN)
X		;; (setq newsgroups (read-string "Newsgroups: " "general"))
X		(or newsgroups		;Use the default newsgroup.
X		    (setq newsgroups
X			  (completing-read "Newsgroup: " gnus-newsrc-assoc
X					   nil 'require-match
X					   newsgroups ;Default newsgroup.
X					   )))
X		(setq subject (read-string "Subject: "))
X		(setq distribution
X		      (substring newsgroups 0 (string-match "\\." newsgroups)))
X		(if (string-equal distribution newsgroups)
X		    ;; Newsgroup may be general or control. In this
X		    ;; case, use default distribution.
X		    (setq distribution gnus-default-distribution))
X		(setq distribution
X		      (read-string "Distribution: " distribution))
X		;; An empty string is ok to ignore gnus-default-distribution.
X		;;(if (string-equal distribution "")
X		;;    (setq distribution nil))
X		))
X	  (news-setup () subject () newsgroups artbuf)
X	  ;; Make sure the article is posted by GNUS.
X	  ;;(mail-position-on-field "Posting-Software")
X	  ;;(insert "GNUS: NNTP-based News Reader for GNU Emacs")
X	  ;; Insert Distribution: field.
X	  ;; Suggested by ichikawa@flab.fujitsu.junet.
X	  (mail-position-on-field "Distribution")
X	  (insert (or distribution gnus-default-distribution ""))
X	  ;; Handle author copy using FCC field.
X	  (if gnus-author-copy
X	      (progn
X		(mail-position-on-field "FCC")
X		(insert gnus-author-copy)))
X	  (if gnus-interactive-post
X	      ;; All fields are filled in.
X	      (goto-char (point-max))
X	    ;; Move point to Newsgroup: field.
X	    (goto-char (point-min))
X	    (end-of-line))
X	  ))
X    (message "")))
X
X(defun gnus-news-reply (&optional yank)
X  "Compose and post a reply (aka a followup) to the current article on USENET.
XWhile composing the followup, use \\[news-reply-yank-original] to yank the
Xoriginal message into it."
X  (interactive)
X  (if (or (not gnus-novice-user)
X	  (y-or-n-p "Are you sure you want to followup to all of USENET? "))
X      (let (from cc subject date to followup-to newsgroups message-of
X		 references distribution message-id
X		 (artbuf (current-buffer)))
X	(save-restriction
X	  (and (not (zerop (buffer-size)))
X	       ;;(equal major-mode 'news-mode)
X	       (equal major-mode 'gnus-Article-mode)
X	       (progn
X		 ;; (news-show-all-headers)
X		 (gnus-Article-show-all-headers)
X		 (narrow-to-region (point-min)
X				   (progn (goto-char (point-min))
X					  (search-forward "\n\n")
X					  (point)))))
X	  (setq from (mail-fetch-field "from"))
X	  (setq	news-reply-yank-from from)
X	  (setq	subject (mail-fetch-field "subject"))
X	  (setq	date (mail-fetch-field "date"))
X	  (setq followup-to (mail-fetch-field "followup-to"))
X	  ;; Ignore Followup-To: poster.
X	  (if (or (null gnus-use-followup-to) ;Ignore followup-to: field.
X		  (string-equal "" followup-to)	;Bogus header.
X		  (string-equal "poster" followup-to))
X	      (setq followup-to nil))
X	  (setq	newsgroups (or followup-to (mail-fetch-field "newsgroups")))
X	  (setq	references (mail-fetch-field "references"))
X	  (setq	distribution (mail-fetch-field "distribution"))
X	  (setq	message-id (mail-fetch-field "message-id"))
X	  (setq	news-reply-yank-message-id message-id))
X	(pop-to-buffer gnus-post-news-buffer)
X	(news-reply-mode)
X	(gnus-overload-functions)
X	(if (and (buffer-modified-p)
X		 (> (buffer-size) 0)
X		 (not (y-or-n-p "Unsent article being composed; erase it? ")))
X	    ;; Continue composition.
X	    ;; Make news-reply-yank-original work on current article.
X	    (setq mail-reply-buffer artbuf)
X	  (erase-buffer)
X	  (and subject
X	       (setq subject
X		     (concat "Re: " (gnus-simplify-subject subject 're-only))))
X	  (and from
X	       (progn
X		 (let ((stop-pos
X			(string-match "  *at \\|  *@ \\| *(\\| *<" from)))
X		   (setq message-of
X			 (concat
X			  (if stop-pos (substring from 0 stop-pos) from)
X			  "'s message of "
X			  date)))))
X	  (news-setup nil subject message-of newsgroups artbuf)
X	  (if followup-to
X	      (progn (news-reply-followup-to)
X		     (insert followup-to)))
X	  ;; Fold long references line to follow RFC1036.
X	  (mail-position-on-field "References")
X	  (let ((begin (point))
X		(fill-column 79)
X		(fill-prefix "\t"))
X	    (if references
X		(insert references))
X	    (if (and references message-id)
X		(insert " "))
X	    (if message-id
X		(insert message-id))
X	    ;; The region must end with a newline to fill the region
X	    ;; without inserting extra newline.
X	    (fill-region-as-paragraph begin (1+ (point))))
X	  ;; Make sure the article is posted by GNUS.
X	  ;;(mail-position-on-field "Posting-Software")
X	  ;;(insert "GNUS: NNTP-based News Reader for GNU Emacs")
X	  ;; Distribution must be the same as original article.
X	  (mail-position-on-field "Distribution")
X	  (insert (or distribution ""))
X	  ;; Handle author copy using FCC field.
SHAR_EOF
echo "End of part 6, continue with part 7"
echo "7" > s2_seq_.tmp
exit 0
--
Masanobu UMEDA
umerin@tc.Nagasaki.GO.JP
